his_api_controller.go 1.6MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014
  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. "strings"
  10. //"crypto/x509/pkix"
  11. "encoding/json"
  12. "fmt"
  13. "gdyb/controllers"
  14. "gdyb/enums"
  15. "gdyb/models"
  16. "gdyb/service"
  17. "gdyb/utils"
  18. "github.com/astaxie/beego"
  19. "github.com/axgle/mahonia"
  20. "github.com/go-ole/go-ole/oleutil"
  21. "github.com/gorilla/websocket"
  22. "github.com/jinzhu/gorm"
  23. "github.com/shopspring/decimal"
  24. "io"
  25. "io/ioutil"
  26. "math/rand"
  27. "net/http"
  28. "net/url"
  29. "os"
  30. "path/filepath"
  31. "regexp"
  32. "strconv"
  33. "syscall"
  34. "time"
  35. "unsafe"
  36. )
  37. type HisApiController struct {
  38. controllers.BaseAuthAPIController
  39. }
  40. func HisManagerApiRegistRouters() {
  41. //挂号
  42. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  43. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  44. //上传就诊信息-上传明细-结算
  45. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  46. //查询
  47. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  48. //对总账
  49. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  50. //对明细
  51. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  52. //退费,退明细
  53. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  54. //退号
  55. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  56. //退明细
  57. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  58. //上传就诊信息-上传明细-预结算
  59. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  60. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  61. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  62. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  63. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  64. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  65. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  66. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  67. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  68. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  69. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  70. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  71. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  72. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  73. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  74. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  75. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  76. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  77. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  78. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  79. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  80. beego.Router("/api/check", &HisApiController{}, "get:Check")
  81. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  82. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  83. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  84. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  85. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  86. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  87. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  88. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  89. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  90. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  91. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  92. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  93. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  94. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  95. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  96. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  97. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  98. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  99. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  100. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  101. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  102. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  103. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  104. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  108. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  109. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  110. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  111. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  112. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  113. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  114. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  115. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  116. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  136. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  137. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  138. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  139. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  140. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  141. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  142. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  143. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  144. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  145. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  146. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  147. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  148. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  149. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  150. //库盘和变更
  151. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  152. //删除库盘和变更
  153. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  154. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  155. //药品变更
  156. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  157. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  158. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  159. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  160. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  161. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  162. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  163. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  164. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  165. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  166. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  167. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  168. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  169. //beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  170. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  171. }
  172. func (c *HisApiController) Get3201() {
  173. adminUser := c.GetAdminUserInfo()
  174. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  175. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  176. var response Response
  177. if err := json.Unmarshal([]byte(result), &response); err != nil {
  178. fmt.Println("Error decoding JSON:", err)
  179. return
  180. }
  181. }
  182. func (c *HisApiController) TestNet() {
  183. c.ServeSuccessJSON(map[string]interface{}{
  184. "msg": "成功",
  185. })
  186. }
  187. func (c *HisApiController) Get3508() {
  188. admin_user_id, _ := c.GetInt64("admin_user_id")
  189. drug_id, _ := c.GetInt64("id")
  190. start_time := c.GetString("start_time")
  191. end_time := c.GetString("end_time")
  192. adminUser := c.GetAdminUserInfo()
  193. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  194. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  195. drug, _ := service.GetDrugByID(drug_id)
  196. var struct3508 models.Struct3508
  197. struct3508.OrgName = miConfig.OrgName
  198. struct3508.FixmedinsCode = miConfig.Code
  199. struct3508.AccessKey = miConfig.AccessKey
  200. struct3508.Opter = curRoles.UserName
  201. struct3508.RequestUrl = miConfig.Url
  202. struct3508.Url = miConfig.Url
  203. struct3508.AppId = miConfig.Cainfo
  204. struct3508.AppSecret = miConfig.AppSecret
  205. struct3508.Enckey = miConfig.EncKey
  206. struct3508.SignKey = miConfig.SignKey
  207. struct3508.SecretKey = miConfig.SecretKey
  208. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  209. struct3508.Begndate = start_time
  210. struct3508.Enddate = end_time
  211. result1, result2, _ := service.FJyb3508(struct3508)
  212. saveLog(result1, result2, "3508", "3508")
  213. var res models.Result3508
  214. var respJSON2 map[string]interface{}
  215. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  218. return
  219. }
  220. userJSONBytes2, _ := json.Marshal(respJSON2)
  221. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  222. utils.ErrorLog("解析失败:%v", err)
  223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  224. return
  225. }
  226. if res.Infcode == -1 {
  227. c.ServeSuccessJSON(map[string]interface{}{
  228. "failed_code": -10,
  229. "msg": res.ErrMsg,
  230. })
  231. } else {
  232. c.ServeSuccessJSON(map[string]interface{}{
  233. "info": res.Output,
  234. })
  235. }
  236. }
  237. func (c *HisApiController) Get3509() {
  238. admin_user_id, _ := c.GetInt64("admin_user_id")
  239. drug_id, _ := c.GetInt64("id")
  240. start_time := c.GetString("start_time")
  241. end_time := c.GetString("end_time")
  242. adminUser := c.GetAdminUserInfo()
  243. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  244. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  245. drug, _ := service.GetDrugByID(drug_id)
  246. var struct3508 models.Struct3509
  247. struct3508.OrgName = miConfig.OrgName
  248. struct3508.FixmedinsCode = miConfig.Code
  249. struct3508.AccessKey = miConfig.AccessKey
  250. struct3508.Opter = curRoles.UserName
  251. struct3508.RequestUrl = miConfig.Url
  252. struct3508.Url = miConfig.Url
  253. struct3508.AppId = miConfig.Cainfo
  254. struct3508.AppSecret = miConfig.AppSecret
  255. struct3508.Enckey = miConfig.EncKey
  256. struct3508.SignKey = miConfig.SignKey
  257. struct3508.SecretKey = miConfig.SecretKey
  258. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  259. struct3508.Begndate = start_time
  260. struct3508.Enddate = end_time
  261. result1, result2, _ := service.FJyb3509(struct3508)
  262. saveLog(result1, result2, "3509", "3509")
  263. var res models.Result3509
  264. var respJSON2 map[string]interface{}
  265. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  268. return
  269. }
  270. userJSONBytes2, _ := json.Marshal(respJSON2)
  271. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  272. utils.ErrorLog("解析失败:%v", err)
  273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  274. return
  275. }
  276. if res.Infcode == -1 {
  277. c.ServeSuccessJSON(map[string]interface{}{
  278. "failed_code": -10,
  279. "msg": res.ErrMsg,
  280. })
  281. } else {
  282. c.ServeSuccessJSON(map[string]interface{}{
  283. "info": res.Output,
  284. })
  285. }
  286. }
  287. func (c *HisApiController) Get3510() {
  288. admin_user_id, _ := c.GetInt64("admin_user_id")
  289. drug_id, _ := c.GetInt64("id")
  290. start_time := c.GetString("start_time")
  291. end_time := c.GetString("end_time")
  292. adminUser := c.GetAdminUserInfo()
  293. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  294. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  295. drug, _ := service.GetDrugByID(drug_id)
  296. var struct3508 models.Struct3510
  297. struct3508.FixmedinsCode = miConfig.Code
  298. struct3508.OrgName = miConfig.OrgName
  299. struct3508.AccessKey = miConfig.AccessKey
  300. struct3508.Opter = curRoles.UserName
  301. struct3508.RequestUrl = miConfig.Url
  302. struct3508.Url = miConfig.Url
  303. struct3508.AppId = miConfig.Cainfo
  304. struct3508.AppSecret = miConfig.AppSecret
  305. struct3508.Enckey = miConfig.EncKey
  306. struct3508.SignKey = miConfig.SignKey
  307. struct3508.SecretKey = miConfig.SecretKey
  308. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  309. struct3508.Begndate = start_time
  310. struct3508.Enddate = end_time
  311. result1, result2, _ := service.FJyb3510(struct3508)
  312. saveLog(result1, result2, "3510", "3510")
  313. var res models.Result3510
  314. var respJSON2 map[string]interface{}
  315. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  318. return
  319. }
  320. userJSONBytes2, _ := json.Marshal(respJSON2)
  321. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  322. utils.ErrorLog("解析失败:%v", err)
  323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  324. return
  325. }
  326. if res.Infcode == -1 {
  327. c.ServeSuccessJSON(map[string]interface{}{
  328. "failed_code": -10,
  329. "msg": res.ErrMsg,
  330. })
  331. } else {
  332. c.ServeSuccessJSON(map[string]interface{}{
  333. "info": res.Output,
  334. })
  335. }
  336. }
  337. func (c *HisApiController) Get3511() {
  338. admin_user_id, _ := c.GetInt64("admin_user_id")
  339. drug_id, _ := c.GetInt64("id")
  340. start_time := c.GetString("start_time")
  341. end_time := c.GetString("end_time")
  342. adminUser := c.GetAdminUserInfo()
  343. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  344. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  345. drug, _ := service.GetDrugByID(drug_id)
  346. var struct3508 models.Struct3511
  347. struct3508.FixmedinsCode = miConfig.Code
  348. struct3508.OrgName = miConfig.OrgName
  349. struct3508.AccessKey = miConfig.AccessKey
  350. struct3508.Opter = curRoles.UserName
  351. struct3508.RequestUrl = miConfig.Url
  352. struct3508.Url = miConfig.Url
  353. struct3508.AppId = miConfig.Cainfo
  354. struct3508.AppSecret = miConfig.AppSecret
  355. struct3508.Enckey = miConfig.EncKey
  356. struct3508.SignKey = miConfig.SignKey
  357. struct3508.SecretKey = miConfig.SecretKey
  358. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  359. struct3508.Begndate = start_time
  360. struct3508.Enddate = end_time
  361. result1, result2, _ := service.FJyb3511(struct3508)
  362. saveLog(result1, result2, "3511", "3511")
  363. var res models.Result3511
  364. var respJSON2 map[string]interface{}
  365. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  368. return
  369. }
  370. userJSONBytes2, _ := json.Marshal(respJSON2)
  371. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  372. utils.ErrorLog("解析失败:%v", err)
  373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  374. return
  375. }
  376. if res.Infcode == -1 {
  377. c.ServeSuccessJSON(map[string]interface{}{
  378. "failed_code": -10,
  379. "msg": res.ErrMsg,
  380. })
  381. } else {
  382. c.ServeSuccessJSON(map[string]interface{}{
  383. "info": res.Output,
  384. })
  385. }
  386. }
  387. func (c *HisApiController) Get3512() {
  388. admin_user_id, _ := c.GetInt64("admin_user_id")
  389. drug_id, _ := c.GetInt64("id")
  390. start_time := c.GetString("start_time")
  391. end_time := c.GetString("end_time")
  392. adminUser := c.GetAdminUserInfo()
  393. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  394. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  395. drug, _ := service.GetDrugByID(drug_id)
  396. var struct3508 models.Struct3512
  397. struct3508.FixmedinsCode = miConfig.Code
  398. struct3508.OrgName = miConfig.OrgName
  399. struct3508.AccessKey = miConfig.AccessKey
  400. struct3508.Opter = curRoles.UserName
  401. struct3508.RequestUrl = miConfig.Url
  402. struct3508.Url = miConfig.Url
  403. struct3508.AppId = miConfig.Cainfo
  404. struct3508.AppSecret = miConfig.AppSecret
  405. struct3508.Enckey = miConfig.EncKey
  406. struct3508.SignKey = miConfig.SignKey
  407. struct3508.SecretKey = miConfig.SecretKey
  408. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  409. struct3508.Begndate = start_time
  410. struct3508.Enddate = end_time
  411. result1, result2, _ := service.FJyb3512(struct3508)
  412. saveLog(result1, result2, "3512", "3512")
  413. var res models.Result3512
  414. var respJSON2 map[string]interface{}
  415. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  418. return
  419. }
  420. userJSONBytes2, _ := json.Marshal(respJSON2)
  421. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  422. utils.ErrorLog("解析失败:%v", err)
  423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  424. return
  425. }
  426. if res.Infcode == -1 {
  427. c.ServeSuccessJSON(map[string]interface{}{
  428. "failed_code": -10,
  429. "msg": res.ErrMsg,
  430. })
  431. } else {
  432. c.ServeSuccessJSON(map[string]interface{}{
  433. "info": res.Output,
  434. })
  435. }
  436. }
  437. func (c *HisApiController) Get3513() {
  438. admin_user_id, _ := c.GetInt64("admin_user_id")
  439. drug_id, _ := c.GetInt64("id")
  440. start_time := c.GetString("start_time")
  441. end_time := c.GetString("end_time")
  442. adminUser := c.GetAdminUserInfo()
  443. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  444. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  445. drug, _ := service.GetDrugByID(drug_id)
  446. var struct3508 models.Struct3513
  447. struct3508.FixmedinsCode = miConfig.Code
  448. struct3508.OrgName = miConfig.OrgName
  449. struct3508.AccessKey = miConfig.AccessKey
  450. struct3508.Opter = curRoles.UserName
  451. struct3508.RequestUrl = miConfig.Url
  452. struct3508.Url = miConfig.Url
  453. struct3508.AppId = miConfig.Cainfo
  454. struct3508.AppSecret = miConfig.AppSecret
  455. struct3508.Enckey = miConfig.EncKey
  456. struct3508.SignKey = miConfig.SignKey
  457. struct3508.SecretKey = miConfig.SecretKey
  458. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  459. struct3508.Begndate = start_time
  460. struct3508.Enddate = end_time
  461. result1, result2, _ := service.FJyb3513(struct3508)
  462. saveLog(result1, result2, "3513", "3513")
  463. var res models.Result3513
  464. var respJSON2 map[string]interface{}
  465. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  468. return
  469. }
  470. userJSONBytes2, _ := json.Marshal(respJSON2)
  471. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  472. utils.ErrorLog("解析失败:%v", err)
  473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  474. return
  475. }
  476. if res.Infcode == -1 {
  477. c.ServeSuccessJSON(map[string]interface{}{
  478. "failed_code": -10,
  479. "msg": res.ErrMsg,
  480. })
  481. } else {
  482. c.ServeSuccessJSON(map[string]interface{}{
  483. "info": res.Output,
  484. })
  485. }
  486. }
  487. func (c *HisApiController) Get35081() {
  488. admin_user_id, _ := c.GetInt64("admin_user_id")
  489. drug_id, _ := c.GetInt64("id")
  490. //start_time := c.GetString("start_time")
  491. //end_time := c.GetString("end_time")
  492. page, _ := c.GetInt("page")
  493. adminUser := c.GetAdminUserInfo()
  494. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  495. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  496. drug, _ := service.GetDrugByID(drug_id)
  497. var struct3508 models.Struct35081
  498. struct3508.FixmedinsCode = miConfig.Code
  499. struct3508.OrgName = miConfig.OrgName
  500. struct3508.AccessKey = miConfig.AccessKey
  501. struct3508.Opter = curRoles.UserName
  502. struct3508.RequestUrl = miConfig.Url
  503. struct3508.Url = miConfig.Url
  504. struct3508.AppId = miConfig.Cainfo
  505. struct3508.AppSecret = miConfig.AppSecret
  506. struct3508.Enckey = miConfig.EncKey
  507. struct3508.SignKey = miConfig.SignKey
  508. struct3508.SecretKey = miConfig.SecretKey
  509. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  510. struct3508.PageNum = page
  511. struct3508.PageSize = 10
  512. result1, result2, _ := service.FJyb35081(struct3508)
  513. saveLog(result1, result2, "35081", "35081")
  514. var res models.Result35081
  515. var respJSON2 map[string]interface{}
  516. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  519. return
  520. }
  521. userJSONBytes2, _ := json.Marshal(respJSON2)
  522. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  523. utils.ErrorLog("解析失败:%v", err)
  524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  525. return
  526. }
  527. if res.Infcode == -1 {
  528. c.ServeSuccessJSON(map[string]interface{}{
  529. "failed_code": -10,
  530. "msg": res.ErrMsg,
  531. })
  532. } else {
  533. c.ServeSuccessJSON(map[string]interface{}{
  534. "info": res.Output,
  535. })
  536. }
  537. }
  538. func (c *HisApiController) Get35082() {
  539. admin_user_id, _ := c.GetInt64("admin_user_id")
  540. drug_id, _ := c.GetInt64("id")
  541. //start_time := c.GetString("start_time")
  542. //end_time := c.GetString("end_time")
  543. page, _ := c.GetInt("page")
  544. adminUser := c.GetAdminUserInfo()
  545. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  546. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  547. drug, _ := service.GetDrugByID(drug_id)
  548. var struct3508 models.Struct35082
  549. struct3508.FixmedinsCode = miConfig.Code
  550. struct3508.OrgName = miConfig.OrgName
  551. struct3508.AccessKey = miConfig.AccessKey
  552. struct3508.Opter = curRoles.UserName
  553. struct3508.RequestUrl = miConfig.Url
  554. struct3508.Url = miConfig.Url
  555. struct3508.AppId = miConfig.Cainfo
  556. struct3508.AppSecret = miConfig.AppSecret
  557. struct3508.Enckey = miConfig.EncKey
  558. struct3508.SignKey = miConfig.SignKey
  559. struct3508.SecretKey = miConfig.SecretKey
  560. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  561. struct3508.PageNum = page
  562. struct3508.PageSize = 10
  563. result1, result2, _ := service.FJyb35082(struct3508)
  564. saveLog(result1, result2, "35082", "35082")
  565. var res models.Result35082
  566. var respJSON2 map[string]interface{}
  567. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  570. return
  571. }
  572. userJSONBytes2, _ := json.Marshal(respJSON2)
  573. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  574. utils.ErrorLog("解析失败:%v", err)
  575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  576. return
  577. }
  578. if res.Infcode == -1 {
  579. c.ServeSuccessJSON(map[string]interface{}{
  580. "failed_code": -10,
  581. "msg": res.ErrMsg,
  582. })
  583. } else {
  584. c.ServeSuccessJSON(map[string]interface{}{
  585. "info": res.Output,
  586. })
  587. }
  588. }
  589. func (c *HisApiController) FJ3501AND3502() {
  590. ids := c.GetString("ids")
  591. admin_user_id, _ := c.GetInt64("admin_user_id")
  592. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  593. id_arr := strings.Split(ids, ",")
  594. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  595. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  596. //库盘
  597. var errs []string
  598. for _, drug := range drugs {
  599. if drug.IsPc == 0 && drug.IsBg == 0 {
  600. var res2 ResultSix
  601. var res3 ResultSix
  602. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  603. var struct3501 models.Struct3501
  604. struct3501.Code = miConfig.Code
  605. struct3501.OrgName = miConfig.OrgName
  606. struct3501.AccessKey = miConfig.AccessKey
  607. struct3501.Opter = roles.UserName
  608. struct3501.RequestUrl = miConfig.Url
  609. struct3501.Url = miConfig.Url
  610. struct3501.AppId = miConfig.Cainfo
  611. struct3501.AppSecret = miConfig.AppSecret
  612. struct3501.Enckey = miConfig.EncKey
  613. struct3501.SignKey = miConfig.SignKey
  614. struct3501.SecretKey = miConfig.SecretKey
  615. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  616. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  617. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  618. struct3501.RxFlag = "1"
  619. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  620. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  621. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  622. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  623. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  624. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  625. struct3501.FixmedinsBchno = number
  626. struct3501.DrugTracCodg = drug.DrugCode
  627. memo := make(map[string]interface{})
  628. memo["pric"] = drug.Price
  629. bytesData, _ := json.Marshal(memo)
  630. struct3501.Memo = string(bytesData)
  631. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  632. result1, result2, _ := service.FJyb3501(struct3501)
  633. saveLog(result1, result2, "3501", "3501")
  634. //saveLog(result, requestLog, "2201", "挂号")
  635. var respJSON2 map[string]interface{}
  636. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  639. return
  640. }
  641. userJSONBytes2, _ := json.Marshal(respJSON2)
  642. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  643. utils.ErrorLog("解析失败:%v", err)
  644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  645. return
  646. }
  647. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  648. data := make(map[string]interface{})
  649. data["struct_3501s"] = struct3501
  650. client := &http.Client{}
  651. bytesData, _ := json.Marshal(data)
  652. var req *http.Request
  653. if miConfig.MdtrtareaAdmvs == "320921" {
  654. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  655. } else {
  656. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  657. }
  658. resp, _ := client.Do(req)
  659. defer resp.Body.Close()
  660. body, ioErr := ioutil.ReadAll(resp.Body)
  661. if ioErr != nil {
  662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  663. }
  664. var respJSON map[string]interface{}
  665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  668. return
  669. }
  670. var resSix10265 ResultSix10265 //1101结果
  671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  672. result, _ := json.Marshal(respJSON)
  673. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  674. utils.ErrorLog("解析失败:%v", err)
  675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  676. return
  677. }
  678. res2.InfRefmsgid = resSix10265.InfRefmsgid
  679. res2.Output = resSix10265.Output
  680. res2.ErrMsg = resSix10265.ErrMsg
  681. res2.Cainfo = resSix10265.Cainfo
  682. res2.WarnMsg = resSix10265.WarnMsg
  683. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  684. res2.Infcode = infocode
  685. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  686. data := make(map[string]interface{})
  687. data["struct_3501s"] = struct3501
  688. client := &http.Client{}
  689. bytesData, _ := json.Marshal(data)
  690. var req *http.Request
  691. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  692. resp, _ := client.Do(req)
  693. defer resp.Body.Close()
  694. body, ioErr := ioutil.ReadAll(resp.Body)
  695. if ioErr != nil {
  696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  697. }
  698. var respJSON map[string]interface{}
  699. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  702. return
  703. }
  704. var resSix10265 ResultSix10265 //1101结果
  705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  706. result, _ := json.Marshal(respJSON)
  707. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  708. utils.ErrorLog("解析失败:%v", err)
  709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  710. return
  711. }
  712. res2.InfRefmsgid = resSix10265.InfRefmsgid
  713. res2.Output = resSix10265.Output
  714. res2.ErrMsg = resSix10265.ErrMsg
  715. res2.Cainfo = resSix10265.Cainfo
  716. res2.WarnMsg = resSix10265.WarnMsg
  717. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  718. res2.Infcode = infocode
  719. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  720. data := make(map[string]interface{})
  721. data["struct_3501s"] = struct3501
  722. client := &http.Client{}
  723. bytesData, _ := json.Marshal(data)
  724. var req *http.Request
  725. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  726. resp, _ := client.Do(req)
  727. defer resp.Body.Close()
  728. body, ioErr := ioutil.ReadAll(resp.Body)
  729. if ioErr != nil {
  730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  731. }
  732. var respJSON map[string]interface{}
  733. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  736. return
  737. }
  738. var resSix10265 ResultSix10265 //1101结果
  739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  740. result, _ := json.Marshal(respJSON)
  741. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  742. utils.ErrorLog("解析失败:%v", err)
  743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  744. return
  745. }
  746. res2.InfRefmsgid = resSix10265.InfRefmsgid
  747. res2.Output = resSix10265.Output
  748. res2.ErrMsg = resSix10265.ErrMsg
  749. res2.Cainfo = resSix10265.Cainfo
  750. res2.WarnMsg = resSix10265.WarnMsg
  751. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  752. res2.Infcode = infocode
  753. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  754. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  755. saveLog(result1, result2, "3501", "3501")
  756. //saveLog(result, requestLog, "2201", "挂号")
  757. var respJSON2 map[string]interface{}
  758. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  761. return
  762. }
  763. userJSONBytes2, _ := json.Marshal(respJSON2)
  764. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  765. utils.ErrorLog("解析失败:%v", err)
  766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  767. return
  768. }
  769. }
  770. if res2.Infcode != -1 {
  771. drug.IsPc = 1
  772. drug.Bchno = number
  773. drug.PcDate = time.Now().Unix()
  774. err := service.SaveW(drug)
  775. if err == nil {
  776. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  777. var struct3502 models.Struct3502
  778. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  779. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  780. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  781. struct3502.FixmedinsCode = miConfig.Code
  782. struct3502.Code = miConfig.Code
  783. struct3502.RxFlag = "0"
  784. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  785. struct3502.OrgName = miConfig.OrgName
  786. struct3502.Opter = roles.UserName
  787. struct3502.AccessKey = miConfig.AccessKey
  788. struct3502.RequestUrl = miConfig.Url
  789. struct3502.SecretKey = miConfig.SecretKey
  790. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  791. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  792. struct3502.Url = miConfig.Url
  793. struct3502.AppId = miConfig.Cainfo
  794. struct3502.AppSecret = miConfig.AppSecret
  795. struct3502.Enckey = miConfig.EncKey
  796. struct3502.SignKey = miConfig.SignKey
  797. struct3502.SecretKey = miConfig.SecretKey
  798. struct3502.DrugTracCodg = drug.DrugCode
  799. struct3502.Memo = ""
  800. struct3502.InvChgType = "108"
  801. struct3502.FixmedinsBchno = bg_number
  802. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  803. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  804. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  805. result11, result22, _ := service.FJyb3502(struct3502)
  806. saveLog(result11, result22, "3502", "3502")
  807. var respJSON3 map[string]interface{}
  808. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  811. return
  812. }
  813. userJSONBytes3, _ := json.Marshal(respJSON3)
  814. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  815. utils.ErrorLog("解析失败:%v", err)
  816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  817. return
  818. }
  819. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  820. data := make(map[string]interface{})
  821. data["struct_3502s"] = struct3502
  822. client := &http.Client{}
  823. bytesData, _ := json.Marshal(data)
  824. var req *http.Request
  825. if miConfig.MdtrtareaAdmvs == "320921" {
  826. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  827. } else {
  828. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  829. }
  830. resp, _ := client.Do(req)
  831. defer resp.Body.Close()
  832. body, ioErr := ioutil.ReadAll(resp.Body)
  833. if ioErr != nil {
  834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  835. }
  836. var respJSON map[string]interface{}
  837. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  840. return
  841. }
  842. var resSix10265 ResultSix10265 //1101结果
  843. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  844. result, _ := json.Marshal(respJSON)
  845. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  846. utils.ErrorLog("解析失败:%v", err)
  847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  848. return
  849. }
  850. res3.InfRefmsgid = resSix10265.InfRefmsgid
  851. res3.Output = resSix10265.Output
  852. res3.ErrMsg = resSix10265.ErrMsg
  853. res3.Cainfo = resSix10265.Cainfo
  854. res3.WarnMsg = resSix10265.WarnMsg
  855. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  856. res3.Infcode = infocode
  857. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  858. data := make(map[string]interface{})
  859. data["struct_3502s"] = struct3502
  860. client := &http.Client{}
  861. bytesData, _ := json.Marshal(data)
  862. var req *http.Request
  863. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  864. resp, _ := client.Do(req)
  865. defer resp.Body.Close()
  866. body, ioErr := ioutil.ReadAll(resp.Body)
  867. if ioErr != nil {
  868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  869. }
  870. var respJSON map[string]interface{}
  871. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  874. return
  875. }
  876. var resSix10265 ResultSix10265 //1101结果
  877. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  878. result, _ := json.Marshal(respJSON)
  879. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  880. utils.ErrorLog("解析失败:%v", err)
  881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  882. return
  883. }
  884. res3.InfRefmsgid = resSix10265.InfRefmsgid
  885. res3.Output = resSix10265.Output
  886. res3.ErrMsg = resSix10265.ErrMsg
  887. res3.Cainfo = resSix10265.Cainfo
  888. res3.WarnMsg = resSix10265.WarnMsg
  889. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  890. res3.Infcode = infocode
  891. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  892. data := make(map[string]interface{})
  893. data["struct_3501s"] = struct3501
  894. client := &http.Client{}
  895. bytesData, _ := json.Marshal(data)
  896. var req *http.Request
  897. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  898. resp, _ := client.Do(req)
  899. defer resp.Body.Close()
  900. body, ioErr := ioutil.ReadAll(resp.Body)
  901. if ioErr != nil {
  902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  903. }
  904. var respJSON map[string]interface{}
  905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  908. return
  909. }
  910. var resSix10265 ResultSix10265 //1101结果
  911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  912. result, _ := json.Marshal(respJSON)
  913. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  914. utils.ErrorLog("解析失败:%v", err)
  915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  916. return
  917. }
  918. res2.InfRefmsgid = resSix10265.InfRefmsgid
  919. res2.Output = resSix10265.Output
  920. res2.ErrMsg = resSix10265.ErrMsg
  921. res2.Cainfo = resSix10265.Cainfo
  922. res2.WarnMsg = resSix10265.WarnMsg
  923. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  924. res2.Infcode = infocode
  925. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  926. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  927. saveLog(result11, result22, "3502", "3502")
  928. var respJSON3 map[string]interface{}
  929. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  932. return
  933. }
  934. userJSONBytes3, _ := json.Marshal(respJSON3)
  935. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  936. utils.ErrorLog("解析失败:%v", err)
  937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  938. return
  939. }
  940. }
  941. if res3.Infcode == -1 {
  942. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  943. c.ServeSuccessJSON(map[string]interface{}{
  944. "failed_code": -10,
  945. "msg": res3.ErrMsg,
  946. })
  947. } else {
  948. drug.IsBg = 1
  949. drug.BgBchno = bg_number
  950. service.SaveW(drug)
  951. }
  952. }
  953. } else {
  954. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  955. }
  956. }
  957. //变更
  958. if drug.IsPc == 1 && drug.IsBg == 0 {
  959. var res3 ResultSix
  960. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  961. var struct3502 models.Struct3502
  962. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  963. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  964. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  965. struct3502.FixmedinsCode = miConfig.Code
  966. struct3502.Code = miConfig.Code
  967. struct3502.Opter = roles.UserName
  968. struct3502.RxFlag = "0"
  969. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  970. struct3502.OrgName = miConfig.OrgName
  971. struct3502.AccessKey = miConfig.AccessKey
  972. struct3502.RequestUrl = miConfig.Url
  973. struct3502.SecretKey = miConfig.SecretKey
  974. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  975. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  976. struct3502.InvChgType = "108"
  977. struct3502.DrugTracCodg = drug.DrugCode
  978. struct3502.Url = miConfig.Url
  979. struct3502.AppId = miConfig.Cainfo
  980. struct3502.AppSecret = miConfig.AppSecret
  981. struct3502.Enckey = miConfig.EncKey
  982. struct3502.SignKey = miConfig.SignKey
  983. struct3502.SecretKey = miConfig.SecretKey
  984. struct3502.FixmedinsBchno = bg_number
  985. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  986. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  987. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  988. result1, result2, _ := service.FJyb3502(struct3502)
  989. saveLog(result1, result2, "3502", "3502")
  990. var respJSON3 map[string]interface{}
  991. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  994. return
  995. }
  996. userJSONBytes3, _ := json.Marshal(respJSON3)
  997. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  998. utils.ErrorLog("解析失败:%v", err)
  999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1000. return
  1001. }
  1002. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1003. data := make(map[string]interface{})
  1004. data["struct_3502s"] = struct3502
  1005. client := &http.Client{}
  1006. bytesData, _ := json.Marshal(data)
  1007. var req *http.Request
  1008. if miConfig.MdtrtareaAdmvs == "320921" {
  1009. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1010. } else {
  1011. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1012. }
  1013. resp, _ := client.Do(req)
  1014. defer resp.Body.Close()
  1015. body, ioErr := ioutil.ReadAll(resp.Body)
  1016. if ioErr != nil {
  1017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1018. }
  1019. var respJSON map[string]interface{}
  1020. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1023. return
  1024. }
  1025. var resSix10265 ResultSix10265 //1101结果
  1026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1027. result, _ := json.Marshal(respJSON)
  1028. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1029. utils.ErrorLog("解析失败:%v", err)
  1030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1031. return
  1032. }
  1033. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1034. res3.Output = resSix10265.Output
  1035. res3.ErrMsg = resSix10265.ErrMsg
  1036. res3.Cainfo = resSix10265.Cainfo
  1037. res3.WarnMsg = resSix10265.WarnMsg
  1038. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1039. res3.Infcode = infocode
  1040. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1041. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1042. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  1043. }
  1044. if res3.Infcode == -1 {
  1045. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1046. } else {
  1047. drug.IsBg = 1
  1048. drug.BgBchno = bg_number
  1049. service.SaveW(drug)
  1050. }
  1051. }
  1052. }
  1053. if len(errs) == 0 {
  1054. c.ServeSuccessJSON(map[string]interface{}{
  1055. "msg": "盘存变更成功",
  1056. })
  1057. } else {
  1058. c.ServeSuccessJSON(map[string]interface{}{
  1059. "failed_code": -10,
  1060. "msg": errs,
  1061. })
  1062. }
  1063. }
  1064. func (c *HisApiController) DeletePCandBG() {
  1065. ids := c.GetString("ids")
  1066. id_arr := strings.Split(ids, ",")
  1067. admin_user_id, _ := c.GetInt64("admin_user_id")
  1068. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1069. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1070. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1071. var err []string
  1072. for _, item := range drugs {
  1073. if item.IsPc == 1 && item.IsBg == 1 {
  1074. var res FJ3507Result
  1075. var res2 FJ3507Result
  1076. var struct3507 models.Struct3507
  1077. struct3507.FixmedinsBchno = item.Bchno
  1078. struct3507.InvDataType = "1"
  1079. struct3507.Opter = roles.UserName
  1080. struct3507.OrgName = miConfig.OrgName
  1081. struct3507.AccessKey = miConfig.AccessKey
  1082. struct3507.RequestUrl = miConfig.Url
  1083. struct3507.FixmedinsCode = miConfig.Code
  1084. struct3507.Code = miConfig.Code
  1085. struct3507.SecretKey = miConfig.SecretKey
  1086. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1087. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1088. struct3507.Url = miConfig.Url
  1089. struct3507.AppId = miConfig.Cainfo
  1090. struct3507.AppSecret = miConfig.AppSecret
  1091. struct3507.Enckey = miConfig.EncKey
  1092. struct3507.SignKey = miConfig.SignKey
  1093. struct3507.SecretKey = miConfig.SecretKey
  1094. if miConfig.MdtrtareaAdmvs == "350500" {
  1095. result, result1, _ := service.FJyb3507(struct3507)
  1096. saveLog(result, result1, "3507", "3507")
  1097. var respJSON2 map[string]interface{}
  1098. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1101. return
  1102. }
  1103. userJSONBytes2, _ := json.Marshal(respJSON2)
  1104. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1105. utils.ErrorLog("解析失败:%v", err)
  1106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1107. return
  1108. }
  1109. } else {
  1110. data := make(map[string]interface{})
  1111. data["struct_3507s"] = struct3507
  1112. client := &http.Client{}
  1113. bytesData, _ := json.Marshal(data)
  1114. var req *http.Request
  1115. if miConfig.MdtrtareaAdmvs == "320921" {
  1116. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1117. } else {
  1118. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1119. }
  1120. resp, _ := client.Do(req)
  1121. defer resp.Body.Close()
  1122. body, ioErr := ioutil.ReadAll(resp.Body)
  1123. if ioErr != nil {
  1124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1125. }
  1126. var respJSON map[string]interface{}
  1127. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1130. return
  1131. }
  1132. var resSix10265 ResultSix10265 //1101结果
  1133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1134. result, _ := json.Marshal(respJSON)
  1135. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1136. utils.ErrorLog("解析失败:%v", err)
  1137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1138. return
  1139. }
  1140. res.InfRefmsgid = resSix10265.InfRefmsgid
  1141. //res.Output = resSix10265.Output
  1142. res.ErrMsg = resSix10265.ErrMsg
  1143. res.Cainfo = resSix10265.Cainfo
  1144. res.WarnMsg = resSix10265.WarnMsg
  1145. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1146. res.Infcode = infocode
  1147. }
  1148. if res.Infcode == 0 {
  1149. item.IsPc = 0
  1150. err2 := service.SaveW(item)
  1151. if err2 == nil {
  1152. var struct3507_2 models.Struct3507
  1153. struct3507_2.OrgName = miConfig.OrgName
  1154. struct3507_2.AccessKey = miConfig.AccessKey
  1155. struct3507_2.RequestUrl = miConfig.Url
  1156. struct3507_2.Opter = roles.UserName
  1157. struct3507_2.FixmedinsCode = miConfig.Code
  1158. struct3507_2.Code = miConfig.Code
  1159. struct3507_2.SecretKey = miConfig.SecretKey
  1160. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1161. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1162. struct3507_2.Url = miConfig.Url
  1163. struct3507_2.AppId = miConfig.Cainfo
  1164. struct3507_2.AppSecret = miConfig.AppSecret
  1165. struct3507_2.Enckey = miConfig.EncKey
  1166. struct3507_2.SignKey = miConfig.SignKey
  1167. struct3507_2.SecretKey = miConfig.SecretKey
  1168. struct3507_2.FixmedinsBchno = item.BgBchno
  1169. struct3507_2.InvDataType = "2"
  1170. if miConfig.MdtrtareaAdmvs == "350500" {
  1171. result11, result22, _ := service.FJyb3507(struct3507_2)
  1172. saveLog(result11, result22, "3507", "3507")
  1173. var respJSON3 map[string]interface{}
  1174. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1177. return
  1178. }
  1179. userJSONBytes3, _ := json.Marshal(respJSON3)
  1180. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1181. utils.ErrorLog("解析失败:%v", err)
  1182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1183. return
  1184. }
  1185. } else {
  1186. data := make(map[string]interface{})
  1187. data["struct_3507s"] = struct3507_2
  1188. client := &http.Client{}
  1189. bytesData, _ := json.Marshal(data)
  1190. var req *http.Request
  1191. if miConfig.MdtrtareaAdmvs == "320921" {
  1192. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1193. } else {
  1194. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1195. }
  1196. resp, _ := client.Do(req)
  1197. defer resp.Body.Close()
  1198. body, ioErr := ioutil.ReadAll(resp.Body)
  1199. if ioErr != nil {
  1200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1201. }
  1202. var respJSON map[string]interface{}
  1203. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1206. return
  1207. }
  1208. var resSix10265 ResultSix10265 //1101结果
  1209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1210. result, _ := json.Marshal(respJSON)
  1211. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1212. utils.ErrorLog("解析失败:%v", err)
  1213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1214. return
  1215. }
  1216. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1217. //res2.Output = resSix10265.Output
  1218. res2.ErrMsg = resSix10265.ErrMsg
  1219. res2.Cainfo = resSix10265.Cainfo
  1220. res2.WarnMsg = resSix10265.WarnMsg
  1221. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1222. res2.Infcode = infocode
  1223. }
  1224. if res2.Infcode != -1 {
  1225. item.IsBg = 0
  1226. item.Bchno = ""
  1227. item.BgBchno = ""
  1228. item.PcDate = 0
  1229. service.SaveW(item)
  1230. } else {
  1231. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1232. }
  1233. }
  1234. } else {
  1235. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1236. }
  1237. }
  1238. if item.IsPc == 1 && item.IsBg == 0 {
  1239. var res FJ3507Result
  1240. var struct3507 models.Struct3507
  1241. struct3507.FixmedinsBchno = item.Bchno
  1242. struct3507.InvDataType = "1"
  1243. struct3507.Opter = roles.UserName
  1244. struct3507.FixmedinsCode = miConfig.Code
  1245. struct3507.Code = miConfig.Code
  1246. struct3507.OrgName = miConfig.OrgName
  1247. struct3507.AccessKey = miConfig.AccessKey
  1248. struct3507.RequestUrl = miConfig.Url
  1249. struct3507.SecretKey = miConfig.SecretKey
  1250. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1251. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1252. struct3507.Url = miConfig.Url
  1253. struct3507.AppId = miConfig.Cainfo
  1254. struct3507.AppSecret = miConfig.AppSecret
  1255. struct3507.Enckey = miConfig.EncKey
  1256. struct3507.SignKey = miConfig.SignKey
  1257. struct3507.SecretKey = miConfig.SecretKey
  1258. //result, result1, _ := service.FJyb3507(struct3507)
  1259. //saveLog(result, result1, "3507", "3507")
  1260. if miConfig.MdtrtareaAdmvs == "350500" {
  1261. result, result1, _ := service.FJyb3507(struct3507)
  1262. saveLog(result, result1, "3507", "3507")
  1263. var respJSON2 map[string]interface{}
  1264. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1267. return
  1268. }
  1269. userJSONBytes2, _ := json.Marshal(respJSON2)
  1270. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1271. utils.ErrorLog("解析失败:%v", err)
  1272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1273. return
  1274. }
  1275. } else {
  1276. data := make(map[string]interface{})
  1277. data["struct_3507s"] = struct3507
  1278. client := &http.Client{}
  1279. bytesData, _ := json.Marshal(data)
  1280. var req *http.Request
  1281. if miConfig.MdtrtareaAdmvs == "320921" {
  1282. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1283. } else {
  1284. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1285. }
  1286. resp, _ := client.Do(req)
  1287. defer resp.Body.Close()
  1288. body, ioErr := ioutil.ReadAll(resp.Body)
  1289. if ioErr != nil {
  1290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1291. }
  1292. var respJSON map[string]interface{}
  1293. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1296. return
  1297. }
  1298. var resSix10265 ResultSix10265 //1101结果
  1299. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1300. result, _ := json.Marshal(respJSON)
  1301. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1302. utils.ErrorLog("解析失败:%v", err)
  1303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1304. return
  1305. }
  1306. res.InfRefmsgid = resSix10265.InfRefmsgid
  1307. //res.Output = resSix10265.Output
  1308. res.ErrMsg = resSix10265.ErrMsg
  1309. res.Cainfo = resSix10265.Cainfo
  1310. res.WarnMsg = resSix10265.WarnMsg
  1311. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1312. res.Infcode = infocode
  1313. }
  1314. if res.Infcode == 0 {
  1315. item.IsPc = 0
  1316. item.Bchno = ""
  1317. item.BgBchno = ""
  1318. item.PcDate = 0
  1319. service.SaveW(item)
  1320. } else {
  1321. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1322. }
  1323. }
  1324. if item.IsPc == 0 && item.IsBg == 1 {
  1325. var res FJ3507Result
  1326. var struct3507 models.Struct3507
  1327. struct3507.FixmedinsBchno = item.BgBchno
  1328. struct3507.InvDataType = "2"
  1329. struct3507.Opter = roles.UserName
  1330. struct3507.FixmedinsCode = miConfig.Code
  1331. struct3507.OrgName = miConfig.OrgName
  1332. struct3507.AccessKey = miConfig.AccessKey
  1333. struct3507.RequestUrl = miConfig.Url
  1334. struct3507.SecretKey = miConfig.SecretKey
  1335. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1336. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1337. struct3507.Url = miConfig.Url
  1338. struct3507.AppId = miConfig.Cainfo
  1339. struct3507.AppSecret = miConfig.AppSecret
  1340. struct3507.Enckey = miConfig.EncKey
  1341. struct3507.SignKey = miConfig.SignKey
  1342. struct3507.SecretKey = miConfig.SecretKey
  1343. //result, result1, _ := service.FJyb3507(struct3507)
  1344. //saveLog(result, result1, "3507", "3507")
  1345. if miConfig.MdtrtareaAdmvs == "350500" {
  1346. result, result1, _ := service.FJyb3507(struct3507)
  1347. saveLog(result, result1, "3507", "3507")
  1348. var respJSON2 map[string]interface{}
  1349. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1352. return
  1353. }
  1354. userJSONBytes2, _ := json.Marshal(respJSON2)
  1355. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1356. utils.ErrorLog("解析失败:%v", err)
  1357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1358. return
  1359. }
  1360. } else {
  1361. data := make(map[string]interface{})
  1362. data["struct_3507s"] = struct3507
  1363. client := &http.Client{}
  1364. bytesData, _ := json.Marshal(data)
  1365. var req *http.Request
  1366. if miConfig.MdtrtareaAdmvs == "320921" {
  1367. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1368. } else {
  1369. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1370. }
  1371. resp, _ := client.Do(req)
  1372. defer resp.Body.Close()
  1373. body, ioErr := ioutil.ReadAll(resp.Body)
  1374. if ioErr != nil {
  1375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1376. }
  1377. var respJSON map[string]interface{}
  1378. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1381. return
  1382. }
  1383. var resSix10265 ResultSix10265 //1101结果
  1384. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1385. result, _ := json.Marshal(respJSON)
  1386. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1387. utils.ErrorLog("解析失败:%v", err)
  1388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1389. return
  1390. }
  1391. res.InfRefmsgid = resSix10265.InfRefmsgid
  1392. //res.Output = resSix10265.Output
  1393. res.ErrMsg = resSix10265.ErrMsg
  1394. res.Cainfo = resSix10265.Cainfo
  1395. res.WarnMsg = resSix10265.WarnMsg
  1396. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1397. res.Infcode = infocode
  1398. }
  1399. if res.Infcode == 0 {
  1400. item.IsBg = 0
  1401. item.Bchno = ""
  1402. item.BgBchno = ""
  1403. item.PcDate = 0
  1404. service.SaveW(item)
  1405. } else {
  1406. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1407. }
  1408. }
  1409. }
  1410. if len(err) == 0 {
  1411. c.ServeSuccessJSON(map[string]interface{}{
  1412. "msg": "删除盘存变更成功",
  1413. })
  1414. } else {
  1415. c.ServeSuccessJSON(map[string]interface{}{
  1416. "failed_code": -10,
  1417. "msg": err,
  1418. })
  1419. }
  1420. }
  1421. func (c *HisApiController) DeleteXSandBG() {
  1422. ids := c.GetString("ids")
  1423. id_arr := strings.Split(ids, ",")
  1424. admin_user_id, _ := c.GetInt64("admin_user_id")
  1425. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1426. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1427. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1428. var err []string
  1429. for _, item := range flows {
  1430. if item.IsSale == 1 && item.IsChange == 1 {
  1431. var res FJ3507Result
  1432. var res2 FJ3507Result
  1433. var struct3507 models.Struct3507
  1434. struct3507.FixmedinsBchno = item.Bchno
  1435. struct3507.InvDataType = "4"
  1436. struct3507.Opter = roles.UserName
  1437. struct3507.OrgName = miConfig.OrgName
  1438. struct3507.AccessKey = miConfig.AccessKey
  1439. struct3507.RequestUrl = miConfig.Url
  1440. struct3507.FixmedinsCode = miConfig.Code
  1441. struct3507.SecretKey = miConfig.SecretKey
  1442. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1443. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1444. struct3507.Url = miConfig.Url
  1445. struct3507.AppId = miConfig.Cainfo
  1446. struct3507.AppSecret = miConfig.AppSecret
  1447. struct3507.Enckey = miConfig.EncKey
  1448. struct3507.SignKey = miConfig.SignKey
  1449. struct3507.SecretKey = miConfig.SecretKey
  1450. //result, result1, _ := service.FJyb3507(struct3507)
  1451. //saveLog(result, result1, "3507", "3507")
  1452. if miConfig.MdtrtareaAdmvs == "350500" {
  1453. result, result1, _ := service.FJyb3507(struct3507)
  1454. saveLog(result, result1, "3507", "3507")
  1455. var respJSON2 map[string]interface{}
  1456. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1459. return
  1460. }
  1461. userJSONBytes2, _ := json.Marshal(respJSON2)
  1462. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1463. utils.ErrorLog("解析失败:%v", err)
  1464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1465. return
  1466. }
  1467. } else {
  1468. data := make(map[string]interface{})
  1469. data["struct_3507s"] = struct3507
  1470. client := &http.Client{}
  1471. bytesData, _ := json.Marshal(data)
  1472. var req *http.Request
  1473. if miConfig.MdtrtareaAdmvs == "320921" {
  1474. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1475. } else {
  1476. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1477. }
  1478. resp, _ := client.Do(req)
  1479. defer resp.Body.Close()
  1480. body, ioErr := ioutil.ReadAll(resp.Body)
  1481. if ioErr != nil {
  1482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1483. }
  1484. var respJSON map[string]interface{}
  1485. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1488. return
  1489. }
  1490. var resSix10265 ResultSix10265 //1101结果
  1491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1492. result, _ := json.Marshal(respJSON)
  1493. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1494. utils.ErrorLog("解析失败:%v", err)
  1495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1496. return
  1497. }
  1498. res.InfRefmsgid = resSix10265.InfRefmsgid
  1499. //res.Output = resSix10265.Output
  1500. res.ErrMsg = resSix10265.ErrMsg
  1501. res.Cainfo = resSix10265.Cainfo
  1502. res.WarnMsg = resSix10265.WarnMsg
  1503. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1504. res.Infcode = infocode
  1505. }
  1506. if res.Infcode == 0 {
  1507. item.IsSale = 0
  1508. item.SaleDate = ""
  1509. item.Bchno = ""
  1510. err2 := service.SaveDF(item)
  1511. if err2 == nil {
  1512. var struct3507_2 models.Struct3507
  1513. struct3507_2.OrgName = miConfig.OrgName
  1514. struct3507_2.AccessKey = miConfig.AccessKey
  1515. struct3507_2.RequestUrl = miConfig.Url
  1516. struct3507_2.Opter = roles.UserName
  1517. struct3507_2.FixmedinsCode = miConfig.Code
  1518. struct3507_2.Code = miConfig.Code
  1519. struct3507_2.SecretKey = miConfig.SecretKey
  1520. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1521. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1522. struct3507_2.Url = miConfig.Url
  1523. struct3507_2.AppId = miConfig.Cainfo
  1524. struct3507_2.AppSecret = miConfig.AppSecret
  1525. struct3507_2.Enckey = miConfig.EncKey
  1526. struct3507_2.SignKey = miConfig.SignKey
  1527. struct3507_2.SecretKey = miConfig.SecretKey
  1528. struct3507_2.FixmedinsBchno = item.BgBchno
  1529. struct3507_2.InvDataType = "2"
  1530. if miConfig.MdtrtareaAdmvs == "350500" {
  1531. result11, result22, _ := service.FJyb3507(struct3507_2)
  1532. saveLog(result11, result22, "3507", "3507")
  1533. var respJSON3 map[string]interface{}
  1534. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1537. return
  1538. }
  1539. userJSONBytes3, _ := json.Marshal(respJSON3)
  1540. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1541. utils.ErrorLog("解析失败:%v", err)
  1542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1543. return
  1544. }
  1545. } else {
  1546. data := make(map[string]interface{})
  1547. data["struct_3507s"] = struct3507_2
  1548. client := &http.Client{}
  1549. bytesData, _ := json.Marshal(data)
  1550. var req *http.Request
  1551. if miConfig.MdtrtareaAdmvs == "320921" {
  1552. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1553. } else {
  1554. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1555. }
  1556. resp, _ := client.Do(req)
  1557. defer resp.Body.Close()
  1558. body, ioErr := ioutil.ReadAll(resp.Body)
  1559. if ioErr != nil {
  1560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1561. }
  1562. var respJSON map[string]interface{}
  1563. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1566. return
  1567. }
  1568. var resSix10265 ResultSix10265 //1101结果
  1569. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1570. result, _ := json.Marshal(respJSON)
  1571. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1572. utils.ErrorLog("解析失败:%v", err)
  1573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1574. return
  1575. }
  1576. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1577. //res.Output = resSix10265.Output
  1578. res2.ErrMsg = resSix10265.ErrMsg
  1579. res2.Cainfo = resSix10265.Cainfo
  1580. res2.WarnMsg = resSix10265.WarnMsg
  1581. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1582. res2.Infcode = infocode
  1583. }
  1584. if res2.Infcode == 0 {
  1585. item.IsChange = 0
  1586. item.BgBchno = ""
  1587. service.SaveDF2(item)
  1588. } else {
  1589. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1590. }
  1591. }
  1592. } else {
  1593. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1594. }
  1595. }
  1596. if item.IsSale == 2 && item.IsChange == 1 {
  1597. var res FJ3507Result
  1598. var res2 FJ3507Result
  1599. var struct3507 models.Struct3507
  1600. struct3507.FixmedinsBchno = item.Bchno
  1601. struct3507.InvDataType = "4"
  1602. struct3507.Opter = roles.UserName
  1603. struct3507.OrgName = miConfig.OrgName
  1604. struct3507.AccessKey = miConfig.AccessKey
  1605. struct3507.RequestUrl = miConfig.Url
  1606. struct3507.FixmedinsCode = miConfig.Code
  1607. struct3507.Code = miConfig.Code
  1608. struct3507.SecretKey = miConfig.SecretKey
  1609. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1610. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1611. struct3507.Url = miConfig.Url
  1612. struct3507.AppId = miConfig.Cainfo
  1613. struct3507.AppSecret = miConfig.AppSecret
  1614. struct3507.Enckey = miConfig.EncKey
  1615. struct3507.SignKey = miConfig.SignKey
  1616. struct3507.SecretKey = miConfig.SecretKey
  1617. //result, result1, _ := service.FJyb3507(struct3507)
  1618. //saveLog(result, result1, "3507", "3507")
  1619. //
  1620. //var respJSON2 map[string]interface{}
  1621. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1622. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1623. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1624. // return
  1625. //}
  1626. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1627. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1628. // utils.ErrorLog("解析失败:%v", err)
  1629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1630. // return
  1631. //}
  1632. if miConfig.MdtrtareaAdmvs == "350500" {
  1633. result, result1, _ := service.FJyb3507(struct3507)
  1634. saveLog(result, result1, "3507", "3507")
  1635. var respJSON2 map[string]interface{}
  1636. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1639. return
  1640. }
  1641. userJSONBytes2, _ := json.Marshal(respJSON2)
  1642. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1643. utils.ErrorLog("解析失败:%v", err)
  1644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1645. return
  1646. }
  1647. } else {
  1648. data := make(map[string]interface{})
  1649. data["struct_3507s"] = struct3507
  1650. client := &http.Client{}
  1651. bytesData, _ := json.Marshal(data)
  1652. var req *http.Request
  1653. if miConfig.MdtrtareaAdmvs == "320921" {
  1654. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1655. } else {
  1656. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1657. }
  1658. resp, _ := client.Do(req)
  1659. defer resp.Body.Close()
  1660. body, ioErr := ioutil.ReadAll(resp.Body)
  1661. if ioErr != nil {
  1662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1663. }
  1664. var respJSON map[string]interface{}
  1665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1668. return
  1669. }
  1670. var resSix10265 ResultSix10265 //1101结果
  1671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1672. result, _ := json.Marshal(respJSON)
  1673. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1674. utils.ErrorLog("解析失败:%v", err)
  1675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1676. return
  1677. }
  1678. res.InfRefmsgid = resSix10265.InfRefmsgid
  1679. //res.Output = resSix10265.Output
  1680. res.ErrMsg = resSix10265.ErrMsg
  1681. res.Cainfo = resSix10265.Cainfo
  1682. res.WarnMsg = resSix10265.WarnMsg
  1683. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1684. res.Infcode = infocode
  1685. }
  1686. if res.Infcode == 0 {
  1687. item.IsSale = 0
  1688. item.SaleDate = ""
  1689. item.Bchno = ""
  1690. err2 := service.SaveDF(item)
  1691. if err2 == nil {
  1692. var struct3507_2 models.Struct3507
  1693. struct3507_2.OrgName = miConfig.OrgName
  1694. struct3507_2.AccessKey = miConfig.AccessKey
  1695. struct3507_2.RequestUrl = miConfig.Url
  1696. struct3507_2.Opter = roles.UserName
  1697. struct3507_2.FixmedinsCode = miConfig.Code
  1698. struct3507_2.Code = miConfig.Code
  1699. struct3507_2.SecretKey = miConfig.SecretKey
  1700. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1701. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1702. struct3507_2.Url = miConfig.Url
  1703. struct3507_2.AppId = miConfig.Cainfo
  1704. struct3507_2.AppSecret = miConfig.AppSecret
  1705. struct3507_2.Enckey = miConfig.EncKey
  1706. struct3507_2.SignKey = miConfig.SignKey
  1707. struct3507_2.SecretKey = miConfig.SecretKey
  1708. struct3507_2.FixmedinsBchno = item.BgBchno
  1709. struct3507_2.InvDataType = "2"
  1710. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1711. //saveLog(result11, result22, "3507", "3507")
  1712. //var respJSON3 map[string]interface{}
  1713. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1714. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1715. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1716. // return
  1717. //}
  1718. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1719. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1720. // utils.ErrorLog("解析失败:%v", err)
  1721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1722. // return
  1723. //}
  1724. if miConfig.MdtrtareaAdmvs == "350500" {
  1725. result11, result22, _ := service.FJyb3507(struct3507_2)
  1726. saveLog(result11, result22, "3507", "3507")
  1727. var respJSON3 map[string]interface{}
  1728. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1731. return
  1732. }
  1733. userJSONBytes3, _ := json.Marshal(respJSON3)
  1734. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1735. utils.ErrorLog("解析失败:%v", err)
  1736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1737. return
  1738. }
  1739. } else {
  1740. data := make(map[string]interface{})
  1741. data["struct_3507s"] = struct3507_2
  1742. client := &http.Client{}
  1743. bytesData, _ := json.Marshal(data)
  1744. var req *http.Request
  1745. if miConfig.MdtrtareaAdmvs == "320921" {
  1746. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1747. } else {
  1748. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1749. }
  1750. resp, _ := client.Do(req)
  1751. defer resp.Body.Close()
  1752. body, ioErr := ioutil.ReadAll(resp.Body)
  1753. if ioErr != nil {
  1754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1755. }
  1756. var respJSON map[string]interface{}
  1757. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1760. return
  1761. }
  1762. var resSix10265 ResultSix10265 //1101结果
  1763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1764. result, _ := json.Marshal(respJSON)
  1765. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1766. utils.ErrorLog("解析失败:%v", err)
  1767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1768. return
  1769. }
  1770. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1771. //res.Output = resSix10265.Output
  1772. res2.ErrMsg = resSix10265.ErrMsg
  1773. res2.Cainfo = resSix10265.Cainfo
  1774. res2.WarnMsg = resSix10265.WarnMsg
  1775. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1776. res2.Infcode = infocode
  1777. }
  1778. if res2.Infcode == 0 {
  1779. item.IsChange = 0
  1780. item.BgBchno = ""
  1781. service.SaveDF2(item)
  1782. } else {
  1783. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1784. }
  1785. }
  1786. } else {
  1787. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1788. }
  1789. }
  1790. if item.IsSale == 1 && item.IsChange == 0 {
  1791. var res FJ3507Result
  1792. var struct3507 models.Struct3507
  1793. struct3507.FixmedinsBchno = item.Bchno
  1794. struct3507.InvDataType = "4"
  1795. struct3507.Opter = roles.UserName
  1796. struct3507.FixmedinsCode = miConfig.Code
  1797. struct3507.Code = miConfig.Code
  1798. struct3507.OrgName = miConfig.OrgName
  1799. struct3507.AccessKey = miConfig.AccessKey
  1800. struct3507.RequestUrl = miConfig.Url
  1801. struct3507.SecretKey = miConfig.SecretKey
  1802. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1803. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1804. struct3507.Url = miConfig.Url
  1805. struct3507.AppId = miConfig.Cainfo
  1806. struct3507.AppSecret = miConfig.AppSecret
  1807. struct3507.Enckey = miConfig.EncKey
  1808. struct3507.SignKey = miConfig.SignKey
  1809. struct3507.SecretKey = miConfig.SecretKey
  1810. //result, result1, _ := service.FJyb3507(struct3507)
  1811. //saveLog(result, result1, "3507", "3507")
  1812. //
  1813. //var respJSON3 map[string]interface{}
  1814. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1815. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1817. // return
  1818. //}
  1819. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1820. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1821. // utils.ErrorLog("解析失败:%v", err)
  1822. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. // return
  1824. //}
  1825. if miConfig.MdtrtareaAdmvs == "350500" {
  1826. result, result1, _ := service.FJyb3507(struct3507)
  1827. saveLog(result, result1, "3507", "3507")
  1828. var respJSON2 map[string]interface{}
  1829. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1832. return
  1833. }
  1834. userJSONBytes2, _ := json.Marshal(respJSON2)
  1835. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1836. utils.ErrorLog("解析失败:%v", err)
  1837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1838. return
  1839. }
  1840. } else {
  1841. data := make(map[string]interface{})
  1842. data["struct_3507s"] = struct3507
  1843. client := &http.Client{}
  1844. bytesData, _ := json.Marshal(data)
  1845. var req *http.Request
  1846. if miConfig.MdtrtareaAdmvs == "320921" {
  1847. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1848. } else {
  1849. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1850. }
  1851. resp, _ := client.Do(req)
  1852. defer resp.Body.Close()
  1853. body, ioErr := ioutil.ReadAll(resp.Body)
  1854. if ioErr != nil {
  1855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1856. }
  1857. var respJSON map[string]interface{}
  1858. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1861. return
  1862. }
  1863. var resSix10265 ResultSix10265 //1101结果
  1864. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1865. result, _ := json.Marshal(respJSON)
  1866. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1867. utils.ErrorLog("解析失败:%v", err)
  1868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1869. return
  1870. }
  1871. res.InfRefmsgid = resSix10265.InfRefmsgid
  1872. //res.Output = resSix10265.Output
  1873. res.ErrMsg = resSix10265.ErrMsg
  1874. res.Cainfo = resSix10265.Cainfo
  1875. res.WarnMsg = resSix10265.WarnMsg
  1876. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1877. res.Infcode = infocode
  1878. }
  1879. if res.Infcode == 0 {
  1880. item.IsSale = 0
  1881. item.SaleDate = ""
  1882. service.SaveDF(item)
  1883. } else {
  1884. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1885. }
  1886. }
  1887. if item.IsSale == 2 && item.IsChange == 0 {
  1888. var res FJ3507Result
  1889. var struct3507 models.Struct3507
  1890. struct3507.FixmedinsBchno = item.Bchno
  1891. struct3507.InvDataType = "4"
  1892. struct3507.Opter = roles.UserName
  1893. struct3507.FixmedinsCode = miConfig.Code
  1894. struct3507.Code = miConfig.Code
  1895. struct3507.OrgName = miConfig.OrgName
  1896. struct3507.AccessKey = miConfig.AccessKey
  1897. struct3507.RequestUrl = miConfig.Url
  1898. struct3507.SecretKey = miConfig.SecretKey
  1899. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1900. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1901. struct3507.Url = miConfig.Url
  1902. struct3507.AppId = miConfig.Cainfo
  1903. struct3507.AppSecret = miConfig.AppSecret
  1904. struct3507.Enckey = miConfig.EncKey
  1905. struct3507.SignKey = miConfig.SignKey
  1906. struct3507.SecretKey = miConfig.SecretKey
  1907. //result, result1, _ := service.FJyb3507(struct3507)
  1908. //saveLog(result, result1, "3507", "3507")
  1909. //
  1910. //var respJSON3 map[string]interface{}
  1911. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1912. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1913. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1914. // return
  1915. //}
  1916. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1917. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1918. // utils.ErrorLog("解析失败:%v", err)
  1919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1920. // return
  1921. //}
  1922. if miConfig.MdtrtareaAdmvs == "350500" {
  1923. result, result1, _ := service.FJyb3507(struct3507)
  1924. saveLog(result, result1, "3507", "3507")
  1925. var respJSON2 map[string]interface{}
  1926. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1929. return
  1930. }
  1931. userJSONBytes2, _ := json.Marshal(respJSON2)
  1932. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1933. utils.ErrorLog("解析失败:%v", err)
  1934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1935. return
  1936. }
  1937. } else {
  1938. data := make(map[string]interface{})
  1939. data["struct_3507s"] = struct3507
  1940. client := &http.Client{}
  1941. bytesData, _ := json.Marshal(data)
  1942. var req *http.Request
  1943. if miConfig.MdtrtareaAdmvs == "320921" {
  1944. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1945. } else {
  1946. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1947. }
  1948. resp, _ := client.Do(req)
  1949. defer resp.Body.Close()
  1950. body, ioErr := ioutil.ReadAll(resp.Body)
  1951. if ioErr != nil {
  1952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1953. }
  1954. var respJSON map[string]interface{}
  1955. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1958. return
  1959. }
  1960. var resSix10265 ResultSix10265 //1101结果
  1961. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1962. result, _ := json.Marshal(respJSON)
  1963. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1964. utils.ErrorLog("解析失败:%v", err)
  1965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1966. return
  1967. }
  1968. res.InfRefmsgid = resSix10265.InfRefmsgid
  1969. //res.Output = resSix10265.Output
  1970. res.ErrMsg = resSix10265.ErrMsg
  1971. res.Cainfo = resSix10265.Cainfo
  1972. res.WarnMsg = resSix10265.WarnMsg
  1973. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1974. res.Infcode = infocode
  1975. }
  1976. if res.Infcode == 0 {
  1977. item.IsSale = 0
  1978. item.SaleDate = ""
  1979. item.Bchno = ""
  1980. service.SaveDF(item)
  1981. } else {
  1982. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1983. }
  1984. }
  1985. if item.IsSale == 0 && item.IsChange == 1 {
  1986. var res FJ3507Result
  1987. var struct3507 models.Struct3507
  1988. struct3507.FixmedinsBchno = item.BgBchno
  1989. struct3507.InvDataType = "2"
  1990. struct3507.Opter = roles.UserName
  1991. struct3507.FixmedinsCode = miConfig.Code
  1992. struct3507.Code = miConfig.Code
  1993. struct3507.OrgName = miConfig.OrgName
  1994. struct3507.AccessKey = miConfig.AccessKey
  1995. struct3507.RequestUrl = miConfig.Url
  1996. struct3507.SecretKey = miConfig.SecretKey
  1997. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1998. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1999. struct3507.Url = miConfig.Url
  2000. struct3507.AppId = miConfig.Cainfo
  2001. struct3507.AppSecret = miConfig.AppSecret
  2002. struct3507.Enckey = miConfig.EncKey
  2003. struct3507.SignKey = miConfig.SignKey
  2004. struct3507.SecretKey = miConfig.SecretKey
  2005. //result, result1, _ := service.FJyb3507(struct3507)
  2006. //saveLog(result, result1, "3507", "3507")
  2007. //
  2008. //var respJSON3 map[string]interface{}
  2009. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2010. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2011. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2012. // return
  2013. //}
  2014. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2015. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2016. // utils.ErrorLog("解析失败:%v", err)
  2017. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2018. // return
  2019. //}
  2020. if miConfig.MdtrtareaAdmvs == "350500" {
  2021. result, result1, _ := service.FJyb3507(struct3507)
  2022. saveLog(result, result1, "3507", "3507")
  2023. var respJSON2 map[string]interface{}
  2024. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2027. return
  2028. }
  2029. userJSONBytes2, _ := json.Marshal(respJSON2)
  2030. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2031. utils.ErrorLog("解析失败:%v", err)
  2032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2033. return
  2034. }
  2035. } else {
  2036. data := make(map[string]interface{})
  2037. data["struct_3507s"] = struct3507
  2038. client := &http.Client{}
  2039. bytesData, _ := json.Marshal(data)
  2040. var req *http.Request
  2041. if miConfig.MdtrtareaAdmvs == "320921" {
  2042. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2043. } else {
  2044. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2045. }
  2046. resp, _ := client.Do(req)
  2047. defer resp.Body.Close()
  2048. body, ioErr := ioutil.ReadAll(resp.Body)
  2049. if ioErr != nil {
  2050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2051. }
  2052. var respJSON map[string]interface{}
  2053. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2056. return
  2057. }
  2058. var resSix10265 ResultSix10265 //1101结果
  2059. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2060. result, _ := json.Marshal(respJSON)
  2061. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2062. utils.ErrorLog("解析失败:%v", err)
  2063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2064. return
  2065. }
  2066. res.InfRefmsgid = resSix10265.InfRefmsgid
  2067. //res.Output = resSix10265.Output
  2068. res.ErrMsg = resSix10265.ErrMsg
  2069. res.Cainfo = resSix10265.Cainfo
  2070. res.WarnMsg = resSix10265.WarnMsg
  2071. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2072. res.Infcode = infocode
  2073. }
  2074. if res.Infcode == 0 {
  2075. item.IsChange = 0
  2076. item.BgBchno = ""
  2077. service.SaveDF2(item)
  2078. } else {
  2079. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2080. }
  2081. }
  2082. }
  2083. if len(err) == 0 {
  2084. c.ServeSuccessJSON(map[string]interface{}{
  2085. "msg": "删除销售变更成功",
  2086. })
  2087. } else {
  2088. c.ServeSuccessJSON(map[string]interface{}{
  2089. "failed_code": -10,
  2090. "msg": err,
  2091. })
  2092. }
  2093. }
  2094. //func (c *HisApiController) DeleteXSandBGTwo() {
  2095. // patient_id, _ := c.GetInt64("patient_id")
  2096. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2097. // //id_arr := strings.Split(ids, ",")
  2098. // times := c.GetString("time", "")
  2099. // timeLayout := "2006-01-02"
  2100. // loc, _ := time.LoadLocation("Local")
  2101. // var stime, etime int64
  2102. // if times == "" {
  2103. // stime, etime = GetNowTime()
  2104. // } else {
  2105. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2106. // stime = stmp.Unix()
  2107. // etime = stime + 86399
  2108. // }
  2109. // advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2110. // var flows []*models.DrugFlow
  2111. // for _, item := range advicelist {
  2112. // flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
  2113. // flows = append(flows, flow...)
  2114. // }
  2115. //
  2116. // //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2117. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2118. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2119. //
  2120. // var err []string
  2121. // for _, item := range flows {
  2122. // if item.IsSale == 1 && item.IsChange == 1 {
  2123. // var res FJ3507Result
  2124. // var res2 FJ3507Result
  2125. //
  2126. // var struct3507 models.Struct3507
  2127. // struct3507.FixmedinsBchno = item.Bchno
  2128. // struct3507.InvDataType = "4"
  2129. // struct3507.Opter = roles.UserName
  2130. // struct3507.OrgName = miConfig.OrgName
  2131. // struct3507.AccessKey = miConfig.AccessKey
  2132. // struct3507.RequestUrl = miConfig.Url
  2133. // struct3507.FixmedinsCode = miConfig.Code
  2134. // struct3507.SecretKey = miConfig.SecretKey
  2135. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2136. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2137. // struct3507.Url = miConfig.Url
  2138. // struct3507.AppId = miConfig.Cainfo
  2139. // struct3507.AppSecret = miConfig.AppSecret
  2140. // struct3507.Enckey = miConfig.EncKey
  2141. // struct3507.SignKey = miConfig.SignKey
  2142. // struct3507.SecretKey = miConfig.SecretKey
  2143. //
  2144. // //result, result1, _ := service.FJyb3507(struct3507)
  2145. // //saveLog(result, result1, "3507", "3507")
  2146. //
  2147. // if miConfig.MdtrtareaAdmvs == "350500" {
  2148. // result, result1, _ := service.FJyb3507(struct3507)
  2149. // saveLog(result, result1, "3507", "3507")
  2150. // var respJSON2 map[string]interface{}
  2151. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2152. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2154. // return
  2155. // }
  2156. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2157. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2158. // utils.ErrorLog("解析失败:%v", err)
  2159. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2160. // return
  2161. // }
  2162. // } else {
  2163. // data := make(map[string]interface{})
  2164. // data["struct_3507s"] = struct3507
  2165. // client := &http.Client{}
  2166. // bytesData, _ := json.Marshal(data)
  2167. // var req *http.Request
  2168. // if miConfig.MdtrtareaAdmvs == "320921" {
  2169. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2170. // } else {
  2171. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2172. // }
  2173. //
  2174. // resp, _ := client.Do(req)
  2175. // defer resp.Body.Close()
  2176. // body, ioErr := ioutil.ReadAll(resp.Body)
  2177. // if ioErr != nil {
  2178. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2179. // }
  2180. // var respJSON map[string]interface{}
  2181. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2182. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2183. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2184. // return
  2185. // }
  2186. // var resSix10265 ResultSix10265 //1101结果
  2187. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2188. // result, _ := json.Marshal(respJSON)
  2189. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2190. // utils.ErrorLog("解析失败:%v", err)
  2191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2192. // return
  2193. // }
  2194. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2195. // //res.Output = resSix10265.Output
  2196. // res.ErrMsg = resSix10265.ErrMsg
  2197. // res.Cainfo = resSix10265.Cainfo
  2198. // res.WarnMsg = resSix10265.WarnMsg
  2199. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2200. // res.Infcode = infocode
  2201. // }
  2202. //
  2203. // if res.Infcode == 0 {
  2204. // item.IsSale = 0
  2205. // item.SaleDate = ""
  2206. // item.Bchno = ""
  2207. //
  2208. // err2 := service.SaveDF(item)
  2209. // if err2 == nil {
  2210. // var struct3507_2 models.Struct3507
  2211. // struct3507_2.OrgName = miConfig.OrgName
  2212. // struct3507_2.AccessKey = miConfig.AccessKey
  2213. // struct3507_2.RequestUrl = miConfig.Url
  2214. // struct3507_2.Opter = roles.UserName
  2215. // struct3507_2.FixmedinsCode = miConfig.Code
  2216. // struct3507_2.Code = miConfig.Code
  2217. //
  2218. // struct3507_2.SecretKey = miConfig.SecretKey
  2219. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2220. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2221. // struct3507_2.Url = miConfig.Url
  2222. // struct3507_2.AppId = miConfig.Cainfo
  2223. // struct3507_2.AppSecret = miConfig.AppSecret
  2224. // struct3507_2.Enckey = miConfig.EncKey
  2225. // struct3507_2.SignKey = miConfig.SignKey
  2226. // struct3507_2.SecretKey = miConfig.SecretKey
  2227. // struct3507_2.FixmedinsBchno = item.BgBchno
  2228. // struct3507_2.InvDataType = "2"
  2229. //
  2230. // if miConfig.MdtrtareaAdmvs == "350500" {
  2231. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2232. // saveLog(result11, result22, "3507", "3507")
  2233. //
  2234. // var respJSON3 map[string]interface{}
  2235. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2236. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2237. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2238. // return
  2239. // }
  2240. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2241. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2242. // utils.ErrorLog("解析失败:%v", err)
  2243. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2244. // return
  2245. // }
  2246. // } else {
  2247. //
  2248. // data := make(map[string]interface{})
  2249. // data["struct_3507s"] = struct3507_2
  2250. // client := &http.Client{}
  2251. // bytesData, _ := json.Marshal(data)
  2252. // var req *http.Request
  2253. // if miConfig.MdtrtareaAdmvs == "320921" {
  2254. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2255. // } else {
  2256. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2257. // }
  2258. //
  2259. // resp, _ := client.Do(req)
  2260. // defer resp.Body.Close()
  2261. // body, ioErr := ioutil.ReadAll(resp.Body)
  2262. // if ioErr != nil {
  2263. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2264. // }
  2265. // var respJSON map[string]interface{}
  2266. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2267. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2269. // return
  2270. // }
  2271. // var resSix10265 ResultSix10265 //1101结果
  2272. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2273. // result, _ := json.Marshal(respJSON)
  2274. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2275. // utils.ErrorLog("解析失败:%v", err)
  2276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2277. // return
  2278. // }
  2279. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2280. // //res.Output = resSix10265.Output
  2281. // res2.ErrMsg = resSix10265.ErrMsg
  2282. // res2.Cainfo = resSix10265.Cainfo
  2283. // res2.WarnMsg = resSix10265.WarnMsg
  2284. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2285. // res2.Infcode = infocode
  2286. // }
  2287. //
  2288. // if res2.Infcode == 0 {
  2289. // item.IsChange = 0
  2290. // item.BgBchno = ""
  2291. // service.SaveDF2(item)
  2292. // } else {
  2293. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2294. // }
  2295. // }
  2296. // } else {
  2297. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2298. // }
  2299. //
  2300. // }
  2301. // if item.IsSale == 2 && item.IsChange == 1 {
  2302. // var res FJ3507Result
  2303. // var res2 FJ3507Result
  2304. //
  2305. // var struct3507 models.Struct3507
  2306. // struct3507.FixmedinsBchno = item.Bchno
  2307. // struct3507.InvDataType = "4"
  2308. // struct3507.Opter = roles.UserName
  2309. // struct3507.OrgName = miConfig.OrgName
  2310. // struct3507.AccessKey = miConfig.AccessKey
  2311. // struct3507.RequestUrl = miConfig.Url
  2312. // struct3507.FixmedinsCode = miConfig.Code
  2313. // struct3507.Code = miConfig.Code
  2314. //
  2315. // struct3507.SecretKey = miConfig.SecretKey
  2316. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2317. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2318. // struct3507.Url = miConfig.Url
  2319. // struct3507.AppId = miConfig.Cainfo
  2320. // struct3507.AppSecret = miConfig.AppSecret
  2321. // struct3507.Enckey = miConfig.EncKey
  2322. // struct3507.SignKey = miConfig.SignKey
  2323. // struct3507.SecretKey = miConfig.SecretKey
  2324. // //result, result1, _ := service.FJyb3507(struct3507)
  2325. // //saveLog(result, result1, "3507", "3507")
  2326. // //
  2327. // //var respJSON2 map[string]interface{}
  2328. // //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2329. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2330. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2331. // // return
  2332. // //}
  2333. // //userJSONBytes2, _ := json.Marshal(respJSON2)
  2334. // //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2335. // // utils.ErrorLog("解析失败:%v", err)
  2336. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2337. // // return
  2338. // //}
  2339. //
  2340. // if miConfig.MdtrtareaAdmvs == "350500" {
  2341. // result, result1, _ := service.FJyb3507(struct3507)
  2342. // saveLog(result, result1, "3507", "3507")
  2343. // var respJSON2 map[string]interface{}
  2344. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2345. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2347. // return
  2348. // }
  2349. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2350. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2351. // utils.ErrorLog("解析失败:%v", err)
  2352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2353. // return
  2354. // }
  2355. // } else {
  2356. // data := make(map[string]interface{})
  2357. // data["struct_3507s"] = struct3507
  2358. // client := &http.Client{}
  2359. // bytesData, _ := json.Marshal(data)
  2360. // var req *http.Request
  2361. // if miConfig.MdtrtareaAdmvs == "320921" {
  2362. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2363. // } else {
  2364. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2365. // }
  2366. //
  2367. // resp, _ := client.Do(req)
  2368. // defer resp.Body.Close()
  2369. // body, ioErr := ioutil.ReadAll(resp.Body)
  2370. // if ioErr != nil {
  2371. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2372. // }
  2373. // var respJSON map[string]interface{}
  2374. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2375. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2376. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2377. // return
  2378. // }
  2379. // var resSix10265 ResultSix10265 //1101结果
  2380. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2381. // result, _ := json.Marshal(respJSON)
  2382. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2383. // utils.ErrorLog("解析失败:%v", err)
  2384. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2385. // return
  2386. // }
  2387. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2388. // //res.Output = resSix10265.Output
  2389. // res.ErrMsg = resSix10265.ErrMsg
  2390. // res.Cainfo = resSix10265.Cainfo
  2391. // res.WarnMsg = resSix10265.WarnMsg
  2392. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2393. // res.Infcode = infocode
  2394. // }
  2395. //
  2396. // if res.Infcode == 0 {
  2397. // item.IsSale = 0
  2398. // item.SaleDate = ""
  2399. // item.Bchno = ""
  2400. // err2 := service.SaveDF(item)
  2401. // if err2 == nil {
  2402. // var struct3507_2 models.Struct3507
  2403. // struct3507_2.OrgName = miConfig.OrgName
  2404. // struct3507_2.AccessKey = miConfig.AccessKey
  2405. // struct3507_2.RequestUrl = miConfig.Url
  2406. // struct3507_2.Opter = roles.UserName
  2407. // struct3507_2.FixmedinsCode = miConfig.Code
  2408. // struct3507_2.Code = miConfig.Code
  2409. //
  2410. // struct3507_2.SecretKey = miConfig.SecretKey
  2411. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2412. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2413. // struct3507_2.Url = miConfig.Url
  2414. // struct3507_2.AppId = miConfig.Cainfo
  2415. // struct3507_2.AppSecret = miConfig.AppSecret
  2416. // struct3507_2.Enckey = miConfig.EncKey
  2417. // struct3507_2.SignKey = miConfig.SignKey
  2418. // struct3507_2.SecretKey = miConfig.SecretKey
  2419. // struct3507_2.FixmedinsBchno = item.BgBchno
  2420. // struct3507_2.InvDataType = "2"
  2421. //
  2422. // //result11, result22, _ := service.FJyb3507(struct3507_2)
  2423. // //saveLog(result11, result22, "3507", "3507")
  2424. // //var respJSON3 map[string]interface{}
  2425. // //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2426. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2427. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2428. // // return
  2429. // //}
  2430. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2431. // //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2432. // // utils.ErrorLog("解析失败:%v", err)
  2433. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2434. // // return
  2435. // //}
  2436. //
  2437. // if miConfig.MdtrtareaAdmvs == "350500" {
  2438. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2439. // saveLog(result11, result22, "3507", "3507")
  2440. //
  2441. // var respJSON3 map[string]interface{}
  2442. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2443. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2444. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2445. // return
  2446. // }
  2447. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2448. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2449. // utils.ErrorLog("解析失败:%v", err)
  2450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2451. // return
  2452. // }
  2453. // } else {
  2454. //
  2455. // data := make(map[string]interface{})
  2456. // data["struct_3507s"] = struct3507_2
  2457. // client := &http.Client{}
  2458. // bytesData, _ := json.Marshal(data)
  2459. // var req *http.Request
  2460. // if miConfig.MdtrtareaAdmvs == "320921" {
  2461. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2462. // } else {
  2463. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2464. // }
  2465. //
  2466. // resp, _ := client.Do(req)
  2467. // defer resp.Body.Close()
  2468. // body, ioErr := ioutil.ReadAll(resp.Body)
  2469. // if ioErr != nil {
  2470. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2471. // }
  2472. // var respJSON map[string]interface{}
  2473. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2474. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2476. // return
  2477. // }
  2478. // var resSix10265 ResultSix10265 //1101结果
  2479. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2480. // result, _ := json.Marshal(respJSON)
  2481. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2482. // utils.ErrorLog("解析失败:%v", err)
  2483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2484. // return
  2485. // }
  2486. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2487. // //res.Output = resSix10265.Output
  2488. // res2.ErrMsg = resSix10265.ErrMsg
  2489. // res2.Cainfo = resSix10265.Cainfo
  2490. // res2.WarnMsg = resSix10265.WarnMsg
  2491. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2492. // res2.Infcode = infocode
  2493. // }
  2494. // if res2.Infcode == 0 {
  2495. // item.IsChange = 0
  2496. // item.BgBchno = ""
  2497. // service.SaveDF2(item)
  2498. // } else {
  2499. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2500. // }
  2501. // }
  2502. // } else {
  2503. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2504. // }
  2505. //
  2506. // }
  2507. // if item.IsSale == 1 && item.IsChange == 0 {
  2508. //
  2509. // var res FJ3507Result
  2510. // var struct3507 models.Struct3507
  2511. // struct3507.FixmedinsBchno = item.Bchno
  2512. // struct3507.InvDataType = "4"
  2513. // struct3507.Opter = roles.UserName
  2514. // struct3507.FixmedinsCode = miConfig.Code
  2515. // struct3507.Code = miConfig.Code
  2516. //
  2517. // struct3507.OrgName = miConfig.OrgName
  2518. // struct3507.AccessKey = miConfig.AccessKey
  2519. // struct3507.RequestUrl = miConfig.Url
  2520. // struct3507.SecretKey = miConfig.SecretKey
  2521. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2522. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2523. // struct3507.Url = miConfig.Url
  2524. // struct3507.AppId = miConfig.Cainfo
  2525. // struct3507.AppSecret = miConfig.AppSecret
  2526. // struct3507.Enckey = miConfig.EncKey
  2527. // struct3507.SignKey = miConfig.SignKey
  2528. // struct3507.SecretKey = miConfig.SecretKey
  2529. // //result, result1, _ := service.FJyb3507(struct3507)
  2530. // //saveLog(result, result1, "3507", "3507")
  2531. // //
  2532. // //var respJSON3 map[string]interface{}
  2533. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2534. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2535. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2536. // // return
  2537. // //}
  2538. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2539. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2540. // // utils.ErrorLog("解析失败:%v", err)
  2541. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2542. // // return
  2543. // //}
  2544. // if miConfig.MdtrtareaAdmvs == "350500" {
  2545. // result, result1, _ := service.FJyb3507(struct3507)
  2546. // saveLog(result, result1, "3507", "3507")
  2547. // var respJSON2 map[string]interface{}
  2548. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2549. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2551. // return
  2552. // }
  2553. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2554. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2555. // utils.ErrorLog("解析失败:%v", err)
  2556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2557. // return
  2558. // }
  2559. // } else {
  2560. // data := make(map[string]interface{})
  2561. // data["struct_3507s"] = struct3507
  2562. // client := &http.Client{}
  2563. // bytesData, _ := json.Marshal(data)
  2564. // var req *http.Request
  2565. // if miConfig.MdtrtareaAdmvs == "320921" {
  2566. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2567. // } else {
  2568. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2569. // }
  2570. //
  2571. // resp, _ := client.Do(req)
  2572. // defer resp.Body.Close()
  2573. // body, ioErr := ioutil.ReadAll(resp.Body)
  2574. // if ioErr != nil {
  2575. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2576. // }
  2577. // var respJSON map[string]interface{}
  2578. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2579. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2581. // return
  2582. // }
  2583. // var resSix10265 ResultSix10265 //1101结果
  2584. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2585. // result, _ := json.Marshal(respJSON)
  2586. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2587. // utils.ErrorLog("解析失败:%v", err)
  2588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2589. // return
  2590. // }
  2591. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2592. // //res.Output = resSix10265.Output
  2593. // res.ErrMsg = resSix10265.ErrMsg
  2594. // res.Cainfo = resSix10265.Cainfo
  2595. // res.WarnMsg = resSix10265.WarnMsg
  2596. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2597. // res.Infcode = infocode
  2598. // }
  2599. //
  2600. // if res.Infcode == 0 {
  2601. // item.IsSale = 0
  2602. // item.SaleDate = ""
  2603. // service.SaveDF(item)
  2604. // } else {
  2605. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2606. // }
  2607. // }
  2608. // if item.IsSale == 2 && item.IsChange == 0 {
  2609. //
  2610. // var res FJ3507Result
  2611. // var struct3507 models.Struct3507
  2612. // struct3507.FixmedinsBchno = item.Bchno
  2613. // struct3507.InvDataType = "4"
  2614. // struct3507.Opter = roles.UserName
  2615. // struct3507.FixmedinsCode = miConfig.Code
  2616. // struct3507.Code = miConfig.Code
  2617. //
  2618. // struct3507.OrgName = miConfig.OrgName
  2619. // struct3507.AccessKey = miConfig.AccessKey
  2620. // struct3507.RequestUrl = miConfig.Url
  2621. // struct3507.SecretKey = miConfig.SecretKey
  2622. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2623. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2624. // struct3507.Url = miConfig.Url
  2625. // struct3507.AppId = miConfig.Cainfo
  2626. // struct3507.AppSecret = miConfig.AppSecret
  2627. // struct3507.Enckey = miConfig.EncKey
  2628. // struct3507.SignKey = miConfig.SignKey
  2629. // struct3507.SecretKey = miConfig.SecretKey
  2630. // //result, result1, _ := service.FJyb3507(struct3507)
  2631. // //saveLog(result, result1, "3507", "3507")
  2632. // //
  2633. // //var respJSON3 map[string]interface{}
  2634. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2635. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2636. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2637. // // return
  2638. // //}
  2639. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2640. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2641. // // utils.ErrorLog("解析失败:%v", err)
  2642. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2643. // // return
  2644. // //}
  2645. // if miConfig.MdtrtareaAdmvs == "350500" {
  2646. // result, result1, _ := service.FJyb3507(struct3507)
  2647. // saveLog(result, result1, "3507", "3507")
  2648. // var respJSON2 map[string]interface{}
  2649. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2650. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2652. // return
  2653. // }
  2654. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2655. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2656. // utils.ErrorLog("解析失败:%v", err)
  2657. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2658. // return
  2659. // }
  2660. // } else {
  2661. // data := make(map[string]interface{})
  2662. // data["struct_3507s"] = struct3507
  2663. // client := &http.Client{}
  2664. // bytesData, _ := json.Marshal(data)
  2665. // var req *http.Request
  2666. // if miConfig.MdtrtareaAdmvs == "320921" {
  2667. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2668. // } else {
  2669. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2670. // }
  2671. //
  2672. // resp, _ := client.Do(req)
  2673. // defer resp.Body.Close()
  2674. // body, ioErr := ioutil.ReadAll(resp.Body)
  2675. // if ioErr != nil {
  2676. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2677. // }
  2678. // var respJSON map[string]interface{}
  2679. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2680. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2682. // return
  2683. // }
  2684. // var resSix10265 ResultSix10265 //1101结果
  2685. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2686. // result, _ := json.Marshal(respJSON)
  2687. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2688. // utils.ErrorLog("解析失败:%v", err)
  2689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2690. // return
  2691. // }
  2692. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2693. // //res.Output = resSix10265.Output
  2694. // res.ErrMsg = resSix10265.ErrMsg
  2695. // res.Cainfo = resSix10265.Cainfo
  2696. // res.WarnMsg = resSix10265.WarnMsg
  2697. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2698. // res.Infcode = infocode
  2699. // }
  2700. //
  2701. // if res.Infcode == 0 {
  2702. // item.IsSale = 0
  2703. // item.SaleDate = ""
  2704. // item.Bchno = ""
  2705. //
  2706. // service.SaveDF(item)
  2707. // } else {
  2708. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2709. // }
  2710. // }
  2711. // if item.IsSale == 0 && item.IsChange == 1 {
  2712. //
  2713. // var res FJ3507Result
  2714. // var struct3507 models.Struct3507
  2715. // struct3507.FixmedinsBchno = item.BgBchno
  2716. // struct3507.InvDataType = "2"
  2717. // struct3507.Opter = roles.UserName
  2718. // struct3507.FixmedinsCode = miConfig.Code
  2719. // struct3507.Code = miConfig.Code
  2720. //
  2721. // struct3507.OrgName = miConfig.OrgName
  2722. // struct3507.AccessKey = miConfig.AccessKey
  2723. // struct3507.RequestUrl = miConfig.Url
  2724. // struct3507.SecretKey = miConfig.SecretKey
  2725. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2726. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2727. // struct3507.Url = miConfig.Url
  2728. // struct3507.AppId = miConfig.Cainfo
  2729. // struct3507.AppSecret = miConfig.AppSecret
  2730. // struct3507.Enckey = miConfig.EncKey
  2731. // struct3507.SignKey = miConfig.SignKey
  2732. // struct3507.SecretKey = miConfig.SecretKey
  2733. // //result, result1, _ := service.FJyb3507(struct3507)
  2734. // //saveLog(result, result1, "3507", "3507")
  2735. // //
  2736. // //var respJSON3 map[string]interface{}
  2737. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2738. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2739. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2740. // // return
  2741. // //}
  2742. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2743. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2744. // // utils.ErrorLog("解析失败:%v", err)
  2745. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2746. // // return
  2747. // //}
  2748. // if miConfig.MdtrtareaAdmvs == "350500" {
  2749. // result, result1, _ := service.FJyb3507(struct3507)
  2750. // saveLog(result, result1, "3507", "3507")
  2751. // var respJSON2 map[string]interface{}
  2752. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2753. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2755. // return
  2756. // }
  2757. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2758. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2759. // utils.ErrorLog("解析失败:%v", err)
  2760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2761. // return
  2762. // }
  2763. // } else {
  2764. // data := make(map[string]interface{})
  2765. // data["struct_3507s"] = struct3507
  2766. // client := &http.Client{}
  2767. // bytesData, _ := json.Marshal(data)
  2768. // var req *http.Request
  2769. // if miConfig.MdtrtareaAdmvs == "320921" {
  2770. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2771. // } else {
  2772. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2773. // }
  2774. //
  2775. // resp, _ := client.Do(req)
  2776. // defer resp.Body.Close()
  2777. // body, ioErr := ioutil.ReadAll(resp.Body)
  2778. // if ioErr != nil {
  2779. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2780. // }
  2781. // var respJSON map[string]interface{}
  2782. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2783. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2785. // return
  2786. // }
  2787. // var resSix10265 ResultSix10265 //1101结果
  2788. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2789. // result, _ := json.Marshal(respJSON)
  2790. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2791. // utils.ErrorLog("解析失败:%v", err)
  2792. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2793. // return
  2794. // }
  2795. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2796. // //res.Output = resSix10265.Output
  2797. // res.ErrMsg = resSix10265.ErrMsg
  2798. // res.Cainfo = resSix10265.Cainfo
  2799. // res.WarnMsg = resSix10265.WarnMsg
  2800. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2801. // res.Infcode = infocode
  2802. // }
  2803. //
  2804. // if res.Infcode == 0 {
  2805. // item.IsChange = 0
  2806. // item.BgBchno = ""
  2807. // service.SaveDF2(item)
  2808. // } else {
  2809. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2810. // }
  2811. // }
  2812. // }
  2813. // if len(err) == 0 {
  2814. // c.ServeSuccessJSON(map[string]interface{}{
  2815. // "msg": "删除销售变更成功",
  2816. // })
  2817. //
  2818. // } else {
  2819. // c.ServeSuccessJSON(map[string]interface{}{
  2820. // "failed_code": -10,
  2821. // "msg": err,
  2822. // })
  2823. //
  2824. // }
  2825. //
  2826. //}
  2827. // 获取当天起止时间戳
  2828. func GetNowTime() (int64, int64) {
  2829. t := time.Now()
  2830. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2831. timesamp := addTime.Unix()
  2832. return timesamp, timesamp + 86399
  2833. }
  2834. func (c *HisApiController) ChangeDrugfour() {
  2835. patient_id, _ := c.GetInt64("patient_id")
  2836. admin_user_id, _ := c.GetInt64("admin_user_id")
  2837. //id_arr := strings.Split(ids, ",")
  2838. times := c.GetString("time", "")
  2839. timeLayout := "2006-01-02"
  2840. loc, _ := time.LoadLocation("Local")
  2841. var stime, etime int64
  2842. if times == "" {
  2843. stime, etime = GetNowTime()
  2844. } else {
  2845. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2846. stime = stmp.Unix()
  2847. etime = stime + 86399
  2848. }
  2849. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2850. var flows []*models.DrugFlow
  2851. for _, item := range advicelist {
  2852. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.ID, stime, c.GetAdminUserInfo().CurrentOrgId)
  2853. flows = append(flows, flow...)
  2854. }
  2855. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2856. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2857. var err []string
  2858. for _, item := range flows {
  2859. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2860. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2861. if prescription.OrderStatus == 2 {
  2862. //已经结算
  2863. //判断是否已经销售
  2864. if item.IsSale == 1 { //是否已经销售,1是 0否
  2865. //是否已经变更 1是 0否
  2866. //if item.IsChange == 0 { //没变更,进行变更操作
  2867. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2868. //
  2869. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2870. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  2871. // var respJSON3 map[string]interface{}
  2872. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2873. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2875. // return
  2876. // }
  2877. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2878. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2879. // utils.ErrorLog("解析失败:%v", err)
  2880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2881. // return
  2882. // }
  2883. // if res3.Infcode == 0 {
  2884. // item.IsChange = 1
  2885. // item.BgBchno = bg_number
  2886. // service.SaveDF2(item)
  2887. // } else {
  2888. //
  2889. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2890. // }
  2891. //}
  2892. } else { //没销售,
  2893. var res FJ3507Result
  2894. var res3507for10188 FJ3507ResultFor10188
  2895. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2896. //进行商品销售接口
  2897. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2898. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2899. var respJSON3 map[string]interface{}
  2900. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2903. return
  2904. }
  2905. userJSONBytes3, _ := json.Marshal(respJSON3)
  2906. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2907. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2908. utils.ErrorLog("解析失败:%v", err)
  2909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2910. return
  2911. }
  2912. //if res3507for10188.Infcode
  2913. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2914. //res.Output = resSix10265.Output
  2915. res.ErrMsg = res3507for10188.ErrMsg
  2916. res.Cainfo = res3507for10188.Cainfo
  2917. res.WarnMsg = res3507for10188.WarnMsg
  2918. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2919. res.Infcode = infocode
  2920. } else {
  2921. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2922. utils.ErrorLog("解析失败:%v", err)
  2923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2924. return
  2925. }
  2926. }
  2927. if res.Infcode == 0 {
  2928. item.IsSale = 1
  2929. item.Bchno = number
  2930. item.SaleDate = time.Now().Format("2006-01-02")
  2931. service.SaveDF(item)
  2932. //if err5 == nil {
  2933. // if item.IsChange == 0 { //没变更,进行变更操作
  2934. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2935. //
  2936. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2937. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  2938. //
  2939. // var respJSON3 map[string]interface{}
  2940. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2941. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2943. // return
  2944. // }
  2945. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2946. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2947. // utils.ErrorLog("解析失败:%v", err)
  2948. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2949. // return
  2950. // }
  2951. // //if res3507for10188.Infcode
  2952. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2953. // //res.Output = resSix10265.Output
  2954. // res3.ErrMsg = res3507for10188.ErrMsg
  2955. // res3.Cainfo = res3507for10188.Cainfo
  2956. // res3.WarnMsg = res3507for10188.WarnMsg
  2957. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2958. // res3.Infcode = infocode
  2959. // } else {
  2960. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2961. // utils.ErrorLog("解析失败:%v", err)
  2962. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2963. // return
  2964. // }
  2965. // }
  2966. // if res3.Infcode == 0 {
  2967. // item.IsChange = 1
  2968. // item.BgBchno = bg_number
  2969. // service.SaveDF2(item)
  2970. // } else {
  2971. //
  2972. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2973. // }
  2974. // }
  2975. //}
  2976. } else {
  2977. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2978. }
  2979. }
  2980. } else { //还没结,提示用户去结算,并药品追溯上传
  2981. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  2982. }
  2983. }
  2984. }
  2985. if len(err) == 0 {
  2986. c.ServeSuccessJSON(map[string]interface{}{
  2987. "msg": "销售成功",
  2988. })
  2989. } else {
  2990. c.ServeSuccessJSON(map[string]interface{}{
  2991. "failed_code": -10,
  2992. "msg": err,
  2993. })
  2994. }
  2995. }
  2996. //func (c *HisApiController) ChangeDrugfour() {
  2997. // patient_id, _ := c.GetInt64("patient_id")
  2998. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2999. // //id_arr := strings.Split(ids, ",")
  3000. // times := c.GetString("time", "")
  3001. // timeLayout := "2006-01-02"
  3002. // loc, _ := time.LoadLocation("Local")
  3003. // var stime, etime int64
  3004. // if times == "" {
  3005. // stime, etime = GetNowTime()
  3006. // } else {
  3007. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3008. // stime = stmp.Unix()
  3009. // etime = stime + 86399
  3010. // }
  3011. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3012. // var flows []*models.DrugFlow
  3013. // for _, item := range advicelist {
  3014. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3015. // flows = append(flows, flow...)
  3016. // }
  3017. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3018. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3019. // var err []string
  3020. //
  3021. // for _, item := range flows {
  3022. // var res3 ResultSix
  3023. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3024. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3025. // if prescription.OrderStatus == 2 {
  3026. // //已经结算
  3027. // //判断是否已经销售
  3028. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3029. // //是否已经变更 1是 0否
  3030. // if item.IsChange == 0 { //没变更,进行变更操作
  3031. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3032. //
  3033. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3034. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3035. // var respJSON3 map[string]interface{}
  3036. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3037. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3039. // return
  3040. // }
  3041. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3042. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3043. // utils.ErrorLog("解析失败:%v", err)
  3044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3045. // return
  3046. // }
  3047. // if res3.Infcode == 0 {
  3048. // item.IsChange = 1
  3049. // item.BgBchno = bg_number
  3050. // service.SaveDF2(item)
  3051. // } else {
  3052. //
  3053. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3054. // }
  3055. // }
  3056. // } else { //没销售,
  3057. // var res FJ3507Result
  3058. // var res3507for10188 FJ3507ResultFor10188
  3059. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3060. //
  3061. // //进行商品销售接口
  3062. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3063. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3064. // var respJSON3 map[string]interface{}
  3065. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3066. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3067. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3068. // return
  3069. // }
  3070. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3071. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3072. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3073. // utils.ErrorLog("解析失败:%v", err)
  3074. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3075. // return
  3076. // }
  3077. // //if res3507for10188.Infcode
  3078. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3079. // //res.Output = resSix10265.Output
  3080. // res.ErrMsg = res3507for10188.ErrMsg
  3081. // res.Cainfo = res3507for10188.Cainfo
  3082. // res.WarnMsg = res3507for10188.WarnMsg
  3083. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3084. // res.Infcode = infocode
  3085. // } else {
  3086. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3087. // utils.ErrorLog("解析失败:%v", err)
  3088. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3089. // return
  3090. // }
  3091. //
  3092. // }
  3093. // if res.Infcode == 0 {
  3094. // item.IsSale = 1
  3095. // item.Bchno = number
  3096. // item.SaleDate = time.Now().Format("2006-01-02")
  3097. //
  3098. // err5 := service.SaveDF(item)
  3099. // if err5 == nil {
  3100. // if item.IsChange == 0 { //没变更,进行变更操作
  3101. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3102. //
  3103. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3104. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3105. //
  3106. // var respJSON3 map[string]interface{}
  3107. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3108. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3109. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3110. // return
  3111. // }
  3112. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3113. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3114. // utils.ErrorLog("解析失败:%v", err)
  3115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3116. // return
  3117. // }
  3118. // //if res3507for10188.Infcode
  3119. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3120. // //res.Output = resSix10265.Output
  3121. // res3.ErrMsg = res3507for10188.ErrMsg
  3122. // res3.Cainfo = res3507for10188.Cainfo
  3123. // res3.WarnMsg = res3507for10188.WarnMsg
  3124. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3125. // res3.Infcode = infocode
  3126. // } else {
  3127. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3128. // utils.ErrorLog("解析失败:%v", err)
  3129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3130. // return
  3131. // }
  3132. // }
  3133. // if res3.Infcode == 0 {
  3134. // item.IsChange = 1
  3135. // item.BgBchno = bg_number
  3136. // service.SaveDF2(item)
  3137. // } else {
  3138. //
  3139. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3140. // }
  3141. // }
  3142. // }
  3143. // } else {
  3144. //
  3145. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3146. // }
  3147. // }
  3148. //
  3149. // } else { //还没结,提示用户去结算,并药品追溯上传
  3150. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3151. // }
  3152. // }
  3153. // }
  3154. // if len(err) == 0 {
  3155. // c.ServeSuccessJSON(map[string]interface{}{
  3156. // "msg": "销售变更成功",
  3157. // })
  3158. // } else {
  3159. // c.ServeSuccessJSON(map[string]interface{}{
  3160. // "failed_code": -10,
  3161. // "msg": err,
  3162. // })
  3163. // }
  3164. //}
  3165. func (c *HisApiController) ChangeDrug() {
  3166. ids := c.GetString("ids")
  3167. id_arr := strings.Split(ids, ",")
  3168. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3169. admin_user_id, _ := c.GetInt64("admin_user_id")
  3170. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3171. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3172. var err []string
  3173. for _, item := range flows {
  3174. var res3 ResultSix
  3175. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3176. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3177. if prescription.OrderStatus == 2 {
  3178. //已经结算
  3179. //判断是否已经销售
  3180. if item.IsSale == 1 { //是否已经销售,1是 0否
  3181. //是否已经变更 1是 0否
  3182. if item.IsChange == 0 { //没变更,进行变更操作
  3183. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3184. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3185. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3186. var respJSON3 map[string]interface{}
  3187. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3190. return
  3191. }
  3192. userJSONBytes3, _ := json.Marshal(respJSON3)
  3193. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3194. utils.ErrorLog("解析失败:%v", err)
  3195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3196. return
  3197. }
  3198. if res3.Infcode == 0 {
  3199. item.IsChange = 1
  3200. item.BgBchno = bg_number
  3201. service.SaveDF2(item)
  3202. } else {
  3203. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3204. }
  3205. }
  3206. } else { //没销售,
  3207. var res FJ3507Result
  3208. var res3507for10188 FJ3507ResultFor10188
  3209. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3210. //进行商品销售接口
  3211. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3212. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3213. var respJSON3 map[string]interface{}
  3214. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3217. return
  3218. }
  3219. userJSONBytes3, _ := json.Marshal(respJSON3)
  3220. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3221. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3222. utils.ErrorLog("解析失败:%v", err)
  3223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3224. return
  3225. }
  3226. //if res3507for10188.Infcode
  3227. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3228. //res.Output = resSix10265.Output
  3229. res.ErrMsg = res3507for10188.ErrMsg
  3230. res.Cainfo = res3507for10188.Cainfo
  3231. res.WarnMsg = res3507for10188.WarnMsg
  3232. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3233. res.Infcode = infocode
  3234. } else {
  3235. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3236. utils.ErrorLog("解析失败:%v", err)
  3237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3238. return
  3239. }
  3240. }
  3241. if res.Infcode == 0 {
  3242. item.IsSale = 1
  3243. item.Bchno = number
  3244. item.SaleDate = time.Now().Format("2006-01-02")
  3245. err5 := service.SaveDF(item)
  3246. if err5 == nil {
  3247. if item.IsChange == 0 { //没变更,进行变更操作
  3248. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3249. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3250. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3251. var respJSON3 map[string]interface{}
  3252. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3255. return
  3256. }
  3257. userJSONBytes3, _ := json.Marshal(respJSON3)
  3258. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3259. utils.ErrorLog("解析失败:%v", err)
  3260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3261. return
  3262. }
  3263. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3264. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3265. utils.ErrorLog("解析失败:%v", err)
  3266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3267. return
  3268. }
  3269. //if res3507for10188.Infcode
  3270. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3271. //res.Output = resSix10265.Output
  3272. res3.ErrMsg = res3507for10188.ErrMsg
  3273. res3.Cainfo = res3507for10188.Cainfo
  3274. res3.WarnMsg = res3507for10188.WarnMsg
  3275. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3276. res3.Infcode = infocode
  3277. } else {
  3278. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3279. utils.ErrorLog("解析失败:%v", err)
  3280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3281. return
  3282. }
  3283. }
  3284. if res3.Infcode == 0 {
  3285. item.IsChange = 1
  3286. item.BgBchno = bg_number
  3287. service.SaveDF2(item)
  3288. } else {
  3289. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3290. }
  3291. }
  3292. }
  3293. } else {
  3294. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3295. }
  3296. }
  3297. } else { //还没结算
  3298. var res3507for10188 FJ3507ResultFor10188
  3299. if item.IsChange == 0 { //没变更,进行变更操作
  3300. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3301. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3302. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3303. var respJSON3 map[string]interface{}
  3304. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3307. return
  3308. }
  3309. userJSONBytes3, _ := json.Marshal(respJSON3)
  3310. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3311. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3312. utils.ErrorLog("解析失败:%v", err)
  3313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3314. return
  3315. }
  3316. //if res3507for10188.Infcode
  3317. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3318. //res.Output = resSix10265.Output
  3319. res3.ErrMsg = res3507for10188.ErrMsg
  3320. res3.Cainfo = res3507for10188.Cainfo
  3321. res3.WarnMsg = res3507for10188.WarnMsg
  3322. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3323. res3.Infcode = infocode
  3324. } else {
  3325. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3326. utils.ErrorLog("解析失败:%v", err)
  3327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3328. return
  3329. }
  3330. }
  3331. if res3.Infcode == 0 {
  3332. item.IsChange = 1
  3333. item.BgBchno = bg_number
  3334. service.SaveDF2(item)
  3335. } else {
  3336. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3337. }
  3338. }
  3339. }
  3340. } else if item.ConsumableType == 7 {
  3341. var res3507for10188 FJ3507ResultFor10188
  3342. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3343. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3344. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3345. //判断是否已经销售
  3346. if item.IsSale == 2 { //是否已经销售,1是 0否
  3347. //是否已经变更 1是 0否
  3348. if item.IsChange == 0 { //没变更,进行变更操作
  3349. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3350. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3351. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3352. var respJSON3 map[string]interface{}
  3353. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3356. return
  3357. }
  3358. userJSONBytes3, _ := json.Marshal(respJSON3)
  3359. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3360. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3361. utils.ErrorLog("解析失败:%v", err)
  3362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3363. return
  3364. }
  3365. //if res3507for10188.Infcode
  3366. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3367. //res.Output = resSix10265.Output
  3368. res3.ErrMsg = res3507for10188.ErrMsg
  3369. res3.Cainfo = res3507for10188.Cainfo
  3370. res3.WarnMsg = res3507for10188.WarnMsg
  3371. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3372. res3.Infcode = infocode
  3373. } else {
  3374. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3375. utils.ErrorLog("解析失败:%v", err)
  3376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3377. return
  3378. }
  3379. }
  3380. if res3.Infcode == 0 {
  3381. item.IsChange = 1
  3382. item.BgBchno = bg_number
  3383. service.SaveDF2(item)
  3384. } else {
  3385. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3386. }
  3387. }
  3388. } else { //没销售,
  3389. //进行商品销售退货接口
  3390. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3391. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3392. saveLog(result111, result222, "3506", "销售退货")
  3393. var res7 FJ3507Result
  3394. //进行商品销售接口
  3395. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3396. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3397. var respJSON3 map[string]interface{}
  3398. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3401. return
  3402. }
  3403. userJSONBytes3, _ := json.Marshal(respJSON3)
  3404. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3405. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3406. utils.ErrorLog("解析失败:%v", err)
  3407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3408. return
  3409. }
  3410. //if res3507for10188.Infcode
  3411. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3412. //res.Output = resSix10265.Output
  3413. res7.ErrMsg = res3507for10188.ErrMsg
  3414. res7.Cainfo = res3507for10188.Cainfo
  3415. res7.WarnMsg = res3507for10188.WarnMsg
  3416. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3417. res7.Infcode = infocode
  3418. } else {
  3419. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3420. utils.ErrorLog("解析失败:%v", err)
  3421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3422. return
  3423. }
  3424. }
  3425. if res7.Infcode == 0 {
  3426. item.IsSale = 2
  3427. item.SaleDate = item.SaleDate
  3428. item.Bchno = number
  3429. service.SaveDF(item)
  3430. if item.IsChange == 0 { //没变更,进行变更操作
  3431. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3432. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3433. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3434. var respJSON3 map[string]interface{}
  3435. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3438. return
  3439. }
  3440. userJSONBytes3, _ := json.Marshal(respJSON3)
  3441. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3442. // utils.ErrorLog("解析失败:%v", err)
  3443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3444. // return
  3445. //}
  3446. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3447. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3448. utils.ErrorLog("解析失败:%v", err)
  3449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3450. return
  3451. }
  3452. //if res3507for10188.Infcode
  3453. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3454. //res.Output = resSix10265.Output
  3455. res3.ErrMsg = res3507for10188.ErrMsg
  3456. res3.Cainfo = res3507for10188.Cainfo
  3457. res3.WarnMsg = res3507for10188.WarnMsg
  3458. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3459. res3.Infcode = infocode
  3460. } else {
  3461. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3462. utils.ErrorLog("解析失败:%v", err)
  3463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3464. return
  3465. }
  3466. }
  3467. if res3.Infcode == 0 {
  3468. item.IsChange = 1
  3469. item.BgBchno = bg_number
  3470. service.SaveDF2(item)
  3471. } else {
  3472. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3473. }
  3474. }
  3475. } else {
  3476. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3477. }
  3478. }
  3479. } else { //还没结算
  3480. if item.IsChange == 0 { //没变更,进行变更操作
  3481. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3482. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3483. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3484. var respJSON3 map[string]interface{}
  3485. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3488. return
  3489. }
  3490. userJSONBytes3, _ := json.Marshal(respJSON3)
  3491. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3492. // utils.ErrorLog("解析失败:%v", err)
  3493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3494. // return
  3495. //}
  3496. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3497. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3498. utils.ErrorLog("解析失败:%v", err)
  3499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3500. return
  3501. }
  3502. //if res3507for10188.Infcode
  3503. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3504. //res.Output = resSix10265.Output
  3505. res3.ErrMsg = res3507for10188.ErrMsg
  3506. res3.Cainfo = res3507for10188.Cainfo
  3507. res3.WarnMsg = res3507for10188.WarnMsg
  3508. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3509. res3.Infcode = infocode
  3510. } else {
  3511. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3512. utils.ErrorLog("解析失败:%v", err)
  3513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3514. return
  3515. }
  3516. }
  3517. if res3.Infcode == 0 {
  3518. item.IsChange = 1
  3519. item.BgBchno = bg_number
  3520. service.SaveDF2(item)
  3521. } else {
  3522. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3523. }
  3524. }
  3525. }
  3526. }
  3527. }
  3528. if len(err) == 0 {
  3529. c.ServeSuccessJSON(map[string]interface{}{
  3530. "msg": "销售变更成功",
  3531. })
  3532. } else {
  3533. c.ServeSuccessJSON(map[string]interface{}{
  3534. "failed_code": -10,
  3535. "msg": err,
  3536. })
  3537. }
  3538. }
  3539. func (c *HisApiController) ChangeDrugtwo() {
  3540. //ids := c.GetString("ids")
  3541. //id_arr := strings.Split(ids, ",")
  3542. flows, _ := service.GetNewDrugFlowInfotwo()
  3543. admin_user_id, _ := c.GetInt64("admin_user_id")
  3544. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3545. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3546. var err []string
  3547. for _, item := range flows {
  3548. var res3 ResultSix
  3549. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3550. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3551. if prescription.OrderStatus == 2 {
  3552. //已经结算
  3553. //判断是否已经销售
  3554. if item.IsSale == 1 { //是否已经销售,1是 0否
  3555. //是否已经变更 1是 0否
  3556. if item.IsChange == 0 { //没变更,进行变更操作
  3557. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3558. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3559. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3560. var respJSON3 map[string]interface{}
  3561. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3564. return
  3565. }
  3566. userJSONBytes3, _ := json.Marshal(respJSON3)
  3567. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3568. utils.ErrorLog("解析失败:%v", err)
  3569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3570. return
  3571. }
  3572. if res3.Infcode == 0 {
  3573. item.IsChange = 1
  3574. item.BgBchno = bg_number
  3575. service.SaveDF2(item)
  3576. } else {
  3577. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3578. }
  3579. }
  3580. } else { //没销售,
  3581. var res FJ3507Result
  3582. var res3507for10188 FJ3507ResultFor10188
  3583. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3584. //进行商品销售接口
  3585. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3586. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3587. var respJSON3 map[string]interface{}
  3588. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3591. return
  3592. }
  3593. userJSONBytes3, _ := json.Marshal(respJSON3)
  3594. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3595. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3596. utils.ErrorLog("解析失败:%v", err)
  3597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3598. return
  3599. }
  3600. //if res3507for10188.Infcode
  3601. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3602. //res.Output = resSix10265.Output
  3603. res.ErrMsg = res3507for10188.ErrMsg
  3604. res.Cainfo = res3507for10188.Cainfo
  3605. res.WarnMsg = res3507for10188.WarnMsg
  3606. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3607. res.Infcode = infocode
  3608. } else {
  3609. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3610. utils.ErrorLog("解析失败:%v", err)
  3611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3612. return
  3613. }
  3614. }
  3615. if res.Infcode == 0 {
  3616. item.IsSale = 1
  3617. item.Bchno = number
  3618. item.SaleDate = time.Now().Format("2006-01-02")
  3619. err5 := service.SaveDF(item)
  3620. if err5 == nil {
  3621. if item.IsChange == 0 { //没变更,进行变更操作
  3622. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3623. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3624. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3625. var respJSON3 map[string]interface{}
  3626. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3629. return
  3630. }
  3631. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3632. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3633. utils.ErrorLog("解析失败:%v", err)
  3634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3635. return
  3636. }
  3637. //if res3507for10188.Infcode
  3638. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3639. //res.Output = resSix10265.Output
  3640. res3.ErrMsg = res3507for10188.ErrMsg
  3641. res3.Cainfo = res3507for10188.Cainfo
  3642. res3.WarnMsg = res3507for10188.WarnMsg
  3643. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3644. res3.Infcode = infocode
  3645. } else {
  3646. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3647. utils.ErrorLog("解析失败:%v", err)
  3648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3649. return
  3650. }
  3651. }
  3652. if res3.Infcode == 0 {
  3653. item.IsChange = 1
  3654. item.BgBchno = bg_number
  3655. service.SaveDF2(item)
  3656. } else {
  3657. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3658. }
  3659. }
  3660. }
  3661. } else {
  3662. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3663. }
  3664. }
  3665. } else { //还没结算
  3666. var res3507for10188 FJ3507ResultFor10188
  3667. if item.IsChange == 0 { //没变更,进行变更操作
  3668. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3669. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3670. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3671. var respJSON3 map[string]interface{}
  3672. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3675. return
  3676. }
  3677. userJSONBytes3, _ := json.Marshal(respJSON3)
  3678. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3679. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3680. utils.ErrorLog("解析失败:%v", err)
  3681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3682. return
  3683. }
  3684. //if res3507for10188.Infcode
  3685. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3686. //res.Output = resSix10265.Output
  3687. res3.ErrMsg = res3507for10188.ErrMsg
  3688. res3.Cainfo = res3507for10188.Cainfo
  3689. res3.WarnMsg = res3507for10188.WarnMsg
  3690. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3691. res3.Infcode = infocode
  3692. } else {
  3693. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3694. utils.ErrorLog("解析失败:%v", err)
  3695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3696. return
  3697. }
  3698. }
  3699. if res3.Infcode == 0 {
  3700. item.IsChange = 1
  3701. item.BgBchno = bg_number
  3702. service.SaveDF2(item)
  3703. } else {
  3704. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3705. }
  3706. }
  3707. }
  3708. } else if item.ConsumableType == 7 {
  3709. var res3507for10188 FJ3507ResultFor10188
  3710. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3711. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3712. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3713. //判断是否已经销售
  3714. if item.IsSale == 2 { //是否已经销售,1是 0否
  3715. //是否已经变更 1是 0否
  3716. if item.IsChange == 0 { //没变更,进行变更操作
  3717. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3718. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3719. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3720. var respJSON3 map[string]interface{}
  3721. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3724. return
  3725. }
  3726. userJSONBytes3, _ := json.Marshal(respJSON3)
  3727. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3728. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3729. utils.ErrorLog("解析失败:%v", err)
  3730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3731. return
  3732. }
  3733. //if res3507for10188.Infcode
  3734. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3735. //res.Output = resSix10265.Output
  3736. res3.ErrMsg = res3507for10188.ErrMsg
  3737. res3.Cainfo = res3507for10188.Cainfo
  3738. res3.WarnMsg = res3507for10188.WarnMsg
  3739. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3740. res3.Infcode = infocode
  3741. } else {
  3742. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3743. utils.ErrorLog("解析失败:%v", err)
  3744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3745. return
  3746. }
  3747. }
  3748. if res3.Infcode == 0 {
  3749. item.IsChange = 1
  3750. item.BgBchno = bg_number
  3751. service.SaveDF2(item)
  3752. } else {
  3753. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3754. }
  3755. }
  3756. } else { //没销售,
  3757. //进行商品销售退货接口
  3758. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3759. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3760. saveLog(result111, result222, "3506", "销售退货")
  3761. var res7 FJ3507Result
  3762. //进行商品销售接口
  3763. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3764. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3765. var respJSON3 map[string]interface{}
  3766. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3769. return
  3770. }
  3771. userJSONBytes3, _ := json.Marshal(respJSON3)
  3772. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3773. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3774. utils.ErrorLog("解析失败:%v", err)
  3775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3776. return
  3777. }
  3778. //if res3507for10188.Infcode
  3779. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3780. //res.Output = resSix10265.Output
  3781. res7.ErrMsg = res3507for10188.ErrMsg
  3782. res7.Cainfo = res3507for10188.Cainfo
  3783. res7.WarnMsg = res3507for10188.WarnMsg
  3784. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3785. res7.Infcode = infocode
  3786. } else {
  3787. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3788. utils.ErrorLog("解析失败:%v", err)
  3789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3790. return
  3791. }
  3792. }
  3793. if res7.Infcode == 0 {
  3794. item.IsSale = 2
  3795. item.SaleDate = item.SaleDate
  3796. item.Bchno = number
  3797. service.SaveDF(item)
  3798. if item.IsChange == 0 { //没变更,进行变更操作
  3799. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3800. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3801. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3802. var respJSON3 map[string]interface{}
  3803. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3806. return
  3807. }
  3808. userJSONBytes3, _ := json.Marshal(respJSON3)
  3809. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3810. // utils.ErrorLog("解析失败:%v", err)
  3811. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3812. // return
  3813. //}
  3814. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3815. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3816. utils.ErrorLog("解析失败:%v", err)
  3817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3818. return
  3819. }
  3820. //if res3507for10188.Infcode
  3821. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3822. //res.Output = resSix10265.Output
  3823. res3.ErrMsg = res3507for10188.ErrMsg
  3824. res3.Cainfo = res3507for10188.Cainfo
  3825. res3.WarnMsg = res3507for10188.WarnMsg
  3826. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3827. res3.Infcode = infocode
  3828. } else {
  3829. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3830. utils.ErrorLog("解析失败:%v", err)
  3831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3832. return
  3833. }
  3834. }
  3835. if res3.Infcode == 0 {
  3836. item.IsChange = 1
  3837. item.BgBchno = bg_number
  3838. service.SaveDF2(item)
  3839. } else {
  3840. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3841. }
  3842. }
  3843. } else {
  3844. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3845. }
  3846. }
  3847. } else { //还没结算
  3848. if item.IsChange == 0 { //没变更,进行变更操作
  3849. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3850. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3851. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3852. var respJSON3 map[string]interface{}
  3853. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3856. return
  3857. }
  3858. userJSONBytes3, _ := json.Marshal(respJSON3)
  3859. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3860. // utils.ErrorLog("解析失败:%v", err)
  3861. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3862. // return
  3863. //}
  3864. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3865. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3866. utils.ErrorLog("解析失败:%v", err)
  3867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3868. return
  3869. }
  3870. //if res3507for10188.Infcode
  3871. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3872. //res.Output = resSix10265.Output
  3873. res3.ErrMsg = res3507for10188.ErrMsg
  3874. res3.Cainfo = res3507for10188.Cainfo
  3875. res3.WarnMsg = res3507for10188.WarnMsg
  3876. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3877. res3.Infcode = infocode
  3878. } else {
  3879. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3880. utils.ErrorLog("解析失败:%v", err)
  3881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3882. return
  3883. }
  3884. }
  3885. if res3.Infcode == 0 {
  3886. item.IsChange = 1
  3887. item.BgBchno = bg_number
  3888. service.SaveDF2(item)
  3889. } else {
  3890. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3891. }
  3892. }
  3893. }
  3894. }
  3895. }
  3896. if len(err) == 0 {
  3897. c.ServeSuccessJSON(map[string]interface{}{
  3898. "msg": "销售变更成功",
  3899. })
  3900. } else {
  3901. c.ServeSuccessJSON(map[string]interface{}{
  3902. "failed_code": -10,
  3903. "msg": err,
  3904. })
  3905. }
  3906. }
  3907. func (c *HisApiController) ChangeDrugthree() {
  3908. //ids := c.GetString("ids")
  3909. //id_arr := strings.Split(ids, ",")
  3910. flows, _ := service.GetNewDrugFlowInfothree()
  3911. admin_user_id, _ := c.GetInt64("admin_user_id")
  3912. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3913. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3914. var err []string
  3915. for _, item := range flows {
  3916. var res3 ResultSix
  3917. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3918. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3919. if prescription.OrderStatus == 2 {
  3920. //已经结算
  3921. //判断是否已经销售
  3922. if item.IsSale == 1 { //是否已经销售,1是 0否
  3923. //是否已经变更 1是 0否
  3924. if item.IsChange == 0 { //没变更,进行变更操作
  3925. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3926. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3927. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3928. var respJSON3 map[string]interface{}
  3929. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3932. return
  3933. }
  3934. userJSONBytes3, _ := json.Marshal(respJSON3)
  3935. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3936. utils.ErrorLog("解析失败:%v", err)
  3937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3938. return
  3939. }
  3940. if res3.Infcode == 0 {
  3941. item.IsChange = 1
  3942. item.BgBchno = bg_number
  3943. service.SaveDF2(item)
  3944. } else {
  3945. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3946. }
  3947. }
  3948. } else { //没销售,
  3949. var res FJ3507Result
  3950. var res3507for10188 FJ3507ResultFor10188
  3951. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3952. //进行商品销售接口
  3953. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3954. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3955. var respJSON3 map[string]interface{}
  3956. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3959. return
  3960. }
  3961. userJSONBytes3, _ := json.Marshal(respJSON3)
  3962. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3963. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3964. utils.ErrorLog("解析失败:%v", err)
  3965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3966. return
  3967. }
  3968. //if res3507for10188.Infcode
  3969. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3970. //res.Output = resSix10265.Output
  3971. res.ErrMsg = res3507for10188.ErrMsg
  3972. res.Cainfo = res3507for10188.Cainfo
  3973. res.WarnMsg = res3507for10188.WarnMsg
  3974. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3975. res.Infcode = infocode
  3976. } else {
  3977. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3978. utils.ErrorLog("解析失败:%v", err)
  3979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3980. return
  3981. }
  3982. }
  3983. if res.Infcode == 0 {
  3984. item.IsSale = 1
  3985. item.Bchno = number
  3986. item.SaleDate = time.Now().Format("2006-01-02")
  3987. err5 := service.SaveDF(item)
  3988. if err5 == nil {
  3989. if item.IsChange == 0 { //没变更,进行变更操作
  3990. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3991. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3992. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3993. var respJSON3 map[string]interface{}
  3994. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3997. return
  3998. }
  3999. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4000. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4001. utils.ErrorLog("解析失败:%v", err)
  4002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4003. return
  4004. }
  4005. //if res3507for10188.Infcode
  4006. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4007. //res.Output = resSix10265.Output
  4008. res3.ErrMsg = res3507for10188.ErrMsg
  4009. res3.Cainfo = res3507for10188.Cainfo
  4010. res3.WarnMsg = res3507for10188.WarnMsg
  4011. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4012. res3.Infcode = infocode
  4013. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4014. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4015. utils.ErrorLog("解析失败:%v", err)
  4016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4017. return
  4018. }
  4019. //if res3507for10188.Infcode
  4020. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4021. //res.Output = resSix10265.Output
  4022. res3.ErrMsg = res3507for10188.ErrMsg
  4023. res3.Cainfo = res3507for10188.Cainfo
  4024. res3.WarnMsg = res3507for10188.WarnMsg
  4025. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4026. res3.Infcode = infocode
  4027. } else {
  4028. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4029. utils.ErrorLog("解析失败:%v", err)
  4030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4031. return
  4032. }
  4033. }
  4034. if res3.Infcode == 0 {
  4035. item.IsChange = 1
  4036. item.BgBchno = bg_number
  4037. service.SaveDF2(item)
  4038. } else {
  4039. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4040. }
  4041. }
  4042. }
  4043. } else {
  4044. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4045. }
  4046. }
  4047. } else { //还没结算
  4048. var res3507for10188 FJ3507ResultFor10188
  4049. if item.IsChange == 0 { //没变更,进行变更操作
  4050. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4051. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4052. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4053. var respJSON3 map[string]interface{}
  4054. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4057. return
  4058. }
  4059. userJSONBytes3, _ := json.Marshal(respJSON3)
  4060. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4061. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4062. utils.ErrorLog("解析失败:%v", err)
  4063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4064. return
  4065. }
  4066. //if res3507for10188.Infcode
  4067. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4068. //res.Output = resSix10265.Output
  4069. res3.ErrMsg = res3507for10188.ErrMsg
  4070. res3.Cainfo = res3507for10188.Cainfo
  4071. res3.WarnMsg = res3507for10188.WarnMsg
  4072. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4073. res3.Infcode = infocode
  4074. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4075. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4076. utils.ErrorLog("解析失败:%v", err)
  4077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4078. return
  4079. }
  4080. //if res3507for10188.Infcode
  4081. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4082. //res.Output = resSix10265.Output
  4083. res3.ErrMsg = res3507for10188.ErrMsg
  4084. res3.Cainfo = res3507for10188.Cainfo
  4085. res3.WarnMsg = res3507for10188.WarnMsg
  4086. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4087. res3.Infcode = infocode
  4088. } else {
  4089. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4090. utils.ErrorLog("解析失败:%v", err)
  4091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4092. return
  4093. }
  4094. }
  4095. if res3.Infcode == 0 {
  4096. item.IsChange = 1
  4097. item.BgBchno = bg_number
  4098. service.SaveDF2(item)
  4099. } else {
  4100. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4101. }
  4102. }
  4103. }
  4104. } else if item.ConsumableType == 7 {
  4105. var res3507for10188 FJ3507ResultFor10188
  4106. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4107. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4108. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4109. //判断是否已经销售
  4110. if item.IsSale == 2 { //是否已经销售,1是 0否
  4111. //是否已经变更 1是 0否
  4112. if item.IsChange == 0 { //没变更,进行变更操作
  4113. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4114. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4115. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4116. var respJSON3 map[string]interface{}
  4117. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4120. return
  4121. }
  4122. userJSONBytes3, _ := json.Marshal(respJSON3)
  4123. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4124. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4125. utils.ErrorLog("解析失败:%v", err)
  4126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4127. return
  4128. }
  4129. //if res3507for10188.Infcode
  4130. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4131. //res.Output = resSix10265.Output
  4132. res3.ErrMsg = res3507for10188.ErrMsg
  4133. res3.Cainfo = res3507for10188.Cainfo
  4134. res3.WarnMsg = res3507for10188.WarnMsg
  4135. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4136. res3.Infcode = infocode
  4137. } else {
  4138. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4139. utils.ErrorLog("解析失败:%v", err)
  4140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4141. return
  4142. }
  4143. }
  4144. if res3.Infcode == 0 {
  4145. item.IsChange = 1
  4146. item.BgBchno = bg_number
  4147. service.SaveDF2(item)
  4148. } else {
  4149. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4150. }
  4151. }
  4152. } else { //没销售,
  4153. //进行商品销售退货接口
  4154. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4155. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4156. saveLog(result111, result222, "3506", "销售退货")
  4157. var res7 FJ3507Result
  4158. //进行商品销售接口
  4159. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4160. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4161. var respJSON3 map[string]interface{}
  4162. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4165. return
  4166. }
  4167. userJSONBytes3, _ := json.Marshal(respJSON3)
  4168. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4169. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4170. utils.ErrorLog("解析失败:%v", err)
  4171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4172. return
  4173. }
  4174. //if res3507for10188.Infcode
  4175. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4176. //res.Output = resSix10265.Output
  4177. res7.ErrMsg = res3507for10188.ErrMsg
  4178. res7.Cainfo = res3507for10188.Cainfo
  4179. res7.WarnMsg = res3507for10188.WarnMsg
  4180. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4181. res7.Infcode = infocode
  4182. } else {
  4183. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4184. utils.ErrorLog("解析失败:%v", err)
  4185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4186. return
  4187. }
  4188. }
  4189. if res7.Infcode == 0 {
  4190. item.IsSale = 2
  4191. item.SaleDate = item.SaleDate
  4192. item.Bchno = number
  4193. service.SaveDF(item)
  4194. if item.IsChange == 0 { //没变更,进行变更操作
  4195. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4196. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4197. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4198. var respJSON3 map[string]interface{}
  4199. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4202. return
  4203. }
  4204. userJSONBytes3, _ := json.Marshal(respJSON3)
  4205. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4206. // utils.ErrorLog("解析失败:%v", err)
  4207. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4208. // return
  4209. //}
  4210. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4211. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4212. utils.ErrorLog("解析失败:%v", err)
  4213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4214. return
  4215. }
  4216. //if res3507for10188.Infcode
  4217. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4218. //res.Output = resSix10265.Output
  4219. res3.ErrMsg = res3507for10188.ErrMsg
  4220. res3.Cainfo = res3507for10188.Cainfo
  4221. res3.WarnMsg = res3507for10188.WarnMsg
  4222. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4223. res3.Infcode = infocode
  4224. } else {
  4225. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4226. utils.ErrorLog("解析失败:%v", err)
  4227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4228. return
  4229. }
  4230. }
  4231. if res3.Infcode == 0 {
  4232. item.IsChange = 1
  4233. item.BgBchno = bg_number
  4234. service.SaveDF2(item)
  4235. } else {
  4236. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4237. }
  4238. }
  4239. } else {
  4240. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4241. }
  4242. }
  4243. } else { //还没结算
  4244. if item.IsChange == 0 { //没变更,进行变更操作
  4245. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4246. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4247. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4248. var respJSON3 map[string]interface{}
  4249. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4252. return
  4253. }
  4254. userJSONBytes3, _ := json.Marshal(respJSON3)
  4255. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4256. // utils.ErrorLog("解析失败:%v", err)
  4257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4258. // return
  4259. //}
  4260. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4261. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4262. utils.ErrorLog("解析失败:%v", err)
  4263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4264. return
  4265. }
  4266. //if res3507for10188.Infcode
  4267. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4268. //res.Output = resSix10265.Output
  4269. res3.ErrMsg = res3507for10188.ErrMsg
  4270. res3.Cainfo = res3507for10188.Cainfo
  4271. res3.WarnMsg = res3507for10188.WarnMsg
  4272. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4273. res3.Infcode = infocode
  4274. } else {
  4275. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4276. utils.ErrorLog("解析失败:%v", err)
  4277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4278. return
  4279. }
  4280. }
  4281. if res3.Infcode == 0 {
  4282. item.IsChange = 1
  4283. item.BgBchno = bg_number
  4284. service.SaveDF2(item)
  4285. } else {
  4286. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4287. }
  4288. }
  4289. }
  4290. }
  4291. }
  4292. if len(err) == 0 {
  4293. c.ServeSuccessJSON(map[string]interface{}{
  4294. "msg": "销售变更成功",
  4295. })
  4296. } else {
  4297. c.ServeSuccessJSON(map[string]interface{}{
  4298. "failed_code": -10,
  4299. "msg": err,
  4300. })
  4301. }
  4302. }
  4303. func (c *HisApiController) ChangeDrugTen() {
  4304. start_time_str := c.GetString("start_time")
  4305. end_time_str := c.GetString("end_time")
  4306. //ids := c.GetString("ids")
  4307. //id_arr := strings.Split(ids, ",")
  4308. timeLayout := "2006-01-02"
  4309. loc, _ := time.LoadLocation("Local")
  4310. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4311. recordStartTime := theStartTime.Unix()
  4312. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4313. recordEndTime := theEndTime.Unix()
  4314. //timestamp := int64(1729612800)
  4315. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4316. admin_user_id, _ := c.GetInt64("admin_user_id")
  4317. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4318. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4319. var err []string
  4320. for _, item := range flows {
  4321. var res3 ResultSix
  4322. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4323. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4324. continue
  4325. }
  4326. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4327. continue
  4328. }
  4329. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4330. if prescription.OrderStatus == 2 {
  4331. //已经结算
  4332. //判断 是否已经销售
  4333. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4334. ////是否已经变更 1是 0否
  4335. //if item.IsChange == 0 { //没变更,进行变更操作
  4336. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4337. //
  4338. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4339. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4340. // var respJSON3 map[string]interface{}
  4341. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4342. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4344. // return
  4345. // }
  4346. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4347. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4348. // utils.ErrorLog("解析失败:%v", err)
  4349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4350. // return
  4351. // }
  4352. // if res3.Infcode == 0 {
  4353. // item.IsChange = 1
  4354. // item.BgBchno = bg_number
  4355. // service.SaveDF2(item)
  4356. // } else {
  4357. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4358. // }
  4359. //}
  4360. //} else
  4361. if item.IsSale == 0 { //没销售,
  4362. var res FJ3507Result
  4363. var res3507for10188 FJ3507ResultFor10188
  4364. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4365. //进行商品销售接口
  4366. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4367. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4368. var respJSON3 map[string]interface{}
  4369. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4372. return
  4373. }
  4374. userJSONBytes3, _ := json.Marshal(respJSON3)
  4375. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4376. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4377. utils.ErrorLog("解析失败:%v", err)
  4378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4379. return
  4380. }
  4381. //if res3507for10188.Infcode
  4382. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4383. //res.Output = resSix10265.Output
  4384. res.ErrMsg = res3507for10188.ErrMsg
  4385. res.Cainfo = res3507for10188.Cainfo
  4386. res.WarnMsg = res3507for10188.WarnMsg
  4387. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4388. res.Infcode = infocode
  4389. } else {
  4390. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4391. utils.ErrorLog("解析失败:%v", err)
  4392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4393. return
  4394. }
  4395. }
  4396. if res.Infcode == 0 {
  4397. item.IsSale = 1
  4398. item.Bchno = number
  4399. item.SaleDate = time.Now().Format("2006-01-02")
  4400. err5 := service.SaveDF(item)
  4401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4402. //if err5 == nil {
  4403. //
  4404. // if item.IsChange == 1 { //没变更,进行变更操作
  4405. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4406. //
  4407. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4408. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4409. //
  4410. // var respJSON3 map[string]interface{}
  4411. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4412. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4414. // return
  4415. // }
  4416. //
  4417. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4418. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4419. // utils.ErrorLog("解析失败:%v", err)
  4420. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4421. // return
  4422. // }
  4423. // //if res3507for10188.Infcode
  4424. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4425. // //res.Output = resSix10265.Output
  4426. // res3.ErrMsg = res3507for10188.ErrMsg
  4427. // res3.Cainfo = res3507for10188.Cainfo
  4428. // res3.WarnMsg = res3507for10188.WarnMsg
  4429. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4430. // res3.Infcode = infocode
  4431. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4432. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4433. // utils.ErrorLog("解析失败:%v", err)
  4434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4435. // return
  4436. // }
  4437. // //if res3507for10188.Infcode
  4438. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4439. // //res.Output = resSix10265.Output
  4440. // res3.ErrMsg = res3507for10188.ErrMsg
  4441. // res3.Cainfo = res3507for10188.Cainfo
  4442. // res3.WarnMsg = res3507for10188.WarnMsg
  4443. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4444. // res3.Infcode = infocode
  4445. //
  4446. // } else {
  4447. //
  4448. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4449. // utils.ErrorLog("解析失败:%v", err)
  4450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4451. // return
  4452. // }
  4453. //
  4454. // }
  4455. //
  4456. // if res3.Infcode == 0 {
  4457. // item.IsChange = 1
  4458. // item.BgBchno = bg_number
  4459. // service.SaveDF2(item)
  4460. // return
  4461. // } else {
  4462. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4463. // }
  4464. // }
  4465. //}
  4466. } else {
  4467. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4468. }
  4469. }
  4470. }
  4471. } else if item.ConsumableType == 7 {
  4472. var res3507for10188 FJ3507ResultFor10188
  4473. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4474. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4475. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4476. //判断是否已经销售
  4477. if item.IsSale == 2 { //是否已经销售,1是 0否
  4478. //是否已经变更 1是 0否
  4479. if item.IsChange == 0 { //没变更,进行变更操作
  4480. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4481. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4482. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4483. var respJSON3 map[string]interface{}
  4484. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4487. return
  4488. }
  4489. userJSONBytes3, _ := json.Marshal(respJSON3)
  4490. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4491. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4492. utils.ErrorLog("解析失败:%v", err)
  4493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4494. return
  4495. }
  4496. //if res3507for10188.Infcode
  4497. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4498. //res.Output = resSix10265.Output
  4499. res3.ErrMsg = res3507for10188.ErrMsg
  4500. res3.Cainfo = res3507for10188.Cainfo
  4501. res3.WarnMsg = res3507for10188.WarnMsg
  4502. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4503. res3.Infcode = infocode
  4504. } else {
  4505. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4506. utils.ErrorLog("解析失败:%v", err)
  4507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4508. return
  4509. }
  4510. }
  4511. if res3.Infcode == 0 {
  4512. item.IsChange = 1
  4513. item.BgBchno = bg_number
  4514. service.SaveDF2(item)
  4515. } else {
  4516. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4517. }
  4518. }
  4519. } else { //没销售,
  4520. //进行商品销售退货接口
  4521. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4522. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4523. saveLog(result111, result222, "3506", "销售退货")
  4524. var res7 FJ3507Result
  4525. //进行商品销售接口
  4526. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4527. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4528. var respJSON3 map[string]interface{}
  4529. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4532. return
  4533. }
  4534. userJSONBytes3, _ := json.Marshal(respJSON3)
  4535. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4536. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4537. utils.ErrorLog("解析失败:%v", err)
  4538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4539. return
  4540. }
  4541. //if res3507for10188.Infcode
  4542. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4543. //res.Output = resSix10265.Output
  4544. res7.ErrMsg = res3507for10188.ErrMsg
  4545. res7.Cainfo = res3507for10188.Cainfo
  4546. res7.WarnMsg = res3507for10188.WarnMsg
  4547. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4548. res7.Infcode = infocode
  4549. } else {
  4550. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4551. utils.ErrorLog("解析失败:%v", err)
  4552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4553. return
  4554. }
  4555. }
  4556. if res7.Infcode == 0 {
  4557. item.IsSale = 2
  4558. item.SaleDate = item.SaleDate
  4559. item.Bchno = number
  4560. service.SaveDF(item)
  4561. if item.IsChange == 0 { //没变更,进行变更操作
  4562. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4563. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4564. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4565. var respJSON3 map[string]interface{}
  4566. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4569. return
  4570. }
  4571. userJSONBytes3, _ := json.Marshal(respJSON3)
  4572. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4573. // utils.ErrorLog("解析失败:%v", err)
  4574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4575. // return
  4576. //}
  4577. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4578. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4579. utils.ErrorLog("解析失败:%v", err)
  4580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4581. return
  4582. }
  4583. //if res3507for10188.Infcode
  4584. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4585. //res.Output = resSix10265.Output
  4586. res3.ErrMsg = res3507for10188.ErrMsg
  4587. res3.Cainfo = res3507for10188.Cainfo
  4588. res3.WarnMsg = res3507for10188.WarnMsg
  4589. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4590. res3.Infcode = infocode
  4591. } else {
  4592. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4593. utils.ErrorLog("解析失败:%v", err)
  4594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4595. return
  4596. }
  4597. }
  4598. if res3.Infcode == 0 {
  4599. item.IsChange = 1
  4600. item.BgBchno = bg_number
  4601. service.SaveDF2(item)
  4602. } else {
  4603. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4604. }
  4605. }
  4606. } else {
  4607. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4608. }
  4609. }
  4610. } else { //还没结算
  4611. if item.IsChange == 0 { //没变更,进行变更操作
  4612. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4613. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4614. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4615. var respJSON3 map[string]interface{}
  4616. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4619. return
  4620. }
  4621. userJSONBytes3, _ := json.Marshal(respJSON3)
  4622. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4623. // utils.ErrorLog("解析失败:%v", err)
  4624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4625. // return
  4626. //}
  4627. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4628. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4629. utils.ErrorLog("解析失败:%v", err)
  4630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4631. return
  4632. }
  4633. //if res3507for10188.Infcode
  4634. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4635. //res.Output = resSix10265.Output
  4636. res3.ErrMsg = res3507for10188.ErrMsg
  4637. res3.Cainfo = res3507for10188.Cainfo
  4638. res3.WarnMsg = res3507for10188.WarnMsg
  4639. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4640. res3.Infcode = infocode
  4641. } else {
  4642. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4643. utils.ErrorLog("解析失败:%v", err)
  4644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4645. return
  4646. }
  4647. }
  4648. if res3.Infcode == 0 {
  4649. item.IsChange = 1
  4650. item.BgBchno = bg_number
  4651. service.SaveDF2(item)
  4652. } else {
  4653. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4654. }
  4655. }
  4656. }
  4657. }
  4658. }
  4659. if len(err) == 0 {
  4660. c.ServeSuccessJSON(map[string]interface{}{
  4661. "msg": "销售变更成功",
  4662. })
  4663. } else {
  4664. c.ServeSuccessJSON(map[string]interface{}{
  4665. "failed_code": -10,
  4666. "msg": err,
  4667. })
  4668. }
  4669. }
  4670. func ChangeDrugTenone() {
  4671. //ids := c.GetString("ids")
  4672. //id_arr := strings.Split(ids, ",")
  4673. now := time.Now()
  4674. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4675. //timestamp := int64(1729612800)
  4676. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4677. admin_user_id := int64(2463)
  4678. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4679. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4680. var err []string
  4681. for _, item := range flows {
  4682. var res3 ResultSix
  4683. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4684. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4685. continue
  4686. }
  4687. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4688. continue
  4689. }
  4690. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4691. if prescription.OrderStatus == 2 {
  4692. //已经结算
  4693. //判断是否已经销售
  4694. if item.IsSale == 1 { //是否已经销售,1是 0否
  4695. //是否已经变更 1是 0否
  4696. if item.IsChange == 0 { //没变更,进行变更操作
  4697. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4698. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4699. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4700. var respJSON3 map[string]interface{}
  4701. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4703. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4704. return
  4705. }
  4706. userJSONBytes3, _ := json.Marshal(respJSON3)
  4707. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4708. utils.ErrorLog("解析失败:%v", err)
  4709. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4710. return
  4711. }
  4712. if res3.Infcode == 0 {
  4713. item.IsChange = 1
  4714. item.BgBchno = bg_number
  4715. service.SaveDF2(item)
  4716. } else {
  4717. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4718. }
  4719. }
  4720. } else { //没销售,
  4721. var res FJ3507Result
  4722. var res3507for10188 FJ3507ResultFor10188
  4723. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4724. //进行商品销售接口
  4725. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4726. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4727. var respJSON3 map[string]interface{}
  4728. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4730. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4731. return
  4732. }
  4733. userJSONBytes3, _ := json.Marshal(respJSON3)
  4734. {
  4735. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4736. utils.ErrorLog("解析失败:%v", err)
  4737. return
  4738. }
  4739. //if res3507for10188.Infcode
  4740. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4741. //res.Output = resSix10265.Output
  4742. res.ErrMsg = res3507for10188.ErrMsg
  4743. res.Cainfo = res3507for10188.Cainfo
  4744. res.WarnMsg = res3507for10188.WarnMsg
  4745. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4746. res.Infcode = infocode
  4747. }
  4748. if res.Infcode == 0 {
  4749. item.IsSale = 1
  4750. item.Bchno = number
  4751. item.SaleDate = time.Now().Format("2006-01-02")
  4752. err5 := service.SaveDF(item)
  4753. if err5 == nil {
  4754. if item.IsChange == 1 { //没变更,进行变更操作
  4755. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4756. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4757. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4758. var respJSON3 map[string]interface{}
  4759. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4761. return
  4762. }
  4763. {
  4764. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4765. utils.ErrorLog("解析失败:%v", err)
  4766. return
  4767. }
  4768. //if res3507for10188.Infcode
  4769. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4770. //res.Output = resSix10265.Output
  4771. res3.ErrMsg = res3507for10188.ErrMsg
  4772. res3.Cainfo = res3507for10188.Cainfo
  4773. res3.WarnMsg = res3507for10188.WarnMsg
  4774. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4775. res3.Infcode = infocode
  4776. }
  4777. if res3.Infcode == 0 {
  4778. item.IsChange = 1
  4779. item.BgBchno = bg_number
  4780. service.SaveDF2(item)
  4781. } else {
  4782. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4783. }
  4784. }
  4785. }
  4786. } else {
  4787. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4788. }
  4789. }
  4790. }
  4791. }
  4792. }
  4793. }
  4794. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4795. var struct3502 models.Struct3502
  4796. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4797. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4798. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4799. struct3502.FixmedinsCode = miConfig.Code
  4800. struct3502.Code = miConfig.Code
  4801. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4802. struct3502.Opter = role.UserName
  4803. struct3502.RxFlag = "1"
  4804. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4805. struct3502.OrgName = miConfig.OrgName
  4806. struct3502.AccessKey = miConfig.AccessKey
  4807. struct3502.RequestUrl = miConfig.Url
  4808. struct3502.SecretKey = miConfig.SecretKey
  4809. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4810. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4811. struct3502.Url = miConfig.Url
  4812. struct3502.AppId = miConfig.Cainfo
  4813. struct3502.AppSecret = miConfig.AppSecret
  4814. struct3502.Enckey = miConfig.EncKey
  4815. struct3502.SignKey = miConfig.SignKey
  4816. struct3502.SecretKey = miConfig.SecretKey
  4817. struct3502.InvChgType = chgType
  4818. struct3502.FixmedinsBchno = number
  4819. struct3502.Cnt = strconv.FormatInt(count, 10)
  4820. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4821. //result1, result2, _ := service.FJyb3502(struct3502)
  4822. if miConfig.MdtrtareaAdmvs == "350500" {
  4823. result1, result2, _ := service.FJyb3502(struct3502)
  4824. //saveLog(result1, result2, "3502", "3502")
  4825. return result1, result2
  4826. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4827. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4828. return result1, result2
  4829. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4830. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4831. return result1, result2
  4832. } else {
  4833. data := make(map[string]interface{})
  4834. data["struct_3502s"] = struct3502
  4835. client := &http.Client{}
  4836. bytesData, _ := json.Marshal(data)
  4837. var req *http.Request
  4838. if miConfig.MdtrtareaAdmvs == "320921" {
  4839. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4840. } else {
  4841. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4842. }
  4843. resp, _ := client.Do(req)
  4844. defer resp.Body.Close()
  4845. body, ioErr := ioutil.ReadAll(resp.Body)
  4846. if ioErr != nil {
  4847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4848. }
  4849. var respJSON map[string]interface{}
  4850. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4852. }
  4853. //var resSix10265 ResultSix10265 //1101结果
  4854. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4855. result, _ := json.Marshal(respJSON)
  4856. return string(result), ""
  4857. }
  4858. }
  4859. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4860. var struct3505 models.Struct3505
  4861. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4862. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4863. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4864. struct3505.FixmedinsBchno = number
  4865. struct3505.Opter = role.UserName
  4866. struct3505.FixmedinsCode = miConfig.Code
  4867. struct3505.Code = miConfig.Code
  4868. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  4869. struct3505.PrscDrName = roles.UserName
  4870. if org_id == 10191 {
  4871. struct3505.PharName = "刘水山"
  4872. struct3505.PharPracCertNo = "2015026350260000002611351127"
  4873. }
  4874. if org_id == 10188 {
  4875. struct3505.PharName = "李汉清"
  4876. struct3505.PharPracCertNo = "30220200932022010034"
  4877. }
  4878. if org_id == 10217 {
  4879. struct3505.PharName = "张敏"
  4880. struct3505.PharPracCertNo = "30220230432090100108"
  4881. }
  4882. if org_id == 10318 {
  4883. struct3505.PharName = "邹刘阳"
  4884. struct3505.PharPracCertNo = "210441200001378"
  4885. }
  4886. if org_id == 10402 {
  4887. struct3505.PharName = "刘韶健"
  4888. struct3505.PharPracCertNo = "2015026440262015440501001198"
  4889. }
  4890. if org_id == 9919 {
  4891. struct3505.PharName = "周君权"
  4892. struct3505.PharPracCertNo = "089644396094401375"
  4893. }
  4894. if org_id == 10644 {
  4895. struct3505.PharName = "陈金娣"
  4896. struct3505.PharPracCertNo = "20181441500320100066"
  4897. }
  4898. if org_id == 10567 {
  4899. struct3505.PharName = "范小兰"
  4900. struct3505.PharPracCertNo = "0200102079485"
  4901. }
  4902. if org_id == 10721 {
  4903. struct3505.PharName = "孙莉侠"
  4904. struct3505.PharPracCertNo = "060399"
  4905. }
  4906. if org_id == 10726 {
  4907. struct3505.PharName = "彭建福"
  4908. struct3505.PharPracCertNo = "D445281006261"
  4909. }
  4910. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4911. struct3505.SetlId = order.SetlId
  4912. struct3505.MdtrtSn = order.MdtrtId
  4913. struct3505.ManuLotnum = drug.Number
  4914. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4915. struct3505.ExpyEnd = ""
  4916. struct3505.RxFlag = "1"
  4917. struct3505.TrdnFlag = "1"
  4918. struct3505.RtalDocno = order.Number
  4919. struct3505.PsnCertType = "01"
  4920. struct3505.CertNo = order.Certno
  4921. struct3505.PsnNo = order.PsnNo
  4922. struct3505.PsnName = order.PsnName
  4923. struct3505.Url = miConfig.Url
  4924. struct3505.AppId = miConfig.Cainfo
  4925. struct3505.AppSecret = miConfig.AppSecret
  4926. struct3505.Enckey = miConfig.EncKey
  4927. struct3505.SignKey = miConfig.SignKey
  4928. struct3505.SecretKey = miConfig.SecretKey
  4929. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4930. struct3505.SelRetnCnt = strValue
  4931. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4932. struct3505.SelRetnOpterName = role.UserName
  4933. if order.IsMedicineInsurance == 1 {
  4934. struct3505.MdtrtSetlType = "1"
  4935. } else {
  4936. struct3505.MdtrtSetlType = "2"
  4937. }
  4938. struct3505.OrgName = miConfig.OrgName
  4939. struct3505.AccessKey = miConfig.AccessKey
  4940. struct3505.RequestUrl = miConfig.Url
  4941. struct3505.SecretKey = miConfig.SecretKey
  4942. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4943. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4944. struct3505.Cainfo = miConfig.Cainfo
  4945. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4946. if miConfig.MdtrtareaAdmvs == "350500" {
  4947. result1, result2, _ := service.FJyb3505(struct3505)
  4948. return result1, result2
  4949. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4950. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  4951. return result1, result2
  4952. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4953. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  4954. return result1, result2
  4955. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  4956. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  4957. return result1, result2
  4958. } else if miConfig.MdtrtareaAdmvs == "340699" {
  4959. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  4960. return result1, result2
  4961. } else {
  4962. data := make(map[string]interface{})
  4963. data["struct_3505s"] = struct3505
  4964. client := &http.Client{}
  4965. bytesData, _ := json.Marshal(data)
  4966. var req *http.Request
  4967. if miConfig.MdtrtareaAdmvs == "320921" {
  4968. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4969. } else {
  4970. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4971. }
  4972. resp, _ := client.Do(req)
  4973. defer resp.Body.Close()
  4974. body, ioErr := ioutil.ReadAll(resp.Body)
  4975. if ioErr != nil {
  4976. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4977. }
  4978. var respJSON map[string]interface{}
  4979. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4981. }
  4982. //var resSix10265 ResultSix10265 //1101结果
  4983. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4984. result, _ := json.Marshal(respJSON)
  4985. return string(result), ""
  4986. }
  4987. }
  4988. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4989. var struct3506 models.Struct3506
  4990. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4991. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4992. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4993. struct3506.FixmedinsCode = miConfig.Code
  4994. struct3506.Code = miConfig.Code
  4995. struct3506.FixmedinsBchno = number
  4996. struct3506.Opter = role.UserName
  4997. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4998. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  4999. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5000. struct3506.MdtrtSn = order.MdtrtId
  5001. struct3506.ExpyEnd = ""
  5002. struct3506.RxFlag = "0"
  5003. struct3506.TrdnFlag = "1"
  5004. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5005. struct3506.SelRetnCnt = strValue
  5006. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5007. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5008. struct3506.SelRetnOpterName = role.UserName
  5009. struct3506.OrgName = miConfig.OrgName
  5010. struct3506.AccessKey = miConfig.AccessKey
  5011. struct3506.RequestUrl = miConfig.Url
  5012. struct3506.SecretKey = miConfig.SecretKey
  5013. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5014. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5015. struct3506.Url = miConfig.Url
  5016. struct3506.AppId = miConfig.Cainfo
  5017. struct3506.AppSecret = miConfig.AppSecret
  5018. struct3506.Enckey = miConfig.EncKey
  5019. struct3506.SignKey = miConfig.SignKey
  5020. struct3506.SecretKey = miConfig.SecretKey
  5021. struct3506.DrugTracCodg = drug.DrugCode
  5022. if miConfig.MdtrtareaAdmvs == "350500" {
  5023. result1, result2, _ := service.FJyb3506(struct3506)
  5024. return result1, result2
  5025. } else {
  5026. data := make(map[string]interface{})
  5027. data["struct_3506s"] = struct3506
  5028. client := &http.Client{}
  5029. bytesData, _ := json.Marshal(data)
  5030. var req *http.Request
  5031. if miConfig.MdtrtareaAdmvs == "320921" {
  5032. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5033. } else {
  5034. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5035. }
  5036. resp, _ := client.Do(req)
  5037. defer resp.Body.Close()
  5038. body, ioErr := ioutil.ReadAll(resp.Body)
  5039. if ioErr != nil {
  5040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5041. }
  5042. var respJSON map[string]interface{}
  5043. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5045. }
  5046. //var resSix10265 ResultSix10265 //1101结果
  5047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5048. result, _ := json.Marshal(respJSON)
  5049. return string(result), ""
  5050. }
  5051. }
  5052. func (c *HisApiController) Get1318() {
  5053. adminUser := c.GetAdminUserInfo()
  5054. admin_user_id, _ := c.GetInt64("admin_user_id")
  5055. code := c.GetString("code")
  5056. code = ""
  5057. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5058. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5059. api := ""
  5060. if miConfig.MdtrtareaAdmvs == "320921" {
  5061. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5062. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5063. } else {
  5064. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5065. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5066. }
  5067. resp, requestErr := http.Get(api)
  5068. if requestErr != nil {
  5069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5070. return
  5071. }
  5072. body, ioErr := ioutil.ReadAll(resp.Body)
  5073. if ioErr != nil {
  5074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5076. return
  5077. }
  5078. var respJSON map[string]interface{}
  5079. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5082. return
  5083. }
  5084. //var res Result2406
  5085. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5086. result, _ := json.Marshal(respJSON)
  5087. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5088. utils.ErrorLog("解析失败:%v", err)
  5089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5090. return
  5091. }
  5092. if res.Infcode == "0" {
  5093. c.ServeSuccessJSON(map[string]interface{}{
  5094. "result": "",
  5095. })
  5096. } else {
  5097. c.ServeSuccessJSON(map[string]interface{}{
  5098. "failed_code": -10,
  5099. "msg": res.ErrMsg,
  5100. })
  5101. */return
  5102. //}
  5103. }
  5104. func (c *HisApiController) Get2503() {
  5105. adminUser := c.GetAdminUserInfo()
  5106. admin_user_id, _ := c.GetInt64("admin_user_id")
  5107. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5108. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5109. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5110. }
  5111. func (c *HisApiController) Get2406() {
  5112. id, _ := c.GetInt64("id")
  5113. record_time := c.GetString("record_time")
  5114. his_patient_id, _ := c.GetInt64("his_patient_id")
  5115. admin_user_id, _ := c.GetInt64("admin_user_id")
  5116. diagnosis_id := c.GetString("diagnosis")
  5117. timeLayout := "2006-01-02"
  5118. loc, _ := time.LoadLocation("Local")
  5119. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5120. if err != nil {
  5121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5122. return
  5123. }
  5124. recordDateTime := theTime.Unix()
  5125. adminUser := c.GetAdminUserInfo()
  5126. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5127. var config []*models.HisXtDiagnoseConfig
  5128. for _, item := range diagnosis_ids {
  5129. id, _ := strconv.ParseInt(item, 10, 64)
  5130. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5131. config = append(config, &diagnosisConfig)
  5132. }
  5133. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5134. fmt.Println(his_patient_id)
  5135. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5136. //timestamp := time.Now().Unix()
  5137. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5138. var patientPrescription models.HisPrescriptionInfo
  5139. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5140. if patientPrescription.ID == 0 {
  5141. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5142. }
  5143. var res2 Result2406
  5144. if miConfig.MdtrtareaAdmvs == "341203" {
  5145. data := make(map[string]interface{})
  5146. client := &http.Client{}
  5147. data["psn_no"] = his.PsnNo
  5148. data["mdtrt_id"] = his.Number
  5149. data["operator"] = roles.UserName
  5150. data["cert_no"] = his.IdCardNo
  5151. data["org_name"] = miConfig.OrgName
  5152. data["psn_name"] = his.Name
  5153. data["ipt_otp_no"] = his.IptOtpNo
  5154. data["ipt_psn_sp_flag_type"] = "0901"
  5155. data["ipt_psn_sp_flag"] = "1"
  5156. data["fixmedins_code"] = miConfig.Code
  5157. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5158. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5159. data["url"] = miConfig.Url
  5160. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5161. bytesData, _ := json.Marshal(data)
  5162. var req *http.Request
  5163. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5164. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5165. resp, _ := client.Do(req)
  5166. defer resp.Body.Close()
  5167. body, ioErr := ioutil.ReadAll(resp.Body)
  5168. if ioErr != nil {
  5169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5171. return
  5172. }
  5173. var respJSON map[string]interface{}
  5174. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5177. return
  5178. }
  5179. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5180. if status == "0" {
  5181. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5182. c.ServeSuccessJSON(map[string]interface{}{
  5183. "failed_code": -10,
  5184. "msg": err_msg,
  5185. })
  5186. return
  5187. }
  5188. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5189. userJSONBytes, _ := json.Marshal(respJSON)
  5190. fmt.Println("log")
  5191. fmt.Println(string(userJSONBytes))
  5192. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5193. utils.ErrorLog("解析失败:%v", err)
  5194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5195. return
  5196. }
  5197. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5198. data := make(map[string]interface{})
  5199. client := &http.Client{}
  5200. data["psn_no"] = his.PsnNo
  5201. data["mdtrt_id"] = his.Number
  5202. data["operator"] = roles.UserName
  5203. data["cert_no"] = his.IdCardNo
  5204. data["org_name"] = miConfig.OrgName
  5205. data["psn_name"] = his.Name
  5206. data["ipt_otp_no"] = his.IptOtpNo
  5207. data["ipt_psn_sp_flag_type"] = "0901"
  5208. data["ipt_psn_sp_flag"] = "1"
  5209. data["fixmedins_code"] = miConfig.Code
  5210. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5211. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5212. data["url"] = miConfig.Url
  5213. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5214. bytesData, _ := json.Marshal(data)
  5215. var req *http.Request
  5216. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5217. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5218. resp, _ := client.Do(req)
  5219. defer resp.Body.Close()
  5220. body, ioErr := ioutil.ReadAll(resp.Body)
  5221. if ioErr != nil {
  5222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5224. return
  5225. }
  5226. var respJSON map[string]interface{}
  5227. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5230. return
  5231. }
  5232. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5233. if status == "0" {
  5234. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5235. c.ServeSuccessJSON(map[string]interface{}{
  5236. "failed_code": -10,
  5237. "msg": err_msg,
  5238. })
  5239. return
  5240. }
  5241. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5242. userJSONBytes, _ := json.Marshal(respJSON)
  5243. fmt.Println("log")
  5244. fmt.Println(string(userJSONBytes))
  5245. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5246. utils.ErrorLog("解析失败:%v", err)
  5247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5248. return
  5249. }
  5250. }
  5251. if res2.Infcode != 0 {
  5252. adminUser := c.GetAdminUserInfo()
  5253. errlog := &models.HisOrderError{
  5254. UserOrgId: adminUser.CurrentOrgId,
  5255. Ctime: time.Now().Unix(),
  5256. Mtime: time.Now().Unix(),
  5257. ErrMsg: res2.ErrMsg,
  5258. Status: 1,
  5259. PatientId: id,
  5260. RecordTime: recordDateTime,
  5261. Stage: 3,
  5262. }
  5263. service.CreateErrMsgLog(errlog)
  5264. c.ServeSuccessJSON(map[string]interface{}{
  5265. "failed_code": -10,
  5266. "msg": res2.ErrMsg,
  5267. })
  5268. return
  5269. } else {
  5270. c.ServeSuccessJSON(map[string]interface{}{
  5271. "msg": "上传成功",
  5272. })
  5273. return
  5274. }
  5275. }
  5276. func (c *HisApiController) Get4105() {
  5277. }
  5278. func (c *HisApiController) Post5302() {
  5279. patient_id, _ := c.GetInt64("id")
  5280. admin_user_id, _ := c.GetInt64("admin_user_id")
  5281. p, _ := service.GetHisPatientById(patient_id)
  5282. adminUser := c.GetAdminUserInfo()
  5283. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5284. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5285. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5286. }
  5287. func (c *HisApiController) Get4104() {
  5288. }
  5289. type Output struct {
  5290. CertNo string `json:"certno"`
  5291. PsnName string `json:"psn_name"`
  5292. CardNo string `json:"card_no"`
  5293. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5294. CardSN string `json:"card_sn"`
  5295. PsnCertType string `json:"psn_cert_type"`
  5296. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5297. MdtrtCertType string `json:"mdtrt_cert_type"`
  5298. QRCode string `json:"qrCode"`
  5299. EcToken string `json:"ecToken"`
  5300. }
  5301. type AHResponse struct {
  5302. Body AHBody `json:"body"`
  5303. Code int `json:"code"`
  5304. CSBCode int `json:"csbCode"`
  5305. Message string `json:"message"`
  5306. RequestID string `json:"requestId"`
  5307. State struct{} `json:"state"`
  5308. }
  5309. type AHBody struct {
  5310. ErrMsg string `json:"err_msg"`
  5311. InfRefMsgID string `json:"inf_refmsgid"`
  5312. InfCode int `json:"infcode"`
  5313. Output struct {
  5314. Result []struct {
  5315. BasMednFlag string `json:"bas_medn_flag"`
  5316. ChldMedcFlag string `json:"chld_medc_flag"`
  5317. ChrgitmLv string `json:"chrgitm_lv"`
  5318. Cnt float64 `json:"cnt"`
  5319. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5320. DrtReimFlag string `json:"drt_reim_flag"`
  5321. FeedetlSn string `json:"feedetl_sn"`
  5322. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5323. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5324. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5325. ListSpItemFlag string `json:"list_sp_item_flag"`
  5326. LmtUsedFlag string `json:"lmt_used_flag"`
  5327. MedChrgitmType string `json:"med_chrgitm_type"`
  5328. Memo string `json:"memo"`
  5329. OverlmtAmt float64 `json:"overlmt_amt"`
  5330. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5331. Pric float64 `json:"pric"`
  5332. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5333. SelfpayProp float64 `json:"selfpay_prop"`
  5334. } `json:"result"`
  5335. } `json:"output"`
  5336. }
  5337. type Response struct {
  5338. Output Output `json:"output"`
  5339. Infcode int `json:"infcode"`
  5340. InfRefMsgID string `json:"inf_refmsgid"`
  5341. RefMsgTime string `json:"refmsg_time"`
  5342. RespondTime string `json:"respond_time"`
  5343. ErrMsg string `json:"err_msg"`
  5344. WarnMsg string `json:"warn_msg"`
  5345. SignType string `json:"signtype"`
  5346. CAInfo string `json:"cainfo"`
  5347. }
  5348. func (c *HisApiController) Getquerydata() {
  5349. query_type, _ := c.GetInt64("type")
  5350. refd_setl_flag := c.GetString("refd_setl_flag")
  5351. med_type := c.GetString("med_type")
  5352. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5353. cert_no := c.GetString("cert_no")
  5354. psn_no := c.GetString("psn_no")
  5355. start_time := c.GetString("start_time")
  5356. end_time := c.GetString("end_time")
  5357. page, _ := c.GetInt64("page")
  5358. limit, _ := c.GetInt64("limit")
  5359. var bp models.BusinessParams5262
  5360. bp.RefdSetlFlag = refd_setl_flag
  5361. bp.MedType = med_type
  5362. bp.Certno = cert_no
  5363. bp.Psnno = psn_no
  5364. bp.QBegntime = start_time
  5365. bp.QEndtime = end_time
  5366. if query_type == 1 { //本地
  5367. Post5262(c, bp, page, limit)
  5368. } else { //异地
  5369. Post5267(c, bp, page, limit)
  5370. }
  5371. }
  5372. func (c *HisApiController) Drugscheck() {
  5373. admin_user_id, _ := c.GetInt64("admin_user_id")
  5374. adminUser := c.GetAdminUserInfo()
  5375. var queryResult []QueryResult
  5376. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5377. for _, item := range drugs {
  5378. result := QueryResult{
  5379. ID: item.ID,
  5380. Name: item.DrugName,
  5381. Code: item.MedicalInsuranceNumber,
  5382. List_type_code: "101",
  5383. }
  5384. queryResult = append(queryResult, result)
  5385. }
  5386. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5387. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5388. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5389. for _, item := range queryResult {
  5390. 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)
  5391. }
  5392. }
  5393. func (c *HisApiController) Goodcheck() {
  5394. admin_user_id, _ := c.GetInt64("admin_user_id")
  5395. adminUser := c.GetAdminUserInfo()
  5396. var queryResult []QueryResult
  5397. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5398. for _, item := range goods {
  5399. result := QueryResult{
  5400. ID: item.ID,
  5401. Name: item.GoodName,
  5402. Code: item.SocialSecurityDirectoryCode,
  5403. List_type_code: "301",
  5404. }
  5405. queryResult = append(queryResult, result)
  5406. }
  5407. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5408. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5409. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5410. for _, item := range queryResult {
  5411. 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)
  5412. //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)
  5413. }
  5414. }
  5415. func (c *HisApiController) Projectcheck() {
  5416. admin_user_id, _ := c.GetInt64("admin_user_id")
  5417. adminUser := c.GetAdminUserInfo()
  5418. var queryResult []QueryResult
  5419. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5420. for _, item := range projects {
  5421. result := QueryResult{
  5422. ID: item.ID,
  5423. Name: item.ProjectName,
  5424. Code: item.MedicalCode,
  5425. List_type_code: "201",
  5426. }
  5427. queryResult = append(queryResult, result)
  5428. }
  5429. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5430. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5431. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5432. for _, item := range queryResult {
  5433. 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)
  5434. }
  5435. }
  5436. //func (c *HisApiController)CancleDia(){
  5437. //
  5438. // id, _ := c.GetInt64("id")
  5439. // record_time := c.GetString("record_time")
  5440. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5441. //
  5442. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5443. //
  5444. // diagnosis_id := c.GetString("diagnosis")
  5445. // sick_type, _ := c.GetInt64("sick_type")
  5446. // reg_type, _ := c.GetInt64("p_type")
  5447. // begin_time := c.GetString("begin_time")
  5448. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5449. //
  5450. //
  5451. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5452. //
  5453. // fmt.Println(acct_used_flag)
  5454. //
  5455. //
  5456. // timeLayout := "2006-01-02"
  5457. // loc, _ := time.LoadLocation("Local")
  5458. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5459. // if err != nil {
  5460. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5461. // return
  5462. // }
  5463. // recordDateTime := theTime.Unix()
  5464. // adminUser := c.GetAdminUserInfo()
  5465. //
  5466. //
  5467. //
  5468. //
  5469. //
  5470. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5471. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5472. // var patientPrescription models.HisPrescriptionInfo
  5473. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5474. // if patientPrescription.ID == 0 {
  5475. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5476. // }
  5477. // //if patientPrescription.Do
  5478. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5479. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5480. //
  5481. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5482. //
  5483. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5484. //
  5485. // var config []*models.HisXtDiagnoseConfig
  5486. // for _, item := range diagnosis_ids {
  5487. // id, _ := strconv.ParseInt(item, 10, 64)
  5488. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5489. // config = append(config, &diagnosisConfig)
  5490. // }
  5491. //
  5492. // sickConfig, _ := service.FindSickById(sick_type)
  5493. //
  5494. //
  5495. // data := make(map[string]interface{})
  5496. // client := &http.Client{}
  5497. // data["psn_no"] = his.PsnNo
  5498. // data["mdtrt_id"] = his.Number
  5499. // data["doctor"] = roles.UserName
  5500. // data["department"] = department.Name
  5501. // data["org_name"] = miConfig.OrgName
  5502. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5503. // data["doctor_id"] = doctor_info.DoctorNumber
  5504. // data["new_doctor_name"] = doctor_info.UserName
  5505. // data["fixmedins_code"] = miConfig.Code
  5506. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5507. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5508. // data["secret_key"] = miConfig.SecretKey
  5509. // data["sick_code"] = sickConfig.CountryCode
  5510. // data["sick_name"] = sickConfig.ClassName
  5511. // data["url"] = miConfig.Url
  5512. // data["ak"] = miConfig.AccessKey
  5513. // data["begin_time"] = begin_time
  5514. // data["cainfo"] = miConfig.Cainfo
  5515. // data["is_vaild"] = "0"
  5516. //
  5517. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5518. // data["config"] = config
  5519. // bytesData, _ := json.Marshal(data)
  5520. //
  5521. // var req *http.Request
  5522. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5523. // resp, _ := client.Do(req)
  5524. // defer resp.Body.Close()
  5525. // body, ioErr := ioutil.ReadAll(resp.Body)
  5526. // if ioErr != nil {
  5527. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5528. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5529. // return
  5530. // }
  5531. // var respJSON map[string]interface{}
  5532. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5533. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5534. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5535. // return
  5536. // }
  5537. //
  5538. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5539. // userJSONBytes, _ := json.Marshal(respJSON)
  5540. // fmt.Println("log")
  5541. // fmt.Println(string(userJSONBytes))
  5542. //
  5543. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5544. // utils.ErrorLog("解析失败:%v", err)
  5545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5546. // return
  5547. // }
  5548. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5549. // res2.Output = ressix10265.Output
  5550. // res2.ErrMsg = ressix10265.ErrMsg
  5551. // res2.Cainfo = ressix10265.Cainfo
  5552. // res2.WarnMsg = ressix10265.WarnMsg
  5553. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5554. // res2.Infcode = infocode
  5555. //
  5556. //}
  5557. func (c *HisApiController) Get4102() {
  5558. order_id, _ := c.GetInt64("order_id")
  5559. admin_user_id, _ := c.GetInt64("admin_user_id")
  5560. stas_type := c.GetString("stas_type")
  5561. order, _ := service.GetHisOrderByIDTwo(order_id)
  5562. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5563. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5564. var pp models.PublicParams
  5565. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5566. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5567. pp.FixmedinsName = miConfig.OrgName
  5568. pp.FixmedinsCode = miConfig.Code
  5569. pp.RequestUrl = miConfig.Url
  5570. pp.Cainfo = miConfig.Cainfo
  5571. pp.SecretKey = miConfig.SecretKey
  5572. pp.AccessKey = miConfig.AccessKey
  5573. pp.OpterName = curRoles.UserName
  5574. if miConfig.MdtrtareaAdmvs == "350500" {
  5575. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5576. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5577. saveLog(result, request, "4102", "清单确认")
  5578. var dat map[string]interface{}
  5579. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5580. fmt.Println(dat)
  5581. } else {
  5582. fmt.Println(err)
  5583. }
  5584. var empty ResultFourteen
  5585. userJSONBytes, _ := json.Marshal(dat)
  5586. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5587. utils.ErrorLog("解析失败:%v", err)
  5588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5589. return
  5590. }
  5591. if empty.Infcode == 0 {
  5592. c.ServeSuccessJSON(map[string]interface{}{
  5593. "msg": "确认成功",
  5594. })
  5595. return
  5596. }
  5597. } else {
  5598. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5599. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5600. result3, request3 := service.Jxyb4105(pp)
  5601. saveLog(result, request, "4102", "清单确认")
  5602. saveLog(result2, request2, "4103", "清单确认")
  5603. saveLog(result3, request3, "4105", "清单统计")
  5604. var dat map[string]interface{}
  5605. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5606. fmt.Println(dat)
  5607. } else {
  5608. fmt.Println(err)
  5609. }
  5610. var empty ResultFourteen
  5611. userJSONBytes, _ := json.Marshal(dat)
  5612. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5613. utils.ErrorLog("解析失败:%v", err)
  5614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5615. return
  5616. }
  5617. if empty.Infcode == 0 {
  5618. c.ServeSuccessJSON(map[string]interface{}{
  5619. "msg": "确认成功",
  5620. })
  5621. return
  5622. }
  5623. }
  5624. }
  5625. // 对账权限查询
  5626. func (c *HisApiController) Get3260() {
  5627. admin_user_id, _ := c.GetInt64("admin_user_id")
  5628. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5629. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5630. var api string
  5631. var res models.JSResult3260
  5632. if miConfig.MdtrtareaAdmvs == "320921" {
  5633. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5634. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5635. } else {
  5636. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5637. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5638. }
  5639. resp, requestErr := http.Get(api)
  5640. if requestErr != nil {
  5641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5642. return
  5643. }
  5644. body, ioErr := ioutil.ReadAll(resp.Body)
  5645. if ioErr != nil {
  5646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5648. return
  5649. }
  5650. var respJSON map[string]interface{}
  5651. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5654. return
  5655. }
  5656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5657. result, _ := json.Marshal(respJSON)
  5658. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5659. utils.ErrorLog("解析失败:%v", err)
  5660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5661. return
  5662. }
  5663. if res.Infcode == "0" {
  5664. c.ServeSuccessJSON(map[string]interface{}{
  5665. "result": res.Output.Data,
  5666. })
  5667. } else {
  5668. c.ServeSuccessJSON(map[string]interface{}{
  5669. "failed_code": -10,
  5670. "msg": res.ErrMsg,
  5671. })
  5672. return
  5673. }
  5674. }
  5675. func (c *HisApiController) Get3261() {
  5676. admin_user_id, _ := c.GetInt64("admin_user_id")
  5677. //month := c.GetString("month")
  5678. startTime := c.GetString("start_time")
  5679. //endTime, _ := c.GetString("end_time")
  5680. times := strings.Split(startTime, "-")
  5681. stmt_mon := times[0] + times[1]
  5682. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5683. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5684. var api string
  5685. var res models.JSResult3261
  5686. //var res10265 Result5301For10265
  5687. if miConfig.MdtrtareaAdmvs == "320921" {
  5688. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5689. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5690. } else {
  5691. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5692. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5693. }
  5694. resp, requestErr := http.Get(api)
  5695. if requestErr != nil {
  5696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5697. return
  5698. }
  5699. body, ioErr := ioutil.ReadAll(resp.Body)
  5700. if ioErr != nil {
  5701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5703. return
  5704. }
  5705. var respJSON map[string]interface{}
  5706. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5709. return
  5710. }
  5711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5712. result, _ := json.Marshal(respJSON)
  5713. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5714. utils.ErrorLog("解析失败:%v", err)
  5715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5716. return
  5717. }
  5718. if res.Infcode == "0" {
  5719. c.ServeSuccessJSON(map[string]interface{}{
  5720. "result": res.Output,
  5721. })
  5722. } else {
  5723. c.ServeSuccessJSON(map[string]interface{}{
  5724. "failed_code": -10,
  5725. "msg": res.ErrMsg,
  5726. })
  5727. return
  5728. }
  5729. }
  5730. type TempFun struct {
  5731. FundKey string
  5732. FundCode string
  5733. }
  5734. func (c *HisApiController) Get3262() {
  5735. admin_user_id, _ := c.GetInt64("admin_user_id")
  5736. startTime := c.GetString("start_time")
  5737. endTime := c.GetString("end_time")
  5738. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5739. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5740. //timeLayout := "2006-01-02"
  5741. //loc, _ := time.LoadLocation("Local")
  5742. //var theStartTIme int64
  5743. //if len(startTime) > 0 {
  5744. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  5745. // if err != nil {
  5746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5747. // return
  5748. // }
  5749. // theStartTIme = theTime.Unix()
  5750. //}
  5751. //var theEndtTIme int64
  5752. //if len(endTime) > 0 {
  5753. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  5754. // if err != nil {
  5755. // utils.ErrorLog(err.Error())
  5756. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5757. // return
  5758. // }
  5759. // theEndtTIme = theTime.Unix()
  5760. //}
  5761. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5762. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5763. for _, team := range datas {
  5764. fmt.Println(team.PsnTime)
  5765. for _, team_two := range datas_two {
  5766. fmt.Println(team_two.PsnTime)
  5767. if team.FundKey == team_two.FundKey {
  5768. fmt.Println(team_two.PsnTime)
  5769. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  5770. fmt.Println(team.PsnTime)
  5771. }
  5772. }
  5773. }
  5774. fmt.Println("1111")
  5775. fmt.Println(datas)
  5776. fmt.Println("1111")
  5777. var twos []models.FixMonRecDetailFileInTwo
  5778. for _, team := range datas {
  5779. var two models.FixMonRecDetailFileInTwo
  5780. two.MedType = team.MedType
  5781. two.Insutype = team.Insutype
  5782. two.PsnType = team.PsnType
  5783. two.MedType = team.MedType
  5784. two.FixBlngAdmdvs = "999999"
  5785. two.InsuAdmdvs = "555555"
  5786. two.PsnTime = team.PsnTime
  5787. two.PsnCnt = team.PsnCnt
  5788. two.FundKey = team.FundKey
  5789. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  5790. fps, _ := strconv.ParseFloat(team.Fund, 64)
  5791. ia, _ := strconv.ParseFloat(team.Amt, 64)
  5792. two.MedfeeSumAmt = ms
  5793. two.InscpAmt = ia
  5794. two.FundPaySumAmt = fps
  5795. twos = append(twos, two)
  5796. }
  5797. //startTime := c.GetString("start_time")
  5798. //endTime, _ := c.GetString("end_time")
  5799. times := strings.Split(startTime, "-")
  5800. stmt_mon := times[0] + times[1]
  5801. var funs []models.FundDetail
  5802. for _, item := range datas {
  5803. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  5804. funs = append(funs, fun...)
  5805. }
  5806. var funInfos []models.Fund
  5807. //for _, item := range funs {
  5808. // var rf []models.FundInfo
  5809. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  5810. // for _, subitem := range rf {
  5811. // var fund models.Fund
  5812. // fund.FundCode = subitem.FundPayType
  5813. // fund.FundName = subitem.FundPayTypeName
  5814. // fund.FundAmt = subitem.FundPayAmt
  5815. // fund.FundKey = item.FundKey
  5816. // fund.InsuAdmdvs = "555555"
  5817. // fund.FixBlngAdmdvs = "999999"
  5818. // funInfos = append(funInfos, fund)
  5819. // }
  5820. //}
  5821. var tempFuns []TempFun
  5822. for _, funInfo := range funInfos {
  5823. var tempFun TempFun
  5824. tempFun.FundKey = funInfo.FundKey
  5825. tempFun.FundCode = funInfo.FundCode
  5826. tempFuns = append(tempFuns, tempFun)
  5827. }
  5828. tempFuns = RemoveRepeatedFunElement(tempFuns)
  5829. fmt.Println(tempFuns)
  5830. var funInfosTwo []models.Fund
  5831. decimal.DivisionPrecision = 2
  5832. for _, item := range tempFuns {
  5833. var fund models.Fund
  5834. for _, subItem := range funInfos {
  5835. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  5836. fund.FundKey = subItem.FundKey
  5837. fund.InsuAdmdvs = subItem.InsuAdmdvs
  5838. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  5839. fund.FundName = subItem.FundName
  5840. fund.FundCode = subItem.FundCode
  5841. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  5842. }
  5843. }
  5844. funInfosTwo = append(funInfosTwo, fund)
  5845. }
  5846. fmt.Println("funInfosTwo")
  5847. fmt.Println(funInfosTwo)
  5848. var upld_btch string
  5849. var empty models.JSResultEmpty
  5850. data := make(map[string]interface{})
  5851. data["org_name"] = miConfig.OrgName
  5852. data["doctor"] = curRoles.UserName
  5853. data["doctor_name"] = curRoles.UserName
  5854. data["fixmedins_code"] = miConfig.Code
  5855. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5856. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5857. data["secret_key"] = miConfig.SecretKey
  5858. data["url"] = miConfig.Url
  5859. data["ak"] = miConfig.AccessKey
  5860. data["cainfo"] = miConfig.Cainfo
  5861. data["datas"] = twos
  5862. data["fund"] = funInfosTwo
  5863. fmt.Println(twos)
  5864. month := time.Unix(1557042972, 0).Format("1")
  5865. year := time.Now().Format("2006")
  5866. month = time.Now().Format("01")
  5867. day := time.Now().Format("02")
  5868. hour := time.Now().Format("15")
  5869. min := time.Now().Format("04")
  5870. sec := time.Now().Format("05")
  5871. fix_fill_date := year + month + day + hour + min + sec
  5872. data["fix_fill_dept"] = miConfig.OrgName
  5873. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5874. data["fix_fill_psn"] = curRoles.UserName
  5875. data["fix_fill_date"] = fix_fill_date
  5876. data["stmt_loc"] = "2"
  5877. data["setl_mon"] = stmt_mon
  5878. upld_btch = "0"
  5879. data["upld_btch"] = upld_btch
  5880. //fmt.Println(data)
  5881. client := &http.Client{}
  5882. bytesData, _ := json.Marshal(data)
  5883. var req *http.Request
  5884. if miConfig.MdtrtareaAdmvs == "320921" {
  5885. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5886. } else {
  5887. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5888. }
  5889. resp, _ := client.Do(req)
  5890. defer resp.Body.Close()
  5891. body, ioErr := ioutil.ReadAll(resp.Body)
  5892. if ioErr != nil {
  5893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5895. }
  5896. var respJSON map[string]interface{}
  5897. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5900. }
  5901. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5902. //fmt.Println(respJSON)
  5903. result, _ := json.Marshal(respJSON)
  5904. //fmt.Println(result)
  5905. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  5906. utils.ErrorLog("解析失败:%v", err)
  5907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5908. }
  5909. if empty.Infcode != "0" {
  5910. c.ServeSuccessJSON(map[string]interface{}{
  5911. "failed_code": -10,
  5912. "msg": empty.ErrMsg,
  5913. })
  5914. return
  5915. } else {
  5916. c.ServeSuccessJSON(map[string]interface{}{
  5917. "msg": "上传成功",
  5918. })
  5919. return
  5920. }
  5921. }
  5922. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  5923. newArr = make([]TempFun, 0)
  5924. for i := 0; i < len(arr); i++ {
  5925. repeat := false
  5926. for j := i + 1; j < len(arr); j++ {
  5927. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  5928. repeat = true
  5929. break
  5930. }
  5931. }
  5932. if !repeat {
  5933. newArr = append(newArr, arr[i])
  5934. }
  5935. }
  5936. return
  5937. }
  5938. func (c *HisApiController) Get3263() {
  5939. admin_user_id, _ := c.GetInt64("admin_user_id")
  5940. startTime := c.GetString("start_time")
  5941. //endTime, _ := c.GetString("end_time")
  5942. times := strings.Split(startTime, "-")
  5943. setl_mon := times[0] + times[1]
  5944. upld_btch := "0"
  5945. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5946. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5947. var result3263 models.JSResult3263
  5948. data := make(map[string]interface{})
  5949. data["org_name"] = miConfig.OrgName
  5950. data["doctor"] = curRoles.UserName
  5951. data["doctor_name"] = curRoles.UserName
  5952. data["fixmedins_code"] = miConfig.Code
  5953. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5954. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5955. data["secret_key"] = miConfig.SecretKey
  5956. data["url"] = miConfig.Url
  5957. data["ak"] = miConfig.AccessKey
  5958. data["cainfo"] = miConfig.Cainfo
  5959. data["setl_mon"] = setl_mon
  5960. data["stmt_loc"] = "2"
  5961. data["upld_btch"] = upld_btch
  5962. client := &http.Client{}
  5963. bytesData, _ := json.Marshal(data)
  5964. var req *http.Request
  5965. if miConfig.MdtrtareaAdmvs == "320921" {
  5966. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5967. } else {
  5968. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5969. }
  5970. resp, _ := client.Do(req)
  5971. defer resp.Body.Close()
  5972. body, ioErr := ioutil.ReadAll(resp.Body)
  5973. if ioErr != nil {
  5974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5976. }
  5977. var respJSON map[string]interface{}
  5978. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5981. }
  5982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5983. fmt.Println(respJSON)
  5984. result, _ := json.Marshal(respJSON)
  5985. fmt.Println(result)
  5986. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  5987. utils.ErrorLog("解析失败:%v", err)
  5988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5989. }
  5990. if result3263.Infcode != "0" {
  5991. c.ServeSuccessJSON(map[string]interface{}{
  5992. "failed_code": -10,
  5993. "msg": result3263.ErrMsg,
  5994. })
  5995. return
  5996. } else {
  5997. c.ServeSuccessJSON(map[string]interface{}{
  5998. "list": result3263.Output,
  5999. })
  6000. return
  6001. }
  6002. }
  6003. func (c *HisApiController) Get3264() {
  6004. admin_user_id, _ := c.GetInt64("admin_user_id")
  6005. startTime := c.GetString("start_time")
  6006. //endTime, _ := c.GetString("end_time")
  6007. times := strings.Split(startTime, "-")
  6008. setl_mon := times[0] + times[1]
  6009. upld_btch := "0"
  6010. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6011. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6012. //solidify_id := []
  6013. var result3263 models.JSResult3263
  6014. data := make(map[string]interface{})
  6015. data["org_name"] = miConfig.OrgName
  6016. data["doctor"] = curRoles.UserName
  6017. data["doctor_name"] = curRoles.UserName
  6018. data["fixmedins_code"] = miConfig.Code
  6019. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6020. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6021. data["secret_key"] = miConfig.SecretKey
  6022. data["url"] = miConfig.Url
  6023. data["ak"] = miConfig.AccessKey
  6024. data["cainfo"] = miConfig.Cainfo
  6025. data["setl_mon"] = setl_mon
  6026. data["stmt_loc"] = "2"
  6027. data["upld_btch"] = upld_btch
  6028. client := &http.Client{}
  6029. bytesData, _ := json.Marshal(data)
  6030. var req3263 *http.Request
  6031. if miConfig.MdtrtareaAdmvs == "320921" {
  6032. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6033. } else {
  6034. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6035. }
  6036. resp, _ := client.Do(req3263)
  6037. defer resp.Body.Close()
  6038. body, ioErr := ioutil.ReadAll(resp.Body)
  6039. if ioErr != nil {
  6040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6042. }
  6043. var respJSON3263 map[string]interface{}
  6044. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6047. }
  6048. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6049. fmt.Println(respJSON3263)
  6050. result, _ := json.Marshal(respJSON3263)
  6051. fmt.Println(result)
  6052. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6053. utils.ErrorLog("解析失败:%v", err)
  6054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6055. }
  6056. var ids []string
  6057. for _, item := range result3263.Output {
  6058. ids = append(ids, item.SolidifyID)
  6059. }
  6060. var empty models.JSResultEmpty
  6061. data2 := make(map[string]interface{})
  6062. data2["org_name"] = miConfig.OrgName
  6063. data2["doctor"] = curRoles.UserName
  6064. data2["doctor_name"] = curRoles.UserName
  6065. data2["fixmedins_code"] = miConfig.Code
  6066. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6067. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6068. data2["secret_key"] = miConfig.SecretKey
  6069. data2["url"] = miConfig.Url
  6070. data2["ak"] = miConfig.AccessKey
  6071. data2["cainfo"] = miConfig.Cainfo
  6072. data2["setl_mon"] = setl_mon
  6073. data2["stmt_loc"] = "2"
  6074. data2["upld_btch"] = upld_btch
  6075. data2["solidify_id"] = ids
  6076. client2 := &http.Client{}
  6077. bytesData2, _ := json.Marshal(data2)
  6078. var req *http.Request
  6079. if miConfig.MdtrtareaAdmvs == "320921" {
  6080. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6081. } else {
  6082. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6083. }
  6084. resp2, _ := client2.Do(req)
  6085. defer resp.Body.Close()
  6086. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6087. if ioErr2 != nil {
  6088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6090. }
  6091. var respJSON map[string]interface{}
  6092. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6095. }
  6096. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6097. fmt.Println(respJSON)
  6098. result2, _ := json.Marshal(respJSON)
  6099. fmt.Println(result2)
  6100. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6101. utils.ErrorLog("解析失败:%v", err)
  6102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6103. }
  6104. if empty.Infcode != "0" {
  6105. c.ServeSuccessJSON(map[string]interface{}{
  6106. "failed_code": -10,
  6107. "msg": empty.ErrMsg,
  6108. })
  6109. return
  6110. } else {
  6111. c.ServeSuccessJSON(map[string]interface{}{
  6112. "msg": "",
  6113. })
  6114. return
  6115. }
  6116. }
  6117. func (c *HisApiController) Get3265() {
  6118. admin_user_id, _ := c.GetInt64("admin_user_id")
  6119. startTime := c.GetString("start_time")
  6120. //endTime, _ := c.GetString("end_time")
  6121. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6122. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6123. times := strings.Split(startTime, "-")
  6124. setl_mon := times[0] + times[1]
  6125. var upld_btch string
  6126. upld_btch = "0"
  6127. //var empty models.JSResultEmpty
  6128. var result3265 models.JSResult3264
  6129. var result3263 models.JSResult3263
  6130. data2 := make(map[string]interface{})
  6131. data2["org_name"] = miConfig.OrgName
  6132. data2["doctor"] = curRoles.UserName
  6133. data2["doctor_name"] = curRoles.UserName
  6134. data2["fixmedins_code"] = miConfig.Code
  6135. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6136. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6137. data2["secret_key"] = miConfig.SecretKey
  6138. data2["url"] = miConfig.Url
  6139. data2["ak"] = miConfig.AccessKey
  6140. data2["cainfo"] = miConfig.Cainfo
  6141. data2["setl_mon"] = setl_mon
  6142. data2["stmt_loc"] = "2"
  6143. data2["upld_btch"] = upld_btch
  6144. client2 := &http.Client{}
  6145. bytesData2, _ := json.Marshal(data2)
  6146. var req3263 *http.Request
  6147. if miConfig.MdtrtareaAdmvs == "320921" {
  6148. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6149. } else {
  6150. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6151. }
  6152. resp2, _ := client2.Do(req3263)
  6153. defer resp2.Body.Close()
  6154. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6155. if ioErr2 != nil {
  6156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6158. }
  6159. var respJSON3263 map[string]interface{}
  6160. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6163. }
  6164. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6165. fmt.Println(respJSON3263)
  6166. result2, _ := json.Marshal(respJSON3263)
  6167. fmt.Println(result2)
  6168. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6169. utils.ErrorLog("解析失败:%v", err)
  6170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6171. }
  6172. var ids []string
  6173. for _, item := range result3263.Output {
  6174. ids = append(ids, item.SolidifyID)
  6175. }
  6176. data := make(map[string]interface{})
  6177. data["org_name"] = miConfig.OrgName
  6178. data["doctor"] = curRoles.UserName
  6179. data["doctor_name"] = curRoles.UserName
  6180. data["fixmedins_code"] = miConfig.Code
  6181. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6182. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6183. data["secret_key"] = miConfig.SecretKey
  6184. data["url"] = miConfig.Url
  6185. data["ak"] = miConfig.AccessKey
  6186. data["cainfo"] = miConfig.Cainfo
  6187. data["setl_mon"] = setl_mon
  6188. data["solidify_id"] = ids
  6189. month := time.Unix(1557042972, 0).Format("1")
  6190. year := time.Now().Format("2006")
  6191. month = time.Now().Format("01")
  6192. day := time.Now().Format("02")
  6193. hour := time.Now().Format("15")
  6194. min := time.Now().Format("04")
  6195. sec := time.Now().Format("05")
  6196. fix_fill_date := year + month + day + hour + min + sec
  6197. data["fix_fill_dept"] = miConfig.OrgName
  6198. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6199. data["fix_fill_psn"] = curRoles.UserName
  6200. data["fix_fill_date"] = fix_fill_date
  6201. data["stmt_loc"] = "2"
  6202. data["upld_btch"] = upld_btch
  6203. client := &http.Client{}
  6204. bytesData, _ := json.Marshal(data)
  6205. var req *http.Request
  6206. if miConfig.MdtrtareaAdmvs == "320921" {
  6207. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6208. } else {
  6209. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6210. }
  6211. resp, _ := client.Do(req)
  6212. defer resp.Body.Close()
  6213. body, ioErr := ioutil.ReadAll(resp.Body)
  6214. if ioErr != nil {
  6215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6217. }
  6218. var respJSON map[string]interface{}
  6219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6222. }
  6223. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6224. fmt.Println(respJSON)
  6225. result, _ := json.Marshal(respJSON)
  6226. fmt.Println(result)
  6227. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6228. utils.ErrorLog("解析失败:%v", err)
  6229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6230. }
  6231. if result3265.Infcode != "0" {
  6232. c.ServeSuccessJSON(map[string]interface{}{
  6233. "failed_code": -10,
  6234. "msg": result3265.ErrMsg,
  6235. })
  6236. return
  6237. } else {
  6238. c.ServeSuccessJSON(map[string]interface{}{
  6239. "info": result3265.Output,
  6240. })
  6241. return
  6242. }
  6243. }
  6244. func (c *HisApiController) Get3266() {
  6245. admin_user_id, _ := c.GetInt64("admin_user_id")
  6246. startTime := c.GetString("start_time")
  6247. //endTime, _ := c.GetString("end_time")
  6248. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6249. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6250. times := strings.Split(startTime, "-")
  6251. stmt_mon := times[0] + times[1]
  6252. var upld_btch string
  6253. //var empty models.JSResultEmpty
  6254. var result3265 models.JSResult3264
  6255. data := make(map[string]interface{})
  6256. data["org_name"] = miConfig.OrgName
  6257. data["doctor"] = curRoles.UserName
  6258. data["doctor_name"] = curRoles.UserName
  6259. data["fixmedins_code"] = miConfig.Code
  6260. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6261. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6262. data["secret_key"] = miConfig.SecretKey
  6263. data["url"] = miConfig.Url
  6264. data["ak"] = miConfig.AccessKey
  6265. data["cainfo"] = miConfig.Cainfo
  6266. data["setl_mon"] = stmt_mon
  6267. month := time.Unix(1557042972, 0).Format("1")
  6268. year := time.Now().Format("2006")
  6269. month = time.Now().Format("01")
  6270. day := time.Now().Format("02")
  6271. hour := time.Now().Format("15")
  6272. min := time.Now().Format("04")
  6273. sec := time.Now().Format("05")
  6274. fix_fill_date := year + month + day + hour + min + sec
  6275. data["fix_fill_dept"] = miConfig.OrgName
  6276. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6277. data["fix_fill_psn"] = curRoles.UserName
  6278. data["fix_fill_date"] = fix_fill_date
  6279. data["stmt_loc"] = "2"
  6280. upld_btch = "0"
  6281. data["upld_btch"] = upld_btch
  6282. client := &http.Client{}
  6283. bytesData, _ := json.Marshal(data)
  6284. var req *http.Request
  6285. if miConfig.MdtrtareaAdmvs == "320921" {
  6286. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6287. } else {
  6288. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6289. }
  6290. resp, _ := client.Do(req)
  6291. defer resp.Body.Close()
  6292. body, ioErr := ioutil.ReadAll(resp.Body)
  6293. if ioErr != nil {
  6294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6296. }
  6297. var respJSON map[string]interface{}
  6298. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6301. }
  6302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6303. fmt.Println(respJSON)
  6304. result, _ := json.Marshal(respJSON)
  6305. fmt.Println(result)
  6306. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6307. utils.ErrorLog("解析失败:%v", err)
  6308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6309. }
  6310. if result3265.Infcode != "0" {
  6311. c.ServeSuccessJSON(map[string]interface{}{
  6312. "failed_code": -10,
  6313. "msg": result3265.ErrMsg,
  6314. })
  6315. return
  6316. } else {
  6317. c.ServeSuccessJSON(map[string]interface{}{
  6318. "info": result3265.Output,
  6319. })
  6320. return
  6321. }
  6322. }
  6323. func (c *HisApiController) Get3267() {
  6324. admin_user_id, _ := c.GetInt64("admin_user_id")
  6325. startTime := c.GetString("start_time")
  6326. //endTime, _ := c.GetString("end_time")
  6327. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6328. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6329. times := strings.Split(startTime, "-")
  6330. setl_mon := times[0] + times[1]
  6331. var upld_btch string
  6332. //var empty models.JSResultEmpty
  6333. var result3265 models.JSResult3264
  6334. upld_btch = "0"
  6335. data := make(map[string]interface{})
  6336. data["org_name"] = miConfig.OrgName
  6337. data["doctor"] = curRoles.UserName
  6338. data["doctor_name"] = curRoles.UserName
  6339. data["fixmedins_code"] = miConfig.Code
  6340. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6341. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6342. data["secret_key"] = miConfig.SecretKey
  6343. data["url"] = miConfig.Url
  6344. data["ak"] = miConfig.AccessKey
  6345. data["cainfo"] = miConfig.Cainfo
  6346. data["setl_mon"] = setl_mon
  6347. data["stmt_loc"] = "2"
  6348. data["upld_btch"] = upld_btch
  6349. client := &http.Client{}
  6350. bytesData, _ := json.Marshal(data)
  6351. var req *http.Request
  6352. if miConfig.MdtrtareaAdmvs == "320921" {
  6353. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6354. } else {
  6355. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6356. }
  6357. resp, _ := client.Do(req)
  6358. defer resp.Body.Close()
  6359. body, ioErr := ioutil.ReadAll(resp.Body)
  6360. if ioErr != nil {
  6361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6363. }
  6364. var respJSON map[string]interface{}
  6365. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6368. }
  6369. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6370. fmt.Println(respJSON)
  6371. result, _ := json.Marshal(respJSON)
  6372. fmt.Println(result)
  6373. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6374. utils.ErrorLog("解析失败:%v", err)
  6375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6376. }
  6377. if result3265.Infcode != "0" {
  6378. c.ServeSuccessJSON(map[string]interface{}{
  6379. "failed_code": -10,
  6380. "msg": result3265.ErrMsg,
  6381. })
  6382. return
  6383. } else {
  6384. c.ServeSuccessJSON(map[string]interface{}{
  6385. "info": result3265.Output.Data,
  6386. })
  6387. return
  6388. }
  6389. }
  6390. func (c *HisApiController) Get3268() {
  6391. admin_user_id, _ := c.GetInt64("admin_user_id")
  6392. startTime := c.GetString("start_time")
  6393. endTime := c.GetString("end_time")
  6394. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6395. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6396. times := strings.Split(startTime, "-")
  6397. setl_mon := times[0] + times[1]
  6398. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6399. var twos []models.FixMonRecDetailFileInTwo
  6400. var funs []models.FundDetail
  6401. for _, item := range datas {
  6402. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6403. funs = append(funs, fun...)
  6404. }
  6405. var funInfos []models.Fund
  6406. //for _, item := range funs {
  6407. // var rf []models.FundInfo
  6408. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6409. // for _, subitem := range rf {
  6410. // var fund models.Fund
  6411. // fund.FundCode = subitem.FundPayType
  6412. // fund.FundName = subitem.FundPayTypeName
  6413. // fund.FundAmt = subitem.FundPayAmt
  6414. // fund.FundKey = item.FundKey
  6415. // fund.InsuAdmdvs = "555555"
  6416. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6417. // funInfos = append(funInfos, fund)
  6418. // }
  6419. //}
  6420. for _, team := range datas {
  6421. var two models.FixMonRecDetailFileInTwo
  6422. two.SetlDate = time.Now().Format("2006-01-02")
  6423. two.MedType = team.MedType
  6424. two.Insutype = team.Insutype
  6425. two.PsnType = team.PsnType
  6426. two.MedType = team.MedType
  6427. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6428. two.InsuAdmdvs = team.InsuAdmdvs
  6429. two.PsnTime = team.PsnTime
  6430. two.PsnCnt = team.PsnCnt
  6431. two.FundKey = team.FundKey
  6432. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6433. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6434. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6435. two.MedfeeSumAmt = ms
  6436. two.InscpAmt = ia
  6437. two.FundPaySumAmt = fps
  6438. twos = append(twos, two)
  6439. }
  6440. var upld_btch string
  6441. upld_btch = "0"
  6442. var empty models.JSResultEmpty
  6443. data := make(map[string]interface{})
  6444. data["org_name"] = miConfig.OrgName
  6445. data["doctor"] = curRoles.UserName
  6446. data["doctor_name"] = curRoles.UserName
  6447. data["fixmedins_code"] = miConfig.Code
  6448. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6449. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6450. data["secret_key"] = miConfig.SecretKey
  6451. data["url"] = miConfig.Url
  6452. data["ak"] = miConfig.AccessKey
  6453. data["cainfo"] = miConfig.Cainfo
  6454. data["datas"] = twos
  6455. data["fund"] = funInfos
  6456. data["setl_mon"] = setl_mon
  6457. month := time.Unix(1557042972, 0).Format("1")
  6458. year := time.Now().Format("2006")
  6459. month = time.Now().Format("01")
  6460. day := time.Now().Format("02")
  6461. hour := time.Now().Format("15")
  6462. min := time.Now().Format("04")
  6463. sec := time.Now().Format("05")
  6464. fix_fill_date := year + month + day + hour + min + sec
  6465. data["fix_fill_dept"] = miConfig.OrgName
  6466. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6467. data["fix_fill_psn"] = curRoles.UserName
  6468. data["fix_fill_date"] = fix_fill_date
  6469. data["stmt_loc"] = "2"
  6470. data["upld_btch"] = upld_btch
  6471. client := &http.Client{}
  6472. bytesData, _ := json.Marshal(data)
  6473. var req *http.Request
  6474. if miConfig.MdtrtareaAdmvs == "320921" {
  6475. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6476. } else {
  6477. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6478. }
  6479. resp, _ := client.Do(req)
  6480. defer resp.Body.Close()
  6481. body, ioErr := ioutil.ReadAll(resp.Body)
  6482. if ioErr != nil {
  6483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6485. }
  6486. var respJSON map[string]interface{}
  6487. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6490. }
  6491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6492. fmt.Println(respJSON)
  6493. result, _ := json.Marshal(respJSON)
  6494. fmt.Println(result)
  6495. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6496. utils.ErrorLog("解析失败:%v", err)
  6497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6498. }
  6499. if empty.Infcode != "0" {
  6500. c.ServeSuccessJSON(map[string]interface{}{
  6501. "failed_code": -10,
  6502. "msg": empty.ErrMsg,
  6503. })
  6504. return
  6505. } else {
  6506. c.ServeSuccessJSON(map[string]interface{}{
  6507. "msg": "上传成功",
  6508. })
  6509. return
  6510. }
  6511. }
  6512. func (c *HisApiController) Get3269() {
  6513. admin_user_id, _ := c.GetInt64("admin_user_id")
  6514. startTime := c.GetString("start_time")
  6515. //endTime, _ := c.GetString("end_time")
  6516. times := strings.Split(startTime, "-")
  6517. setl_mon := times[0] + times[1]
  6518. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6519. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6520. var result3263 models.JSResult3263
  6521. data := make(map[string]interface{})
  6522. data["org_name"] = miConfig.OrgName
  6523. data["doctor"] = curRoles.UserName
  6524. data["doctor_name"] = curRoles.UserName
  6525. data["fixmedins_code"] = miConfig.Code
  6526. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6527. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6528. data["secret_key"] = miConfig.SecretKey
  6529. data["url"] = miConfig.Url
  6530. data["ak"] = miConfig.AccessKey
  6531. data["cainfo"] = miConfig.Cainfo
  6532. data["setl_mon"] = setl_mon
  6533. data["stmt_loc"] = "2"
  6534. client := &http.Client{}
  6535. bytesData, _ := json.Marshal(data)
  6536. var req *http.Request
  6537. if miConfig.MdtrtareaAdmvs == "320921" {
  6538. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6539. } else {
  6540. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6541. }
  6542. resp, _ := client.Do(req)
  6543. defer resp.Body.Close()
  6544. body, ioErr := ioutil.ReadAll(resp.Body)
  6545. if ioErr != nil {
  6546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6548. }
  6549. var respJSON map[string]interface{}
  6550. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6553. }
  6554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6555. fmt.Println(respJSON)
  6556. result, _ := json.Marshal(respJSON)
  6557. fmt.Println(result)
  6558. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6559. utils.ErrorLog("解析失败:%v", err)
  6560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6561. }
  6562. if result3263.Infcode != "0" {
  6563. c.ServeSuccessJSON(map[string]interface{}{
  6564. "failed_code": -10,
  6565. "msg": result3263.ErrMsg,
  6566. })
  6567. return
  6568. } else {
  6569. c.ServeSuccessJSON(map[string]interface{}{
  6570. "msg": "上传成功",
  6571. })
  6572. return
  6573. }
  6574. }
  6575. func (c *HisApiController) Get3270() {
  6576. admin_user_id, _ := c.GetInt64("admin_user_id")
  6577. startTime := c.GetString("start_time")
  6578. //endTime, _ := c.GetString("end_time")
  6579. times := strings.Split(startTime, "-")
  6580. setl_mon := times[0] + times[1]
  6581. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6582. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6583. var result3263 models.JSResult3263
  6584. data2 := make(map[string]interface{})
  6585. data2["org_name"] = miConfig.OrgName
  6586. data2["doctor"] = curRoles.UserName
  6587. data2["doctor_name"] = curRoles.UserName
  6588. data2["fixmedins_code"] = miConfig.Code
  6589. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6590. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6591. data2["secret_key"] = miConfig.SecretKey
  6592. data2["url"] = miConfig.Url
  6593. data2["ak"] = miConfig.AccessKey
  6594. data2["cainfo"] = miConfig.Cainfo
  6595. data2["setl_mon"] = setl_mon
  6596. data2["stmt_loc"] = "2"
  6597. client2 := &http.Client{}
  6598. bytesData2, _ := json.Marshal(data2)
  6599. var req3263 *http.Request
  6600. if miConfig.MdtrtareaAdmvs == "320921" {
  6601. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6602. } else {
  6603. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6604. }
  6605. resp2, _ := client2.Do(req3263)
  6606. defer resp2.Body.Close()
  6607. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6608. if ioErr2 != nil {
  6609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6611. }
  6612. var respJSON3263 map[string]interface{}
  6613. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6616. }
  6617. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6618. fmt.Println(respJSON3263)
  6619. result2, _ := json.Marshal(respJSON3263)
  6620. fmt.Println(result2)
  6621. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6622. utils.ErrorLog("解析失败:%v", err)
  6623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6624. }
  6625. var ids []string
  6626. for _, item := range result3263.Output {
  6627. ids = append(ids, item.SolidifyID)
  6628. }
  6629. var result3264 models.JSResult3264
  6630. data := make(map[string]interface{})
  6631. data["org_name"] = miConfig.OrgName
  6632. data["doctor"] = curRoles.UserName
  6633. data["doctor_name"] = curRoles.UserName
  6634. data["fixmedins_code"] = miConfig.Code
  6635. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6636. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6637. data["secret_key"] = miConfig.SecretKey
  6638. data["url"] = miConfig.Url
  6639. data["ak"] = miConfig.AccessKey
  6640. data["cainfo"] = miConfig.Cainfo
  6641. data["setl_mon"] = setl_mon
  6642. data["stmt_loc"] = "2"
  6643. data["solidify_id"] = ids
  6644. client := &http.Client{}
  6645. bytesData, _ := json.Marshal(data)
  6646. var req *http.Request
  6647. if miConfig.MdtrtareaAdmvs == "320921" {
  6648. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6649. } else {
  6650. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6651. }
  6652. resp, _ := client.Do(req)
  6653. defer resp.Body.Close()
  6654. body, ioErr := ioutil.ReadAll(resp.Body)
  6655. if ioErr != nil {
  6656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6658. }
  6659. var respJSON map[string]interface{}
  6660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6663. }
  6664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6665. fmt.Println(respJSON)
  6666. result, _ := json.Marshal(respJSON)
  6667. fmt.Println(result)
  6668. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  6669. utils.ErrorLog("解析失败:%v", err)
  6670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6671. }
  6672. if result3264.Infcode != "0" {
  6673. c.ServeSuccessJSON(map[string]interface{}{
  6674. "failed_code": -10,
  6675. "msg": result3264.ErrMsg,
  6676. })
  6677. return
  6678. } else {
  6679. c.ServeSuccessJSON(map[string]interface{}{
  6680. "info": result3264.Output,
  6681. })
  6682. return
  6683. }
  6684. }
  6685. func (c *HisApiController) Get3271() {
  6686. admin_user_id, _ := c.GetInt64("admin_user_id")
  6687. startTime := c.GetString("start_time")
  6688. //endTime, _ := c.GetString("end_time")
  6689. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6690. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6691. times := strings.Split(startTime, "-")
  6692. setl_mon := times[0] + times[1]
  6693. //var empty models.JSResultEmpty
  6694. var result3265 models.JSResult3264
  6695. var result3263 models.JSResult3263
  6696. data2 := make(map[string]interface{})
  6697. data2["org_name"] = miConfig.OrgName
  6698. data2["doctor"] = curRoles.UserName
  6699. data2["doctor_name"] = curRoles.UserName
  6700. data2["fixmedins_code"] = miConfig.Code
  6701. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6702. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6703. data2["secret_key"] = miConfig.SecretKey
  6704. data2["url"] = miConfig.Url
  6705. data2["ak"] = miConfig.AccessKey
  6706. data2["cainfo"] = miConfig.Cainfo
  6707. data2["setl_mon"] = setl_mon
  6708. data2["stmt_loc"] = "2"
  6709. client2 := &http.Client{}
  6710. bytesData2, _ := json.Marshal(data2)
  6711. var req3263 *http.Request
  6712. if miConfig.MdtrtareaAdmvs == "320921" {
  6713. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6714. } else {
  6715. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6716. }
  6717. resp2, _ := client2.Do(req3263)
  6718. defer resp2.Body.Close()
  6719. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6720. if ioErr2 != nil {
  6721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6723. }
  6724. var respJSON3263 map[string]interface{}
  6725. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6728. }
  6729. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6730. fmt.Println(respJSON3263)
  6731. result2, _ := json.Marshal(respJSON3263)
  6732. fmt.Println(result2)
  6733. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6734. utils.ErrorLog("解析失败:%v", err)
  6735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6736. }
  6737. var ids []string
  6738. for _, item := range result3263.Output {
  6739. ids = append(ids, item.SolidifyID)
  6740. }
  6741. data := make(map[string]interface{})
  6742. data["org_name"] = miConfig.OrgName
  6743. data["doctor"] = curRoles.UserName
  6744. data["doctor_name"] = curRoles.UserName
  6745. data["fixmedins_code"] = miConfig.Code
  6746. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6747. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6748. data["secret_key"] = miConfig.SecretKey
  6749. data["url"] = miConfig.Url
  6750. data["ak"] = miConfig.AccessKey
  6751. data["cainfo"] = miConfig.Cainfo
  6752. data["setl_mon"] = setl_mon
  6753. data["solidify_id"] = ids
  6754. month := time.Unix(1557042972, 0).Format("1")
  6755. year := time.Now().Format("2006")
  6756. month = time.Now().Format("01")
  6757. day := time.Now().Format("02")
  6758. hour := time.Now().Format("15")
  6759. min := time.Now().Format("04")
  6760. sec := time.Now().Format("05")
  6761. fix_fill_date := year + month + day + hour + min + sec
  6762. data["fix_fill_dept"] = miConfig.OrgName
  6763. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6764. data["fix_fill_psn"] = curRoles.UserName
  6765. data["fix_fill_date"] = fix_fill_date
  6766. data["stmt_loc"] = "2"
  6767. client := &http.Client{}
  6768. bytesData, _ := json.Marshal(data)
  6769. var req *http.Request
  6770. if miConfig.MdtrtareaAdmvs == "320921" {
  6771. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6772. } else {
  6773. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6774. }
  6775. resp, _ := client.Do(req)
  6776. defer resp.Body.Close()
  6777. body, ioErr := ioutil.ReadAll(resp.Body)
  6778. if ioErr != nil {
  6779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6781. }
  6782. var respJSON map[string]interface{}
  6783. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6786. }
  6787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6788. fmt.Println(respJSON)
  6789. result, _ := json.Marshal(respJSON)
  6790. fmt.Println(result)
  6791. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6792. utils.ErrorLog("解析失败:%v", err)
  6793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6794. }
  6795. if result3265.Infcode != "0" {
  6796. c.ServeSuccessJSON(map[string]interface{}{
  6797. "failed_code": -10,
  6798. "msg": result3265.ErrMsg,
  6799. })
  6800. return
  6801. } else {
  6802. c.ServeSuccessJSON(map[string]interface{}{
  6803. "info": result3265.Output.Data,
  6804. })
  6805. return
  6806. }
  6807. }
  6808. func (c *HisApiController) Get3272() {
  6809. admin_user_id, _ := c.GetInt64("admin_user_id")
  6810. startTime := c.GetString("start_time")
  6811. //endTime, _ := c.GetString("end_time")
  6812. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6813. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6814. times := strings.Split(startTime, "-")
  6815. setl_mon := times[0] + times[1]
  6816. var upld_btch string
  6817. //var empty models.JSResultEmpty
  6818. var result3265 models.JSResult3264
  6819. data := make(map[string]interface{})
  6820. data["org_name"] = miConfig.OrgName
  6821. data["doctor"] = curRoles.UserName
  6822. data["doctor_name"] = curRoles.UserName
  6823. data["fixmedins_code"] = miConfig.Code
  6824. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6825. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6826. data["secret_key"] = miConfig.SecretKey
  6827. data["url"] = miConfig.Url
  6828. data["ak"] = miConfig.AccessKey
  6829. data["cainfo"] = miConfig.Cainfo
  6830. data["setl_mon"] = setl_mon
  6831. month := time.Unix(1557042972, 0).Format("1")
  6832. year := time.Now().Format("2006")
  6833. month = time.Now().Format("01")
  6834. day := time.Now().Format("02")
  6835. hour := time.Now().Format("15")
  6836. min := time.Now().Format("04")
  6837. sec := time.Now().Format("05")
  6838. fix_fill_date := year + month + day + hour + min + sec
  6839. data["fix_fill_dept"] = miConfig.OrgName
  6840. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6841. data["fix_fill_psn"] = curRoles.UserName
  6842. data["fix_fill_date"] = fix_fill_date
  6843. data["stmt_loc"] = "2"
  6844. data["upld_btch"] = upld_btch
  6845. client := &http.Client{}
  6846. bytesData, _ := json.Marshal(data)
  6847. var req *http.Request
  6848. if miConfig.MdtrtareaAdmvs == "320921" {
  6849. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6850. } else {
  6851. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6852. }
  6853. resp, _ := client.Do(req)
  6854. defer resp.Body.Close()
  6855. body, ioErr := ioutil.ReadAll(resp.Body)
  6856. if ioErr != nil {
  6857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6859. }
  6860. var respJSON map[string]interface{}
  6861. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6864. }
  6865. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6866. fmt.Println(respJSON)
  6867. result, _ := json.Marshal(respJSON)
  6868. fmt.Println(result)
  6869. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6870. utils.ErrorLog("解析失败:%v", err)
  6871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6872. }
  6873. if result3265.Infcode != "0" {
  6874. c.ServeSuccessJSON(map[string]interface{}{
  6875. "failed_code": -10,
  6876. "msg": result3265.ErrMsg,
  6877. })
  6878. return
  6879. } else {
  6880. c.ServeSuccessJSON(map[string]interface{}{
  6881. "info": result3265.Output,
  6882. })
  6883. return
  6884. }
  6885. }
  6886. func (c *HisApiController) Get3273() {
  6887. admin_user_id, _ := c.GetInt64("admin_user_id")
  6888. startTime := c.GetString("start_time")
  6889. //endTime, _ := c.GetString("end_time")
  6890. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6891. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6892. times := strings.Split(startTime, "-")
  6893. setl_mon := times[0] + times[1]
  6894. var result3265 models.JSResult3264
  6895. data := make(map[string]interface{})
  6896. data["org_name"] = miConfig.OrgName
  6897. data["doctor"] = curRoles.UserName
  6898. data["doctor_name"] = curRoles.UserName
  6899. data["fixmedins_code"] = miConfig.Code
  6900. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6901. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6902. data["secret_key"] = miConfig.SecretKey
  6903. data["url"] = miConfig.Url
  6904. data["ak"] = miConfig.AccessKey
  6905. data["cainfo"] = miConfig.Cainfo
  6906. data["setl_mon"] = setl_mon
  6907. data["stmt_loc"] = "2"
  6908. client := &http.Client{}
  6909. bytesData, _ := json.Marshal(data)
  6910. var req *http.Request
  6911. if miConfig.MdtrtareaAdmvs == "320921" {
  6912. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  6913. } else {
  6914. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  6915. }
  6916. resp, _ := client.Do(req)
  6917. defer resp.Body.Close()
  6918. body, ioErr := ioutil.ReadAll(resp.Body)
  6919. if ioErr != nil {
  6920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6922. }
  6923. var respJSON map[string]interface{}
  6924. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6927. }
  6928. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6929. fmt.Println(respJSON)
  6930. result, _ := json.Marshal(respJSON)
  6931. fmt.Println(result)
  6932. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6933. utils.ErrorLog("解析失败:%v", err)
  6934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6935. }
  6936. if result3265.Infcode != "0" {
  6937. c.ServeSuccessJSON(map[string]interface{}{
  6938. "failed_code": -10,
  6939. "msg": result3265.ErrMsg,
  6940. })
  6941. return
  6942. } else {
  6943. c.ServeSuccessJSON(map[string]interface{}{
  6944. "info": result3265.Output.Data,
  6945. })
  6946. return
  6947. }
  6948. }
  6949. func (c *HisApiController) Get3274() {
  6950. //if miConfig.MdtrtareaAdmvs == "320921" {
  6951. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6952. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6953. // "&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
  6954. //
  6955. //} else {
  6956. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6957. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6958. // "&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
  6959. //
  6960. //}
  6961. }
  6962. func (c *HisApiController) Get3275() {
  6963. //if miConfig.MdtrtareaAdmvs == "320921" {
  6964. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6965. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6966. // "&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
  6967. //
  6968. //} else {
  6969. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6970. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6971. // "&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
  6972. //
  6973. //}
  6974. }
  6975. func (c *HisApiController) Get3276() {
  6976. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6977. //month := c.GetString("month")
  6978. //
  6979. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6980. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6981. //var api string
  6982. //var res Result5301
  6983. //
  6984. //if miConfig.MdtrtareaAdmvs == "320921" {
  6985. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6986. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6987. //} else {
  6988. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6989. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6990. //}
  6991. //
  6992. //resp, requestErr := http.Get(api)
  6993. //if requestErr != nil {
  6994. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6995. // return
  6996. //}
  6997. //
  6998. //body, ioErr := ioutil.ReadAll(resp.Body)
  6999. //if ioErr != nil {
  7000. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7002. // return
  7003. //}
  7004. //var respJSON map[string]interface{}
  7005. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7006. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7008. // return
  7009. //}
  7010. //
  7011. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7012. //result, _ := json.Marshal(respJSON)
  7013. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7014. // utils.ErrorLog("解析失败:%v", err)
  7015. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7016. // return
  7017. //}
  7018. }
  7019. func (c *HisApiController) Get3277() {
  7020. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7021. //month := c.GetString("month")
  7022. //
  7023. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7024. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7025. //var api string
  7026. //var res Result5301
  7027. //
  7028. //if miConfig.MdtrtareaAdmvs == "320921" {
  7029. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7030. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7031. //} else {
  7032. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7033. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7034. //}
  7035. //
  7036. //resp, requestErr := http.Get(api)
  7037. //if requestErr != nil {
  7038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7039. // return
  7040. //}
  7041. //
  7042. //body, ioErr := ioutil.ReadAll(resp.Body)
  7043. //if ioErr != nil {
  7044. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7045. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7046. // return
  7047. //}
  7048. //var respJSON map[string]interface{}
  7049. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7050. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7051. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7052. // return
  7053. //}
  7054. //
  7055. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7056. //result, _ := json.Marshal(respJSON)
  7057. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7058. // utils.ErrorLog("解析失败:%v", err)
  7059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7060. // return
  7061. //}
  7062. }
  7063. func (c *HisApiController) GetCFYLJG001() {
  7064. admin_user_id, _ := c.GetInt64("admin_user_id")
  7065. patient_id, _ := c.GetInt64("patient_id")
  7066. his_patient_id, _ := c.GetInt64("his_patient_id")
  7067. record_time := c.GetString("record_time")
  7068. admin_user_id = 3626
  7069. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7070. psn, _ := service.GetPsnByPatientId(patient_id)
  7071. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7072. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7073. var cFYLJG001 models.CFYLJG001
  7074. timeLayout := "2006-01-02"
  7075. loc, _ := time.LoadLocation("Local")
  7076. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7077. if err != nil {
  7078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7079. return
  7080. }
  7081. recordDateTime := theTime.Unix()
  7082. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7083. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7084. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7085. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7086. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7087. for _, item := range prescriptions {
  7088. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7089. if his.IdCardType == 1 {
  7090. bas := strings.Split(psn.CardInfo, "|")
  7091. basNumber := bas[1]
  7092. fmt.Println(basNumber)
  7093. card_sn := bas[3]
  7094. card_no := bas[2]
  7095. cFYLJG001.MdtrtCertType = "03"
  7096. cFYLJG001.CardSn = card_sn
  7097. cFYLJG001.MdtrtCertNo = card_no
  7098. cFYLJG001.EcToken = ""
  7099. cFYLJG001.AuthNo = ""
  7100. } else if his.IdCardType == 2 {
  7101. cFYLJG001.MdtrtCertType = "02"
  7102. cFYLJG001.CardSn = ""
  7103. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7104. cFYLJG001.EcToken = ""
  7105. cFYLJG001.AuthNo = ""
  7106. } else if his.IdCardType == 4 {
  7107. cFYLJG001.MdtrtCertType = "01"
  7108. cFYLJG001.CardSn = ""
  7109. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7110. cFYLJG001.EcToken = psn.VerifyNumber
  7111. cFYLJG001.AuthNo = ""
  7112. }
  7113. cFYLJG001.BizTypeCode = "01"
  7114. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7115. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7116. cFYLJG001.RxTypeCode = "1"
  7117. tempTime := time.Unix(item.PreTime, 0)
  7118. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7119. cFYLJG001.PrscTime = timeFormatOne
  7120. var count float64
  7121. if item.Type == 1 {
  7122. for _, sumItem := range item.HisDoctorAdviceInfo {
  7123. count = count + sumItem.PrescribingNumber
  7124. }
  7125. }
  7126. cFYLJG001.RxDrugCnt = count
  7127. cFYLJG001.ValiDays = "5"
  7128. ts := time.Unix(item.PreTime, 0)
  7129. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7130. tempTime3 := time.Unix(record_time2, 0)
  7131. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7132. cFYLJG001.ValiEndTime = timeFormat3
  7133. cFYLJG001.RxCotnFlag = "0"
  7134. for _, subItem := range item.HisDoctorAdviceInfo {
  7135. var drug models.RxDrug
  7136. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7137. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7138. drug.RxItemTypeCode = "11"
  7139. drug.DrugDosform = "乳膏剂" //TODO
  7140. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7141. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7142. }
  7143. drug.MedcWayDscr = subItem.DeliveryWay
  7144. tempTime2 := time.Unix(subItem.StartTime, 0)
  7145. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7146. drug.MedcBegntime = timeFormatTwo
  7147. if subItem.Day > 0 {
  7148. ts := time.Unix(subItem.StartTime, 0)
  7149. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7150. tempTime4 := time.Unix(record_time, 0)
  7151. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7152. drug.MedcEndtime = timeFormat5
  7153. } else {
  7154. tempTime2 := time.Unix(subItem.StartTime, 0)
  7155. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7156. drug.MedcEndtime = timeFormatTwo
  7157. }
  7158. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7159. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7160. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7161. drug.DrugCnt = subItem.PrescribingNumber
  7162. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7163. drug.DrugGenname = subItem.AdviceName
  7164. drug.MedcWayCodg = subItem.DeliveryWay
  7165. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7166. drug.SinDoscnt = subItem.SingleDose
  7167. drug.SinDosunt = subItem.SingleDoseUnit
  7168. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7169. drug.UsedFrquName = subItem.ExecutionFrequency
  7170. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7171. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7172. drug.HospApprFlag = "1"
  7173. cFYLJG001.List = append(cFYLJG001.List, drug)
  7174. }
  7175. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7176. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7177. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7178. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7179. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7180. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7181. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7182. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7183. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7184. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7185. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7186. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7187. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7188. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7189. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7190. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7191. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7192. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7193. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7194. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7195. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7196. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7197. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7198. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7199. tempTime2 := time.Now().Unix()
  7200. tempTime6 := time.Unix(tempTime2, 0)
  7201. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7202. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7203. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7204. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7205. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7206. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7207. //memo := make(map[string]interface{})
  7208. //inputData := make(map[string]interface{}, 0)
  7209. //type MyData struct {
  7210. // Insutype string `json:"insutype"`
  7211. //}
  7212. //
  7213. // data := MyData{
  7214. // Insutype: his.Insutype,
  7215. //}
  7216. //
  7217. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7218. var config []*models.HisXtDiagnoseConfig
  7219. for _, item := range diagnosis_ids {
  7220. id, _ := strconv.ParseInt(item, 10, 64)
  7221. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7222. config = append(config, &diagnosisConfig)
  7223. }
  7224. for index, subitem := range config {
  7225. if index == 0 {
  7226. var dia models.DiseInfo
  7227. dia.DiagType = "1"
  7228. dia.MaindiagFlag = "1"
  7229. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7230. dia.DiagCode = subitem.CountryCode
  7231. dia.DiagName = subitem.ClassName
  7232. dia.DiagDept = "肾内科"
  7233. dia.DiagDrNo = doctor.DoctorNumber
  7234. dia.DiagDrName = doctor.UserName
  7235. tempTime3 := time.Unix(item.PreTime, 0)
  7236. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7237. dia.DiagTime = timeFormatTwo
  7238. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7239. } else {
  7240. var dia models.DiseInfo
  7241. dia.DiagType = "1"
  7242. dia.MaindiagFlag = "0"
  7243. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7244. dia.DiagCode = subitem.CountryCode
  7245. dia.DiagName = subitem.ClassName
  7246. dia.DiagDept = "肾内科"
  7247. dia.DiagDrNo = doctor.DoctorNumber
  7248. dia.DiagDrName = doctor.UserName
  7249. tempTime3 := time.Unix(item.PreTime, 0)
  7250. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7251. dia.DiagTime = timeFormatTwo
  7252. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7253. }
  7254. }
  7255. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7256. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7257. var res ResultCFYLJG001
  7258. var respJSON2 map[string]interface{}
  7259. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7262. return
  7263. }
  7264. userJSONBytes2, _ := json.Marshal(respJSON2)
  7265. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7266. utils.ErrorLog("解析失败:%v", err)
  7267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7268. return
  7269. }
  7270. if res.Infcode == -1 {
  7271. c.ServeSuccessJSON(map[string]interface{}{
  7272. "failed_code": -10,
  7273. "msg": res.ErrMsg,
  7274. })
  7275. return
  7276. } else {
  7277. var flow models.HisPrescriptionFlow
  7278. flow.Ctime = time.Now().Unix()
  7279. flow.SignDigest = ""
  7280. flow.RxTraceCode = res.Output.RxTraceCode
  7281. flow.HiRxno = res.Output.HiRxno
  7282. flow.MID = his.Number
  7283. flow.Status = 1
  7284. flow.DCode = doctor_info.DoctorNumber
  7285. flow.OriginalRxFile = ""
  7286. flow.OriginalValue = ""
  7287. flow.SignCertDn = ""
  7288. flow.UserOrgId = 10454
  7289. flow.SignCertSn = ""
  7290. flow.Mtime = time.Now().Unix()
  7291. service.Createflow(&flow)
  7292. c.ServeSuccessJSON(map[string]interface{}{
  7293. "msg": "上传成功",
  7294. })
  7295. }
  7296. }
  7297. }
  7298. func (c *HisApiController) GetCFYLJG002() {
  7299. admin_user_id, _ := c.GetInt64("admin_user_id")
  7300. his_patient_id, _ := c.GetInt64("his_patient_id")
  7301. record_time := c.GetString("record_time")
  7302. admin_user_id = 3626
  7303. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7304. //id, _ := c.GetInt64("id")
  7305. admin_user_id = 3626
  7306. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7307. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7308. flow, _ := service.Getflowtwo(his.Number)
  7309. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7310. //record_time := c.GetString("record_time")
  7311. patient_id, _ := c.GetInt64("patient_id")
  7312. //patient_id = 23834
  7313. //record_time = "2023-09-18"
  7314. timeLayout := "2006-01-02"
  7315. loc, _ := time.LoadLocation("Local")
  7316. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7317. if err != nil {
  7318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7319. return
  7320. }
  7321. recordDateTime := theTime.Unix()
  7322. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7323. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7324. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7325. dept, _ := service.GetDepartMentDetail(info.Departments)
  7326. inputData := make(map[string]interface{})
  7327. inputData["rxTraceCode"] = flow.RxTraceCode
  7328. inputData["hiRxno"] = flow.HiRxno
  7329. inputData["mdtrtId"] = flow.MID
  7330. inputData["patnName"] = his.PsnName
  7331. inputData["psnCertType"] = his.PsnCertType
  7332. inputData["certno"] = his.Certno
  7333. inputData["fixmedinsName"] = miConfig.OrgName
  7334. inputData["fixmedinsCode"] = miConfig.Code
  7335. inputData["drCode"] = doctor_info.DoctorNumber
  7336. inputData["prscDrName"] = doctor_info.UserName
  7337. inputData["pharDeptName"] = dept.Name
  7338. inputData["pharDeptCode"] = dept.Number
  7339. inputData["pharProfttlCodg"] = dept.Name
  7340. inputData["pharProfttlName"] = ""
  7341. inputData["pharCode"] = "HY440309002107"
  7342. inputData["pharCertType"] = "01"
  7343. inputData["pharCertno"] = "430482199408260023"
  7344. inputData["pharName"] = "彭斯遥"
  7345. inputData["pharPracCertNo"] = ""
  7346. tempTime2 := time.Unix(info.Ctime, 0)
  7347. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7348. inputData["pharChkTime"] = timeFormatTwo
  7349. bytesData, _ := json.Marshal(inputData)
  7350. fmt.Println(string(bytesData))
  7351. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7352. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7353. if err != nil {
  7354. fmt.Println("Error reading PDF file:", err)
  7355. return
  7356. }
  7357. // 将 PDF 文件内容进行 Base64 编码
  7358. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7359. fmt.Println(err)
  7360. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7361. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7362. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7363. var res2 Result002
  7364. var respJSON2 map[string]interface{}
  7365. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7368. return
  7369. }
  7370. userJSONBytes2, _ := json.Marshal(respJSON2)
  7371. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7372. utils.ErrorLog("解析失败:%v", err)
  7373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7374. return
  7375. }
  7376. if res2.Infcode == 0 {
  7377. flow.Ctime = time.Now().Unix()
  7378. flow.SignDigest = res2.Output.SignDigest
  7379. flow.RxFile = res2.Output.RxFile
  7380. flow.MID = his.Number
  7381. flow.Status = 1
  7382. flow.DCode = doctor_info.DoctorNumber
  7383. flow.OriginalRxFile = rx_encoded
  7384. flow.OriginalValue = encoded
  7385. flow.SignCertDn = res2.Output.SignCertDn
  7386. flow.SignCertSn = res2.Output.SignCertSn
  7387. flow.Mtime = time.Now().Unix()
  7388. service.Saveflow(flow)
  7389. c.ServeSuccessJSON(map[string]interface{}{
  7390. "msg": "预签名成功",
  7391. })
  7392. } else {
  7393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7394. return
  7395. }
  7396. }
  7397. func (c *HisApiController) GetCFYLJG003() {
  7398. admin_user_id, _ := c.GetInt64("admin_user_id")
  7399. his_patient_id, _ := c.GetInt64("his_patient_id")
  7400. record_time := c.GetString("record_time")
  7401. admin_user_id = 3626
  7402. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7403. //id, _ := c.GetInt64("id")
  7404. admin_user_id = 3626
  7405. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7406. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7407. flow, _ := service.Getflowtwo(his.Number)
  7408. //id = 3
  7409. patient_id, _ := c.GetInt64("patient_id")
  7410. //patient_id = 23834
  7411. //record_time = "2023-09-18"
  7412. timeLayout := "2006-01-02"
  7413. loc, _ := time.LoadLocation("Local")
  7414. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7415. if err != nil {
  7416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7417. return
  7418. }
  7419. recordDateTime := theTime.Unix()
  7420. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7421. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7422. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7423. dept, _ := service.GetDepartMentDetail(info.Departments)
  7424. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7425. var cFYLJG003 models.CFYLJG003
  7426. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7427. cFYLJG003.HiRxno = flow.HiRxno
  7428. cFYLJG003.MdtrtID = flow.MID
  7429. cFYLJG003.PatnName = his.Name
  7430. cFYLJG003.Certno = his.Certno
  7431. cFYLJG003.FixmedinsName = miConfig.OrgName
  7432. cFYLJG003.FixmedinsCode = miConfig.Code
  7433. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7434. cFYLJG003.PrscDrName = doctor_info.UserName
  7435. cFYLJG003.PharDeptName = dept.Name
  7436. cFYLJG003.PharDeptCode = dept.Number
  7437. cFYLJG003.PharCode = "HY440309002107"
  7438. cFYLJG003.PharCertType = "01"
  7439. cFYLJG003.PharCertno = "430482199408260023"
  7440. cFYLJG003.PharName = "彭斯遥"
  7441. cFYLJG003.PsnCertType = "01"
  7442. cFYLJG003.RxFile = flow.RxFile
  7443. cFYLJG003.SignDigest = flow.SignDigest
  7444. cFYLJG003.FixmedinsCode = miConfig.Code
  7445. cFYLJG003.PsnCertType = "01"
  7446. cFYLJG003.PharProfttlCodg = dept.Name
  7447. //inputData["pharProfttlCodg"] =dept.Name
  7448. tempTime2 := time.Unix(info.Ctime, 0)
  7449. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7450. cFYLJG003.PharChkTime = timeFormatTwo
  7451. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7452. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7453. var res ResultCFYLJG003
  7454. var respJSON2 map[string]interface{}
  7455. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7458. return
  7459. }
  7460. userJSONBytes2, _ := json.Marshal(respJSON2)
  7461. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7462. utils.ErrorLog("解析失败:%v", err)
  7463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7464. return
  7465. }
  7466. if res.Infcode == -1 {
  7467. c.ServeSuccessJSON(map[string]interface{}{
  7468. "failed_code": -10,
  7469. "msg": res.ErrMsg,
  7470. })
  7471. return
  7472. } else {
  7473. c.ServeSuccessJSON(map[string]interface{}{
  7474. "info": res.Output,
  7475. })
  7476. }
  7477. }
  7478. func (c *HisApiController) GetCFYLJG004() {
  7479. admin_user_id, _ := c.GetInt64("admin_user_id")
  7480. his_patient_id, _ := c.GetInt64("his_patient_id")
  7481. record_time := c.GetString("record_time")
  7482. admin_user_id = 3626
  7483. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7484. //id, _ := c.GetInt64("id")
  7485. admin_user_id = 3626
  7486. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7487. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7488. flow, _ := service.Getflowtwo(his.Number)
  7489. //id = 3
  7490. patient_id, _ := c.GetInt64("patient_id")
  7491. //patient_id = 23834
  7492. //record_time = "2023-09-18"
  7493. timeLayout := "2006-01-02"
  7494. loc, _ := time.LoadLocation("Local")
  7495. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7496. if err != nil {
  7497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7498. return
  7499. }
  7500. recordDateTime := theTime.Unix()
  7501. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7502. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7503. var cFYLJG004 models.CFYLJG004
  7504. cFYLJG004.HiRxno = flow.HiRxno
  7505. cFYLJG004.FixmedinsCode = miConfig.Code
  7506. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7507. cFYLJG004.UndoDrCertType = "01"
  7508. cFYLJG004.UndoRea = "撤销处方"
  7509. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7510. cFYLJG004.UndoDrName = doctor_info.UserName
  7511. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7512. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7513. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7514. var res ResultCFYLJG004
  7515. var respJSON2 map[string]interface{}
  7516. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7519. return
  7520. }
  7521. userJSONBytes2, _ := json.Marshal(respJSON2)
  7522. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7523. utils.ErrorLog("解析失败:%v", err)
  7524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7525. return
  7526. }
  7527. if res.Infcode == -1 {
  7528. c.ServeSuccessJSON(map[string]interface{}{
  7529. "failed_code": -10,
  7530. "msg": res.ErrMsg,
  7531. })
  7532. return
  7533. } else {
  7534. flow.Status = 0
  7535. service.Saveflow(flow)
  7536. c.ServeSuccessJSON(map[string]interface{}{
  7537. "msg": "撤销成功",
  7538. })
  7539. return
  7540. }
  7541. }
  7542. func (c *HisApiController) GetCFYLJG005() {
  7543. admin_user_id, _ := c.GetInt64("admin_user_id")
  7544. his_patient_id, _ := c.GetInt64("his_patient_id")
  7545. //record_time := c.GetString("record_time")
  7546. admin_user_id = 3626
  7547. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7548. //id, _ := c.GetInt64("id")
  7549. admin_user_id = 3626
  7550. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7551. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7552. flow, _ := service.Getflowtwo(his.Number)
  7553. //id = 3
  7554. var cFYLJG005 models.CFYLJG005
  7555. //patient_id, _ := c.GetInt64("patient_id")
  7556. cFYLJG005.HiRxno = flow.HiRxno
  7557. cFYLJG005.MdtrtID = flow.MID
  7558. cFYLJG005.EcToken = ""
  7559. cFYLJG005.PsnName = his.Name
  7560. cFYLJG005.PsnCertType = "01"
  7561. cFYLJG005.Certno = his.IdCardNo
  7562. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7563. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7564. var res ResultCFYLJG005
  7565. var respJSON2 map[string]interface{}
  7566. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7569. return
  7570. }
  7571. userJSONBytes2, _ := json.Marshal(respJSON2)
  7572. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7573. utils.ErrorLog("解析失败:%v", err)
  7574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7575. return
  7576. }
  7577. if res.Infcode == -1 {
  7578. c.ServeSuccessJSON(map[string]interface{}{
  7579. "failed_code": -10,
  7580. "msg": res.ErrMsg,
  7581. })
  7582. return
  7583. } else {
  7584. c.ServeSuccessJSON(map[string]interface{}{
  7585. "info": res.Output,
  7586. })
  7587. return
  7588. }
  7589. }
  7590. func (c *HisApiController) GetCFYLJG006() {
  7591. admin_user_id, _ := c.GetInt64("admin_user_id")
  7592. his_patient_id, _ := c.GetInt64("his_patient_id")
  7593. admin_user_id = 3626
  7594. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7595. //id, _ := c.GetInt64("id")
  7596. admin_user_id = 3626
  7597. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7598. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7599. flow, _ := service.Getflowtwo(his.Number)
  7600. //id = 3
  7601. patient_id, _ := c.GetInt64("patient_id")
  7602. var cFYLJG006 models.CFYLJG006
  7603. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7604. cFYLJG006.HiRxno = flow.HiRxno
  7605. cFYLJG006.MdtrtID = flow.MID
  7606. cFYLJG006.PsnName = patient.Name
  7607. cFYLJG006.PsnCertType = "01"
  7608. cFYLJG006.Certno = patient.IdCardNo
  7609. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7610. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7611. var res ResultCFYLJG006
  7612. var respJSON2 map[string]interface{}
  7613. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7616. return
  7617. }
  7618. userJSONBytes2, _ := json.Marshal(respJSON2)
  7619. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7620. utils.ErrorLog("解析失败:%v", err)
  7621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7622. return
  7623. }
  7624. if res.Infcode == -1 {
  7625. c.ServeSuccessJSON(map[string]interface{}{
  7626. "failed_code": -10,
  7627. "msg": res.ErrMsg,
  7628. })
  7629. return
  7630. } else {
  7631. c.ServeSuccessJSON(map[string]interface{}{
  7632. "info": res.Output,
  7633. })
  7634. return
  7635. }
  7636. }
  7637. func (c *HisApiController) GetCFYLJG007() {
  7638. admin_user_id, _ := c.GetInt64("admin_user_id")
  7639. his_patient_id, _ := c.GetInt64("his_patient_id")
  7640. admin_user_id = 3626
  7641. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7642. //id, _ := c.GetInt64("id")
  7643. admin_user_id = 3626
  7644. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7645. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7646. flow, _ := service.Getflowtwo(his.Number)
  7647. //id = 3
  7648. patient_id, _ := c.GetInt64("patient_id")
  7649. var cFYLJG007 models.CFYLJG007
  7650. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7651. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7652. cFYLJG007.HiRxno = flow.HiRxno
  7653. cFYLJG007.MdtrtID = flow.MID
  7654. cFYLJG007.PsnNo = his.PsnNo
  7655. cFYLJG007.PsnCertType = "01"
  7656. cFYLJG007.Certno = patient.IdCardNo
  7657. cFYLJG007.PsnName = patient.Name
  7658. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  7659. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  7660. var res ResultCFYLJG007
  7661. var respJSON2 map[string]interface{}
  7662. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7665. return
  7666. }
  7667. userJSONBytes2, _ := json.Marshal(respJSON2)
  7668. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7669. utils.ErrorLog("解析失败:%v", err)
  7670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7671. return
  7672. }
  7673. if res.Infcode == -1 {
  7674. c.ServeSuccessJSON(map[string]interface{}{
  7675. "failed_code": -10,
  7676. "msg": res.ErrMsg,
  7677. })
  7678. return
  7679. } else {
  7680. c.ServeSuccessJSON(map[string]interface{}{
  7681. "info": res,
  7682. })
  7683. return
  7684. }
  7685. }
  7686. func (c *HisApiController) GetCFYLJG008() {
  7687. admin_user_id, _ := c.GetInt64("admin_user_id")
  7688. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7689. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7690. var cFYLJG008 models.CFYLJG008
  7691. //id, _ := c.GetInt64("id")
  7692. patient_id, _ := c.GetInt64("patient_id")
  7693. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7694. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7695. //id = 3
  7696. //flow, _ := service.Getflow(id)
  7697. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7698. //
  7699. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7700. //patient_id, _ := c.GetInt64("patient_id")
  7701. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7702. record_time := c.GetString("record_time")
  7703. admin_user_id = 3626
  7704. patient_id = 19424
  7705. //his_patient_id = 263947
  7706. record_time = "2023-08-29"
  7707. timeLayout := "2006-01-02"
  7708. loc, _ := time.LoadLocation("Local")
  7709. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7710. if err != nil {
  7711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7712. return
  7713. }
  7714. recordDateTime := theTime.Unix()
  7715. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7716. cFYLJG008.FixmedinsName = ""
  7717. cFYLJG008.Lat = ""
  7718. cFYLJG008.Lng = ""
  7719. cFYLJG008.OrderType = "1"
  7720. cFYLJG008.PoolareaNo = ""
  7721. cFYLJG008.Lng = ""
  7722. cFYLJG008.PageNum = 1
  7723. cFYLJG008.PageSize = 10
  7724. var MPI models.MedinsProdInvChgDDTO
  7725. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  7726. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  7727. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  7728. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  7729. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  7730. var res ResultCFYLJG008
  7731. var respJSON2 map[string]interface{}
  7732. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7735. return
  7736. }
  7737. userJSONBytes2, _ := json.Marshal(respJSON2)
  7738. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7739. utils.ErrorLog("解析失败:%v", err)
  7740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7741. return
  7742. }
  7743. if res.Infcode == -1 {
  7744. c.ServeSuccessJSON(map[string]interface{}{
  7745. "failed_code": -10,
  7746. "msg": res.ErrMsg,
  7747. })
  7748. return
  7749. } else {
  7750. c.ServeSuccessJSON(map[string]interface{}{
  7751. "info": res.Output,
  7752. })
  7753. return
  7754. }
  7755. }
  7756. func (c *HisApiController) GetBL4201A() {
  7757. order_id, _ := c.GetInt64("order_id")
  7758. admin_user_id, _ := c.GetInt64("admin_user_id")
  7759. order, _ := service.GetHisOrderByIDTwo(order_id)
  7760. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7761. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7762. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7763. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7764. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7765. department, _ := service.GetDepartMentDetail(his.Departments)
  7766. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7767. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7768. if order.ID == 0 {
  7769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7770. return
  7771. }
  7772. var struct4201A models.Struct4201A
  7773. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7774. for _, items := range order_info {
  7775. memo := make(map[string]interface{})
  7776. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7777. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7778. fsiOPFLD.MedType = "14"
  7779. fsiOPFLD.BkkpSn = items.FeedetlSn
  7780. fsiOPFLD.FixmedinsCode = miConfig.Code
  7781. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7782. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7783. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7784. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7785. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7786. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7787. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7788. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7789. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7790. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7791. fsiOPFLD.BilgDeptName = department.Name
  7792. fsiOPFLD.BilgDeptCodg = department.Number
  7793. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7794. fsiOPFLD.BilgDrName = doctor.UserName
  7795. fsiOPFLD.MedChrgitmType = "09"
  7796. memo["hosp_appr_flag"] = "1"
  7797. memo["invoice_no"] = order.MdtrtId
  7798. memo["memo"] = "自费"
  7799. bytesData, _ := json.Marshal(memo)
  7800. fsiOPFLD.Memo = string(bytesData)
  7801. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7802. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7803. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7804. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7805. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7806. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7807. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7808. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7809. fsiOPFLD.BilgDeptName = department.Name
  7810. fsiOPFLD.BilgDeptCodg = department.Number
  7811. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7812. fsiOPFLD.BilgDrName = doctor.UserName
  7813. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7814. case 0:
  7815. break
  7816. case 1:
  7817. fsiOPFLD.MedChrgitmType = "14"
  7818. break
  7819. case 2:
  7820. fsiOPFLD.MedChrgitmType = "05"
  7821. break
  7822. case 3:
  7823. fsiOPFLD.MedChrgitmType = "03"
  7824. break
  7825. case 4:
  7826. fsiOPFLD.MedChrgitmType = "03"
  7827. break
  7828. case 5:
  7829. fsiOPFLD.MedChrgitmType = "08"
  7830. break
  7831. case 6:
  7832. fsiOPFLD.MedChrgitmType = "14"
  7833. break
  7834. case 7:
  7835. fsiOPFLD.MedChrgitmType = "14"
  7836. break
  7837. case 8:
  7838. fsiOPFLD.MedChrgitmType = "03"
  7839. break
  7840. case 9:
  7841. fsiOPFLD.MedChrgitmType = "14"
  7842. break
  7843. case 10:
  7844. fsiOPFLD.MedChrgitmType = "14"
  7845. break
  7846. case 11:
  7847. fsiOPFLD.MedChrgitmType = "06"
  7848. break
  7849. case 12:
  7850. fsiOPFLD.MedChrgitmType = "12"
  7851. break
  7852. case 13:
  7853. fsiOPFLD.MedChrgitmType = "01"
  7854. break
  7855. case 14:
  7856. fsiOPFLD.MedChrgitmType = "04"
  7857. break
  7858. case 15:
  7859. fsiOPFLD.MedChrgitmType = "14"
  7860. break
  7861. }
  7862. memo["hosp_appr_flag"] = "1"
  7863. memo["invoice_no"] = order.MdtrtId
  7864. memo["memo"] = "自费"
  7865. bytesData, _ := json.Marshal(memo)
  7866. fsiOPFLD.Memo = string(bytesData)
  7867. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7868. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  7869. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7870. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7871. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7872. fsiOPFLD.BilgDeptName = department.Name
  7873. fsiOPFLD.BilgDeptCodg = department.Number
  7874. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7875. fsiOPFLD.BilgDrName = doctor.UserName
  7876. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7877. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7878. fsiOPFLD.MedChrgitmType = "08"
  7879. memo["hosp_appr_flag"] = "1"
  7880. memo["invoice_no"] = order.MdtrtId
  7881. memo["memo"] = "自费"
  7882. bytesData, _ := json.Marshal(memo)
  7883. fsiOPFLD.Memo = string(bytesData)
  7884. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7885. }
  7886. }
  7887. }
  7888. for _, items := range order_info_two {
  7889. memo := make(map[string]interface{})
  7890. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7891. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7892. fsiOPFLD.MedType = "14"
  7893. fsiOPFLD.BkkpSn = items.FeedetlSn
  7894. fsiOPFLD.FixmedinsCode = miConfig.Code
  7895. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7896. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7897. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7898. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7899. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7900. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7901. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7902. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7903. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7904. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7905. fsiOPFLD.BilgDeptName = department.Name
  7906. fsiOPFLD.BilgDeptCodg = department.Number
  7907. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7908. fsiOPFLD.BilgDrName = doctor.UserName
  7909. fsiOPFLD.MedChrgitmType = "09"
  7910. memo["hosp_appr_flag"] = "1"
  7911. memo["invoice_no"] = order.MdtrtId
  7912. memo["memo"] = "自费"
  7913. bytesData, _ := json.Marshal(memo)
  7914. fsiOPFLD.Memo = string(bytesData)
  7915. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7916. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7917. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7918. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7919. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7920. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7921. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7922. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7923. fsiOPFLD.BilgDeptName = department.Name
  7924. fsiOPFLD.BilgDeptCodg = department.Number
  7925. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7926. fsiOPFLD.BilgDrName = doctor.UserName
  7927. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7928. case 0:
  7929. break
  7930. case 1:
  7931. fsiOPFLD.MedChrgitmType = "14"
  7932. break
  7933. case 2:
  7934. fsiOPFLD.MedChrgitmType = "05"
  7935. break
  7936. case 3:
  7937. fsiOPFLD.MedChrgitmType = "03"
  7938. break
  7939. case 4:
  7940. fsiOPFLD.MedChrgitmType = "03"
  7941. break
  7942. case 5:
  7943. fsiOPFLD.MedChrgitmType = "08"
  7944. break
  7945. case 6:
  7946. fsiOPFLD.MedChrgitmType = "14"
  7947. break
  7948. case 7:
  7949. fsiOPFLD.MedChrgitmType = "14"
  7950. break
  7951. case 8:
  7952. fsiOPFLD.MedChrgitmType = "03"
  7953. break
  7954. case 9:
  7955. fsiOPFLD.MedChrgitmType = "14"
  7956. break
  7957. case 10:
  7958. fsiOPFLD.MedChrgitmType = "14"
  7959. break
  7960. case 11:
  7961. fsiOPFLD.MedChrgitmType = "06"
  7962. break
  7963. case 12:
  7964. fsiOPFLD.MedChrgitmType = "12"
  7965. break
  7966. case 13:
  7967. fsiOPFLD.MedChrgitmType = "01"
  7968. break
  7969. case 14:
  7970. fsiOPFLD.MedChrgitmType = "04"
  7971. break
  7972. case 15:
  7973. fsiOPFLD.MedChrgitmType = "14"
  7974. break
  7975. }
  7976. memo["hosp_appr_flag"] = "1"
  7977. memo["invoice_no"] = order.MdtrtId
  7978. memo["memo"] = "自费"
  7979. bytesData, _ := json.Marshal(memo)
  7980. fsiOPFLD.Memo = string(bytesData)
  7981. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7982. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  7983. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7984. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7985. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7986. fsiOPFLD.BilgDeptName = department.Name
  7987. fsiOPFLD.BilgDeptCodg = department.Number
  7988. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7989. fsiOPFLD.BilgDrName = doctor.UserName
  7990. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7991. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7992. fsiOPFLD.MedChrgitmType = "08"
  7993. memo["hosp_appr_flag"] = "1"
  7994. memo["invoice_no"] = order.MdtrtId
  7995. memo["memo"] = "自费"
  7996. bytesData, _ := json.Marshal(memo)
  7997. fsiOPFLD.Memo = string(bytesData)
  7998. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7999. }
  8000. }
  8001. }
  8002. fmt.Println(fsiOPFLDs)
  8003. struct4201A.Fopfd = fsiOPFLDs
  8004. fmt.Println(struct4201A.Fopfd)
  8005. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8006. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8007. var res2 ResultSix
  8008. var respJSON2 map[string]interface{}
  8009. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8012. return
  8013. }
  8014. userJSONBytes2, _ := json.Marshal(respJSON2)
  8015. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8016. utils.ErrorLog("解析失败:%v", err)
  8017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8018. return
  8019. }
  8020. if res2.Infcode != 0 {
  8021. c.ServeSuccessJSON(map[string]interface{}{
  8022. "failed_code": -10,
  8023. "msg": res2.ErrMsg,
  8024. })
  8025. return
  8026. } else {
  8027. order.IsUploadOrderInfo = 1
  8028. service.UpdateOrder(order)
  8029. c.ServeSuccessJSON(map[string]interface{}{
  8030. "msg": "上传成功",
  8031. })
  8032. }
  8033. }
  8034. func (c *HisApiController) Get2505() {
  8035. admin_user_id, _ := c.GetInt64("admin_user_id")
  8036. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8037. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8038. 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)
  8039. }
  8040. func (c *HisApiController) Get4201A() {
  8041. order_id, _ := c.GetInt64("order_id")
  8042. admin_user_id, _ := c.GetInt64("admin_user_id")
  8043. order, _ := service.GetHisOrderByIDTwo(order_id)
  8044. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8045. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8046. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8047. //order_info = append(order_info, order_info_two...)
  8048. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8049. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8050. department, _ := service.GetDepartMentDetail(his.Departments)
  8051. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8052. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8053. if order.ID == 0 {
  8054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8055. return
  8056. }
  8057. var struct4201A models.Struct4201A
  8058. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8059. for _, items := range order_info {
  8060. memo := make(map[string]interface{})
  8061. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8062. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8063. fsiOPFLD.MedType = "14"
  8064. fsiOPFLD.BkkpSn = items.FeedetlSn
  8065. fsiOPFLD.FixmedinsCode = miConfig.Code
  8066. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8067. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8068. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8069. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8070. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8071. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8072. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8073. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8074. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8075. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8076. fsiOPFLD.BilgDeptName = department.Name
  8077. fsiOPFLD.BilgDeptCodg = department.Number
  8078. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8079. fsiOPFLD.BilgDrName = doctor.UserName
  8080. fsiOPFLD.MedChrgitmType = "09"
  8081. memo["hosp_appr_flag"] = "1"
  8082. memo["invoice_no"] = order.MdtrtId
  8083. memo["memo"] = "自费"
  8084. bytesData, _ := json.Marshal(memo)
  8085. fsiOPFLD.Memo = string(bytesData)
  8086. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8087. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8088. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8089. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8090. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8091. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8092. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8093. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8094. fsiOPFLD.BilgDeptName = department.Name
  8095. fsiOPFLD.BilgDeptCodg = department.Number
  8096. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8097. fsiOPFLD.BilgDrName = doctor.UserName
  8098. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8099. case 0:
  8100. break
  8101. case 1:
  8102. fsiOPFLD.MedChrgitmType = "14"
  8103. break
  8104. case 2:
  8105. fsiOPFLD.MedChrgitmType = "05"
  8106. break
  8107. case 3:
  8108. fsiOPFLD.MedChrgitmType = "03"
  8109. break
  8110. case 4:
  8111. fsiOPFLD.MedChrgitmType = "03"
  8112. break
  8113. case 5:
  8114. fsiOPFLD.MedChrgitmType = "08"
  8115. break
  8116. case 6:
  8117. fsiOPFLD.MedChrgitmType = "14"
  8118. break
  8119. case 7:
  8120. fsiOPFLD.MedChrgitmType = "14"
  8121. break
  8122. case 8:
  8123. fsiOPFLD.MedChrgitmType = "03"
  8124. break
  8125. case 9:
  8126. fsiOPFLD.MedChrgitmType = "14"
  8127. break
  8128. case 10:
  8129. fsiOPFLD.MedChrgitmType = "14"
  8130. break
  8131. case 11:
  8132. fsiOPFLD.MedChrgitmType = "06"
  8133. break
  8134. case 12:
  8135. fsiOPFLD.MedChrgitmType = "12"
  8136. break
  8137. case 13:
  8138. fsiOPFLD.MedChrgitmType = "01"
  8139. break
  8140. case 14:
  8141. fsiOPFLD.MedChrgitmType = "04"
  8142. break
  8143. case 15:
  8144. fsiOPFLD.MedChrgitmType = "14"
  8145. break
  8146. }
  8147. memo["hosp_appr_flag"] = "1"
  8148. memo["invoice_no"] = order.MdtrtId
  8149. memo["memo"] = "自费"
  8150. bytesData, _ := json.Marshal(memo)
  8151. fsiOPFLD.Memo = string(bytesData)
  8152. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8153. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8154. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8155. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8156. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8157. fsiOPFLD.BilgDeptName = department.Name
  8158. fsiOPFLD.BilgDeptCodg = department.Number
  8159. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8160. fsiOPFLD.BilgDrName = doctor.UserName
  8161. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8162. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8163. fsiOPFLD.MedChrgitmType = "08"
  8164. memo["hosp_appr_flag"] = "1"
  8165. memo["invoice_no"] = order.MdtrtId
  8166. memo["memo"] = "自费"
  8167. bytesData, _ := json.Marshal(memo)
  8168. fsiOPFLD.Memo = string(bytesData)
  8169. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8170. }
  8171. }
  8172. }
  8173. for _, items := range order_info_two {
  8174. memo := make(map[string]interface{})
  8175. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8176. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8177. fsiOPFLD.MedType = "14"
  8178. fsiOPFLD.BkkpSn = items.FeedetlSn
  8179. fsiOPFLD.FixmedinsCode = miConfig.Code
  8180. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8181. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8182. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8183. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8184. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8185. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8186. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8187. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8188. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8189. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8190. fsiOPFLD.BilgDeptName = department.Name
  8191. fsiOPFLD.BilgDeptCodg = department.Number
  8192. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8193. fsiOPFLD.BilgDrName = doctor.UserName
  8194. fsiOPFLD.MedChrgitmType = "09"
  8195. memo["hosp_appr_flag"] = "1"
  8196. memo["invoice_no"] = order.MdtrtId
  8197. memo["memo"] = "自费"
  8198. bytesData, _ := json.Marshal(memo)
  8199. fsiOPFLD.Memo = string(bytesData)
  8200. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8201. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8202. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8203. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8204. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8205. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8206. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8207. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8208. fsiOPFLD.BilgDeptName = department.Name
  8209. fsiOPFLD.BilgDeptCodg = department.Number
  8210. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8211. fsiOPFLD.BilgDrName = doctor.UserName
  8212. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8213. case 0:
  8214. break
  8215. case 1:
  8216. fsiOPFLD.MedChrgitmType = "14"
  8217. break
  8218. case 2:
  8219. fsiOPFLD.MedChrgitmType = "05"
  8220. break
  8221. case 3:
  8222. fsiOPFLD.MedChrgitmType = "03"
  8223. break
  8224. case 4:
  8225. fsiOPFLD.MedChrgitmType = "03"
  8226. break
  8227. case 5:
  8228. fsiOPFLD.MedChrgitmType = "08"
  8229. break
  8230. case 6:
  8231. fsiOPFLD.MedChrgitmType = "14"
  8232. break
  8233. case 7:
  8234. fsiOPFLD.MedChrgitmType = "14"
  8235. break
  8236. case 8:
  8237. fsiOPFLD.MedChrgitmType = "03"
  8238. break
  8239. case 9:
  8240. fsiOPFLD.MedChrgitmType = "14"
  8241. break
  8242. case 10:
  8243. fsiOPFLD.MedChrgitmType = "14"
  8244. break
  8245. case 11:
  8246. fsiOPFLD.MedChrgitmType = "06"
  8247. break
  8248. case 12:
  8249. fsiOPFLD.MedChrgitmType = "12"
  8250. break
  8251. case 13:
  8252. fsiOPFLD.MedChrgitmType = "01"
  8253. break
  8254. case 14:
  8255. fsiOPFLD.MedChrgitmType = "04"
  8256. break
  8257. case 15:
  8258. fsiOPFLD.MedChrgitmType = "14"
  8259. break
  8260. }
  8261. memo["hosp_appr_flag"] = "1"
  8262. memo["invoice_no"] = order.MdtrtId
  8263. memo["memo"] = "自费"
  8264. bytesData, _ := json.Marshal(memo)
  8265. fsiOPFLD.Memo = string(bytesData)
  8266. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8267. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8268. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8269. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8270. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8271. fsiOPFLD.BilgDeptName = department.Name
  8272. fsiOPFLD.BilgDeptCodg = department.Number
  8273. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8274. fsiOPFLD.BilgDrName = doctor.UserName
  8275. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8276. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8277. fsiOPFLD.MedChrgitmType = "08"
  8278. memo["hosp_appr_flag"] = "1"
  8279. memo["invoice_no"] = order.MdtrtId
  8280. memo["memo"] = "自费"
  8281. bytesData, _ := json.Marshal(memo)
  8282. fsiOPFLD.Memo = string(bytesData)
  8283. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8284. }
  8285. }
  8286. }
  8287. fmt.Println(fsiOPFLDs)
  8288. struct4201A.Fopfd = fsiOPFLDs
  8289. fmt.Println(struct4201A.Fopfd)
  8290. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8291. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8292. var res2 ResultSix
  8293. var respJSON2 map[string]interface{}
  8294. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8297. return
  8298. }
  8299. userJSONBytes2, _ := json.Marshal(respJSON2)
  8300. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8301. utils.ErrorLog("解析失败:%v", err)
  8302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8303. return
  8304. }
  8305. if res2.Infcode != 0 {
  8306. c.ServeSuccessJSON(map[string]interface{}{
  8307. "failed_code": -10,
  8308. "msg": res2.ErrMsg,
  8309. })
  8310. return
  8311. } else {
  8312. order.IsUploadOrderInfo = 1
  8313. service.UpdateOrder(order)
  8314. c.ServeSuccessJSON(map[string]interface{}{
  8315. "msg": "上传成功",
  8316. })
  8317. }
  8318. }
  8319. func (c *HisApiController) Get4202() {
  8320. order_id, _ := c.GetInt64("order_id")
  8321. admin_user_id, _ := c.GetInt64("admin_user_id")
  8322. order, _ := service.GetHisOrderByIDTwo(order_id)
  8323. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8324. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8325. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8326. if order.ID == 0 {
  8327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8328. return
  8329. }
  8330. var struct4202 models.Struct4202
  8331. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8332. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8333. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8334. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8335. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8336. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8337. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8338. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8339. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8340. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8341. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8342. var config []*models.HisXtDiagnoseConfig
  8343. for _, item := range diagnosis_ids {
  8344. id, _ := strconv.ParseInt(item, 10, 64)
  8345. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8346. config = append(config, &diagnosisConfig)
  8347. }
  8348. var tempDiaginfos []models.OwnPayPatnDiagListD
  8349. for index, item := range config {
  8350. if index == 0 {
  8351. var tempDiaginfo models.OwnPayPatnDiagListD
  8352. tempDiaginfo.InoutDiagType = "1"
  8353. tempDiaginfo.DiagCode = item.CountryCode
  8354. tempDiaginfo.DiagName = item.CountryContentName
  8355. tempDiaginfo.DiagType = "1"
  8356. tempDiaginfo.DiagSrtNo = "1"
  8357. tempDiaginfo.MaindiagFlag = "1"
  8358. tempDiaginfo.ValiFlag = "1"
  8359. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8360. } else {
  8361. var tempDiaginfo models.OwnPayPatnDiagListD
  8362. tempDiaginfo.DiagCode = item.CountryCode
  8363. tempDiaginfo.DiagName = item.CountryContentName
  8364. tempDiaginfo.DiagType = "2"
  8365. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8366. tempDiaginfo.MaindiagFlag = "0"
  8367. tempDiaginfo.ValiFlag = "1"
  8368. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8369. }
  8370. }
  8371. struct4202.ODiagListD = tempDiaginfos
  8372. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8373. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8374. var res2 ResultSix
  8375. var respJSON2 map[string]interface{}
  8376. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8379. return
  8380. }
  8381. userJSONBytes2, _ := json.Marshal(respJSON2)
  8382. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8383. utils.ErrorLog("解析失败:%v", err)
  8384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8385. return
  8386. }
  8387. if res2.Infcode != 0 {
  8388. c.ServeSuccessJSON(map[string]interface{}{
  8389. "failed_code": -10,
  8390. "msg": res2.ErrMsg,
  8391. })
  8392. return
  8393. } else {
  8394. order.IsUploadDiagnose = 1
  8395. service.UpdateOrder(order)
  8396. c.ServeSuccessJSON(map[string]interface{}{
  8397. "msg": "上传成功",
  8398. })
  8399. }
  8400. }
  8401. func (c *HisApiController) Get4203() {
  8402. admin_user_id, _ := c.GetInt64("admin_user_id")
  8403. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8404. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8405. order_id, _ := c.GetInt64("order_id")
  8406. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8407. number := ""
  8408. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8409. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8410. if his.ID == 0 {
  8411. number = hospital.Number
  8412. } else {
  8413. number = his.Number
  8414. }
  8415. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8416. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8417. var res2 ResultSix
  8418. var respJSON2 map[string]interface{}
  8419. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8422. return
  8423. }
  8424. userJSONBytes2, _ := json.Marshal(respJSON2)
  8425. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8426. utils.ErrorLog("解析失败:%v", err)
  8427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8428. return
  8429. }
  8430. if res2.Infcode != 0 {
  8431. c.ServeSuccessJSON(map[string]interface{}{
  8432. "failed_code": -10,
  8433. "msg": res2.ErrMsg,
  8434. })
  8435. return
  8436. } else {
  8437. order.IsUploadSuccess = 1
  8438. service.UpdateOrderTwo(order)
  8439. c.ServeSuccessJSON(map[string]interface{}{
  8440. "msg": "上传成功",
  8441. })
  8442. }
  8443. }
  8444. func (c *HisApiController) Get4205() {
  8445. order_id, _ := c.GetInt64("order_id")
  8446. admin_user_id, _ := c.GetInt64("admin_user_id")
  8447. fapiao_code := c.GetString("fapiao_code")
  8448. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8449. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8450. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8451. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8452. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8453. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8454. //order_info = append(order_info, order_info_two...)
  8455. department, _ := service.GetDepartMentDetail(his.Departments)
  8456. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8457. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8458. if order.ID == 0 {
  8459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8460. return
  8461. }
  8462. var struct4201A models.Struct4201A
  8463. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8464. for _, items := range order_info {
  8465. memo := make(map[string]interface{})
  8466. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8467. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8468. fsiOPFLD.MedType = pre.MedType
  8469. fsiOPFLD.FixmedinsCode = miConfig.Code
  8470. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8471. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8472. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8473. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8474. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8475. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8476. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8477. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8478. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8479. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8480. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8481. fsiOPFLD.BilgDeptName = department.Name
  8482. fsiOPFLD.BilgDeptCodg = department.Number
  8483. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8484. fsiOPFLD.BilgDrName = doctor.UserName
  8485. fsiOPFLD.MedChrgitmType = "09"
  8486. memo["hosp_appr_flag"] = "1"
  8487. memo["invoice_no"] = fapiao_code
  8488. memo["memo"] = "自费"
  8489. bytesData, _ := json.Marshal(memo)
  8490. fsiOPFLD.Memo = string(bytesData)
  8491. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8492. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8493. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8494. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8495. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8496. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8497. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8498. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8499. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8500. fsiOPFLD.BilgDeptName = department.Name
  8501. fsiOPFLD.BilgDeptCodg = department.Number
  8502. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8503. fsiOPFLD.BilgDrName = doctor.UserName
  8504. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8505. case 0:
  8506. break
  8507. case 1:
  8508. fsiOPFLD.MedChrgitmType = "14"
  8509. break
  8510. case 2:
  8511. fsiOPFLD.MedChrgitmType = "05"
  8512. break
  8513. case 3:
  8514. fsiOPFLD.MedChrgitmType = "03"
  8515. break
  8516. case 4:
  8517. fsiOPFLD.MedChrgitmType = "03"
  8518. break
  8519. case 5:
  8520. fsiOPFLD.MedChrgitmType = "08"
  8521. break
  8522. case 6:
  8523. fsiOPFLD.MedChrgitmType = "14"
  8524. break
  8525. case 7:
  8526. fsiOPFLD.MedChrgitmType = "14"
  8527. break
  8528. case 8:
  8529. fsiOPFLD.MedChrgitmType = "03"
  8530. break
  8531. case 9:
  8532. fsiOPFLD.MedChrgitmType = "14"
  8533. break
  8534. case 10:
  8535. fsiOPFLD.MedChrgitmType = "14"
  8536. break
  8537. case 11:
  8538. fsiOPFLD.MedChrgitmType = "06"
  8539. break
  8540. case 12:
  8541. fsiOPFLD.MedChrgitmType = "12"
  8542. break
  8543. case 13:
  8544. fsiOPFLD.MedChrgitmType = "01"
  8545. break
  8546. case 14:
  8547. fsiOPFLD.MedChrgitmType = "04"
  8548. break
  8549. case 15:
  8550. fsiOPFLD.MedChrgitmType = "14"
  8551. break
  8552. }
  8553. memo["hosp_appr_flag"] = "1"
  8554. memo["invoice_no"] = fapiao_code
  8555. memo["memo"] = "自费"
  8556. bytesData, _ := json.Marshal(memo)
  8557. fsiOPFLD.Memo = string(bytesData)
  8558. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8559. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8560. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8561. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8562. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8563. fsiOPFLD.BilgDeptName = department.Name
  8564. fsiOPFLD.BilgDeptCodg = department.Number
  8565. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8566. fsiOPFLD.BilgDrName = doctor.UserName
  8567. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8568. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8569. fsiOPFLD.MedChrgitmType = "08"
  8570. memo["hosp_appr_flag"] = "1"
  8571. memo["invoice_no"] = fapiao_code
  8572. memo["memo"] = "自费"
  8573. bytesData, _ := json.Marshal(memo)
  8574. fsiOPFLD.Memo = string(bytesData)
  8575. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8576. }
  8577. }
  8578. }
  8579. for _, items := range order_info_two {
  8580. memo := make(map[string]interface{})
  8581. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8582. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8583. fsiOPFLD.MedType = pre.MedType
  8584. fsiOPFLD.BkkpSn = items.FeedetlSn
  8585. fsiOPFLD.FixmedinsCode = miConfig.Code
  8586. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8587. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8588. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8589. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8590. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8591. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8592. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8593. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8594. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8595. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8596. fsiOPFLD.BilgDeptName = department.Name
  8597. fsiOPFLD.BilgDeptCodg = department.Number
  8598. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8599. fsiOPFLD.BilgDrName = doctor.UserName
  8600. fsiOPFLD.MedChrgitmType = "09"
  8601. memo["hosp_appr_flag"] = "1"
  8602. memo["invoice_no"] = fapiao_code
  8603. memo["memo"] = "自费"
  8604. bytesData, _ := json.Marshal(memo)
  8605. fsiOPFLD.Memo = string(bytesData)
  8606. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8607. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8608. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8609. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8610. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8611. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8612. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8613. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8614. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8615. fsiOPFLD.BilgDeptName = department.Name
  8616. fsiOPFLD.BilgDeptCodg = department.Number
  8617. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8618. fsiOPFLD.BilgDrName = doctor.UserName
  8619. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8620. case 0:
  8621. break
  8622. case 1:
  8623. fsiOPFLD.MedChrgitmType = "14"
  8624. break
  8625. case 2:
  8626. fsiOPFLD.MedChrgitmType = "05"
  8627. break
  8628. case 3:
  8629. fsiOPFLD.MedChrgitmType = "03"
  8630. break
  8631. case 4:
  8632. fsiOPFLD.MedChrgitmType = "03"
  8633. break
  8634. case 5:
  8635. fsiOPFLD.MedChrgitmType = "08"
  8636. break
  8637. case 6:
  8638. fsiOPFLD.MedChrgitmType = "14"
  8639. break
  8640. case 7:
  8641. fsiOPFLD.MedChrgitmType = "14"
  8642. break
  8643. case 8:
  8644. fsiOPFLD.MedChrgitmType = "03"
  8645. break
  8646. case 9:
  8647. fsiOPFLD.MedChrgitmType = "14"
  8648. break
  8649. case 10:
  8650. fsiOPFLD.MedChrgitmType = "14"
  8651. break
  8652. case 11:
  8653. fsiOPFLD.MedChrgitmType = "06"
  8654. break
  8655. case 12:
  8656. fsiOPFLD.MedChrgitmType = "12"
  8657. break
  8658. case 13:
  8659. fsiOPFLD.MedChrgitmType = "01"
  8660. break
  8661. case 14:
  8662. fsiOPFLD.MedChrgitmType = "04"
  8663. break
  8664. case 15:
  8665. fsiOPFLD.MedChrgitmType = "14"
  8666. break
  8667. }
  8668. memo["hosp_appr_flag"] = "1"
  8669. memo["invoice_no"] = fapiao_code
  8670. memo["memo"] = "自费"
  8671. bytesData, _ := json.Marshal(memo)
  8672. fsiOPFLD.Memo = string(bytesData)
  8673. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8674. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8675. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8676. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8677. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8678. fsiOPFLD.BilgDeptName = department.Name
  8679. fsiOPFLD.BilgDeptCodg = department.Number
  8680. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8681. fsiOPFLD.BilgDrName = doctor.UserName
  8682. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8683. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8684. fsiOPFLD.MedChrgitmType = "08"
  8685. memo["hosp_appr_flag"] = "1"
  8686. memo["invoice_no"] = fapiao_code
  8687. memo["memo"] = "自费"
  8688. bytesData, _ := json.Marshal(memo)
  8689. fsiOPFLD.Memo = string(bytesData)
  8690. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8691. }
  8692. }
  8693. }
  8694. fmt.Println(fsiOPFLDs)
  8695. struct4201A.Fopfd = fsiOPFLDs
  8696. fmt.Println(struct4201A.Fopfd)
  8697. var struct4202 models.Struct4202
  8698. timeLayout := "2006-01-02 15:04:05"
  8699. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  8700. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8701. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8702. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8703. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8704. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8705. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8706. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  8707. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  8708. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8709. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8710. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8711. var config []*models.HisXtDiagnoseConfig
  8712. for _, item := range diagnosis_ids {
  8713. id, _ := strconv.ParseInt(item, 10, 64)
  8714. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8715. config = append(config, &diagnosisConfig)
  8716. }
  8717. var tempDiaginfos []models.OwnPayPatnDiagListD
  8718. for index, item := range config {
  8719. if index == 0 {
  8720. var tempDiaginfo models.OwnPayPatnDiagListD
  8721. tempDiaginfo.InoutDiagType = "1"
  8722. tempDiaginfo.DiagCode = item.CountryCode
  8723. tempDiaginfo.DiagName = item.CountryContentName
  8724. tempDiaginfo.DiagType = "1"
  8725. tempDiaginfo.DiagSrtNo = "1"
  8726. tempDiaginfo.MaindiagFlag = "1"
  8727. tempDiaginfo.ValiFlag = "1"
  8728. tempDiaginfo.DiagDrName = doctor.UserName
  8729. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8730. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8731. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8732. } else {
  8733. var tempDiaginfo models.OwnPayPatnDiagListD
  8734. tempDiaginfo.DiagCode = item.CountryCode
  8735. tempDiaginfo.DiagName = item.CountryContentName
  8736. tempDiaginfo.DiagType = "2"
  8737. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8738. tempDiaginfo.MaindiagFlag = "0"
  8739. tempDiaginfo.ValiFlag = "1"
  8740. tempDiaginfo.DiagDrName = doctor.UserName
  8741. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8742. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8743. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8744. }
  8745. }
  8746. struct4202.ODiagListD = tempDiaginfos
  8747. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  8748. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  8749. var res2 ResultSix
  8750. var respJSON2 map[string]interface{}
  8751. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8754. return
  8755. }
  8756. userJSONBytes2, _ := json.Marshal(respJSON2)
  8757. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8758. utils.ErrorLog("解析失败:%v", err)
  8759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8760. return
  8761. }
  8762. if res2.Infcode != 0 {
  8763. c.ServeSuccessJSON(map[string]interface{}{
  8764. "failed_code": -10,
  8765. "msg": res2.ErrMsg,
  8766. })
  8767. return
  8768. } else {
  8769. order.IsUploadDiagnose = 1
  8770. order.IsUploadOrderInfo = 1
  8771. service.UpdateOrderTwo(order)
  8772. c.ServeSuccessJSON(map[string]interface{}{
  8773. "msg": "上传成功",
  8774. })
  8775. }
  8776. }
  8777. func (c *HisApiController) Get4207() {
  8778. admin_user_id, _ := c.GetInt64("admin_user_id")
  8779. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8780. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8781. order_id, _ := c.GetInt64("order_id")
  8782. order, _ := service.GetHisOrderByIDTwo(order_id)
  8783. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8784. var struct4207 models.Struct4207
  8785. struct4207.PageNum = "1"
  8786. struct4207.PageSize = "1000"
  8787. struct4207.FixmedinsCode = miConfig.Code
  8788. struct4207.FixmedinsMdtrtID = order.Number
  8789. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  8790. saveLog(result, requestLog, "4207", "查询")
  8791. var res2 ResultSix
  8792. var respJSON2 map[string]interface{}
  8793. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8796. return
  8797. }
  8798. userJSONBytes2, _ := json.Marshal(respJSON2)
  8799. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8800. utils.ErrorLog("解析失败:%v", err)
  8801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8802. return
  8803. }
  8804. if res2.Infcode != 0 {
  8805. c.ServeSuccessJSON(map[string]interface{}{
  8806. "failed_code": -10,
  8807. "msg": res2.ErrMsg,
  8808. })
  8809. return
  8810. } else {
  8811. c.ServeSuccessJSON(map[string]interface{}{
  8812. "msg": "查询成功",
  8813. })
  8814. }
  8815. }
  8816. func (c *HisApiController) Get4208() {
  8817. admin_user_id, _ := c.GetInt64("admin_user_id")
  8818. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8819. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8820. order_id, _ := c.GetInt64("order_id")
  8821. order, _ := service.GetHisOrderByIDTwo(order_id)
  8822. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8823. var struct4208 models.Struct4208
  8824. struct4208.PageNum = "1"
  8825. struct4208.PageSize = "1000"
  8826. struct4208.PsnCertType = "01"
  8827. struct4208.Certno = his.Certno
  8828. struct4208.MedType = order.MedType
  8829. struct4208.PsnName = his.Name
  8830. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  8831. saveLog(result, requestLog, "4208", "查询")
  8832. var res2 ResultSix
  8833. var respJSON2 map[string]interface{}
  8834. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8837. return
  8838. }
  8839. userJSONBytes2, _ := json.Marshal(respJSON2)
  8840. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8841. utils.ErrorLog("解析失败:%v", err)
  8842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8843. return
  8844. }
  8845. if res2.Infcode != 0 {
  8846. c.ServeSuccessJSON(map[string]interface{}{
  8847. "failed_code": -10,
  8848. "msg": res2.ErrMsg,
  8849. })
  8850. return
  8851. } else {
  8852. c.ServeSuccessJSON(map[string]interface{}{
  8853. "msg": "查询成功",
  8854. })
  8855. }
  8856. }
  8857. func (c *HisApiController) Get4209() {
  8858. admin_user_id, _ := c.GetInt64("admin_user_id")
  8859. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8860. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8861. order_id, _ := c.GetInt64("order_id")
  8862. order, _ := service.GetHisOrderByIDTwo(order_id)
  8863. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8864. var struct4209 models.Struct4209
  8865. struct4209.FixmedinsMdtrtID = order.Number
  8866. struct4209.FixmedinsCode = miConfig.Code
  8867. struct4209.PageSize = "1000"
  8868. struct4209.PageNum = "1"
  8869. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  8870. saveLog(result, requestLog, "4209", "查询")
  8871. var res2 ResultSix
  8872. var respJSON2 map[string]interface{}
  8873. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8876. return
  8877. }
  8878. userJSONBytes2, _ := json.Marshal(respJSON2)
  8879. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8880. utils.ErrorLog("解析失败:%v", err)
  8881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8882. return
  8883. }
  8884. if res2.Infcode != 0 {
  8885. c.ServeSuccessJSON(map[string]interface{}{
  8886. "failed_code": -10,
  8887. "msg": res2.ErrMsg,
  8888. })
  8889. return
  8890. } else {
  8891. c.ServeSuccessJSON(map[string]interface{}{
  8892. "msg": "查询成功",
  8893. })
  8894. }
  8895. }
  8896. type Result3101 struct {
  8897. Infcode string `json:"infcode"`
  8898. InfRefmsgid string `json:"inf_refmsgid"`
  8899. RefmsgTime string `json:"refmsg_time"`
  8900. RespondTime string `json:"respond_time"`
  8901. Enctype string `json:"enctype"`
  8902. Signtype string `json:"signtype"`
  8903. ErrMsg string `json:"err_msg"`
  8904. Output struct {
  8905. Result []struct {
  8906. JudgeResultDetailDtos []struct {
  8907. VolaItemType string `json:"vola_item_type"`
  8908. MdtrtID string `json:"mdtrt_id"`
  8909. JrdID string `json:"jrd_id"`
  8910. PatnID string `json:"patn_id"`
  8911. RxID string `json:"rx_id"`
  8912. VolaAmt interface{} `json:"vola_amt"`
  8913. } `json:"judge_result_detail_dtos"`
  8914. RuleID string `json:"rule_id"`
  8915. VolaEvid string `json:"vola_evid"`
  8916. MdtrtID string `json:"mdtrt_id"`
  8917. RuleName string `json:"rule_name"`
  8918. VolaAmtStas string `json:"vola_amt_stas"`
  8919. JrID string `json:"jr_id"`
  8920. PatnID string `json:"patn_id"`
  8921. SevDeg string `json:"sev_deg"`
  8922. VolaAmt float64 `json:"vola_amt"`
  8923. VolaBhvrType string `json:"vola_bhvr_type"`
  8924. VolaCont string `json:"vola_cont"`
  8925. } `json:"result"`
  8926. } `json:"output"`
  8927. }
  8928. type Resultgd3101 struct {
  8929. Infcode int64 `json:"infcode"`
  8930. InfRefmsgid string `json:"inf_refmsgid"`
  8931. RefmsgTime string `json:"refmsg_time"`
  8932. RespondTime string `json:"respond_time"`
  8933. Enctype string `json:"enctype"`
  8934. Signtype string `json:"signtype"`
  8935. ErrMsg string `json:"err_msg"`
  8936. Output struct {
  8937. Result []struct {
  8938. JudgeResultDetailDtos []struct {
  8939. VolaItemType string `json:"vola_item_type"`
  8940. MdtrtID string `json:"mdtrt_id"`
  8941. JrdID string `json:"jrd_id"`
  8942. PatnID string `json:"patn_id"`
  8943. RxID string `json:"rx_id"`
  8944. VolaAmt interface{} `json:"vola_amt"`
  8945. } `json:"judge_result_detail_dtos"`
  8946. RuleID string `json:"rule_id"`
  8947. VolaEvid string `json:"vola_evid"`
  8948. MdtrtID string `json:"mdtrt_id"`
  8949. RuleName string `json:"rule_name"`
  8950. VolaAmtStas string `json:"vola_amt_stas"`
  8951. JrID string `json:"jr_id"`
  8952. PatnID string `json:"patn_id"`
  8953. SevDeg string `json:"sev_deg"`
  8954. VolaAmt float64 `json:"vola_amt"`
  8955. VolaBhvrType string `json:"vola_bhvr_type"`
  8956. VolaCont string `json:"vola_cont"`
  8957. } `json:"result"`
  8958. } `json:"output"`
  8959. }
  8960. func (c *HisApiController) ReadEleToken() {
  8961. admin_user_id, _ := c.GetInt64("admin_user_id")
  8962. his_patient_id, _ := c.GetInt64("his_patient_id")
  8963. adminUser := c.GetAdminUserInfo()
  8964. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8965. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8966. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8967. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8968. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8969. if len(tokens) > 0 {
  8970. c.ServeSuccessJSON(map[string]interface{}{
  8971. "msg": "读取成功",
  8972. })
  8973. } else {
  8974. c.ServeSuccessJSON(map[string]interface{}{
  8975. "failed_code": -10,
  8976. "msg": "读取失败",
  8977. })
  8978. }
  8979. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8980. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8981. if len(tokens) > 0 {
  8982. c.ServeSuccessJSON(map[string]interface{}{
  8983. "msg": "读取成功",
  8984. })
  8985. } else {
  8986. c.ServeSuccessJSON(map[string]interface{}{
  8987. "failed_code": -10,
  8988. "msg": "读取失败",
  8989. })
  8990. }
  8991. } else if miConfig.MdtrtareaAdmvs == "340699" {
  8992. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8993. if len(tokens) > 0 {
  8994. c.ServeSuccessJSON(map[string]interface{}{
  8995. "msg": "读取成功",
  8996. })
  8997. } else {
  8998. c.ServeSuccessJSON(map[string]interface{}{
  8999. "failed_code": -10,
  9000. "msg": "读取失败",
  9001. })
  9002. }
  9003. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9004. var api string
  9005. 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 +
  9006. "&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"
  9007. resp, requestErr := http.Get(api)
  9008. if requestErr != nil {
  9009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9010. }
  9011. body, ioErr := ioutil.ReadAll(resp.Body)
  9012. if ioErr != nil {
  9013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9015. }
  9016. var respJSON map[string]interface{}
  9017. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9020. return
  9021. }
  9022. var status string
  9023. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9024. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9025. var token string
  9026. var res ResultTwo //1101结果
  9027. var res10265 ResultTwo10265 //1101结果
  9028. if status == "0" { //读卡成功
  9029. var card_info string //卡信息
  9030. var busi_card_info string
  9031. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9032. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9033. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9034. fmt.Println(card_info)
  9035. fmt.Println(busi_card_info)
  9036. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9037. result, _ := json.Marshal(respJSON)
  9038. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9039. utils.ErrorLog("解析失败:%v", err)
  9040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9041. return
  9042. }
  9043. res.ErrMsg = res10265.ErrMsg
  9044. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9045. res.Infcode = infocode
  9046. res.Output = res10265.Output
  9047. res.InfRefmsgid = res10265.InfRefmsgid
  9048. if res.Infcode == 0 {
  9049. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9050. if err == gorm.ErrRecordNotFound {
  9051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9052. return
  9053. } else if err != nil {
  9054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9055. return
  9056. } else {
  9057. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9058. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9059. infoStr := string(Iinfos)
  9060. idetinfoStr := string(Idetinfos)
  9061. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9062. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9063. psn := &models.HisPsn{
  9064. PsnNo: res.Output.Baseinfo.PsnNo,
  9065. PatientId: patient.ID,
  9066. Certno: res.Output.Baseinfo.Certno,
  9067. Gend: res.Output.Baseinfo.Gend,
  9068. Naty: res.Output.Baseinfo.Naty,
  9069. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9070. PsnName: res.Output.Baseinfo.PsnName,
  9071. Age: float64(age),
  9072. Brdy: b,
  9073. Idetinfo: idetinfoStr,
  9074. Insuinfo: infoStr,
  9075. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9076. CardInfo: card_info,
  9077. VerifyNumber: token,
  9078. IdCardType: 4,
  9079. }
  9080. var rf []*ResultFive
  9081. json.Unmarshal([]byte(infoStr), &rf)
  9082. var insutypes []*ResultFive
  9083. var insutype string
  9084. var is390 int = 0
  9085. var is310 int = 0
  9086. for _, item := range rf {
  9087. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9088. insutypes = append(insutypes, item)
  9089. }
  9090. }
  9091. if len(insutypes) == 1 {
  9092. insutype = insutypes[0].Insutype
  9093. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9094. } else {
  9095. for _, i := range insutypes {
  9096. if i.Insutype == "390" {
  9097. is390 = 1
  9098. }
  9099. if i.Insutype == "310" {
  9100. is310 = 1
  9101. }
  9102. }
  9103. }
  9104. if is390 == 1 {
  9105. insutype = "390"
  9106. }
  9107. if is310 == 1 {
  9108. insutype = "310"
  9109. }
  9110. if len(insutypes) == 0 {
  9111. insutype = "310"
  9112. }
  9113. service.CreateHisPsn(psn)
  9114. c.ServeSuccessJSON(map[string]interface{}{
  9115. "patient": patient,
  9116. "number": token,
  9117. "insutype": insutype,
  9118. })
  9119. }
  9120. } else {
  9121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9122. return
  9123. }
  9124. } else { //读卡失败
  9125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9126. return
  9127. }
  9128. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9129. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9130. if len(errMsg) == 0 {
  9131. type ELeData struct {
  9132. Data struct {
  9133. IdNo string `json:"idNo"`
  9134. IdType string `json:"idType"`
  9135. UserName string `json:"userName"`
  9136. EcToken string `json:"ecToken"`
  9137. InsuOrg string `json:"insuOrg"`
  9138. Gender string `json:"gender"`
  9139. Birthday string `json:"birthday"`
  9140. Nationality string `json:"nationality"`
  9141. Email string `json:"email"`
  9142. Extra string `json:"extra"`
  9143. } `json:"data"`
  9144. Code int `json:"code"`
  9145. Message string `json:"message"`
  9146. }
  9147. var ele ELeData
  9148. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9149. if err != nil {
  9150. utils.ErrorLog("解析失败:%v", err)
  9151. }
  9152. token := ele.Data.EcToken
  9153. if len(token) > 0 {
  9154. psn := &models.HisPsn{
  9155. PsnNo: his.PsnNo,
  9156. Age: 0,
  9157. PatientId: his.PatientId,
  9158. Certno: his.Certno,
  9159. Brdy: his.Brdy,
  9160. Gend: his.Gend,
  9161. Naty: his.Naty,
  9162. PsnCertType: his.PsnCertType,
  9163. PsnName: his.PsnName,
  9164. Idetinfo: his.Idetinfo,
  9165. Insuinfo: his.Iinfo,
  9166. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9167. CardInfo: outPutInfo,
  9168. VerifyNumber: token,
  9169. }
  9170. service.CreateHisPsn(psn)
  9171. }
  9172. if len(token) > 0 {
  9173. c.ServeSuccessJSON(map[string]interface{}{
  9174. "msg": "读取成功",
  9175. })
  9176. } else {
  9177. c.ServeSuccessJSON(map[string]interface{}{
  9178. "failed_code": -10,
  9179. "msg": "读取失败",
  9180. })
  9181. }
  9182. }
  9183. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9184. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9185. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9186. type ELeData struct {
  9187. Data struct {
  9188. IdNo string `json:"idNo"`
  9189. IdType string `json:"idType"`
  9190. UserName string `json:"userName"`
  9191. EcToken string `json:"ecToken"`
  9192. InsuOrg string `json:"insuOrg"`
  9193. Gender string `json:"gender"`
  9194. Birthday string `json:"birthday"`
  9195. Nationality string `json:"nationality"`
  9196. Email string `json:"email"`
  9197. Extra string `json:"extra"`
  9198. } `json:"data"`
  9199. Code int `json:"code"`
  9200. Message string `json:"message"`
  9201. }
  9202. var ele ELeData
  9203. err := json.Unmarshal([]byte(result), &ele)
  9204. if err != nil {
  9205. utils.ErrorLog("解析失败:%v", err)
  9206. }
  9207. token := ele.Data.EcToken
  9208. token = Remove0000(token)
  9209. fmt.Println(ele.Data.UserName)
  9210. 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)
  9211. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9212. var res ResultTwo
  9213. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9214. utils.ErrorLog("解析失败:%v", err)
  9215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9216. return
  9217. }
  9218. if res.Infcode == 0 {
  9219. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9220. if err == gorm.ErrRecordNotFound {
  9221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9222. return
  9223. } else if err != nil {
  9224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9225. return
  9226. } else {
  9227. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9228. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9229. infoStr := string(Iinfos)
  9230. idetinfoStr := string(Idetinfos)
  9231. psn := &models.HisPsn{
  9232. PsnNo: res.Output.Baseinfo.PsnNo,
  9233. PatientId: patient.ID,
  9234. Certno: res.Output.Baseinfo.Certno,
  9235. Gend: res.Output.Baseinfo.Gend,
  9236. Naty: res.Output.Baseinfo.Naty,
  9237. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9238. PsnName: res.Output.Baseinfo.PsnName,
  9239. Idetinfo: idetinfoStr,
  9240. Insuinfo: infoStr,
  9241. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9242. CardInfo: "",
  9243. VerifyNumber: token,
  9244. }
  9245. service.CreateHisPsn(psn)
  9246. c.ServeSuccessJSON(map[string]interface{}{
  9247. "patient": patient,
  9248. "number": token,
  9249. })
  9250. }
  9251. } else {
  9252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9253. return
  9254. }
  9255. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9256. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9257. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9258. type ELeData struct {
  9259. Data struct {
  9260. IdNo string `json:"idNo"`
  9261. IdType string `json:"idType"`
  9262. UserName string `json:"userName"`
  9263. EcToken string `json:"ecToken"`
  9264. InsuOrg string `json:"insuOrg"`
  9265. Gender string `json:"gender"`
  9266. Birthday string `json:"birthday"`
  9267. Nationality string `json:"nationality"`
  9268. Email string `json:"email"`
  9269. Extra string `json:"extra"`
  9270. } `json:"data"`
  9271. Code int `json:"code"`
  9272. Message string `json:"message"`
  9273. }
  9274. var ele ELeData
  9275. err := json.Unmarshal([]byte(result), &ele)
  9276. if err != nil {
  9277. utils.ErrorLog("解析失败:%v", err)
  9278. }
  9279. token := ele.Data.EcToken
  9280. token = Remove0000(token)
  9281. fmt.Println(ele.Data.UserName)
  9282. 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)
  9283. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9284. var res ResultTwo
  9285. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9286. utils.ErrorLog("解析失败:%v", err)
  9287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9288. return
  9289. }
  9290. if res.Infcode == 0 {
  9291. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9292. if err == gorm.ErrRecordNotFound {
  9293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9294. return
  9295. } else if err != nil {
  9296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9297. return
  9298. } else {
  9299. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9300. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9301. infoStr := string(Iinfos)
  9302. idetinfoStr := string(Idetinfos)
  9303. psn := &models.HisPsn{
  9304. PsnNo: res.Output.Baseinfo.PsnNo,
  9305. PatientId: patient.ID,
  9306. Certno: res.Output.Baseinfo.Certno,
  9307. Gend: res.Output.Baseinfo.Gend,
  9308. Naty: res.Output.Baseinfo.Naty,
  9309. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9310. PsnName: res.Output.Baseinfo.PsnName,
  9311. Idetinfo: idetinfoStr,
  9312. Insuinfo: infoStr,
  9313. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9314. CardInfo: "",
  9315. VerifyNumber: token,
  9316. }
  9317. service.CreateHisPsn(psn)
  9318. c.ServeSuccessJSON(map[string]interface{}{
  9319. "patient": patient,
  9320. "number": token,
  9321. })
  9322. }
  9323. } else {
  9324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9325. return
  9326. }
  9327. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9328. //if initFlag == 0 {
  9329. //c.TestGetJiangXiBasBaseInit()
  9330. //}
  9331. //if initEleFlag == 0 {
  9332. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9333. //}
  9334. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9335. utils.ErrorLog("解析失败:%v", json_result)
  9336. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9337. type ELeData struct {
  9338. Data struct {
  9339. IdNo string `json:"idNo"`
  9340. IdType string `json:"idType"`
  9341. UserName string `json:"userName"`
  9342. EcToken string `json:"ecToken"`
  9343. InsuOrg string `json:"insuOrg"`
  9344. Gender string `json:"gender"`
  9345. Birthday string `json:"birthday"`
  9346. Nationality string `json:"nationality"`
  9347. Email string `json:"email"`
  9348. Extra string `json:"extra"`
  9349. } `json:"data"`
  9350. Code int `json:"code"`
  9351. Message string `json:"message"`
  9352. }
  9353. var ele ELeData
  9354. err := json.Unmarshal([]byte(json_result), &ele)
  9355. if err != nil {
  9356. utils.ErrorLog("解析失败:%v", err)
  9357. }
  9358. token := ele.Data.EcToken
  9359. token = Remove0000(token)
  9360. //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)
  9361. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  9362. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9363. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9364. var res ResultTwo
  9365. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9366. utils.ErrorLog("解析失败:%v", err)
  9367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9368. return
  9369. }
  9370. if res.Infcode == 0 {
  9371. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9372. if err == gorm.ErrRecordNotFound {
  9373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9374. return
  9375. } else if err != nil {
  9376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9377. return
  9378. } else {
  9379. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9380. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9381. infoStr := string(Iinfos)
  9382. idetinfoStr := string(Idetinfos)
  9383. psn := &models.HisPsn{
  9384. PsnNo: res.Output.Baseinfo.PsnNo,
  9385. PatientId: patient.ID,
  9386. Certno: res.Output.Baseinfo.Certno,
  9387. Gend: res.Output.Baseinfo.Gend,
  9388. Naty: res.Output.Baseinfo.Naty,
  9389. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9390. PsnName: res.Output.Baseinfo.PsnName,
  9391. Idetinfo: idetinfoStr,
  9392. Insuinfo: infoStr,
  9393. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9394. CardInfo: "",
  9395. VerifyNumber: token,
  9396. InsuplcAdmdvs: ele.Data.InsuOrg,
  9397. }
  9398. service.CreateHisPsn(psn)
  9399. c.ServeSuccessJSON(map[string]interface{}{
  9400. "patient": patient,
  9401. "number": token,
  9402. })
  9403. }
  9404. } else {
  9405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9406. return
  9407. }
  9408. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9409. res := c.GetoleInfo()
  9410. if res.Infcode == 0 {
  9411. var result string
  9412. if res.Output.MdtrtCertType == "01" {
  9413. 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)
  9414. } else if res.Output.MdtrtCertType == "02" {
  9415. 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)
  9416. } else if res.Output.MdtrtCertType == "03" {
  9417. 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)
  9418. }
  9419. var dat map[string]interface{}
  9420. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9421. fmt.Println(dat)
  9422. } else {
  9423. fmt.Println(err)
  9424. }
  9425. userJSONBytes, _ := json.Marshal(dat)
  9426. var res2 ResultTwo
  9427. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9428. utils.ErrorLog("解析失败:%v", err)
  9429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9430. return
  9431. }
  9432. if res2.Infcode == 0 {
  9433. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9434. if err == gorm.ErrRecordNotFound {
  9435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9436. return
  9437. } else if err != nil {
  9438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9439. return
  9440. } else {
  9441. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9442. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9443. infoStr := string(Iinfos)
  9444. idetinfoStr := string(Idetinfos)
  9445. var rf []*ResultFive
  9446. json.Unmarshal([]byte(infoStr), &rf)
  9447. var insutypes []*ResultFive
  9448. var insutype string
  9449. var is390 int = 0
  9450. var is310 int = 0
  9451. //var insuplc_admdvs string
  9452. for _, item := range rf {
  9453. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9454. insutypes = append(insutypes, item)
  9455. }
  9456. }
  9457. if len(insutypes) == 1 {
  9458. insutype = insutypes[0].Insutype
  9459. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9460. } else {
  9461. for _, i := range insutypes {
  9462. if i.Insutype == "390" {
  9463. is390 = 1
  9464. }
  9465. if i.Insutype == "310" {
  9466. is310 = 1
  9467. }
  9468. }
  9469. }
  9470. if is390 == 1 {
  9471. insutype = "390"
  9472. }
  9473. if is310 == 1 {
  9474. insutype = "310"
  9475. }
  9476. if len(insutypes) == 0 {
  9477. insutype = "310"
  9478. }
  9479. psn := &models.HisPsn{
  9480. PsnNo: res2.Output.Baseinfo.PsnNo,
  9481. PatientId: patient.ID,
  9482. Certno: res2.Output.Baseinfo.Certno,
  9483. Gend: res2.Output.Baseinfo.Gend,
  9484. Naty: res2.Output.Baseinfo.Naty,
  9485. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9486. PsnName: res2.Output.Baseinfo.PsnName,
  9487. Idetinfo: idetinfoStr,
  9488. Insuinfo: infoStr,
  9489. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9490. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9491. VerifyNumber: res.Output.EcToken,
  9492. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9493. }
  9494. service.CreateHisPsn(psn)
  9495. c.ServeSuccessJSON(map[string]interface{}{
  9496. "patient": patient,
  9497. "number": res.Output.CardNo,
  9498. "insutype": insutype,
  9499. })
  9500. }
  9501. } else {
  9502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9503. return
  9504. }
  9505. } else {
  9506. c.ServeSuccessJSON(map[string]interface{}{
  9507. "failed_code": -10,
  9508. "msg": res.ErrMsg,
  9509. })
  9510. }
  9511. } else {
  9512. //if initFlag == 0 {
  9513. // c.TestGetBasBaseInit()
  9514. //}
  9515. //token := c.GetEleBaseInfo()
  9516. //token = Remove0000(token)
  9517. type ELeData struct {
  9518. Code string `json:"code"`
  9519. Data struct {
  9520. Aac002 string `json:"aac002"`
  9521. Aaz500 string `json:"aaz500"`
  9522. ActCardNo string `json:"actCardNo"`
  9523. Bab520 string `json:"bab520"`
  9524. Bkz543 string `json:"bkz543"`
  9525. BusinessType string `json:"businessType"`
  9526. CertfCodg string `json:"certfCodg"`
  9527. EcIndexNo string `json:"ecIndexNo"`
  9528. EcToken string `json:"ecToken"`
  9529. ID0000 string `json:"id0000"`
  9530. IDNo string `json:"idNo"`
  9531. IDType string `json:"idType"`
  9532. Idcode string `json:"idcode"`
  9533. IdentityToken string `json:"identity_token"`
  9534. InsuOrg string `json:"insuOrg"`
  9535. OfficeID string `json:"officeId"`
  9536. OfficeName string `json:"officeName"`
  9537. OperatorID string `json:"operatorId"`
  9538. OperatorName string `json:"operatorName"`
  9539. OrgID string `json:"orgId"`
  9540. UserName string `json:"userName"`
  9541. } `json:"data"`
  9542. Infno interface{} `json:"infno"`
  9543. Message string `json:"message"`
  9544. OrgID string `json:"orgId"`
  9545. TransType string `json:"transType"`
  9546. }
  9547. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9548. fmt.Println(result)
  9549. outPutInfo := Remove0000(result)
  9550. fmt.Println(outPutInfo)
  9551. var ele ELeData
  9552. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9553. if err != nil {
  9554. utils.ErrorLog("解析失败:%v", err)
  9555. }
  9556. token := ele.Data.EcToken
  9557. var result2 string
  9558. var requestLog2 string
  9559. if len(token) > 0 {
  9560. if strings.Contains(ele.Data.IDNo, "HKG") {
  9561. 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)
  9562. } else {
  9563. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9564. }
  9565. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9566. var res ResultTwo
  9567. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9568. utils.ErrorLog("解析失败:%v", err)
  9569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9570. return
  9571. }
  9572. if res.Infcode == 0 {
  9573. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9574. if err == gorm.ErrRecordNotFound {
  9575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9576. return
  9577. } else if err != nil {
  9578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9579. return
  9580. } else {
  9581. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9582. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9583. infoStr := string(Iinfos)
  9584. idetinfoStr := string(Idetinfos)
  9585. psn := &models.HisPsn{
  9586. PsnNo: res.Output.Baseinfo.PsnNo,
  9587. PatientId: patient.ID,
  9588. Certno: res.Output.Baseinfo.Certno,
  9589. Gend: res.Output.Baseinfo.Gend,
  9590. Naty: res.Output.Baseinfo.Naty,
  9591. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9592. PsnName: res.Output.Baseinfo.PsnName,
  9593. Idetinfo: idetinfoStr,
  9594. Insuinfo: infoStr,
  9595. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9596. CardInfo: "",
  9597. VerifyNumber: token,
  9598. }
  9599. service.CreateHisPsn(psn)
  9600. c.ServeSuccessJSON(map[string]interface{}{
  9601. "msg": "读取成功",
  9602. })
  9603. }
  9604. } else {
  9605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9606. return
  9607. }
  9608. } else {
  9609. c.ServeSuccessJSON(map[string]interface{}{
  9610. "failed_code": -10,
  9611. "msg": "读取失败",
  9612. })
  9613. }
  9614. }
  9615. }
  9616. func (c *HisApiController) ReadEleFace() {
  9617. admin_user_id, _ := c.GetInt64("admin_user_id")
  9618. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9619. adminUser := c.GetAdminUserInfo()
  9620. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9621. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9622. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9623. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9624. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9625. if len(tokens) > 0 {
  9626. c.ServeSuccessJSON(map[string]interface{}{
  9627. "msg": "读取成功",
  9628. })
  9629. } else {
  9630. c.ServeSuccessJSON(map[string]interface{}{
  9631. "failed_code": -10,
  9632. "msg": "读取失败",
  9633. })
  9634. }
  9635. }
  9636. }
  9637. func (c *HisApiController) Get9001() {
  9638. adminUser := c.GetAdminUserInfo()
  9639. admin_user_id, _ := c.GetInt64("admin_user_id")
  9640. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9641. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9642. if miConfig.MdtrtareaAdmvs == "350500" {
  9643. service.GetFjAuthorizationInfo(miConfig.Code)
  9644. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9645. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9646. var dat map[string]interface{}
  9647. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9648. fmt.Println(dat)
  9649. } else {
  9650. fmt.Println(err)
  9651. }
  9652. userJSONBytes, _ := json.Marshal(dat)
  9653. var res models.Result9001
  9654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9655. utils.ErrorLog("解析失败:%v", err)
  9656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9657. return
  9658. }
  9659. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9660. fmt.Println(miConfig.SecretKey)
  9661. var res models.Result9001Two
  9662. 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 +
  9663. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9664. resp, requestErr := http.Get(api)
  9665. if requestErr != nil {
  9666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9667. return
  9668. }
  9669. body, ioErr := ioutil.ReadAll(resp.Body)
  9670. if ioErr != nil {
  9671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9673. return
  9674. }
  9675. var respJSON map[string]interface{}
  9676. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9679. return
  9680. }
  9681. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9682. if status == "0" {
  9683. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9684. c.ServeSuccessJSON(map[string]interface{}{
  9685. "failed_code": -10,
  9686. "msg": err_msg,
  9687. })
  9688. return
  9689. }
  9690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9691. result, _ := json.Marshal(respJSON)
  9692. fmt.Println("log")
  9693. fmt.Println(string(result))
  9694. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9695. utils.ErrorLog("解析失败:%v", err)
  9696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9697. return
  9698. }
  9699. if res.Infcode == 0 {
  9700. sign := models.HisSignIn{
  9701. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9702. SignNo: res.Output.Signinoutb.SignNo,
  9703. SignTime: "",
  9704. Ctime: time.Now().Unix(),
  9705. Mtime: time.Now().Unix(),
  9706. Status: 1,
  9707. InputLog: "",
  9708. OutputLog: "",
  9709. FixmedinsCode: miConfig.Code,
  9710. }
  9711. err := service.CreateSignIn(&sign)
  9712. if err == nil {
  9713. c.ServeSuccessJSON(map[string]interface{}{
  9714. "msg": "签到成功",
  9715. })
  9716. }
  9717. } else {
  9718. c.ServeSuccessJSON(map[string]interface{}{
  9719. "failed_code": -10,
  9720. "msg": res.ErrMsg,
  9721. })
  9722. return
  9723. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9724. //return
  9725. }
  9726. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9727. fmt.Println(miConfig.SecretKey)
  9728. var res models.Result9001Two
  9729. 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 +
  9730. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9731. resp, requestErr := http.Get(api)
  9732. if requestErr != nil {
  9733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9734. return
  9735. }
  9736. body, ioErr := ioutil.ReadAll(resp.Body)
  9737. if ioErr != nil {
  9738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9740. return
  9741. }
  9742. var respJSON map[string]interface{}
  9743. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9746. return
  9747. }
  9748. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9749. if status == "0" {
  9750. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9751. c.ServeSuccessJSON(map[string]interface{}{
  9752. "failed_code": -10,
  9753. "msg": err_msg,
  9754. })
  9755. return
  9756. }
  9757. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9758. result, _ := json.Marshal(respJSON)
  9759. fmt.Println("log")
  9760. fmt.Println(string(result))
  9761. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9762. utils.ErrorLog("解析失败:%v", err)
  9763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9764. return
  9765. }
  9766. if res.Infcode == 0 {
  9767. sign := models.HisSignIn{
  9768. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9769. SignNo: res.Output.Signinoutb.SignNo,
  9770. SignTime: "",
  9771. Ctime: time.Now().Unix(),
  9772. Mtime: time.Now().Unix(),
  9773. Status: 1,
  9774. InputLog: "",
  9775. OutputLog: "",
  9776. FixmedinsCode: miConfig.Code,
  9777. }
  9778. err := service.CreateSignIn(&sign)
  9779. if err == nil {
  9780. c.ServeSuccessJSON(map[string]interface{}{
  9781. "msg": "签到成功",
  9782. })
  9783. }
  9784. } else {
  9785. c.ServeSuccessJSON(map[string]interface{}{
  9786. "failed_code": -10,
  9787. "msg": res.ErrMsg,
  9788. })
  9789. return
  9790. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9791. //return
  9792. }
  9793. } else {
  9794. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  9795. var dat map[string]interface{}
  9796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9797. fmt.Println(dat)
  9798. } else {
  9799. fmt.Println(err)
  9800. }
  9801. userJSONBytes, _ := json.Marshal(dat)
  9802. var res models.Result9001
  9803. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9804. utils.ErrorLog("解析失败:%v", err)
  9805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9806. return
  9807. }
  9808. if res.Infcode == 0 {
  9809. sign := models.HisSignIn{
  9810. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9811. SignNo: res.Output.Signinoutb.SignNo,
  9812. SignTime: res.Output.Signinoutb.SignTime,
  9813. Ctime: time.Now().Unix(),
  9814. Mtime: time.Now().Unix(),
  9815. Status: 1,
  9816. InputLog: "",
  9817. OutputLog: "",
  9818. FixmedinsCode: miConfig.Code,
  9819. }
  9820. err := service.CreateSignIn(&sign)
  9821. if err == nil {
  9822. c.ServeSuccessJSON(map[string]interface{}{
  9823. "msg": "签到成功",
  9824. })
  9825. }
  9826. }
  9827. }
  9828. }
  9829. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription, de models.XtHisDepartment) (res2 Result3101) {
  9830. var res Result3101
  9831. adminUser := c.GetAdminUserInfo()
  9832. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9833. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9834. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9835. //record_time := c.GetString("record_time")
  9836. //trig_scen := c.GetString("trig_scen")
  9837. timeLayout := "2006-01-02"
  9838. loc, _ := time.LoadLocation("Local")
  9839. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9840. if err != nil {
  9841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9842. return res
  9843. }
  9844. recordDateTime := theTime.Unix()
  9845. var patientPrescription models.HisPrescriptionInfo
  9846. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9847. //if patientPrescription.ID == 0 {
  9848. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9849. //}
  9850. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9851. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9852. //
  9853. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9854. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9855. var pp models.PublicParams
  9856. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9857. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9858. pp.FixmedinsName = miConfig.OrgName
  9859. pp.FixmedinsCode = miConfig.Code
  9860. pp.RequestUrl = miConfig.Url
  9861. pp.Cainfo = miConfig.Cainfo
  9862. pp.SecretKey = miConfig.SecretKey
  9863. pp.AccessKey = miConfig.AccessKey
  9864. pp.OpterName = roles.UserName
  9865. var config []*models.HisXtDiagnoseConfig
  9866. for _, item := range diagnosis_ids {
  9867. id, _ := strconv.ParseInt(item, 10, 64)
  9868. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9869. config = append(config, &diagnosisConfig)
  9870. }
  9871. var pd models.PatientDtos
  9872. pd.PatnID = his.PsnNo
  9873. pd.PatnName = his.Name
  9874. pd.Gend = his.Gend
  9875. pd.Brdy = his.Brdy
  9876. pd.Poolarea = miConfig.MdtrtareaAdmvs
  9877. pd.CurrMdtrtID = his.Number
  9878. var fed models.FsiEncounterDtos
  9879. fed.MdtrtID = his.Number
  9880. fed.MedinsID = miConfig.Code
  9881. fed.MedinsName = miConfig.OrgName
  9882. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9883. fed.MedMdtrtType = "1"
  9884. fed.MedinsType = "1"
  9885. fed.MedinsLv = "11"
  9886. tm := time.Unix(his.RecordDate, 0)
  9887. s_tm := tm.Format("2006-01-02 15:04:05")
  9888. fed.AdmDate = s_tm
  9889. fed.DscgDate = s_tm
  9890. fed.DscgMainDiseCodg = config[0].CountryCode
  9891. fed.DscgMainDiseName = config[0].CountryContentName
  9892. //诊断信息
  9893. var fdds []*models.FsiDiagnoseDtos
  9894. for index, item := range config {
  9895. if index == 0 {
  9896. var fdd models.FsiDiagnoseDtos
  9897. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9898. fdd.InoutDiseType = "1"
  9899. fdd.MaindiseFlag = "1"
  9900. fdd.DiseDate = s_tm
  9901. fdd.DiasSrtNo = "1"
  9902. fdd.DiseName = item.CountryContentName
  9903. fdd.DiseCodg = item.CountryCode
  9904. fdds = append(fdds, &fdd)
  9905. } else {
  9906. var fdd models.FsiDiagnoseDtos
  9907. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9908. fdd.InoutDiseType = "1"
  9909. fdd.MaindiseFlag = "1"
  9910. fdd.DiseDate = s_tm
  9911. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9912. fdd.DiseName = item.CountryContentName
  9913. fdd.DiseCodg = item.CountryCode
  9914. fdds = append(fdds, &fdd)
  9915. }
  9916. }
  9917. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9918. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  9919. fed.AdmDeptName = de.Name
  9920. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  9921. fed.DscgDeptName = de.Name
  9922. fed.MedMdtrtType = "1"
  9923. fed.MedType = "11"
  9924. //if his.Insutype == "390" {
  9925. // fed.MedType = "1402"
  9926. //} else {
  9927. // fed.MedType = "9933"
  9928. //}
  9929. var orders []*models.FsiOrderDtos
  9930. if trig_scen == "2" {
  9931. //处方医嘱信息
  9932. for _, item := range prescriptions {
  9933. for _, subItem := range item.HisDoctorAdviceInfo {
  9934. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9935. var order models.FsiOrderDtos
  9936. order.RxID = strconv.FormatInt(item.ID, 10)
  9937. order.Rxno = strconv.FormatInt(item.ID, 10)
  9938. order.LongDrordFlag = "0"
  9939. order.HilistType = "1"
  9940. order.ChrgType = "1"
  9941. order.DrordBhvr = "-"
  9942. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9943. order.HosplistName = subItem.BaseDrugLib.DrugName
  9944. order.HilistLv = "1"
  9945. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9946. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9947. order.HosplistName = subItem.BaseDrugLib.DrugName
  9948. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9949. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9950. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9951. order.OwnpayAmt = ""
  9952. order.SelfpayAmt = ""
  9953. order.Spec = ""
  9954. order.SpecUnt = ""
  9955. order.DrordBegnDate = s_tm
  9956. order.DrordStopDate = ""
  9957. order.DrordDrCodg = doctor_info.DoctorNumber
  9958. order.DrordDeptName = department.Name
  9959. order.DrordDeptCodg = department.Number
  9960. order.DrordDrName = doctor_info.UserName
  9961. order.DrordDrProfttl = "234"
  9962. order.CurrDrordFlag = "1"
  9963. orders = append(orders, &order)
  9964. }
  9965. }
  9966. for _, subItem := range item.HisPrescriptionProject {
  9967. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9968. var order models.FsiOrderDtos
  9969. order.RxID = strconv.FormatInt(item.ID, 10)
  9970. order.Rxno = strconv.FormatInt(item.ID, 10)
  9971. order.LongDrordFlag = "0"
  9972. order.HilistType = "1"
  9973. order.ChrgType = "1"
  9974. order.DrordBhvr = "-"
  9975. order.HilistCode = subItem.HisProject.MedicalCode
  9976. order.HosplistName = subItem.HisProject.ProjectName
  9977. order.HilistLv = "1"
  9978. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9979. order.HosplistCode = subItem.HisProject.MedicalCode
  9980. order.HosplistName = subItem.HisProject.ProjectName
  9981. order.Cnt = subItem.Count
  9982. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9983. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9984. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9985. order.OwnpayAmt = ""
  9986. order.SelfpayAmt = ""
  9987. order.Spec = ""
  9988. order.SpecUnt = ""
  9989. order.DrordBegnDate = s_tm
  9990. order.DrordStopDate = ""
  9991. order.DrordDrCodg = doctor_info.DoctorNumber
  9992. order.DrordDeptName = department.Name
  9993. order.DrordDeptCodg = department.Number
  9994. order.DrordDrName = doctor_info.UserName
  9995. order.DrordDrProfttl = "234"
  9996. order.CurrDrordFlag = "1"
  9997. orders = append(orders, &order)
  9998. }
  9999. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10000. var order models.FsiOrderDtos
  10001. order.RxID = strconv.FormatInt(item.ID, 10)
  10002. order.Rxno = strconv.FormatInt(item.ID, 10)
  10003. order.LongDrordFlag = "0"
  10004. order.HilistType = "1"
  10005. order.ChrgType = "1"
  10006. order.DrordBhvr = "-"
  10007. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10008. order.HosplistName = subItem.GoodInfo.GoodName
  10009. order.HilistLv = "1"
  10010. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10011. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10012. order.HosplistName = subItem.GoodInfo.GoodName
  10013. order.Cnt = subItem.Count
  10014. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10015. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10016. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10017. order.OwnpayAmt = ""
  10018. order.SelfpayAmt = ""
  10019. order.Spec = ""
  10020. order.SpecUnt = ""
  10021. order.DrordBegnDate = s_tm
  10022. order.DrordStopDate = ""
  10023. order.DrordDrCodg = doctor_info.DoctorNumber
  10024. order.DrordDeptName = department.Name
  10025. order.DrordDeptCodg = department.Number
  10026. order.DrordDrName = doctor_info.UserName
  10027. order.DrordDrProfttl = "234"
  10028. order.CurrDrordFlag = "1"
  10029. orders = append(orders, &order)
  10030. }
  10031. }
  10032. }
  10033. //处方医嘱信息
  10034. }
  10035. fed.MatnStas = "0"
  10036. fed.MedfeeSumamt = "0"
  10037. fed.OwnpayAmt = "0"
  10038. fed.SelfpayAmt = "0"
  10039. fed.AcctPayamt = "0"
  10040. fed.MaAmt = "0"
  10041. fed.HifpPayamt = "0"
  10042. fed.SetlTotlnum = "1"
  10043. fed.Insutype = his.Insutype
  10044. fed.ReimFlag = "0"
  10045. fed.OutSetlFlag = "0"
  10046. var fopd []*models.FsiOperationDtosData
  10047. data := make(map[string]interface{})
  10048. data["fed"] = fed
  10049. data["fdd"] = fdds
  10050. data["fod"] = orders
  10051. data["pd"] = pd
  10052. data["pp"] = pp
  10053. data["fopd"] = fopd
  10054. data["trig_scen"] = trig_scen
  10055. fmt.Println(data)
  10056. fmt.Println(fed)
  10057. fmt.Println(fdds)
  10058. fmt.Println(orders)
  10059. fmt.Println(pd)
  10060. fmt.Println(pp)
  10061. fmt.Println(fopd)
  10062. client := &http.Client{}
  10063. bytesData, _ := json.Marshal(data)
  10064. var req *http.Request
  10065. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10066. if miConfig.MdtrtareaAdmvs == "320921" {
  10067. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10068. } else {
  10069. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10070. }
  10071. resp, _ := client.Do(req)
  10072. defer resp.Body.Close()
  10073. body, ioErr := ioutil.ReadAll(resp.Body)
  10074. if ioErr != nil {
  10075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10077. return res
  10078. }
  10079. var respJSON map[string]interface{}
  10080. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10083. return res
  10084. }
  10085. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10086. fmt.Println(respJSON)
  10087. result, _ := json.Marshal(respJSON)
  10088. fmt.Println(result)
  10089. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10090. utils.ErrorLog("解析失败:%v", err)
  10091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10092. return res
  10093. }
  10094. return res
  10095. } else {
  10096. //if miConfig.MdtrtareaAdmvs == "441202" {
  10097. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10098. saveLog(output, input, "3101", "事前")
  10099. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10100. utils.ErrorLog("解析失败:%v", err)
  10101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10102. return
  10103. }
  10104. return res
  10105. //}
  10106. }
  10107. }
  10108. 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) {
  10109. adminUser := c.GetAdminUserInfo()
  10110. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10111. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10112. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10113. //record_time := c.GetString("record_time")
  10114. //trig_scen := c.GetString("trig_scen")
  10115. timeLayout := "2006-01-02"
  10116. loc, _ := time.LoadLocation("Local")
  10117. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10118. if err != nil {
  10119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10120. return res
  10121. }
  10122. recordDateTime := theTime.Unix()
  10123. var patientPrescription models.HisPrescriptionInfo
  10124. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10125. if patientPrescription.ID == 0 {
  10126. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10127. }
  10128. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10129. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10130. //
  10131. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10132. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10133. var pp models.PublicParams
  10134. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10135. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10136. pp.FixmedinsName = miConfig.OrgName
  10137. pp.FixmedinsCode = miConfig.Code
  10138. pp.RequestUrl = miConfig.Url
  10139. pp.Cainfo = miConfig.Cainfo
  10140. pp.SecretKey = miConfig.SecretKey
  10141. pp.AccessKey = miConfig.AccessKey
  10142. pp.OpterName = roles.UserName
  10143. var config []*models.HisXtDiagnoseConfig
  10144. for _, item := range diagnosis_ids {
  10145. id, _ := strconv.ParseInt(item, 10, 64)
  10146. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10147. config = append(config, &diagnosisConfig)
  10148. }
  10149. var pd models.PatientDtos
  10150. pd.PatnID = his.PsnNo
  10151. pd.PatnName = his.Name
  10152. pd.Gend = his.Gend
  10153. pd.Brdy = his.Brdy
  10154. pd.Poolarea = his.InsuplcAdmdvs
  10155. pd.CurrMdtrtID = his.Number
  10156. var fed models.FsiEncounterDtos
  10157. fed.MdtrtID = his.Number
  10158. fed.MedinsID = miConfig.Code
  10159. fed.MedinsName = miConfig.OrgName
  10160. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10161. fed.MedMdtrtType = "1"
  10162. fed.MedinsType = "1"
  10163. fed.MedinsLv = "11"
  10164. tm := time.Unix(his.RecordDate, 0)
  10165. s_tm := tm.Format("2006-01-02 15:04:05")
  10166. fed.AdmDate = s_tm
  10167. fed.DscgDate = s_tm
  10168. fed.DscgMainDiseCodg = config[0].CountryCode
  10169. fed.DscgMainDiseName = config[0].CountryContentName
  10170. //诊断信息
  10171. var fdds []*models.FsiDiagnoseDtos
  10172. for index, item := range config {
  10173. if index == 0 {
  10174. var fdd models.FsiDiagnoseDtos
  10175. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10176. fdd.InoutDiseType = "1"
  10177. fdd.MaindiseFlag = "1"
  10178. fdd.DiseDate = s_tm
  10179. fdd.DiasSrtNo = "1"
  10180. fdd.DiseName = item.CountryContentName
  10181. fdd.DiseCodg = item.CountryCode
  10182. fdds = append(fdds, &fdd)
  10183. } else {
  10184. var fdd models.FsiDiagnoseDtos
  10185. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10186. fdd.InoutDiseType = "1"
  10187. fdd.MaindiseFlag = "1"
  10188. fdd.DiseDate = s_tm
  10189. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10190. fdd.DiseName = item.CountryContentName
  10191. fdd.DiseCodg = item.CountryCode
  10192. fdds = append(fdds, &fdd)
  10193. }
  10194. }
  10195. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10196. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10197. fed.AdmDeptName = department.Name
  10198. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10199. fed.DscgDeptName = department.Name
  10200. fed.MedMdtrtType = "1"
  10201. fed.MedType = "11"
  10202. //if his.Insutype == "390" {
  10203. // fed.MedType = "1402"
  10204. //} else {
  10205. // fed.MedType = "9933"
  10206. //}
  10207. var orders []*models.FsiOrderDtos
  10208. if trig_scen == "2" {
  10209. //处方医嘱信息
  10210. for _, item := range prescriptions {
  10211. for _, subItem := range item.HisDoctorAdviceInfo {
  10212. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10213. var order models.FsiOrderDtos
  10214. order.RxID = strconv.FormatInt(item.ID, 10)
  10215. order.Rxno = strconv.FormatInt(item.ID, 10)
  10216. order.LongDrordFlag = "0"
  10217. order.HilistType = "1"
  10218. order.ChrgType = "1"
  10219. order.DrordBhvr = "-"
  10220. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10221. order.HosplistName = subItem.BaseDrugLib.DrugName
  10222. order.HilistLv = "1"
  10223. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10224. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10225. order.HosplistName = subItem.BaseDrugLib.DrugName
  10226. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10227. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10228. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10229. order.OwnpayAmt = ""
  10230. order.SelfpayAmt = ""
  10231. order.Spec = ""
  10232. order.SpecUnt = ""
  10233. order.DrordBegnDate = s_tm
  10234. order.DrordStopDate = ""
  10235. order.DrordDrCodg = doctor_info.DoctorNumber
  10236. order.DrordDeptName = department.Name
  10237. order.DrordDeptCodg = department.Number
  10238. order.DrordDrName = doctor_info.UserName
  10239. order.DrordDrProfttl = "234"
  10240. order.CurrDrordFlag = "1"
  10241. orders = append(orders, &order)
  10242. }
  10243. }
  10244. for _, subItem := range item.HisPrescriptionProject {
  10245. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10246. var order models.FsiOrderDtos
  10247. order.RxID = strconv.FormatInt(item.ID, 10)
  10248. order.Rxno = strconv.FormatInt(item.ID, 10)
  10249. order.LongDrordFlag = "0"
  10250. order.HilistType = "1"
  10251. order.ChrgType = "1"
  10252. order.DrordBhvr = "-"
  10253. order.HilistCode = subItem.HisProject.MedicalCode
  10254. order.HosplistName = subItem.HisProject.ProjectName
  10255. order.HilistLv = "1"
  10256. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10257. order.HosplistCode = subItem.HisProject.MedicalCode
  10258. order.HosplistName = subItem.HisProject.ProjectName
  10259. order.Cnt = subItem.Count
  10260. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10261. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10262. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10263. order.OwnpayAmt = ""
  10264. order.SelfpayAmt = ""
  10265. order.Spec = ""
  10266. order.SpecUnt = ""
  10267. order.DrordBegnDate = s_tm
  10268. order.DrordStopDate = ""
  10269. order.DrordDrCodg = doctor_info.DoctorNumber
  10270. order.DrordDeptName = department.Name
  10271. order.DrordDeptCodg = department.Number
  10272. order.DrordDrName = doctor_info.UserName
  10273. order.DrordDrProfttl = "234"
  10274. order.CurrDrordFlag = "1"
  10275. orders = append(orders, &order)
  10276. }
  10277. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10278. var order models.FsiOrderDtos
  10279. order.RxID = strconv.FormatInt(item.ID, 10)
  10280. order.Rxno = strconv.FormatInt(item.ID, 10)
  10281. order.LongDrordFlag = "0"
  10282. order.HilistType = "1"
  10283. order.ChrgType = "1"
  10284. order.DrordBhvr = "-"
  10285. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10286. order.HosplistName = subItem.GoodInfo.GoodName
  10287. order.HilistLv = "1"
  10288. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10289. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10290. order.HosplistName = subItem.GoodInfo.GoodName
  10291. order.Cnt = subItem.Count
  10292. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10293. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10294. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10295. order.OwnpayAmt = ""
  10296. order.SelfpayAmt = ""
  10297. order.Spec = ""
  10298. order.SpecUnt = ""
  10299. order.DrordBegnDate = s_tm
  10300. order.DrordStopDate = ""
  10301. order.DrordDrCodg = doctor_info.DoctorNumber
  10302. order.DrordDeptName = department.Name
  10303. order.DrordDeptCodg = department.Number
  10304. order.DrordDrName = doctor_info.UserName
  10305. order.DrordDrProfttl = "234"
  10306. order.CurrDrordFlag = "1"
  10307. orders = append(orders, &order)
  10308. }
  10309. }
  10310. }
  10311. //处方医嘱信息
  10312. }
  10313. fed.MatnStas = "0"
  10314. fed.MedfeeSumamt = "0"
  10315. fed.OwnpayAmt = "0"
  10316. fed.SelfpayAmt = "0"
  10317. fed.AcctPayamt = "0"
  10318. fed.MaAmt = "0"
  10319. fed.HifpPayamt = "0"
  10320. fed.SetlTotlnum = "1"
  10321. fed.Insutype = his.Insutype
  10322. fed.ReimFlag = "0"
  10323. fed.OutSetlFlag = "0"
  10324. var fopd []*models.FsiOperationDtosData
  10325. data := make(map[string]interface{})
  10326. data["fed"] = fed
  10327. data["fdd"] = fdds
  10328. data["fod"] = orders
  10329. data["pd"] = pd
  10330. data["pp"] = pp
  10331. data["fopd"] = fopd
  10332. data["trig_scen"] = trig_scen
  10333. fmt.Println(data)
  10334. fmt.Println(fed)
  10335. fmt.Println(fdds)
  10336. fmt.Println(orders)
  10337. fmt.Println(pd)
  10338. fmt.Println(pp)
  10339. fmt.Println(fopd)
  10340. client := &http.Client{}
  10341. bytesData, _ := json.Marshal(data)
  10342. var req *http.Request
  10343. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10344. if miConfig.MdtrtareaAdmvs == "320921" {
  10345. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10346. } else {
  10347. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10348. }
  10349. resp, _ := client.Do(req)
  10350. defer resp.Body.Close()
  10351. body, ioErr := ioutil.ReadAll(resp.Body)
  10352. if ioErr != nil {
  10353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10355. return res
  10356. }
  10357. var respJSON map[string]interface{}
  10358. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10361. return res
  10362. }
  10363. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10364. fmt.Println(respJSON)
  10365. result, _ := json.Marshal(respJSON)
  10366. fmt.Println(result)
  10367. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10368. utils.ErrorLog("解析失败:%v", err)
  10369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10370. return res
  10371. }
  10372. return res
  10373. } else {
  10374. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10375. saveLog(output, input, "3101", "事前")
  10376. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10377. utils.ErrorLog("解析失败:%v", err)
  10378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10379. return
  10380. }
  10381. return res
  10382. }
  10383. return res
  10384. }
  10385. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10386. ////patient_id, _ := c.GetInt64("patient_id")
  10387. //order_id, _ := c.GetInt64("order_id")
  10388. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10389. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10390. //trig_scen := c.GetString("trig_scen")
  10391. adminUser := c.GetAdminUserInfo()
  10392. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10393. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10394. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10395. record_time := c.GetString("record_time")
  10396. order, _ := service.GetHisOrderByID(order_id)
  10397. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10398. timeLayout := "2006-01-02"
  10399. loc, _ := time.LoadLocation("Local")
  10400. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10401. if err != nil {
  10402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10403. return
  10404. }
  10405. recordDateTime := theTime.Unix()
  10406. var patientPrescription models.HisPrescriptionInfo
  10407. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10408. if patientPrescription.ID == 0 {
  10409. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10410. }
  10411. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10412. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10413. //
  10414. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10415. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10416. var pp models.PublicParams
  10417. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10418. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10419. pp.FixmedinsName = miConfig.OrgName
  10420. pp.FixmedinsCode = miConfig.Code
  10421. pp.RequestUrl = miConfig.Url
  10422. pp.Cainfo = miConfig.Cainfo
  10423. pp.SecretKey = miConfig.SecretKey
  10424. pp.AccessKey = miConfig.AccessKey
  10425. pp.OpterName = roles.UserName
  10426. var config []*models.HisXtDiagnoseConfig
  10427. for _, item := range diagnosis_ids {
  10428. id, _ := strconv.ParseInt(item, 10, 64)
  10429. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10430. config = append(config, &diagnosisConfig)
  10431. }
  10432. var pd models.PatientDtos
  10433. pd.PatnID = his.PsnNo
  10434. pd.PatnName = his.Name
  10435. pd.Gend = his.Gend
  10436. pd.Brdy = psn_info.Brdy
  10437. pd.Poolarea = his.InsuplcAdmdvs
  10438. pd.CurrMdtrtID = his.Number
  10439. var fed models.FsiEncounterDtos
  10440. fed.MdtrtID = his.Number
  10441. fed.MedinsID = miConfig.Code
  10442. fed.MedinsName = miConfig.OrgName
  10443. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10444. fed.MedMdtrtType = "1"
  10445. fed.MedinsType = "1"
  10446. fed.MedinsLv = "11"
  10447. tm := time.Unix(his.RecordDate, 0)
  10448. s_tm := tm.Format("2006-01-02 15:04:05")
  10449. fed.AdmDate = s_tm
  10450. fed.DscgDate = s_tm
  10451. fed.DscgMainDiseCodg = config[0].CountryCode
  10452. fed.DscgMainDiseName = config[0].CountryContentName
  10453. //诊断信息
  10454. var fdds []*models.FsiDiagnoseDtos
  10455. for index, item := range config {
  10456. if index == 0 {
  10457. var fdd models.FsiDiagnoseDtos
  10458. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10459. fdd.InoutDiseType = "1"
  10460. fdd.MaindiseFlag = "1"
  10461. fdd.DiseDate = s_tm
  10462. fdd.DiasSrtNo = "1"
  10463. fdd.DiseName = item.CountryContentName
  10464. fdd.DiseCodg = item.CountryCode
  10465. fdds = append(fdds, &fdd)
  10466. } else {
  10467. var fdd models.FsiDiagnoseDtos
  10468. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10469. fdd.InoutDiseType = "1"
  10470. fdd.MaindiseFlag = "1"
  10471. fdd.DiseDate = s_tm
  10472. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10473. fdd.DiseName = item.CountryContentName
  10474. fdd.DiseCodg = item.CountryCode
  10475. fdds = append(fdds, &fdd)
  10476. }
  10477. }
  10478. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10479. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10480. fed.AdmDeptName = department.Name
  10481. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10482. fed.DscgDeptName = department.Name
  10483. fed.MedType = order.MedType
  10484. //处方医嘱信息
  10485. var orders []*models.FsiOrderDtos
  10486. //for _, item := range prescriptions {
  10487. // for _, subItem := range item.HisDoctorAdviceInfo {
  10488. // var order models.FsiOrderDtos
  10489. // order.RxID = strconv.FormatInt(item.ID, 10)
  10490. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10491. // order.LongDrordFlag = "0"
  10492. // order.HilistType = "1"
  10493. // order.ChrgType = "1"
  10494. // order.DrordBhvr = "-"
  10495. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10496. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10497. // order.HilistLv = "1"
  10498. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10499. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10500. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10501. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10502. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10503. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10504. // order.OwnpayAmt = ""
  10505. // order.SelfpayAmt = ""
  10506. // order.Spec = ""
  10507. // order.SpecUnt = ""
  10508. // order.DrordBegnDate = s_tm
  10509. // order.DrordStopDate = ""
  10510. // order.DrordDrCodg = "1"
  10511. // order.DrordDeptName = department.Name
  10512. // order.DrordDrCodg = "1"
  10513. // order.DrordDrName = doctor_info.UserName
  10514. // order.DrordDrProfttl = ""
  10515. // order.CurrDrordFlag = "1"
  10516. // orders = append(orders, &order)
  10517. // }
  10518. // for _, subItem := range item.HisPrescriptionProject {
  10519. // if subItem.Type == 2 {
  10520. // var order models.FsiOrderDtos
  10521. // order.RxID = strconv.FormatInt(item.ID, 10)
  10522. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10523. // order.LongDrordFlag = "0"
  10524. // order.HilistType = "1"
  10525. // order.ChrgType = "1"
  10526. // order.DrordBhvr = "-"
  10527. // order.HilistCode = subItem.HisProject.MedicalCode
  10528. // order.HosplistName = subItem.HisProject.ProjectName
  10529. // order.HilistLv = "1"
  10530. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10531. // order.HosplistCode = subItem.HisProject.MedicalCode
  10532. // order.HosplistName = subItem.HisProject.ProjectName
  10533. // order.Cnt = subItem.Count
  10534. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10535. //
  10536. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10537. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10538. // order.OwnpayAmt = ""
  10539. // order.SelfpayAmt = ""
  10540. // order.Spec = ""
  10541. // order.SpecUnt = ""
  10542. // order.DrordBegnDate = s_tm
  10543. // order.DrordStopDate = ""
  10544. // order.DrordDrCodg = "1"
  10545. // order.DrordDeptName = department.Name
  10546. // order.DrordDrCodg = "1"
  10547. // order.DrordDrName = doctor_info.UserName
  10548. // order.DrordDrProfttl = ""
  10549. // order.CurrDrordFlag = "1"
  10550. // orders = append(orders, &order)
  10551. //
  10552. // }
  10553. // if subItem.Type == 3 {
  10554. //
  10555. // var order models.FsiOrderDtos
  10556. // order.RxID = strconv.FormatInt(item.ID, 10)
  10557. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10558. // order.LongDrordFlag = "0"
  10559. // order.HilistType = "1"
  10560. // order.ChrgType = "1"
  10561. // order.DrordBhvr = "-"
  10562. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10563. // order.HosplistName = subItem.GoodInfo.GoodName
  10564. // order.HilistLv = "1"
  10565. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10566. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10567. // order.HosplistName = subItem.GoodInfo.GoodName
  10568. // order.Cnt = subItem.Count
  10569. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10570. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10571. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10572. // order.OwnpayAmt = ""
  10573. // order.SelfpayAmt = ""
  10574. // order.Spec = ""
  10575. // order.SpecUnt = ""
  10576. // order.DrordBegnDate = s_tm
  10577. // order.DrordStopDate = ""
  10578. // order.DrordDrCodg = "1"
  10579. // order.DrordDeptName = department.Name
  10580. // order.DrordDrCodg = "1"
  10581. // order.DrordDrName = doctor_info.UserName
  10582. // order.DrordDrProfttl = ""
  10583. // order.CurrDrordFlag = "1"
  10584. // orders = append(orders, &order)
  10585. //
  10586. // }
  10587. // }
  10588. //}
  10589. for _, item := range prescriptions {
  10590. for _, subItem := range item.HisDoctorAdviceInfo {
  10591. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10592. var order models.FsiOrderDtos
  10593. order.RxID = strconv.FormatInt(item.ID, 10)
  10594. order.Rxno = strconv.FormatInt(item.ID, 10)
  10595. order.LongDrordFlag = "0"
  10596. order.HilistType = "1"
  10597. order.ChrgType = "1"
  10598. order.DrordBhvr = "-"
  10599. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10600. order.HosplistName = subItem.BaseDrugLib.DrugName
  10601. order.HilistLv = "1"
  10602. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10603. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10604. order.HosplistName = subItem.BaseDrugLib.DrugName
  10605. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10606. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10607. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10608. order.OwnpayAmt = ""
  10609. order.SelfpayAmt = ""
  10610. order.Spec = ""
  10611. order.SpecUnt = ""
  10612. order.DrordBegnDate = s_tm
  10613. order.DrordStopDate = ""
  10614. order.DrordDrCodg = doctor_info.DoctorNumber
  10615. order.DrordDeptName = department.Name
  10616. order.DrordDeptCodg = department.Number
  10617. order.DrordDrName = doctor_info.UserName
  10618. order.DrordDrProfttl = "234"
  10619. order.CurrDrordFlag = "1"
  10620. orders = append(orders, &order)
  10621. }
  10622. }
  10623. for _, subItem := range item.HisPrescriptionProject {
  10624. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10625. var order models.FsiOrderDtos
  10626. order.RxID = strconv.FormatInt(item.ID, 10)
  10627. order.Rxno = strconv.FormatInt(item.ID, 10)
  10628. order.LongDrordFlag = "0"
  10629. order.HilistType = "1"
  10630. order.ChrgType = "1"
  10631. order.DrordBhvr = "-"
  10632. order.HilistCode = subItem.HisProject.MedicalCode
  10633. order.HosplistName = subItem.HisProject.ProjectName
  10634. order.HilistLv = "1"
  10635. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10636. order.HosplistCode = subItem.HisProject.MedicalCode
  10637. order.HosplistName = subItem.HisProject.ProjectName
  10638. order.Cnt = subItem.Count
  10639. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10640. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10641. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10642. order.OwnpayAmt = ""
  10643. order.SelfpayAmt = ""
  10644. order.Spec = ""
  10645. order.SpecUnt = ""
  10646. order.DrordBegnDate = s_tm
  10647. order.DrordStopDate = ""
  10648. order.DrordDrCodg = doctor_info.DoctorNumber
  10649. order.DrordDeptName = department.Name
  10650. order.DrordDeptCodg = department.Number
  10651. order.DrordDrName = doctor_info.UserName
  10652. order.DrordDrProfttl = "234"
  10653. order.CurrDrordFlag = "1"
  10654. orders = append(orders, &order)
  10655. }
  10656. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10657. var order models.FsiOrderDtos
  10658. order.RxID = strconv.FormatInt(item.ID, 10)
  10659. order.Rxno = strconv.FormatInt(item.ID, 10)
  10660. order.LongDrordFlag = "0"
  10661. order.HilistType = "1"
  10662. order.ChrgType = "1"
  10663. order.DrordBhvr = "0"
  10664. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10665. order.HosplistName = subItem.GoodInfo.GoodName
  10666. order.HilistLv = "1"
  10667. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10668. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10669. order.HosplistName = subItem.GoodInfo.GoodName
  10670. order.Cnt = subItem.Count
  10671. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10672. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10673. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10674. order.OwnpayAmt = ""
  10675. order.SelfpayAmt = ""
  10676. order.Spec = ""
  10677. order.SpecUnt = ""
  10678. order.DrordBegnDate = s_tm
  10679. order.DrordStopDate = ""
  10680. order.DrordDrCodg = doctor_info.DoctorNumber
  10681. order.DrordDeptName = department.Name
  10682. order.DrordDeptCodg = department.Number
  10683. order.DrordDrName = doctor_info.UserName
  10684. order.DrordDrProfttl = "234"
  10685. order.CurrDrordFlag = "1"
  10686. orders = append(orders, &order)
  10687. }
  10688. }
  10689. }
  10690. //处方医嘱信息
  10691. fed.MatnStas = "0"
  10692. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  10693. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  10694. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  10695. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  10696. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  10697. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  10698. fed.SetlTotlnum = "1"
  10699. fed.Insutype = his.Insutype
  10700. fed.ReimFlag = "0"
  10701. fed.OutSetlFlag = "0"
  10702. var fopd []*models.FsiOperationDtosData
  10703. data := make(map[string]interface{})
  10704. data["fed"] = fed
  10705. data["fdd"] = fdds
  10706. data["fod"] = orders
  10707. data["pd"] = pd
  10708. data["pp"] = pp
  10709. data["fopd"] = fopd
  10710. data["trig_scen"] = trig_scen
  10711. client := &http.Client{}
  10712. bytesData, _ := json.Marshal(data)
  10713. var req *http.Request
  10714. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10715. if miConfig.MdtrtareaAdmvs == "320921" {
  10716. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10717. } else {
  10718. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10719. }
  10720. resp, _ := client.Do(req)
  10721. defer resp.Body.Close()
  10722. body, ioErr := ioutil.ReadAll(resp.Body)
  10723. if ioErr != nil {
  10724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10726. return res
  10727. }
  10728. var respJSON map[string]interface{}
  10729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10732. return res
  10733. }
  10734. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10735. result, _ := json.Marshal(respJSON)
  10736. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10737. utils.ErrorLog("解析失败:%v", err)
  10738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10739. return res
  10740. }
  10741. return res
  10742. } else {
  10743. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10744. saveLog(output, input, "3102", "事中")
  10745. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10746. utils.ErrorLog("解析失败:%v", err)
  10747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10748. return
  10749. }
  10750. return res
  10751. }
  10752. return res
  10753. }
  10754. func Checkgd3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription, de models.XtHisDepartment) (res2 Resultgd3101) {
  10755. var res Resultgd3101
  10756. adminUser := c.GetAdminUserInfo()
  10757. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10758. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10759. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10760. //record_time := c.GetString("record_time")
  10761. //trig_scen := c.GetString("trig_scen")
  10762. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10763. //psn_info, _ := service.GetPatientId(patient_id)
  10764. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10765. timeLayout := "2006-01-02"
  10766. loc, _ := time.LoadLocation("Local")
  10767. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10768. if err != nil {
  10769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10770. return res
  10771. }
  10772. recordDateTime := theTime.Unix()
  10773. var patientPrescription models.HisPrescriptionInfo
  10774. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10775. //if patientPrescription.ID == 0 {
  10776. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10777. //}
  10778. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10779. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10780. //
  10781. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10782. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10783. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10784. var pp models.PublicParams
  10785. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10786. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10787. pp.FixmedinsName = miConfig.OrgName
  10788. pp.FixmedinsCode = miConfig.Code
  10789. pp.RequestUrl = miConfig.Url
  10790. pp.Cainfo = miConfig.Cainfo
  10791. pp.SecretKey = miConfig.SecretKey
  10792. pp.AccessKey = miConfig.AccessKey
  10793. pp.OpterName = roles.UserName
  10794. var config []*models.HisXtDiagnoseConfig
  10795. for _, item := range diagnosis_ids {
  10796. id, _ := strconv.ParseInt(item, 10, 64)
  10797. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10798. config = append(config, &diagnosisConfig)
  10799. }
  10800. var pd models.PatientDtos
  10801. pd.PatnID = his.PsnNo
  10802. pd.PatnName = his.Name
  10803. pd.Gend = his.Gend
  10804. pd.Brdy = str
  10805. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10806. pd.CurrMdtrtID = his.Number
  10807. var fed models.FsiEncounterDtos
  10808. fed.MdtrtID = his.Number
  10809. fed.MedinsID = miConfig.Code
  10810. fed.MedinsName = miConfig.OrgName
  10811. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10812. fed.MedMdtrtType = "1"
  10813. fed.MedinsType = "1"
  10814. fed.MedinsLv = "11"
  10815. tm := time.Unix(his.RecordDate, 0)
  10816. s_tm := tm.Format("2006-01-02 15:04:05")
  10817. fed.AdmDate = s_tm
  10818. fed.DscgDate = s_tm
  10819. fed.DscgMainDiseCodg = config[0].CountryCode
  10820. fed.DscgMainDiseName = config[0].CountryContentName
  10821. //诊断信息
  10822. var fdds []*models.FsiDiagnoseDtos
  10823. for index, item := range config {
  10824. if index == 0 {
  10825. var fdd models.FsiDiagnoseDtos
  10826. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10827. fdd.InoutDiseType = "1"
  10828. fdd.MaindiseFlag = "1"
  10829. fdd.DiseDate = s_tm
  10830. fdd.DiasSrtNo = "1"
  10831. fdd.DiseName = item.CountryContentName
  10832. fdd.DiseCodg = item.CountryCode
  10833. fdds = append(fdds, &fdd)
  10834. } else {
  10835. var fdd models.FsiDiagnoseDtos
  10836. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10837. fdd.InoutDiseType = "1"
  10838. fdd.MaindiseFlag = "1"
  10839. fdd.DiseDate = s_tm
  10840. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10841. fdd.DiseName = item.CountryContentName
  10842. fdd.DiseCodg = item.CountryCode
  10843. fdds = append(fdds, &fdd)
  10844. }
  10845. }
  10846. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10847. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10848. fed.AdmDeptName = de.Name
  10849. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10850. fed.DscgDeptName = de.Name
  10851. fed.MedMdtrtType = "1"
  10852. fed.MedType = "11"
  10853. //if his.Insutype == "390" {
  10854. // fed.MedType = "1402"
  10855. //} else {
  10856. // fed.MedType = "9933"
  10857. //}
  10858. var orders []*models.FsiOrderDtos
  10859. if trig_scen == "2" {
  10860. //处方医嘱信息
  10861. for _, item := range prescriptions {
  10862. for _, subItem := range item.HisDoctorAdviceInfo {
  10863. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10864. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10865. var order models.FsiOrderDtos
  10866. order.RxID = strconv.FormatInt(item.ID, 10)
  10867. order.Rxno = strconv.FormatInt(item.ID, 10)
  10868. order.LongDrordFlag = "0"
  10869. order.HilistType = "1"
  10870. order.ChrgType = "1"
  10871. order.DrordBhvr = "0"
  10872. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10873. order.HosplistName = subItem.BaseDrugLib.DrugName
  10874. order.HilistLv = "1"
  10875. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10876. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10877. order.HosplistName = subItem.BaseDrugLib.DrugName
  10878. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10879. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10880. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10881. order.OwnpayAmt = ""
  10882. order.SelfpayAmt = ""
  10883. order.Spec = spec
  10884. order.SpecUnt = subItem.PrescribingNumberUnit
  10885. order.DrordBegnDate = s_tm
  10886. order.DrordStopDate = ""
  10887. order.DrordDrCodg = doctor_info.DoctorNumber
  10888. order.DrordDeptName = department.Name
  10889. order.DrordDeptCodg = department.Number
  10890. order.DrordDrName = doctor_info.UserName
  10891. order.DrordDrProfttl = "234"
  10892. order.CurrDrordFlag = "1"
  10893. orders = append(orders, &order)
  10894. }
  10895. }
  10896. for _, subItem := range item.HisPrescriptionProject {
  10897. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10898. var order models.FsiOrderDtos
  10899. order.RxID = strconv.FormatInt(item.ID, 10)
  10900. order.Rxno = strconv.FormatInt(item.ID, 10)
  10901. order.LongDrordFlag = "0"
  10902. order.HilistType = "1"
  10903. order.ChrgType = "1"
  10904. order.DrordBhvr = "0"
  10905. order.HilistCode = subItem.HisProject.MedicalCode
  10906. order.HosplistName = subItem.HisProject.ProjectName
  10907. order.HilistLv = "1"
  10908. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10909. order.HosplistCode = subItem.HisProject.MedicalCode
  10910. order.HosplistName = subItem.HisProject.ProjectName
  10911. order.Cnt = subItem.Count
  10912. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10913. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10914. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10915. order.OwnpayAmt = ""
  10916. order.SelfpayAmt = ""
  10917. order.Spec = subItem.Unit
  10918. order.SpecUnt = subItem.Unit
  10919. order.DrordBegnDate = s_tm
  10920. order.DrordStopDate = ""
  10921. order.DrordDrCodg = doctor_info.DoctorNumber
  10922. order.DrordDeptName = department.Name
  10923. order.DrordDeptCodg = department.Number
  10924. order.DrordDrName = doctor_info.UserName
  10925. order.DrordDrProfttl = "234"
  10926. order.CurrDrordFlag = "1"
  10927. orders = append(orders, &order)
  10928. }
  10929. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10930. var order models.FsiOrderDtos
  10931. order.RxID = strconv.FormatInt(item.ID, 10)
  10932. order.Rxno = strconv.FormatInt(item.ID, 10)
  10933. order.LongDrordFlag = "0"
  10934. order.HilistType = "1"
  10935. order.ChrgType = "1"
  10936. order.DrordBhvr = "0"
  10937. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10938. order.HosplistName = subItem.GoodInfo.GoodName
  10939. order.HilistLv = "1"
  10940. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10941. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10942. order.HosplistName = subItem.GoodInfo.GoodName
  10943. order.Cnt = subItem.Count
  10944. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10945. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10946. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10947. order.OwnpayAmt = ""
  10948. order.SelfpayAmt = ""
  10949. order.Spec = subItem.GoodInfo.SpecificationName
  10950. order.SpecUnt = subItem.Unit
  10951. order.DrordBegnDate = s_tm
  10952. order.DrordStopDate = ""
  10953. order.DrordDrCodg = doctor_info.DoctorNumber
  10954. order.DrordDeptName = department.Name
  10955. order.DrordDeptCodg = department.Number
  10956. order.DrordDrName = doctor_info.UserName
  10957. order.DrordDrProfttl = "234"
  10958. order.CurrDrordFlag = "1"
  10959. orders = append(orders, &order)
  10960. }
  10961. }
  10962. }
  10963. //处方医嘱信息
  10964. }
  10965. fed.MatnStas = "0"
  10966. fed.MedfeeSumamt = "0"
  10967. fed.OwnpayAmt = "0"
  10968. fed.SelfpayAmt = "0"
  10969. fed.AcctPayamt = "0"
  10970. fed.MaAmt = "0"
  10971. fed.HifpPayamt = "0"
  10972. fed.SetlTotlnum = "1"
  10973. fed.Insutype = his.Insutype
  10974. fed.ReimFlag = "0"
  10975. fed.OutSetlFlag = "0"
  10976. var fopd []*models.FsiOperationDtosData
  10977. data := make(map[string]interface{})
  10978. data["fed"] = fed
  10979. data["fdd"] = fdds
  10980. data["fod"] = orders
  10981. data["pd"] = pd
  10982. data["pp"] = pp
  10983. data["fopd"] = fopd
  10984. data["trig_scen"] = trig_scen
  10985. fmt.Println(data)
  10986. fmt.Println(fed)
  10987. fmt.Println(fdds)
  10988. fmt.Println(orders)
  10989. fmt.Println(pd)
  10990. fmt.Println(pp)
  10991. fmt.Println(fopd)
  10992. client := &http.Client{}
  10993. bytesData, _ := json.Marshal(data)
  10994. var req *http.Request
  10995. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10996. if miConfig.MdtrtareaAdmvs == "320921" {
  10997. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10998. } else {
  10999. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11000. }
  11001. resp, _ := client.Do(req)
  11002. defer resp.Body.Close()
  11003. body, ioErr := ioutil.ReadAll(resp.Body)
  11004. if ioErr != nil {
  11005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11007. return res
  11008. }
  11009. var respJSON map[string]interface{}
  11010. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11013. return res
  11014. }
  11015. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11016. fmt.Println(respJSON)
  11017. result, _ := json.Marshal(respJSON)
  11018. fmt.Println(result)
  11019. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11020. utils.ErrorLog("解析失败:%v", err)
  11021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11022. return res
  11023. }
  11024. return res
  11025. } else {
  11026. //if miConfig.MdtrtareaAdmvs == "441202" {
  11027. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11028. saveLog(output, input, "3101", "事前")
  11029. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11030. utils.ErrorLog("解析失败:%v", err)
  11031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11032. return
  11033. }
  11034. return res
  11035. //}
  11036. }
  11037. }
  11038. 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) {
  11039. adminUser := c.GetAdminUserInfo()
  11040. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11041. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11042. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11043. //record_time := c.GetString("record_time")
  11044. //trig_scen := c.GetString("trig_scen")
  11045. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11046. timeLayout := "2006-01-02"
  11047. loc, _ := time.LoadLocation("Local")
  11048. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11049. if err != nil {
  11050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11051. return res
  11052. }
  11053. recordDateTime := theTime.Unix()
  11054. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11055. var patientPrescription models.HisPrescriptionInfo
  11056. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11057. if patientPrescription.ID == 0 {
  11058. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11059. }
  11060. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11061. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11062. //
  11063. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11064. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11065. var pp models.PublicParams
  11066. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11067. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11068. pp.FixmedinsName = miConfig.OrgName
  11069. pp.FixmedinsCode = miConfig.Code
  11070. pp.RequestUrl = miConfig.Url
  11071. pp.Cainfo = miConfig.Cainfo
  11072. pp.SecretKey = miConfig.SecretKey
  11073. pp.AccessKey = miConfig.AccessKey
  11074. pp.OpterName = roles.UserName
  11075. var config []*models.HisXtDiagnoseConfig
  11076. for _, item := range diagnosis_ids {
  11077. id, _ := strconv.ParseInt(item, 10, 64)
  11078. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11079. config = append(config, &diagnosisConfig)
  11080. }
  11081. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11082. var pd models.PatientDtos
  11083. pd.PatnID = his.PsnNo
  11084. pd.PatnName = his.Name
  11085. pd.Gend = his.Gend
  11086. pd.Brdy = str
  11087. pd.Poolarea = his.InsuplcAdmdvs
  11088. pd.CurrMdtrtID = his.Number
  11089. var fed models.FsiEncounterDtos
  11090. fed.MdtrtID = his.Number
  11091. fed.MedinsID = miConfig.Code
  11092. fed.MedinsName = miConfig.OrgName
  11093. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11094. fed.MedMdtrtType = "1"
  11095. fed.MedinsType = "1"
  11096. fed.MedinsLv = "11"
  11097. tm := time.Unix(his.RecordDate, 0)
  11098. s_tm := tm.Format("2006-01-02 15:04:05")
  11099. fed.AdmDate = s_tm
  11100. fed.DscgDate = s_tm
  11101. fed.DscgMainDiseCodg = config[0].CountryCode
  11102. fed.DscgMainDiseName = config[0].CountryContentName
  11103. //诊断信息
  11104. var fdds []*models.FsiDiagnoseDtos
  11105. for index, item := range config {
  11106. if index == 0 {
  11107. var fdd models.FsiDiagnoseDtos
  11108. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11109. fdd.InoutDiseType = "1"
  11110. fdd.MaindiseFlag = "1"
  11111. fdd.DiseDate = s_tm
  11112. fdd.DiasSrtNo = "1"
  11113. fdd.DiseName = item.CountryContentName
  11114. fdd.DiseCodg = item.CountryCode
  11115. fdds = append(fdds, &fdd)
  11116. } else {
  11117. var fdd models.FsiDiagnoseDtos
  11118. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11119. fdd.InoutDiseType = "1"
  11120. fdd.MaindiseFlag = "1"
  11121. fdd.DiseDate = s_tm
  11122. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11123. fdd.DiseName = item.CountryContentName
  11124. fdd.DiseCodg = item.CountryCode
  11125. fdds = append(fdds, &fdd)
  11126. }
  11127. }
  11128. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11129. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11130. fed.AdmDeptName = department.Name
  11131. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11132. fed.DscgDeptName = department.Name
  11133. fed.MedMdtrtType = "1"
  11134. fed.MedType = "11"
  11135. //if his.Insutype == "390" {
  11136. // fed.MedType = "1402"
  11137. //} else {
  11138. // fed.MedType = "9933"
  11139. //}
  11140. var orders []*models.FsiOrderDtos
  11141. if trig_scen == "2" {
  11142. //处方医嘱信息
  11143. for _, item := range prescriptions {
  11144. for _, subItem := range item.HisDoctorAdviceInfo {
  11145. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11146. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11147. var order models.FsiOrderDtos
  11148. order.RxID = strconv.FormatInt(item.ID, 10)
  11149. order.Rxno = strconv.FormatInt(item.ID, 10)
  11150. order.LongDrordFlag = "0"
  11151. order.HilistType = "1"
  11152. order.ChrgType = "1"
  11153. order.DrordBhvr = "0"
  11154. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11155. order.HosplistName = subItem.BaseDrugLib.DrugName
  11156. order.HilistLv = "1"
  11157. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11158. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11159. order.HosplistName = subItem.BaseDrugLib.DrugName
  11160. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11161. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11162. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11163. order.OwnpayAmt = ""
  11164. order.SelfpayAmt = ""
  11165. order.Spec = spec
  11166. order.SpecUnt = subItem.PrescribingNumberUnit
  11167. order.DrordBegnDate = s_tm
  11168. order.DrordStopDate = ""
  11169. order.DrordDrCodg = doctor_info.DoctorNumber
  11170. order.DrordDeptName = department.Name
  11171. order.DrordDeptCodg = department.Number
  11172. order.DrordDrName = doctor_info.UserName
  11173. order.DrordDrProfttl = "234"
  11174. order.CurrDrordFlag = "1"
  11175. orders = append(orders, &order)
  11176. }
  11177. }
  11178. for _, subItem := range item.HisPrescriptionProject {
  11179. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11180. var order models.FsiOrderDtos
  11181. order.RxID = strconv.FormatInt(item.ID, 10)
  11182. order.Rxno = strconv.FormatInt(item.ID, 10)
  11183. order.LongDrordFlag = "0"
  11184. order.HilistType = "1"
  11185. order.ChrgType = "1"
  11186. order.DrordBhvr = "0"
  11187. order.HilistCode = subItem.HisProject.MedicalCode
  11188. order.HosplistName = subItem.HisProject.ProjectName
  11189. order.HilistLv = "1"
  11190. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11191. order.HosplistCode = subItem.HisProject.MedicalCode
  11192. order.HosplistName = subItem.HisProject.ProjectName
  11193. order.Cnt = subItem.Count
  11194. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11195. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11196. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11197. order.OwnpayAmt = ""
  11198. order.SelfpayAmt = ""
  11199. order.Spec = subItem.Unit
  11200. order.SpecUnt = subItem.Unit
  11201. order.DrordBegnDate = s_tm
  11202. order.DrordStopDate = ""
  11203. order.DrordDrCodg = doctor_info.DoctorNumber
  11204. order.DrordDeptName = department.Name
  11205. order.DrordDeptCodg = department.Number
  11206. order.DrordDrName = doctor_info.UserName
  11207. order.DrordDrProfttl = "234"
  11208. order.CurrDrordFlag = "1"
  11209. orders = append(orders, &order)
  11210. }
  11211. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11212. var order models.FsiOrderDtos
  11213. order.RxID = strconv.FormatInt(item.ID, 10)
  11214. order.Rxno = strconv.FormatInt(item.ID, 10)
  11215. order.LongDrordFlag = "0"
  11216. order.HilistType = "1"
  11217. order.ChrgType = "1"
  11218. order.DrordBhvr = "0"
  11219. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11220. order.HosplistName = subItem.GoodInfo.GoodName
  11221. order.HilistLv = "1"
  11222. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11223. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11224. order.HosplistName = subItem.GoodInfo.GoodName
  11225. order.Cnt = subItem.Count
  11226. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11227. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11228. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11229. order.OwnpayAmt = ""
  11230. order.SelfpayAmt = ""
  11231. order.Spec = subItem.GoodInfo.SpecificationName
  11232. order.SpecUnt = subItem.Unit
  11233. order.DrordBegnDate = s_tm
  11234. order.DrordStopDate = ""
  11235. order.DrordDrCodg = doctor_info.DoctorNumber
  11236. order.DrordDeptName = department.Name
  11237. order.DrordDeptCodg = department.Number
  11238. order.DrordDrName = doctor_info.UserName
  11239. order.DrordDrProfttl = "234"
  11240. order.CurrDrordFlag = "1"
  11241. orders = append(orders, &order)
  11242. }
  11243. }
  11244. }
  11245. //处方医嘱信息
  11246. }
  11247. fed.MatnStas = "0"
  11248. fed.MedfeeSumamt = "0"
  11249. fed.OwnpayAmt = "0"
  11250. fed.SelfpayAmt = "0"
  11251. fed.AcctPayamt = "0"
  11252. fed.MaAmt = "0"
  11253. fed.HifpPayamt = "0"
  11254. fed.SetlTotlnum = "1"
  11255. fed.Insutype = his.Insutype
  11256. fed.ReimFlag = "0"
  11257. fed.OutSetlFlag = "0"
  11258. var fopd []*models.FsiOperationDtosData
  11259. data := make(map[string]interface{})
  11260. data["fed"] = fed
  11261. data["fdd"] = fdds
  11262. data["fod"] = orders
  11263. data["pd"] = pd
  11264. data["pp"] = pp
  11265. data["fopd"] = fopd
  11266. data["trig_scen"] = trig_scen
  11267. fmt.Println(data)
  11268. fmt.Println(fed)
  11269. fmt.Println(fdds)
  11270. fmt.Println(orders)
  11271. fmt.Println(pd)
  11272. fmt.Println(pp)
  11273. fmt.Println(fopd)
  11274. client := &http.Client{}
  11275. bytesData, _ := json.Marshal(data)
  11276. var req *http.Request
  11277. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11278. if miConfig.MdtrtareaAdmvs == "320921" {
  11279. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11280. } else {
  11281. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11282. }
  11283. resp, _ := client.Do(req)
  11284. defer resp.Body.Close()
  11285. body, ioErr := ioutil.ReadAll(resp.Body)
  11286. if ioErr != nil {
  11287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11289. return res
  11290. }
  11291. var respJSON map[string]interface{}
  11292. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11295. return res
  11296. }
  11297. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11298. fmt.Println(respJSON)
  11299. result, _ := json.Marshal(respJSON)
  11300. fmt.Println(result)
  11301. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11302. utils.ErrorLog("解析失败:%v", err)
  11303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11304. return res
  11305. }
  11306. return res
  11307. } else {
  11308. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11309. saveLog(output, input, "3101", "事前")
  11310. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11311. utils.ErrorLog("解析失败:%v", err)
  11312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11313. return
  11314. }
  11315. return res
  11316. }
  11317. return res
  11318. }
  11319. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11320. ////patient_id, _ := c.GetInt64("patient_id")
  11321. //order_id, _ := c.GetInt64("order_id")
  11322. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11323. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11324. //trig_scen := c.GetString("trig_scen")
  11325. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11326. //utils.ErrorLog("解析失败:%v", psn_info)
  11327. adminUser := c.GetAdminUserInfo()
  11328. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11329. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11330. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11331. record_time := c.GetString("record_time")
  11332. order, _ := service.GetHisOrderByID(order_id)
  11333. timeLayout := "2006-01-02"
  11334. loc, _ := time.LoadLocation("Local")
  11335. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11336. if err != nil {
  11337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11338. return
  11339. }
  11340. recordDateTime := theTime.Unix()
  11341. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11342. var patientPrescription models.HisPrescriptionInfo
  11343. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11344. if patientPrescription.ID == 0 {
  11345. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11346. }
  11347. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11348. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11349. //
  11350. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11351. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11352. var pp models.PublicParams
  11353. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11354. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11355. pp.FixmedinsName = miConfig.OrgName
  11356. pp.FixmedinsCode = miConfig.Code
  11357. pp.RequestUrl = miConfig.Url
  11358. pp.Cainfo = miConfig.Cainfo
  11359. pp.SecretKey = miConfig.SecretKey
  11360. pp.AccessKey = miConfig.AccessKey
  11361. pp.OpterName = roles.UserName
  11362. var config []*models.HisXtDiagnoseConfig
  11363. for _, item := range diagnosis_ids {
  11364. id, _ := strconv.ParseInt(item, 10, 64)
  11365. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11366. config = append(config, &diagnosisConfig)
  11367. }
  11368. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11369. var pd models.PatientDtos
  11370. pd.PatnID = his.PsnNo
  11371. pd.PatnName = his.Name
  11372. pd.Gend = his.Gend
  11373. pd.Brdy = str
  11374. pd.Poolarea = his.InsuplcAdmdvs
  11375. pd.CurrMdtrtID = his.Number
  11376. var fed models.FsiEncounterDtos
  11377. fed.MdtrtID = his.Number
  11378. fed.MedinsID = miConfig.Code
  11379. fed.MedinsName = miConfig.OrgName
  11380. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11381. fed.MedMdtrtType = "1"
  11382. fed.MedinsType = "1"
  11383. fed.MedinsLv = "11"
  11384. tm := time.Unix(his.RecordDate, 0)
  11385. s_tm := tm.Format("2006-01-02 15:04:05")
  11386. fed.AdmDate = s_tm
  11387. fed.DscgDate = s_tm
  11388. fed.DscgMainDiseCodg = config[0].CountryCode
  11389. fed.DscgMainDiseName = config[0].CountryContentName
  11390. //诊断信息
  11391. var fdds []*models.FsiDiagnoseDtos
  11392. for index, item := range config {
  11393. if index == 0 {
  11394. var fdd models.FsiDiagnoseDtos
  11395. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11396. fdd.InoutDiseType = "1"
  11397. fdd.MaindiseFlag = "1"
  11398. fdd.DiseDate = s_tm
  11399. fdd.DiasSrtNo = "1"
  11400. fdd.DiseName = item.CountryContentName
  11401. fdd.DiseCodg = item.CountryCode
  11402. fdds = append(fdds, &fdd)
  11403. } else {
  11404. var fdd models.FsiDiagnoseDtos
  11405. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11406. fdd.InoutDiseType = "1"
  11407. fdd.MaindiseFlag = "1"
  11408. fdd.DiseDate = s_tm
  11409. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11410. fdd.DiseName = item.CountryContentName
  11411. fdd.DiseCodg = item.CountryCode
  11412. fdds = append(fdds, &fdd)
  11413. }
  11414. }
  11415. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11416. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11417. fed.AdmDeptName = department.Name
  11418. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11419. fed.DscgDeptName = department.Name
  11420. fed.MedType = order.MedType
  11421. //处方医嘱信息
  11422. var orders []*models.FsiOrderDtos
  11423. //for _, item := range prescriptions {
  11424. // for _, subItem := range item.HisDoctorAdviceInfo {
  11425. // var order models.FsiOrderDtos
  11426. // order.RxID = strconv.FormatInt(item.ID, 10)
  11427. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11428. // order.LongDrordFlag = "0"
  11429. // order.HilistType = "1"
  11430. // order.ChrgType = "1"
  11431. // order.DrordBhvr = "-"
  11432. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11433. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11434. // order.HilistLv = "1"
  11435. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11436. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11437. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11438. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11439. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11440. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11441. // order.OwnpayAmt = ""
  11442. // order.SelfpayAmt = ""
  11443. // order.Spec = ""
  11444. // order.SpecUnt = ""
  11445. // order.DrordBegnDate = s_tm
  11446. // order.DrordStopDate = ""
  11447. // order.DrordDrCodg = "1"
  11448. // order.DrordDeptName = department.Name
  11449. // order.DrordDrCodg = "1"
  11450. // order.DrordDrName = doctor_info.UserName
  11451. // order.DrordDrProfttl = ""
  11452. // order.CurrDrordFlag = "1"
  11453. // orders = append(orders, &order)
  11454. // }
  11455. // for _, subItem := range item.HisPrescriptionProject {
  11456. // if subItem.Type == 2 {
  11457. // var order models.FsiOrderDtos
  11458. // order.RxID = strconv.FormatInt(item.ID, 10)
  11459. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11460. // order.LongDrordFlag = "0"
  11461. // order.HilistType = "1"
  11462. // order.ChrgType = "1"
  11463. // order.DrordBhvr = "-"
  11464. // order.HilistCode = subItem.HisProject.MedicalCode
  11465. // order.HosplistName = subItem.HisProject.ProjectName
  11466. // order.HilistLv = "1"
  11467. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11468. // order.HosplistCode = subItem.HisProject.MedicalCode
  11469. // order.HosplistName = subItem.HisProject.ProjectName
  11470. // order.Cnt = subItem.Count
  11471. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11472. //
  11473. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11474. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11475. // order.OwnpayAmt = ""
  11476. // order.SelfpayAmt = ""
  11477. // order.Spec = ""
  11478. // order.SpecUnt = ""
  11479. // order.DrordBegnDate = s_tm
  11480. // order.DrordStopDate = ""
  11481. // order.DrordDrCodg = "1"
  11482. // order.DrordDeptName = department.Name
  11483. // order.DrordDrCodg = "1"
  11484. // order.DrordDrName = doctor_info.UserName
  11485. // order.DrordDrProfttl = ""
  11486. // order.CurrDrordFlag = "1"
  11487. // orders = append(orders, &order)
  11488. //
  11489. // }
  11490. // if subItem.Type == 3 {
  11491. //
  11492. // var order models.FsiOrderDtos
  11493. // order.RxID = strconv.FormatInt(item.ID, 10)
  11494. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11495. // order.LongDrordFlag = "0"
  11496. // order.HilistType = "1"
  11497. // order.ChrgType = "1"
  11498. // order.DrordBhvr = "-"
  11499. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11500. // order.HosplistName = subItem.GoodInfo.GoodName
  11501. // order.HilistLv = "1"
  11502. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11503. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11504. // order.HosplistName = subItem.GoodInfo.GoodName
  11505. // order.Cnt = subItem.Count
  11506. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11507. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11508. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11509. // order.OwnpayAmt = ""
  11510. // order.SelfpayAmt = ""
  11511. // order.Spec = ""
  11512. // order.SpecUnt = ""
  11513. // order.DrordBegnDate = s_tm
  11514. // order.DrordStopDate = ""
  11515. // order.DrordDrCodg = "1"
  11516. // order.DrordDeptName = department.Name
  11517. // order.DrordDrCodg = "1"
  11518. // order.DrordDrName = doctor_info.UserName
  11519. // order.DrordDrProfttl = ""
  11520. // order.CurrDrordFlag = "1"
  11521. // orders = append(orders, &order)
  11522. //
  11523. // }
  11524. // }
  11525. //}
  11526. for _, item := range prescriptions {
  11527. for _, subItem := range item.HisDoctorAdviceInfo {
  11528. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11529. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11530. var order models.FsiOrderDtos
  11531. order.RxID = strconv.FormatInt(item.ID, 10)
  11532. order.Rxno = strconv.FormatInt(item.ID, 10)
  11533. order.LongDrordFlag = "0"
  11534. order.HilistType = "1"
  11535. order.ChrgType = "1"
  11536. order.DrordBhvr = "0"
  11537. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11538. order.HosplistName = subItem.BaseDrugLib.DrugName
  11539. order.HilistLv = "1"
  11540. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11541. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11542. order.HosplistName = subItem.BaseDrugLib.DrugName
  11543. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11544. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11545. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11546. order.OwnpayAmt = ""
  11547. order.SelfpayAmt = ""
  11548. order.Spec = spec
  11549. order.SpecUnt = subItem.PrescribingNumberUnit
  11550. order.DrordBegnDate = s_tm
  11551. order.DrordStopDate = ""
  11552. order.DrordDrCodg = doctor_info.DoctorNumber
  11553. order.DrordDeptName = department.Name
  11554. order.DrordDeptCodg = department.Number
  11555. order.DrordDrName = doctor_info.UserName
  11556. order.DrordDrProfttl = "234"
  11557. order.CurrDrordFlag = "1"
  11558. orders = append(orders, &order)
  11559. }
  11560. }
  11561. for _, subItem := range item.HisPrescriptionProject {
  11562. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11563. var order models.FsiOrderDtos
  11564. order.RxID = strconv.FormatInt(item.ID, 10)
  11565. order.Rxno = strconv.FormatInt(item.ID, 10)
  11566. order.LongDrordFlag = "0"
  11567. order.HilistType = "1"
  11568. order.ChrgType = "1"
  11569. order.DrordBhvr = "0"
  11570. order.HilistCode = subItem.HisProject.MedicalCode
  11571. order.HosplistName = subItem.HisProject.ProjectName
  11572. order.HilistLv = "1"
  11573. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11574. order.HosplistCode = subItem.HisProject.MedicalCode
  11575. order.HosplistName = subItem.HisProject.ProjectName
  11576. order.Cnt = subItem.Count
  11577. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11578. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11579. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11580. order.OwnpayAmt = ""
  11581. order.SelfpayAmt = ""
  11582. order.Spec = subItem.Unit
  11583. order.SpecUnt = subItem.Unit
  11584. order.DrordBegnDate = s_tm
  11585. order.DrordStopDate = ""
  11586. order.DrordDrCodg = doctor_info.DoctorNumber
  11587. order.DrordDeptName = department.Name
  11588. order.DrordDeptCodg = department.Number
  11589. order.DrordDrName = doctor_info.UserName
  11590. order.DrordDrProfttl = "234"
  11591. order.CurrDrordFlag = "1"
  11592. orders = append(orders, &order)
  11593. }
  11594. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11595. var order models.FsiOrderDtos
  11596. order.RxID = strconv.FormatInt(item.ID, 10)
  11597. order.Rxno = strconv.FormatInt(item.ID, 10)
  11598. order.LongDrordFlag = "0"
  11599. order.HilistType = "1"
  11600. order.ChrgType = "1"
  11601. order.DrordBhvr = "0"
  11602. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11603. order.HosplistName = subItem.GoodInfo.GoodName
  11604. order.HilistLv = "1"
  11605. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11606. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11607. order.HosplistName = subItem.GoodInfo.GoodName
  11608. order.Cnt = subItem.Count
  11609. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11610. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11611. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11612. order.OwnpayAmt = ""
  11613. order.SelfpayAmt = ""
  11614. order.Spec = subItem.GoodInfo.SpecificationName
  11615. order.SpecUnt = subItem.Unit
  11616. order.DrordBegnDate = s_tm
  11617. order.DrordStopDate = ""
  11618. order.DrordDrCodg = doctor_info.DoctorNumber
  11619. order.DrordDeptName = department.Name
  11620. order.DrordDeptCodg = department.Number
  11621. order.DrordDrName = doctor_info.UserName
  11622. order.DrordDrProfttl = "234"
  11623. order.CurrDrordFlag = "1"
  11624. orders = append(orders, &order)
  11625. }
  11626. }
  11627. }
  11628. //处方医嘱信息
  11629. fed.MatnStas = "0"
  11630. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11631. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11632. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11633. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11634. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11635. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11636. fed.SetlTotlnum = "1"
  11637. fed.Insutype = his.Insutype
  11638. fed.ReimFlag = "0"
  11639. fed.OutSetlFlag = "0"
  11640. var fopd []*models.FsiOperationDtosData
  11641. data := make(map[string]interface{})
  11642. data["fed"] = fed
  11643. data["fdd"] = fdds
  11644. data["fod"] = orders
  11645. data["pd"] = pd
  11646. data["pp"] = pp
  11647. data["fopd"] = fopd
  11648. data["trig_scen"] = trig_scen
  11649. client := &http.Client{}
  11650. bytesData, _ := json.Marshal(data)
  11651. var req *http.Request
  11652. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11653. if miConfig.MdtrtareaAdmvs == "320921" {
  11654. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11655. } else {
  11656. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11657. }
  11658. resp, _ := client.Do(req)
  11659. defer resp.Body.Close()
  11660. body, ioErr := ioutil.ReadAll(resp.Body)
  11661. if ioErr != nil {
  11662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11664. return res
  11665. }
  11666. var respJSON map[string]interface{}
  11667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11670. return res
  11671. }
  11672. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11673. result, _ := json.Marshal(respJSON)
  11674. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11675. utils.ErrorLog("解析失败:%v", err)
  11676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11677. return res
  11678. }
  11679. return res
  11680. } else {
  11681. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11682. saveLog(output, input, "3102", "事中")
  11683. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11684. utils.ErrorLog("解析失败:%v", err)
  11685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11686. return
  11687. }
  11688. return res
  11689. }
  11690. return res
  11691. }
  11692. func (c *HisApiController) Check() {
  11693. psn_no := c.GetString("psn_no")
  11694. in := c.GetString("in")
  11695. mt := c.GetString("mt")
  11696. baseParams := models.BaseParams{
  11697. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  11698. FixmedinsCode: "H15049901371",
  11699. InsuplcAdmdvs: "150499",
  11700. MdtrtareaAdmvs: "150499",
  11701. OrgName: "赤峰费森血液透析中心",
  11702. Doctor: "1111",
  11703. }
  11704. service.Gdyb2001(baseParams, psn_no, in, mt)
  11705. }
  11706. func (c *HisApiController) GetPsnNcdsInfo() {
  11707. admin_user_id, _ := c.GetInt64("admin_user_id")
  11708. patient_id, _ := c.GetInt64("patient_id")
  11709. //id, _ := c.GetInt64("id")
  11710. adminUser := c.GetAdminUserInfo()
  11711. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11712. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11713. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  11714. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11715. //psn_record, _ := service.GetP(id)
  11716. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11717. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  11718. //
  11719. //if psn_record.ID == 0 {
  11720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11721. // return
  11722. //}
  11723. var res Result5301
  11724. var res10265 Result5301For10265
  11725. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11726. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11727. var api string
  11728. if miConfig.MdtrtareaAdmvs == "320921" {
  11729. 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 +
  11730. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11731. } else {
  11732. 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 +
  11733. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11734. }
  11735. resp, requestErr := http.Get(api)
  11736. if requestErr != nil {
  11737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11738. return
  11739. }
  11740. body, ioErr := ioutil.ReadAll(resp.Body)
  11741. if ioErr != nil {
  11742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11744. return
  11745. }
  11746. var respJSON map[string]interface{}
  11747. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11750. return
  11751. }
  11752. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11753. result, _ := json.Marshal(respJSON)
  11754. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11755. utils.ErrorLog("解析失败:%v", err)
  11756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11757. return
  11758. }
  11759. res.ErrMsg = res10265.ErrMsg
  11760. res.Output = res10265.Output
  11761. res.InfRefmsgid = res10265.InfRefmsgid
  11762. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11763. res.Infcode = infocode
  11764. } else if miConfig.MdtrtareaAdmvs == "341203" {
  11765. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11766. var api string
  11767. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11768. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11769. resp, requestErr := http.Get(api)
  11770. if requestErr != nil {
  11771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11772. return
  11773. }
  11774. body, ioErr := ioutil.ReadAll(resp.Body)
  11775. if ioErr != nil {
  11776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11778. return
  11779. }
  11780. var respJSON map[string]interface{}
  11781. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11784. return
  11785. }
  11786. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11787. if status == "0" {
  11788. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11789. c.ServeSuccessJSON(map[string]interface{}{
  11790. "failed_code": -10,
  11791. "msg": err_msg,
  11792. })
  11793. return
  11794. }
  11795. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11796. result, _ := json.Marshal(respJSON)
  11797. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11798. utils.ErrorLog("解析失败:%v", err)
  11799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11800. return
  11801. }
  11802. } else if miConfig.MdtrtareaAdmvs == "340699" {
  11803. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11804. var api string
  11805. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11806. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11807. resp, requestErr := http.Get(api)
  11808. if requestErr != nil {
  11809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11810. return
  11811. }
  11812. body, ioErr := ioutil.ReadAll(resp.Body)
  11813. if ioErr != nil {
  11814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11816. return
  11817. }
  11818. var respJSON map[string]interface{}
  11819. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11822. return
  11823. }
  11824. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11825. if status == "0" {
  11826. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11827. c.ServeSuccessJSON(map[string]interface{}{
  11828. "failed_code": -10,
  11829. "msg": err_msg,
  11830. })
  11831. return
  11832. }
  11833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11834. result, _ := json.Marshal(respJSON)
  11835. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11836. utils.ErrorLog("解析失败:%v", err)
  11837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11838. return
  11839. }
  11840. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11841. p, _ := service.GetHisPatientById(patient_id)
  11842. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11843. var dat map[string]interface{}
  11844. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11845. fmt.Println(dat)
  11846. } else {
  11847. fmt.Println(err)
  11848. }
  11849. userJSONBytes, _ := json.Marshal(dat)
  11850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11851. utils.ErrorLog("解析失败:%v", err)
  11852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11853. return
  11854. }
  11855. } else if miConfig.MdtrtareaAdmvs == "361025" {
  11856. p, _ := service.GetHisPatientById(patient_id)
  11857. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11858. var dat map[string]interface{}
  11859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11860. fmt.Println(dat)
  11861. } else {
  11862. fmt.Println(err)
  11863. }
  11864. userJSONBytes, _ := json.Marshal(dat)
  11865. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11866. utils.ErrorLog("解析失败:%v", err)
  11867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11868. return
  11869. }
  11870. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11871. p, _ := service.GetHisPatientById(patient_id)
  11872. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11873. var dat map[string]interface{}
  11874. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11875. fmt.Println(dat)
  11876. } else {
  11877. fmt.Println(err)
  11878. }
  11879. userJSONBytes, _ := json.Marshal(dat)
  11880. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11881. utils.ErrorLog("解析失败:%v", err)
  11882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11883. return
  11884. }
  11885. } else if miConfig.MdtrtareaAdmvs == "420200" {
  11886. p, _ := service.GetHisPatientById(patient_id)
  11887. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  11888. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11889. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11890. resp, requestErr := http.Get(api)
  11891. if requestErr != nil {
  11892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11893. return
  11894. }
  11895. body, ioErr := ioutil.ReadAll(resp.Body)
  11896. if ioErr != nil {
  11897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11899. return
  11900. }
  11901. var respJSON map[string]interface{}
  11902. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11905. return
  11906. }
  11907. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11908. result, _ := json.Marshal(respJSON)
  11909. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11910. utils.ErrorLog("解析失败:%v", err)
  11911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11912. return
  11913. }
  11914. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11915. p, _ := service.GetHisPatientById(patient_id)
  11916. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  11917. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11918. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11919. resp, requestErr := http.Get(api)
  11920. if requestErr != nil {
  11921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11922. return
  11923. }
  11924. body, ioErr := ioutil.ReadAll(resp.Body)
  11925. if ioErr != nil {
  11926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11928. return
  11929. }
  11930. var respJSON map[string]interface{}
  11931. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11934. return
  11935. }
  11936. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11937. result, _ := json.Marshal(respJSON)
  11938. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11939. utils.ErrorLog("解析失败:%v", err)
  11940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11941. return
  11942. }
  11943. } else if miConfig.MdtrtareaAdmvs == "421182" {
  11944. p, _ := service.GetHisPatientById(patient_id)
  11945. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  11946. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11947. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11948. resp, requestErr := http.Get(api)
  11949. if requestErr != nil {
  11950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11951. return
  11952. }
  11953. body, ioErr := ioutil.ReadAll(resp.Body)
  11954. if ioErr != nil {
  11955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11957. return
  11958. }
  11959. var respJSON map[string]interface{}
  11960. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11963. return
  11964. }
  11965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11966. result, _ := json.Marshal(respJSON)
  11967. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11968. utils.ErrorLog("解析失败:%v", err)
  11969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11970. return
  11971. }
  11972. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11973. p, _ := service.GetHisPatientById(patient_id)
  11974. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  11975. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11976. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11977. resp, requestErr := http.Get(api)
  11978. if requestErr != nil {
  11979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11980. return
  11981. }
  11982. body, ioErr := ioutil.ReadAll(resp.Body)
  11983. if ioErr != nil {
  11984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11986. return
  11987. }
  11988. var respJSON map[string]interface{}
  11989. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11992. return
  11993. }
  11994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11995. result, _ := json.Marshal(respJSON)
  11996. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11997. utils.ErrorLog("解析失败:%v", err)
  11998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11999. return
  12000. }
  12001. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12002. p, _ := service.GetHisPatientById(patient_id)
  12003. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12004. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12005. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12006. resp, requestErr := http.Get(api)
  12007. if requestErr != nil {
  12008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12009. return
  12010. }
  12011. body, ioErr := ioutil.ReadAll(resp.Body)
  12012. if ioErr != nil {
  12013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12015. return
  12016. }
  12017. var respJSON map[string]interface{}
  12018. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12021. return
  12022. }
  12023. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12024. result, _ := json.Marshal(respJSON)
  12025. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12026. utils.ErrorLog("解析失败:%v", err)
  12027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12028. return
  12029. }
  12030. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12031. p, _ := service.GetHisPatientById(patient_id)
  12032. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12033. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12034. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12035. resp, requestErr := http.Get(api)
  12036. if requestErr != nil {
  12037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12038. return
  12039. }
  12040. body, ioErr := ioutil.ReadAll(resp.Body)
  12041. if ioErr != nil {
  12042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12044. return
  12045. }
  12046. var respJSON map[string]interface{}
  12047. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12050. return
  12051. }
  12052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12053. result, _ := json.Marshal(respJSON)
  12054. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12055. utils.ErrorLog("解析失败:%v", err)
  12056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12057. return
  12058. }
  12059. } else {
  12060. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12061. var dat map[string]interface{}
  12062. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12063. fmt.Println(dat)
  12064. } else {
  12065. fmt.Println(err)
  12066. }
  12067. userJSONBytes, _ := json.Marshal(dat)
  12068. if miConfig.Code == "H15049901371" {
  12069. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12070. utils.ErrorLog("解析失败:%v", err)
  12071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12072. return
  12073. }
  12074. res.InfRefmsgid = res10265.InfRefmsgid
  12075. res.Output = res10265.Output
  12076. res.ErrMsg = res10265.ErrMsg
  12077. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12078. res.Infcode = infocode
  12079. } else {
  12080. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12081. utils.ErrorLog("解析失败:%v", err)
  12082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12083. return
  12084. }
  12085. }
  12086. }
  12087. if res.Infcode == 0 {
  12088. c.ServeSuccessJSON(map[string]interface{}{
  12089. "result": res.Output.Result,
  12090. })
  12091. }
  12092. }
  12093. func (c *HisApiController) CheckInsutype() {
  12094. his_patient_id, _ := c.GetInt64("his_patient_id")
  12095. admin_user_id, _ := c.GetInt64("admin_user_id")
  12096. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12097. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12098. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12099. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12100. var dat map[string]interface{}
  12101. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12102. fmt.Println(dat)
  12103. } else {
  12104. fmt.Println(err)
  12105. }
  12106. userJSONBytes, _ := json.Marshal(dat)
  12107. var res Result90100
  12108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12109. utils.ErrorLog("解析失败:%v", err)
  12110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12111. return
  12112. }
  12113. if res.Infcode != 0 {
  12114. c.ServeSuccessJSON(map[string]interface{}{
  12115. "failed_code": -10,
  12116. "msg": res.ErrMsg,
  12117. })
  12118. return
  12119. } else {
  12120. fmt.Println(res)
  12121. }
  12122. }
  12123. func (c *HisApiController) CheckCardPWD() {
  12124. card_pwd := c.GetString("card_pwd")
  12125. his_patient_id, _ := c.GetInt64("his_patient_id")
  12126. admin_user_id, _ := c.GetInt64("admin_user_id")
  12127. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12128. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12129. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12130. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12131. bas := strings.Split(psn.CardInfo, "|")
  12132. basNumber := bas[2]
  12133. if psn.InsuplcAdmdvs[:4] == "4403" {
  12134. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12135. var dat map[string]interface{}
  12136. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12137. fmt.Println(dat)
  12138. } else {
  12139. fmt.Println(err)
  12140. }
  12141. userJSONBytes, _ := json.Marshal(dat)
  12142. var res Result90991
  12143. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12144. utils.ErrorLog("解析失败:%v", err)
  12145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12146. return
  12147. }
  12148. if res.Infcode != 0 {
  12149. c.ServeSuccessJSON(map[string]interface{}{
  12150. "failed_code": -10,
  12151. "msg": res.ErrMsg,
  12152. })
  12153. return
  12154. } else {
  12155. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12156. var msg string
  12157. switch res.Output.Result.CardStat {
  12158. case "00":
  12159. msg = "未激活"
  12160. break
  12161. case "10":
  12162. msg = "激活"
  12163. break
  12164. case "20":
  12165. msg = "窗口挂失"
  12166. break
  12167. case "21":
  12168. msg = "电话挂失"
  12169. break
  12170. case "22":
  12171. msg = "单位网上申报挂失"
  12172. break
  12173. case "23":
  12174. msg = "保健办挂失"
  12175. break
  12176. case "24":
  12177. msg = "个人网上挂失"
  12178. break
  12179. case "25":
  12180. msg = "网上服务大厅挂失"
  12181. break
  12182. case "30":
  12183. msg = "注销"
  12184. break
  12185. case "40":
  12186. msg = "回收"
  12187. break
  12188. case "99":
  12189. msg = "制卡中(无效卡)"
  12190. break
  12191. }
  12192. c.ServeSuccessJSON(map[string]interface{}{
  12193. "failed_code": -10,
  12194. "msg": msg,
  12195. })
  12196. return
  12197. } else {
  12198. c.ServeSuccessJSON(map[string]interface{}{
  12199. "msg": "校验成功",
  12200. })
  12201. return
  12202. }
  12203. }
  12204. } else {
  12205. c.ServeSuccessJSON(map[string]interface{}{
  12206. "msg": "校验成功",
  12207. })
  12208. return
  12209. }
  12210. }
  12211. func (c *HisApiController) CheckCardPWDTwo() {
  12212. //card_pwd := c.GetString("card_pwd")
  12213. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12214. admin_user_id, _ := c.GetInt64("admin_user_id")
  12215. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12216. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12217. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12218. var dat map[string]interface{}
  12219. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12220. fmt.Println(dat)
  12221. } else {
  12222. fmt.Println(err)
  12223. }
  12224. userJSONBytes, _ := json.Marshal(dat)
  12225. var res Result90991
  12226. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12227. utils.ErrorLog("解析失败:%v", err)
  12228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12229. return
  12230. }
  12231. if res.Infcode != 0 {
  12232. c.ServeSuccessJSON(map[string]interface{}{
  12233. "failed_code": -10,
  12234. "msg": res.ErrMsg,
  12235. })
  12236. return
  12237. } else {
  12238. if res.Output.Result.SscnoCheckStat == "0" {
  12239. var msg string
  12240. switch res.Output.Result.CardStat {
  12241. case "00":
  12242. msg = "未激活"
  12243. break
  12244. case "10":
  12245. msg = "激活"
  12246. break
  12247. case "20":
  12248. msg = "窗口挂失"
  12249. break
  12250. case "21":
  12251. msg = "电话挂失"
  12252. break
  12253. case "22":
  12254. msg = "单位网上申报挂失"
  12255. break
  12256. case "23":
  12257. msg = "保健办挂失"
  12258. break
  12259. case "24":
  12260. msg = "个人网上挂失"
  12261. break
  12262. case "25":
  12263. msg = "网上服务大厅挂失"
  12264. break
  12265. case "30":
  12266. msg = "注销"
  12267. break
  12268. case "40":
  12269. msg = "回收"
  12270. break
  12271. case "99":
  12272. msg = "制卡中(无效卡)"
  12273. break
  12274. }
  12275. c.ServeSuccessJSON(map[string]interface{}{
  12276. "failed_code": -10,
  12277. "msg": msg,
  12278. })
  12279. return
  12280. } else {
  12281. c.ServeSuccessJSON(map[string]interface{}{
  12282. "msg": "校验成功",
  12283. })
  12284. return
  12285. }
  12286. }
  12287. }
  12288. type ELeCertData struct {
  12289. Data struct {
  12290. Extra string `json:"extra"`
  12291. IDNo string `json:"idNo"`
  12292. IDType string `json:"idType"`
  12293. EcToken string `json:"ecToken"`
  12294. InsuOrg string `json:"insuOrg"`
  12295. UserName string `json:"userName"`
  12296. EcIndexNo string `json:"ecIndexNo"`
  12297. Gender string `json:"gender"`
  12298. Birthday string `json:"birthday"`
  12299. Nationality string `json:"nationality"`
  12300. Email string `json:"email"`
  12301. } `json:"OutData"`
  12302. }
  12303. func (c *HisApiController) ReadCard() {
  12304. id_card_type, _ := c.GetInt64("id_card_type")
  12305. admin_user_id, _ := c.GetInt64("admin_user_id")
  12306. certificates, _ := c.GetInt64("certificates")
  12307. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12308. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12309. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12310. switch id_card_type {
  12311. case 1:
  12312. if miConfig.MdtrtareaAdmvs == "421300" {
  12313. var res ResultTwo
  12314. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12315. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12316. "&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)
  12317. resp, requestErr := http.Get(api)
  12318. if requestErr != nil {
  12319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12320. return
  12321. }
  12322. body, ioErr := ioutil.ReadAll(resp.Body)
  12323. if ioErr != nil {
  12324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12326. return
  12327. }
  12328. var respJSON map[string]interface{}
  12329. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12332. return
  12333. }
  12334. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12335. result, _ := json.Marshal(respJSON)
  12336. fmt.Println("log")
  12337. fmt.Println(string(result))
  12338. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12339. utils.ErrorLog("解析失败:%v", err)
  12340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12341. return
  12342. }
  12343. if res.Infcode == 0 {
  12344. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12345. if err == gorm.ErrRecordNotFound {
  12346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12347. return
  12348. } else if err != nil {
  12349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12350. return
  12351. } else {
  12352. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12353. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12354. infoStr := string(Iinfos)
  12355. idetinfoStr := string(Idetinfos)
  12356. var rf []*ResultFive
  12357. json.Unmarshal([]byte(infoStr), &rf)
  12358. var insutypes []*ResultFive
  12359. var insutype string
  12360. var is390 int = 0
  12361. var is310 int = 0
  12362. for _, item := range rf {
  12363. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12364. insutypes = append(insutypes, item)
  12365. }
  12366. }
  12367. if len(insutypes) == 1 {
  12368. insutype = insutypes[0].Insutype
  12369. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12370. } else {
  12371. for _, i := range insutypes {
  12372. if i.Insutype == "390" {
  12373. is390 = 1
  12374. }
  12375. if i.Insutype == "310" {
  12376. is310 = 1
  12377. }
  12378. }
  12379. }
  12380. if is390 == 1 {
  12381. insutype = "390"
  12382. }
  12383. if is310 == 1 {
  12384. insutype = "310"
  12385. }
  12386. if len(insutypes) == 0 {
  12387. insutype = "390"
  12388. }
  12389. var insuplc_admdvs string
  12390. for _, item := range rf {
  12391. if item.Insutype == insutype {
  12392. insuplc_admdvs = item.InsuplcAdmdvs
  12393. }
  12394. }
  12395. if strings.Contains(insuplc_admdvs, "4213") {
  12396. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12397. }
  12398. psn := &models.HisPsn{
  12399. PsnNo: res.Output.Baseinfo.PsnNo,
  12400. PatientId: patient.ID,
  12401. Certno: res.Output.Baseinfo.Certno,
  12402. Gend: res.Output.Baseinfo.Gend,
  12403. Naty: res.Output.Baseinfo.Naty,
  12404. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12405. PsnName: res.Output.Baseinfo.PsnName,
  12406. Idetinfo: idetinfoStr,
  12407. Insuinfo: infoStr,
  12408. InsuplcAdmdvs: insuplc_admdvs,
  12409. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12410. }
  12411. service.CreateHisPsn(psn)
  12412. c.ServeSuccessJSON(map[string]interface{}{
  12413. "patient": patient,
  12414. "number": res.Output.Baseinfo.Certno,
  12415. })
  12416. }
  12417. } else {
  12418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12419. return
  12420. }
  12421. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12422. var res ResultTwo
  12423. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12424. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12425. "&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)
  12426. resp, requestErr := http.Get(api)
  12427. if requestErr != nil {
  12428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12429. return
  12430. }
  12431. body, ioErr := ioutil.ReadAll(resp.Body)
  12432. if ioErr != nil {
  12433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12435. return
  12436. }
  12437. var respJSON map[string]interface{}
  12438. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12441. return
  12442. }
  12443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12444. result, _ := json.Marshal(respJSON)
  12445. fmt.Println("log")
  12446. fmt.Println(string(result))
  12447. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12448. utils.ErrorLog("解析失败:%v", err)
  12449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12450. return
  12451. }
  12452. if res.Infcode == 0 {
  12453. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12454. if err == gorm.ErrRecordNotFound {
  12455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12456. return
  12457. } else if err != nil {
  12458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12459. return
  12460. } else {
  12461. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12462. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12463. infoStr := string(Iinfos)
  12464. idetinfoStr := string(Idetinfos)
  12465. psn := &models.HisPsn{
  12466. PsnNo: res.Output.Baseinfo.PsnNo,
  12467. PatientId: patient.ID,
  12468. Certno: res.Output.Baseinfo.Certno,
  12469. Gend: res.Output.Baseinfo.Gend,
  12470. Naty: res.Output.Baseinfo.Naty,
  12471. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12472. PsnName: res.Output.Baseinfo.PsnName,
  12473. Idetinfo: idetinfoStr,
  12474. Insuinfo: infoStr,
  12475. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12476. }
  12477. service.CreateHisPsn(psn)
  12478. var rf []*ResultFive
  12479. json.Unmarshal([]byte(infoStr), &rf)
  12480. var insutypes []*ResultFive
  12481. var insutype string
  12482. var is390 int = 0
  12483. var is310 int = 0
  12484. for _, item := range rf {
  12485. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12486. insutypes = append(insutypes, item)
  12487. }
  12488. }
  12489. if len(insutypes) == 1 {
  12490. insutype = insutypes[0].Insutype
  12491. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12492. } else {
  12493. for _, i := range insutypes {
  12494. if i.Insutype == "390" {
  12495. is390 = 1
  12496. }
  12497. if i.Insutype == "310" {
  12498. is310 = 1
  12499. }
  12500. }
  12501. }
  12502. if is390 == 1 {
  12503. insutype = "390"
  12504. }
  12505. if is310 == 1 {
  12506. insutype = "310"
  12507. }
  12508. if len(insutypes) == 0 {
  12509. insutype = "310"
  12510. }
  12511. c.ServeSuccessJSON(map[string]interface{}{
  12512. "patient": patient,
  12513. "number": res.Output.Baseinfo.Certno,
  12514. "insutype": insutype,
  12515. })
  12516. }
  12517. } else {
  12518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12519. return
  12520. }
  12521. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12522. var res ResultTwo
  12523. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12524. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12525. "&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)
  12526. resp, requestErr := http.Get(api)
  12527. if requestErr != nil {
  12528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12529. return
  12530. }
  12531. body, ioErr := ioutil.ReadAll(resp.Body)
  12532. if ioErr != nil {
  12533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12535. return
  12536. }
  12537. var respJSON map[string]interface{}
  12538. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12541. return
  12542. }
  12543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12544. result, _ := json.Marshal(respJSON)
  12545. fmt.Println("log")
  12546. fmt.Println(string(result))
  12547. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12548. utils.ErrorLog("解析失败:%v", err)
  12549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12550. return
  12551. }
  12552. if res.Infcode == 0 {
  12553. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12554. if err == gorm.ErrRecordNotFound {
  12555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12556. return
  12557. } else if err != nil {
  12558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12559. return
  12560. } else {
  12561. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12562. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12563. infoStr := string(Iinfos)
  12564. idetinfoStr := string(Idetinfos)
  12565. var rf []*ResultFive
  12566. json.Unmarshal([]byte(infoStr), &rf)
  12567. var insutypes []*ResultFive
  12568. var insutype string
  12569. var is390 int = 0
  12570. var is310 int = 0
  12571. for _, item := range rf {
  12572. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12573. insutypes = append(insutypes, item)
  12574. }
  12575. }
  12576. if len(insutypes) == 1 {
  12577. insutype = insutypes[0].Insutype
  12578. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12579. } else {
  12580. for _, i := range insutypes {
  12581. if i.Insutype == "390" {
  12582. is390 = 1
  12583. }
  12584. if i.Insutype == "310" {
  12585. is310 = 1
  12586. }
  12587. }
  12588. }
  12589. if is390 == 1 {
  12590. insutype = "390"
  12591. }
  12592. if is310 == 1 {
  12593. insutype = "310"
  12594. }
  12595. if len(insutypes) == 0 {
  12596. insutype = "390"
  12597. }
  12598. var insuplc_admdvs string
  12599. for _, item := range rf {
  12600. if item.Insutype == insutype {
  12601. insuplc_admdvs = item.InsuplcAdmdvs
  12602. }
  12603. }
  12604. psn := &models.HisPsn{
  12605. PsnNo: res.Output.Baseinfo.PsnNo,
  12606. PatientId: patient.ID,
  12607. Certno: res.Output.Baseinfo.Certno,
  12608. Gend: res.Output.Baseinfo.Gend,
  12609. Naty: res.Output.Baseinfo.Naty,
  12610. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12611. PsnName: res.Output.Baseinfo.PsnName,
  12612. Idetinfo: idetinfoStr,
  12613. Insuinfo: infoStr,
  12614. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12615. InsuplcAdmdvs: insuplc_admdvs,
  12616. }
  12617. service.CreateHisPsn(psn)
  12618. for _, item := range rf {
  12619. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12620. insutypes = append(insutypes, item)
  12621. }
  12622. }
  12623. if len(insutypes) == 1 {
  12624. insutype = insutypes[0].Insutype
  12625. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12626. } else {
  12627. for _, i := range insutypes {
  12628. if i.Insutype == "390" {
  12629. is390 = 1
  12630. }
  12631. if i.Insutype == "310" {
  12632. is310 = 1
  12633. }
  12634. }
  12635. }
  12636. if is390 == 1 {
  12637. insutype = "390"
  12638. }
  12639. if is310 == 1 {
  12640. insutype = "310"
  12641. }
  12642. if len(insutypes) == 0 {
  12643. insutype = "310"
  12644. }
  12645. c.ServeSuccessJSON(map[string]interface{}{
  12646. "patient": patient,
  12647. "number": res.Output.Baseinfo.Certno,
  12648. "insutype": insutype,
  12649. })
  12650. }
  12651. } else {
  12652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12653. return
  12654. }
  12655. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12656. var res ResultTwo
  12657. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  12658. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12659. "&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)
  12660. resp, requestErr := http.Get(api)
  12661. if requestErr != nil {
  12662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12663. return
  12664. }
  12665. body, ioErr := ioutil.ReadAll(resp.Body)
  12666. if ioErr != nil {
  12667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12669. return
  12670. }
  12671. var respJSON map[string]interface{}
  12672. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12675. return
  12676. }
  12677. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12678. result, _ := json.Marshal(respJSON)
  12679. fmt.Println("log")
  12680. fmt.Println(string(result))
  12681. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12682. utils.ErrorLog("解析失败:%v", err)
  12683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12684. return
  12685. }
  12686. if res.Infcode == 0 {
  12687. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12688. if err == gorm.ErrRecordNotFound {
  12689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12690. return
  12691. } else if err != nil {
  12692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12693. return
  12694. } else {
  12695. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12696. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12697. infoStr := string(Iinfos)
  12698. idetinfoStr := string(Idetinfos)
  12699. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12700. psn := &models.HisPsn{
  12701. PsnNo: res.Output.Baseinfo.PsnNo,
  12702. PatientId: patient.ID,
  12703. Certno: res.Output.Baseinfo.Certno,
  12704. Brdy: b,
  12705. Age: float64(age),
  12706. Gend: res.Output.Baseinfo.Gend,
  12707. Naty: res.Output.Baseinfo.Naty,
  12708. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12709. PsnName: res.Output.Baseinfo.PsnName,
  12710. Idetinfo: idetinfoStr,
  12711. Insuinfo: infoStr,
  12712. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12713. }
  12714. service.CreateHisPsn(psn)
  12715. var rf []*ResultFive
  12716. json.Unmarshal([]byte(infoStr), &rf)
  12717. var insutypes []*ResultFive
  12718. var insutype string
  12719. var is390 int = 0
  12720. var is310 int = 0
  12721. for _, item := range rf {
  12722. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12723. insutypes = append(insutypes, item)
  12724. }
  12725. }
  12726. if len(insutypes) == 1 {
  12727. insutype = insutypes[0].Insutype
  12728. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12729. } else {
  12730. for _, i := range insutypes {
  12731. if i.Insutype == "390" {
  12732. is390 = 1
  12733. }
  12734. if i.Insutype == "310" {
  12735. is310 = 1
  12736. }
  12737. }
  12738. }
  12739. if is390 == 1 {
  12740. insutype = "390"
  12741. }
  12742. if is310 == 1 {
  12743. insutype = "310"
  12744. }
  12745. if len(insutypes) == 0 {
  12746. insutype = "310"
  12747. }
  12748. c.ServeSuccessJSON(map[string]interface{}{
  12749. "patient": patient,
  12750. "number": res.Output.Baseinfo.Certno,
  12751. "insutype": insutype,
  12752. })
  12753. }
  12754. } else {
  12755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12756. return
  12757. }
  12758. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12759. var api string
  12760. if miConfig.MdtrtareaAdmvs == "320921" {
  12761. 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 +
  12762. "&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
  12763. fmt.Println(api)
  12764. } else {
  12765. 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 +
  12766. "&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)
  12767. }
  12768. resp, requestErr := http.Get(api)
  12769. if requestErr != nil {
  12770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12771. return
  12772. }
  12773. body, ioErr := ioutil.ReadAll(resp.Body)
  12774. if ioErr != nil {
  12775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12777. return
  12778. }
  12779. var respJSON map[string]interface{}
  12780. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12783. return
  12784. }
  12785. var status string
  12786. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12787. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12788. //console.log()
  12789. fmt.Println("type===")
  12790. fmt.Println(card_type)
  12791. var token string
  12792. var res ResultTwo //1101结果
  12793. var res10265 ResultTwo10265 //1101结果
  12794. var card_info string //卡信息
  12795. var busi_card_info string
  12796. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12797. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12798. if status == "0" { //读卡成功
  12799. if card_type == "1" {
  12800. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12801. result, _ := json.Marshal(respJSON)
  12802. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12803. utils.ErrorLog("解析失败:%v", err)
  12804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12805. return
  12806. }
  12807. res.ErrMsg = res10265.ErrMsg
  12808. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12809. res.Infcode = infocode
  12810. res.Output = res10265.Output
  12811. res.InfRefmsgid = res10265.InfRefmsgid
  12812. } else {
  12813. //var card_info string //卡信息
  12814. //var busi_card_info string
  12815. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12816. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12817. //fmt.Println(card_info)
  12818. //fmt.Println(busi_card_info)
  12819. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12820. result, _ := json.Marshal(respJSON)
  12821. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12822. utils.ErrorLog("解析失败:%v", err)
  12823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12824. return
  12825. }
  12826. res.ErrMsg = res10265.ErrMsg
  12827. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12828. res.Infcode = infocode
  12829. res.Output = res10265.Output
  12830. res.InfRefmsgid = res10265.InfRefmsgid
  12831. }
  12832. if res.Infcode == 0 {
  12833. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12834. if err == gorm.ErrRecordNotFound {
  12835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12836. return
  12837. } else if err != nil {
  12838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12839. return
  12840. } else {
  12841. if card_type == "1" {
  12842. bas := strings.Split(card_info, "|")
  12843. basNumber := bas[2]
  12844. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12845. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12846. infoStr := string(Iinfos)
  12847. idetinfoStr := string(Idetinfos)
  12848. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12849. psn := &models.HisPsn{
  12850. PsnNo: res.Output.Baseinfo.PsnNo,
  12851. PatientId: patient.ID,
  12852. Certno: res.Output.Baseinfo.Certno,
  12853. Brdy: b,
  12854. Age: float64(age),
  12855. Gend: res.Output.Baseinfo.Gend,
  12856. Naty: res.Output.Baseinfo.Naty,
  12857. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12858. PsnName: res.Output.Baseinfo.PsnName,
  12859. Idetinfo: idetinfoStr,
  12860. Insuinfo: infoStr,
  12861. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12862. CardInfo: card_info,
  12863. VerifyNumber: busi_card_info,
  12864. }
  12865. service.CreateHisPsn(psn)
  12866. var rf []*ResultFive
  12867. json.Unmarshal([]byte(infoStr), &rf)
  12868. var insutypes []*ResultFive
  12869. var insutype string
  12870. var is390 int = 0
  12871. var is310 int = 0
  12872. for _, item := range rf {
  12873. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12874. insutypes = append(insutypes, item)
  12875. }
  12876. }
  12877. if len(insutypes) == 1 {
  12878. insutype = insutypes[0].Insutype
  12879. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12880. } else {
  12881. for _, i := range insutypes {
  12882. if i.Insutype == "390" {
  12883. is390 = 1
  12884. }
  12885. if i.Insutype == "310" {
  12886. is310 = 1
  12887. }
  12888. }
  12889. }
  12890. if is390 == 1 {
  12891. insutype = "390"
  12892. }
  12893. if is310 == 1 {
  12894. insutype = "310"
  12895. }
  12896. if len(insutypes) == 0 {
  12897. insutype = "310"
  12898. }
  12899. c.ServeSuccessJSON(map[string]interface{}{
  12900. "patient": patient,
  12901. "number": basNumber,
  12902. "insutype": insutype,
  12903. })
  12904. } else {
  12905. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12906. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12907. infoStr := string(Iinfos)
  12908. idetinfoStr := string(Idetinfos)
  12909. psn := &models.HisPsn{
  12910. PsnNo: res.Output.Baseinfo.PsnNo,
  12911. PatientId: patient.ID,
  12912. Certno: res.Output.Baseinfo.Certno,
  12913. Gend: res.Output.Baseinfo.Gend,
  12914. Naty: res.Output.Baseinfo.Naty,
  12915. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12916. PsnName: res.Output.Baseinfo.PsnName,
  12917. Idetinfo: idetinfoStr,
  12918. Insuinfo: infoStr,
  12919. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12920. CardInfo: card_info,
  12921. VerifyNumber: token,
  12922. }
  12923. service.CreateHisPsn(psn)
  12924. c.ServeSuccessJSON(map[string]interface{}{
  12925. "patient": patient,
  12926. "number": token,
  12927. })
  12928. }
  12929. }
  12930. } else {
  12931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12932. return
  12933. }
  12934. } else { //读卡失败
  12935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12936. return
  12937. }
  12938. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12939. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  12940. cardnum = DeleteExtraSpaceTwo(cardnum)
  12941. cardCode = DeleteExtraSpaceTwo(cardCode)
  12942. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  12943. name = DeleteExtraSpaceTwo(name)
  12944. errmsg = DeleteExtraSpaceTwo(errmsg)
  12945. cardnum = Remove0000(cardnum)
  12946. cardCode = Remove0000(cardCode)
  12947. id_card_no = Remove0000(id_card_no)
  12948. name = Remove0000(name)
  12949. errmsg = Remove0000(errmsg)
  12950. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  12951. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  12952. //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)
  12953. //fmt.Println(result2)
  12954. //fmt.Println(requestLog2)
  12955. //fmt.Println(errMsgLog2)
  12956. 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)
  12957. saveLog(result, requestLog, "1101", "获取人员信息")
  12958. fmt.Println(errMsgLog)
  12959. if len(errMsgLog) > 0 {
  12960. } else {
  12961. var dat map[string]interface{}
  12962. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12963. fmt.Println(dat)
  12964. } else {
  12965. fmt.Println(err)
  12966. }
  12967. userJSONBytes, _ := json.Marshal(dat)
  12968. var res ResultTwo
  12969. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12970. utils.ErrorLog("解析失败:%v", err)
  12971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12972. return
  12973. }
  12974. res.ErrMsg = errMsgLog
  12975. if res.Infcode == 0 {
  12976. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12977. if err == gorm.ErrRecordNotFound {
  12978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12979. return
  12980. } else if err != nil {
  12981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12982. return
  12983. } else {
  12984. fmt.Println(res)
  12985. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12986. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12987. infoStr := string(Iinfos)
  12988. idetinfoStr := string(Idetinfos)
  12989. var rf []*ResultFive
  12990. json.Unmarshal([]byte(infoStr), &rf)
  12991. var insutypes []*ResultFive
  12992. var insutype string
  12993. var is390 int = 0
  12994. var is310 int = 0
  12995. for _, item := range rf {
  12996. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12997. insutypes = append(insutypes, item)
  12998. }
  12999. }
  13000. if len(insutypes) == 1 {
  13001. insutype = insutypes[0].Insutype
  13002. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13003. } else {
  13004. for _, i := range insutypes {
  13005. if i.Insutype == "390" {
  13006. is390 = 1
  13007. }
  13008. if i.Insutype == "310" {
  13009. is310 = 1
  13010. }
  13011. }
  13012. }
  13013. if is390 == 1 {
  13014. insutype = "390"
  13015. }
  13016. if is310 == 1 {
  13017. insutype = "310"
  13018. }
  13019. if len(insutypes) == 0 {
  13020. insutype = "390"
  13021. }
  13022. var insuplc_admdvs string
  13023. for _, item := range rf {
  13024. if item.Insutype == insutype {
  13025. insuplc_admdvs = item.InsuplcAdmdvs
  13026. }
  13027. }
  13028. psn := &models.HisPsn{
  13029. PsnNo: res.Output.Baseinfo.PsnNo,
  13030. PatientId: patient.ID,
  13031. Certno: res.Output.Baseinfo.Certno,
  13032. Gend: res.Output.Baseinfo.Gend,
  13033. Naty: res.Output.Baseinfo.Naty,
  13034. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13035. PsnName: res.Output.Baseinfo.PsnName,
  13036. Idetinfo: idetinfoStr,
  13037. Insuinfo: infoStr,
  13038. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13039. CardInfo: basStr,
  13040. VerifyNumber: "",
  13041. InsuplcAdmdvs: insuplc_admdvs,
  13042. }
  13043. service.CreateHisPsn(psn)
  13044. c.ServeSuccessJSON(map[string]interface{}{
  13045. "patient": patient,
  13046. "number": cardnum,
  13047. "insutype": insutype,
  13048. })
  13049. }
  13050. } else {
  13051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13052. return
  13053. }
  13054. }
  13055. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13056. fmt.Println(initFlag)
  13057. fmt.Println("initFlag")
  13058. if initFlag == 0 {
  13059. c.TestGetJiangXiBasBaseInit()
  13060. }
  13061. basStr := c.GetBasBaseInfo()
  13062. if len(basStr) == 0 {
  13063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13064. return
  13065. }
  13066. fmt.Println(basStr)
  13067. bas := strings.Split(basStr, "|")
  13068. basNumber := bas[1]
  13069. fmt.Println(basNumber)
  13070. card_sn := bas[3]
  13071. fmt.Println(card_sn)
  13072. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13073. 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, patient.Name)
  13074. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13075. var dat map[string]interface{}
  13076. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13077. fmt.Println(dat)
  13078. } else {
  13079. fmt.Println(err)
  13080. }
  13081. userJSONBytes, _ := json.Marshal(dat)
  13082. var res ResultTwo
  13083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13084. utils.ErrorLog("解析失败:%v", err)
  13085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13086. return
  13087. }
  13088. if res.Infcode == 0 {
  13089. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13090. if err == gorm.ErrRecordNotFound {
  13091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13092. return
  13093. } else if err != nil {
  13094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13095. return
  13096. } else {
  13097. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13098. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13099. infoStr := string(Iinfos)
  13100. idetinfoStr := string(Idetinfos)
  13101. var rf []*ResultFive
  13102. json.Unmarshal([]byte(infoStr), &rf)
  13103. var insutypes []*ResultFive
  13104. var insutype string
  13105. var is390 int = 0
  13106. var is310 int = 0
  13107. var insuplc_admdvs string
  13108. for _, item := range rf {
  13109. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13110. insutypes = append(insutypes, item)
  13111. }
  13112. }
  13113. if len(insutypes) == 1 {
  13114. insutype = insutypes[0].Insutype
  13115. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13116. } else {
  13117. for _, i := range insutypes {
  13118. if i.Insutype == "390" {
  13119. is390 = 1
  13120. }
  13121. if i.Insutype == "310" {
  13122. is310 = 1
  13123. }
  13124. }
  13125. }
  13126. if is390 == 1 {
  13127. insutype = "390"
  13128. }
  13129. if is310 == 1 {
  13130. insutype = "310"
  13131. }
  13132. if len(insutypes) == 0 {
  13133. insutype = "310"
  13134. }
  13135. for _, item := range rf {
  13136. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13137. insuplc_admdvs = item.InsuplcAdmdvs
  13138. }
  13139. }
  13140. psn := &models.HisPsn{
  13141. PsnNo: res.Output.Baseinfo.PsnNo,
  13142. PatientId: patient.ID,
  13143. Certno: res.Output.Baseinfo.Certno,
  13144. Gend: res.Output.Baseinfo.Gend,
  13145. Naty: res.Output.Baseinfo.Naty,
  13146. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13147. PsnName: res.Output.Baseinfo.PsnName,
  13148. Idetinfo: idetinfoStr,
  13149. Insuinfo: infoStr,
  13150. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13151. CardInfo: basStr,
  13152. InsuplcAdmdvs: insuplc_admdvs,
  13153. VerifyNumber: "",
  13154. }
  13155. service.CreateHisPsn(psn)
  13156. c.ServeSuccessJSON(map[string]interface{}{
  13157. "patient": patient,
  13158. "number": basNumber,
  13159. "insutype": insutype,
  13160. })
  13161. }
  13162. } else {
  13163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13164. return
  13165. }
  13166. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13167. basStr := c.GetBasBaseInfo1111()
  13168. fmt.Println(basStr)
  13169. if len(basStr) == 0 {
  13170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13171. return
  13172. }
  13173. fmt.Println(basStr)
  13174. bas := strings.Split(basStr, "|")
  13175. basNumber := bas[1]
  13176. fmt.Println(basNumber)
  13177. card_sn := ""
  13178. fmt.Println(card_sn)
  13179. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13180. 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, patient.Name)
  13181. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13182. var dat map[string]interface{}
  13183. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13184. fmt.Println(dat)
  13185. } else {
  13186. fmt.Println(err)
  13187. }
  13188. userJSONBytes, _ := json.Marshal(dat)
  13189. var res ResultTwo
  13190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13191. utils.ErrorLog("解析失败:%v", err)
  13192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13193. return
  13194. }
  13195. if res.Infcode == 0 {
  13196. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13197. if err == gorm.ErrRecordNotFound {
  13198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13199. return
  13200. } else if err != nil {
  13201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13202. return
  13203. } else {
  13204. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13205. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13206. infoStr := string(Iinfos)
  13207. idetinfoStr := string(Idetinfos)
  13208. var rf []*ResultFive
  13209. json.Unmarshal([]byte(infoStr), &rf)
  13210. var insutypes []*ResultFive
  13211. var insutype string
  13212. var is390 int = 0
  13213. var is310 int = 0
  13214. var insuplc_admdvs string
  13215. for _, item := range rf {
  13216. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13217. insutypes = append(insutypes, item)
  13218. }
  13219. }
  13220. if len(insutypes) == 1 {
  13221. insutype = insutypes[0].Insutype
  13222. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13223. } else {
  13224. for _, i := range insutypes {
  13225. if i.Insutype == "390" {
  13226. is390 = 1
  13227. }
  13228. if i.Insutype == "310" {
  13229. is310 = 1
  13230. }
  13231. }
  13232. }
  13233. if is390 == 1 {
  13234. insutype = "390"
  13235. }
  13236. if is310 == 1 {
  13237. insutype = "310"
  13238. }
  13239. if len(insutypes) == 0 {
  13240. insutype = "310"
  13241. }
  13242. for _, item := range rf {
  13243. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13244. insuplc_admdvs = item.InsuplcAdmdvs
  13245. }
  13246. }
  13247. psn := &models.HisPsn{
  13248. PsnNo: res.Output.Baseinfo.PsnNo,
  13249. PatientId: patient.ID,
  13250. Certno: res.Output.Baseinfo.Certno,
  13251. Gend: res.Output.Baseinfo.Gend,
  13252. Naty: res.Output.Baseinfo.Naty,
  13253. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13254. PsnName: res.Output.Baseinfo.PsnName,
  13255. Idetinfo: idetinfoStr,
  13256. Insuinfo: infoStr,
  13257. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13258. CardInfo: basStr,
  13259. InsuplcAdmdvs: insuplc_admdvs,
  13260. VerifyNumber: "",
  13261. }
  13262. service.CreateHisPsn(psn)
  13263. c.ServeSuccessJSON(map[string]interface{}{
  13264. "patient": patient,
  13265. "number": basNumber,
  13266. "insutype": insutype,
  13267. })
  13268. }
  13269. } else {
  13270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13271. return
  13272. }
  13273. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13274. fmt.Println(initFlag)
  13275. fmt.Println("initFlag")
  13276. if initFlag == 0 {
  13277. c.TestGetHnBasBaseInit()
  13278. }
  13279. basStr := c.GetBasBaseInfo()
  13280. if len(basStr) == 0 {
  13281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13282. return
  13283. }
  13284. fmt.Println(basStr)
  13285. bas := strings.Split(basStr, "|")
  13286. basNumber := bas[1]
  13287. fmt.Println(basNumber)
  13288. card_sn := bas[3]
  13289. card_no := bas[2]
  13290. fmt.Println(card_sn)
  13291. name := bas[4]
  13292. name = ConvertToString(name, "gbk", "utf-8")
  13293. 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)
  13294. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13295. var dat map[string]interface{}
  13296. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13297. fmt.Println(dat)
  13298. } else {
  13299. fmt.Println(err)
  13300. }
  13301. userJSONBytes, _ := json.Marshal(dat)
  13302. var res ResultTwo
  13303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13304. utils.ErrorLog("解析失败:%v", err)
  13305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13306. return
  13307. }
  13308. if res.Infcode == 0 {
  13309. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13310. if err == gorm.ErrRecordNotFound {
  13311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13312. return
  13313. } else if err != nil {
  13314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13315. return
  13316. } else {
  13317. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13318. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13319. infoStr := string(Iinfos)
  13320. idetinfoStr := string(Idetinfos)
  13321. psn := &models.HisPsn{
  13322. PsnNo: res.Output.Baseinfo.PsnNo,
  13323. PatientId: patient.ID,
  13324. Certno: res.Output.Baseinfo.Certno,
  13325. Gend: res.Output.Baseinfo.Gend,
  13326. Naty: res.Output.Baseinfo.Naty,
  13327. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13328. PsnName: res.Output.Baseinfo.PsnName,
  13329. Idetinfo: idetinfoStr,
  13330. Insuinfo: infoStr,
  13331. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13332. CardInfo: basStr,
  13333. VerifyNumber: "",
  13334. }
  13335. service.CreateHisPsn(psn)
  13336. var rf []*ResultFive
  13337. json.Unmarshal([]byte(infoStr), &rf)
  13338. var insutypes []*ResultFive
  13339. var insutype string
  13340. var is390 int = 0
  13341. var is310 int = 0
  13342. for _, item := range rf {
  13343. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13344. insutypes = append(insutypes, item)
  13345. }
  13346. }
  13347. if len(insutypes) == 1 {
  13348. insutype = insutypes[0].Insutype
  13349. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13350. } else {
  13351. for _, i := range insutypes {
  13352. if i.Insutype == "390" {
  13353. is390 = 1
  13354. }
  13355. if i.Insutype == "310" {
  13356. is310 = 1
  13357. }
  13358. }
  13359. }
  13360. if is390 == 1 {
  13361. insutype = "390"
  13362. }
  13363. if is310 == 1 {
  13364. insutype = "310"
  13365. }
  13366. if len(insutypes) == 0 {
  13367. insutype = "310"
  13368. }
  13369. c.ServeSuccessJSON(map[string]interface{}{
  13370. "patient": patient,
  13371. "number": basNumber,
  13372. "insutype": insutype,
  13373. })
  13374. }
  13375. } else {
  13376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13377. return
  13378. }
  13379. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13380. var api string
  13381. 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 +
  13382. "&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
  13383. fmt.Println(api)
  13384. resp, requestErr := http.Get(api)
  13385. if requestErr != nil {
  13386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13387. return
  13388. }
  13389. body, ioErr := ioutil.ReadAll(resp.Body)
  13390. if ioErr != nil {
  13391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13393. return
  13394. }
  13395. var respJSON map[string]interface{}
  13396. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13399. return
  13400. }
  13401. var res ResultTwo //1101结果
  13402. var res10265 ResultTwo10265 //1101结果
  13403. var card_info string //卡信息
  13404. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13405. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13406. result, _ := json.Marshal(respJSON)
  13407. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13408. utils.ErrorLog("解析失败:%v", err)
  13409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13410. return
  13411. }
  13412. res.ErrMsg = res10265.ErrMsg
  13413. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13414. res.Infcode = infocode
  13415. res.Output = res10265.Output
  13416. res.InfRefmsgid = res10265.InfRefmsgid
  13417. if res.Infcode == 0 {
  13418. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13419. if err == gorm.ErrRecordNotFound {
  13420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13421. return
  13422. } else if err != nil {
  13423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13424. return
  13425. } else {
  13426. bas := strings.Split(card_info, "|")
  13427. basNumber := bas[2]
  13428. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13429. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13430. infoStr := string(Iinfos)
  13431. idetinfoStr := string(Idetinfos)
  13432. psn := &models.HisPsn{
  13433. PsnNo: res.Output.Baseinfo.PsnNo,
  13434. PatientId: patient.ID,
  13435. Certno: res.Output.Baseinfo.Certno,
  13436. Gend: res.Output.Baseinfo.Gend,
  13437. Naty: res.Output.Baseinfo.Naty,
  13438. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13439. PsnName: res.Output.Baseinfo.PsnName,
  13440. Idetinfo: idetinfoStr,
  13441. Insuinfo: infoStr,
  13442. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13443. CardInfo: card_info,
  13444. VerifyNumber: token,
  13445. }
  13446. service.CreateHisPsn(psn)
  13447. var rf []*ResultFive
  13448. json.Unmarshal([]byte(infoStr), &rf)
  13449. var insutypes []*ResultFive
  13450. var insutype string
  13451. var is390 int = 0
  13452. var is310 int = 0
  13453. for _, item := range rf {
  13454. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13455. insutypes = append(insutypes, item)
  13456. }
  13457. }
  13458. if len(insutypes) == 1 {
  13459. insutype = insutypes[0].Insutype
  13460. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13461. } else {
  13462. for _, i := range insutypes {
  13463. if i.Insutype == "390" {
  13464. is390 = 1
  13465. }
  13466. if i.Insutype == "310" {
  13467. is310 = 1
  13468. }
  13469. }
  13470. }
  13471. if is390 == 1 {
  13472. insutype = "390"
  13473. }
  13474. if is310 == 1 {
  13475. insutype = "310"
  13476. }
  13477. if len(insutypes) == 0 {
  13478. insutype = "310"
  13479. }
  13480. c.ServeSuccessJSON(map[string]interface{}{
  13481. "patient": patient,
  13482. "number": basNumber,
  13483. "insutype": insutype,
  13484. })
  13485. }
  13486. } else {
  13487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13488. return
  13489. }
  13490. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13491. res := c.GetoleInfo()
  13492. if res.Infcode == 0 {
  13493. var result string
  13494. if res.Output.MdtrtCertType == "01" {
  13495. 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)
  13496. } else if res.Output.MdtrtCertType == "02" {
  13497. 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)
  13498. } else if res.Output.MdtrtCertType == "03" {
  13499. 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)
  13500. }
  13501. var dat map[string]interface{}
  13502. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13503. fmt.Println(dat)
  13504. } else {
  13505. fmt.Println(err)
  13506. }
  13507. userJSONBytes, _ := json.Marshal(dat)
  13508. var res2 ResultTwo
  13509. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13510. utils.ErrorLog("解析失败:%v", err)
  13511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13512. return
  13513. }
  13514. if res2.Infcode == 0 {
  13515. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13516. if err == gorm.ErrRecordNotFound {
  13517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13518. return
  13519. } else if err != nil {
  13520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13521. return
  13522. } else {
  13523. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13524. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13525. infoStr := string(Iinfos)
  13526. idetinfoStr := string(Idetinfos)
  13527. var rf []*ResultFive
  13528. json.Unmarshal([]byte(infoStr), &rf)
  13529. var insutypes []*ResultFive
  13530. var insutype string
  13531. var is390 int = 0
  13532. var is310 int = 0
  13533. //var insuplc_admdvs string
  13534. for _, item := range rf {
  13535. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13536. insutypes = append(insutypes, item)
  13537. }
  13538. }
  13539. if len(insutypes) == 1 {
  13540. insutype = insutypes[0].Insutype
  13541. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13542. } else {
  13543. for _, i := range insutypes {
  13544. if i.Insutype == "390" {
  13545. is390 = 1
  13546. }
  13547. if i.Insutype == "310" {
  13548. is310 = 1
  13549. }
  13550. }
  13551. }
  13552. if is390 == 1 {
  13553. insutype = "390"
  13554. }
  13555. if is310 == 1 {
  13556. insutype = "310"
  13557. }
  13558. if len(insutypes) == 0 {
  13559. insutype = "310"
  13560. }
  13561. psn := &models.HisPsn{
  13562. PsnNo: res2.Output.Baseinfo.PsnNo,
  13563. PatientId: patient.ID,
  13564. Certno: res2.Output.Baseinfo.Certno,
  13565. Gend: res2.Output.Baseinfo.Gend,
  13566. Naty: res2.Output.Baseinfo.Naty,
  13567. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13568. PsnName: res2.Output.Baseinfo.PsnName,
  13569. Idetinfo: idetinfoStr,
  13570. Insuinfo: infoStr,
  13571. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13572. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13573. VerifyNumber: res.Output.EcToken,
  13574. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13575. }
  13576. if res.Output.MdtrtCertType == "01" {
  13577. psn.VerifyNumber = res.Output.EcToken
  13578. //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)
  13579. } else if res.Output.MdtrtCertType == "02" {
  13580. psn.VerifyNumber = res.Output.MdtrtCertNo
  13581. //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)
  13582. } else if res.Output.MdtrtCertType == "03" {
  13583. psn.VerifyNumber = res.Output.MdtrtCertNo
  13584. //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)
  13585. }
  13586. var balc float64
  13587. for _, item := range rf {
  13588. if item.Insutype == insutype {
  13589. balc = item.Balc
  13590. }
  13591. }
  13592. service.CreateHisPsn(psn)
  13593. c.ServeSuccessJSON(map[string]interface{}{
  13594. "patient": patient,
  13595. "number": res.Output.CardNo,
  13596. "insutype": insutype,
  13597. "blac": balc,
  13598. "desc": idetinfoStr,
  13599. })
  13600. }
  13601. } else {
  13602. c.ServeSuccessJSON(map[string]interface{}{
  13603. "failed_code": -10,
  13604. "msg": res2.ErrMsg,
  13605. })
  13606. }
  13607. } else {
  13608. c.ServeSuccessJSON(map[string]interface{}{
  13609. "failed_code": -10,
  13610. "msg": res.ErrMsg,
  13611. })
  13612. }
  13613. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13614. var api string
  13615. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13616. "&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
  13617. fmt.Println(api)
  13618. resp, requestErr := http.Get(api)
  13619. if requestErr != nil {
  13620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13621. return
  13622. }
  13623. body, ioErr := ioutil.ReadAll(resp.Body)
  13624. if ioErr != nil {
  13625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13627. return
  13628. }
  13629. var respJSON map[string]interface{}
  13630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13633. return
  13634. }
  13635. var status string
  13636. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13637. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13638. //console.log()
  13639. fmt.Println("type===")
  13640. fmt.Println(card_type)
  13641. var token string
  13642. var res ResultTwo //1101结果
  13643. //var res10265 ResultTwoesultTwo10265 //1101结果
  13644. var card_info string //卡信息
  13645. var busi_card_info string
  13646. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13647. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13648. if status == "0" { //读卡成功
  13649. if card_type == "1" {
  13650. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13651. result, _ := json.Marshal(respJSON)
  13652. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13653. utils.ErrorLog("解析失败:%v", err)
  13654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13655. return
  13656. }
  13657. } else {
  13658. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13659. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13660. result, _ := json.Marshal(respJSON)
  13661. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13662. utils.ErrorLog("解析失败:%v", err)
  13663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13664. return
  13665. }
  13666. }
  13667. if res.Infcode == 0 {
  13668. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13669. if err == gorm.ErrRecordNotFound {
  13670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13671. return
  13672. } else if err != nil {
  13673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13674. return
  13675. } else {
  13676. if card_type == "1" {
  13677. bas := strings.Split(card_info, "|")
  13678. basNumber := bas[2]
  13679. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13680. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13681. infoStr := string(Iinfos)
  13682. idetinfoStr := string(Idetinfos)
  13683. psn := &models.HisPsn{
  13684. PsnNo: res.Output.Baseinfo.PsnNo,
  13685. PatientId: patient.ID,
  13686. Certno: res.Output.Baseinfo.Certno,
  13687. Gend: res.Output.Baseinfo.Gend,
  13688. Naty: res.Output.Baseinfo.Naty,
  13689. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13690. PsnName: res.Output.Baseinfo.PsnName,
  13691. Idetinfo: idetinfoStr,
  13692. Insuinfo: infoStr,
  13693. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13694. CardInfo: card_info,
  13695. VerifyNumber: busi_card_info,
  13696. }
  13697. service.CreateHisPsn(psn)
  13698. var rf []*ResultFive
  13699. json.Unmarshal([]byte(infoStr), &rf)
  13700. var insutypes []*ResultFive
  13701. var insutype string
  13702. var is390 int = 0
  13703. var is310 int = 0
  13704. for _, item := range rf {
  13705. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13706. insutypes = append(insutypes, item)
  13707. }
  13708. }
  13709. if len(insutypes) == 1 {
  13710. insutype = insutypes[0].Insutype
  13711. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13712. } else {
  13713. for _, i := range insutypes {
  13714. if i.Insutype == "390" {
  13715. is390 = 1
  13716. }
  13717. if i.Insutype == "310" {
  13718. is310 = 1
  13719. }
  13720. }
  13721. }
  13722. if is390 == 1 {
  13723. insutype = "390"
  13724. }
  13725. if is310 == 1 {
  13726. insutype = "310"
  13727. }
  13728. if len(insutypes) == 0 {
  13729. insutype = "310"
  13730. }
  13731. c.ServeSuccessJSON(map[string]interface{}{
  13732. "patient": patient,
  13733. "number": basNumber,
  13734. "insutype": insutype,
  13735. })
  13736. } else {
  13737. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13738. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13739. infoStr := string(Iinfos)
  13740. idetinfoStr := string(Idetinfos)
  13741. psn := &models.HisPsn{
  13742. PsnNo: res.Output.Baseinfo.PsnNo,
  13743. PatientId: patient.ID,
  13744. Certno: res.Output.Baseinfo.Certno,
  13745. Gend: res.Output.Baseinfo.Gend,
  13746. Naty: res.Output.Baseinfo.Naty,
  13747. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13748. PsnName: res.Output.Baseinfo.PsnName,
  13749. Idetinfo: idetinfoStr,
  13750. Insuinfo: infoStr,
  13751. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13752. CardInfo: card_info,
  13753. VerifyNumber: token,
  13754. }
  13755. service.CreateHisPsn(psn)
  13756. c.ServeSuccessJSON(map[string]interface{}{
  13757. "patient": patient,
  13758. "number": token,
  13759. })
  13760. }
  13761. }
  13762. } else {
  13763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13764. return
  13765. }
  13766. } else { //读卡失败
  13767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13768. return
  13769. }
  13770. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13771. var api string
  13772. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13773. "&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
  13774. fmt.Println(api)
  13775. resp, requestErr := http.Get(api)
  13776. if requestErr != nil {
  13777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13778. return
  13779. }
  13780. body, ioErr := ioutil.ReadAll(resp.Body)
  13781. if ioErr != nil {
  13782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13784. return
  13785. }
  13786. var respJSON map[string]interface{}
  13787. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13790. return
  13791. }
  13792. var status string
  13793. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13794. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13795. //console.log()
  13796. fmt.Println("type===")
  13797. fmt.Println(card_type)
  13798. var token string
  13799. var res ResultTwo //1101结果
  13800. //var res10265 ResultTwoesultTwo10265 //1101结果
  13801. var card_info string //卡信息
  13802. //var busi_card_info string
  13803. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13804. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13805. if status == "0" { //读卡成功
  13806. if card_type == "1" {
  13807. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13808. result, _ := json.Marshal(respJSON)
  13809. fmt.Println(result)
  13810. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13811. utils.ErrorLog("解析失败:%v", err)
  13812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13813. return
  13814. }
  13815. fmt.Println(res)
  13816. } else {
  13817. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13818. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13819. result, _ := json.Marshal(respJSON)
  13820. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13821. utils.ErrorLog("解析失败:%v", err)
  13822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13823. return
  13824. }
  13825. }
  13826. if res.Infcode == 0 {
  13827. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13828. if err == gorm.ErrRecordNotFound {
  13829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13830. return
  13831. } else if err != nil {
  13832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13833. return
  13834. } else {
  13835. if card_type == "1" {
  13836. bas := strings.Split(card_info, "|")
  13837. basNumber := bas[2]
  13838. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13839. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13840. infoStr := string(Iinfos)
  13841. idetinfoStr := string(Idetinfos)
  13842. psn := &models.HisPsn{
  13843. PsnNo: res.Output.Baseinfo.PsnNo,
  13844. PatientId: patient.ID,
  13845. Certno: res.Output.Baseinfo.Certno,
  13846. Gend: res.Output.Baseinfo.Gend,
  13847. Naty: res.Output.Baseinfo.Naty,
  13848. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13849. PsnName: res.Output.Baseinfo.PsnName,
  13850. Idetinfo: idetinfoStr,
  13851. Insuinfo: infoStr,
  13852. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13853. CardInfo: card_info,
  13854. //VerifyNumber: busi_card_info,
  13855. }
  13856. service.CreateHisPsn(psn)
  13857. var rf []*ResultFive
  13858. json.Unmarshal([]byte(infoStr), &rf)
  13859. var insutypes []*ResultFive
  13860. var insutype string
  13861. var is390 int = 0
  13862. var is310 int = 0
  13863. for _, item := range rf {
  13864. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13865. insutypes = append(insutypes, item)
  13866. }
  13867. }
  13868. if len(insutypes) == 1 {
  13869. insutype = insutypes[0].Insutype
  13870. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13871. } else {
  13872. for _, i := range insutypes {
  13873. if i.Insutype == "390" {
  13874. is390 = 1
  13875. }
  13876. if i.Insutype == "310" {
  13877. is310 = 1
  13878. }
  13879. }
  13880. }
  13881. if is390 == 1 {
  13882. insutype = "390"
  13883. }
  13884. if is310 == 1 {
  13885. insutype = "310"
  13886. }
  13887. if len(insutypes) == 0 {
  13888. insutype = "310"
  13889. }
  13890. c.ServeSuccessJSON(map[string]interface{}{
  13891. "patient": patient,
  13892. "number": basNumber,
  13893. "insutype": insutype,
  13894. })
  13895. } else {
  13896. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13897. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13898. infoStr := string(Iinfos)
  13899. idetinfoStr := string(Idetinfos)
  13900. psn := &models.HisPsn{
  13901. PsnNo: res.Output.Baseinfo.PsnNo,
  13902. PatientId: patient.ID,
  13903. Certno: res.Output.Baseinfo.Certno,
  13904. Gend: res.Output.Baseinfo.Gend,
  13905. Naty: res.Output.Baseinfo.Naty,
  13906. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13907. PsnName: res.Output.Baseinfo.PsnName,
  13908. Idetinfo: idetinfoStr,
  13909. Insuinfo: infoStr,
  13910. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13911. CardInfo: card_info,
  13912. VerifyNumber: token,
  13913. }
  13914. service.CreateHisPsn(psn)
  13915. c.ServeSuccessJSON(map[string]interface{}{
  13916. "patient": patient,
  13917. "number": token,
  13918. })
  13919. }
  13920. }
  13921. } else {
  13922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13923. return
  13924. }
  13925. } else { //读卡失败
  13926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13927. return
  13928. }
  13929. } else {
  13930. if initFlag == 0 {
  13931. c.TestGetBasBaseInit()
  13932. }
  13933. basStr := c.GetBasBaseInfo()
  13934. if len(basStr) == 0 {
  13935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13936. return
  13937. }
  13938. fmt.Println(basStr)
  13939. bas := strings.Split(basStr, "|")
  13940. basNumber := bas[1]
  13941. fmt.Println(basNumber)
  13942. card_sn := bas[3]
  13943. fmt.Println(card_sn)
  13944. cardNumber := bas[2]
  13945. fmt.Println(cardNumber)
  13946. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  13947. var result string
  13948. if bas[0][:2] == "44" {
  13949. 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)
  13950. } else {
  13951. 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)
  13952. }
  13953. var dat map[string]interface{}
  13954. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13955. fmt.Println(dat)
  13956. } else {
  13957. fmt.Println(err)
  13958. }
  13959. userJSONBytes, _ := json.Marshal(dat)
  13960. var res ResultTwo
  13961. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13962. utils.ErrorLog("解析失败:%v", err)
  13963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13964. return
  13965. }
  13966. if res.Infcode == 0 {
  13967. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13968. if err == gorm.ErrRecordNotFound {
  13969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13970. return
  13971. } else if err != nil {
  13972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13973. return
  13974. } else {
  13975. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13976. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13977. infoStr := string(Iinfos)
  13978. idetinfoStr := string(Idetinfos)
  13979. var rf []*ResultFive
  13980. json.Unmarshal([]byte(infoStr), &rf)
  13981. var insutypes []*ResultFive
  13982. var insutype string
  13983. var is390 int = 0
  13984. var is310 int = 0
  13985. var insuplc_admdvs string
  13986. for _, item := range rf {
  13987. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13988. insutypes = append(insutypes, item)
  13989. }
  13990. }
  13991. if len(insutypes) == 1 {
  13992. insutype = insutypes[0].Insutype
  13993. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13994. } else {
  13995. for _, i := range insutypes {
  13996. if i.Insutype == "390" {
  13997. is390 = 1
  13998. }
  13999. if i.Insutype == "310" {
  14000. is310 = 1
  14001. }
  14002. }
  14003. }
  14004. if is390 == 1 {
  14005. insutype = "390"
  14006. }
  14007. if is310 == 1 {
  14008. insutype = "310"
  14009. }
  14010. if len(insutypes) == 0 {
  14011. insutype = "310"
  14012. }
  14013. for _, item := range rf {
  14014. if item.Insutype == insutype {
  14015. insuplc_admdvs = item.InsuplcAdmdvs
  14016. }
  14017. }
  14018. psn := &models.HisPsn{
  14019. PsnNo: res.Output.Baseinfo.PsnNo,
  14020. PatientId: patient.ID,
  14021. Certno: res.Output.Baseinfo.Certno,
  14022. Gend: res.Output.Baseinfo.Gend,
  14023. Naty: res.Output.Baseinfo.Naty,
  14024. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14025. PsnName: res.Output.Baseinfo.PsnName,
  14026. Idetinfo: idetinfoStr,
  14027. Insuinfo: infoStr,
  14028. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14029. CardInfo: basStr,
  14030. VerifyNumber: "",
  14031. InsuplcAdmdvs: insuplc_admdvs,
  14032. }
  14033. service.CreateHisPsn(psn)
  14034. c.ServeSuccessJSON(map[string]interface{}{
  14035. "patient": patient,
  14036. "number": basNumber,
  14037. })
  14038. }
  14039. } else {
  14040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14041. return
  14042. }
  14043. break
  14044. }
  14045. case 2:
  14046. if miConfig.MdtrtareaAdmvs == "430800" {
  14047. if initFlag == 0 {
  14048. c.TestGetHnBasBaseInit()
  14049. }
  14050. SFZStr := c.GetSFZBaseInfo()
  14051. if len(SFZStr) == 0 {
  14052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14053. return
  14054. }
  14055. fmt.Println(SFZStr)
  14056. id_card_str := strings.Split(SFZStr, "^")
  14057. card_no := id_card_str[0]
  14058. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14059. //name := id_card_str[1]
  14060. //name = ConvertToString(name, "gbk", "utf-8")
  14061. 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, "", "", card_no)
  14062. var dat map[string]interface{}
  14063. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14064. fmt.Println(dat)
  14065. } else {
  14066. fmt.Println(err)
  14067. }
  14068. userJSONBytes, _ := json.Marshal(dat)
  14069. var res ResultTwo
  14070. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14071. utils.ErrorLog("解析失败:%v", err)
  14072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14073. return
  14074. }
  14075. if res.Infcode == 0 {
  14076. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14077. if err == gorm.ErrRecordNotFound {
  14078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14079. return
  14080. } else if err != nil {
  14081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14082. return
  14083. } else {
  14084. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14085. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14086. infoStr := string(Iinfos)
  14087. idetinfoStr := string(Idetinfos)
  14088. var rf []*ResultFive
  14089. json.Unmarshal([]byte(infoStr), &rf)
  14090. var insutypes []*ResultFive
  14091. var insutype string
  14092. var is390 int = 0
  14093. var is310 int = 0
  14094. for _, item := range rf {
  14095. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14096. insutypes = append(insutypes, item)
  14097. }
  14098. }
  14099. if len(insutypes) == 1 {
  14100. insutype = insutypes[0].Insutype
  14101. } else {
  14102. for _, i := range insutypes {
  14103. if i.Insutype == "390" {
  14104. is390 = 1
  14105. }
  14106. if i.Insutype == "310" {
  14107. is310 = 1
  14108. }
  14109. }
  14110. }
  14111. if is390 == 1 {
  14112. insutype = "390"
  14113. }
  14114. if is310 == 1 {
  14115. insutype = "310"
  14116. }
  14117. if len(insutypes) == 0 {
  14118. insutype = "310"
  14119. }
  14120. var InsuplcAdmdvs string
  14121. for _, item := range rf {
  14122. if item.Insutype == insutype {
  14123. InsuplcAdmdvs = item.InsuplcAdmdvs
  14124. }
  14125. }
  14126. psn := &models.HisPsn{
  14127. PsnNo: res.Output.Baseinfo.PsnNo,
  14128. PatientId: patient.ID,
  14129. Certno: res.Output.Baseinfo.Certno,
  14130. Gend: res.Output.Baseinfo.Gend,
  14131. Naty: res.Output.Baseinfo.Naty,
  14132. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14133. PsnName: res.Output.Baseinfo.PsnName,
  14134. Idetinfo: idetinfoStr,
  14135. Insuinfo: infoStr,
  14136. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14137. CardInfo: SFZStr,
  14138. VerifyNumber: "",
  14139. InsuplcAdmdvs: InsuplcAdmdvs,
  14140. }
  14141. service.CreateHisPsn(psn)
  14142. c.ServeSuccessJSON(map[string]interface{}{
  14143. "patient": patient,
  14144. "number": card_no,
  14145. "insutype": insutype,
  14146. })
  14147. }
  14148. } else {
  14149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14150. return
  14151. }
  14152. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14153. var res ResultTwo
  14154. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14155. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14156. "&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)
  14157. resp, requestErr := http.Get(api)
  14158. if requestErr != nil {
  14159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14160. return
  14161. }
  14162. body, ioErr := ioutil.ReadAll(resp.Body)
  14163. if ioErr != nil {
  14164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14166. return
  14167. }
  14168. var respJSON map[string]interface{}
  14169. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14172. return
  14173. }
  14174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14175. result, _ := json.Marshal(respJSON)
  14176. fmt.Println("log")
  14177. fmt.Println(string(result))
  14178. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14179. utils.ErrorLog("解析失败:%v", err)
  14180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14181. return
  14182. }
  14183. if res.Infcode == 0 {
  14184. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14185. if err == gorm.ErrRecordNotFound {
  14186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14187. return
  14188. } else if err != nil {
  14189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14190. return
  14191. } else {
  14192. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14193. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14194. infoStr := string(Iinfos)
  14195. idetinfoStr := string(Idetinfos)
  14196. psn := &models.HisPsn{
  14197. PsnNo: res.Output.Baseinfo.PsnNo,
  14198. PatientId: patient.ID,
  14199. Certno: res.Output.Baseinfo.Certno,
  14200. Gend: res.Output.Baseinfo.Gend,
  14201. Naty: res.Output.Baseinfo.Naty,
  14202. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14203. PsnName: res.Output.Baseinfo.PsnName,
  14204. Idetinfo: idetinfoStr,
  14205. Insuinfo: infoStr,
  14206. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14207. }
  14208. service.CreateHisPsn(psn)
  14209. c.ServeSuccessJSON(map[string]interface{}{
  14210. "patient": patient,
  14211. "number": res.Output.Baseinfo.Certno,
  14212. })
  14213. }
  14214. } else {
  14215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14216. return
  14217. }
  14218. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14219. var res ResultTwo
  14220. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14221. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14222. "&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)
  14223. resp, requestErr := http.Get(api)
  14224. if requestErr != nil {
  14225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14226. return
  14227. }
  14228. body, ioErr := ioutil.ReadAll(resp.Body)
  14229. if ioErr != nil {
  14230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14232. return
  14233. }
  14234. var respJSON map[string]interface{}
  14235. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14238. return
  14239. }
  14240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14241. result, _ := json.Marshal(respJSON)
  14242. fmt.Println("log")
  14243. fmt.Println(string(result))
  14244. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14245. utils.ErrorLog("解析失败:%v", err)
  14246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14247. return
  14248. }
  14249. if res.Infcode == 0 {
  14250. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14251. if err == gorm.ErrRecordNotFound {
  14252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14253. return
  14254. } else if err != nil {
  14255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14256. return
  14257. } else {
  14258. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14259. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14260. infoStr := string(Iinfos)
  14261. idetinfoStr := string(Idetinfos)
  14262. psn := &models.HisPsn{
  14263. PsnNo: res.Output.Baseinfo.PsnNo,
  14264. PatientId: patient.ID,
  14265. Certno: res.Output.Baseinfo.Certno,
  14266. Gend: res.Output.Baseinfo.Gend,
  14267. Naty: res.Output.Baseinfo.Naty,
  14268. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14269. PsnName: res.Output.Baseinfo.PsnName,
  14270. Idetinfo: idetinfoStr,
  14271. Insuinfo: infoStr,
  14272. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14273. }
  14274. service.CreateHisPsn(psn)
  14275. c.ServeSuccessJSON(map[string]interface{}{
  14276. "patient": patient,
  14277. "number": res.Output.Baseinfo.Certno,
  14278. })
  14279. }
  14280. } else {
  14281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14282. return
  14283. }
  14284. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14285. var res ResultTwo
  14286. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14287. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14288. "&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)
  14289. resp, requestErr := http.Get(api)
  14290. if requestErr != nil {
  14291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14292. return
  14293. }
  14294. body, ioErr := ioutil.ReadAll(resp.Body)
  14295. if ioErr != nil {
  14296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14298. return
  14299. }
  14300. var respJSON map[string]interface{}
  14301. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14304. return
  14305. }
  14306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14307. result, _ := json.Marshal(respJSON)
  14308. fmt.Println("log")
  14309. fmt.Println(string(result))
  14310. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14311. utils.ErrorLog("解析失败:%v", err)
  14312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14313. return
  14314. }
  14315. if res.Infcode == 0 {
  14316. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14317. if err == gorm.ErrRecordNotFound {
  14318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14319. return
  14320. } else if err != nil {
  14321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14322. return
  14323. } else {
  14324. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14325. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14326. infoStr := string(Iinfos)
  14327. idetinfoStr := string(Idetinfos)
  14328. var rf []*ResultFive
  14329. json.Unmarshal([]byte(infoStr), &rf)
  14330. var insutypes []*ResultFive
  14331. var insutype string
  14332. var is390 int = 0
  14333. var is310 int = 0
  14334. for _, item := range rf {
  14335. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14336. insutypes = append(insutypes, item)
  14337. }
  14338. }
  14339. if len(insutypes) == 1 {
  14340. insutype = insutypes[0].Insutype
  14341. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14342. } else {
  14343. for _, i := range insutypes {
  14344. if i.Insutype == "390" {
  14345. is390 = 1
  14346. }
  14347. if i.Insutype == "310" {
  14348. is310 = 1
  14349. }
  14350. }
  14351. }
  14352. if is390 == 1 {
  14353. insutype = "390"
  14354. }
  14355. if is310 == 1 {
  14356. insutype = "310"
  14357. }
  14358. if len(insutypes) == 0 {
  14359. insutype = "390"
  14360. }
  14361. var insuplc_admdvs string
  14362. for _, item := range rf {
  14363. if item.Insutype == insutype {
  14364. insuplc_admdvs = item.InsuplcAdmdvs
  14365. }
  14366. }
  14367. psn := &models.HisPsn{
  14368. PsnNo: res.Output.Baseinfo.PsnNo,
  14369. PatientId: patient.ID,
  14370. Certno: res.Output.Baseinfo.Certno,
  14371. Gend: res.Output.Baseinfo.Gend,
  14372. Naty: res.Output.Baseinfo.Naty,
  14373. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14374. PsnName: res.Output.Baseinfo.PsnName,
  14375. Idetinfo: idetinfoStr,
  14376. Insuinfo: infoStr,
  14377. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14378. InsuplcAdmdvs: insuplc_admdvs,
  14379. }
  14380. service.CreateHisPsn(psn)
  14381. c.ServeSuccessJSON(map[string]interface{}{
  14382. "patient": patient,
  14383. "number": res.Output.Baseinfo.Certno,
  14384. })
  14385. }
  14386. } else {
  14387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14388. return
  14389. }
  14390. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14391. res := c.GetoleInfo()
  14392. if res.Infcode == 0 {
  14393. var result string
  14394. if res.Output.MdtrtCertType == "01" {
  14395. 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)
  14396. } else if res.Output.MdtrtCertType == "02" {
  14397. 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)
  14398. } else if res.Output.MdtrtCertType == "03" {
  14399. 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)
  14400. }
  14401. var dat map[string]interface{}
  14402. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14403. fmt.Println(dat)
  14404. } else {
  14405. fmt.Println(err)
  14406. }
  14407. userJSONBytes, _ := json.Marshal(dat)
  14408. var res2 ResultTwo
  14409. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14410. utils.ErrorLog("解析失败:%v", err)
  14411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14412. return
  14413. }
  14414. if res2.Infcode == 0 {
  14415. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14416. if err == gorm.ErrRecordNotFound {
  14417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14418. return
  14419. } else if err != nil {
  14420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14421. return
  14422. } else {
  14423. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14424. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14425. infoStr := string(Iinfos)
  14426. idetinfoStr := string(Idetinfos)
  14427. var rf []*ResultFive
  14428. json.Unmarshal([]byte(infoStr), &rf)
  14429. var insutypes []*ResultFive
  14430. var insutype string
  14431. var is390 int = 0
  14432. var is310 int = 0
  14433. //var insuplc_admdvs string
  14434. for _, item := range rf {
  14435. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14436. insutypes = append(insutypes, item)
  14437. }
  14438. }
  14439. if len(insutypes) == 1 {
  14440. insutype = insutypes[0].Insutype
  14441. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14442. } else {
  14443. for _, i := range insutypes {
  14444. if i.Insutype == "390" {
  14445. is390 = 1
  14446. }
  14447. if i.Insutype == "310" {
  14448. is310 = 1
  14449. }
  14450. }
  14451. }
  14452. if is390 == 1 {
  14453. insutype = "390"
  14454. }
  14455. if is310 == 1 {
  14456. insutype = "310"
  14457. }
  14458. if len(insutypes) == 0 {
  14459. insutype = "310"
  14460. }
  14461. psn := &models.HisPsn{
  14462. PsnNo: res2.Output.Baseinfo.PsnNo,
  14463. PatientId: patient.ID,
  14464. //Brdy: res2.Output.Baseinfo.Brdy,
  14465. Certno: res2.Output.Baseinfo.Certno,
  14466. Gend: res2.Output.Baseinfo.Gend,
  14467. Naty: res2.Output.Baseinfo.Naty,
  14468. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14469. PsnName: res2.Output.Baseinfo.PsnName,
  14470. Idetinfo: idetinfoStr,
  14471. Insuinfo: infoStr,
  14472. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14473. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14474. VerifyNumber: res.Output.EcToken,
  14475. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14476. }
  14477. service.CreateHisPsn(psn)
  14478. var balc float64
  14479. for _, item := range rf {
  14480. if item.Insutype == insutype {
  14481. balc = item.Balc
  14482. }
  14483. }
  14484. c.ServeSuccessJSON(map[string]interface{}{
  14485. "patient": patient,
  14486. "number": res.Output.CardNo,
  14487. "insutype": insutype,
  14488. "blac": balc,
  14489. "desc": idetinfoStr,
  14490. })
  14491. }
  14492. } else {
  14493. c.ServeSuccessJSON(map[string]interface{}{
  14494. "failed_code": -10,
  14495. "msg": res2.ErrMsg,
  14496. })
  14497. }
  14498. } else {
  14499. c.ServeSuccessJSON(map[string]interface{}{
  14500. "failed_code": -10,
  14501. "msg": res.ErrMsg,
  14502. })
  14503. }
  14504. } else {
  14505. SFZStr := c.GetSFZBaseInfo()
  14506. id_card_str := strings.Split(SFZStr, "^")
  14507. id_card_number := id_card_str[0]
  14508. card_sn := ""
  14509. 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)
  14510. var dat map[string]interface{}
  14511. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14512. fmt.Println(dat)
  14513. } else {
  14514. fmt.Println(err)
  14515. }
  14516. userJSONBytes, _ := json.Marshal(dat)
  14517. var res ResultTwo
  14518. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14519. utils.ErrorLog("解析失败:%v", err)
  14520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14521. return
  14522. }
  14523. if res.Infcode == 0 {
  14524. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  14525. if err == gorm.ErrRecordNotFound {
  14526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14527. return
  14528. } else if err != nil {
  14529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14530. return
  14531. } else {
  14532. c.ServeSuccessJSON(map[string]interface{}{
  14533. "patient": patient,
  14534. "number": id_card_number,
  14535. })
  14536. }
  14537. } else {
  14538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14539. return
  14540. }
  14541. }
  14542. break
  14543. case 3:
  14544. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14545. var api string
  14546. if miConfig.MdtrtareaAdmvs == "320921" {
  14547. 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 +
  14548. "&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
  14549. fmt.Println(api)
  14550. } else {
  14551. 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 +
  14552. "&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)
  14553. }
  14554. resp, requestErr := http.Get(api)
  14555. if requestErr != nil {
  14556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14557. return
  14558. }
  14559. body, ioErr := ioutil.ReadAll(resp.Body)
  14560. if ioErr != nil {
  14561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14563. return
  14564. }
  14565. var respJSON map[string]interface{}
  14566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14569. return
  14570. }
  14571. var status string
  14572. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14573. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14574. var token string
  14575. var res ResultTwo //1101结果
  14576. var res10265 ResultTwo10265 //1101结果
  14577. var card_info string //卡信息
  14578. var busi_card_info string
  14579. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14580. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14581. if status == "0" { //读卡成功
  14582. if card_type == "1" {
  14583. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14584. result, _ := json.Marshal(respJSON)
  14585. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14586. utils.ErrorLog("解析失败:%v", err)
  14587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14588. return
  14589. }
  14590. res.ErrMsg = res10265.ErrMsg
  14591. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14592. res.Infcode = infocode
  14593. res.Output = res10265.Output
  14594. res.InfRefmsgid = res10265.InfRefmsgid
  14595. } else {
  14596. //var card_info string //卡信息
  14597. //var busi_card_info string
  14598. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14599. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14600. //fmt.Println(card_info)
  14601. //fmt.Println(busi_card_info)
  14602. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14603. result, _ := json.Marshal(respJSON)
  14604. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14605. utils.ErrorLog("解析失败:%v", err)
  14606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14607. return
  14608. }
  14609. res.ErrMsg = res10265.ErrMsg
  14610. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14611. res.Infcode = infocode
  14612. res.Output = res10265.Output
  14613. res.InfRefmsgid = res10265.InfRefmsgid
  14614. }
  14615. if res.Infcode == 0 {
  14616. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14617. if err == gorm.ErrRecordNotFound {
  14618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14619. return
  14620. } else if err != nil {
  14621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14622. return
  14623. } else {
  14624. if card_type == "1" {
  14625. bas := strings.Split(card_info, "|")
  14626. basNumber := bas[2]
  14627. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14628. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14629. infoStr := string(Iinfos)
  14630. idetinfoStr := string(Idetinfos)
  14631. psn := &models.HisPsn{
  14632. PsnNo: res.Output.Baseinfo.PsnNo,
  14633. PatientId: patient.ID,
  14634. Certno: res.Output.Baseinfo.Certno,
  14635. //Brdy: res.Output.Baseinfo.Brdy,
  14636. Gend: res.Output.Baseinfo.Gend,
  14637. Naty: res.Output.Baseinfo.Naty,
  14638. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14639. PsnName: res.Output.Baseinfo.PsnName,
  14640. Idetinfo: idetinfoStr,
  14641. Insuinfo: infoStr,
  14642. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14643. CardInfo: card_info,
  14644. VerifyNumber: busi_card_info,
  14645. }
  14646. service.CreateHisPsn(psn)
  14647. c.ServeSuccessJSON(map[string]interface{}{
  14648. "patient": patient,
  14649. "number": basNumber,
  14650. })
  14651. } else {
  14652. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14653. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14654. infoStr := string(Iinfos)
  14655. idetinfoStr := string(Idetinfos)
  14656. psn := &models.HisPsn{
  14657. PsnNo: res.Output.Baseinfo.PsnNo,
  14658. PatientId: patient.ID,
  14659. Certno: res.Output.Baseinfo.Certno,
  14660. Gend: res.Output.Baseinfo.Gend,
  14661. Naty: res.Output.Baseinfo.Naty,
  14662. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14663. PsnName: res.Output.Baseinfo.PsnName,
  14664. Idetinfo: idetinfoStr,
  14665. Insuinfo: infoStr,
  14666. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14667. CardInfo: card_info,
  14668. VerifyNumber: token,
  14669. }
  14670. service.CreateHisPsn(psn)
  14671. var rf []*ResultFive
  14672. json.Unmarshal([]byte(infoStr), &rf)
  14673. var insutypes []*ResultFive
  14674. var insutype string
  14675. var is390 int = 0
  14676. var is310 int = 0
  14677. for _, item := range rf {
  14678. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14679. insutypes = append(insutypes, item)
  14680. }
  14681. }
  14682. if len(insutypes) == 1 {
  14683. insutype = insutypes[0].Insutype
  14684. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14685. } else {
  14686. for _, i := range insutypes {
  14687. if i.Insutype == "390" {
  14688. is390 = 1
  14689. }
  14690. if i.Insutype == "310" {
  14691. is310 = 1
  14692. }
  14693. }
  14694. }
  14695. if is390 == 1 {
  14696. insutype = "390"
  14697. }
  14698. if is310 == 1 {
  14699. insutype = "310"
  14700. }
  14701. if len(insutypes) == 0 {
  14702. insutype = "310"
  14703. }
  14704. c.ServeSuccessJSON(map[string]interface{}{
  14705. "patient": patient,
  14706. "number": token,
  14707. "insutype": insutype,
  14708. })
  14709. }
  14710. }
  14711. } else {
  14712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14713. return
  14714. }
  14715. } else { //读卡失败
  14716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14717. return
  14718. }
  14719. }
  14720. break
  14721. case 4:
  14722. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14723. var api string
  14724. if miConfig.MdtrtareaAdmvs == "320921" {
  14725. 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 +
  14726. "&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
  14727. fmt.Println(api)
  14728. } else {
  14729. 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 +
  14730. "&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)
  14731. }
  14732. resp, requestErr := http.Get(api)
  14733. if requestErr != nil {
  14734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14735. return
  14736. }
  14737. body, ioErr := ioutil.ReadAll(resp.Body)
  14738. if ioErr != nil {
  14739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14741. return
  14742. }
  14743. var respJSON map[string]interface{}
  14744. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14747. return
  14748. }
  14749. var status string
  14750. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14751. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14752. var token string
  14753. var res ResultTwo //1101结果
  14754. var res10265 ResultTwo10265 //1101结果
  14755. if status == "0" { //读卡成功
  14756. var card_info string //卡信息
  14757. var busi_card_info string
  14758. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14759. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14760. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14761. fmt.Println(card_info)
  14762. fmt.Println(busi_card_info)
  14763. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14764. result, _ := json.Marshal(respJSON)
  14765. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14766. utils.ErrorLog("解析失败:%v", err)
  14767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14768. return
  14769. }
  14770. res.ErrMsg = res10265.ErrMsg
  14771. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14772. res.Infcode = infocode
  14773. res.Output = res10265.Output
  14774. res.InfRefmsgid = res10265.InfRefmsgid
  14775. if res.Infcode == 0 {
  14776. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14777. if err == gorm.ErrRecordNotFound {
  14778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14779. return
  14780. } else if err != nil {
  14781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14782. return
  14783. } else {
  14784. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14785. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14786. infoStr := string(Iinfos)
  14787. idetinfoStr := string(Idetinfos)
  14788. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14789. psn := &models.HisPsn{
  14790. PsnNo: res.Output.Baseinfo.PsnNo,
  14791. PatientId: patient.ID,
  14792. Certno: res.Output.Baseinfo.Certno,
  14793. Brdy: b,
  14794. Age: float64(age),
  14795. //Brdy: res.Output.Baseinfo.Brdy,
  14796. Gend: res.Output.Baseinfo.Gend,
  14797. Naty: res.Output.Baseinfo.Naty,
  14798. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14799. PsnName: res.Output.Baseinfo.PsnName,
  14800. Idetinfo: idetinfoStr,
  14801. Insuinfo: infoStr,
  14802. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14803. CardInfo: card_info,
  14804. VerifyNumber: token,
  14805. }
  14806. var rf []*ResultFive
  14807. json.Unmarshal([]byte(infoStr), &rf)
  14808. var insutypes []*ResultFive
  14809. var insutype string
  14810. var is390 int = 0
  14811. var is310 int = 0
  14812. for _, item := range rf {
  14813. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14814. insutypes = append(insutypes, item)
  14815. }
  14816. }
  14817. if len(insutypes) == 1 {
  14818. insutype = insutypes[0].Insutype
  14819. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14820. } else {
  14821. for _, i := range insutypes {
  14822. if i.Insutype == "390" {
  14823. is390 = 1
  14824. }
  14825. if i.Insutype == "310" {
  14826. is310 = 1
  14827. }
  14828. }
  14829. }
  14830. if is390 == 1 {
  14831. insutype = "390"
  14832. }
  14833. if is310 == 1 {
  14834. insutype = "310"
  14835. }
  14836. if len(insutypes) == 0 {
  14837. insutype = "310"
  14838. }
  14839. service.CreateHisPsn(psn)
  14840. c.ServeSuccessJSON(map[string]interface{}{
  14841. "patient": patient,
  14842. "number": token,
  14843. "insutype": insutype,
  14844. })
  14845. }
  14846. } else {
  14847. c.ServeSuccessJSON(map[string]interface{}{
  14848. "failed_code": -10,
  14849. "msg": res.ErrMsg,
  14850. })
  14851. }
  14852. } else { //读卡失败
  14853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14854. return
  14855. }
  14856. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14857. var api string
  14858. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14859. "&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
  14860. resp, requestErr := http.Get(api)
  14861. if requestErr != nil {
  14862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14863. return
  14864. }
  14865. body, ioErr := ioutil.ReadAll(resp.Body)
  14866. if ioErr != nil {
  14867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14869. return
  14870. }
  14871. var respJSON map[string]interface{}
  14872. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14875. return
  14876. }
  14877. var status string
  14878. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14879. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14880. var token string
  14881. var res ResultTwo //1101结果
  14882. if status == "1" { //读卡成功
  14883. var card_info string //卡信息
  14884. var busi_card_info string
  14885. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14886. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14887. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14888. fmt.Println(card_info)
  14889. fmt.Println(busi_card_info)
  14890. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14891. result, _ := json.Marshal(respJSON)
  14892. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14893. utils.ErrorLog("解析失败:%v", err)
  14894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14895. return
  14896. }
  14897. if res.Infcode == 0 {
  14898. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14899. if err == gorm.ErrRecordNotFound {
  14900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14901. return
  14902. } else if err != nil {
  14903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14904. return
  14905. } else {
  14906. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14907. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14908. infoStr := string(Iinfos)
  14909. idetinfoStr := string(Idetinfos)
  14910. psn := &models.HisPsn{
  14911. PsnNo: res.Output.Baseinfo.PsnNo,
  14912. PatientId: patient.ID,
  14913. Certno: res.Output.Baseinfo.Certno,
  14914. Gend: res.Output.Baseinfo.Gend,
  14915. Naty: res.Output.Baseinfo.Naty,
  14916. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14917. PsnName: res.Output.Baseinfo.PsnName,
  14918. Idetinfo: idetinfoStr,
  14919. Insuinfo: infoStr,
  14920. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14921. CardInfo: card_info,
  14922. VerifyNumber: token,
  14923. }
  14924. var rf []*ResultFive
  14925. json.Unmarshal([]byte(infoStr), &rf)
  14926. var insutypes []*ResultFive
  14927. var insutype string
  14928. var is390 int = 0
  14929. var is310 int = 0
  14930. for _, item := range rf {
  14931. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14932. insutypes = append(insutypes, item)
  14933. }
  14934. }
  14935. if len(insutypes) == 1 {
  14936. insutype = insutypes[0].Insutype
  14937. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14938. } else {
  14939. for _, i := range insutypes {
  14940. if i.Insutype == "390" {
  14941. is390 = 1
  14942. }
  14943. if i.Insutype == "310" {
  14944. is310 = 1
  14945. }
  14946. }
  14947. }
  14948. if is390 == 1 {
  14949. insutype = "390"
  14950. }
  14951. if is310 == 1 {
  14952. insutype = "310"
  14953. }
  14954. if len(insutypes) == 0 {
  14955. insutype = "310"
  14956. }
  14957. service.CreateHisPsn(psn)
  14958. c.ServeSuccessJSON(map[string]interface{}{
  14959. "patient": patient,
  14960. "number": token,
  14961. "insutype": insutype,
  14962. })
  14963. }
  14964. } else {
  14965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14966. return
  14967. }
  14968. } else { //读卡失败
  14969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14970. return
  14971. }
  14972. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14973. var api string
  14974. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14975. "&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
  14976. resp, requestErr := http.Get(api)
  14977. if requestErr != nil {
  14978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14979. return
  14980. }
  14981. body, ioErr := ioutil.ReadAll(resp.Body)
  14982. if ioErr != nil {
  14983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14985. return
  14986. }
  14987. var respJSON map[string]interface{}
  14988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14991. return
  14992. }
  14993. var status string
  14994. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14995. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14996. var token string
  14997. var res ResultTwo //1101结果
  14998. if status == "1" { //读卡成功
  14999. var card_info string //卡信息
  15000. var busi_card_info string
  15001. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15002. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15003. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15004. fmt.Println(card_info)
  15005. fmt.Println(busi_card_info)
  15006. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15007. result, _ := json.Marshal(respJSON)
  15008. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15009. utils.ErrorLog("解析失败:%v", err)
  15010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15011. return
  15012. }
  15013. if res.Infcode == 0 {
  15014. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15015. if err == gorm.ErrRecordNotFound {
  15016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15017. return
  15018. } else if err != nil {
  15019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15020. return
  15021. } else {
  15022. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15023. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15024. infoStr := string(Iinfos)
  15025. idetinfoStr := string(Idetinfos)
  15026. psn := &models.HisPsn{
  15027. PsnNo: res.Output.Baseinfo.PsnNo,
  15028. PatientId: patient.ID,
  15029. Certno: res.Output.Baseinfo.Certno,
  15030. Gend: res.Output.Baseinfo.Gend,
  15031. Naty: res.Output.Baseinfo.Naty,
  15032. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15033. PsnName: res.Output.Baseinfo.PsnName,
  15034. Idetinfo: idetinfoStr,
  15035. Insuinfo: infoStr,
  15036. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15037. CardInfo: card_info,
  15038. VerifyNumber: token,
  15039. }
  15040. var rf []*ResultFive
  15041. json.Unmarshal([]byte(infoStr), &rf)
  15042. var insutypes []*ResultFive
  15043. var insutype string
  15044. var is390 int = 0
  15045. var is310 int = 0
  15046. for _, item := range rf {
  15047. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15048. insutypes = append(insutypes, item)
  15049. }
  15050. }
  15051. if len(insutypes) == 1 {
  15052. insutype = insutypes[0].Insutype
  15053. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15054. } else {
  15055. for _, i := range insutypes {
  15056. if i.Insutype == "390" {
  15057. is390 = 1
  15058. }
  15059. if i.Insutype == "310" {
  15060. is310 = 1
  15061. }
  15062. }
  15063. }
  15064. if is390 == 1 {
  15065. insutype = "390"
  15066. }
  15067. if is310 == 1 {
  15068. insutype = "310"
  15069. }
  15070. if len(insutypes) == 0 {
  15071. insutype = "310"
  15072. }
  15073. service.CreateHisPsn(psn)
  15074. c.ServeSuccessJSON(map[string]interface{}{
  15075. "patient": patient,
  15076. "number": token,
  15077. "insutype": insutype,
  15078. })
  15079. }
  15080. } else {
  15081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15082. return
  15083. }
  15084. } else { //读卡失败
  15085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15086. return
  15087. }
  15088. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15089. //idNo := c.GetString("idNo")
  15090. //userName := c.GetString("userName")
  15091. //ecToken := c.GetString("ecToken")
  15092. //insuOrg := c.GetString("insuOrg")
  15093. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15094. utils.ErrorLog("解析失败:%v", json_result)
  15095. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15096. type ELeData struct {
  15097. Data struct {
  15098. IdNo string `json:"idNo"`
  15099. IdType string `json:"idType"`
  15100. UserName string `json:"userName"`
  15101. EcToken string `json:"ecToken"`
  15102. InsuOrg string `json:"insuOrg"`
  15103. Gender string `json:"gender"`
  15104. Birthday string `json:"birthday"`
  15105. Nationality string `json:"nationality"`
  15106. Email string `json:"email"`
  15107. Extra string `json:"extra"`
  15108. } `json:"data"`
  15109. Code int `json:"code"`
  15110. Message string `json:"message"`
  15111. }
  15112. var ele ELeData
  15113. err := json.Unmarshal([]byte(json_result), &ele)
  15114. if err != nil {
  15115. utils.ErrorLog("解析失败:%v", err)
  15116. }
  15117. token := ele.Data.EcToken
  15118. token = Remove0000(token)
  15119. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  15120. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15121. var res ResultTwo
  15122. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15123. utils.ErrorLog("解析失败:%v", err)
  15124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15125. return
  15126. }
  15127. if res.Infcode == 0 {
  15128. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15129. if err == gorm.ErrRecordNotFound {
  15130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15131. return
  15132. } else if err != nil {
  15133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15134. return
  15135. } else {
  15136. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15137. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15138. infoStr := string(Iinfos)
  15139. idetinfoStr := string(Idetinfos)
  15140. psn := &models.HisPsn{
  15141. PsnNo: res.Output.Baseinfo.PsnNo,
  15142. PatientId: patient.ID,
  15143. Certno: res.Output.Baseinfo.Certno,
  15144. Gend: res.Output.Baseinfo.Gend,
  15145. Naty: res.Output.Baseinfo.Naty,
  15146. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15147. PsnName: res.Output.Baseinfo.PsnName,
  15148. Idetinfo: idetinfoStr,
  15149. Insuinfo: infoStr,
  15150. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15151. CardInfo: "",
  15152. Stage: "1",
  15153. VerifyNumber: token,
  15154. InsuplcAdmdvs: ele.Data.InsuOrg,
  15155. }
  15156. service.CreateHisPsn(psn)
  15157. var rf []*ResultFive
  15158. json.Unmarshal([]byte(infoStr), &rf)
  15159. var insutypes []*ResultFive
  15160. var insutype string
  15161. var is390 int = 0
  15162. var is310 int = 0
  15163. for _, item := range rf {
  15164. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15165. insutypes = append(insutypes, item)
  15166. }
  15167. }
  15168. if len(insutypes) == 1 {
  15169. insutype = insutypes[0].Insutype
  15170. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15171. } else {
  15172. for _, i := range insutypes {
  15173. if i.Insutype == "390" {
  15174. is390 = 1
  15175. }
  15176. if i.Insutype == "310" {
  15177. is310 = 1
  15178. }
  15179. }
  15180. }
  15181. if is390 == 1 {
  15182. insutype = "390"
  15183. }
  15184. if is310 == 1 {
  15185. insutype = "310"
  15186. }
  15187. if len(insutypes) == 0 {
  15188. insutype = "310"
  15189. }
  15190. c.ServeSuccessJSON(map[string]interface{}{
  15191. "patient": patient,
  15192. "number": token,
  15193. "insutype": insutype,
  15194. })
  15195. }
  15196. } else {
  15197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15198. return
  15199. }
  15200. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15201. //if initFlag == 0 {
  15202. //c.TestGetJiangXiBasBaseInit()
  15203. //}
  15204. //if initEleFlag == 0 {
  15205. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15206. //}
  15207. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15208. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15209. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15210. type ELeData struct {
  15211. Data struct {
  15212. IdNo string `json:"idNo"`
  15213. IdType string `json:"idType"`
  15214. UserName string `json:"userName"`
  15215. EcToken string `json:"ecToken"`
  15216. InsuOrg string `json:"insuOrg"`
  15217. Gender string `json:"gender"`
  15218. Birthday string `json:"birthday"`
  15219. Nationality string `json:"nationality"`
  15220. Email string `json:"email"`
  15221. Extra string `json:"extra"`
  15222. } `json:"data"`
  15223. Code int `json:"code"`
  15224. Message string `json:"message"`
  15225. }
  15226. var ele ELeData
  15227. err := json.Unmarshal([]byte(result), &ele)
  15228. if err != nil {
  15229. utils.ErrorLog("解析失败:%v", err)
  15230. }
  15231. token := ele.Data.EcToken
  15232. token = Remove0000(token)
  15233. 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)
  15234. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15235. var res ResultTwo
  15236. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15237. utils.ErrorLog("解析失败:%v", err)
  15238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15239. return
  15240. }
  15241. if res.Infcode == 0 {
  15242. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15243. if err == gorm.ErrRecordNotFound {
  15244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15245. return
  15246. } else if err != nil {
  15247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15248. return
  15249. } else {
  15250. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15251. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15252. infoStr := string(Iinfos)
  15253. idetinfoStr := string(Idetinfos)
  15254. psn := &models.HisPsn{
  15255. PsnNo: res.Output.Baseinfo.PsnNo,
  15256. PatientId: patient.ID,
  15257. Certno: res.Output.Baseinfo.Certno,
  15258. Gend: res.Output.Baseinfo.Gend,
  15259. Naty: res.Output.Baseinfo.Naty,
  15260. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15261. PsnName: res.Output.Baseinfo.PsnName,
  15262. Idetinfo: idetinfoStr,
  15263. Insuinfo: infoStr,
  15264. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15265. CardInfo: "",
  15266. VerifyNumber: token,
  15267. InsuplcAdmdvs: ele.Data.InsuOrg,
  15268. }
  15269. service.CreateHisPsn(psn)
  15270. var rf []*ResultFive
  15271. json.Unmarshal([]byte(infoStr), &rf)
  15272. var insutypes []*ResultFive
  15273. var insutype string
  15274. var is390 int = 0
  15275. var is310 int = 0
  15276. for _, item := range rf {
  15277. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15278. insutypes = append(insutypes, item)
  15279. }
  15280. }
  15281. if len(insutypes) == 1 {
  15282. insutype = insutypes[0].Insutype
  15283. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15284. } else {
  15285. for _, i := range insutypes {
  15286. if i.Insutype == "390" {
  15287. is390 = 1
  15288. }
  15289. if i.Insutype == "310" {
  15290. is310 = 1
  15291. }
  15292. }
  15293. }
  15294. if is390 == 1 {
  15295. insutype = "390"
  15296. }
  15297. if is310 == 1 {
  15298. insutype = "310"
  15299. }
  15300. if len(insutypes) == 0 {
  15301. insutype = "310"
  15302. }
  15303. c.ServeSuccessJSON(map[string]interface{}{
  15304. "patient": patient,
  15305. "number": token,
  15306. "insutype": insutype,
  15307. })
  15308. }
  15309. } else {
  15310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15311. return
  15312. }
  15313. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15314. //if initFlag == 0 {
  15315. //c.TestGetJiangXiBasBaseInit()
  15316. //}
  15317. //if initEleFlag == 0 {
  15318. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15319. //}
  15320. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15321. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15322. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15323. type ELeData struct {
  15324. Data struct {
  15325. IdNo string `json:"idNo"`
  15326. IdType string `json:"idType"`
  15327. UserName string `json:"userName"`
  15328. EcToken string `json:"ecToken"`
  15329. InsuOrg string `json:"insuOrg"`
  15330. Gender string `json:"gender"`
  15331. Birthday string `json:"birthday"`
  15332. Nationality string `json:"nationality"`
  15333. Email string `json:"email"`
  15334. Extra string `json:"extra"`
  15335. } `json:"data"`
  15336. Code int `json:"code"`
  15337. Message string `json:"message"`
  15338. }
  15339. var ele ELeData
  15340. err := json.Unmarshal([]byte(result), &ele)
  15341. if err != nil {
  15342. utils.ErrorLog("解析失败:%v", err)
  15343. }
  15344. token := ele.Data.EcToken
  15345. token = Remove0000(token)
  15346. 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)
  15347. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15348. var res ResultTwo
  15349. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15350. utils.ErrorLog("解析失败:%v", err)
  15351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15352. return
  15353. }
  15354. if res.Infcode == 0 {
  15355. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15356. if err == gorm.ErrRecordNotFound {
  15357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15358. return
  15359. } else if err != nil {
  15360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15361. return
  15362. } else {
  15363. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15364. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15365. infoStr := string(Iinfos)
  15366. idetinfoStr := string(Idetinfos)
  15367. psn := &models.HisPsn{
  15368. PsnNo: res.Output.Baseinfo.PsnNo,
  15369. PatientId: patient.ID,
  15370. Certno: res.Output.Baseinfo.Certno,
  15371. Gend: res.Output.Baseinfo.Gend,
  15372. Naty: res.Output.Baseinfo.Naty,
  15373. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15374. PsnName: res.Output.Baseinfo.PsnName,
  15375. Idetinfo: idetinfoStr,
  15376. Insuinfo: infoStr,
  15377. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15378. CardInfo: "",
  15379. VerifyNumber: token,
  15380. InsuplcAdmdvs: ele.Data.InsuOrg,
  15381. }
  15382. service.CreateHisPsn(psn)
  15383. var rf []*ResultFive
  15384. json.Unmarshal([]byte(infoStr), &rf)
  15385. var insutypes []*ResultFive
  15386. var insutype string
  15387. var is390 int = 0
  15388. var is310 int = 0
  15389. for _, item := range rf {
  15390. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15391. insutypes = append(insutypes, item)
  15392. }
  15393. }
  15394. if len(insutypes) == 1 {
  15395. insutype = insutypes[0].Insutype
  15396. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15397. } else {
  15398. for _, i := range insutypes {
  15399. if i.Insutype == "390" {
  15400. is390 = 1
  15401. }
  15402. if i.Insutype == "310" {
  15403. is310 = 1
  15404. }
  15405. }
  15406. }
  15407. if is390 == 1 {
  15408. insutype = "390"
  15409. }
  15410. if is310 == 1 {
  15411. insutype = "310"
  15412. }
  15413. if len(insutypes) == 0 {
  15414. insutype = "310"
  15415. }
  15416. c.ServeSuccessJSON(map[string]interface{}{
  15417. "patient": patient,
  15418. "number": token,
  15419. "insutype": insutype,
  15420. })
  15421. }
  15422. } else {
  15423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15424. return
  15425. }
  15426. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15427. //if initFlag == 0 {
  15428. c.TestGetJiangXiBasBaseInit()
  15429. //}
  15430. //if initEleFlag == 0 {
  15431. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15432. //}
  15433. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15434. type ELeData struct {
  15435. Data struct {
  15436. IdNo string `json:"idNo"`
  15437. IdType string `json:"idType"`
  15438. UserName string `json:"userName"`
  15439. EcToken string `json:"ecToken"`
  15440. InsuOrg string `json:"insuOrg"`
  15441. Gender string `json:"gender"`
  15442. Birthday string `json:"birthday"`
  15443. Nationality string `json:"nationality"`
  15444. Email string `json:"email"`
  15445. Extra string `json:"extra"`
  15446. } `json:"data"`
  15447. Code int `json:"code"`
  15448. Message string `json:"message"`
  15449. }
  15450. var ele ELeData
  15451. err := json.Unmarshal([]byte(json_result), &ele)
  15452. if err != nil {
  15453. utils.ErrorLog("解析失败:%v", err)
  15454. }
  15455. token := ele.Data.EcToken
  15456. token = Remove0000(token)
  15457. 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)
  15458. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15459. var res ResultTwo
  15460. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15461. utils.ErrorLog("解析失败:%v", err)
  15462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15463. return
  15464. }
  15465. if res.Infcode == 0 {
  15466. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15467. if err == gorm.ErrRecordNotFound {
  15468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15469. return
  15470. } else if err != nil {
  15471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15472. return
  15473. } else {
  15474. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15475. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15476. infoStr := string(Iinfos)
  15477. idetinfoStr := string(Idetinfos)
  15478. psn := &models.HisPsn{
  15479. PsnNo: res.Output.Baseinfo.PsnNo,
  15480. PatientId: patient.ID,
  15481. Certno: res.Output.Baseinfo.Certno,
  15482. Gend: res.Output.Baseinfo.Gend,
  15483. Naty: res.Output.Baseinfo.Naty,
  15484. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15485. PsnName: res.Output.Baseinfo.PsnName,
  15486. Idetinfo: idetinfoStr,
  15487. Insuinfo: infoStr,
  15488. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15489. CardInfo: "",
  15490. VerifyNumber: token,
  15491. }
  15492. service.CreateHisPsn(psn)
  15493. var rf []*ResultFive
  15494. json.Unmarshal([]byte(infoStr), &rf)
  15495. var insutypes []*ResultFive
  15496. var insutype string
  15497. var is390 int = 0
  15498. var is310 int = 0
  15499. for _, item := range rf {
  15500. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15501. insutypes = append(insutypes, item)
  15502. }
  15503. }
  15504. if len(insutypes) == 1 {
  15505. insutype = insutypes[0].Insutype
  15506. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15507. } else {
  15508. for _, i := range insutypes {
  15509. if i.Insutype == "390" {
  15510. is390 = 1
  15511. }
  15512. if i.Insutype == "310" {
  15513. is310 = 1
  15514. }
  15515. }
  15516. }
  15517. if is390 == 1 {
  15518. insutype = "390"
  15519. }
  15520. if is310 == 1 {
  15521. insutype = "310"
  15522. }
  15523. if len(insutypes) == 0 {
  15524. insutype = "310"
  15525. }
  15526. c.ServeSuccessJSON(map[string]interface{}{
  15527. "patient": patient,
  15528. "number": token,
  15529. "insutype": insutype,
  15530. })
  15531. }
  15532. } else {
  15533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15534. return
  15535. }
  15536. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15537. type ELeData struct {
  15538. Code string `json:"code"`
  15539. Data struct {
  15540. Aac002 string `json:"aac002"`
  15541. Aaz500 string `json:"aaz500"`
  15542. ActCardNo string `json:"actCardNo"`
  15543. Bab520 string `json:"bab520"`
  15544. Bkz543 string `json:"bkz543"`
  15545. BusinessType string `json:"businessType"`
  15546. CertfCodg string `json:"certfCodg"`
  15547. EcIndexNo string `json:"ecIndexNo"`
  15548. EcToken string `json:"ecToken"`
  15549. ID0000 string `json:"id0000"`
  15550. IDNo string `json:"idNo"`
  15551. IDType string `json:"idType"`
  15552. Idcode string `json:"idcode"`
  15553. IdentityToken string `json:"identity_token"`
  15554. InsuOrg string `json:"insuOrg"`
  15555. OfficeID string `json:"officeId"`
  15556. OfficeName string `json:"officeName"`
  15557. OperatorID string `json:"operatorId"`
  15558. OperatorName string `json:"operatorName"`
  15559. OrgID string `json:"orgId"`
  15560. UserName string `json:"userName"`
  15561. } `json:"data"`
  15562. Infno interface{} `json:"infno"`
  15563. Message string `json:"message"`
  15564. OrgID string `json:"orgId"`
  15565. TransType string `json:"transType"`
  15566. }
  15567. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  15568. outPutInfo = Remove0000(outPutInfo)
  15569. if len(outPutInfo) > 0 {
  15570. var ele ELeData
  15571. err := json.Unmarshal([]byte(outPutInfo), &ele)
  15572. if err != nil {
  15573. utils.ErrorLog("解析失败:%v", err)
  15574. }
  15575. token := ele.Data.EcToken
  15576. fmt.Println(inputInfo)
  15577. fmt.Println(outPutInfo)
  15578. 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)
  15579. saveLog(result, requestLog, "1101", "获取人员信息")
  15580. var dat map[string]interface{}
  15581. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15582. fmt.Println(dat)
  15583. } else {
  15584. fmt.Println(err)
  15585. }
  15586. userJSONBytes, _ := json.Marshal(dat)
  15587. var res ResultTwo
  15588. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15589. utils.ErrorLog("解析失败:%v", err)
  15590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15591. return
  15592. }
  15593. res.ErrMsg = errMsgLog
  15594. if res.Infcode == 0 {
  15595. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  15596. if err == gorm.ErrRecordNotFound {
  15597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15598. return
  15599. } else if err != nil {
  15600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15601. return
  15602. } else {
  15603. fmt.Println(res)
  15604. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15605. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15606. infoStr := string(Iinfos)
  15607. idetinfoStr := string(Idetinfos)
  15608. psn := &models.HisPsn{
  15609. PsnNo: res.Output.Baseinfo.PsnNo,
  15610. PatientId: patient.ID,
  15611. Certno: res.Output.Baseinfo.Certno,
  15612. Gend: res.Output.Baseinfo.Gend,
  15613. Naty: res.Output.Baseinfo.Naty,
  15614. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15615. PsnName: res.Output.Baseinfo.PsnName,
  15616. Idetinfo: idetinfoStr,
  15617. Insuinfo: infoStr,
  15618. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15619. CardInfo: outPutInfo,
  15620. VerifyNumber: token,
  15621. InsuplcAdmdvs: ele.Data.InsuOrg,
  15622. }
  15623. service.CreateHisPsn(psn)
  15624. var rf []*ResultFive
  15625. json.Unmarshal([]byte(infoStr), &rf)
  15626. var insutypes []*ResultFive
  15627. var insutype string
  15628. var is390 int = 0
  15629. var is310 int = 0
  15630. for _, item := range rf {
  15631. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15632. insutypes = append(insutypes, item)
  15633. }
  15634. }
  15635. if len(insutypes) == 1 {
  15636. insutype = insutypes[0].Insutype
  15637. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15638. } else {
  15639. for _, i := range insutypes {
  15640. if i.Insutype == "390" {
  15641. is390 = 1
  15642. }
  15643. if i.Insutype == "310" {
  15644. is310 = 1
  15645. }
  15646. }
  15647. }
  15648. if is390 == 1 {
  15649. insutype = "390"
  15650. }
  15651. if is310 == 1 {
  15652. insutype = "310"
  15653. }
  15654. if len(insutypes) == 0 {
  15655. insutype = "310"
  15656. }
  15657. c.ServeSuccessJSON(map[string]interface{}{
  15658. "patient": patient,
  15659. "number": token,
  15660. "insutype": insutype,
  15661. })
  15662. }
  15663. } else {
  15664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15665. return
  15666. }
  15667. }
  15668. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15669. var api string
  15670. 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 +
  15671. "&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
  15672. resp, requestErr := http.Get(api)
  15673. if requestErr != nil {
  15674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15675. return
  15676. }
  15677. body, ioErr := ioutil.ReadAll(resp.Body)
  15678. if ioErr != nil {
  15679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15681. return
  15682. }
  15683. var respJSON map[string]interface{}
  15684. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15685. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15687. return
  15688. }
  15689. var status string
  15690. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15691. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15692. var token string
  15693. var res ResultTwo //1101结果
  15694. var res10265 ResultTwo10265 //1101结果
  15695. if status == "0" { //读卡成功
  15696. var card_info string //卡信息
  15697. var busi_card_info string
  15698. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15699. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15700. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15701. fmt.Println(card_info)
  15702. fmt.Println(busi_card_info)
  15703. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15704. result, _ := json.Marshal(respJSON)
  15705. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15706. utils.ErrorLog("解析失败:%v", err)
  15707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15708. return
  15709. }
  15710. res.ErrMsg = res10265.ErrMsg
  15711. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15712. res.Infcode = infocode
  15713. res.Output = res10265.Output
  15714. res.InfRefmsgid = res10265.InfRefmsgid
  15715. if res.Infcode == 0 {
  15716. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15717. if err == gorm.ErrRecordNotFound {
  15718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15719. return
  15720. } else if err != nil {
  15721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15722. return
  15723. } else {
  15724. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15725. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15726. infoStr := string(Iinfos)
  15727. idetinfoStr := string(Idetinfos)
  15728. psn := &models.HisPsn{
  15729. PsnNo: res.Output.Baseinfo.PsnNo,
  15730. PatientId: patient.ID,
  15731. Certno: res.Output.Baseinfo.Certno,
  15732. Gend: res.Output.Baseinfo.Gend,
  15733. Naty: res.Output.Baseinfo.Naty,
  15734. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15735. PsnName: res.Output.Baseinfo.PsnName,
  15736. Idetinfo: idetinfoStr,
  15737. Insuinfo: infoStr,
  15738. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15739. CardInfo: card_info,
  15740. VerifyNumber: token,
  15741. }
  15742. var rf []*ResultFive
  15743. json.Unmarshal([]byte(infoStr), &rf)
  15744. var insutypes []*ResultFive
  15745. var insutype string
  15746. var is390 int = 0
  15747. var is310 int = 0
  15748. for _, item := range rf {
  15749. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15750. insutypes = append(insutypes, item)
  15751. }
  15752. }
  15753. if len(insutypes) == 1 {
  15754. insutype = insutypes[0].Insutype
  15755. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15756. } else {
  15757. for _, i := range insutypes {
  15758. if i.Insutype == "390" {
  15759. is390 = 1
  15760. }
  15761. if i.Insutype == "310" {
  15762. is310 = 1
  15763. }
  15764. }
  15765. }
  15766. if is390 == 1 {
  15767. insutype = "390"
  15768. }
  15769. if is310 == 1 {
  15770. insutype = "310"
  15771. }
  15772. if len(insutypes) == 0 {
  15773. insutype = "310"
  15774. }
  15775. service.CreateHisPsn(psn)
  15776. c.ServeSuccessJSON(map[string]interface{}{
  15777. "patient": patient,
  15778. "number": token,
  15779. "insutype": insutype,
  15780. })
  15781. }
  15782. } else {
  15783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15784. return
  15785. }
  15786. } else { //读卡失败
  15787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15788. return
  15789. }
  15790. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15791. res := c.GetoleInfo()
  15792. if res.Infcode == 0 {
  15793. var result string
  15794. if res.Output.MdtrtCertType == "01" {
  15795. 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)
  15796. } else if res.Output.MdtrtCertType == "02" {
  15797. 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)
  15798. } else if res.Output.MdtrtCertType == "03" {
  15799. 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)
  15800. }
  15801. var dat map[string]interface{}
  15802. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15803. fmt.Println(dat)
  15804. } else {
  15805. fmt.Println(err)
  15806. }
  15807. userJSONBytes, _ := json.Marshal(dat)
  15808. var res2 ResultTwo
  15809. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15810. utils.ErrorLog("解析失败:%v", err)
  15811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15812. return
  15813. }
  15814. if res2.Infcode == 0 {
  15815. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15816. if err == gorm.ErrRecordNotFound {
  15817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15818. return
  15819. } else if err != nil {
  15820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15821. return
  15822. } else {
  15823. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15824. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15825. infoStr := string(Iinfos)
  15826. idetinfoStr := string(Idetinfos)
  15827. var rf []*ResultFive
  15828. json.Unmarshal([]byte(infoStr), &rf)
  15829. var insutypes []*ResultFive
  15830. var insutype string
  15831. var is390 int = 0
  15832. var is310 int = 0
  15833. //var insuplc_admdvs string
  15834. for _, item := range rf {
  15835. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15836. insutypes = append(insutypes, item)
  15837. }
  15838. }
  15839. if len(insutypes) == 1 {
  15840. insutype = insutypes[0].Insutype
  15841. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15842. } else {
  15843. for _, i := range insutypes {
  15844. if i.Insutype == "390" {
  15845. is390 = 1
  15846. }
  15847. if i.Insutype == "310" {
  15848. is310 = 1
  15849. }
  15850. }
  15851. }
  15852. if is390 == 1 {
  15853. insutype = "390"
  15854. }
  15855. if is310 == 1 {
  15856. insutype = "310"
  15857. }
  15858. if len(insutypes) == 0 {
  15859. insutype = "310"
  15860. }
  15861. psn := &models.HisPsn{
  15862. PsnNo: res2.Output.Baseinfo.PsnNo,
  15863. PatientId: patient.ID,
  15864. Certno: res2.Output.Baseinfo.Certno,
  15865. Gend: res2.Output.Baseinfo.Gend,
  15866. Naty: res2.Output.Baseinfo.Naty,
  15867. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15868. PsnName: res2.Output.Baseinfo.PsnName,
  15869. Idetinfo: idetinfoStr,
  15870. Insuinfo: infoStr,
  15871. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15872. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15873. VerifyNumber: res.Output.EcToken,
  15874. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15875. }
  15876. if res.Output.MdtrtCertType == "01" {
  15877. psn.VerifyNumber = res.Output.EcToken
  15878. //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)
  15879. } else if res.Output.MdtrtCertType == "02" {
  15880. psn.VerifyNumber = res.Output.CardNo
  15881. //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)
  15882. } else if res.Output.MdtrtCertType == "03" {
  15883. psn.VerifyNumber = res.Output.MdtrtCertNo
  15884. //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)
  15885. }
  15886. service.CreateHisPsn(psn)
  15887. var balc float64
  15888. for _, item := range rf {
  15889. if item.Insutype == insutype {
  15890. balc = item.Balc
  15891. }
  15892. }
  15893. c.ServeSuccessJSON(map[string]interface{}{
  15894. "patient": patient,
  15895. "number": res.Output.CardNo,
  15896. "insutype": insutype,
  15897. "blac": balc,
  15898. "desc": idetinfoStr,
  15899. })
  15900. }
  15901. } else {
  15902. c.ServeSuccessJSON(map[string]interface{}{
  15903. "failed_code": -10,
  15904. "msg": res2.ErrMsg,
  15905. })
  15906. }
  15907. } else {
  15908. c.ServeSuccessJSON(map[string]interface{}{
  15909. "failed_code": -10,
  15910. "msg": res.ErrMsg,
  15911. })
  15912. }
  15913. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15914. var res ResultTwo
  15915. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15916. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15917. "&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)
  15918. resp, requestErr := http.Get(api)
  15919. if requestErr != nil {
  15920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15921. return
  15922. }
  15923. body, ioErr := ioutil.ReadAll(resp.Body)
  15924. if ioErr != nil {
  15925. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15927. return
  15928. }
  15929. var respJSON map[string]interface{}
  15930. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15933. return
  15934. }
  15935. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15936. result, _ := json.Marshal(respJSON)
  15937. fmt.Println("log")
  15938. fmt.Println(string(result))
  15939. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15940. utils.ErrorLog("解析失败:%v", err)
  15941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15942. return
  15943. }
  15944. if res.Infcode == 0 {
  15945. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15946. if err == gorm.ErrRecordNotFound {
  15947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15948. return
  15949. } else if err != nil {
  15950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15951. return
  15952. } else {
  15953. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15954. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15955. infoStr := string(Iinfos)
  15956. idetinfoStr := string(Idetinfos)
  15957. var rf []*ResultFive
  15958. json.Unmarshal([]byte(infoStr), &rf)
  15959. var insutypes []*ResultFive
  15960. var insutype string
  15961. var is390 int = 0
  15962. var is310 int = 0
  15963. for _, item := range rf {
  15964. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15965. insutypes = append(insutypes, item)
  15966. }
  15967. }
  15968. if len(insutypes) == 1 {
  15969. insutype = insutypes[0].Insutype
  15970. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15971. } else {
  15972. for _, i := range insutypes {
  15973. if i.Insutype == "390" {
  15974. is390 = 1
  15975. }
  15976. if i.Insutype == "310" {
  15977. is310 = 1
  15978. }
  15979. }
  15980. }
  15981. if is390 == 1 {
  15982. insutype = "390"
  15983. }
  15984. if is310 == 1 {
  15985. insutype = "310"
  15986. }
  15987. if len(insutypes) == 0 {
  15988. insutype = "390"
  15989. }
  15990. var insuplc_admdvs string
  15991. for _, item := range rf {
  15992. if item.Insutype == insutype {
  15993. insuplc_admdvs = item.InsuplcAdmdvs
  15994. }
  15995. }
  15996. psn := &models.HisPsn{
  15997. PsnNo: res.Output.Baseinfo.PsnNo,
  15998. PatientId: patient.ID,
  15999. Certno: res.Output.Baseinfo.Certno,
  16000. Gend: res.Output.Baseinfo.Gend,
  16001. Naty: res.Output.Baseinfo.Naty,
  16002. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16003. PsnName: res.Output.Baseinfo.PsnName,
  16004. Idetinfo: idetinfoStr,
  16005. Insuinfo: infoStr,
  16006. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16007. InsuplcAdmdvs: insuplc_admdvs,
  16008. }
  16009. service.CreateHisPsn(psn)
  16010. c.ServeSuccessJSON(map[string]interface{}{
  16011. "patient": patient,
  16012. "number": res.Output.Baseinfo.Certno,
  16013. })
  16014. }
  16015. } else {
  16016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16017. return
  16018. }
  16019. } else {
  16020. type ELeData struct {
  16021. Code string `json:"code"`
  16022. Data struct {
  16023. Aac002 string `json:"aac002"`
  16024. Aaz500 string `json:"aaz500"`
  16025. ActCardNo string `json:"actCardNo"`
  16026. Bab520 string `json:"bab520"`
  16027. Bkz543 string `json:"bkz543"`
  16028. BusinessType string `json:"businessType"`
  16029. CertfCodg string `json:"certfCodg"`
  16030. EcIndexNo string `json:"ecIndexNo"`
  16031. EcToken string `json:"ecToken"`
  16032. ID0000 string `json:"id0000"`
  16033. IDNo string `json:"idNo"`
  16034. IDType string `json:"idType"`
  16035. Idcode string `json:"idcode"`
  16036. IdentityToken string `json:"identity_token"`
  16037. InsuOrg string `json:"insuOrg"`
  16038. OfficeID string `json:"officeId"`
  16039. OfficeName string `json:"officeName"`
  16040. OperatorID string `json:"operatorId"`
  16041. OperatorName string `json:"operatorName"`
  16042. OrgID string `json:"orgId"`
  16043. UserName string `json:"userName"`
  16044. } `json:"data"`
  16045. Infno interface{} `json:"infno"`
  16046. Message string `json:"message"`
  16047. OrgID string `json:"orgId"`
  16048. TransType string `json:"transType"`
  16049. }
  16050. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16051. fmt.Println(result)
  16052. outPutInfo := Remove0000(result)
  16053. fmt.Println(outPutInfo)
  16054. if len(outPutInfo) > 0 {
  16055. var ele ELeData
  16056. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16057. if err != nil {
  16058. utils.ErrorLog("解析失败:%v", err)
  16059. }
  16060. token := ele.Data.EcToken
  16061. fmt.Println(outPutInfo)
  16062. 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)
  16063. saveLog(result, requestLog, "1101", "获取人员信息")
  16064. var dat map[string]interface{}
  16065. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16066. fmt.Println(dat)
  16067. } else {
  16068. fmt.Println(err)
  16069. }
  16070. userJSONBytes, _ := json.Marshal(dat)
  16071. var res ResultTwo
  16072. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16073. utils.ErrorLog("解析失败:%v", err)
  16074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16075. return
  16076. }
  16077. if res.Infcode == 0 {
  16078. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16079. if err == gorm.ErrRecordNotFound {
  16080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16081. return
  16082. } else if err != nil {
  16083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16084. return
  16085. } else {
  16086. fmt.Println(res)
  16087. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16088. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16089. infoStr := string(Iinfos)
  16090. idetinfoStr := string(Idetinfos)
  16091. psn := &models.HisPsn{
  16092. PsnNo: res.Output.Baseinfo.PsnNo,
  16093. PatientId: patient.ID,
  16094. Certno: res.Output.Baseinfo.Certno,
  16095. Gend: res.Output.Baseinfo.Gend,
  16096. Naty: res.Output.Baseinfo.Naty,
  16097. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16098. PsnName: res.Output.Baseinfo.PsnName,
  16099. Idetinfo: idetinfoStr,
  16100. Insuinfo: infoStr,
  16101. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16102. CardInfo: outPutInfo,
  16103. VerifyNumber: token,
  16104. InsuplcAdmdvs: ele.Data.InsuOrg,
  16105. }
  16106. service.CreateHisPsn(psn)
  16107. var rf []*ResultFive
  16108. json.Unmarshal([]byte(infoStr), &rf)
  16109. var insutypes []*ResultFive
  16110. var insutype string
  16111. var is390 int = 0
  16112. var is310 int = 0
  16113. for _, item := range rf {
  16114. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16115. insutypes = append(insutypes, item)
  16116. }
  16117. }
  16118. if len(insutypes) == 1 {
  16119. insutype = insutypes[0].Insutype
  16120. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16121. } else {
  16122. for _, i := range insutypes {
  16123. if i.Insutype == "390" {
  16124. is390 = 1
  16125. }
  16126. if i.Insutype == "310" {
  16127. is310 = 1
  16128. }
  16129. }
  16130. }
  16131. if is390 == 1 {
  16132. insutype = "390"
  16133. }
  16134. if is310 == 1 {
  16135. insutype = "310"
  16136. }
  16137. if len(insutypes) == 0 {
  16138. insutype = "310"
  16139. }
  16140. c.ServeSuccessJSON(map[string]interface{}{
  16141. "patient": patient,
  16142. "number": token,
  16143. "insutype": insutype,
  16144. })
  16145. }
  16146. } else {
  16147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16148. return
  16149. }
  16150. }
  16151. //fmt.Println(result)
  16152. //
  16153. //if initFlag == 0 {
  16154. // c.TestGetBasBaseInit()
  16155. //}
  16156. //token := c.GetEleBaseInfo()
  16157. //
  16158. //token = Remove0000(token)
  16159. //
  16160. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16161. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16162. ////
  16163. //var res ResultTwo
  16164. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16165. // utils.ErrorLog("解析失败:%v", err)
  16166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16167. // return
  16168. //}
  16169. //
  16170. //if res.Infcode == 0 {
  16171. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16172. // if err == gorm.ErrRecordNotFound {
  16173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16174. // return
  16175. // } else if err != nil {
  16176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16177. // return
  16178. //
  16179. // } else {
  16180. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16181. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16182. // infoStr := string(Iinfos)
  16183. // idetinfoStr := string(Idetinfos)
  16184. //
  16185. //
  16186. //
  16187. //
  16188. // var rf []*ResultFive
  16189. // json.Unmarshal([]byte(infoStr), &rf)
  16190. //
  16191. // var insutypes []*ResultFive
  16192. // var insutype string
  16193. // var is390 int = 0
  16194. // var is310 int = 0
  16195. // var insuplc_admdvs string
  16196. //
  16197. // for _, item := range rf {
  16198. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16199. // insutypes = append(insutypes, item)
  16200. // }
  16201. // }
  16202. //
  16203. // if len(insutypes) == 1 {
  16204. // insutype = insutypes[0].Insutype
  16205. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16206. // } else {
  16207. // for _, i := range insutypes {
  16208. // if i.Insutype == "390" {
  16209. // is390 = 1
  16210. // }
  16211. //
  16212. // if i.Insutype == "310" {
  16213. // is310 = 1
  16214. // }
  16215. // }
  16216. // }
  16217. // if is390 == 1 {
  16218. // insutype = "390"
  16219. // }
  16220. //
  16221. // if is310 == 1 {
  16222. // insutype = "310"
  16223. // }
  16224. // if len(insutypes) == 0 {
  16225. // insutype = "310"
  16226. // }
  16227. // for _, item := range rf {
  16228. // if item.Insutype == insutype {
  16229. // insuplc_admdvs = item.InsuplcAdmdvs
  16230. // }
  16231. // }
  16232. // psn := &models.HisPsn{
  16233. // PsnNo: res.Output.Baseinfo.PsnNo,
  16234. // Age: res.Output.Baseinfo.Age,
  16235. // PatientId: patient.ID,
  16236. // Certno: res.Output.Baseinfo.Certno,
  16237. // Brdy: res.Output.Baseinfo.Brdy,
  16238. // Gend: res.Output.Baseinfo.Gend,
  16239. // Naty: res.Output.Baseinfo.Naty,
  16240. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16241. // PsnName: res.Output.Baseinfo.PsnName,
  16242. // Idetinfo: idetinfoStr,
  16243. // Insuinfo: infoStr,
  16244. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16245. // CardInfo: "",
  16246. // VerifyNumber: token,
  16247. // InsuplcAdmdvs: insuplc_admdvs,
  16248. // }
  16249. // service.CreateHisPsn(psn)
  16250. //
  16251. // c.ServeSuccessJSON(map[string]interface{}{
  16252. // "patient": patient,
  16253. // "number": token,
  16254. // })
  16255. // }
  16256. //} else {
  16257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16258. // return
  16259. //}
  16260. }
  16261. break
  16262. case 5:
  16263. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16264. var api string
  16265. if miConfig.MdtrtareaAdmvs == "320921" {
  16266. 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 +
  16267. "&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
  16268. fmt.Println(api)
  16269. } else {
  16270. 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 +
  16271. "&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)
  16272. }
  16273. resp, requestErr := http.Get(api)
  16274. if requestErr != nil {
  16275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16276. return
  16277. }
  16278. body, ioErr := ioutil.ReadAll(resp.Body)
  16279. if ioErr != nil {
  16280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16282. return
  16283. }
  16284. var respJSON map[string]interface{}
  16285. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16288. return
  16289. }
  16290. var status string
  16291. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16292. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16293. var token string
  16294. var res ResultTwo //1101结果
  16295. var res10265 ResultTwo10265 //1101结果
  16296. if status == "0" { //读卡成功
  16297. var card_info string //卡信息
  16298. //var busi_card_info string
  16299. var auth_info string
  16300. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16301. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16302. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16303. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16304. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16305. result, _ := json.Marshal(respJSON)
  16306. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16307. utils.ErrorLog("解析失败:%v", err)
  16308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16309. return
  16310. }
  16311. res.ErrMsg = res10265.ErrMsg
  16312. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16313. res.Infcode = infocode
  16314. res.Output = res10265.Output
  16315. res.InfRefmsgid = res10265.InfRefmsgid
  16316. if res.Infcode == 0 {
  16317. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16318. if err == gorm.ErrRecordNotFound {
  16319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16320. return
  16321. } else if err != nil {
  16322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16323. return
  16324. } else {
  16325. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16326. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16327. infoStr := string(Iinfos)
  16328. idetinfoStr := string(Idetinfos)
  16329. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16330. psn := &models.HisPsn{
  16331. PsnNo: res.Output.Baseinfo.PsnNo,
  16332. PatientId: patient.ID,
  16333. Certno: res.Output.Baseinfo.Certno,
  16334. Gend: res.Output.Baseinfo.Gend,
  16335. Brdy: b,
  16336. Age: float64(age),
  16337. Naty: res.Output.Baseinfo.Naty,
  16338. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16339. PsnName: res.Output.Baseinfo.PsnName,
  16340. Idetinfo: idetinfoStr,
  16341. Insuinfo: infoStr,
  16342. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16343. CardInfo: card_info,
  16344. VerifyNumber: token,
  16345. AuthInfo: auth_info,
  16346. }
  16347. var rf []*ResultFive
  16348. json.Unmarshal([]byte(infoStr), &rf)
  16349. var insutypes []*ResultFive
  16350. var insutype string
  16351. var is390 int = 0
  16352. var is310 int = 0
  16353. for _, item := range rf {
  16354. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16355. insutypes = append(insutypes, item)
  16356. }
  16357. }
  16358. if len(insutypes) == 1 {
  16359. insutype = insutypes[0].Insutype
  16360. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16361. } else {
  16362. for _, i := range insutypes {
  16363. if i.Insutype == "390" {
  16364. is390 = 1
  16365. }
  16366. if i.Insutype == "310" {
  16367. is310 = 1
  16368. }
  16369. }
  16370. }
  16371. if is390 == 1 {
  16372. insutype = "390"
  16373. }
  16374. if is310 == 1 {
  16375. insutype = "310"
  16376. }
  16377. if len(insutypes) == 0 {
  16378. insutype = "310"
  16379. }
  16380. service.CreateHisPsn(psn)
  16381. c.ServeSuccessJSON(map[string]interface{}{
  16382. "patient": patient,
  16383. "number": token,
  16384. "insutype": insutype,
  16385. })
  16386. }
  16387. } else {
  16388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16389. return
  16390. }
  16391. } else { //读卡失败
  16392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16393. return
  16394. }
  16395. }
  16396. break
  16397. }
  16398. }
  16399. var initFlag int64 = 0
  16400. var initEleFlag int64 = 0
  16401. func (c *HisApiController) TestGetBasBaseInit() {
  16402. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16403. Iinit := DllDef.MustFindProc("Init")
  16404. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16405. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  16406. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  16407. if ret != 0 {
  16408. fmt.Println("SSCard的报错原因:", err)
  16409. fmt.Println("SSCard的运算结果为:", ret)
  16410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16411. return
  16412. }
  16413. result := int(ret)
  16414. fmt.Println("SSCard的运算结果为1:", result)
  16415. initFlag = 1
  16416. return
  16417. }
  16418. func (c *HisApiController) HandleJiangXiReadCard() {
  16419. fmt.Println("~~~~~~")
  16420. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16421. admin_user_id, _ := c.GetInt64("admin_user_id")
  16422. id_card_type, _ := c.GetInt64("id_card_type")
  16423. //certificates, _ := c.GetInt64("certificates")
  16424. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16425. if initFlag == 0 {
  16426. c.TestGetJiangXiBasBaseInit()
  16427. }
  16428. basStr := c.GetBasBaseInfo()
  16429. if len(basStr) == 0 {
  16430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16431. return
  16432. }
  16433. fmt.Println(basStr)
  16434. bas := strings.Split(basStr, "|")
  16435. basNumber := bas[1]
  16436. fmt.Println(basNumber)
  16437. card_sn := bas[3]
  16438. fmt.Println(card_sn)
  16439. 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, "")
  16440. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  16441. var dat map[string]interface{}
  16442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16443. fmt.Println(dat)
  16444. } else {
  16445. fmt.Println(err)
  16446. }
  16447. userJSONBytes, _ := json.Marshal(dat)
  16448. var res ResultTwo
  16449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16450. utils.ErrorLog("解析失败:%v", err)
  16451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16452. return
  16453. }
  16454. if res.Infcode == 0 {
  16455. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  16456. if err == gorm.ErrRecordNotFound {
  16457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16458. return
  16459. } else if err != nil {
  16460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16461. return
  16462. } else {
  16463. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16464. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16465. infoStr := string(Iinfos)
  16466. idetinfoStr := string(Idetinfos)
  16467. psn := &models.HisPsn{
  16468. PsnNo: res.Output.Baseinfo.PsnNo,
  16469. PatientId: patient.ID,
  16470. Certno: res.Output.Baseinfo.Certno,
  16471. Gend: res.Output.Baseinfo.Gend,
  16472. Naty: res.Output.Baseinfo.Naty,
  16473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16474. PsnName: res.Output.Baseinfo.PsnName,
  16475. Idetinfo: idetinfoStr,
  16476. Insuinfo: infoStr,
  16477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16478. CardInfo: basStr,
  16479. VerifyNumber: "",
  16480. }
  16481. service.CreateHisPsn(psn)
  16482. c.ServeSuccessJSON(map[string]interface{}{
  16483. "patient": patient,
  16484. "number": basNumber,
  16485. })
  16486. }
  16487. } else {
  16488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16489. return
  16490. }
  16491. }
  16492. func (c *HisApiController) TestGetHnBasBaseInit() {
  16493. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16494. Iinit := DllDef.MustFindProc("Init")
  16495. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16496. //http://10.77.211.236/CSB/hsa-fsi-1303
  16497. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  16498. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  16499. // 调用 Init 函数
  16500. ret, _, err := Iinit.Call(uintptr(unsafe.Pointer(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"))), uintptr(unsafe.Pointer(StrPtr("430800|scr.hun.hsip.gov.cn"))))
  16501. //if ret != 0 {
  16502. fmt.Println("SSCard的报错原因:", err)
  16503. fmt.Println("SSCard的运算结果为:", ret)
  16504. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16505. // return
  16506. //}
  16507. result := int(ret)
  16508. fmt.Println("SSCard的运算结果为1:", result)
  16509. initFlag = 1
  16510. return
  16511. }
  16512. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  16513. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16514. Iinit := DllDef.MustFindProc("Init")
  16515. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16516. //http://10.77.211.236/CSB/hsa-fsi-1303
  16517. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  16518. if ret != 0 {
  16519. fmt.Println("SSCard的报错原因:", err)
  16520. fmt.Println("SSCard的运算结果为:", ret)
  16521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16522. return
  16523. }
  16524. result := int(ret)
  16525. fmt.Println("SSCard的运算结果为1:", result)
  16526. initFlag = 1
  16527. return
  16528. }
  16529. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  16530. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16531. Iinit := DllDef.MustFindProc("Init")
  16532. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16533. //http://10.77.211.236/CSB/hsa-fsi-1303
  16534. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  16535. if ret != 0 {
  16536. fmt.Println("SSCard的报错原因:", err)
  16537. fmt.Println("SSCard的运算结果为:", ret)
  16538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16539. return
  16540. }
  16541. result := int(ret)
  16542. fmt.Println("SSCard的运算结果为1:", result)
  16543. initFlag = 1
  16544. return
  16545. }
  16546. func (c *HisApiController) GetSFZBaseInfo() string {
  16547. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16548. readCard := DllDef.MustFindProc("ReadSFZ")
  16549. if readCard == nil {
  16550. fmt.Println("readcard is nil")
  16551. readCard = DllDef.MustFindProc("ReadSFZ")
  16552. }
  16553. str := make([]byte, 8096)
  16554. str1 := make([]byte, 8096)
  16555. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  16556. fmt.Println(r)
  16557. return Remove0000(string(str))
  16558. }
  16559. func (c *HisApiController) GetEleBaseInfo() string {
  16560. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16561. readCard := DllDef.MustFindProc("GetQRBase")
  16562. fmt.Println(readCard)
  16563. if readCard == nil {
  16564. fmt.Println("readcard is nil")
  16565. readCard = DllDef.MustFindProc("GetQRBase")
  16566. }
  16567. str := make([]byte, 1024)
  16568. str1 := make([]byte, 1024)
  16569. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  16570. fmt.Println(ret2)
  16571. fmt.Println(string(str1))
  16572. fmt.Println(string(str))
  16573. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16574. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16575. if ret2 != 0 {
  16576. return ""
  16577. }
  16578. return string(str)
  16579. }
  16580. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  16581. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16582. readCard := DllDef.MustFindProc("NationEcTrans")
  16583. fmt.Println(readCard)
  16584. fmt.Println("!!!!!")
  16585. pBusiCardInfo := make([]byte, 2048)
  16586. input := make(map[string]interface{})
  16587. inputData := make(map[string]interface{})
  16588. inputData["orgId"] = code
  16589. inputData["businessType"] = "01101"
  16590. inputData["operatorId"] = "1"
  16591. inputData["operatorName"] = "admin"
  16592. inputData["officeId"] = "001"
  16593. inputData["officeName"] = "血透室"
  16594. inputData["deviceType"] = ""
  16595. input["data"] = inputData
  16596. input["orgId"] = code
  16597. input["transType"] = "ec.query"
  16598. bytesData, _ := json.Marshal(input)
  16599. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  16600. fmt.Println(ret2)
  16601. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16602. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16603. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  16604. }
  16605. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  16606. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16607. readCard := DllDef.MustFindProc("NationEcTrans")
  16608. fmt.Println(readCard)
  16609. fmt.Println("!!!!!")
  16610. pBusiCardInfo := make([]byte, 2048)
  16611. input := make(map[string]interface{})
  16612. inputData := make(map[string]interface{})
  16613. inputData["orgId"] = code
  16614. inputData["businessType"] = "01101"
  16615. inputData["operatorId"] = "9"
  16616. inputData["operatorName"] = "admin"
  16617. inputData["officeId"] = "001"
  16618. inputData["officeName"] = "血透室"
  16619. inputData["deviceType"] = ""
  16620. input["data"] = inputData
  16621. input["orgId"] = code
  16622. input["transType"] = "ec.query"
  16623. bytesData, _ := json.Marshal(input)
  16624. 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])))
  16625. fmt.Println(ret2)
  16626. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16627. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16628. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  16629. }
  16630. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  16631. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16632. readCard := DllDef.MustFindProc("NationEcTrans")
  16633. fmt.Println(readCard)
  16634. fmt.Println("!!!!!")
  16635. pBusiCardInfo := make([]byte, 2048)
  16636. input := make(map[string]interface{})
  16637. inputData := make(map[string]interface{})
  16638. inputData["orgId"] = code
  16639. inputData["businessType"] = "01301"
  16640. inputData["operatorId"] = "9"
  16641. inputData["operatorName"] = "admin"
  16642. inputData["officeId"] = "001"
  16643. inputData["officeName"] = "血透室"
  16644. inputData["deviceType"] = ""
  16645. input["data"] = inputData
  16646. input["orgId"] = code
  16647. input["transType"] = "ec.query"
  16648. bytesData, _ := json.Marshal(input)
  16649. 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])))
  16650. fmt.Println(ret2)
  16651. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16652. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16653. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  16654. }
  16655. func GetJxEleBaseInfo(org_id int64) string {
  16656. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16657. readCard := DllDef.MustFindProc("NationEcTrans")
  16658. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16659. if readCard == nil {
  16660. fmt.Println("readcard is nil")
  16661. readCard = DllDef.MustFindProc("NationEcTrans")
  16662. }
  16663. str1 := make([]byte, 1024)
  16664. data := make(map[string]interface{})
  16665. inputData := make(map[string]interface{})
  16666. inputData["orgId"] = miConfig.Code
  16667. inputData["businessType"] = "01101"
  16668. inputData["operatorId"] = "test001"
  16669. inputData["operatorName"] = "cn"
  16670. inputData["officeId"] = "32760"
  16671. inputData["officeName"] = "waike"
  16672. inputData["deviceType"] = ""
  16673. data["data"] = inputData
  16674. data["transType"] = "ec.query"
  16675. data["extra "] = ""
  16676. data["orgId"] = miConfig.Code
  16677. bytesData, _ := json.Marshal(data)
  16678. //bytesData, _ := json.Marshal(data)
  16679. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16680. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16681. fmt.Println(ret2)
  16682. fmt.Println(string(str1))
  16683. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16684. if ret2 != 0 {
  16685. return ""
  16686. }
  16687. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16688. }
  16689. //func GetJxEleBaseInfoTWO(org_id int64) string {
  16690. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  16691. // readCard := DllDef.MustFindProc("NationEcTrans")
  16692. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16693. //
  16694. // if readCard == nil {
  16695. // fmt.Println("readcard is nil")
  16696. // readCard = DllDef.MustFindProc("NationEcTrans")
  16697. // }
  16698. // str1 := make([]byte, 1024)
  16699. //
  16700. // data := make(map[string]interface{})
  16701. //
  16702. // inputData := make(map[string]interface{})
  16703. // inputData["orgId"] = miConfig.Code
  16704. // inputData["businessType"] = "01101"
  16705. // inputData["operatorId"] = "test001"
  16706. // inputData["operatorName"] = "cn"
  16707. // inputData["officeId"] = "32760"
  16708. // inputData["officeName"] = "waike"
  16709. // inputData["deviceType"] = ""
  16710. //
  16711. // data["data"] = inputData
  16712. // data["transType"] = "ec.query"
  16713. // data["extra "] = ""
  16714. // data["orgId"] = miConfig.Code
  16715. // bytesData, _ := json.Marshal(data)
  16716. // //bytesData, _ := json.Marshal(data)
  16717. //
  16718. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16719. //
  16720. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16721. // fmt.Println(ret2)
  16722. // fmt.Println(string(str1))
  16723. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16724. //
  16725. // if ret2 != 0 {
  16726. // return ""
  16727. // }
  16728. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16729. //}
  16730. func GetJxEleBaseInitInfo(org_id int64) string {
  16731. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16732. readCard := DllDef.MustFindProc("NationEcTrans")
  16733. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16734. if readCard == nil {
  16735. fmt.Println("readcard is nil")
  16736. readCard = DllDef.MustFindProc("NationEcTrans")
  16737. }
  16738. str1 := make([]byte, 2048)
  16739. data := make(map[string]interface{})
  16740. inputData := make(map[string]interface{})
  16741. inputData["orgId"] = miConfig.Code
  16742. inputData["businessType"] = "01101"
  16743. inputData["operatorId"] = "1"
  16744. inputData["operatorName"] = "huangchuang"
  16745. inputData["officeId"] = "101"
  16746. inputData["officeName"] = "xuetou"
  16747. inputData["deviceType"] = ""
  16748. data["data"] = inputData
  16749. data["transType"] = "ec.query"
  16750. data["orgId"] = miConfig.Code
  16751. bytesData, _ := json.Marshal(data)
  16752. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16753. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16754. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  16755. fmt.Println(ret2)
  16756. fmt.Println(string(str1))
  16757. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16758. if ret2 != 0 {
  16759. return ""
  16760. }
  16761. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  16762. initEleFlag = 1
  16763. }
  16764. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16765. }
  16766. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  16767. // // 构建命令
  16768. // cmd := exec.Command("python", "b.py")
  16769. //
  16770. // // 执行命令并等待完成
  16771. // output, err := cmd.CombinedOutput()
  16772. // if err != nil {
  16773. // fmt.Println("Error executing Python script:", err)
  16774. // return
  16775. // }
  16776. //
  16777. // // 打印Python脚本的输出
  16778. // fmt.Println(string(output))
  16779. //}
  16780. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  16781. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  16782. readCard := DllDef.MustFindProc("gxyb_call")
  16783. if readCard == nil {
  16784. fmt.Println("readcard is nil")
  16785. readCard = DllDef.MustFindProc("gxyb_call")
  16786. }
  16787. str := make([]byte, 1024)
  16788. str1 := make([]byte, 1024)
  16789. //data := make(map[string]interface{})
  16790. currentTime := time.Now()
  16791. // 格式化时间为 "YYYYMMDDHH24MISS"
  16792. formattedTime := currentTime.Format("20060102150405")
  16793. inputData := make(map[string]interface{})
  16794. inputData2 := make(map[string]interface{})
  16795. inputData["transNo"] = "1401"
  16796. inputData["transType"] = "passwordCheck"
  16797. inputData["timestamp"] = formattedTime
  16798. inputData2["fixmedinsCode"] = code
  16799. inputData2["psnNo"] = ""
  16800. inputData["data"] = inputData2
  16801. jsonBytes, err := json.Marshal(inputData)
  16802. if err != nil {
  16803. fmt.Println("Error encoding map to JSON:", err)
  16804. }
  16805. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16806. fmt.Println(string(str1))
  16807. fmt.Println(string(str))
  16808. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16809. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16810. if ret2 != 0 {
  16811. return ""
  16812. }
  16813. return string(str)
  16814. }
  16815. func (c *HisApiController) GetoleInfo() Response {
  16816. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  16817. defer ole.CoUninitialize()
  16818. // Replace with the ProgID or CLSID of your COM object
  16819. progID := "YinHai.XJ.Actual.Interface.New"
  16820. // Create COM object
  16821. unknown, err := oleutil.CreateObject(progID)
  16822. if err != nil {
  16823. fmt.Println("Unable to create COM object:", err)
  16824. }
  16825. defer unknown.Release()
  16826. // Query for the IDispatch interface
  16827. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  16828. if err != nil {
  16829. fmt.Println("Unable to get IDispatch interface:", err)
  16830. }
  16831. defer dispatch.Release()
  16832. // Prepare parameters
  16833. transNo := "1401"
  16834. transType := "passwordCheck"
  16835. timestamp := time.Now().Unix()
  16836. fixmedinsCode := "H45072101171"
  16837. psnNo := ""
  16838. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  16839. result2 := ""
  16840. // Call COM object's method using the IDispatch interface
  16841. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  16842. fmt.Println(resulr)
  16843. fmt.Println(result2)
  16844. if err != nil {
  16845. fmt.Println("调用COM对象方法失败:", err)
  16846. }
  16847. var response Response
  16848. err2 := json.Unmarshal([]byte(result2), &response)
  16849. if err2 != nil {
  16850. fmt.Println("解析JSON失败:", err)
  16851. }
  16852. return response
  16853. }
  16854. func (c *HisApiController) GetBasBaseInfo() string {
  16855. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16856. readCard := DllDef.MustFindProc("ReadCardBas")
  16857. if readCard == nil {
  16858. fmt.Println("readcard is nil")
  16859. readCard = DllDef.MustFindProc("ReadCardBas")
  16860. }
  16861. str := make([]byte, 1024)
  16862. str1 := make([]byte, 1024)
  16863. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  16864. fmt.Println(string(str1))
  16865. fmt.Println(string(str))
  16866. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16867. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16868. if ret2 != 0 {
  16869. return ""
  16870. }
  16871. return string(str)
  16872. }
  16873. type Program struct {
  16874. FunctionID string `xml:"function_id"`
  16875. CardInfo string `xml:"cardinfo"`
  16876. User string `xml:"user"`
  16877. }
  16878. func (c *HisApiController) GetBasBaseInfo1111() string {
  16879. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  16880. readCard := DllDef.MustFindProc("ReadSICardInfo")
  16881. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  16882. if readCard == nil {
  16883. fmt.Println("readcard is nil")
  16884. readCard = DllDef.MustFindProc("ReadSICardInfo")
  16885. }
  16886. if readCard2 == nil {
  16887. fmt.Println("readcard is nil")
  16888. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  16889. }
  16890. str := make([]byte, 1024)
  16891. str1 := make([]byte, 1024)
  16892. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16893. str3 := make([]byte, 1024)
  16894. str4 := make([]byte, 1024)
  16895. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  16896. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  16897. //if err != nil {
  16898. // fmt.Println("Error opening file:", err)
  16899. //}
  16900. //defer file.Close()
  16901. //
  16902. //var lastProgram Program
  16903. //scanner := bufio.NewScanner(file)
  16904. //inProgram := false
  16905. //
  16906. //for scanner.Scan() {
  16907. // line := scanner.Text()
  16908. // if strings.Contains(line, "<program>") {
  16909. // inProgram = true
  16910. // programXML := "<program>"
  16911. // for scanner.Scan() {
  16912. // line = scanner.Text()
  16913. // programXML += line
  16914. // if strings.Contains(line, "</program>") {
  16915. // programXML += "</program>"
  16916. // break
  16917. // }
  16918. // }
  16919. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  16920. // // 解析成功,更新最后的 Program
  16921. // }
  16922. // inProgram = false
  16923. // }
  16924. //}
  16925. //
  16926. // fmt.Println("Error reading file:", inProgram)
  16927. //
  16928. //if err := scanner.Err(); err != nil {
  16929. // fmt.Println("Error reading file:", err)
  16930. //}
  16931. // 输出最后一次的 Program
  16932. //fmt.Printf("最后一次的 <program>:\n")
  16933. //fmt.Printf("<program>\n")
  16934. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  16935. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  16936. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  16937. //fmt.Printf("</program>\n")
  16938. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16939. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16940. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  16941. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  16942. return ConvertToString(string(str), "gbk", "utf-8")
  16943. }
  16944. func (c *HisApiController) GetahBasBaseInfo() string {
  16945. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  16946. readCard := DllDef.MustFindProc("iReadCardBas")
  16947. if readCard == nil {
  16948. fmt.Println("readcard is nil")
  16949. readCard = DllDef.MustFindProc("iReadCardBas")
  16950. }
  16951. //str := make([]byte, 1024)
  16952. str1 := make([]byte, 1024)
  16953. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  16954. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  16955. //if err != nil {
  16956. // fmt.Println("Error opening file:", err)
  16957. //}
  16958. //defer file.Close()
  16959. //
  16960. //var lastProgram Program
  16961. //scanner := bufio.NewScanner(file)
  16962. //inProgram := false
  16963. //
  16964. //for scanner.Scan() {
  16965. // line := scanner.Text()
  16966. // if strings.Contains(line, "<program>") {
  16967. // inProgram = true
  16968. // programXML := "<program>"
  16969. // for scanner.Scan() {
  16970. // line = scanner.Text()
  16971. // programXML += line
  16972. // if strings.Contains(line, "</program>") {
  16973. // programXML += "</program>"
  16974. // break
  16975. // }
  16976. // }
  16977. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  16978. // // 解析成功,更新最后的 Program
  16979. // }
  16980. // inProgram = false
  16981. // }
  16982. //}
  16983. //
  16984. // fmt.Println("Error reading file:", inProgram)
  16985. //
  16986. //if err := scanner.Err(); err != nil {
  16987. // fmt.Println("Error reading file:", err)
  16988. //}
  16989. // 输出最后一次的 Program
  16990. //fmt.Printf("最后一次的 <program>:\n")
  16991. //fmt.Printf("<program>\n")
  16992. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  16993. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  16994. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  16995. //fmt.Printf("</program>\n")
  16996. fmt.Println(string(str1))
  16997. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16998. if ret2 != 0 {
  16999. return ""
  17000. }
  17001. return string(str1)
  17002. }
  17003. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17004. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17005. readCard := DllDef.MustFindProc("read_cardinfo")
  17006. if readCard == nil {
  17007. fmt.Println("readcard is nil")
  17008. readCard = DllDef.MustFindProc("read_cardinfo")
  17009. }
  17010. str := make([]byte, 1024) //卡号
  17011. str1 := make([]byte, 1024) //卡识别码
  17012. str2 := make([]byte, 1024) //身份证号
  17013. str3 := make([]byte, 1024) //姓名
  17014. str4 := make([]byte, 1024) //错误信息
  17015. 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])))
  17016. fmt.Println(string(str1))
  17017. fmt.Println(string(str))
  17018. fmt.Println(string(str2))
  17019. fmt.Println(string(str3))
  17020. fmt.Println(string(str4))
  17021. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17022. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17023. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17024. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17025. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17026. if ret2 != 0 {
  17027. return "", "", "", "", ""
  17028. }
  17029. return string(str), string(str1), string(str2), string(str3), string(str4)
  17030. }
  17031. type CustomFundPay struct {
  17032. FundPayType string `json:"fund_pay_type"`
  17033. FundPayamt float64 `json:"fund_payamt"`
  17034. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17035. }
  17036. //func (c *HisApiController) GetBatchSettleList() {
  17037. // start_time_str := c.GetString("start_time")
  17038. // //end_time_str := c.GetString("end_time")
  17039. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17040. //
  17041. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17042. //
  17043. // for _, item := range orders {
  17044. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17045. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17046. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17047. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17048. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17049. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17050. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17051. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17052. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17053. //
  17054. // if order.ID == 0 {
  17055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17056. // return
  17057. // }
  17058. //
  17059. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17060. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17061. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17062. // //fmt.Println(count)
  17063. // //var zero string
  17064. // //number := count + 1
  17065. // //if number >= 1000 {
  17066. // // zero = "0000" + strconv.FormatInt(number, 10)
  17067. // //} else if number >= 10000 {
  17068. // // zero = "000" + strconv.FormatInt(number, 10)
  17069. // //} else if number >= 100000 {
  17070. // // zero = "00" + strconv.FormatInt(number, 10)
  17071. // //} else if number >= 1000000 {
  17072. // // zero = "0" + strconv.FormatInt(number, 10)
  17073. // //} else {
  17074. // // zero = strconv.FormatInt(number, 10)
  17075. // //}
  17076. // //fmt.Println(zero)
  17077. //
  17078. // struct4101 := service.Struct4101{
  17079. // PsnNo: order.PsnNo,
  17080. // MdtrtId: order.MdtrtId,
  17081. // SetlId: order.SetlId,
  17082. // PsnName: order.PsnName,
  17083. // Gend: order.Gend,
  17084. // Brdy: his.Brdy,
  17085. // Age: his.Age,
  17086. // Naty: order.Naty,
  17087. // PatnCertType: "01",
  17088. // Certno: order.Certno,
  17089. // Prfs: "90",
  17090. // ConerName: roles[0].UserName,
  17091. // PatnRlts: "99",
  17092. // ConerAddr: miConfig.OrgName,
  17093. // ConerTel: admin.Mobile,
  17094. // HiType: order.Insutype,
  17095. // Insuplc: miConfig.InsuplcAdmdvs,
  17096. // MaindiagFlag: "1",
  17097. // BillCode: order.SetlId,
  17098. // BillNo: order.SetlId,
  17099. // BizSn: order.Number,
  17100. // PsnSelfPay: order.PsnPartAmt,
  17101. // PsnOwnPay: order.PsnPartAmt,
  17102. // AcctPay: order.AcctPay,
  17103. // PsnCashpay: order.PsnCashPay,
  17104. // HiPaymtd: "1",
  17105. // Hsorg: miConfig.InsuplcAdmdvs,
  17106. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17107. // MedinsFillPsn: curRoles.UserName,
  17108. // MedinsFillDept: miConfig.OrgName,
  17109. // IptMedType: "2",
  17110. // }
  17111. // struct4101.SetlBegnDate = order.SetlTime
  17112. // struct4101.SetlEndDate = order.SetlTime
  17113. // time_arr := strings.Split(order.SetlTime, " ")
  17114. // struct4101.AdmTime = time_arr[0]
  17115. // struct4101.AdmEndTime = time_arr[0]
  17116. //
  17117. // var rf []CustomFundPay
  17118. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17119. //
  17120. // var tempFunPays []service.CustomStruct
  17121. // for _, item := range rf {
  17122. // var tempFunPay service.CustomStruct
  17123. // tempFunPay.FundPayamt = item.FundPayamt
  17124. // tempFunPay.FundPayType = item.FundPayType
  17125. // tempFunPays = append(tempFunPays, tempFunPay)
  17126. // }
  17127. // struct4101.CustomStruct = tempFunPays
  17128. //
  17129. // var tempDiaginfos []service.DiaginfoStructTwo
  17130. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17131. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17132. //
  17133. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17134. // var config []*models.HisXtDiagnoseConfig
  17135. // for _, item := range diagnosis_ids {
  17136. // id, _ := strconv.ParseInt(item, 10, 64)
  17137. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17138. // config = append(config, &diagnosisConfig)
  17139. // }
  17140. //
  17141. // for index, item := range config {
  17142. // if index == 0 {
  17143. // var tempDiaginfo service.DiaginfoStructTwo
  17144. // tempDiaginfo.DiagCode = item.CountryCode
  17145. // tempDiaginfo.DiagName = item.CountryContentName
  17146. // tempDiaginfo.DiagType = "1"
  17147. // tempDiaginfo.MaindiagFlag = "1"
  17148. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17149. // } else {
  17150. // var tempDiaginfo service.DiaginfoStructTwo
  17151. // tempDiaginfo.DiagCode = item.CountryCode
  17152. // tempDiaginfo.DiagName = item.CountryContentName
  17153. // tempDiaginfo.DiagType = "1"
  17154. // tempDiaginfo.MaindiagFlag = "0"
  17155. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17156. // }
  17157. // }
  17158. // struct4101.Diseinfo = tempDiaginfos
  17159. //
  17160. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17161. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17162. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17163. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17164. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17165. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17166. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17167. //
  17168. // var iteminfo service.IteminfoStruct
  17169. //
  17170. // var bedCostTotal float64 = 0 //床位总费
  17171. // var bedCostSelfTotal float64 = 0 //床位自费
  17172. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17173. //
  17174. // var operationCostTotal float64 = 0 //手术费
  17175. // var operationCostSelfTotal float64 = 0 //手术费
  17176. // var operationCostPartSelfTotal float64 = 0 //手术费
  17177. //
  17178. // var otherCostTotal float64 = 0 //其他费用
  17179. // var otherCostSelfTotal float64 = 0 //其他费用
  17180. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17181. //
  17182. // var materialCostTotal float64 = 0 //材料费
  17183. // var materialCostSelfTotal float64 = 0 //材料费
  17184. // var materialCostPartSelfTotal float64 = 0 //材料费
  17185. //
  17186. // var westernMedicineCostTotal float64 = 0 //西药费
  17187. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17188. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17189. //
  17190. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17191. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17192. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17193. //
  17194. // var checkCostTotal float64 = 0 //检查费
  17195. // var checkCostSelfTotal float64 = 0 //检查费
  17196. // var checkCostPartSelfTotal float64 = 0 //检查费
  17197. //
  17198. // var laboratoryCostTotal float64 = 0 //化验费
  17199. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17200. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17201. //
  17202. // var treatCostTotal float64 = 0 //治疗费用
  17203. // var treatCostSelfTotal float64 = 0 //治疗费用
  17204. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17205. //
  17206. // decimal.DivisionPrecision = 2
  17207. //
  17208. // var bed_fulamt_ownpay_amt float64 = 0
  17209. // var operation_fulamt_ownpay_amt float64 = 0
  17210. // var other_fulamt_ownpay_amt float64 = 0
  17211. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17212. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17213. // var check_fulamt_ownpay_amt float64 = 0
  17214. // var material_fulamt_ownpay_amt float64 = 0
  17215. // var laboratory_fulamt_ownpay_amt float64 = 0
  17216. // var treat_fulamt_ownpay_amt float64 = 0
  17217. //
  17218. // var bed_claa_sunmfee float64 = 0
  17219. // var bed_clab_amt float64 = 0
  17220. // var bed_other_amt float64 = 0
  17221. //
  17222. // var operation_claa_sunmfee float64 = 0
  17223. // var operation_clab_amt float64 = 0
  17224. // var operation_other_amt float64 = 0
  17225. //
  17226. // var other_claa_sunmfee float64 = 0
  17227. // var other_clab_amt float64 = 0
  17228. // var other_other_amt float64 = 0
  17229. //
  17230. // var westernMedicine_claa_sunmfee float64 = 0
  17231. // var westernMedicine_clab_amt float64 = 0
  17232. // var westernMedicine_other_amt float64 = 0
  17233. //
  17234. // var chineseTraditional_claa_sunmfee float64 = 0
  17235. // var chineseTraditional_clab_amt float64 = 0
  17236. // var chineseTraditional_other_amt float64 = 0
  17237. //
  17238. // var check_claa_sunmfee float64 = 0
  17239. // var check_clab_amt float64 = 0
  17240. // var check_other_amt float64 = 0
  17241. //
  17242. // var material_claa_sunmfee float64 = 0
  17243. // var material_clab_amt float64 = 0
  17244. // var material_other_amt float64 = 0
  17245. //
  17246. // var laboratory_claa_sunmfee float64 = 0
  17247. // var laboratory_clab_amt float64 = 0
  17248. // var laboratory_other_amt float64 = 0
  17249. //
  17250. // var treat_claa_sunmfee float64 = 0
  17251. // var treat_clab_amt float64 = 0
  17252. // var treat_other_amt float64 = 0
  17253. //
  17254. // for _, item := range order.HisOrderInfo {
  17255. // if item.MedChrgitmType == "01" { //床位费
  17256. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17257. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17258. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17259. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17260. // if item.ChrgitmLv == "1" {
  17261. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17262. // }
  17263. // if item.ChrgitmLv == "2" {
  17264. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17265. //
  17266. // }
  17267. // if item.ChrgitmLv == "3" {
  17268. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17269. // }
  17270. //
  17271. // }
  17272. //
  17273. // if item.MedChrgitmType == "03" { //检查费
  17274. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17275. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17276. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17277. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17278. // if item.ChrgitmLv == "1" {
  17279. //
  17280. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17281. //
  17282. // }
  17283. // if item.ChrgitmLv == "2" {
  17284. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17285. //
  17286. // }
  17287. // if item.ChrgitmLv == "3" {
  17288. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17289. // }
  17290. // }
  17291. //
  17292. // if item.MedChrgitmType == "04" { //化验费
  17293. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17294. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17295. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17296. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17297. // if item.ChrgitmLv == "1" {
  17298. //
  17299. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17300. //
  17301. // }
  17302. // if item.ChrgitmLv == "2" {
  17303. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17304. //
  17305. // }
  17306. // if item.ChrgitmLv == "3" {
  17307. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17308. // }
  17309. // }
  17310. //
  17311. // if item.MedChrgitmType == "05" { //治疗费
  17312. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17313. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17314. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17315. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17316. // if item.ChrgitmLv == "1" {
  17317. //
  17318. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17319. //
  17320. // }
  17321. // if item.ChrgitmLv == "2" {
  17322. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17323. //
  17324. // }
  17325. // if item.ChrgitmLv == "3" {
  17326. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17327. // }
  17328. // }
  17329. //
  17330. // if item.MedChrgitmType == "06" { //手术费
  17331. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17332. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17333. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17334. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17335. //
  17336. // if item.ChrgitmLv == "1" {
  17337. //
  17338. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17339. //
  17340. // }
  17341. // if item.ChrgitmLv == "2" {
  17342. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17343. //
  17344. // }
  17345. // if item.ChrgitmLv == "3" {
  17346. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17347. // }
  17348. // }
  17349. //
  17350. // if item.MedChrgitmType == "08" { //材料费
  17351. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17352. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17353. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17354. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17355. // if item.ChrgitmLv == "1" {
  17356. //
  17357. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17358. //
  17359. // }
  17360. // if item.ChrgitmLv == "2" {
  17361. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17362. //
  17363. // }
  17364. // if item.ChrgitmLv == "3" {
  17365. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17366. // }
  17367. // }
  17368. //
  17369. // if item.MedChrgitmType == "09" { //西药费
  17370. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17371. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17372. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17373. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17374. // if item.ChrgitmLv == "1" {
  17375. //
  17376. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17377. //
  17378. // }
  17379. // if item.ChrgitmLv == "2" {
  17380. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17381. //
  17382. // }
  17383. // if item.ChrgitmLv == "3" {
  17384. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17385. // }
  17386. // }
  17387. //
  17388. // if item.MedChrgitmType == "11" { //中成费
  17389. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17390. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17391. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17392. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17393. // if item.ChrgitmLv == "1" {
  17394. //
  17395. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17396. //
  17397. // }
  17398. // if item.ChrgitmLv == "2" {
  17399. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17400. //
  17401. // }
  17402. // if item.ChrgitmLv == "3" {
  17403. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17404. // }
  17405. // }
  17406. //
  17407. // if item.MedChrgitmType == "14" { //其他费
  17408. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17409. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17410. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17411. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17412. // if item.ChrgitmLv == "1" {
  17413. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17414. //
  17415. // }
  17416. // if item.ChrgitmLv == "2" {
  17417. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17418. //
  17419. // }
  17420. // if item.ChrgitmLv == "3" {
  17421. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17422. // }
  17423. // }
  17424. //
  17425. // }
  17426. //
  17427. // var iteminfoStructs []service.IteminfoStruct
  17428. //
  17429. // if bedCostTotal != 0 {
  17430. // iteminfo.MedChrgitm = "01"
  17431. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17432. // iteminfo.Amt = bedCostTotal
  17433. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  17434. // iteminfo.ClabAmt = bed_clab_amt
  17435. // iteminfo.OthAmt = bed_other_amt
  17436. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17437. // }
  17438. //
  17439. // if checkCostTotal != 0 {
  17440. // iteminfo.MedChrgitm = "03"
  17441. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17442. // iteminfo.Amt = checkCostTotal
  17443. // iteminfo.ClaaSumfee = check_claa_sunmfee
  17444. // iteminfo.ClabAmt = check_clab_amt
  17445. // iteminfo.OthAmt = check_other_amt
  17446. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17447. //
  17448. // }
  17449. //
  17450. // if laboratoryCostTotal != 0 {
  17451. // iteminfo.MedChrgitm = "04"
  17452. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17453. // iteminfo.Amt = laboratoryCostTotal
  17454. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17455. // iteminfo.ClabAmt = laboratory_clab_amt
  17456. // iteminfo.OthAmt = laboratory_other_amt
  17457. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17458. //
  17459. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17460. //
  17461. // }
  17462. //
  17463. // if treatCostTotal != 0 {
  17464. // iteminfo.MedChrgitm = "05"
  17465. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17466. // iteminfo.Amt = treatCostTotal
  17467. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  17468. // iteminfo.ClabAmt = treat_clab_amt
  17469. // iteminfo.OthAmt = treat_other_amt
  17470. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17471. // //(struct4101.IteminfoStruct, iteminfo)
  17472. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17473. // }
  17474. //
  17475. // if operationCostTotal != 0 {
  17476. // iteminfo.MedChrgitm = "06"
  17477. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17478. // iteminfo.Amt = operationCostTotal
  17479. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  17480. // iteminfo.ClabAmt = operation_clab_amt
  17481. // iteminfo.OthAmt = operation_other_amt
  17482. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17483. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17484. // }
  17485. //
  17486. // if materialCostTotal != 0 {
  17487. // iteminfo.MedChrgitm = "08"
  17488. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  17489. // iteminfo.Amt = materialCostTotal
  17490. // iteminfo.ClaaSumfee = material_claa_sunmfee
  17491. // iteminfo.ClabAmt = material_clab_amt
  17492. // iteminfo.OthAmt = material_other_amt
  17493. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17494. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17495. // }
  17496. //
  17497. // if westernMedicineCostTotal != 0 {
  17498. // iteminfo.MedChrgitm = "09"
  17499. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17500. // iteminfo.Amt = westernMedicineCostTotal
  17501. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17502. // iteminfo.ClabAmt = westernMedicine_clab_amt
  17503. // iteminfo.OthAmt = westernMedicine_other_amt
  17504. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17505. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17506. //
  17507. // }
  17508. // if chineseTraditionalMedicineCostTotal != 0 {
  17509. // iteminfo.MedChrgitm = "11"
  17510. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17511. // iteminfo.Amt = westernMedicineCostTotal
  17512. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17513. // iteminfo.ClabAmt = westernMedicine_clab_amt
  17514. // iteminfo.OthAmt = westernMedicine_other_amt
  17515. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17516. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17517. //
  17518. // }
  17519. // if otherCostTotal != 0 {
  17520. // iteminfo.MedChrgitm = "14"
  17521. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  17522. // iteminfo.Amt = otherCostTotal
  17523. // iteminfo.ClaaSumfee = other_claa_sunmfee
  17524. // iteminfo.ClabAmt = other_clab_amt
  17525. // iteminfo.OthAmt = other_other_amt
  17526. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17527. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17528. //
  17529. // }
  17530. // struct4101.IteminfoStruct = iteminfoStructs
  17531. // struct4101.Ntly = "中国"
  17532. // struct4101.AdmCaty = "A03.06"
  17533. //
  17534. // struct4101.DoctorName = doctor.UserName
  17535. // struct4101.DoctorCode = doctor.DoctorNumber
  17536. //
  17537. // var res ResultSeventeen
  17538. //
  17539. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17540. // struct4101.BillCode = order.Number
  17541. // struct4101.BillNo = order.SetlId
  17542. // var resOther ResultSeventeenOther
  17543. // var pp models.PublicParams
  17544. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17545. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17546. // pp.FixmedinsName = miConfig.OrgName
  17547. // pp.FixmedinsCode = miConfig.Code
  17548. // pp.RequestUrl = miConfig.Url
  17549. // pp.Cainfo = miConfig.Cainfo
  17550. // pp.SecretKey = miConfig.SecretKey
  17551. // pp.AccessKey = miConfig.AccessKey
  17552. // pp.OpterName = curRoles.UserName
  17553. //
  17554. // client := &http.Client{}
  17555. // var req *http.Request
  17556. // data := make(map[string]interface{})
  17557. // data["struct4101"] = struct4101
  17558. // data["pp"] = pp
  17559. // bytesData, _ := json.Marshal(data)
  17560. // if miConfig.MdtrtareaAdmvs == "320921" {
  17561. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17562. // } else {
  17563. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17564. // }
  17565. // resp, _ := client.Do(req)
  17566. // defer resp.Body.Close()
  17567. // body, ioErr := ioutil.ReadAll(resp.Body)
  17568. // if ioErr != nil {
  17569. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17570. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17571. // return
  17572. // }
  17573. // var respJSON map[string]interface{}
  17574. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17575. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17576. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17577. // return
  17578. // }
  17579. //
  17580. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17581. // userJSONBytes, _ := json.Marshal(respJSON)
  17582. // fmt.Println("log")
  17583. // fmt.Println(string(userJSONBytes))
  17584. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17585. // utils.ErrorLog("解析失败:%v", err)
  17586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17587. // return
  17588. // }
  17589. // res.InfRefmsgid = resOther.InfRefmsgid
  17590. // res.Output = resOther.Output
  17591. // res.ErrMsg = resOther.ErrMsg
  17592. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17593. // res.Infcode = infocode
  17594. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  17595. //
  17596. // var pp models.PublicParams
  17597. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17598. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17599. // pp.FixmedinsName = miConfig.OrgName
  17600. // pp.FixmedinsCode = miConfig.Code
  17601. // pp.RequestUrl = miConfig.Url
  17602. // pp.Cainfo = miConfig.Cainfo
  17603. // pp.SecretKey = miConfig.SecretKey
  17604. // pp.AccessKey = miConfig.AccessKey
  17605. // pp.OpterName = curRoles.UserName
  17606. // result, _ := service.Jxyb4101(struct4101, pp)
  17607. // var dat map[string]interface{}
  17608. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17609. // fmt.Println(dat)
  17610. // } else {
  17611. // fmt.Println(err)
  17612. // }
  17613. // userJSONBytes, _ := json.Marshal(dat)
  17614. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17615. // utils.ErrorLog("解析失败:%v", err)
  17616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17617. // return
  17618. // }
  17619. //
  17620. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  17621. // var pp models.PublicParams
  17622. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17623. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17624. // pp.FixmedinsName = miConfig.OrgName
  17625. // pp.FixmedinsCode = miConfig.Code
  17626. // pp.RequestUrl = miConfig.Url
  17627. // pp.Cainfo = miConfig.Cainfo
  17628. // pp.SecretKey = miConfig.SecretKey
  17629. // pp.AccessKey = miConfig.AccessKey
  17630. // pp.OpterName = curRoles.UserName
  17631. // result, _ := service.Hnyb4101(struct4101, pp)
  17632. // var dat map[string]interface{}
  17633. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17634. // fmt.Println(dat)
  17635. // } else {
  17636. // fmt.Println(err)
  17637. // }
  17638. // userJSONBytes, _ := json.Marshal(dat)
  17639. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17640. // utils.ErrorLog("解析失败:%v", err)
  17641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17642. // return
  17643. // }
  17644. //
  17645. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  17646. // var resOther ResultSeventeenOther
  17647. //
  17648. // var pp models.PublicParams
  17649. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17650. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17651. // pp.FixmedinsName = miConfig.OrgName
  17652. // pp.FixmedinsCode = miConfig.Code
  17653. // pp.RequestUrl = miConfig.Url
  17654. // pp.Cainfo = miConfig.Cainfo
  17655. // pp.SecretKey = miConfig.SecretKey
  17656. // pp.AccessKey = miConfig.AccessKey
  17657. // pp.OpterName = curRoles.UserName
  17658. // client := &http.Client{}
  17659. // var req *http.Request
  17660. // data := make(map[string]interface{})
  17661. // data["struct4101"] = struct4101
  17662. // data["pp"] = pp
  17663. // bytesData, _ := json.Marshal(data)
  17664. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17665. // resp, _ := client.Do(req)
  17666. // defer resp.Body.Close()
  17667. // body, ioErr := ioutil.ReadAll(resp.Body)
  17668. // if ioErr != nil {
  17669. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17671. // return
  17672. // }
  17673. // var respJSON map[string]interface{}
  17674. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17675. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17677. // return
  17678. // }
  17679. //
  17680. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17681. // userJSONBytes, _ := json.Marshal(respJSON)
  17682. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17683. // utils.ErrorLog("解析失败:%v", err)
  17684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17685. // return
  17686. // }
  17687. // res.InfRefmsgid = resOther.InfRefmsgid
  17688. // res.Output = resOther.Output
  17689. // res.ErrMsg = resOther.ErrMsg
  17690. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17691. // res.Infcode = infocode
  17692. //
  17693. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  17694. // var pp models.PublicParams
  17695. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17696. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17697. // pp.FixmedinsName = miConfig.OrgName
  17698. // pp.FixmedinsCode = miConfig.Code
  17699. // pp.RequestUrl = miConfig.Url
  17700. // pp.Cainfo = miConfig.Cainfo
  17701. // pp.SecretKey = miConfig.SecretKey
  17702. // pp.AccessKey = miConfig.AccessKey
  17703. // pp.OpterName = curRoles.UserName
  17704. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  17705. // fmt.Println(requestLog)
  17706. // fmt.Println(errMsgLog)
  17707. //
  17708. // saveLog(result, requestLog, "4101a", "上传清单")
  17709. //
  17710. // var dat map[string]interface{}
  17711. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17712. // fmt.Println(dat)
  17713. // } else {
  17714. // fmt.Println(err)
  17715. // }
  17716. // userJSONBytes, _ := json.Marshal(dat)
  17717. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17718. // utils.ErrorLog("解析失败:%v", err)
  17719. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17720. // return
  17721. // }
  17722. //
  17723. // } else {
  17724. //
  17725. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  17726. // var dat map[string]interface{}
  17727. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17728. // fmt.Println(dat)
  17729. // } else {
  17730. // fmt.Println(err)
  17731. // }
  17732. // userJSONBytes, _ := json.Marshal(dat)
  17733. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17734. // utils.ErrorLog("解析失败:%v", err)
  17735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17736. // return
  17737. // }
  17738. // }
  17739. //
  17740. // if res.Infcode != 0 {
  17741. // adminUser := c.GetAdminUserInfo()
  17742. // errlog := &models.HisOrderError{
  17743. // UserOrgId: adminUser.CurrentOrgId,
  17744. // Ctime: time.Now().Unix(),
  17745. // Mtime: time.Now().Unix(),
  17746. // ErrMsg: res.ErrMsg,
  17747. // Status: 1,
  17748. // PatientId: order.ID,
  17749. // Stage: 10265,
  17750. // }
  17751. // service.CreateErrMsgLog(errlog)
  17752. // continue
  17753. // } else {
  17754. // //order.FaPiaoNumber = zero
  17755. // //order.FaPiaoCode = last_order.FaPiaoCode
  17756. // //service.UpdateOrder(order)
  17757. // hisFundSettleListResult := &models.HisFundSettleListResult{
  17758. // Number: res.Output.SetlListId,
  17759. // Status: 1,
  17760. // Ctime: time.Now().Unix(),
  17761. // Mtime: time.Now().Unix(),
  17762. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17763. // IsUpload: 1,
  17764. // OrderId: order.ID,
  17765. // }
  17766. // service.CreateUploadRecord(hisFundSettleListResult)
  17767. // c.ServeSuccessJSON(map[string]interface{}{
  17768. // "msg": "上传成功",
  17769. // "result": hisFundSettleListResult,
  17770. // })
  17771. // continue
  17772. // }
  17773. // }
  17774. //}
  17775. func (c *HisApiController) GetbatchSettleList() {
  17776. //order_id, _ := c.GetInt64("order_id")
  17777. admin_user_id, _ := c.GetInt64("admin_user_id")
  17778. orders, _ := service.GetAllHisOrderTwo10485()
  17779. for _, item := range orders {
  17780. order, _ := service.GetHisOrderByIDTwo(item.ID)
  17781. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17782. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17783. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17784. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17785. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17786. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17787. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17788. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17789. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17790. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17791. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17792. //fmt.Println(count)
  17793. //var zero string
  17794. //number := count + 1
  17795. //if number >= 1000 {
  17796. // zero = "0000" + strconv.FormatInt(number, 10)
  17797. //} else if number >= 10000 {
  17798. // zero = "000" + strconv.FormatInt(number, 10)
  17799. //} else if number >= 100000 {
  17800. // zero = "00" + strconv.FormatInt(number, 10)
  17801. //} else if number >= 1000000 {
  17802. // zero = "0" + strconv.FormatInt(number, 10)
  17803. //} else {
  17804. // zero = strconv.FormatInt(number, 10)
  17805. //}
  17806. //fmt.Println(zero)
  17807. struct4101 := service.Struct4101{
  17808. PsnNo: order.PsnNo,
  17809. MdtrtId: order.MdtrtId,
  17810. SetlId: order.SetlId,
  17811. PsnName: order.PsnName,
  17812. Gend: order.Gend,
  17813. Brdy: his.Brdy,
  17814. Age: his.Age,
  17815. Naty: order.Naty,
  17816. PatnCertType: "01",
  17817. Certno: order.Certno,
  17818. Prfs: "90",
  17819. ConerName: roles[0].UserName,
  17820. PatnRlts: "99",
  17821. ConerAddr: miConfig.OrgName,
  17822. ConerTel: admin.Mobile,
  17823. HiType: order.Insutype,
  17824. Insuplc: miConfig.InsuplcAdmdvs,
  17825. MaindiagFlag: "1",
  17826. BillCode: order.SetlId,
  17827. BillNo: order.SetlId,
  17828. BizSn: order.Number,
  17829. PsnSelfPay: order.PsnPartAmt,
  17830. PsnOwnPay: order.PsnPartAmt,
  17831. AcctPay: order.AcctPay,
  17832. PsnCashpay: order.PsnCashPay,
  17833. HiPaymtd: "1",
  17834. Hsorg: miConfig.InsuplcAdmdvs,
  17835. HsorgOpter: miConfig.InsuplcAdmdvs,
  17836. MedinsFillPsn: curRoles.UserName,
  17837. MedinsFillDept: miConfig.OrgName,
  17838. IptMedType: "2",
  17839. }
  17840. struct4101.SetlBegnDate = order.SetlTime
  17841. struct4101.SetlEndDate = order.SetlTime
  17842. time_arr := strings.Split(order.SetlTime, " ")
  17843. struct4101.AdmTime = time_arr[0]
  17844. struct4101.AdmEndTime = time_arr[0]
  17845. //var rf []CustomFundPay
  17846. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  17847. //
  17848. //var tempFunPays []service.CustomStruct
  17849. //for _, item := range rf {
  17850. // var tempFunPay service.CustomStruct
  17851. // tempFunPay.FundPayamt = item.FundPayamt
  17852. // tempFunPay.FundPayType = item.FundPayType
  17853. // tempFunPays = append(tempFunPays, tempFunPay)
  17854. //}
  17855. //struct4101.CustomStruct = tempFunPays
  17856. var tempDiaginfos []service.DiaginfoStructTwo
  17857. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17858. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17859. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17860. var config []*models.HisXtDiagnoseConfig
  17861. for _, item := range diagnosis_ids {
  17862. id, _ := strconv.ParseInt(item, 10, 64)
  17863. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17864. config = append(config, &diagnosisConfig)
  17865. }
  17866. for index, item := range config {
  17867. if index == 0 {
  17868. var tempDiaginfo service.DiaginfoStructTwo
  17869. tempDiaginfo.DiagCode = item.CountryCode
  17870. tempDiaginfo.DiagName = item.CountryContentName
  17871. tempDiaginfo.DiagType = "1"
  17872. tempDiaginfo.MaindiagFlag = "1"
  17873. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17874. } else {
  17875. var tempDiaginfo service.DiaginfoStructTwo
  17876. tempDiaginfo.DiagCode = item.CountryCode
  17877. tempDiaginfo.DiagName = item.CountryContentName
  17878. tempDiaginfo.DiagType = "1"
  17879. tempDiaginfo.MaindiagFlag = "0"
  17880. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17881. }
  17882. }
  17883. struct4101.Diseinfo = tempDiaginfos
  17884. sickConfigTwo, _ := service.FindSickById(his.SickType)
  17885. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17886. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17887. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17888. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17889. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17890. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17891. var iteminfo service.IteminfoStruct
  17892. var bedCostTotal float64 = 0 //床位总费
  17893. var bedCostSelfTotal float64 = 0 //床位自费
  17894. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17895. var operationCostTotal float64 = 0 //手术费
  17896. var operationCostSelfTotal float64 = 0 //手术费
  17897. var operationCostPartSelfTotal float64 = 0 //手术费
  17898. var otherCostTotal float64 = 0 //其他费用
  17899. var otherCostSelfTotal float64 = 0 //其他费用
  17900. var otherCostPartSelfTotal float64 = 0 //其他费用
  17901. var materialCostTotal float64 = 0 //材料费
  17902. var materialCostSelfTotal float64 = 0 //材料费
  17903. var materialCostPartSelfTotal float64 = 0 //材料费
  17904. var westernMedicineCostTotal float64 = 0 //西药费
  17905. var westernMedicineCostSelfTotal float64 = 0 //西药费
  17906. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17907. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17908. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17909. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17910. var checkCostTotal float64 = 0 //检查费
  17911. var checkCostSelfTotal float64 = 0 //检查费
  17912. var checkCostPartSelfTotal float64 = 0 //检查费
  17913. var laboratoryCostTotal float64 = 0 //化验费
  17914. var laboratoryCostSelfTotal float64 = 0 //化验费
  17915. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17916. var treatCostTotal float64 = 0 //治疗费用
  17917. var treatCostSelfTotal float64 = 0 //治疗费用
  17918. var treatCostPartSelfTotal float64 = 0 //治疗费用
  17919. decimal.DivisionPrecision = 2
  17920. var bed_fulamt_ownpay_amt float64 = 0
  17921. var operation_fulamt_ownpay_amt float64 = 0
  17922. var other_fulamt_ownpay_amt float64 = 0
  17923. var westernMedicine_fulamt_ownpay_amt float64 = 0
  17924. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17925. var check_fulamt_ownpay_amt float64 = 0
  17926. var material_fulamt_ownpay_amt float64 = 0
  17927. var laboratory_fulamt_ownpay_amt float64 = 0
  17928. var treat_fulamt_ownpay_amt float64 = 0
  17929. var bed_claa_sunmfee float64 = 0
  17930. var bed_clab_amt float64 = 0
  17931. var bed_other_amt float64 = 0
  17932. var operation_claa_sunmfee float64 = 0
  17933. var operation_clab_amt float64 = 0
  17934. var operation_other_amt float64 = 0
  17935. var other_claa_sunmfee float64 = 0
  17936. var other_clab_amt float64 = 0
  17937. var other_other_amt float64 = 0
  17938. var westernMedicine_claa_sunmfee float64 = 0
  17939. var westernMedicine_clab_amt float64 = 0
  17940. var westernMedicine_other_amt float64 = 0
  17941. var chineseTraditional_claa_sunmfee float64 = 0
  17942. var chineseTraditional_clab_amt float64 = 0
  17943. var chineseTraditional_other_amt float64 = 0
  17944. var check_claa_sunmfee float64 = 0
  17945. var check_clab_amt float64 = 0
  17946. var check_other_amt float64 = 0
  17947. var material_claa_sunmfee float64 = 0
  17948. var material_clab_amt float64 = 0
  17949. var material_other_amt float64 = 0
  17950. var laboratory_claa_sunmfee float64 = 0
  17951. var laboratory_clab_amt float64 = 0
  17952. var laboratory_other_amt float64 = 0
  17953. var treat_claa_sunmfee float64 = 0
  17954. var treat_clab_amt float64 = 0
  17955. var treat_other_amt float64 = 0
  17956. for _, item := range order.HisOrderInfo {
  17957. if item.MedChrgitmType == "01" { //床位费
  17958. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17959. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17960. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17961. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17962. if item.ChrgitmLv == "1" {
  17963. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17964. }
  17965. if item.ChrgitmLv == "2" {
  17966. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17967. }
  17968. if item.ChrgitmLv == "3" {
  17969. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17970. }
  17971. }
  17972. if item.MedChrgitmType == "03" { //检查费
  17973. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17974. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17975. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17976. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17977. if item.ChrgitmLv == "1" {
  17978. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17979. }
  17980. if item.ChrgitmLv == "2" {
  17981. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17982. }
  17983. if item.ChrgitmLv == "3" {
  17984. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17985. }
  17986. }
  17987. if item.MedChrgitmType == "04" { //化验费
  17988. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17989. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17990. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17991. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17992. if item.ChrgitmLv == "1" {
  17993. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17994. }
  17995. if item.ChrgitmLv == "2" {
  17996. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17997. }
  17998. if item.ChrgitmLv == "3" {
  17999. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18000. }
  18001. }
  18002. if item.MedChrgitmType == "05" { //治疗费
  18003. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18004. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18005. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18006. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18007. if item.ChrgitmLv == "1" {
  18008. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18009. }
  18010. if item.ChrgitmLv == "2" {
  18011. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18012. }
  18013. if item.ChrgitmLv == "3" {
  18014. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18015. }
  18016. }
  18017. if item.MedChrgitmType == "06" { //手术费
  18018. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18019. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18020. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18021. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18022. if item.ChrgitmLv == "1" {
  18023. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18024. }
  18025. if item.ChrgitmLv == "2" {
  18026. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18027. }
  18028. if item.ChrgitmLv == "3" {
  18029. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18030. }
  18031. }
  18032. if item.MedChrgitmType == "08" { //材料费
  18033. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18034. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18035. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18036. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18037. if item.ChrgitmLv == "1" {
  18038. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18039. }
  18040. if item.ChrgitmLv == "2" {
  18041. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18042. }
  18043. if item.ChrgitmLv == "3" {
  18044. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18045. }
  18046. }
  18047. if item.MedChrgitmType == "09" { //西药费
  18048. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18049. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18050. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18051. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18052. if item.ChrgitmLv == "1" {
  18053. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18054. }
  18055. if item.ChrgitmLv == "2" {
  18056. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18057. }
  18058. if item.ChrgitmLv == "3" {
  18059. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18060. }
  18061. }
  18062. if item.MedChrgitmType == "11" { //中成费
  18063. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18064. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18065. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18066. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18067. if item.ChrgitmLv == "1" {
  18068. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18069. }
  18070. if item.ChrgitmLv == "2" {
  18071. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18072. }
  18073. if item.ChrgitmLv == "3" {
  18074. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18075. }
  18076. }
  18077. if item.MedChrgitmType == "14" { //其他费
  18078. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18079. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18080. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18081. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18082. if item.ChrgitmLv == "1" {
  18083. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18084. }
  18085. if item.ChrgitmLv == "2" {
  18086. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18087. }
  18088. if item.ChrgitmLv == "3" {
  18089. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18090. }
  18091. }
  18092. }
  18093. var iteminfoStructs []service.IteminfoStruct
  18094. if bedCostTotal != 0 {
  18095. iteminfo.MedChrgitm = "01"
  18096. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18097. iteminfo.Amt = bedCostTotal
  18098. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18099. iteminfo.ClabAmt = bed_clab_amt
  18100. iteminfo.OthAmt = bed_other_amt
  18101. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18102. }
  18103. if checkCostTotal != 0 {
  18104. iteminfo.MedChrgitm = "03"
  18105. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18106. iteminfo.Amt = checkCostTotal
  18107. iteminfo.ClaaSumfee = check_claa_sunmfee
  18108. iteminfo.ClabAmt = check_clab_amt
  18109. iteminfo.OthAmt = check_other_amt
  18110. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18111. }
  18112. if laboratoryCostTotal != 0 {
  18113. iteminfo.MedChrgitm = "04"
  18114. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18115. iteminfo.Amt = laboratoryCostTotal
  18116. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18117. iteminfo.ClabAmt = laboratory_clab_amt
  18118. iteminfo.OthAmt = laboratory_other_amt
  18119. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18120. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18121. }
  18122. if treatCostTotal != 0 {
  18123. iteminfo.MedChrgitm = "05"
  18124. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18125. iteminfo.Amt = treatCostTotal
  18126. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18127. iteminfo.ClabAmt = treat_clab_amt
  18128. iteminfo.OthAmt = treat_other_amt
  18129. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18130. //(struct4101.IteminfoStruct, iteminfo)
  18131. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18132. }
  18133. if operationCostTotal != 0 {
  18134. iteminfo.MedChrgitm = "06"
  18135. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18136. iteminfo.Amt = operationCostTotal
  18137. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18138. iteminfo.ClabAmt = operation_clab_amt
  18139. iteminfo.OthAmt = operation_other_amt
  18140. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18141. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18142. }
  18143. if materialCostTotal != 0 {
  18144. iteminfo.MedChrgitm = "08"
  18145. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18146. iteminfo.Amt = materialCostTotal
  18147. iteminfo.ClaaSumfee = material_claa_sunmfee
  18148. iteminfo.ClabAmt = material_clab_amt
  18149. iteminfo.OthAmt = material_other_amt
  18150. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18151. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18152. }
  18153. if westernMedicineCostTotal != 0 {
  18154. iteminfo.MedChrgitm = "09"
  18155. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18156. iteminfo.Amt = westernMedicineCostTotal
  18157. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18158. iteminfo.ClabAmt = westernMedicine_clab_amt
  18159. iteminfo.OthAmt = westernMedicine_other_amt
  18160. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18161. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18162. }
  18163. if chineseTraditionalMedicineCostTotal != 0 {
  18164. iteminfo.MedChrgitm = "11"
  18165. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18166. iteminfo.Amt = westernMedicineCostTotal
  18167. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18168. iteminfo.ClabAmt = westernMedicine_clab_amt
  18169. iteminfo.OthAmt = westernMedicine_other_amt
  18170. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18171. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18172. }
  18173. if otherCostTotal != 0 {
  18174. iteminfo.MedChrgitm = "14"
  18175. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18176. iteminfo.Amt = otherCostTotal
  18177. iteminfo.ClaaSumfee = other_claa_sunmfee
  18178. iteminfo.ClabAmt = other_clab_amt
  18179. iteminfo.OthAmt = other_other_amt
  18180. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18181. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18182. }
  18183. struct4101.IteminfoStruct = iteminfoStructs
  18184. struct4101.Ntly = "中国"
  18185. struct4101.AdmCaty = "A03.06"
  18186. struct4101.DoctorName = doctor.UserName
  18187. struct4101.DoctorCode = doctor.DoctorNumber
  18188. var res ResultSeventeen
  18189. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18190. struct4101.BillCode = order.Number
  18191. struct4101.BillNo = order.SetlId
  18192. var resOther ResultSeventeenOther
  18193. var pp models.PublicParams
  18194. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18195. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18196. pp.FixmedinsName = miConfig.OrgName
  18197. pp.FixmedinsCode = miConfig.Code
  18198. pp.RequestUrl = miConfig.Url
  18199. pp.Cainfo = miConfig.Cainfo
  18200. pp.SecretKey = miConfig.SecretKey
  18201. pp.AccessKey = miConfig.AccessKey
  18202. pp.OpterName = curRoles.UserName
  18203. client := &http.Client{}
  18204. var req *http.Request
  18205. data := make(map[string]interface{})
  18206. data["struct4101"] = struct4101
  18207. data["pp"] = pp
  18208. bytesData, _ := json.Marshal(data)
  18209. if miConfig.MdtrtareaAdmvs == "320921" {
  18210. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18211. } else {
  18212. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18213. }
  18214. resp, _ := client.Do(req)
  18215. defer resp.Body.Close()
  18216. body, ioErr := ioutil.ReadAll(resp.Body)
  18217. if ioErr != nil {
  18218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18220. return
  18221. }
  18222. var respJSON map[string]interface{}
  18223. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18226. return
  18227. }
  18228. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18229. userJSONBytes, _ := json.Marshal(respJSON)
  18230. fmt.Println("log")
  18231. fmt.Println(string(userJSONBytes))
  18232. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18233. utils.ErrorLog("解析失败:%v", err)
  18234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18235. return
  18236. }
  18237. res.InfRefmsgid = resOther.InfRefmsgid
  18238. res.Output = resOther.Output
  18239. res.ErrMsg = resOther.ErrMsg
  18240. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18241. res.Infcode = infocode
  18242. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18243. var pp models.PublicParams
  18244. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18245. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18246. pp.FixmedinsName = miConfig.OrgName
  18247. pp.FixmedinsCode = miConfig.Code
  18248. pp.RequestUrl = miConfig.Url
  18249. pp.Cainfo = miConfig.Cainfo
  18250. pp.SecretKey = miConfig.SecretKey
  18251. pp.AccessKey = miConfig.AccessKey
  18252. pp.OpterName = curRoles.UserName
  18253. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18254. result, _ := service.Jxyb4101(struct4101, pp)
  18255. var dat map[string]interface{}
  18256. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18257. fmt.Println(dat)
  18258. } else {
  18259. fmt.Println(err)
  18260. }
  18261. userJSONBytes, _ := json.Marshal(dat)
  18262. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18263. utils.ErrorLog("解析失败:%v", err)
  18264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18265. return
  18266. }
  18267. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18268. var pp models.PublicParams
  18269. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18270. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18271. pp.FixmedinsName = miConfig.OrgName
  18272. pp.FixmedinsCode = miConfig.Code
  18273. pp.RequestUrl = miConfig.Url
  18274. pp.Cainfo = miConfig.Cainfo
  18275. pp.SecretKey = miConfig.SecretKey
  18276. pp.AccessKey = miConfig.AccessKey
  18277. pp.OpterName = curRoles.UserName
  18278. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18279. result, _ := service.Jxyb4101(struct4101, pp)
  18280. var dat map[string]interface{}
  18281. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18282. fmt.Println(dat)
  18283. } else {
  18284. fmt.Println(err)
  18285. }
  18286. userJSONBytes, _ := json.Marshal(dat)
  18287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18288. utils.ErrorLog("解析失败:%v", err)
  18289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18290. return
  18291. }
  18292. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18293. var pp models.PublicParams
  18294. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18295. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18296. pp.FixmedinsName = miConfig.OrgName
  18297. pp.FixmedinsCode = miConfig.Code
  18298. pp.RequestUrl = miConfig.Url
  18299. pp.Cainfo = miConfig.Cainfo
  18300. pp.SecretKey = miConfig.SecretKey
  18301. pp.AccessKey = miConfig.AccessKey
  18302. pp.OpterName = curRoles.UserName
  18303. result, _ := service.Hnyb4101(struct4101, pp)
  18304. var dat map[string]interface{}
  18305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18306. fmt.Println(dat)
  18307. } else {
  18308. fmt.Println(err)
  18309. }
  18310. userJSONBytes, _ := json.Marshal(dat)
  18311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18312. utils.ErrorLog("解析失败:%v", err)
  18313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18314. return
  18315. }
  18316. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18317. var resOther ResultSeventeenOther
  18318. var pp models.PublicParams
  18319. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18320. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18321. pp.FixmedinsName = miConfig.OrgName
  18322. pp.FixmedinsCode = miConfig.Code
  18323. pp.RequestUrl = miConfig.Url
  18324. pp.Cainfo = miConfig.Cainfo
  18325. pp.SecretKey = miConfig.SecretKey
  18326. pp.AccessKey = miConfig.AccessKey
  18327. pp.OpterName = curRoles.UserName
  18328. client := &http.Client{}
  18329. var req *http.Request
  18330. data := make(map[string]interface{})
  18331. data["struct4101"] = struct4101
  18332. data["pp"] = pp
  18333. bytesData, _ := json.Marshal(data)
  18334. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18335. resp, _ := client.Do(req)
  18336. defer resp.Body.Close()
  18337. body, ioErr := ioutil.ReadAll(resp.Body)
  18338. if ioErr != nil {
  18339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18341. return
  18342. }
  18343. var respJSON map[string]interface{}
  18344. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18347. return
  18348. }
  18349. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18350. userJSONBytes, _ := json.Marshal(respJSON)
  18351. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18352. utils.ErrorLog("解析失败:%v", err)
  18353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18354. return
  18355. }
  18356. res.InfRefmsgid = resOther.InfRefmsgid
  18357. res.Output = resOther.Output
  18358. res.ErrMsg = resOther.ErrMsg
  18359. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18360. res.Infcode = infocode
  18361. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18362. var pp models.PublicParams
  18363. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18364. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18365. pp.FixmedinsName = miConfig.OrgName
  18366. pp.FixmedinsCode = miConfig.Code
  18367. pp.RequestUrl = miConfig.Url
  18368. pp.Cainfo = miConfig.Cainfo
  18369. pp.SecretKey = miConfig.SecretKey
  18370. pp.AccessKey = miConfig.AccessKey
  18371. pp.OpterName = curRoles.UserName
  18372. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18373. fmt.Println(requestLog)
  18374. fmt.Println(errMsgLog)
  18375. saveLog(result, requestLog, "4101a", "上传清单")
  18376. var dat map[string]interface{}
  18377. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18378. fmt.Println(dat)
  18379. } else {
  18380. fmt.Println(err)
  18381. }
  18382. userJSONBytes, _ := json.Marshal(dat)
  18383. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18384. utils.ErrorLog("解析失败:%v", err)
  18385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18386. return
  18387. }
  18388. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18389. var pp models.PublicParams
  18390. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18391. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18392. pp.FixmedinsName = miConfig.OrgName
  18393. pp.FixmedinsCode = miConfig.Code
  18394. pp.RequestUrl = miConfig.Url
  18395. pp.Cainfo = miConfig.Cainfo
  18396. pp.SecretKey = miConfig.SecretKey
  18397. pp.AccessKey = miConfig.AccessKey
  18398. pp.OpterName = curRoles.UserName
  18399. client := &http.Client{}
  18400. var req *http.Request
  18401. data := make(map[string]interface{})
  18402. data["struct4101"] = struct4101
  18403. data["pp"] = pp
  18404. bytesData, _ := json.Marshal(data)
  18405. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  18406. resp, _ := client.Do(req)
  18407. defer resp.Body.Close()
  18408. body, ioErr := ioutil.ReadAll(resp.Body)
  18409. if ioErr != nil {
  18410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18412. return
  18413. }
  18414. var respJSON map[string]interface{}
  18415. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18418. return
  18419. }
  18420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18421. userJSONBytes, _ := json.Marshal(respJSON)
  18422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18423. utils.ErrorLog("解析失败:%v", err)
  18424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18425. return
  18426. }
  18427. } else {
  18428. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18429. var dat map[string]interface{}
  18430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18431. fmt.Println(dat)
  18432. } else {
  18433. fmt.Println(err)
  18434. }
  18435. userJSONBytes, _ := json.Marshal(dat)
  18436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18437. utils.ErrorLog("解析失败:%v", err)
  18438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18439. return
  18440. }
  18441. }
  18442. if res.Infcode != 0 {
  18443. errlog := &models.HisOrderError{
  18444. UserOrgId: order.UserOrgId,
  18445. Ctime: time.Now().Unix(),
  18446. Mtime: time.Now().Unix(),
  18447. ErrMsg: res.ErrMsg + "解析失败",
  18448. Status: 1,
  18449. PatientId: order.ID,
  18450. Stage: 10485,
  18451. }
  18452. service.CreateErrMsgLog(errlog)
  18453. continue
  18454. //c.ServeSuccessJSON(map[string]interface{}{
  18455. // "failed_code": -10,
  18456. // "msg": res.ErrMsg,
  18457. //})
  18458. } else {
  18459. //order.FaPiaoNumber = zero
  18460. //order.FaPiaoCode = last_order.FaPiaoCode
  18461. //service.UpdateOrder(order)
  18462. hisFundSettleListResult := &models.HisFundSettleListResult{
  18463. Number: res.Output.SetlListId,
  18464. Status: 1,
  18465. Ctime: time.Now().Unix(),
  18466. Mtime: time.Now().Unix(),
  18467. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18468. IsUpload: 1,
  18469. OrderId: order.ID,
  18470. }
  18471. service.CreateUploadRecord(hisFundSettleListResult)
  18472. continue
  18473. }
  18474. }
  18475. }
  18476. func (c *HisApiController) GetSettleList() {
  18477. order_id, _ := c.GetInt64("order_id")
  18478. admin_user_id, _ := c.GetInt64("admin_user_id")
  18479. order, _ := service.GetHisOrderByIDTwo(order_id)
  18480. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18481. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18482. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18483. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18484. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18485. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18486. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18487. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18488. if order.ID == 0 {
  18489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18490. return
  18491. }
  18492. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18493. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18494. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18495. //fmt.Println(count)
  18496. //var zero string
  18497. //number := count + 1
  18498. //if number >= 1000 {
  18499. // zero = "0000" + strconv.FormatInt(number, 10)
  18500. //} else if number >= 10000 {
  18501. // zero = "000" + strconv.FormatInt(number, 10)
  18502. //} else if number >= 100000 {
  18503. // zero = "00" + strconv.FormatInt(number, 10)
  18504. //} else if number >= 1000000 {
  18505. // zero = "0" + strconv.FormatInt(number, 10)
  18506. //} else {
  18507. // zero = strconv.FormatInt(number, 10)
  18508. //}
  18509. //fmt.Println(zero)
  18510. struct4101 := service.Struct4101{
  18511. PsnNo: order.PsnNo,
  18512. MdtrtId: order.MdtrtId,
  18513. SetlId: order.SetlId,
  18514. PsnName: order.PsnName,
  18515. Gend: order.Gend,
  18516. Brdy: his.Brdy,
  18517. Age: his.Age,
  18518. Naty: order.Naty,
  18519. PatnCertType: "01",
  18520. Certno: order.Certno,
  18521. Prfs: "90",
  18522. ConerName: roles[0].UserName,
  18523. PatnRlts: "99",
  18524. ConerAddr: miConfig.OrgName,
  18525. ConerTel: admin.Mobile,
  18526. HiType: order.Insutype,
  18527. Insuplc: miConfig.InsuplcAdmdvs,
  18528. MaindiagFlag: "1",
  18529. BillCode: order.SetlId,
  18530. BillNo: order.SetlId,
  18531. BizSn: order.Number,
  18532. PsnSelfPay: order.PsnPartAmt,
  18533. PsnOwnPay: order.PsnPartAmt,
  18534. AcctPay: order.AcctPay,
  18535. PsnCashpay: order.PsnCashPay,
  18536. HiPaymtd: "1",
  18537. Hsorg: miConfig.InsuplcAdmdvs,
  18538. HsorgOpter: miConfig.InsuplcAdmdvs,
  18539. MedinsFillPsn: curRoles.UserName,
  18540. MedinsFillDept: miConfig.OrgName,
  18541. IptMedType: "2",
  18542. }
  18543. struct4101.SetlBegnDate = order.SetlTime
  18544. struct4101.SetlEndDate = order.SetlTime
  18545. time_arr := strings.Split(order.SetlTime, " ")
  18546. struct4101.AdmTime = time_arr[0]
  18547. struct4101.AdmEndTime = time_arr[0]
  18548. //
  18549. //var rf []CustomFundPay
  18550. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18551. //
  18552. //var tempFunPays []service.CustomStruct
  18553. //for _, item := range rf {
  18554. // var tempFunPay service.CustomStruct
  18555. // tempFunPay.FundPayamt = item.FundPayamt
  18556. // tempFunPay.FundPayType = item.FundPayType
  18557. // tempFunPays = append(tempFunPays, tempFunPay)
  18558. //}
  18559. //struct4101.CustomStruct = tempFunPays
  18560. var tempDiaginfos []service.DiaginfoStructTwo
  18561. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18562. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18563. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  18564. var config []*models.HisXtDiagnoseConfig
  18565. for _, item := range diagnosis_ids {
  18566. id, _ := strconv.ParseInt(item, 10, 64)
  18567. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18568. config = append(config, &diagnosisConfig)
  18569. }
  18570. if miConfig.Code == "H15049901371" {
  18571. //for _, item := range config {
  18572. // if item.ID == 138 {
  18573. diagnosisConfig, _ := service.FindDiagnoseById(138)
  18574. var tempDiaginfo service.DiaginfoStructTwo
  18575. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  18576. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  18577. tempDiaginfo.DiagType = "1"
  18578. tempDiaginfo.MaindiagFlag = "1"
  18579. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18580. //}
  18581. //}
  18582. for _, item := range config {
  18583. if item.ID != 138 {
  18584. var tempDiaginfo service.DiaginfoStructTwo
  18585. tempDiaginfo.DiagCode = item.CountryCode
  18586. tempDiaginfo.DiagName = item.CountryContentName
  18587. tempDiaginfo.DiagType = "1"
  18588. tempDiaginfo.MaindiagFlag = "0"
  18589. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18590. }
  18591. }
  18592. } else {
  18593. for index, item := range config {
  18594. if index == 0 {
  18595. var tempDiaginfo service.DiaginfoStructTwo
  18596. tempDiaginfo.DiagCode = item.CountryCode
  18597. tempDiaginfo.DiagName = item.CountryContentName
  18598. tempDiaginfo.DiagType = "1"
  18599. tempDiaginfo.MaindiagFlag = "1"
  18600. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18601. } else {
  18602. var tempDiaginfo service.DiaginfoStructTwo
  18603. tempDiaginfo.DiagCode = item.CountryCode
  18604. tempDiaginfo.DiagName = item.CountryContentName
  18605. tempDiaginfo.DiagType = "1"
  18606. tempDiaginfo.MaindiagFlag = "0"
  18607. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18608. }
  18609. }
  18610. }
  18611. struct4101.Diseinfo = tempDiaginfos
  18612. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18613. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18614. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18615. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18616. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18617. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18618. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18619. var iteminfo service.IteminfoStruct
  18620. var bedCostTotal float64 = 0 //床位总费
  18621. var bedCostSelfTotal float64 = 0 //床位自费
  18622. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18623. var operationCostTotal float64 = 0 //手术费
  18624. var operationCostSelfTotal float64 = 0 //手术费
  18625. var operationCostPartSelfTotal float64 = 0 //手术费
  18626. var otherCostTotal float64 = 0 //其他费用
  18627. var otherCostSelfTotal float64 = 0 //其他费用
  18628. var otherCostPartSelfTotal float64 = 0 //其他费用
  18629. var materialCostTotal float64 = 0 //材料费
  18630. var materialCostSelfTotal float64 = 0 //材料费
  18631. var materialCostPartSelfTotal float64 = 0 //材料费
  18632. var westernMedicineCostTotal float64 = 0 //西药费
  18633. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18634. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18635. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18636. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18637. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18638. var checkCostTotal float64 = 0 //检查费
  18639. var checkCostSelfTotal float64 = 0 //检查费
  18640. var checkCostPartSelfTotal float64 = 0 //检查费
  18641. var laboratoryCostTotal float64 = 0 //化验费
  18642. var laboratoryCostSelfTotal float64 = 0 //化验费
  18643. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18644. var treatCostTotal float64 = 0 //治疗费用
  18645. var treatCostSelfTotal float64 = 0 //治疗费用
  18646. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18647. decimal.DivisionPrecision = 2
  18648. var bed_fulamt_ownpay_amt float64 = 0
  18649. var operation_fulamt_ownpay_amt float64 = 0
  18650. var other_fulamt_ownpay_amt float64 = 0
  18651. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18652. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18653. var check_fulamt_ownpay_amt float64 = 0
  18654. var material_fulamt_ownpay_amt float64 = 0
  18655. var laboratory_fulamt_ownpay_amt float64 = 0
  18656. var treat_fulamt_ownpay_amt float64 = 0
  18657. var bed_claa_sunmfee float64 = 0
  18658. var bed_clab_amt float64 = 0
  18659. var bed_other_amt float64 = 0
  18660. var operation_claa_sunmfee float64 = 0
  18661. var operation_clab_amt float64 = 0
  18662. var operation_other_amt float64 = 0
  18663. var other_claa_sunmfee float64 = 0
  18664. var other_clab_amt float64 = 0
  18665. var other_other_amt float64 = 0
  18666. var westernMedicine_claa_sunmfee float64 = 0
  18667. var westernMedicine_clab_amt float64 = 0
  18668. var westernMedicine_other_amt float64 = 0
  18669. var chineseTraditional_claa_sunmfee float64 = 0
  18670. var chineseTraditional_clab_amt float64 = 0
  18671. var chineseTraditional_other_amt float64 = 0
  18672. var check_claa_sunmfee float64 = 0
  18673. var check_clab_amt float64 = 0
  18674. var check_other_amt float64 = 0
  18675. var material_claa_sunmfee float64 = 0
  18676. var material_clab_amt float64 = 0
  18677. var material_other_amt float64 = 0
  18678. var laboratory_claa_sunmfee float64 = 0
  18679. var laboratory_clab_amt float64 = 0
  18680. var laboratory_other_amt float64 = 0
  18681. var treat_claa_sunmfee float64 = 0
  18682. var treat_clab_amt float64 = 0
  18683. var treat_other_amt float64 = 0
  18684. for _, item := range order.HisOrderInfo {
  18685. if item.MedChrgitmType == "01" { //床位费
  18686. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18687. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18688. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18689. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18690. if item.ChrgitmLv == "1" {
  18691. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18692. }
  18693. if item.ChrgitmLv == "2" {
  18694. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18695. }
  18696. if item.ChrgitmLv == "3" {
  18697. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18698. }
  18699. }
  18700. if item.MedChrgitmType == "03" { //检查费
  18701. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18702. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18703. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18704. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18705. if item.ChrgitmLv == "1" {
  18706. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18707. }
  18708. if item.ChrgitmLv == "2" {
  18709. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18710. }
  18711. if item.ChrgitmLv == "3" {
  18712. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18713. }
  18714. }
  18715. if item.MedChrgitmType == "04" { //化验费
  18716. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18717. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18718. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18719. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18720. if item.ChrgitmLv == "1" {
  18721. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18722. }
  18723. if item.ChrgitmLv == "2" {
  18724. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18725. }
  18726. if item.ChrgitmLv == "3" {
  18727. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18728. }
  18729. }
  18730. if item.MedChrgitmType == "05" { //治疗费
  18731. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18732. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18733. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18734. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18735. if item.ChrgitmLv == "1" {
  18736. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18737. }
  18738. if item.ChrgitmLv == "2" {
  18739. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18740. }
  18741. if item.ChrgitmLv == "3" {
  18742. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18743. }
  18744. }
  18745. if item.MedChrgitmType == "06" { //手术费
  18746. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18747. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18748. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18749. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18750. if item.ChrgitmLv == "1" {
  18751. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18752. }
  18753. if item.ChrgitmLv == "2" {
  18754. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18755. }
  18756. if item.ChrgitmLv == "3" {
  18757. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18758. }
  18759. }
  18760. if item.MedChrgitmType == "08" { //材料费
  18761. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18762. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18763. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18764. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18765. if item.ChrgitmLv == "1" {
  18766. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18767. }
  18768. if item.ChrgitmLv == "2" {
  18769. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18770. }
  18771. if item.ChrgitmLv == "3" {
  18772. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18773. }
  18774. }
  18775. if item.MedChrgitmType == "09" { //西药费
  18776. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18777. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18778. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18779. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18780. if item.ChrgitmLv == "1" {
  18781. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18782. }
  18783. if item.ChrgitmLv == "2" {
  18784. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18785. }
  18786. if item.ChrgitmLv == "3" {
  18787. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18788. }
  18789. }
  18790. if item.MedChrgitmType == "11" { //中成费
  18791. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18792. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18793. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18794. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18795. if item.ChrgitmLv == "1" {
  18796. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18797. }
  18798. if item.ChrgitmLv == "2" {
  18799. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18800. }
  18801. if item.ChrgitmLv == "3" {
  18802. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18803. }
  18804. }
  18805. if item.MedChrgitmType == "14" { //其他费
  18806. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18807. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18808. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18809. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18810. if item.ChrgitmLv == "1" {
  18811. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18812. }
  18813. if item.ChrgitmLv == "2" {
  18814. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18815. }
  18816. if item.ChrgitmLv == "3" {
  18817. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18818. }
  18819. }
  18820. }
  18821. var iteminfoStructs []service.IteminfoStruct
  18822. if bedCostTotal != 0 {
  18823. iteminfo.MedChrgitm = "01"
  18824. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18825. iteminfo.Amt = bedCostTotal
  18826. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18827. iteminfo.ClabAmt = bed_clab_amt
  18828. iteminfo.OthAmt = bed_other_amt
  18829. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18830. }
  18831. if checkCostTotal != 0 {
  18832. iteminfo.MedChrgitm = "03"
  18833. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18834. iteminfo.Amt = checkCostTotal
  18835. iteminfo.ClaaSumfee = check_claa_sunmfee
  18836. iteminfo.ClabAmt = check_clab_amt
  18837. iteminfo.OthAmt = check_other_amt
  18838. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18839. }
  18840. if laboratoryCostTotal != 0 {
  18841. iteminfo.MedChrgitm = "04"
  18842. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18843. iteminfo.Amt = laboratoryCostTotal
  18844. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18845. iteminfo.ClabAmt = laboratory_clab_amt
  18846. iteminfo.OthAmt = laboratory_other_amt
  18847. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18848. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18849. }
  18850. if treatCostTotal != 0 {
  18851. iteminfo.MedChrgitm = "05"
  18852. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18853. iteminfo.Amt = treatCostTotal
  18854. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18855. iteminfo.ClabAmt = treat_clab_amt
  18856. iteminfo.OthAmt = treat_other_amt
  18857. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18858. //(struct4101.IteminfoStruct, iteminfo)
  18859. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18860. }
  18861. if operationCostTotal != 0 {
  18862. iteminfo.MedChrgitm = "06"
  18863. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18864. iteminfo.Amt = operationCostTotal
  18865. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18866. iteminfo.ClabAmt = operation_clab_amt
  18867. iteminfo.OthAmt = operation_other_amt
  18868. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18869. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18870. }
  18871. if materialCostTotal != 0 {
  18872. iteminfo.MedChrgitm = "08"
  18873. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18874. iteminfo.Amt = materialCostTotal
  18875. iteminfo.ClaaSumfee = material_claa_sunmfee
  18876. iteminfo.ClabAmt = material_clab_amt
  18877. iteminfo.OthAmt = material_other_amt
  18878. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18879. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18880. }
  18881. if westernMedicineCostTotal != 0 {
  18882. iteminfo.MedChrgitm = "09"
  18883. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18884. iteminfo.Amt = westernMedicineCostTotal
  18885. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18886. iteminfo.ClabAmt = westernMedicine_clab_amt
  18887. iteminfo.OthAmt = westernMedicine_other_amt
  18888. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18889. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18890. }
  18891. if chineseTraditionalMedicineCostTotal != 0 {
  18892. iteminfo.MedChrgitm = "11"
  18893. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18894. iteminfo.Amt = westernMedicineCostTotal
  18895. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18896. iteminfo.ClabAmt = westernMedicine_clab_amt
  18897. iteminfo.OthAmt = westernMedicine_other_amt
  18898. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18899. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18900. }
  18901. if otherCostTotal != 0 {
  18902. iteminfo.MedChrgitm = "14"
  18903. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18904. iteminfo.Amt = otherCostTotal
  18905. iteminfo.ClaaSumfee = other_claa_sunmfee
  18906. iteminfo.ClabAmt = other_clab_amt
  18907. iteminfo.OthAmt = other_other_amt
  18908. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18909. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18910. }
  18911. struct4101.IteminfoStruct = iteminfoStructs
  18912. struct4101.Ntly = "中国"
  18913. struct4101.AdmCaty = "A03.06"
  18914. struct4101.DoctorName = doctor.UserName
  18915. struct4101.DoctorCode = doctor.DoctorNumber
  18916. var res ResultSeventeen
  18917. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18918. struct4101.BillCode = order.Number
  18919. struct4101.BillNo = order.SetlId
  18920. var resOther ResultSeventeenOther
  18921. var pp models.PublicParams
  18922. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18923. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18924. pp.FixmedinsName = miConfig.OrgName
  18925. pp.FixmedinsCode = miConfig.Code
  18926. pp.RequestUrl = miConfig.Url
  18927. pp.Cainfo = miConfig.Cainfo
  18928. pp.SecretKey = miConfig.SecretKey
  18929. pp.AccessKey = miConfig.AccessKey
  18930. pp.OpterName = curRoles.UserName
  18931. client := &http.Client{}
  18932. var req *http.Request
  18933. data := make(map[string]interface{})
  18934. data["struct4101"] = struct4101
  18935. data["pp"] = pp
  18936. bytesData, _ := json.Marshal(data)
  18937. if miConfig.MdtrtareaAdmvs == "320921" {
  18938. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18939. } else {
  18940. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18941. }
  18942. resp, _ := client.Do(req)
  18943. defer resp.Body.Close()
  18944. body, ioErr := ioutil.ReadAll(resp.Body)
  18945. if ioErr != nil {
  18946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18948. return
  18949. }
  18950. var respJSON map[string]interface{}
  18951. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18954. return
  18955. }
  18956. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18957. userJSONBytes, _ := json.Marshal(respJSON)
  18958. fmt.Println("log")
  18959. fmt.Println(string(userJSONBytes))
  18960. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18961. utils.ErrorLog("解析失败:%v", err)
  18962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18963. return
  18964. }
  18965. res.InfRefmsgid = resOther.InfRefmsgid
  18966. res.Output = resOther.Output
  18967. res.ErrMsg = resOther.ErrMsg
  18968. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18969. res.Infcode = infocode
  18970. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18971. var pp models.PublicParams
  18972. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18973. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18974. pp.FixmedinsName = miConfig.OrgName
  18975. pp.FixmedinsCode = miConfig.Code
  18976. pp.RequestUrl = miConfig.Url
  18977. pp.Cainfo = miConfig.Cainfo
  18978. pp.SecretKey = miConfig.SecretKey
  18979. pp.AccessKey = miConfig.AccessKey
  18980. pp.OpterName = curRoles.UserName
  18981. result, _ := service.Jxyb4101(struct4101, pp)
  18982. var dat map[string]interface{}
  18983. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18984. fmt.Println(dat)
  18985. } else {
  18986. fmt.Println(err)
  18987. }
  18988. userJSONBytes, _ := json.Marshal(dat)
  18989. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18990. utils.ErrorLog("解析失败:%v", err)
  18991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18992. return
  18993. }
  18994. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18995. var pp models.PublicParams
  18996. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18997. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18998. pp.FixmedinsName = miConfig.OrgName
  18999. pp.FixmedinsCode = miConfig.Code
  19000. pp.RequestUrl = miConfig.Url
  19001. pp.Cainfo = miConfig.Cainfo
  19002. pp.SecretKey = miConfig.SecretKey
  19003. pp.AccessKey = miConfig.AccessKey
  19004. pp.OpterName = curRoles.UserName
  19005. result, _ := service.Jxyb4101(struct4101, pp)
  19006. var dat map[string]interface{}
  19007. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19008. fmt.Println(dat)
  19009. } else {
  19010. fmt.Println(err)
  19011. }
  19012. userJSONBytes, _ := json.Marshal(dat)
  19013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19014. utils.ErrorLog("解析失败:%v", err)
  19015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19016. return
  19017. }
  19018. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19019. var pp models.PublicParams
  19020. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19021. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19022. pp.FixmedinsName = miConfig.OrgName
  19023. pp.FixmedinsCode = miConfig.Code
  19024. pp.RequestUrl = miConfig.Url
  19025. pp.Cainfo = miConfig.Cainfo
  19026. pp.SecretKey = miConfig.SecretKey
  19027. pp.AccessKey = miConfig.AccessKey
  19028. pp.OpterName = curRoles.UserName
  19029. result, _ := service.Hnyb4101(struct4101, pp)
  19030. var dat map[string]interface{}
  19031. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19032. fmt.Println(dat)
  19033. } else {
  19034. fmt.Println(err)
  19035. }
  19036. userJSONBytes, _ := json.Marshal(dat)
  19037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19038. utils.ErrorLog("解析失败:%v", err)
  19039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19040. return
  19041. }
  19042. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19043. var resOther ResultSeventeenOther
  19044. var pp models.PublicParams
  19045. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19046. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19047. pp.FixmedinsName = miConfig.OrgName
  19048. pp.FixmedinsCode = miConfig.Code
  19049. pp.RequestUrl = miConfig.Url
  19050. pp.Cainfo = miConfig.Cainfo
  19051. pp.SecretKey = miConfig.SecretKey
  19052. pp.AccessKey = miConfig.AccessKey
  19053. pp.OpterName = curRoles.UserName
  19054. client := &http.Client{}
  19055. var req *http.Request
  19056. data := make(map[string]interface{})
  19057. data["struct4101"] = struct4101
  19058. data["pp"] = pp
  19059. bytesData, _ := json.Marshal(data)
  19060. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19061. resp, _ := client.Do(req)
  19062. defer resp.Body.Close()
  19063. body, ioErr := ioutil.ReadAll(resp.Body)
  19064. if ioErr != nil {
  19065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19067. return
  19068. }
  19069. var respJSON map[string]interface{}
  19070. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19073. return
  19074. }
  19075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19076. userJSONBytes, _ := json.Marshal(respJSON)
  19077. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19078. utils.ErrorLog("解析失败:%v", err)
  19079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19080. return
  19081. }
  19082. res.InfRefmsgid = resOther.InfRefmsgid
  19083. res.Output = resOther.Output
  19084. res.ErrMsg = resOther.ErrMsg
  19085. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19086. res.Infcode = infocode
  19087. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19088. var pp models.PublicParams
  19089. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19090. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19091. pp.FixmedinsName = miConfig.OrgName
  19092. pp.FixmedinsCode = miConfig.Code
  19093. pp.RequestUrl = miConfig.Url
  19094. pp.Cainfo = miConfig.Cainfo
  19095. pp.SecretKey = miConfig.SecretKey
  19096. pp.AccessKey = miConfig.AccessKey
  19097. pp.OpterName = curRoles.UserName
  19098. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19099. fmt.Println(requestLog)
  19100. fmt.Println(errMsgLog)
  19101. saveLog(result, requestLog, "4101a", "上传清单")
  19102. var dat map[string]interface{}
  19103. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19104. fmt.Println(dat)
  19105. } else {
  19106. fmt.Println(err)
  19107. }
  19108. userJSONBytes, _ := json.Marshal(dat)
  19109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19110. utils.ErrorLog("解析失败:%v", err)
  19111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19112. return
  19113. }
  19114. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19115. var pp models.PublicParams
  19116. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19117. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19118. pp.FixmedinsName = miConfig.OrgName
  19119. pp.FixmedinsCode = miConfig.Code
  19120. pp.RequestUrl = miConfig.Url
  19121. pp.Cainfo = miConfig.Cainfo
  19122. pp.SecretKey = miConfig.SecretKey
  19123. pp.AccessKey = miConfig.AccessKey
  19124. pp.OpterName = curRoles.UserName
  19125. client := &http.Client{}
  19126. var req *http.Request
  19127. data := make(map[string]interface{})
  19128. data["struct4101"] = struct4101
  19129. data["pp"] = pp
  19130. bytesData, _ := json.Marshal(data)
  19131. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19132. resp, _ := client.Do(req)
  19133. defer resp.Body.Close()
  19134. body, ioErr := ioutil.ReadAll(resp.Body)
  19135. if ioErr != nil {
  19136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19138. return
  19139. }
  19140. var respJSON map[string]interface{}
  19141. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19144. return
  19145. }
  19146. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19147. userJSONBytes, _ := json.Marshal(respJSON)
  19148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19149. utils.ErrorLog("解析失败:%v", err)
  19150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19151. return
  19152. }
  19153. } else {
  19154. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19155. var dat map[string]interface{}
  19156. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19157. fmt.Println(dat)
  19158. } else {
  19159. fmt.Println(err)
  19160. }
  19161. userJSONBytes, _ := json.Marshal(dat)
  19162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19163. utils.ErrorLog("解析失败:%v", err)
  19164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19165. return
  19166. }
  19167. }
  19168. if res.Infcode != 0 {
  19169. c.ServeSuccessJSON(map[string]interface{}{
  19170. "failed_code": -10,
  19171. "msg": res.ErrMsg,
  19172. })
  19173. return
  19174. } else {
  19175. //order.FaPiaoNumber = zero
  19176. //order.FaPiaoCode = last_order.FaPiaoCode
  19177. //service.UpdateOrder(order)
  19178. hisFundSettleListResult := &models.HisFundSettleListResult{
  19179. Number: res.Output.SetlListId,
  19180. Status: 1,
  19181. Ctime: time.Now().Unix(),
  19182. Mtime: time.Now().Unix(),
  19183. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19184. IsUpload: 1,
  19185. OrderId: order_id,
  19186. }
  19187. service.CreateUploadRecord(hisFundSettleListResult)
  19188. c.ServeSuccessJSON(map[string]interface{}{
  19189. "msg": "上传成功",
  19190. "result": hisFundSettleListResult,
  19191. })
  19192. return
  19193. }
  19194. }
  19195. func (c *HisApiController) GetSettleListHospital() {
  19196. order_id, _ := c.GetInt64("order_id")
  19197. admin_user_id, _ := c.GetInt64("admin_user_id")
  19198. order, _ := service.GetHisOrderByIDTwo(order_id)
  19199. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19200. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19201. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19202. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19203. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19204. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19205. if order.ID == 0 {
  19206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19207. return
  19208. }
  19209. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19210. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19211. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19212. fmt.Println(count)
  19213. var zero string
  19214. number := count + 1
  19215. if number >= 1000 {
  19216. zero = "0000" + strconv.FormatInt(number, 10)
  19217. } else if number >= 10000 {
  19218. zero = "000" + strconv.FormatInt(number, 10)
  19219. } else if number >= 100000 {
  19220. zero = "00" + strconv.FormatInt(number, 10)
  19221. } else if number >= 1000000 {
  19222. zero = "0" + strconv.FormatInt(number, 10)
  19223. } else {
  19224. zero = strconv.FormatInt(number, 10)
  19225. }
  19226. fmt.Println(zero)
  19227. struct4101 := service.Struct4101{
  19228. PsnNo: order.PsnNo,
  19229. MdtrtId: order.MdtrtId,
  19230. SetlId: order.SetlId,
  19231. PsnName: order.PsnName,
  19232. Gend: order.Gend,
  19233. Brdy: his.Brdy,
  19234. Age: int64(order.Age),
  19235. Naty: order.Naty,
  19236. PatnCertType: "01",
  19237. Certno: order.Certno,
  19238. Prfs: "90",
  19239. ConerName: roles[0].UserName,
  19240. PatnRlts: "99",
  19241. ConerAddr: miConfig.OrgName,
  19242. ConerTel: admin.Mobile,
  19243. HiType: order.Insutype,
  19244. Insuplc: miConfig.InsuplcAdmdvs,
  19245. MaindiagFlag: "1",
  19246. BillCode: order.SetlId,
  19247. BillNo: order.SetlId,
  19248. BizSn: order.Number,
  19249. PsnSelfPay: order.PsnPartAmt,
  19250. PsnOwnPay: order.PsnPartAmt,
  19251. AcctPay: order.AcctPay,
  19252. PsnCashpay: order.PsnCashPay,
  19253. HiPaymtd: "1",
  19254. Hsorg: miConfig.InsuplcAdmdvs,
  19255. HsorgOpter: miConfig.InsuplcAdmdvs,
  19256. MedinsFillPsn: curRoles.UserName,
  19257. MedinsFillDept: depart.Name,
  19258. IptMedType: "2",
  19259. AdmTime: his.InHosptialTime,
  19260. AdmEndTime: his.OutHosptialTime,
  19261. }
  19262. struct4101.SetlBegnDate = order.SetlTime
  19263. struct4101.SetlEndDate = order.SetlTime
  19264. //var rf []CustomFundPay
  19265. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19266. //
  19267. //var tempFunPays []service.CustomStruct
  19268. //for _, item := range rf {
  19269. // var tempFunPay service.CustomStruct
  19270. // tempFunPay.FundPayamt = item.FundPayamt
  19271. // tempFunPay.FundPayType = item.FundPayType
  19272. // tempFunPays = append(tempFunPays, tempFunPay)
  19273. //}
  19274. //struct4101.CustomStruct = tempFunPays
  19275. var tempDiaginfos []service.DiaginfoStructTwo
  19276. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19277. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19278. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19279. //for _, item := range infos {
  19280. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19281. //}
  19282. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19283. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19284. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19285. fmt.Println(diagnosis_ids_arr)
  19286. if order.UserOrgId == 10210 {
  19287. var diagnosis_ids_arr_two []int64
  19288. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19289. var config []*models.HisXtDiagnoseConfig
  19290. for _, id := range diagnosis_ids_arr_two {
  19291. //id, _ := strconv.ParseInt(item, 10, 64)
  19292. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19293. if diagnosisConfig.ID > 0 {
  19294. config = append(config, &diagnosisConfig)
  19295. }
  19296. }
  19297. for index, item := range config {
  19298. if item.ID > 0 {
  19299. if index == 0 {
  19300. var tempDiaginfo service.DiaginfoStructTwo
  19301. tempDiaginfo.DiagCode = item.CountryCode
  19302. tempDiaginfo.DiagName = item.CountryContentName
  19303. tempDiaginfo.DiagType = "1"
  19304. tempDiaginfo.MaindiagFlag = "1"
  19305. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19306. } else {
  19307. var tempDiaginfo service.DiaginfoStructTwo
  19308. tempDiaginfo.DiagCode = item.CountryCode
  19309. tempDiaginfo.DiagName = item.CountryContentName
  19310. tempDiaginfo.DiagType = "1"
  19311. tempDiaginfo.MaindiagFlag = "0"
  19312. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19313. }
  19314. }
  19315. }
  19316. struct4101.Diseinfo = tempDiaginfos
  19317. } else {
  19318. var config []*models.HisXtDiagnoseConfig
  19319. for _, item := range diagnosis_ids_arr {
  19320. id, _ := strconv.ParseInt(item, 10, 64)
  19321. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19322. if diagnosisConfig.ID > 0 {
  19323. config = append(config, &diagnosisConfig)
  19324. }
  19325. }
  19326. for index, item := range config {
  19327. if item.ID > 0 {
  19328. if index == 0 {
  19329. var tempDiaginfo service.DiaginfoStructTwo
  19330. tempDiaginfo.DiagCode = item.CountryCode
  19331. tempDiaginfo.DiagName = item.CountryContentName
  19332. tempDiaginfo.DiagType = "1"
  19333. tempDiaginfo.MaindiagFlag = "1"
  19334. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19335. } else {
  19336. var tempDiaginfo service.DiaginfoStructTwo
  19337. tempDiaginfo.DiagCode = item.CountryCode
  19338. tempDiaginfo.DiagName = item.CountryContentName
  19339. tempDiaginfo.DiagType = "1"
  19340. tempDiaginfo.MaindiagFlag = "0"
  19341. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19342. }
  19343. }
  19344. }
  19345. struct4101.Diseinfo = tempDiaginfos
  19346. }
  19347. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19348. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19349. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19350. tempOpspdiseinfo2.OprnOprtCode = ""
  19351. tempOpspdiseinfo2.OprnOprtName = ""
  19352. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19353. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19354. var iteminfo service.IteminfoStruct
  19355. var bedCostTotal float64 = 0 //床位总费
  19356. var bedCostSelfTotal float64 = 0 //床位自费
  19357. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19358. var operationCostTotal float64 = 0 //手术费
  19359. var operationCostSelfTotal float64 = 0 //手术费
  19360. var operationCostPartSelfTotal float64 = 0 //手术费
  19361. var otherCostTotal float64 = 0 //其他费用
  19362. var otherCostSelfTotal float64 = 0 //其他费用
  19363. var otherCostPartSelfTotal float64 = 0 //其他费用
  19364. var materialCostTotal float64 = 0 //材料费
  19365. var materialCostSelfTotal float64 = 0 //材料费
  19366. var materialCostPartSelfTotal float64 = 0 //材料费
  19367. var westernMedicineCostTotal float64 = 0 //西药费
  19368. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19369. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19370. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19371. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19372. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19373. var checkCostTotal float64 = 0 //检查费
  19374. var checkCostSelfTotal float64 = 0 //检查费
  19375. var checkCostPartSelfTotal float64 = 0 //检查费
  19376. var laboratoryCostTotal float64 = 0 //化验费
  19377. var laboratoryCostSelfTotal float64 = 0 //化验费
  19378. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19379. var treatCostTotal float64 = 0 //治疗费用
  19380. var treatCostSelfTotal float64 = 0 //治疗费用
  19381. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19382. decimal.DivisionPrecision = 2
  19383. var bed_fulamt_ownpay_amt float64 = 0
  19384. var operation_fulamt_ownpay_amt float64 = 0
  19385. var other_fulamt_ownpay_amt float64 = 0
  19386. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19387. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19388. var check_fulamt_ownpay_amt float64 = 0
  19389. var material_fulamt_ownpay_amt float64 = 0
  19390. var laboratory_fulamt_ownpay_amt float64 = 0
  19391. var treat_fulamt_ownpay_amt float64 = 0
  19392. var bed_claa_sunmfee float64 = 0
  19393. var bed_clab_amt float64 = 0
  19394. var bed_other_amt float64 = 0
  19395. var operation_claa_sunmfee float64 = 0
  19396. var operation_clab_amt float64 = 0
  19397. var operation_other_amt float64 = 0
  19398. var other_claa_sunmfee float64 = 0
  19399. var other_clab_amt float64 = 0
  19400. var other_other_amt float64 = 0
  19401. var westernMedicine_claa_sunmfee float64 = 0
  19402. var westernMedicine_clab_amt float64 = 0
  19403. var westernMedicine_other_amt float64 = 0
  19404. var chineseTraditional_claa_sunmfee float64 = 0
  19405. var chineseTraditional_clab_amt float64 = 0
  19406. var chineseTraditional_other_amt float64 = 0
  19407. var check_claa_sunmfee float64 = 0
  19408. var check_clab_amt float64 = 0
  19409. var check_other_amt float64 = 0
  19410. var material_claa_sunmfee float64 = 0
  19411. var material_clab_amt float64 = 0
  19412. var material_other_amt float64 = 0
  19413. var laboratory_claa_sunmfee float64 = 0
  19414. var laboratory_clab_amt float64 = 0
  19415. var laboratory_other_amt float64 = 0
  19416. var treat_claa_sunmfee float64 = 0
  19417. var treat_clab_amt float64 = 0
  19418. var treat_other_amt float64 = 0
  19419. for _, item := range order.HisOrderInfo {
  19420. if item.MedChrgitmType == "01" { //床位费
  19421. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19422. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19423. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19424. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19425. if item.ChrgitmLv == "1" {
  19426. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19427. }
  19428. if item.ChrgitmLv == "2" {
  19429. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19430. }
  19431. if item.ChrgitmLv == "3" {
  19432. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19433. }
  19434. }
  19435. if item.MedChrgitmType == "03" { //检查费
  19436. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19437. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19438. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19439. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19440. if item.ChrgitmLv == "1" {
  19441. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19442. }
  19443. if item.ChrgitmLv == "2" {
  19444. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19445. }
  19446. if item.ChrgitmLv == "3" {
  19447. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19448. }
  19449. }
  19450. if item.MedChrgitmType == "04" { //化验费
  19451. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19452. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19453. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19454. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19455. if item.ChrgitmLv == "1" {
  19456. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19457. }
  19458. if item.ChrgitmLv == "2" {
  19459. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19460. }
  19461. if item.ChrgitmLv == "3" {
  19462. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19463. }
  19464. }
  19465. if item.MedChrgitmType == "05" { //治疗费
  19466. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19467. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19468. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19469. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19470. if item.ChrgitmLv == "1" {
  19471. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19472. }
  19473. if item.ChrgitmLv == "2" {
  19474. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19475. }
  19476. if item.ChrgitmLv == "3" {
  19477. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19478. }
  19479. }
  19480. if item.MedChrgitmType == "06" { //手术费
  19481. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19482. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19483. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19484. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19485. if item.ChrgitmLv == "1" {
  19486. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19487. }
  19488. if item.ChrgitmLv == "2" {
  19489. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19490. }
  19491. if item.ChrgitmLv == "3" {
  19492. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19493. }
  19494. }
  19495. if item.MedChrgitmType == "08" { //材料费
  19496. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19497. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19498. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19499. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19500. if item.ChrgitmLv == "1" {
  19501. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19502. }
  19503. if item.ChrgitmLv == "2" {
  19504. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19505. }
  19506. if item.ChrgitmLv == "3" {
  19507. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19508. }
  19509. }
  19510. if item.MedChrgitmType == "09" { //西药费
  19511. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19512. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19513. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19514. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19515. if item.ChrgitmLv == "1" {
  19516. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19517. }
  19518. if item.ChrgitmLv == "2" {
  19519. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19520. }
  19521. if item.ChrgitmLv == "3" {
  19522. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19523. }
  19524. }
  19525. if item.MedChrgitmType == "11" { //中成费
  19526. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19527. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19528. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19529. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19530. if item.ChrgitmLv == "1" {
  19531. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19532. }
  19533. if item.ChrgitmLv == "2" {
  19534. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19535. }
  19536. if item.ChrgitmLv == "3" {
  19537. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19538. }
  19539. }
  19540. if item.MedChrgitmType == "14" { //其他费
  19541. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19542. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19543. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19544. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19545. if item.ChrgitmLv == "1" {
  19546. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19547. }
  19548. if item.ChrgitmLv == "2" {
  19549. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19550. }
  19551. if item.ChrgitmLv == "3" {
  19552. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19553. }
  19554. }
  19555. }
  19556. var iteminfoStructs []service.IteminfoStruct
  19557. if bedCostTotal != 0 {
  19558. iteminfo.MedChrgitm = "01"
  19559. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19560. iteminfo.Amt = bedCostTotal
  19561. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19562. iteminfo.ClabAmt = bed_clab_amt
  19563. iteminfo.OthAmt = bed_other_amt
  19564. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19565. }
  19566. if checkCostTotal != 0 {
  19567. iteminfo.MedChrgitm = "03"
  19568. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19569. iteminfo.Amt = checkCostTotal
  19570. iteminfo.ClaaSumfee = check_claa_sunmfee
  19571. iteminfo.ClabAmt = check_clab_amt
  19572. iteminfo.OthAmt = check_other_amt
  19573. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19574. }
  19575. if laboratoryCostTotal != 0 {
  19576. iteminfo.MedChrgitm = "04"
  19577. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19578. iteminfo.Amt = laboratoryCostTotal
  19579. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19580. iteminfo.ClabAmt = laboratory_clab_amt
  19581. iteminfo.OthAmt = laboratory_other_amt
  19582. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19583. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19584. }
  19585. if treatCostTotal != 0 {
  19586. iteminfo.MedChrgitm = "05"
  19587. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19588. iteminfo.Amt = treatCostTotal
  19589. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19590. iteminfo.ClabAmt = treat_clab_amt
  19591. iteminfo.OthAmt = treat_other_amt
  19592. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19593. //(struct4101.IteminfoStruct, iteminfo)
  19594. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19595. }
  19596. if operationCostTotal != 0 {
  19597. iteminfo.MedChrgitm = "06"
  19598. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19599. iteminfo.Amt = operationCostTotal
  19600. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19601. iteminfo.ClabAmt = operation_clab_amt
  19602. iteminfo.OthAmt = operation_other_amt
  19603. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19604. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19605. }
  19606. if materialCostTotal != 0 {
  19607. iteminfo.MedChrgitm = "08"
  19608. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19609. iteminfo.Amt = materialCostTotal
  19610. iteminfo.ClaaSumfee = material_claa_sunmfee
  19611. iteminfo.ClabAmt = material_clab_amt
  19612. iteminfo.OthAmt = material_other_amt
  19613. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19614. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19615. }
  19616. if westernMedicineCostTotal != 0 {
  19617. iteminfo.MedChrgitm = "09"
  19618. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19619. iteminfo.Amt = westernMedicineCostTotal
  19620. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19621. iteminfo.ClabAmt = westernMedicine_clab_amt
  19622. iteminfo.OthAmt = westernMedicine_other_amt
  19623. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19624. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19625. }
  19626. if chineseTraditionalMedicineCostTotal != 0 {
  19627. iteminfo.MedChrgitm = "11"
  19628. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19629. iteminfo.Amt = westernMedicineCostTotal
  19630. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19631. iteminfo.ClabAmt = westernMedicine_clab_amt
  19632. iteminfo.OthAmt = westernMedicine_other_amt
  19633. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19634. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19635. }
  19636. if otherCostTotal != 0 {
  19637. iteminfo.MedChrgitm = "14"
  19638. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19639. iteminfo.Amt = otherCostTotal
  19640. iteminfo.ClaaSumfee = other_claa_sunmfee
  19641. iteminfo.ClabAmt = other_clab_amt
  19642. iteminfo.OthAmt = other_other_amt
  19643. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19644. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19645. }
  19646. struct4101.IteminfoStruct = iteminfoStructs
  19647. struct4101.Ntly = "中国"
  19648. struct4101.AdmCaty = "A03.06"
  19649. var resOther ResultSeventeenOther
  19650. var res ResultSeventeen
  19651. if miConfig.MdtrtareaAdmvs == "150499" {
  19652. var pp models.PublicParams
  19653. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19654. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19655. pp.FixmedinsName = miConfig.OrgName
  19656. pp.FixmedinsCode = miConfig.Code
  19657. pp.RequestUrl = miConfig.Url
  19658. pp.Cainfo = miConfig.Cainfo
  19659. pp.SecretKey = miConfig.SecretKey
  19660. pp.AccessKey = miConfig.AccessKey
  19661. pp.OpterName = curRoles.UserName
  19662. client := &http.Client{}
  19663. var req *http.Request
  19664. data := make(map[string]interface{})
  19665. data["struct4101"] = struct4101
  19666. data["pp"] = pp
  19667. bytesData, _ := json.Marshal(data)
  19668. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19669. resp, _ := client.Do(req)
  19670. defer resp.Body.Close()
  19671. body, ioErr := ioutil.ReadAll(resp.Body)
  19672. if ioErr != nil {
  19673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19675. return
  19676. }
  19677. var respJSON map[string]interface{}
  19678. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19681. return
  19682. }
  19683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19684. userJSONBytes, _ := json.Marshal(respJSON)
  19685. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19686. utils.ErrorLog("解析失败:%v", err)
  19687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19688. return
  19689. }
  19690. res.InfRefmsgid = resOther.InfRefmsgid
  19691. res.Output = resOther.Output
  19692. res.ErrMsg = resOther.ErrMsg
  19693. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19694. res.Infcode = infocode
  19695. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19696. var pp models.PublicParams
  19697. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19698. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19699. pp.FixmedinsName = miConfig.OrgName
  19700. pp.FixmedinsCode = miConfig.Code
  19701. pp.RequestUrl = miConfig.Url
  19702. pp.Cainfo = miConfig.Cainfo
  19703. pp.SecretKey = miConfig.SecretKey
  19704. pp.AccessKey = miConfig.AccessKey
  19705. pp.OpterName = curRoles.UserName
  19706. result, _ := service.Jxyb4101(struct4101, pp)
  19707. var dat map[string]interface{}
  19708. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19709. fmt.Println(dat)
  19710. } else {
  19711. fmt.Println(err)
  19712. }
  19713. userJSONBytes, _ := json.Marshal(dat)
  19714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19715. utils.ErrorLog("解析失败:%v", err)
  19716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19717. return
  19718. }
  19719. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19720. var pp models.PublicParams
  19721. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19722. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19723. pp.FixmedinsName = miConfig.OrgName
  19724. pp.FixmedinsCode = miConfig.Code
  19725. pp.RequestUrl = miConfig.Url
  19726. pp.Cainfo = miConfig.Cainfo
  19727. pp.SecretKey = miConfig.SecretKey
  19728. pp.AccessKey = miConfig.AccessKey
  19729. pp.OpterName = curRoles.UserName
  19730. result, _ := service.Jxyb4101(struct4101, pp)
  19731. var dat map[string]interface{}
  19732. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19733. fmt.Println(dat)
  19734. } else {
  19735. fmt.Println(err)
  19736. }
  19737. userJSONBytes, _ := json.Marshal(dat)
  19738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19739. utils.ErrorLog("解析失败:%v", err)
  19740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19741. return
  19742. }
  19743. } else {
  19744. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19745. var dat map[string]interface{}
  19746. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19747. fmt.Println(dat)
  19748. } else {
  19749. fmt.Println(err)
  19750. }
  19751. userJSONBytes, _ := json.Marshal(dat)
  19752. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19753. utils.ErrorLog("解析失败:%v", err)
  19754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19755. return
  19756. }
  19757. }
  19758. if res.Infcode != 0 {
  19759. c.ServeSuccessJSON(map[string]interface{}{
  19760. "failed_code": -10,
  19761. "msg": res.ErrMsg,
  19762. })
  19763. return
  19764. } else {
  19765. if miConfig.MdtrtareaAdmvs != "150499" {
  19766. order.FaPiaoNumber = zero
  19767. order.FaPiaoCode = last_order.FaPiaoCode
  19768. service.UpdateOrder(order)
  19769. }
  19770. hisFundSettleListResult := &models.HisFundSettleListResult{
  19771. Number: res.Output.SetlListId,
  19772. Status: 1,
  19773. Ctime: time.Now().Unix(),
  19774. Mtime: time.Now().Unix(),
  19775. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19776. IsUpload: 1,
  19777. OrderId: order_id,
  19778. }
  19779. service.CreateUploadRecord(hisFundSettleListResult)
  19780. c.ServeSuccessJSON(map[string]interface{}{
  19781. "msg": "上传成功",
  19782. "result": hisFundSettleListResult,
  19783. })
  19784. return
  19785. }
  19786. }
  19787. //func (c *HisApiController) GetBatchSettleList() {
  19788. // orders, _ := service.GetAllHisOrder(10106)
  19789. // for _, item := range orders {
  19790. // order_id := item.ID
  19791. // order, _ := service.GetHisOrderByIDTwo(order_id)
  19792. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19793. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19794. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19795. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  19796. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19797. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19798. //
  19799. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19800. //
  19801. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19802. //
  19803. // if order.ID == 0 {
  19804. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19805. // return
  19806. // }
  19807. // if his.BalanceAccountsType == 2 {
  19808. // continue
  19809. // }
  19810. // struct4101 := service.Struct4101{
  19811. // PsnNo: order.PsnNo,
  19812. // MdtrtId: order.MdtrtId,
  19813. // SetlId: order.SetlId,
  19814. // PsnName: order.PsnName,
  19815. // Gend: order.Gend,
  19816. // Brdy: his.Brdy,
  19817. // Age: his.Age,
  19818. // Naty: order.Naty,
  19819. // PatnCertType: "01",
  19820. // Certno: order.Certno,
  19821. // Prfs: "90",
  19822. // ConerName: roles[0].UserName,
  19823. // PatnRlts: "99",
  19824. // ConerAddr: miConfig.OrgName,
  19825. // ConerTel: admin.Mobile,
  19826. // HiType: order.Insutype,
  19827. // Insuplc: his.InsuplcAdmdvs,
  19828. // MaindiagFlag: "1",
  19829. // BillCode: order.SetlId,
  19830. // BillNo: order.SetlId,
  19831. // BizSn: order.Number,
  19832. // PsnSelfPay: order.PsnPartAmt,
  19833. // PsnOwnPay: order.PsnPartAmt,
  19834. // AcctPay: order.AcctPay,
  19835. // PsnCashpay: order.PsnCashPay,
  19836. // HiPaymtd: "1",
  19837. // Hsorg: his.InsuplcAdmdvs,
  19838. // HsorgOpter: his.InsuplcAdmdvs,
  19839. // MedinsFillPsn: curRoles.UserName,
  19840. // MedinsFillDept: depart.Name,
  19841. // IptMedType: "2",
  19842. // }
  19843. // struct4101.SetlBegnDate = order.SetlTime
  19844. // struct4101.SetlEndDate = order.SetlTime
  19845. // //if order.SettleType == 1 {
  19846. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  19847. // // dateStr := t.Format("2006-01-02")
  19848. // // struct4101.SetlBegnDate = dateStr
  19849. // // struct4101.SetlEndDate = dateStr
  19850. // //} else {
  19851. // // t := time.Unix(int64(order.SettleStartTime), 0)
  19852. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  19853. // // dateStartStr := t.Format("2006-01-02")
  19854. // // dateEndStr := t2.Format("2006-01-02")
  19855. // // struct4101.SetlBegnDate = dateStartStr
  19856. // // struct4101.SetlEndDate = dateEndStr
  19857. // //}
  19858. //
  19859. // var rf []CustomFundPay
  19860. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  19861. //
  19862. // var tempFunPays []service.CustomStruct
  19863. // var tempFunPay610100 service.CustomStruct
  19864. //
  19865. // for _, item := range rf {
  19866. // if item.FundPayType == "610100" {
  19867. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  19868. // tempFunPay610100.FundPayType = item.FundPayType
  19869. // } else {
  19870. // var tempFunPay service.CustomStruct
  19871. // tempFunPay.FundPayamt = item.FundPayamt
  19872. // tempFunPay.FundPayType = item.FundPayType
  19873. // tempFunPays = append(tempFunPays, tempFunPay)
  19874. // }
  19875. // }
  19876. // tempFunPays = append(tempFunPays, tempFunPay610100)
  19877. // struct4101.CustomStruct = tempFunPays
  19878. //
  19879. // var tempDiaginfos []service.DiaginfoStructTwo
  19880. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19881. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19882. //
  19883. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19884. // var config []*models.HisXtDiagnoseConfig
  19885. // for _, item := range diagnosis_ids {
  19886. // id, _ := strconv.ParseInt(item, 10, 64)
  19887. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  19888. // config = append(config, &diagnosisConfig)
  19889. // }
  19890. //
  19891. // for index, item := range config {
  19892. // if index == 0 {
  19893. // var tempDiaginfo service.DiaginfoStructTwo
  19894. // tempDiaginfo.DiagCode = item.CountryCode
  19895. // tempDiaginfo.DiagName = item.CountryContentName
  19896. // tempDiaginfo.DiagType = "1"
  19897. // tempDiaginfo.MaindiagFlag = "1"
  19898. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19899. // } else {
  19900. //
  19901. // var tempDiaginfo service.DiaginfoStructTwo
  19902. // tempDiaginfo.DiagCode = item.CountryCode
  19903. // tempDiaginfo.DiagName = item.CountryContentName
  19904. // tempDiaginfo.DiagType = "2"
  19905. // tempDiaginfo.MaindiagFlag = "0"
  19906. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19907. // }
  19908. // }
  19909. // struct4101.Diseinfo = tempDiaginfos
  19910. //
  19911. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  19912. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19913. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19914. // tempOpspdiseinfo2.OprnOprtCode = ""
  19915. // tempOpspdiseinfo2.OprnOprtName = ""
  19916. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19917. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19918. //
  19919. // var iteminfo service.IteminfoStruct
  19920. //
  19921. // var bedCostTotal float64 = 0 //床位总费
  19922. // var bedCostSelfTotal float64 = 0 //床位自费
  19923. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19924. //
  19925. // var examineCostTotal float64 = 0 //诊查总费
  19926. // var examineCostSelfTotal float64 = 0 //诊查自费
  19927. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  19928. //
  19929. // var nursingCostTotal float64 = 0 //护理总费
  19930. // var nursingCostSelfTotal float64 = 0 //护理自费
  19931. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  19932. //
  19933. // var chineseMedicineCostTotal float64 = 0 //中成药
  19934. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  19935. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  19936. //
  19937. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  19938. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  19939. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  19940. //
  19941. // var registerCostTotal float64 = 0 //一般诊疗费
  19942. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  19943. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  19944. //
  19945. // var operationCostTotal float64 = 0 //手术费
  19946. // var operationCostSelfTotal float64 = 0 //手术费
  19947. // var operationCostPartSelfTotal float64 = 0 //手术费
  19948. //
  19949. // var otherCostTotal float64 = 0 //其他费用
  19950. // var otherCostSelfTotal float64 = 0 //其他费用
  19951. // var otherCostPartSelfTotal float64 = 0 //其他费用
  19952. //
  19953. // var materialCostTotal float64 = 0 //材料费
  19954. // var materialCostSelfTotal float64 = 0 //材料费
  19955. // var materialCostPartSelfTotal float64 = 0 //材料费
  19956. //
  19957. // var westernMedicineCostTotal float64 = 0 //西药费
  19958. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  19959. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19960. //
  19961. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19962. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19963. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19964. //
  19965. // var checkCostTotal float64 = 0 //检查费
  19966. // var checkCostSelfTotal float64 = 0 //检查费
  19967. // var checkCostPartSelfTotal float64 = 0 //检查费
  19968. //
  19969. // var laboratoryCostTotal float64 = 0 //化验费
  19970. // var laboratoryCostSelfTotal float64 = 0 //化验费
  19971. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19972. //
  19973. // var treatCostTotal float64 = 0 //治疗费用
  19974. // var treatCostSelfTotal float64 = 0 //治疗费用
  19975. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  19976. //
  19977. // decimal.DivisionPrecision = 2
  19978. //
  19979. // var bed_fulamt_ownpay_amt float64 = 0
  19980. //
  19981. // var examine_fulamt_ownpay_amt float64 = 0
  19982. //
  19983. // var nursing_fulamt_ownpay_amt float64 = 0
  19984. //
  19985. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  19986. //
  19987. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  19988. //
  19989. // var register_fulamt_ownpay_amt float64 = 0
  19990. //
  19991. // var operation_fulamt_ownpay_amt float64 = 0
  19992. // var other_fulamt_ownpay_amt float64 = 0
  19993. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  19994. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19995. // var check_fulamt_ownpay_amt float64 = 0
  19996. // var material_fulamt_ownpay_amt float64 = 0
  19997. // var laboratory_fulamt_ownpay_amt float64 = 0
  19998. // var treat_fulamt_ownpay_amt float64 = 0
  19999. //
  20000. // var bed_claa_sunmfee float64 = 0
  20001. // var bed_clab_amt float64 = 0
  20002. // var bed_other_amt float64 = 0
  20003. //
  20004. // var examine_claa_sunmfee float64 = 0
  20005. // var examine_clab_amt float64 = 0
  20006. // var examine_other_amt float64 = 0
  20007. //
  20008. // var nursing_claa_sunmfee float64 = 0
  20009. // var nursing_clab_amt float64 = 0
  20010. // var nursing_other_amt float64 = 0
  20011. //
  20012. // var chinese_medicine_claa_sunmfee float64 = 0
  20013. // var chinese_medicine_clab_amt float64 = 0
  20014. // var chinese_medicine_other_amt float64 = 0
  20015. //
  20016. // var commonly_treatment_claa_sunmfee float64 = 0
  20017. // var commonly_treatment_clab_amt float64 = 0
  20018. // var commonly_treatment_other_amt float64 = 0
  20019. //
  20020. // var operation_claa_sunmfee float64 = 0
  20021. // var operation_clab_amt float64 = 0
  20022. // var operation_other_amt float64 = 0
  20023. //
  20024. // var other_claa_sunmfee float64 = 0
  20025. // var other_clab_amt float64 = 0
  20026. // var other_other_amt float64 = 0
  20027. //
  20028. // var westernMedicine_claa_sunmfee float64 = 0
  20029. // var westernMedicine_clab_amt float64 = 0
  20030. // var westernMedicine_other_amt float64 = 0
  20031. //
  20032. // var chineseTraditional_claa_sunmfee float64 = 0
  20033. // var chineseTraditional_clab_amt float64 = 0
  20034. // var chineseTraditional_other_amt float64 = 0
  20035. //
  20036. // var check_claa_sunmfee float64 = 0
  20037. // var check_clab_amt float64 = 0
  20038. // var check_other_amt float64 = 0
  20039. //
  20040. // var material_claa_sunmfee float64 = 0
  20041. // var material_clab_amt float64 = 0
  20042. // var material_other_amt float64 = 0
  20043. //
  20044. // var laboratory_claa_sunmfee float64 = 0
  20045. // var laboratory_clab_amt float64 = 0
  20046. // var laboratory_other_amt float64 = 0
  20047. //
  20048. // var treat_claa_sunmfee float64 = 0
  20049. // var treat_clab_amt float64 = 0
  20050. // var treat_other_amt float64 = 0
  20051. //
  20052. // var register_claa_sunmfee float64 = 0
  20053. // var register_clab_amt float64 = 0
  20054. // var register_other_amt float64 = 0
  20055. //
  20056. // for _, item := range order.HisOrderInfo {
  20057. // if item.MedChrgitmType == "01" { //床位费
  20058. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20059. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20060. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20061. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20062. // if item.ChrgitmLv == "1" {
  20063. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20064. // }
  20065. // if item.ChrgitmLv == "2" {
  20066. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20067. //
  20068. // }
  20069. // if item.ChrgitmLv == "3" {
  20070. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20071. // }
  20072. //
  20073. // }
  20074. //
  20075. // if item.MedChrgitmType == "02" { //诊查
  20076. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20077. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20078. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20079. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20080. // if item.ChrgitmLv == "1" {
  20081. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20082. // }
  20083. // if item.ChrgitmLv == "2" {
  20084. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20085. //
  20086. // }
  20087. // if item.ChrgitmLv == "3" {
  20088. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20089. // }
  20090. //
  20091. // }
  20092. //
  20093. // if item.MedChrgitmType == "03" { //检查费
  20094. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20095. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20096. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20097. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20098. // if item.ChrgitmLv == "1" {
  20099. //
  20100. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20101. //
  20102. // }
  20103. // if item.ChrgitmLv == "2" {
  20104. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20105. //
  20106. // }
  20107. // if item.ChrgitmLv == "3" {
  20108. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20109. // }
  20110. // }
  20111. //
  20112. // if item.MedChrgitmType == "04" { //化验费
  20113. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20114. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20115. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20116. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20117. // if item.ChrgitmLv == "1" {
  20118. //
  20119. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20120. //
  20121. // }
  20122. // if item.ChrgitmLv == "2" {
  20123. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20124. //
  20125. // }
  20126. // if item.ChrgitmLv == "3" {
  20127. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20128. // }
  20129. // }
  20130. //
  20131. // if item.MedChrgitmType == "05" { //治疗费
  20132. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20133. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20134. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20135. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20136. // if item.ChrgitmLv == "1" {
  20137. //
  20138. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20139. //
  20140. // }
  20141. // if item.ChrgitmLv == "2" {
  20142. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20143. //
  20144. // }
  20145. // if item.ChrgitmLv == "3" {
  20146. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20147. // }
  20148. // }
  20149. //
  20150. // if item.MedChrgitmType == "06" { //手术费
  20151. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20152. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20153. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20154. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20155. //
  20156. // if item.ChrgitmLv == "1" {
  20157. //
  20158. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20159. //
  20160. // }
  20161. // if item.ChrgitmLv == "2" {
  20162. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20163. //
  20164. // }
  20165. // if item.ChrgitmLv == "3" {
  20166. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20167. // }
  20168. // }
  20169. //
  20170. // if item.MedChrgitmType == "07" { //手术费
  20171. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20172. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20173. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20174. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20175. //
  20176. // if item.ChrgitmLv == "1" {
  20177. //
  20178. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20179. //
  20180. // }
  20181. // if item.ChrgitmLv == "2" {
  20182. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20183. //
  20184. // }
  20185. // if item.ChrgitmLv == "3" {
  20186. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20187. // }
  20188. // }
  20189. //
  20190. // if item.MedChrgitmType == "08" { //材料费
  20191. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20192. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20193. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20194. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20195. // if item.ChrgitmLv == "1" {
  20196. //
  20197. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20198. //
  20199. // }
  20200. // if item.ChrgitmLv == "2" {
  20201. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20202. //
  20203. // }
  20204. // if item.ChrgitmLv == "3" {
  20205. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20206. // }
  20207. // }
  20208. // if item.MedChrgitmType == "09" { //西药费
  20209. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20210. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20211. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20212. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20213. // if item.ChrgitmLv == "1" {
  20214. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20215. // }
  20216. // if item.ChrgitmLv == "2" {
  20217. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20218. // }
  20219. // if item.ChrgitmLv == "3" {
  20220. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20221. // }
  20222. // }
  20223. // if item.MedChrgitmType == "10" { //中药饮片
  20224. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20225. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20226. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20227. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20228. // if item.ChrgitmLv == "1" {
  20229. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20230. // }
  20231. // if item.ChrgitmLv == "2" {
  20232. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20233. // }
  20234. // if item.ChrgitmLv == "3" {
  20235. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20236. // }
  20237. // }
  20238. //
  20239. // if item.MedChrgitmType == "11" { //中成费
  20240. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20241. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20242. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20243. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20244. // if item.ChrgitmLv == "1" {
  20245. //
  20246. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20247. //
  20248. // }
  20249. // if item.ChrgitmLv == "2" {
  20250. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20251. //
  20252. // }
  20253. // if item.ChrgitmLv == "3" {
  20254. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20255. // }
  20256. // }
  20257. //
  20258. // if item.MedChrgitmType == "12" { //中成费
  20259. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20260. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20261. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20262. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20263. // if item.ChrgitmLv == "1" {
  20264. //
  20265. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20266. //
  20267. // }
  20268. // if item.ChrgitmLv == "2" {
  20269. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20270. //
  20271. // }
  20272. // if item.ChrgitmLv == "3" {
  20273. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20274. // }
  20275. // }
  20276. //
  20277. // if item.MedChrgitmType == "13" { //中成费
  20278. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20279. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20280. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20281. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20282. // if item.ChrgitmLv == "1" {
  20283. //
  20284. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20285. //
  20286. // }
  20287. // if item.ChrgitmLv == "2" {
  20288. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20289. //
  20290. // }
  20291. // if item.ChrgitmLv == "3" {
  20292. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20293. // }
  20294. // }
  20295. //
  20296. // if item.MedChrgitmType == "14" { //其他费
  20297. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20298. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20299. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20300. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20301. // if item.ChrgitmLv == "1" {
  20302. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20303. //
  20304. // }
  20305. // if item.ChrgitmLv == "2" {
  20306. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20307. //
  20308. // }
  20309. // if item.ChrgitmLv == "3" {
  20310. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20311. // }
  20312. // }
  20313. //
  20314. // }
  20315. //
  20316. // var iteminfoStructs []service.IteminfoStruct
  20317. //
  20318. // if bedCostTotal != 0 {
  20319. // iteminfo.MedChrgitm = "01"
  20320. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20321. // iteminfo.Amt = bedCostTotal
  20322. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20323. // iteminfo.ClabAmt = bed_clab_amt
  20324. // iteminfo.OthAmt = bed_other_amt
  20325. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20326. // }
  20327. //
  20328. // if examineCostTotal != 0 {
  20329. // iteminfo.MedChrgitm = "02"
  20330. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20331. // iteminfo.Amt = examineCostTotal
  20332. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20333. // iteminfo.ClabAmt = examine_clab_amt
  20334. // iteminfo.OthAmt = examine_other_amt
  20335. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20336. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20337. // }
  20338. //
  20339. // if checkCostTotal != 0 {
  20340. // iteminfo.MedChrgitm = "03"
  20341. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20342. // iteminfo.Amt = checkCostTotal
  20343. // iteminfo.ClaaSumfee = check_claa_sunmfee
  20344. // iteminfo.ClabAmt = check_clab_amt
  20345. // iteminfo.OthAmt = check_other_amt
  20346. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20347. //
  20348. // }
  20349. //
  20350. // if laboratoryCostTotal != 0 {
  20351. // iteminfo.MedChrgitm = "04"
  20352. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20353. // iteminfo.Amt = laboratoryCostTotal
  20354. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20355. // iteminfo.ClabAmt = laboratory_clab_amt
  20356. // iteminfo.OthAmt = laboratory_other_amt
  20357. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20358. //
  20359. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20360. //
  20361. // }
  20362. //
  20363. // if treatCostTotal != 0 {
  20364. // iteminfo.MedChrgitm = "05"
  20365. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20366. // iteminfo.Amt = treatCostTotal
  20367. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  20368. // iteminfo.ClabAmt = treat_clab_amt
  20369. // iteminfo.OthAmt = treat_other_amt
  20370. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20371. // //(struct4101.IteminfoStruct, iteminfo)
  20372. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20373. // }
  20374. //
  20375. // if operationCostTotal != 0 {
  20376. // iteminfo.MedChrgitm = "06"
  20377. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20378. // iteminfo.Amt = operationCostTotal
  20379. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  20380. // iteminfo.ClabAmt = operation_clab_amt
  20381. // iteminfo.OthAmt = operation_other_amt
  20382. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20383. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20384. // }
  20385. //
  20386. // if nursingCostTotal != 0 {
  20387. // iteminfo.MedChrgitm = "07"
  20388. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  20389. // iteminfo.Amt = nursingCostTotal
  20390. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  20391. // iteminfo.ClabAmt = nursing_clab_amt
  20392. // iteminfo.OthAmt = nursing_other_amt
  20393. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20394. // }
  20395. //
  20396. // if materialCostTotal != 0 {
  20397. // iteminfo.MedChrgitm = "08"
  20398. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20399. // iteminfo.Amt = materialCostTotal
  20400. // iteminfo.ClaaSumfee = material_claa_sunmfee
  20401. // iteminfo.ClabAmt = material_clab_amt
  20402. // iteminfo.OthAmt = material_other_amt
  20403. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20404. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20405. // }
  20406. //
  20407. // if westernMedicineCostTotal != 0 {
  20408. // iteminfo.MedChrgitm = "09"
  20409. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20410. // iteminfo.Amt = westernMedicineCostTotal
  20411. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20412. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20413. // iteminfo.OthAmt = westernMedicine_other_amt
  20414. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20415. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20416. //
  20417. // }
  20418. //
  20419. // if chineseMedicineCostTotal != 0 {
  20420. // iteminfo.MedChrgitm = "10"
  20421. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  20422. // iteminfo.Amt = chineseMedicineCostTotal
  20423. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  20424. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  20425. // iteminfo.OthAmt = chinese_medicine_other_amt
  20426. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20427. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20428. //
  20429. // }
  20430. //
  20431. // if chineseTraditionalMedicineCostTotal != 0 {
  20432. // iteminfo.MedChrgitm = "11"
  20433. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20434. // iteminfo.Amt = westernMedicineCostTotal
  20435. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20436. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20437. // iteminfo.OthAmt = westernMedicine_other_amt
  20438. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20439. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20440. //
  20441. // }
  20442. //
  20443. // if commonlyTreatmentCostTotal != 0 {
  20444. // iteminfo.MedChrgitm = "12"
  20445. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  20446. // iteminfo.Amt = commonlyTreatmentCostTotal
  20447. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  20448. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  20449. // iteminfo.OthAmt = commonly_treatment_other_amt
  20450. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20451. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20452. //
  20453. // }
  20454. //
  20455. // if registerCostTotal != 0 {
  20456. // iteminfo.MedChrgitm = "13"
  20457. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  20458. // iteminfo.Amt = registerCostTotal
  20459. // iteminfo.ClaaSumfee = register_claa_sunmfee
  20460. // iteminfo.ClabAmt = register_clab_amt
  20461. // iteminfo.OthAmt = register_other_amt
  20462. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20463. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20464. //
  20465. // }
  20466. //
  20467. // if otherCostTotal != 0 {
  20468. // iteminfo.MedChrgitm = "14"
  20469. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20470. // iteminfo.Amt = otherCostTotal
  20471. // iteminfo.ClaaSumfee = other_claa_sunmfee
  20472. // iteminfo.ClabAmt = other_clab_amt
  20473. // iteminfo.OthAmt = other_other_amt
  20474. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20475. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20476. //
  20477. // }
  20478. // struct4101.IteminfoStruct = iteminfoStructs
  20479. // time_arr := strings.Split(order.SetlTime, " ")
  20480. // struct4101.AdmTime = time_arr[0]
  20481. // struct4101.AdmEndTime = time_arr[0]
  20482. //
  20483. // struct4101.DoctorName = doctor.UserName
  20484. // struct4101.DoctorCode = doctor.DoctorNumber
  20485. //
  20486. // struct4101.Ntly = "中国"
  20487. // struct4101.AdmCaty = "A03.06"
  20488. // var res ResultSeventeen
  20489. // if miConfig.MdtrtareaAdmvs == "421300" {
  20490. // data := make(map[string]interface{})
  20491. // data["struct4101"] = struct4101
  20492. // data["secret_key"] = miConfig.SecretKey
  20493. // data["org_name"] = miConfig.OrgName
  20494. // data["opera"] = curRoles.UserName
  20495. // data["code"] = miConfig.Code
  20496. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  20497. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20498. //
  20499. // client := &http.Client{}
  20500. // bytesData, _ := json.Marshal(data)
  20501. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  20502. // resp, _ := client.Do(req)
  20503. // defer resp.Body.Close()
  20504. // body, ioErr := ioutil.ReadAll(resp.Body)
  20505. // if ioErr != nil {
  20506. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20508. // return
  20509. // }
  20510. // var respJSON map[string]interface{}
  20511. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20512. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20514. // return
  20515. // }
  20516. //
  20517. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20518. // userJSONBytes, _ := json.Marshal(respJSON)
  20519. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20520. // utils.ErrorLog("解析失败:%v", err)
  20521. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20522. // adminUser := c.GetAdminUserInfo()
  20523. // errlog := &models.HisOrderError{
  20524. // UserOrgId: adminUser.CurrentOrgId,
  20525. // Ctime: time.Now().Unix(),
  20526. // Mtime: time.Now().Unix(),
  20527. // ErrMsg: res.ErrMsg + "解析失败",
  20528. // Status: 1,
  20529. // PatientId: order_id,
  20530. // Stage: 10088,
  20531. // }
  20532. // service.CreateErrMsgLog(errlog)
  20533. // continue
  20534. // }
  20535. //
  20536. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  20537. // data := make(map[string]interface{})
  20538. // data["struct4101"] = struct4101
  20539. // data["secret_key"] = miConfig.SecretKey
  20540. // data["org_name"] = miConfig.OrgName
  20541. // data["opera"] = curRoles.UserName
  20542. // data["code"] = miConfig.Code
  20543. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  20544. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20545. //
  20546. // client := &http.Client{}
  20547. // bytesData, _ := json.Marshal(data)
  20548. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  20549. // resp, _ := client.Do(req)
  20550. // defer resp.Body.Close()
  20551. // body, ioErr := ioutil.ReadAll(resp.Body)
  20552. // if ioErr != nil {
  20553. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20554. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20555. // return
  20556. // }
  20557. // var respJSON map[string]interface{}
  20558. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20559. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20560. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20561. // return
  20562. // }
  20563. //
  20564. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20565. // userJSONBytes, _ := json.Marshal(respJSON)
  20566. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20567. // utils.ErrorLog("解析失败:%v", err)
  20568. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20569. // adminUser := c.GetAdminUserInfo()
  20570. // errlog := &models.HisOrderError{
  20571. // UserOrgId: adminUser.CurrentOrgId,
  20572. // Ctime: time.Now().Unix(),
  20573. // Mtime: time.Now().Unix(),
  20574. // ErrMsg: res.ErrMsg + "解析失败",
  20575. // Status: 1,
  20576. // PatientId: order_id,
  20577. // Stage: 10088,
  20578. // }
  20579. // service.CreateErrMsgLog(errlog)
  20580. // continue
  20581. // }
  20582. //
  20583. // } else {
  20584. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  20585. // fmt.Println(result)
  20586. //
  20587. // var dat map[string]interface{}
  20588. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20589. // fmt.Println(dat)
  20590. // } else {
  20591. // fmt.Println(err)
  20592. // }
  20593. // userJSONBytes, _ := json.Marshal(dat)
  20594. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20595. // utils.ErrorLog("解析失败:%v", err)
  20596. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20597. // adminUser := c.GetAdminUserInfo()
  20598. // errlog := &models.HisOrderError{
  20599. // UserOrgId: adminUser.CurrentOrgId,
  20600. // Ctime: time.Now().Unix(),
  20601. // Mtime: time.Now().Unix(),
  20602. // ErrMsg: res.ErrMsg + "解析失败",
  20603. // Status: 1,
  20604. // PatientId: order_id,
  20605. // Stage: 10106,
  20606. // }
  20607. // service.CreateErrMsgLog(errlog)
  20608. // continue
  20609. // }
  20610. // }
  20611. //
  20612. // if res.Infcode != 0 {
  20613. // adminUser := c.GetAdminUserInfo()
  20614. // errlog := &models.HisOrderError{
  20615. // UserOrgId: adminUser.CurrentOrgId,
  20616. // Ctime: time.Now().Unix(),
  20617. // Mtime: time.Now().Unix(),
  20618. // ErrMsg: res.ErrMsg,
  20619. // Status: 1,
  20620. // PatientId: order_id,
  20621. // Stage: 10106,
  20622. // }
  20623. // service.CreateErrMsgLog(errlog)
  20624. // continue
  20625. // } else {
  20626. // hisFundSettleListResult := &models.HisFundSettleListResult{
  20627. // Number: res.Output.SetlListId,
  20628. // Status: 1,
  20629. // Ctime: time.Now().Unix(),
  20630. // Mtime: time.Now().Unix(),
  20631. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20632. // IsUpload: 1,
  20633. // OrderId: order_id,
  20634. // }
  20635. // service.CreateUploadRecord(hisFundSettleListResult)
  20636. // continue
  20637. // }
  20638. // }
  20639. //}
  20640. func (c *HisApiController) GetOrgInfo() {
  20641. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  20642. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  20643. }
  20644. func (c *HisApiController) GetHisPatientInfo() {
  20645. medical_insurance_card := c.GetString("medical_insurance_card")
  20646. id_card_type, _ := c.GetInt64("id_card_type")
  20647. id_card := c.GetString("id_card")
  20648. adminInfo := c.GetAdminUserInfo()
  20649. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  20650. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  20651. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  20652. IdCardNo := ""
  20653. if id_card_type == 1 {
  20654. IdCardNo = medical_insurance_card
  20655. } else if id_card_type == 2 {
  20656. IdCardNo = id_card
  20657. }
  20658. if config.IsOpen == 1 {
  20659. 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
  20660. resp, requestErr := http.Get(api)
  20661. if requestErr != nil {
  20662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20663. return
  20664. }
  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(string(body)), &respJSON); err != nil {
  20674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20676. return
  20677. }
  20678. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20679. userJSONBytes, _ := json.Marshal(userJSON)
  20680. var res ResultTwo
  20681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20682. utils.ErrorLog("解析失败:%v", err)
  20683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20684. return
  20685. }
  20686. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  20687. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  20688. infoStr := string(Iinfos)
  20689. idetinfoStr := string(Idetinfos)
  20690. if res.Infcode == 0 {
  20691. his := models.VMHisPatient{
  20692. Status: 1,
  20693. Ctime: time.Now().Unix(),
  20694. Mtime: time.Now().Unix(),
  20695. PsnNo: res.Output.Baseinfo.PsnNo,
  20696. PsnCertType: res.Output.Baseinfo.PsnCertType,
  20697. Certno: res.Output.Baseinfo.Certno,
  20698. PsnName: res.Output.Baseinfo.PsnName,
  20699. Gend: res.Output.Baseinfo.Gend,
  20700. Naty: res.Output.Baseinfo.Naty,
  20701. Iinfo: infoStr,
  20702. Idetinfo: idetinfoStr,
  20703. UserOrgId: adminInfo.CurrentOrgId,
  20704. IsReturn: 1,
  20705. IdCardType: id_card_type,
  20706. }
  20707. c.ServeSuccessJSON(map[string]interface{}{
  20708. "info": his,
  20709. })
  20710. } else {
  20711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  20712. return
  20713. }
  20714. }
  20715. }
  20716. //func GetBasBaseInfo() (jsonStr string, err error) {
  20717. //
  20718. // handle := syscall.NewLazyDLL("SSCard.dll")
  20719. // add := handle.NewProc("ReadCardBas")
  20720. // str := make([]byte, 1024)
  20721. // str1 := make([]byte, 1024)
  20722. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  20723. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  20724. //
  20725. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  20726. //
  20727. // fmt.Println("> Add(4,5)的结果为:", ret)
  20728. // handle.Release()
  20729. //
  20730. // return "", nil
  20731. //
  20732. //}
  20733. //func GetQRBaseInfo() (jsonStr string, err error) {
  20734. // handle := syscall.LoadDLL("SSCard.dll")
  20735. // ReadCardBas := handle.FindProc("GetQRBase")
  20736. //
  20737. // str := make([]byte, 256)
  20738. // str1 := make([]byte, 256)
  20739. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  20740. //
  20741. // fmt.Println(string(str))
  20742. // fmt.Println(r)
  20743. // return string(str), nil
  20744. //}
  20745. //func CardInit() int {
  20746. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  20747. // add := DllTestDef.MustFindProc("Init")
  20748. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  20749. // if err != nil {
  20750. // fmt.Println("SSCard的运算结果为:", ret)
  20751. // }
  20752. // result := int(ret)
  20753. // return result
  20754. //}
  20755. //func CardInit() int {
  20756. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  20757. // if err != nil {
  20758. // fmt.Println("SSCard的运算结果为:", ret)
  20759. // }
  20760. // fmt.Println(err)
  20761. // result := int(ret)
  20762. // return result
  20763. //}
  20764. func IntPtr(n int) uintptr {
  20765. return uintptr(n)
  20766. }
  20767. func StrPtr(s string) uintptr {
  20768. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  20769. }
  20770. type Result2001 struct {
  20771. Cainfo interface{} `json:"cainfo"`
  20772. ErrMsg string `json:"err_msg"`
  20773. InfRefmsgid string `json:"inf_refmsgid"`
  20774. Infcode int64 `json:"infcode"`
  20775. Output struct {
  20776. Trtinfo struct {
  20777. PsnNo string `json:"psn_no"`
  20778. TrtChkType string `json:"trt_chk_type"`
  20779. FundPayType string `json:"fund_pay_type"`
  20780. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  20781. Begndate string `json:"begndate"`
  20782. Enddate string `json:"enddate"`
  20783. TrtChkRslt string `json:"trt_chk_rslt"`
  20784. } `json:"trtinfo"`
  20785. } `json:"output"`
  20786. RefmsgTime string `json:"refmsg_time"`
  20787. RespondTime string `json:"respond_time"`
  20788. Signtype interface{} `json:"signtype"`
  20789. WarnMsg interface{} `json:"warn_msg"`
  20790. }
  20791. type Result2001Org10265 struct {
  20792. Cainfo interface{} `json:"cainfo"`
  20793. ErrMsg string `json:"err_msg"`
  20794. InfRefmsgid string `json:"inf_refmsgid"`
  20795. Infcode string `json:"infcode"`
  20796. Output struct {
  20797. Trtinfo struct {
  20798. PsnNo string `json:"psn_no"`
  20799. TrtChkType string `json:"trt_chk_type"`
  20800. FundPayType string `json:"fund_pay_type"`
  20801. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  20802. Begndate string `json:"begndate"`
  20803. Enddate string `json:"enddate"`
  20804. TrtChkRslt string `json:"trt_chk_rslt"`
  20805. } `json:"trtinfo"`
  20806. } `json:"output"`
  20807. RefmsgTime string `json:"refmsg_time"`
  20808. RespondTime string `json:"respond_time"`
  20809. Signtype interface{} `json:"signtype"`
  20810. WarnMsg interface{} `json:"warn_msg"`
  20811. }
  20812. type ResultTwo struct {
  20813. ErrMsg string `json:"err_msg"`
  20814. InfRefmsgid string `json:"inf_refmsgid"`
  20815. Infcode int64 `json:"infcode"`
  20816. Output struct {
  20817. Baseinfo struct {
  20818. //Brdy string `json:"brdy"`
  20819. Certno string `json:"certno"`
  20820. Gend string `json:"gend"`
  20821. Naty string `json:"naty"`
  20822. PsnCertType string `json:"psn_cert_type"`
  20823. PsnName string `json:"psn_name"`
  20824. PsnNo string `json:"psn_no"`
  20825. } `json:"baseinfo"`
  20826. Idetinfo []interface{} `json:"idetinfo"`
  20827. Iinfo []struct {
  20828. Balc float64 `json:"balc"`
  20829. CvlservFlag string `json:"cvlserv_flag"`
  20830. EmpName string `json:"emp_name"`
  20831. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  20832. Insutype string `json:"insutype"`
  20833. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  20834. //PausInsuDate string `json:"paus_insu_date"`
  20835. //PsnInsuDate string `json:"psn_insu_date"`
  20836. PsnInsuStas string `json:"psn_insu_stas"`
  20837. PsnType string `json:"psn_type"`
  20838. } `json:"insuinfo"`
  20839. } `json:"output"`
  20840. RefmsgTime string `json:"refmsg_time"`
  20841. RespondTime string `json:"respond_time"`
  20842. Signtype interface{} `json:"signtype"`
  20843. WarnInfo interface{} `json:"warn_info"`
  20844. }
  20845. type ResultTwo10265 struct {
  20846. ErrMsg string `json:"err_msg"`
  20847. InfRefmsgid string `json:"inf_refmsgid"`
  20848. Infcode string `json:"infcode"`
  20849. Output struct {
  20850. Baseinfo struct {
  20851. //Brdy string `json:"brdy"`
  20852. Certno string `json:"certno"`
  20853. Gend string `json:"gend"`
  20854. Naty string `json:"naty"`
  20855. PsnCertType string `json:"psn_cert_type"`
  20856. PsnName string `json:"psn_name"`
  20857. PsnNo string `json:"psn_no"`
  20858. } `json:"baseinfo"`
  20859. Idetinfo []interface{} `json:"idetinfo"`
  20860. Iinfo []struct {
  20861. Balc float64 `json:"balc"`
  20862. CvlservFlag string `json:"cvlserv_flag"`
  20863. EmpName string `json:"emp_name"`
  20864. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  20865. Insutype string `json:"insutype"`
  20866. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  20867. PsnInsuStas string `json:"psn_insu_stas"`
  20868. PsnType string `json:"psn_type"`
  20869. } `json:"insuinfo"`
  20870. } `json:"output"`
  20871. RefmsgTime string `json:"refmsg_time"`
  20872. RespondTime string `json:"respond_time"`
  20873. Signtype interface{} `json:"signtype"`
  20874. WarnInfo interface{} `json:"warn_info"`
  20875. }
  20876. type ResultThree struct {
  20877. Cainfo interface{} `json:"cainfo"`
  20878. ErrMsg string `json:"err_msg"`
  20879. InfRefmsgid string `json:"inf_refmsgid"`
  20880. Infcode int64 `json:"infcode"`
  20881. Output struct {
  20882. Data struct {
  20883. IptOtpNo string `json:"ipt_otp_no"`
  20884. MdtrtID string `json:"mdtrt_id"`
  20885. PsnNo string `json:"psn_no"`
  20886. } `json:"data"`
  20887. } `json:"output"`
  20888. RefmsgTime string `json:"refmsg_time"`
  20889. RespondTime string `json:"respond_time"`
  20890. Signtype interface{} `json:"signtype"`
  20891. WarnMsg interface{} `json:"warn_msg"`
  20892. }
  20893. type ResultThree10265 struct {
  20894. Cainfo interface{} `json:"cainfo"`
  20895. ErrMsg string `json:"err_msg"`
  20896. InfRefmsgid string `json:"inf_refmsgid"`
  20897. Infcode string `json:"infcode"`
  20898. Output struct {
  20899. Data struct {
  20900. IptOtpNo string `json:"ipt_otp_no"`
  20901. MdtrtID string `json:"mdtrt_id"`
  20902. PsnNo string `json:"psn_no"`
  20903. } `json:"data"`
  20904. } `json:"output"`
  20905. RefmsgTime string `json:"refmsg_time"`
  20906. RespondTime string `json:"respond_time"`
  20907. Signtype interface{} `json:"signtype"`
  20908. WarnMsg interface{} `json:"warn_msg"`
  20909. }
  20910. type ResultFour struct {
  20911. Cainfo string `json:"cainfo"`
  20912. ErrMsg string `json:"err_msg"`
  20913. InfRefmsgid string `json:"inf_refmsgid"`
  20914. Infcode int64 `json:"infcode"`
  20915. Output struct {
  20916. Result []struct {
  20917. BasMednFlag string `json:"bas_medn_flag"`
  20918. ChldMedcFlag string `json:"chld_medc_flag"`
  20919. ChrgitmLv string `json:"chrgitm_lv"`
  20920. Cnt float64 `json:"cnt"`
  20921. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  20922. DrtReimFlag string `json:"drt_reim_flag"`
  20923. FeedetlSn string `json:"feedetl_sn"`
  20924. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20925. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  20926. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20927. ListSpItemFlag string `json:"list_sp_item_flag"`
  20928. LmtUsedFlag string `json:"lmt_used_flag"`
  20929. MedChrgitmType string `json:"med_chrgitm_type"`
  20930. Memo string `json:"memo"`
  20931. OverlmtAmt float64 `json:"overlmt_amt"`
  20932. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20933. Pric float64 `json:"pric"`
  20934. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  20935. SelfpayProp float64 `json:"selfpay_prop"`
  20936. } `json:"result"`
  20937. } `json:"output"`
  20938. RefmsgTime string `json:"refmsg_time"`
  20939. RespondTime string `json:"respond_time"`
  20940. Signtype string `json:"signtype"`
  20941. WarnMsg string `json:"warn_msg"`
  20942. }
  20943. type ResultFour10265 struct {
  20944. Cainfo string `json:"cainfo"`
  20945. ErrMsg string `json:"err_msg"`
  20946. InfRefmsgid string `json:"inf_refmsgid"`
  20947. Infcode string `json:"infcode"`
  20948. Output struct {
  20949. Result []struct {
  20950. BasMednFlag string `json:"bas_medn_flag"`
  20951. ChldMedcFlag string `json:"chld_medc_flag"`
  20952. ChrgitmLv string `json:"chrgitm_lv"`
  20953. Cnt float64 `json:"cnt"`
  20954. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  20955. DrtReimFlag string `json:"drt_reim_flag"`
  20956. FeedetlSn string `json:"feedetl_sn"`
  20957. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20958. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  20959. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20960. ListSpItemFlag string `json:"list_sp_item_flag"`
  20961. LmtUsedFlag string `json:"lmt_used_flag"`
  20962. MedChrgitmType string `json:"med_chrgitm_type"`
  20963. Memo string `json:"memo"`
  20964. OverlmtAmt float64 `json:"overlmt_amt"`
  20965. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20966. Pric float64 `json:"pric"`
  20967. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  20968. SelfpayProp float64 `json:"selfpay_prop"`
  20969. } `json:"result"`
  20970. } `json:"output"`
  20971. RefmsgTime string `json:"refmsg_time"`
  20972. RespondTime string `json:"respond_time"`
  20973. Signtype string `json:"signtype"`
  20974. WarnMsg string `json:"warn_msg"`
  20975. }
  20976. type ResultMemo struct {
  20977. InsuAdmdvs string `json:"insuAdmdvs"`
  20978. }
  20979. // [{"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}]
  20980. type ResultIDInfo struct {
  20981. Begntime string `json:"begntime"`
  20982. Endtime string `json:"endtime"`
  20983. Memo string `json:"memo"`
  20984. }
  20985. type ResultFive struct {
  20986. Balc float64 `json:"balc"`
  20987. CvlservFlag string `json:"cvlserv_flag"`
  20988. EmpName string `json:"emp_name"`
  20989. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  20990. Insutype string `json:"insutype"`
  20991. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  20992. PausInsuDate string `json:"paus_insu_date"`
  20993. PsnInsuDate string `json:"psn_insu_date"`
  20994. PsnInsuStas string `json:"psn_insu_stas"`
  20995. PsnType string `json:"psn_type"`
  20996. }
  20997. type ResultSix struct {
  20998. Cainfo interface{} `json:"cainfo"`
  20999. ErrMsg string `json:"err_msg"`
  21000. InfRefmsgid string `json:"inf_refmsgid"`
  21001. Infcode int64 `json:"infcode"`
  21002. Output struct {
  21003. } `json:"output"`
  21004. RefmsgTime string `json:"refmsg_time"`
  21005. RespondTime string `json:"respond_time"`
  21006. Signtype interface{} `json:"signtype"`
  21007. WarnMsg interface{} `json:"warn_msg"`
  21008. }
  21009. type FJ3507Result struct {
  21010. Cainfo interface{} `json:"cainfo"`
  21011. ErrMsg string `json:"err_msg"`
  21012. InfRefmsgid string `json:"inf_refmsgid"`
  21013. Infcode int64 `json:"infcode"`
  21014. Output struct {
  21015. retRslt string `json:"retRslt"`
  21016. msgRslt string `json:"msgRslt"`
  21017. } `json:"output"`
  21018. RefmsgTime string `json:"refmsg_time"`
  21019. RespondTime string `json:"respond_time"`
  21020. Signtype interface{} `json:"signtype"`
  21021. WarnMsg interface{} `json:"warn_msg"`
  21022. }
  21023. type FJ3507ResultFor10188 struct {
  21024. Cainfo interface{} `json:"cainfo"`
  21025. ErrMsg string `json:"err_msg"`
  21026. InfRefmsgid string `json:"inf_refmsgid"`
  21027. Infcode string `json:"infcode"`
  21028. RefmsgTime string `json:"refmsg_time"`
  21029. RespondTime string `json:"respond_time"`
  21030. Signtype interface{} `json:"signtype"`
  21031. WarnMsg interface{} `json:"warn_msg"`
  21032. }
  21033. type Result2406 struct {
  21034. Cainfo interface{} `json:"cainfo"`
  21035. ErrMsg string `json:"err_msg"`
  21036. InfRefmsgid string `json:"inf_refmsgid"`
  21037. Infcode int64 `json:"infcode"`
  21038. Output struct {
  21039. Result struct {
  21040. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21041. } `json:"result"`
  21042. } `json:"output"`
  21043. RefmsgTime string `json:"refmsg_time"`
  21044. RespondTime string `json:"respond_time"`
  21045. Signtype interface{} `json:"signtype"`
  21046. WarnMsg interface{} `json:"warn_msg"`
  21047. }
  21048. type GZResultSix struct {
  21049. Cainfo interface{} `json:"cainfo"`
  21050. ErrMsg string `json:"err_msg"`
  21051. InfRefmsgid string `json:"inf_refmsgid"`
  21052. Infcode int64 `json:"infcode"`
  21053. Output string `json:"output"`
  21054. RefmsgTime string `json:"refmsg_time"`
  21055. RespondTime string `json:"respond_time"`
  21056. Signtype interface{} `json:"signtype"`
  21057. WarnMsg interface{} `json:"warn_msg"`
  21058. }
  21059. type ResultSix10265 struct {
  21060. Cainfo interface{} `json:"cainfo"`
  21061. ErrMsg string `json:"err_msg"`
  21062. InfRefmsgid string `json:"inf_refmsgid"`
  21063. Infcode string `json:"infcode"`
  21064. Output struct {
  21065. } `json:"output"`
  21066. RefmsgTime string `json:"refmsg_time"`
  21067. RespondTime string `json:"respond_time"`
  21068. Signtype interface{} `json:"signtype"`
  21069. WarnMsg interface{} `json:"warn_msg"`
  21070. }
  21071. type ResultSeven struct {
  21072. Cainfo string `json:"cainfo"`
  21073. ErrMsg string `json:"err_msg"`
  21074. InfRefmsgid string `json:"inf_refmsgid"`
  21075. Infcode int64 `json:"infcode"`
  21076. Output struct {
  21077. Setlinfo struct {
  21078. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21079. AcctPay float64 `json:"acct_pay"`
  21080. ActPayDedc float64 `json:"act_pay_dedc"`
  21081. Age float64 `json:"age"`
  21082. Balc float64 `json:"balc"`
  21083. Certno string `json:"certno"`
  21084. ClrOptins string `json:"clr_optins"`
  21085. ClrType string `json:"clr_type"`
  21086. ClrWay string `json:"clr_way"`
  21087. CvlservFlag string `json:"cvlserv_flag"`
  21088. CvlservPay float64 `json:"cvlserv_pay"`
  21089. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21090. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21091. Gend string `json:"gend"`
  21092. HifesPay float64 `json:"hifes_pay"`
  21093. HifmiPay float64 `json:"hifmi_pay"`
  21094. HifpPay float64 `json:"hifp_pay"`
  21095. HospPartAmt float64 `json:"hosp_part_amt"`
  21096. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21097. Insutype string `json:"insutype"`
  21098. MafPay float64 `json:"maf_pay"`
  21099. MdtrtCertType string `json:"mdtrt_cert_type"`
  21100. HifobPay float64 `json:"hifob_pay"`
  21101. MdtrtID string `json:"mdtrt_id"`
  21102. MedType string `json:"med_type"`
  21103. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21104. MedinsSetlID string `json:"medins_setl_id"`
  21105. Naty string `json:"naty"`
  21106. OthPay float64 `json:"oth_pay"`
  21107. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21108. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21109. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21110. PsnCashPay float64 `json:"psn_cash_pay"`
  21111. PsnCertType string `json:"psn_cert_type"`
  21112. PsnName string `json:"psn_name"`
  21113. PsnNo string `json:"psn_no"`
  21114. PsnPartAmt float64 `json:"psn_part_amt"`
  21115. PsnType string `json:"psn_type"`
  21116. SetlID string `json:"setl_id"`
  21117. SetlTime string `json:"setl_time"`
  21118. } `json:"setlinfo"`
  21119. Setldetail interface{} `json:"setldetail"`
  21120. } `json:"output"`
  21121. RefmsgTime string `json:"refmsg_time"`
  21122. RespondTime string `json:"respond_time"`
  21123. Signtype interface{} `json:"signtype"`
  21124. WarnMsg interface{} `json:"warn_msg"`
  21125. }
  21126. type ResultSevenAH struct {
  21127. Cainfo string `json:"cainfo"`
  21128. ErrMsg string `json:"err_msg"`
  21129. InfRefmsgid string `json:"inf_refmsgid"`
  21130. Infcode int64 `json:"infcode"`
  21131. Output struct {
  21132. Setlinfo struct {
  21133. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21134. AcctPay float64 `json:"acct_pay"`
  21135. ActPayDedc float64 `json:"act_pay_dedc"`
  21136. Age float64 `json:"age"`
  21137. Balc float64 `json:"balc"`
  21138. Certno string `json:"certno"`
  21139. ClrOptins string `json:"clr_optins"`
  21140. ClrType string `json:"clr_type"`
  21141. ClrWay string `json:"clr_way"`
  21142. CvlservFlag string `json:"cvlserv_flag"`
  21143. CvlservPay float64 `json:"cvlserv_pay"`
  21144. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21145. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21146. Gend string `json:"gend"`
  21147. HifesPay float64 `json:"hifes_pay"`
  21148. HifmiPay float64 `json:"hifmi_pay"`
  21149. HifpPay float64 `json:"hifp_pay"`
  21150. HospPartAmt float64 `json:"hosp_part_amt"`
  21151. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21152. Insutype string `json:"insutype"`
  21153. MafPay float64 `json:"maf_pay"`
  21154. MdtrtCertType string `json:"mdtrt_cert_type"`
  21155. HifobPay float64 `json:"hifob_pay"`
  21156. MdtrtID string `json:"mdtrt_id"`
  21157. MedType string `json:"med_type"`
  21158. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21159. MedinsSetlID string `json:"medins_setl_id"`
  21160. Naty string `json:"naty"`
  21161. OthPay float64 `json:"oth_pay"`
  21162. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21163. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21164. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21165. PsnCashPay float64 `json:"psn_cash_pay"`
  21166. PsnCertType string `json:"psn_cert_type"`
  21167. PsnName string `json:"psn_name"`
  21168. PsnNo string `json:"psn_no"`
  21169. PsnPartAmt float64 `json:"psn_part_amt"`
  21170. PsnType string `json:"psn_type"`
  21171. SetlID string `json:"setl_id"`
  21172. SetlTime int64 `json:"setl_time"`
  21173. } `json:"setlinfo"`
  21174. Setldetail interface{} `json:"setldetail"`
  21175. } `json:"output"`
  21176. RefmsgTime string `json:"refmsg_time"`
  21177. RespondTime string `json:"respond_time"`
  21178. Signtype interface{} `json:"signtype"`
  21179. WarnMsg interface{} `json:"warn_msg"`
  21180. }
  21181. type ResultSeven10265 struct {
  21182. Cainfo string `json:"cainfo"`
  21183. ErrMsg string `json:"err_msg"`
  21184. InfRefmsgid string `json:"inf_refmsgid"`
  21185. Infcode string `json:"infcode"`
  21186. Output struct {
  21187. Setlinfo struct {
  21188. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21189. AcctPay float64 `json:"acct_pay"`
  21190. ActPayDedc float64 `json:"act_pay_dedc"`
  21191. Age float64 `json:"age"`
  21192. Balc float64 `json:"balc"`
  21193. Certno string `json:"certno"`
  21194. ClrOptins string `json:"clr_optins"`
  21195. ClrType string `json:"clr_type"`
  21196. ClrWay string `json:"clr_way"`
  21197. CvlservFlag string `json:"cvlserv_flag"`
  21198. CvlservPay float64 `json:"cvlserv_pay"`
  21199. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21200. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21201. Gend string `json:"gend"`
  21202. HifesPay float64 `json:"hifes_pay"`
  21203. HifmiPay float64 `json:"hifmi_pay"`
  21204. HifpPay float64 `json:"hifp_pay"`
  21205. HospPartAmt float64 `json:"hosp_part_amt"`
  21206. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21207. Insutype string `json:"insutype"`
  21208. MafPay float64 `json:"maf_pay"`
  21209. MdtrtCertType string `json:"mdtrt_cert_type"`
  21210. HifobPay float64 `json:"hifob_pay"`
  21211. MdtrtID string `json:"mdtrt_id"`
  21212. MedType string `json:"med_type"`
  21213. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21214. MedinsSetlID string `json:"medins_setl_id"`
  21215. Naty string `json:"naty"`
  21216. OthPay float64 `json:"oth_pay"`
  21217. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21218. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21219. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21220. PsnCashPay float64 `json:"psn_cash_pay"`
  21221. PsnCertType string `json:"psn_cert_type"`
  21222. PsnName string `json:"psn_name"`
  21223. PsnNo string `json:"psn_no"`
  21224. PsnPartAmt float64 `json:"psn_part_amt"`
  21225. PsnType string `json:"psn_type"`
  21226. SetlID string `json:"setl_id"`
  21227. SetlTime string `json:"setl_time"`
  21228. } `json:"setlinfo"`
  21229. Setldetail interface{} `json:"setldetail"`
  21230. } `json:"output"`
  21231. RefmsgTime string `json:"refmsg_time"`
  21232. RespondTime string `json:"respond_time"`
  21233. Signtype interface{} `json:"signtype"`
  21234. WarnMsg interface{} `json:"warn_msg"`
  21235. }
  21236. type ResultSeven10265Two struct {
  21237. Cainfo string `json:"cainfo"`
  21238. ErrMsg string `json:"err_msg"`
  21239. InfRefmsgid string `json:"inf_refmsgid"`
  21240. Infcode string `json:"infcode"`
  21241. Output struct {
  21242. Setlinfo struct {
  21243. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21244. AcctPay float64 `json:"acct_pay"`
  21245. ActPayDedc float64 `json:"act_pay_dedc"`
  21246. Age float64 `json:"age"`
  21247. Balc float64 `json:"balc"`
  21248. Certno string `json:"certno"`
  21249. ClrOptins string `json:"clr_optins"`
  21250. ClrType string `json:"clr_type"`
  21251. ClrWay string `json:"clr_way"`
  21252. CvlservFlag string `json:"cvlserv_flag"`
  21253. CvlservPay float64 `json:"cvlserv_pay"`
  21254. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21255. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21256. Gend string `json:"gend"`
  21257. HifesPay float64 `json:"hifes_pay"`
  21258. HifmiPay float64 `json:"hifmi_pay"`
  21259. HifpPay float64 `json:"hifp_pay"`
  21260. HospPartAmt string `json:"hosp_part_amt"`
  21261. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21262. Insutype string `json:"insutype"`
  21263. MafPay float64 `json:"maf_pay"`
  21264. MdtrtCertType string `json:"mdtrt_cert_type"`
  21265. HifobPay float64 `json:"hifob_pay"`
  21266. MdtrtID string `json:"mdtrt_id"`
  21267. MedType string `json:"med_type"`
  21268. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21269. MedinsSetlID string `json:"medins_setl_id"`
  21270. Naty string `json:"naty"`
  21271. OthPay float64 `json:"oth_pay"`
  21272. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21273. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21274. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21275. PsnCashPay float64 `json:"psn_cash_pay"`
  21276. PsnCertType string `json:"psn_cert_type"`
  21277. PsnName string `json:"psn_name"`
  21278. PsnNo string `json:"psn_no"`
  21279. PsnPartAmt float64 `json:"psn_part_amt"`
  21280. PsnType string `json:"psn_type"`
  21281. SetlID string `json:"setl_id"`
  21282. SetlTime string `json:"setl_time"`
  21283. } `json:"setlinfo"`
  21284. Setldetail interface{} `json:"setldetail"`
  21285. } `json:"output"`
  21286. RefmsgTime string `json:"refmsg_time"`
  21287. RespondTime string `json:"respond_time"`
  21288. Signtype interface{} `json:"signtype"`
  21289. WarnMsg interface{} `json:"warn_msg"`
  21290. }
  21291. type GZResultSeven10265Two struct {
  21292. Cainfo string `json:"cainfo"`
  21293. ErrMsg string `json:"err_msg"`
  21294. InfRefmsgid string `json:"inf_refmsgid"`
  21295. Infcode int64 `json:"infcode"`
  21296. Output struct {
  21297. Setlinfo struct {
  21298. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21299. AcctPay float64 `json:"acct_pay"`
  21300. ActPayDedc float64 `json:"act_pay_dedc"`
  21301. Age float64 `json:"age"`
  21302. Balc float64 `json:"balc"`
  21303. Certno string `json:"certno"`
  21304. ClrOptins string `json:"clr_optins"`
  21305. ClrType string `json:"clr_type"`
  21306. ClrWay string `json:"clr_way"`
  21307. CvlservFlag string `json:"cvlserv_flag"`
  21308. CvlservPay float64 `json:"cvlserv_pay"`
  21309. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21310. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21311. Gend string `json:"gend"`
  21312. HifesPay float64 `json:"hifes_pay"`
  21313. HifmiPay float64 `json:"hifmi_pay"`
  21314. HifpPay float64 `json:"hifp_pay"`
  21315. HospPartAmt float64 `json:"hosp_part_amt"`
  21316. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21317. Insutype string `json:"insutype"`
  21318. MafPay float64 `json:"maf_pay"`
  21319. MdtrtCertType string `json:"mdtrt_cert_type"`
  21320. HifobPay float64 `json:"hifob_pay"`
  21321. MdtrtID string `json:"mdtrt_id"`
  21322. MedType string `json:"med_type"`
  21323. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21324. MedinsSetlID string `json:"medins_setl_id"`
  21325. Naty string `json:"naty"`
  21326. OthPay float64 `json:"oth_pay"`
  21327. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21328. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21329. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21330. PsnCashPay float64 `json:"psn_cash_pay"`
  21331. PsnCertType string `json:"psn_cert_type"`
  21332. PsnName string `json:"psn_name"`
  21333. PsnNo string `json:"psn_no"`
  21334. PsnPartAmt float64 `json:"psn_part_amt"`
  21335. PsnType string `json:"psn_type"`
  21336. SetlID string `json:"setl_id"`
  21337. SetlTime string `json:"setl_time"`
  21338. } `json:"setlinfo"`
  21339. Setldetail interface{} `json:"setldetail"`
  21340. } `json:"output"`
  21341. RefmsgTime string `json:"refmsg_time"`
  21342. RespondTime string `json:"respond_time"`
  21343. Signtype interface{} `json:"signtype"`
  21344. WarnMsg interface{} `json:"warn_msg"`
  21345. }
  21346. type ResultEight struct {
  21347. Cainfo string `json:"cainfo"`
  21348. ErrMsg string `json:"err_msg"`
  21349. InfRefmsgid string `json:"inf_refmsgid"`
  21350. Infcode int64 `json:"infcode"`
  21351. Output struct {
  21352. Stmtinfo struct {
  21353. SetlOptins string `json:"setl_optins"`
  21354. StmtRslt string `json:"stmt_rslt"`
  21355. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21356. } `json:"stmtinfo"`
  21357. } `json:"output"`
  21358. RefmsgTime string `json:"refmsg_time"`
  21359. RespondTime string `json:"respond_time"`
  21360. Signtype interface{} `json:"signtype"`
  21361. WarnMsg interface{} `json:"warn_msg"`
  21362. }
  21363. type ResultEightFor10188 struct {
  21364. Cainfo string `json:"cainfo"`
  21365. ErrMsg string `json:"err_msg"`
  21366. InfRefmsgid string `json:"inf_refmsgid"`
  21367. Infcode string `json:"infcode"`
  21368. Output struct {
  21369. Stmtinfo struct {
  21370. SetlOptins string `json:"setl_optins"`
  21371. StmtRslt string `json:"stmt_rslt"`
  21372. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21373. } `json:"stmtinfo"`
  21374. } `json:"output"`
  21375. RefmsgTime string `json:"refmsg_time"`
  21376. RespondTime string `json:"respond_time"`
  21377. Signtype interface{} `json:"signtype"`
  21378. WarnMsg interface{} `json:"warn_msg"`
  21379. }
  21380. type ResultNine struct {
  21381. Cainfo string `json:"cainfo"`
  21382. ErrMsg string `json:"err_msg"`
  21383. InfRefmsgid string `json:"inf_refmsgid"`
  21384. Infcode int64 `json:"infcode"`
  21385. Output struct {
  21386. FileQuryNo string `json:"file_qury_no"`
  21387. } `json:"output"`
  21388. RefmsgTime string `json:"refmsg_time"`
  21389. RespondTime string `json:"respond_time"`
  21390. Signtype interface{} `json:"signtype"`
  21391. WarnMsg interface{} `json:"warn_msg"`
  21392. }
  21393. type ResultTen struct {
  21394. Cainfo string `json:"cainfo"`
  21395. ErrMsg string `json:"err_msg"`
  21396. InfRefmsgid string `json:"inf_refmsgid"`
  21397. Infcode int64 `json:"infcode"`
  21398. Output struct {
  21399. Fileinfo struct {
  21400. DldEndtime string `json:"dld_endtime"`
  21401. FileQuryNo string `json:"file_qury_no"`
  21402. Filename string `json:"filename"`
  21403. } `json:"fileinfo"`
  21404. } `json:"output"`
  21405. RefmsgTime string `json:"refmsg_time"`
  21406. RespondTime string `json:"respond_time"`
  21407. Signtype interface{} `json:"signtype"`
  21408. WarnMsg interface{} `json:"warn_msg"`
  21409. }
  21410. type Result5262 struct {
  21411. ErrMsg string `json:"err_msg"`
  21412. InfRefmsgid string `json:"inf_refmsgid"`
  21413. Infcode int64 `json:"infcode"`
  21414. Output struct {
  21415. PageInfo struct {
  21416. Size int `json:"size"`
  21417. RecordCounts int `json:"record_counts"`
  21418. } `json:"page_info"`
  21419. Idetinfo []interface{} `json:"idetinfo"`
  21420. Result []struct {
  21421. SetlID string `json:"setl_id"`
  21422. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  21423. MdtrtID string `json:"mdtrt_id"`
  21424. InitSetlID string `json:"init_setl_id,omitempty"`
  21425. PsnNo string `json:"psn_no"`
  21426. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  21427. PsnName string `json:"psn_name"`
  21428. PsnCertType string `json:"psn_cert_type"`
  21429. Certno string `json:"certno"`
  21430. Gend string `json:"gend,omitempty"`
  21431. Naty string `json:"naty,omitempty"`
  21432. Brdy string `json:"brdy,omitempty"`
  21433. Age float64 `json:"age,omitempty"`
  21434. Insutype string `json:"insutype,omitempty"`
  21435. PsnType string `json:"psn_type"`
  21436. CvlservFlag string `json:"cvlserv_flag"`
  21437. CvlservLv string `json:"cvlserv_lv,omitempty"`
  21438. SpPsnType string `json:"sp_psn_type,omitempty"`
  21439. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  21440. ClctGrde string `json:"clct_grde,omitempty"`
  21441. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  21442. NwbFlag string `json:"nwb_flag,omitempty"`
  21443. InsuAdmdvs string `json:"insu_admdvs"`
  21444. EmpNo string `json:"emp_no,omitempty"`
  21445. EmpName string `json:"emp_name,omitempty"`
  21446. EmpType string `json:"emp_type,omitempty"`
  21447. EconType string `json:"econ_type,omitempty"`
  21448. AfilIndu string `json:"afil_indu,omitempty"`
  21449. AfilRlts string `json:"afil_rlts,omitempty"`
  21450. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  21451. PayLoc string `json:"pay_loc,omitempty"`
  21452. FixmedinsCode string `json:"fixmedins_code"`
  21453. FixmedinsName string `json:"fixmedins_name"`
  21454. HospLv string `json:"hosp_lv,omitempty"`
  21455. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  21456. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  21457. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  21458. Begndate string `json:"begndate"`
  21459. Enddate string `json:"enddate"`
  21460. SetlTime string `json:"setl_time"`
  21461. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  21462. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  21463. MedType string `json:"med_type"`
  21464. SetlType string `json:"setl_type,omitempty"`
  21465. ClrType string `json:"clr_type,omitempty"`
  21466. ClrWay string `json:"clr_way,omitempty"`
  21467. PsnSetlway string `json:"psn_setlway,omitempty"`
  21468. ClrOptins string `json:"clr_optins,omitempty"`
  21469. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  21470. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  21471. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  21472. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  21473. InscpAmt float64 `json:"inscp_amt,omitempty"`
  21474. DedcStd float64 `json:"dedc_std,omitempty"`
  21475. CrtDedc float64 `json:"crt_dedc,omitempty"`
  21476. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  21477. HifpPay float64 `json:"hifp_pay,omitempty"`
  21478. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  21479. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  21480. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  21481. HifesPay float64 `json:"hifes_pay,omitempty"`
  21482. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  21483. HifobPay float64 `json:"hifob_pay,omitempty"`
  21484. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  21485. MafPay float64 `json:"maf_pay,omitempty"`
  21486. OthfundPay float64 `json:"othfund_pay,omitempty"`
  21487. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  21488. PsnPay float64 `json:"psn_pay,omitempty"`
  21489. AcctPay float64 `json:"acct_pay,omitempty"`
  21490. CashPayamt float64 `json:"cash_payamt,omitempty"`
  21491. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  21492. Balc float64 `json:"balc,omitempty"`
  21493. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  21494. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  21495. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  21496. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  21497. Year string `json:"year,omitempty"`
  21498. DiseNo string `json:"dise_no,omitempty"`
  21499. DiseName string `json:"dise_name,omitempty"`
  21500. Invono string `json:"invono,omitempty"`
  21501. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  21502. ValiFlag string `json:"vali_flag,omitempty"`
  21503. Memo string `json:"memo,omitempty"`
  21504. Rid string `json:"rid"`
  21505. UpdtTime string `json:"updt_time,omitempty"`
  21506. CrterID string `json:"crter_id,omitempty"`
  21507. CrterName string `json:"crter_name,omitempty"`
  21508. CrteTime string `json:"crte_time,omitempty"`
  21509. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  21510. OpterID string `json:"opter_id,omitempty"`
  21511. OpterName string `json:"opter_name,omitempty"`
  21512. OptTime string `json:"opt_time,omitempty"`
  21513. OptinsNo string `json:"optins_no,omitempty"`
  21514. PoolareaNo string `json:"poolarea_no,omitempty"`
  21515. } `json:"result"`
  21516. } `json:"output"`
  21517. RefmsgTime string `json:"refmsg_time"`
  21518. RespondTime string `json:"respond_time"`
  21519. Signtype interface{} `json:"signtype"`
  21520. WarnInfo interface{} `json:"warn_info"`
  21521. }
  21522. type Result5267 struct {
  21523. ErrMsg string `json:"err_msg"`
  21524. InfRefmsgid string `json:"inf_refmsgid"`
  21525. Infcode int64 `json:"infcode"`
  21526. Output struct {
  21527. PageInfo struct {
  21528. Size int `json:"size"`
  21529. RecordCounts int `json:"record_counts"`
  21530. } `json:"pageinfo"`
  21531. Result []struct {
  21532. SetlID string `json:"setl_id"`
  21533. ClrOptins string `json:"clr_optins"`
  21534. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  21535. MdtrtID string `json:"mdtrt_id"`
  21536. InitSetlID string `json:"init_setl_id,omitempty"`
  21537. PsnNo string `json:"psn_no"`
  21538. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  21539. PsnName string `json:"psn_name"`
  21540. PsnCertType string `json:"psn_cert_type"`
  21541. Certno string `json:"certno"`
  21542. Gend string `json:"gend,omitempty"`
  21543. Naty string `json:"naty,omitempty"`
  21544. Brdy string `json:"brdy,omitempty"`
  21545. Age float64 `json:"age,omitempty"`
  21546. Insutype string `json:"insutype,omitempty"`
  21547. PsnType string `json:"psn_type"`
  21548. CvlservFlag string `json:"cvlserv_flag"`
  21549. CvlservLv string `json:"cvlserv_lv,omitempty"`
  21550. SpPsnType string `json:"sp_psn_type,omitempty"`
  21551. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  21552. ClctGrde string `json:"clct_grde,omitempty"`
  21553. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  21554. NwbFlag string `json:"nwb_flag,omitempty"`
  21555. InsuAdmdvs string `json:"insu_admdvs"`
  21556. EmpNo string `json:"emp_no,omitempty"`
  21557. EmpName string `json:"emp_name,omitempty"`
  21558. EmpType string `json:"emp_type,omitempty"`
  21559. EconType string `json:"econ_type,omitempty"`
  21560. AfilIndu string `json:"afil_indu,omitempty"`
  21561. AfilRlts string `json:"afil_rlts,omitempty"`
  21562. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  21563. PayLoc string `json:"pay_loc,omitempty"`
  21564. FixmedinsCode string `json:"fixmedins_code"`
  21565. FixmedinsName string `json:"fixmedins_name"`
  21566. HospLv string `json:"hosp_lv,omitempty"`
  21567. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  21568. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  21569. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  21570. Begndate string `json:"begndate,omitempty"`
  21571. Enddate string `json:"enddate,omitempty"`
  21572. SetlTime string `json:"setl_time,omitempty"`
  21573. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  21574. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  21575. MedType string `json:"med_type"`
  21576. SetlType string `json:"setl_type,omitempty"`
  21577. ClrType string `json:"clr_type,omitempty"`
  21578. ClrWay string `json:"clr_way,omitempty"`
  21579. PsnSetlway string `json:"psn_setlway,omitempty"`
  21580. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  21581. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  21582. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  21583. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  21584. InscpAmt float64 `json:"inscp_amt,omitempty"`
  21585. DedcStd float64 `json:"dedc_std,omitempty"`
  21586. CrtDedc float64 `json:"crt_dedc,omitempty"`
  21587. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  21588. HifpPay float64 `json:"hifp_pay,omitempty"`
  21589. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  21590. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  21591. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  21592. HifesPay float64 `json:"hifes_pay,omitempty"`
  21593. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  21594. HifobPay float64 `json:"hifob_pay,omitempty"`
  21595. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  21596. MafPay float64 `json:"maf_pay,omitempty"`
  21597. OthfundPay float64 `json:"othfund_pay,omitempty"`
  21598. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  21599. PsnPay float64 `json:"psn_pay,omitempty"`
  21600. AcctPay float64 `json:"acct_pay,omitempty"`
  21601. CashPayamt float64 `json:"cash_payamt,omitempty"`
  21602. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  21603. Balc float64 `json:"balc,omitempty"`
  21604. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  21605. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  21606. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  21607. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  21608. Year string `json:"year,omitempty"`
  21609. DiseNo string `json:"dise_no,omitempty"`
  21610. DiseName string `json:"dise_name,omitempty"`
  21611. Invono string `json:"invono,omitempty"`
  21612. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  21613. Memo string `json:"memo,omitempty"`
  21614. UpdtTime string `json:"updt_time,omitempty"`
  21615. OpterID string `json:"opter_id,omitempty"`
  21616. OpterName string `json:"opter_name,omitempty"`
  21617. OptTime string `json:"opt_time,omitempty"`
  21618. OptinsNo string `json:"optins_no,omitempty"`
  21619. PoolareaNo string `json:"poolarea_no,omitempty"`
  21620. } `json:"result"`
  21621. } `json:"output"`
  21622. RefmsgTime string `json:"refmsg_time"`
  21623. RespondTime string `json:"respond_time"`
  21624. Signtype interface{} `json:"signtype"`
  21625. WarnInfo interface{} `json:"warn_info"`
  21626. }
  21627. // type Autogenerated struct {
  21628. // Output struct {
  21629. // Setlinfo struct {
  21630. // SetlTime string `json:"setl_time"`
  21631. // CvlservPay float64 `json:"cvlserv_pay"`
  21632. // Year string `json:"year"`
  21633. // MedType string `json:"med_type"`
  21634. // PsnPay float64 `json:"psn_pay"`
  21635. // OpterID string `json:"opter_id"`
  21636. // Begndate string `json:"begndate"`
  21637. // FlxempeFlag string `json:"flxempe_flag"`
  21638. // HifmiPay float64 `json:"hifmi_pay"`
  21639. // PsnNo string `json:"psn_no"`
  21640. // ActPayDedc float64 `json:"act_pay_dedc"`
  21641. // MedinsSetlID interface{} `json:"medins_setl_id"`
  21642. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  21643. // ClrWay string `json:"clr_way"`
  21644. // OthPay float64 `json:"oth_pay"`
  21645. // Gend string `json:"gend"`
  21646. // MdtrtID string `json:"mdtrt_id"`
  21647. // AcctPay float64 `json:"acct_pay"`
  21648. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  21649. // Insutype string `json:"insutype"`
  21650. // Invono interface{} `json:"invono"`
  21651. // Enddate string `json:"enddate"`
  21652. // CashPayamt float64 `json:"cash_payamt"`
  21653. // PsnType string `json:"psn_type"`
  21654. // FixmedinsName string `json:"fixmedins_name"`
  21655. // HifpPay float64 `json:"hifp_pay"`
  21656. // NewFlag interface{} `json:"new_flag"`
  21657. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21658. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  21659. // PayLoc string `json:"pay_loc"`
  21660. // ClrType string `json:"clr_type"`
  21661. // RefdSetlFlag string `json:"refd_setl_flag"`
  21662. // CvlservFlag string `json:"cvlserv_flag"`
  21663. // EmpName string `json:"emp_name"`
  21664. // Brdy string `json:"brdy"`
  21665. // Naty string `json:"naty"`
  21666. // Certno string `json:"certno"`
  21667. // DiseCode string `json:"dise_code"`
  21668. // FixmedinsCode string `json:"fixmedins_code"`
  21669. // DedcHospLv string `json:"dedc_hosp_lv"`
  21670. // OpterName string `json:"opter_name"`
  21671. // Balc float64 `json:"balc"`
  21672. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  21673. // PsnCertType string `json:"psn_cert_type"`
  21674. // HifobPay float64 `json:"hifob_pay"`
  21675. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  21676. // HifesPay float64 `json:"hifes_pay"`
  21677. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21678. // OptTime string `json:"opt_time"`
  21679. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21680. // SetlID string `json:"setl_id"`
  21681. // MafPay float64 `json:"maf_pay"`
  21682. // PsnName string `json:"psn_name"`
  21683. // InsuOptins interface{} `json:"insu_optins"`
  21684. // PrefFundPay interface{} `json:"pref_fund_pay"`
  21685. // ClrOptins string `json:"clr_optins"`
  21686. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21687. // DiseName string `json:"dise_name"`
  21688. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  21689. // Age float64 `json:"age"`
  21690. // DtrtCertType string `json:"dtrt_cert_type"`
  21691. // HospLv string `json:"hosp_lv"`
  21692. // } `json:"setlinfo"`
  21693. // Setldetail []struct {
  21694. // FundPayType string `json:"fund_pay_type"`
  21695. // FundPayamt float64 `json:"fund_payamt"`
  21696. // SetlProcInfo interface{} `json:"setl_proc_info"`
  21697. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  21698. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  21699. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  21700. // PrefFundPay interface{} `json:"pref_fund_pay"`
  21701. // } `json:"setldetail"`
  21702. // } `json:"output"`
  21703. // Infcode int `json:"infcode"`
  21704. // WarnMsg interface{} `json:"warn_msg"`
  21705. // Cainfo interface{} `json:"cainfo"`
  21706. // ErrMsg interface{} `json:"err_msg"`
  21707. // RefmsgTime string `json:"refmsg_time"`
  21708. // Signtype interface{} `json:"signtype"`
  21709. // RespondTime string `json:"respond_time"`
  21710. // InfRefmsgid string `json:"inf_refmsgid"`
  21711. // }
  21712. type Result002 struct {
  21713. Cainfo interface{} `json:"cainfo"`
  21714. ErrMsg string `json:"err_msg"`
  21715. InfRefmsgid string `json:"inf_refmsgid"`
  21716. Infcode int64 `json:"infcode"`
  21717. Output struct {
  21718. RxFile string `json:"rx_file"`
  21719. SignDigest string `json:"sign_digest"`
  21720. SignCertSn string `json:"sign_cert_sn"`
  21721. SignCertDn string `json:"sign_cert_dn"`
  21722. } `json:"output"`
  21723. RefmsgTime string `json:"refmsg_time"`
  21724. RespondTime string `json:"respond_time"`
  21725. Signtype interface{} `json:"signtype"`
  21726. WarnMsg interface{} `json:"warn_msg"`
  21727. }
  21728. type Result003 struct {
  21729. Cainfo interface{} `json:"cainfo"`
  21730. ErrMsg string `json:"err_msg"`
  21731. InfRefmsgid string `json:"inf_refmsgid"`
  21732. Infcode int64 `json:"infcode"`
  21733. Output struct {
  21734. HiRxno string `json:"hi_rxno"`
  21735. RxStasCodg string `json:"rx_stas_codg"`
  21736. RxStasName string `json:"rx_stas_name"`
  21737. } `json:"output"`
  21738. RefmsgTime string `json:"refmsg_time"`
  21739. RespondTime string `json:"respond_time"`
  21740. Signtype interface{} `json:"signtype"`
  21741. WarnMsg interface{} `json:"warn_msg"`
  21742. }
  21743. type ResultEleven struct {
  21744. Cainfo string `json:"cainfo"`
  21745. ErrMsg string `json:"err_msg"`
  21746. InfRefmsgid string `json:"inf_refmsgid"`
  21747. Infcode int64 `json:"infcode"`
  21748. Output struct {
  21749. Setlinfo struct {
  21750. SetlTime string `json:"setl_time"`
  21751. CvlservPay float64 `json:"cvlserv_pay"`
  21752. Year string `json:"year"`
  21753. MedType string `json:"med_type"`
  21754. PsnPay float64 `json:"psn_pay"`
  21755. OpterID string `json:"opter_id"`
  21756. Begndate string `json:"begndate"`
  21757. FlxempeFlag string `json:"flxempe_flag"`
  21758. HifmiPay float64 `json:"hifmi_pay"`
  21759. PsnNo string `json:"psn_no"`
  21760. ActPayDedc float64 `json:"act_pay_dedc"`
  21761. MedinsSetlID interface{} `json:"medins_setl_id"`
  21762. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  21763. ClrWay string `json:"clr_way"`
  21764. OthPay float64 `json:"oth_pay"`
  21765. Gend string `json:"gend"`
  21766. MdtrtID string `json:"mdtrt_id"`
  21767. AcctPay float64 `json:"acct_pay"`
  21768. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21769. Insutype string `json:"insutype"`
  21770. Invono interface{} `json:"invono"`
  21771. Enddate string `json:"enddate"`
  21772. CashPayamt float64 `json:"cash_payamt"`
  21773. PsnType string `json:"psn_type"`
  21774. FixmedinsName string `json:"fixmedins_name"`
  21775. HifpPay float64 `json:"hifp_pay"`
  21776. NewFlag interface{} `json:"new_flag"`
  21777. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21778. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21779. PayLoc string `json:"pay_loc"`
  21780. ClrType string `json:"clr_type"`
  21781. RefdSetlFlag string `json:"refd_setl_flag"`
  21782. CvlservFlag string `json:"cvlserv_flag"`
  21783. EmpName string `json:"emp_name"`
  21784. Brdy string `json:"brdy"`
  21785. Naty string `json:"naty"`
  21786. Certno string `json:"certno"`
  21787. DiseCode string `json:"dise_code"`
  21788. FixmedinsCode string `json:"fixmedins_code"`
  21789. DedcHospLv string `json:"dedc_hosp_lv"`
  21790. OpterName string `json:"opter_name"`
  21791. Balc float64 `json:"balc"`
  21792. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  21793. PsnCertType string `json:"psn_cert_type"`
  21794. HifobPay float64 `json:"hifob_pay"`
  21795. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21796. HifesPay float64 `json:"hifes_pay"`
  21797. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21798. OptTime string `json:"opt_time"`
  21799. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21800. SetlID string `json:"setl_id"`
  21801. MafPay float64 `json:"maf_pay"`
  21802. PsnName string `json:"psn_name"`
  21803. InsuOptins interface{} `json:"insu_optins"`
  21804. PrefFundPay interface{} `json:"pref_fund_pay"`
  21805. ClrOptins string `json:"clr_optins"`
  21806. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21807. DiseName string `json:"dise_name"`
  21808. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  21809. Age float64 `json:"age"`
  21810. DtrtCertType string `json:"dtrt_cert_type"`
  21811. HospLv string `json:"hosp_lv"`
  21812. PsnCashPay float64 `json:"psn_cash_pay"`
  21813. } `json:"setlinfo"`
  21814. } `json:"output"`
  21815. RefmsgTime string `json:"refmsg_time"`
  21816. RespondTime string `json:"respond_time"`
  21817. Signtype interface{} `json:"signtype"`
  21818. WarnMsg interface{} `json:"warn_msg"`
  21819. }
  21820. type ResultElevenah struct {
  21821. Cainfo string `json:"cainfo"`
  21822. ErrMsg string `json:"err_msg"`
  21823. InfRefmsgid string `json:"inf_refmsgid"`
  21824. Infcode int64 `json:"infcode"`
  21825. Output struct {
  21826. Setlinfo struct {
  21827. SetlTime int64 `json:"setl_time"`
  21828. CvlservPay float64 `json:"cvlserv_pay"`
  21829. Year string `json:"year"`
  21830. MedType string `json:"med_type"`
  21831. PsnPay float64 `json:"psn_pay"`
  21832. OpterID string `json:"opter_id"`
  21833. Begndate int64 `json:"begndate"`
  21834. FlxempeFlag string `json:"flxempe_flag"`
  21835. HifmiPay float64 `json:"hifmi_pay"`
  21836. PsnNo string `json:"psn_no"`
  21837. ActPayDedc float64 `json:"act_pay_dedc"`
  21838. MedinsSetlID interface{} `json:"medins_setl_id"`
  21839. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  21840. ClrWay string `json:"clr_way"`
  21841. OthPay float64 `json:"oth_pay"`
  21842. Gend string `json:"gend"`
  21843. MdtrtID string `json:"mdtrt_id"`
  21844. AcctPay float64 `json:"acct_pay"`
  21845. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21846. Insutype string `json:"insutype"`
  21847. Invono interface{} `json:"invono"`
  21848. Enddate int64 `json:"enddate"`
  21849. CashPayamt float64 `json:"cash_payamt"`
  21850. PsnType string `json:"psn_type"`
  21851. FixmedinsName string `json:"fixmedins_name"`
  21852. HifpPay float64 `json:"hifp_pay"`
  21853. NewFlag interface{} `json:"new_flag"`
  21854. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21855. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21856. PayLoc string `json:"pay_loc"`
  21857. ClrType string `json:"clr_type"`
  21858. RefdSetlFlag string `json:"refd_setl_flag"`
  21859. CvlservFlag string `json:"cvlserv_flag"`
  21860. EmpName string `json:"emp_name"`
  21861. Brdy int64 `json:"brdy"`
  21862. Naty string `json:"naty"`
  21863. Certno string `json:"certno"`
  21864. DiseCode string `json:"dise_code"`
  21865. FixmedinsCode string `json:"fixmedins_code"`
  21866. DedcHospLv string `json:"dedc_hosp_lv"`
  21867. OpterName string `json:"opter_name"`
  21868. Balc float64 `json:"balc"`
  21869. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  21870. PsnCertType string `json:"psn_cert_type"`
  21871. HifobPay float64 `json:"hifob_pay"`
  21872. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21873. HifesPay float64 `json:"hifes_pay"`
  21874. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21875. OptTime int64 `json:"opt_time"`
  21876. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21877. SetlID string `json:"setl_id"`
  21878. MafPay float64 `json:"maf_pay"`
  21879. PsnName string `json:"psn_name"`
  21880. InsuOptins interface{} `json:"insu_optins"`
  21881. PrefFundPay interface{} `json:"pref_fund_pay"`
  21882. ClrOptins string `json:"clr_optins"`
  21883. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21884. DiseName string `json:"dise_name"`
  21885. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  21886. Age float64 `json:"age"`
  21887. DtrtCertType string `json:"dtrt_cert_type"`
  21888. HospLv string `json:"hosp_lv"`
  21889. PsnCashPay float64 `json:"psn_cash_pay"`
  21890. } `json:"setlinfo"`
  21891. } `json:"output"`
  21892. RefmsgTime string `json:"refmsg_time"`
  21893. RespondTime string `json:"respond_time"`
  21894. Signtype interface{} `json:"signtype"`
  21895. WarnMsg interface{} `json:"warn_msg"`
  21896. }
  21897. type ResultEleven10265 struct {
  21898. Cainfo string `json:"cainfo"`
  21899. ErrMsg string `json:"err_msg"`
  21900. InfRefmsgid string `json:"inf_refmsgid"`
  21901. Infcode string `json:"infcode"`
  21902. Output struct {
  21903. Setlinfo struct {
  21904. SetlTime string `json:"setl_time"`
  21905. CvlservPay float64 `json:"cvlserv_pay"`
  21906. Year string `json:"year"`
  21907. MedType string `json:"med_type"`
  21908. PsnPay float64 `json:"psn_pay"`
  21909. OpterID string `json:"opter_id"`
  21910. Begndate string `json:"begndate"`
  21911. FlxempeFlag string `json:"flxempe_flag"`
  21912. HifmiPay float64 `json:"hifmi_pay"`
  21913. PsnNo string `json:"psn_no"`
  21914. ActPayDedc float64 `json:"act_pay_dedc"`
  21915. MedinsSetlID interface{} `json:"medins_setl_id"`
  21916. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  21917. ClrWay string `json:"clr_way"`
  21918. OthPay float64 `json:"oth_pay"`
  21919. Gend string `json:"gend"`
  21920. MdtrtID string `json:"mdtrt_id"`
  21921. AcctPay float64 `json:"acct_pay"`
  21922. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21923. Insutype string `json:"insutype"`
  21924. Invono interface{} `json:"invono"`
  21925. Enddate string `json:"enddate"`
  21926. CashPayamt float64 `json:"cash_payamt"`
  21927. PsnType string `json:"psn_type"`
  21928. FixmedinsName string `json:"fixmedins_name"`
  21929. HifpPay float64 `json:"hifp_pay"`
  21930. NewFlag interface{} `json:"new_flag"`
  21931. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21932. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21933. PayLoc string `json:"pay_loc"`
  21934. ClrType string `json:"clr_type"`
  21935. RefdSetlFlag string `json:"refd_setl_flag"`
  21936. CvlservFlag string `json:"cvlserv_flag"`
  21937. EmpName string `json:"emp_name"`
  21938. Brdy string `json:"brdy"`
  21939. Naty string `json:"naty"`
  21940. Certno string `json:"certno"`
  21941. DiseCode string `json:"dise_code"`
  21942. FixmedinsCode string `json:"fixmedins_code"`
  21943. DedcHospLv string `json:"dedc_hosp_lv"`
  21944. OpterName string `json:"opter_name"`
  21945. Balc float64 `json:"balc"`
  21946. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  21947. PsnCertType string `json:"psn_cert_type"`
  21948. HifobPay float64 `json:"hifob_pay"`
  21949. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21950. HifesPay float64 `json:"hifes_pay"`
  21951. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21952. OptTime string `json:"opt_time"`
  21953. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21954. SetlID string `json:"setl_id"`
  21955. MafPay float64 `json:"maf_pay"`
  21956. PsnName string `json:"psn_name"`
  21957. InsuOptins interface{} `json:"insu_optins"`
  21958. PrefFundPay interface{} `json:"pref_fund_pay"`
  21959. ClrOptins string `json:"clr_optins"`
  21960. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21961. DiseName string `json:"dise_name"`
  21962. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  21963. Age float64 `json:"age"`
  21964. DtrtCertType string `json:"dtrt_cert_type"`
  21965. HospLv string `json:"hosp_lv"`
  21966. PsnCashPay float64 `json:"psn_cash_pay"`
  21967. } `json:"setlinfo"`
  21968. } `json:"output"`
  21969. RefmsgTime string `json:"refmsg_time"`
  21970. RespondTime string `json:"respond_time"`
  21971. Signtype interface{} `json:"signtype"`
  21972. WarnMsg interface{} `json:"warn_msg"`
  21973. }
  21974. type ResultTwelve struct {
  21975. Cainfo string `json:"cainfo"`
  21976. ErrMsg string `json:"err_msg"`
  21977. InfRefmsgid string `json:"inf_refmsgid"`
  21978. Infcode int64 `json:"infcode"`
  21979. Output struct {
  21980. MdtrtId string `json:"mdtrt_id"`
  21981. ChrgBchno string `json:"chrg_bchno"`
  21982. PsnNo string `json:"psn_no"`
  21983. } `json:"output"`
  21984. RefmsgTime string `json:"refmsg_time"`
  21985. RespondTime string `json:"respond_time"`
  21986. Signtype interface{} `json:"signtype"`
  21987. WarnMsg interface{} `json:"warn_msg"`
  21988. }
  21989. type ResultThirteen struct {
  21990. ErrMsg string `json:"err_msg"`
  21991. InfRefmsgid string `json:"inf_refmsgid"`
  21992. Infcode int64 `json:"infcode"`
  21993. Output struct {
  21994. Result struct {
  21995. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  21996. } `json:"result"`
  21997. } `json:"output"`
  21998. RefmsgTime string `json:"refmsg_time"`
  21999. RespondTime string `json:"respond_time"`
  22000. Signtype interface{} `json:"signtype"`
  22001. WarnInfo interface{} `json:"warn_info"`
  22002. }
  22003. type ResultThirteen10265 struct {
  22004. ErrMsg string `json:"err_msg"`
  22005. InfRefmsgid string `json:"inf_refmsgid"`
  22006. Infcode string `json:"infcode"`
  22007. Output struct {
  22008. Result struct {
  22009. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22010. } `json:"result"`
  22011. } `json:"output"`
  22012. RefmsgTime string `json:"refmsg_time"`
  22013. RespondTime string `json:"respond_time"`
  22014. Signtype interface{} `json:"signtype"`
  22015. WarnInfo interface{} `json:"warn_info"`
  22016. }
  22017. type ResultFourteen struct {
  22018. ErrMsg string `json:"err_msg"`
  22019. InfRefmsgid string `json:"inf_refmsgid"`
  22020. Infcode int64 `json:"infcode"`
  22021. Output struct {
  22022. } `json:"output"`
  22023. RefmsgTime string `json:"refmsg_time"`
  22024. RespondTime string `json:"respond_time"`
  22025. Signtype interface{} `json:"signtype"`
  22026. WarnInfo interface{} `json:"warn_info"`
  22027. }
  22028. type ResultCFYLJG001 struct {
  22029. ErrMsg string `json:"err_msg"`
  22030. InfRefmsgid string `json:"inf_refmsgid"`
  22031. Infcode int64 `json:"infcode"`
  22032. Output struct {
  22033. RxTraceCode string `json:"rx_trace_code"`
  22034. HiRxno string `json:"hi_rxno"`
  22035. } `json:"output"`
  22036. RefmsgTime string `json:"refmsg_time"`
  22037. RespondTime string `json:"respond_time"`
  22038. Signtype interface{} `json:"signtype"`
  22039. WarnInfo interface{} `json:"warn_info"`
  22040. }
  22041. type ResultCFYLJG007 struct {
  22042. ErrMsg string `json:"err_msg"`
  22043. InfRefmsgid string `json:"inf_refmsgid"`
  22044. Infcode int64 `json:"infcode"`
  22045. Output struct {
  22046. HiRxno string `json:"hi_rxno"`
  22047. RxStasName string `json:"rx_stas_name"`
  22048. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22049. Seltdelts []interface{} `json:"seltdelts"`
  22050. RxUsedStasName string `json:"rx_used_stas_name"`
  22051. RxStasCodg string `json:"rx_stas_codg"`
  22052. } `json:"output"`
  22053. RefmsgTime string `json:"refmsg_time"`
  22054. RespondTime string `json:"respond_time"`
  22055. Signtype interface{} `json:"signtype"`
  22056. WarnInfo interface{} `json:"warn_info"`
  22057. }
  22058. type ResultCFYLJG002 struct {
  22059. ErrMsg string `json:"err_msg"`
  22060. InfRefmsgid string `json:"inf_refmsgid"`
  22061. Infcode int64 `json:"infcode"`
  22062. Output struct {
  22063. RxFile string `json:"rx_file"`
  22064. SignDigest string `json:"sign_digest"`
  22065. SignCertSn string `json:"sign_cert_sn"`
  22066. SignCertDn string `json:"sign_cert_dn"`
  22067. } `json:"output"`
  22068. RefmsgTime string `json:"refmsg_time"`
  22069. RespondTime string `json:"respond_time"`
  22070. Signtype interface{} `json:"signtype"`
  22071. WarnInfo interface{} `json:"warn_info"`
  22072. }
  22073. type ResultCFYLJG003 struct {
  22074. ErrMsg string `json:"err_msg"`
  22075. InfRefmsgid string `json:"inf_refmsgid"`
  22076. Infcode int64 `json:"infcode"`
  22077. Output struct {
  22078. HiRxno string `json:"hi_rxno"`
  22079. RxStasCodg string `json:"rx_stas_codg"`
  22080. RxStasName string `json:"rx_stas_name"`
  22081. } `json:"output"`
  22082. RefmsgTime string `json:"refmsg_time"`
  22083. RespondTime string `json:"respond_time"`
  22084. Signtype interface{} `json:"signtype"`
  22085. WarnInfo interface{} `json:"warn_info"`
  22086. }
  22087. type ResultCFYLJG004 struct {
  22088. ErrMsg string `json:"err_msg"`
  22089. InfRefmsgid string `json:"inf_refmsgid"`
  22090. Infcode int64 `json:"infcode"`
  22091. Output struct {
  22092. HiRxno string `json:"hi_rxno"`
  22093. RxStasCodg string `json:"rx_stas_codg"`
  22094. RxStasName string `json:"rx_stas_name"`
  22095. } `json:"output"`
  22096. RefmsgTime string `json:"refmsg_time"`
  22097. RespondTime string `json:"respond_time"`
  22098. Signtype interface{} `json:"signtype"`
  22099. WarnInfo interface{} `json:"warn_info"`
  22100. }
  22101. type ResultCFYLJG008 struct {
  22102. ErrMsg string `json:"err_msg"`
  22103. InfRefmsgid string `json:"inf_refmsgid"`
  22104. Infcode int64 `json:"infcode"`
  22105. Output struct {
  22106. PoolareaNo string `json:"poolareaNo"`
  22107. AdmdvsName string `json:"admdvsName"`
  22108. Count string `json:"count"`
  22109. } `json:"output"`
  22110. RefmsgTime string `json:"refmsg_time"`
  22111. RespondTime string `json:"respond_time"`
  22112. Signtype interface{} `json:"signtype"`
  22113. WarnInfo interface{} `json:"warn_info"`
  22114. }
  22115. type ResultCFYLJG005 struct {
  22116. ErrMsg string `json:"err_msg"`
  22117. InfRefmsgid string `json:"inf_refmsgid"`
  22118. Infcode int64 `json:"infcode"`
  22119. Output struct {
  22120. HiRxNo string `json:"hi_rxno"`
  22121. FixMedinsCode string `json:"fixmedins_code"`
  22122. FixMedinsName string `json:"fixmedins_name"`
  22123. RxStasCodg string `json:"rx_stas_codg"`
  22124. RxStasName string `json:"rx_stas_name"`
  22125. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22126. RxUserdStasName string `json:"rx_userd_stas_name"`
  22127. PrscTime string `json:"prsc_time"`
  22128. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22129. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22130. RxUsedWayName string `json:"rx_used_way_name"`
  22131. RxFrquCodg string `json:"rx_frqu_codg"`
  22132. RxFrquName string `json:"rx_frqu_name"`
  22133. RxDosunt string `json:"rx_dosunt"`
  22134. RxDoscnt float64 `json:"rx_doscnt"`
  22135. RxDrordDscr string `json:"rx_drord_dscr"`
  22136. ValiDays int64 `json:"vali_days"`
  22137. ValiEndTime string `json:"vali_end_time"`
  22138. ReptFlag string `json:"rept_flag"`
  22139. MaxReptCnt int64 `json:"max_rept_cnt"`
  22140. ReptdCnt int64 `json:"reptd_cnt"`
  22141. MinInrvDays int64 `json:"min_inrv_days"`
  22142. RxTypeCode string `json:"rx_type_code"`
  22143. RxTypeName string `json:"rx_type_name"`
  22144. LongRxFlag string `json:"long_rx_flag"`
  22145. RxDetlList []struct {
  22146. MedListCodg string `json:"med_list_codg"`
  22147. MedinsListCodg string `json:"medins_list_codg"`
  22148. HospPrepFlag string `json:"hosp_prep_flag"`
  22149. RxItemTypeCode string `json:"rx_item_type_code"`
  22150. RxItemTypeName string `json:"rx_item_type_name"`
  22151. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22152. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22153. TcmHerbFoote string `json:"tcmherb_foote"`
  22154. MednTypeCode string `json:"medn_type_code"`
  22155. MednTypeName string `json:"medn_type_name"`
  22156. MainMedcFlag string `json:"main_medc_flag"`
  22157. UrgtFlag string `json:"urgt_flag"`
  22158. BasMednFlag string `json:"bas_medn_flag"`
  22159. ImpDrugFlag string `json:"imp_drug_flag"`
  22160. ProdBarc string `json:"prod_barc"`
  22161. DrugProdname string `json:"drug_prodname"`
  22162. GennameCodg string `json:"genname_codg"`
  22163. DrugGenname string `json:"drug_genname"`
  22164. DrugDosform string `json:"drug_dosform"`
  22165. DrugSpec string `json:"drug_spec"`
  22166. PrdrName string `json:"prdr_name"`
  22167. MedcWayCodg string `json:"medc_way_codg"`
  22168. MedcWayDscr string `json:"medc_way_dscr"`
  22169. MedcBegntime string `json:"medc_begntime"`
  22170. MedcEndtime string `json:"medc_endtime"`
  22171. MedcDays float64 `json:"medc_days"`
  22172. DrugPric float64 `json:"drug_pric"`
  22173. DrugSumamt float64 `json:"drug_sumamt"`
  22174. DrugCnt float64 `json:"drug_cnt"`
  22175. DrugDosunt string `json:"drug_dosunt"`
  22176. SinDoscnt float64 `json:"sin_doscnt"`
  22177. SinDosunt string `json:"sin_dosunt"`
  22178. UsedFrquCodg string `json:"used_frqu_codg"`
  22179. UsedFrquName string `json:"used_frqu_name"`
  22180. DrugTotlcnt string `json:"drug_totlcnt"`
  22181. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22182. DiseCodg string `json:"dise_codg"`
  22183. HospApprFlag string `json:"hosp_appr_flag"`
  22184. } `json:"rx_detl_list"`
  22185. RxOtpinfo struct {
  22186. MedType string `json:"med_type"`
  22187. IptOtpNo string `json:"ipt_otp_no"`
  22188. OtpIptFlag string `json:"otp_ipt_flag"`
  22189. PatnName string `json:"patn_name"`
  22190. PatnAge float64 `json:"patn_age"`
  22191. PatnHgt float64 `json:"patn_hgt"`
  22192. PatnWt float64 `json:"patn_wt"`
  22193. Gend string `json:"gend"`
  22194. GesoVal float64 `json:"geso_val"`
  22195. NwbFlag string `json:"nwb_flag"`
  22196. NwbAge string `json:"nwb_age"`
  22197. SuckPrdFlag string `json:"suck_prd_flag"`
  22198. AlgsHis string `json:"algs_his"`
  22199. Insutype string `json:"insutype"`
  22200. PrscDeptName string `json:"prsc_dept_name"`
  22201. PrscDrName string `json:"prsc_dr_name"`
  22202. PharName string `json:"phar_name"`
  22203. PharChkTime string `json:"phar_chk_time"`
  22204. MdtrtTime string `json:"mdtrt_time"`
  22205. DiseCodg string `json:"dise_codg"`
  22206. DiseName string `json:"dise_name"`
  22207. SpDiseFlag string `json:"sp_dise_flag"`
  22208. MaindiagCode string `json:"maindiag_code"`
  22209. MaindiagName string `json:"maindiag_name"`
  22210. DiseCondDscr string `json:"dise_cond_dscr"`
  22211. FstdiagFlag string `json:"fstdiag_flag"`
  22212. } `json:"rx_otpinfo"`
  22213. RxDiseList []struct {
  22214. DiagType string `json:"diag_type"`
  22215. MaindiagFlag string `json:"maindiag_flag"`
  22216. DiagSrtNo string `json:"diag_srt_no"`
  22217. DiagCode string `json:"diag_code"`
  22218. DiagName string `json:"diag_name"`
  22219. DiagDept string `json:"diag_dept"`
  22220. DiagDrNo string `json:"diag_dr_no"`
  22221. DiagDrName string `json:"diag_dr_name"`
  22222. DiagTime string `json:"diag_time"`
  22223. TcmDiseCode string `json:"tcm_dise_code"`
  22224. TcmDiseName string `json:"tcm_dise_name"`
  22225. TcmSympCode string `json:"tcmsymp_code"`
  22226. TcmSymp string `json:"tcmsymp"`
  22227. } `json:"rx_dise_list"`
  22228. } `json:"output"`
  22229. RefmsgTime string `json:"refmsg_time"`
  22230. RespondTime string `json:"respond_time"`
  22231. Signtype interface{} `json:"signtype"`
  22232. WarnInfo interface{} `json:"warn_info"`
  22233. }
  22234. type ResultCFYLJG006 struct {
  22235. ErrMsg string `json:"err_msg"`
  22236. InfRefmsgid string `json:"inf_refmsgid"`
  22237. Infcode int64 `json:"infcode"`
  22238. Output struct {
  22239. HiRxNo string `json:"hi_rxno"`
  22240. PharCode string `json:"phar_code"`
  22241. PharName string `json:"phar_name"`
  22242. RxChkOpnn string `json:"rx_chk_opnn"`
  22243. RxChkTime string `json:"rx_chk_time"`
  22244. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22245. RxChkStasName string `json:"rx_chk_stas_name"`
  22246. RxStasCodg string `json:"rx_stas_codg"`
  22247. RxStasName string `json:"rx_stas_name"`
  22248. } `json:"output"`
  22249. RefmsgTime string `json:"refmsg_time"`
  22250. RespondTime string `json:"respond_time"`
  22251. Signtype interface{} `json:"signtype"`
  22252. WarnInfo interface{} `json:"warn_info"`
  22253. }
  22254. type ResultFourteen10265 struct {
  22255. ErrMsg string `json:"err_msg"`
  22256. InfRefmsgid string `json:"inf_refmsgid"`
  22257. Infcode string `json:"infcode"`
  22258. Output struct {
  22259. } `json:"output"`
  22260. RefmsgTime string `json:"refmsg_time"`
  22261. RespondTime string `json:"respond_time"`
  22262. Signtype interface{} `json:"signtype"`
  22263. WarnInfo interface{} `json:"warn_info"`
  22264. }
  22265. type ResultSixteen struct {
  22266. Cainfo string `json:"cainfo"`
  22267. ErrMsg string `json:"err_msg"`
  22268. InfRefmsgid string `json:"inf_refmsgid"`
  22269. Infcode int64 `json:"infcode"`
  22270. Output struct {
  22271. Setlinfo struct {
  22272. MdtrtID string `json:"mdtrt_id"`
  22273. SetlID string `json:"setl_id"`
  22274. ClrOptins string `json:"clr_optins"`
  22275. SetlTime string `json:"setl_time"`
  22276. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22277. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22278. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22279. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22280. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22281. ActPayDedc float64 `json:"act_pay_dedc"`
  22282. HifpPay float64 `json:"hifp_pay"`
  22283. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22284. Lfpay float64 `json:"selfpay"`
  22285. CvlservPay float64 `json:"cvlserv_pay"`
  22286. HifesPay float64 `json:"hifes_pay"`
  22287. HifmiPay float64 `json:"hifmi_pay"`
  22288. HifobPay float64 `json:"hifob_pay"`
  22289. MafPay float64 `json:"maf_pay"`
  22290. OthPay float64 `json:"oth_pay"`
  22291. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22292. PsnPartAmt float64 `json:"psn_part_amt"`
  22293. AcctPay float64 `json:"acct_pay"`
  22294. Balc float64 `json:"balc"`
  22295. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22296. HospPartAmt float64 `json:"hosp_part_amt"`
  22297. MedinsSetlID string `json:"medins_setl_id"`
  22298. PdnCashPay string `json:"pdn_cash_pay"`
  22299. } `json:"setlinfo"`
  22300. } `json:"output"`
  22301. RefmsgTime string `json:"refmsg_time"`
  22302. RespondTime string `json:"respond_time"`
  22303. Signtype interface{} `json:"signtype"`
  22304. WarnMsg interface{} `json:"warn_msg"`
  22305. }
  22306. type ResultSixteen10265 struct {
  22307. Cainfo string `json:"cainfo"`
  22308. ErrMsg string `json:"err_msg"`
  22309. InfRefmsgid string `json:"inf_refmsgid"`
  22310. Infcode string `json:"infcode"`
  22311. Output struct {
  22312. Setlinfo struct {
  22313. MdtrtID string `json:"mdtrt_id"`
  22314. SetlID string `json:"setl_id"`
  22315. ClrOptins string `json:"clr_optins"`
  22316. SetlTime string `json:"setl_time"`
  22317. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22318. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22319. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22320. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22321. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22322. ActPayDedc float64 `json:"act_pay_dedc"`
  22323. HifpPay float64 `json:"hifp_pay"`
  22324. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22325. Lfpay float64 `json:"selfpay"`
  22326. CvlservPay float64 `json:"cvlserv_pay"`
  22327. HifesPay float64 `json:"hifes_pay"`
  22328. HifmiPay float64 `json:"hifmi_pay"`
  22329. HifobPay float64 `json:"hifob_pay"`
  22330. MafPay float64 `json:"maf_pay"`
  22331. OthPay float64 `json:"oth_pay"`
  22332. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22333. PsnPartAmt float64 `json:"psn_part_amt"`
  22334. AcctPay float64 `json:"acct_pay"`
  22335. Balc float64 `json:"balc"`
  22336. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22337. HospPartAmt float64 `json:"hosp_part_amt"`
  22338. MedinsSetlID string `json:"medins_setl_id"`
  22339. PdnCashPay string `json:"pdn_cash_pay"`
  22340. } `json:"setlinfo"`
  22341. } `json:"output"`
  22342. RefmsgTime string `json:"refmsg_time"`
  22343. RespondTime string `json:"respond_time"`
  22344. Signtype interface{} `json:"signtype"`
  22345. WarnMsg interface{} `json:"warn_msg"`
  22346. }
  22347. type ResultSixteen10265Two struct {
  22348. Cainfo string `json:"cainfo"`
  22349. ErrMsg string `json:"err_msg"`
  22350. InfRefmsgid string `json:"inf_refmsgid"`
  22351. Infcode string `json:"infcode"`
  22352. Output struct {
  22353. Setlinfo interface{} `json:"setlinfo"`
  22354. } `json:"output"`
  22355. RefmsgTime string `json:"refmsg_time"`
  22356. RespondTime string `json:"respond_time"`
  22357. Signtype interface{} `json:"signtype"`
  22358. WarnMsg interface{} `json:"warn_msg"`
  22359. }
  22360. type ResultgzSixteen10265Two struct {
  22361. Cainfo string `json:"cainfo"`
  22362. ErrMsg string `json:"err_msg"`
  22363. InfRefmsgid string `json:"inf_refmsgid"`
  22364. Infcode int64 `json:"infcode"`
  22365. Output struct {
  22366. Setlinfo interface{} `json:"setlinfo"`
  22367. } `json:"output"`
  22368. RefmsgTime string `json:"refmsg_time"`
  22369. RespondTime string `json:"respond_time"`
  22370. Signtype interface{} `json:"signtype"`
  22371. WarnMsg interface{} `json:"warn_msg"`
  22372. }
  22373. type ResultSeventeen struct {
  22374. ErrMsg string `json:"err_msg"`
  22375. InfRefmsgid string `json:"inf_refmsgid"`
  22376. Infcode int64 `json:"infcode"`
  22377. Output struct {
  22378. SetlListId string `json:"setl_list_id"`
  22379. } `json:"output"`
  22380. RefmsgTime string `json:"refmsg_time"`
  22381. RespondTime string `json:"respond_time"`
  22382. Signtype string `json:"signtype"`
  22383. WarnInfo string `json:"warn_info"`
  22384. }
  22385. type ResultSeventeenOther struct {
  22386. ErrMsg string `json:"err_msg"`
  22387. InfRefmsgid string `json:"inf_refmsgid"`
  22388. Infcode string `json:"infcode"`
  22389. Output struct {
  22390. SetlListId string `json:"setl_list_id"`
  22391. } `json:"output"`
  22392. RefmsgTime string `json:"refmsg_time"`
  22393. RespondTime string `json:"respond_time"`
  22394. Signtype string `json:"signtype"`
  22395. WarnInfo string `json:"warn_info"`
  22396. }
  22397. type Result90991 struct {
  22398. ErrMsg string `json:"err_msg"`
  22399. InfRefmsgid string `json:"inf_refmsgid"`
  22400. Infcode int64 `json:"infcode"`
  22401. Output struct {
  22402. Result struct {
  22403. PsnNo string `json:"psn_no"`
  22404. CardStat string `json:"card_stat"`
  22405. Certno string `json:"certno"`
  22406. PsnName string `json:"psn_name"`
  22407. CheckStat string `json:"check_stat"`
  22408. SscnoCheckStat string `json:"sscno_check_stat"`
  22409. } `json:"result"`
  22410. } `json:"output"`
  22411. RefmsgTime string `json:"refmsg_time"`
  22412. RespondTime string `json:"respond_time"`
  22413. Signtype interface{} `json:"signtype"`
  22414. WarnInfo interface{} `json:"warn_info"`
  22415. }
  22416. type Result90100 struct {
  22417. ErrMsg string `json:"err_msg"`
  22418. InfRefmsgid string `json:"inf_refmsgid"`
  22419. Infcode int64 `json:"infcode"`
  22420. Output struct {
  22421. PoolareaNo string `json:"poolarea_no"`
  22422. PoolareaNoName string `json:"poolarea_no_name"`
  22423. Insutype string `json:"insutype"`
  22424. InsutypeName string `json:"insutype_name"`
  22425. ClctType string `json:"clct_type"`
  22426. ClctTypeName string `json:"clct_type_name"`
  22427. ClctFlag string `json:"clct_flag"`
  22428. ClctFlagName string `json:"clct_flag_name"`
  22429. AccrymBegn string `json:"accrym_begn"`
  22430. AccrymEnd string `json:"accrym_end"`
  22431. ClctTime string `json:"clct_time"`
  22432. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  22433. } `json:"output"`
  22434. RefmsgTime string `json:"refmsg_time"`
  22435. RespondTime string `json:"respond_time"`
  22436. Signtype interface{} `json:"signtype"`
  22437. WarnInfo interface{} `json:"warn_info"`
  22438. }
  22439. type Custom struct {
  22440. DetItemFeeSumamt string
  22441. Cut string
  22442. FeedetlSn string
  22443. Price string
  22444. MedListCodg string
  22445. Type int64
  22446. AdviceId int64
  22447. ProjectId int64
  22448. ItemId int64
  22449. }
  22450. type Result5301 struct {
  22451. ErrMsg string `json:"err_msg"`
  22452. InfRefmsgid string `json:"inf_refmsgid"`
  22453. Infcode int64 `json:"infcode"`
  22454. Output struct {
  22455. Result []struct {
  22456. OpspDiseCode string `json:"opsp_dise_code"`
  22457. OpspDiseName string `json:"opsp_dise_name"`
  22458. Begndate string `json:"begndate"`
  22459. Enddate string `json:"enddate"`
  22460. } `json:"feedetail"`
  22461. } `json:"output"`
  22462. RefmsgTime string `json:"refmsg_time"`
  22463. RespondTime string `json:"respond_time"`
  22464. Signtype interface{} `json:"signtype"`
  22465. WarnInfo interface{} `json:"warn_info"`
  22466. }
  22467. type Result5301For10265 struct {
  22468. ErrMsg string `json:"err_msg"`
  22469. InfRefmsgid string `json:"inf_refmsgid"`
  22470. Infcode string `json:"infcode"`
  22471. Output struct {
  22472. Result []struct {
  22473. OpspDiseCode string `json:"opsp_dise_code"`
  22474. OpspDiseName string `json:"opsp_dise_name"`
  22475. Begndate string `json:"begndate"`
  22476. Enddate string `json:"enddate"`
  22477. } `json:"feedetail"`
  22478. } `json:"output"`
  22479. RefmsgTime string `json:"refmsg_time"`
  22480. RespondTime string `json:"respond_time"`
  22481. Signtype interface{} `json:"signtype"`
  22482. WarnInfo interface{} `json:"warn_info"`
  22483. }
  22484. //获取个人信息----挂号-----上传就诊信息
  22485. func (c *HisApiController) GetRegisterInfo() {
  22486. id, _ := c.GetInt64("id")
  22487. record_time := c.GetString("record_time")
  22488. settlementValue, _ := c.GetInt64("settlement_value")
  22489. medical_insurance_card := c.GetString("medical_insurance_card")
  22490. name := c.GetString("name")
  22491. id_card_type, _ := c.GetInt64("id_card_type")
  22492. certificates, _ := c.GetInt64("certificates")
  22493. medical_care, _ := c.GetInt64("medical_care")
  22494. birthday := c.GetString("birthday")
  22495. id_card := c.GetString("id_card")
  22496. register_type, _ := c.GetInt64("register")
  22497. doctor, _ := c.GetInt64("doctor")
  22498. department, _ := c.GetInt64("department")
  22499. gender, _ := c.GetInt64("sex")
  22500. registration_fee, _ := c.GetFloat("registration_fee")
  22501. medical_expenses, _ := c.GetFloat("medical_expenses")
  22502. social_type, _ := c.GetInt64("social_type")
  22503. admin_user_id, _ := c.GetInt64("admin_user_id")
  22504. insuplc_admdvs := c.GetString("insuplc_admdvs")
  22505. mdtrt_type := c.GetString("mdtrt_type")
  22506. if id_card_type == 5 {
  22507. id_card_type = 4
  22508. }
  22509. timeLayout := "2006-01-02"
  22510. loc, _ := time.LoadLocation("Local")
  22511. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  22512. birthUnix := birthdays.Unix()
  22513. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  22514. if err != nil {
  22515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22516. return
  22517. }
  22518. recordDateTime := theTime.Unix()
  22519. adminInfo := c.GetAdminUserInfo()
  22520. var patient service.Patients
  22521. if id == 0 {
  22522. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  22523. } else {
  22524. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  22525. }
  22526. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  22527. if patientPrescription.ID == 0 {
  22528. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  22529. }
  22530. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22531. if patient.ID == 0 {
  22532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  22533. return
  22534. }
  22535. if len(patient.IdCardNo) == 0 {
  22536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  22537. return
  22538. }
  22539. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22540. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  22541. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  22542. //就诊结算未完成,不能进行二次挂号
  22543. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  22544. if len(his) >= 1 {
  22545. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  22546. if len(his) >= 1 && order.ID == 0 {
  22547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  22548. return
  22549. }
  22550. }
  22551. //var register_log string
  22552. if config.IsOpen == 1 {
  22553. var res ResultTwo
  22554. var res10265 ResultTwo10265
  22555. var PsnNo string
  22556. var PsnCertType string
  22557. var Certno string
  22558. var PsnName string
  22559. var Gend string
  22560. var Naty string
  22561. var Brdy string
  22562. var Age float64
  22563. var infoStr string
  22564. var idetinfoStr string
  22565. var infocode int64
  22566. var verify_number string
  22567. fmt.Println(verify_number)
  22568. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  22569. psn_info, _ := service.GetPsnByPatientId(id)
  22570. PsnNo = psn_info.PsnNo
  22571. PsnCertType = psn_info.PsnCertType
  22572. Certno = psn_info.Certno
  22573. PsnName = psn_info.PsnName
  22574. Gend = psn_info.Gend
  22575. Naty = psn_info.Naty
  22576. Brdy = psn_info.Brdy
  22577. Age = psn_info.Age
  22578. infoStr = psn_info.Insuinfo
  22579. idetinfoStr = psn_info.Idetinfo
  22580. infocode = 0
  22581. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22582. psn_info, _ := service.GetPsnByPatientId(id)
  22583. PsnNo = psn_info.PsnNo
  22584. PsnCertType = psn_info.PsnCertType
  22585. Certno = psn_info.Certno
  22586. PsnName = psn_info.PsnName
  22587. Gend = psn_info.Gend
  22588. Naty = psn_info.Naty
  22589. Brdy = psn_info.Brdy
  22590. Age = psn_info.Age
  22591. infoStr = psn_info.Insuinfo
  22592. idetinfoStr = psn_info.Idetinfo
  22593. infocode = 0
  22594. verify_number = psn_info.VerifyNumber
  22595. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22596. if id_card_type == 2 {
  22597. //请求内网数据
  22598. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  22599. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22600. "&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
  22601. resp, requestErr := http.Get(api)
  22602. if requestErr != nil {
  22603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22604. return
  22605. }
  22606. body, ioErr := ioutil.ReadAll(resp.Body)
  22607. if ioErr != nil {
  22608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22610. return
  22611. }
  22612. var respJSON map[string]interface{}
  22613. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22616. return
  22617. }
  22618. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22619. result_byte, _ := json.Marshal(respJSON)
  22620. result := string(result_byte)
  22621. var dat map[string]interface{}
  22622. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22623. fmt.Println(dat)
  22624. } else {
  22625. fmt.Println(err)
  22626. }
  22627. userJSONBytes, _ := json.Marshal(dat)
  22628. var res ResultTwo
  22629. var resTwo10265 ResultTwo10265
  22630. if miConfig.Code == "H15049901371" {
  22631. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  22632. utils.ErrorLog("解析失败:%v", err)
  22633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22634. return
  22635. }
  22636. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  22637. res.Infcode = Infcode
  22638. res.ErrMsg = resTwo10265.ErrMsg
  22639. res.Output = resTwo10265.Output
  22640. res.InfRefmsgid = resTwo10265.InfRefmsgid
  22641. res.RespondTime = resTwo10265.RespondTime
  22642. res.WarnInfo = resTwo10265.WarnInfo
  22643. } else {
  22644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22645. utils.ErrorLog("解析失败:%v", err)
  22646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22647. return
  22648. }
  22649. }
  22650. //var insutypes []string
  22651. //var insutype string
  22652. //var is390 int = 0
  22653. //var is310 int = 0
  22654. //for _, item := range res.Output.Iinfo {
  22655. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22656. // insutypes = append(insutypes, item.Insutype)
  22657. // }
  22658. //}
  22659. //if len(insutypes) == 1 {
  22660. // insutype = insutypes[0]
  22661. //} else {
  22662. // for _, i := range insutypes {
  22663. // if i == "390" {
  22664. // is390 = 1
  22665. // }
  22666. //
  22667. // if i == "310" {
  22668. // is310 = 1
  22669. // }
  22670. // }
  22671. //}
  22672. //if is390 == 1 {
  22673. // insutype = "390"
  22674. //}
  22675. //if is310 == 1 {
  22676. // insutype = "310"
  22677. //}
  22678. //if len(insutypes) == 0 {
  22679. // insutype = "310"
  22680. //}
  22681. PsnNo = res.Output.Baseinfo.PsnNo
  22682. PsnCertType = res.Output.Baseinfo.PsnCertType
  22683. Certno = res.Output.Baseinfo.Certno
  22684. PsnName = res.Output.Baseinfo.PsnName
  22685. Gend = res.Output.Baseinfo.Gend
  22686. Naty = res.Output.Baseinfo.Naty
  22687. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22688. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22689. infoStr = string(Iinfos)
  22690. idetinfoStr = string(Idetinfos)
  22691. infocode = res.Infcode
  22692. //infocode = 0
  22693. //verify_number = psn_info.VerifyNumber
  22694. } else {
  22695. psn_info, _ := service.GetPsnByPatientId(id)
  22696. PsnNo = psn_info.PsnNo
  22697. PsnCertType = psn_info.PsnCertType
  22698. Certno = psn_info.Certno
  22699. PsnName = psn_info.PsnName
  22700. Gend = psn_info.Gend
  22701. Naty = psn_info.Naty
  22702. Brdy = psn_info.Brdy
  22703. Age = psn_info.Age
  22704. infoStr = psn_info.Insuinfo
  22705. idetinfoStr = psn_info.Idetinfo
  22706. infocode = 0
  22707. verify_number = psn_info.VerifyNumber
  22708. }
  22709. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22710. if id_card_type == 1 {
  22711. psn_info, _ := service.GetPsnByPatientId(id)
  22712. PsnNo = psn_info.PsnNo
  22713. PsnCertType = psn_info.PsnCertType
  22714. Certno = psn_info.Certno
  22715. PsnName = psn_info.PsnName
  22716. Gend = psn_info.Gend
  22717. Naty = psn_info.Naty
  22718. Brdy = psn_info.Brdy
  22719. Age = psn_info.Age
  22720. infoStr = psn_info.Insuinfo
  22721. idetinfoStr = psn_info.Idetinfo
  22722. infocode = 0
  22723. verify_number = psn_info.VerifyNumber
  22724. } else if id_card_type == 2 {
  22725. 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)
  22726. fmt.Println(errMsgLog)
  22727. saveLog(result, requestLog, "1101", "人员基本信息获取")
  22728. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22729. utils.ErrorLog("解析失败:%v", err)
  22730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22731. return
  22732. }
  22733. PsnNo = res.Output.Baseinfo.PsnNo
  22734. PsnCertType = res.Output.Baseinfo.PsnCertType
  22735. Certno = res.Output.Baseinfo.Certno
  22736. PsnName = res.Output.Baseinfo.PsnName
  22737. Gend = res.Output.Baseinfo.Gend
  22738. Naty = res.Output.Baseinfo.Naty
  22739. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22740. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22741. infoStr = string(Iinfos)
  22742. idetinfoStr = string(Idetinfos)
  22743. infocode = res.Infcode
  22744. }
  22745. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22746. if id_card_type == 1 {
  22747. psn_info, _ := service.GetPsnByPatientId(id)
  22748. PsnNo = psn_info.PsnNo
  22749. PsnCertType = psn_info.PsnCertType
  22750. Certno = psn_info.Certno
  22751. PsnName = psn_info.PsnName
  22752. Gend = psn_info.Gend
  22753. Naty = psn_info.Naty
  22754. Brdy = psn_info.Brdy
  22755. Age = psn_info.Age
  22756. infoStr = psn_info.Insuinfo
  22757. idetinfoStr = psn_info.Idetinfo
  22758. infocode = 0
  22759. verify_number = psn_info.VerifyNumber
  22760. } else if id_card_type == 2 {
  22761. 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, "")
  22762. saveLog(result, requestLog, "1101", "人员基本信息获取")
  22763. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22764. utils.ErrorLog("解析失败:%v", err)
  22765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22766. return
  22767. }
  22768. PsnNo = res.Output.Baseinfo.PsnNo
  22769. PsnCertType = res.Output.Baseinfo.PsnCertType
  22770. Certno = res.Output.Baseinfo.Certno
  22771. PsnName = res.Output.Baseinfo.PsnName
  22772. Gend = res.Output.Baseinfo.Gend
  22773. Naty = res.Output.Baseinfo.Naty
  22774. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22775. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22776. infoStr = string(Iinfos)
  22777. idetinfoStr = string(Idetinfos)
  22778. infocode = res.Infcode
  22779. } else {
  22780. psn_info, _ := service.GetPsnByPatientId(id)
  22781. PsnNo = psn_info.PsnNo
  22782. PsnCertType = psn_info.PsnCertType
  22783. Certno = psn_info.Certno
  22784. PsnName = psn_info.PsnName
  22785. Gend = psn_info.Gend
  22786. Naty = psn_info.Naty
  22787. Brdy = psn_info.Brdy
  22788. Age = psn_info.Age
  22789. infoStr = psn_info.Insuinfo
  22790. idetinfoStr = psn_info.Idetinfo
  22791. infocode = 0
  22792. verify_number = psn_info.VerifyNumber
  22793. }
  22794. } else if miConfig.MdtrtareaAdmvs == "361025" {
  22795. if id_card_type == 1 {
  22796. psn_info, _ := service.GetPsnByPatientId(id)
  22797. PsnNo = psn_info.PsnNo
  22798. PsnCertType = psn_info.PsnCertType
  22799. Certno = psn_info.Certno
  22800. PsnName = psn_info.PsnName
  22801. Gend = psn_info.Gend
  22802. Naty = psn_info.Naty
  22803. Brdy = psn_info.Brdy
  22804. Age = psn_info.Age
  22805. infoStr = psn_info.Insuinfo
  22806. idetinfoStr = psn_info.Idetinfo
  22807. infocode = 0
  22808. verify_number = psn_info.VerifyNumber
  22809. } else if id_card_type == 2 {
  22810. psn_info, _ := service.GetPsnByPatientId(id)
  22811. PsnNo = psn_info.PsnNo
  22812. PsnCertType = psn_info.PsnCertType
  22813. Certno = psn_info.Certno
  22814. PsnName = psn_info.PsnName
  22815. Gend = psn_info.Gend
  22816. Naty = psn_info.Naty
  22817. Brdy = psn_info.Brdy
  22818. Age = psn_info.Age
  22819. infoStr = psn_info.Insuinfo
  22820. idetinfoStr = psn_info.Idetinfo
  22821. infocode = 0
  22822. verify_number = psn_info.VerifyNumber
  22823. } else {
  22824. psn_info, _ := service.GetPsnByPatientId(id)
  22825. PsnNo = psn_info.PsnNo
  22826. PsnCertType = psn_info.PsnCertType
  22827. Certno = psn_info.Certno
  22828. PsnName = psn_info.PsnName
  22829. Gend = psn_info.Gend
  22830. Naty = psn_info.Naty
  22831. Brdy = psn_info.Brdy
  22832. Age = psn_info.Age
  22833. infoStr = psn_info.Insuinfo
  22834. idetinfoStr = psn_info.Idetinfo
  22835. infocode = 0
  22836. verify_number = psn_info.VerifyNumber
  22837. }
  22838. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  22839. psn_info, _ := service.GetPsnByPatientId(id)
  22840. PsnNo = psn_info.PsnNo
  22841. PsnCertType = psn_info.PsnCertType
  22842. Certno = psn_info.Certno
  22843. PsnName = psn_info.PsnName
  22844. Gend = psn_info.Gend
  22845. Naty = psn_info.Naty
  22846. Brdy = psn_info.Brdy
  22847. Age = psn_info.Age
  22848. infoStr = psn_info.Insuinfo
  22849. idetinfoStr = psn_info.Idetinfo
  22850. infocode = 0
  22851. verify_number = psn_info.VerifyNumber
  22852. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22853. if id_card_type == 1 {
  22854. psn_info, _ := service.GetPsnByPatientId(id)
  22855. PsnNo = psn_info.PsnNo
  22856. PsnCertType = psn_info.PsnCertType
  22857. Certno = psn_info.Certno
  22858. PsnName = psn_info.PsnName
  22859. Gend = psn_info.Gend
  22860. Naty = psn_info.Naty
  22861. Brdy = psn_info.Brdy
  22862. Age = psn_info.Age
  22863. infoStr = psn_info.Insuinfo
  22864. idetinfoStr = psn_info.Idetinfo
  22865. infocode = 0
  22866. verify_number = psn_info.VerifyNumber
  22867. } else if id_card_type == 2 {
  22868. 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)
  22869. saveLog(result, requestLog, "1101", "人员基本信息获取")
  22870. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22871. utils.ErrorLog("解析失败:%v", err)
  22872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22873. return
  22874. }
  22875. PsnNo = res.Output.Baseinfo.PsnNo
  22876. PsnCertType = res.Output.Baseinfo.PsnCertType
  22877. Certno = res.Output.Baseinfo.Certno
  22878. PsnName = res.Output.Baseinfo.PsnName
  22879. Gend = res.Output.Baseinfo.Gend
  22880. Naty = res.Output.Baseinfo.Naty
  22881. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22882. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22883. infoStr = string(Iinfos)
  22884. idetinfoStr = string(Idetinfos)
  22885. infocode = res.Infcode
  22886. } else if id_card_type == 4 {
  22887. psn_info, _ := service.GetPsnByPatientId(id)
  22888. PsnNo = psn_info.PsnNo
  22889. PsnCertType = psn_info.PsnCertType
  22890. Certno = psn_info.Certno
  22891. PsnName = psn_info.PsnName
  22892. Gend = psn_info.Gend
  22893. Naty = psn_info.Naty
  22894. Brdy = psn_info.Brdy
  22895. Age = psn_info.Age
  22896. infoStr = psn_info.Insuinfo
  22897. idetinfoStr = psn_info.Idetinfo
  22898. infocode = 0
  22899. verify_number = psn_info.VerifyNumber
  22900. }
  22901. } else if miConfig.MdtrtareaAdmvs == "131023" {
  22902. var result string
  22903. var requestLog string
  22904. 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), "")
  22905. if id_card_type == 4 {
  22906. psn_info, _ := service.GetPsnByPatientId(id)
  22907. PsnNo = psn_info.PsnNo
  22908. PsnCertType = psn_info.PsnCertType
  22909. Certno = psn_info.Certno
  22910. PsnName = psn_info.PsnName
  22911. Gend = psn_info.Gend
  22912. Naty = psn_info.Naty
  22913. Brdy = psn_info.Brdy
  22914. Age = psn_info.Age
  22915. infoStr = psn_info.Insuinfo
  22916. idetinfoStr = psn_info.Idetinfo
  22917. infocode = 0
  22918. verify_number = psn_info.VerifyNumber
  22919. } else {
  22920. saveLog(result, requestLog, "1101", "人员基本信息获取")
  22921. if miConfig.Code == "H15049901371" {
  22922. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  22923. utils.ErrorLog("解析失败:%v", err)
  22924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22925. return
  22926. }
  22927. res.ErrMsg = res10265.ErrMsg
  22928. res.Output = res10265.Output
  22929. res.InfRefmsgid = res10265.InfRefmsgid
  22930. } else {
  22931. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22932. utils.ErrorLog("解析失败:%v", err)
  22933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22934. return
  22935. }
  22936. }
  22937. PsnNo = res.Output.Baseinfo.PsnNo
  22938. PsnCertType = res.Output.Baseinfo.PsnCertType
  22939. Certno = res.Output.Baseinfo.Certno
  22940. PsnName = res.Output.Baseinfo.PsnName
  22941. Gend = res.Output.Baseinfo.Gend
  22942. Naty = res.Output.Baseinfo.Naty
  22943. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22944. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22945. infoStr = string(Iinfos)
  22946. idetinfoStr = string(Idetinfos)
  22947. if miConfig.Code == "H15049901371" {
  22948. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  22949. } else {
  22950. infocode = res.Infcode
  22951. }
  22952. }
  22953. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22954. psn_info, _ := service.GetPsnByPatientId(id)
  22955. PsnNo = psn_info.PsnNo
  22956. PsnCertType = psn_info.PsnCertType
  22957. Certno = psn_info.Certno
  22958. PsnName = psn_info.PsnName
  22959. Gend = psn_info.Gend
  22960. Naty = psn_info.Naty
  22961. Brdy = psn_info.Brdy
  22962. Age = psn_info.Age
  22963. infoStr = psn_info.Insuinfo
  22964. idetinfoStr = psn_info.Idetinfo
  22965. infocode = 0
  22966. verify_number = psn_info.VerifyNumber
  22967. } else if miConfig.MdtrtareaAdmvs == "450721" {
  22968. psn_info, _ := service.GetPsnByPatientId(id)
  22969. PsnNo = psn_info.PsnNo
  22970. PsnCertType = psn_info.PsnCertType
  22971. Certno = psn_info.Certno
  22972. PsnName = psn_info.PsnName
  22973. Gend = psn_info.Gend
  22974. Naty = psn_info.Naty
  22975. Brdy = psn_info.Brdy
  22976. Age = psn_info.Age
  22977. infoStr = psn_info.Insuinfo
  22978. idetinfoStr = psn_info.Idetinfo
  22979. infocode = 0
  22980. verify_number = psn_info.VerifyNumber
  22981. } else {
  22982. var result string
  22983. var requestLog string
  22984. //if miConfig.UserOrgId == 10138 {
  22985. if id_card_type != 4 || id_card_type != 1 {
  22986. var insa string
  22987. if len(patient.InsuplcAdmdvs) > 0 {
  22988. insa = patient.InsuplcAdmdvs
  22989. } else {
  22990. insa = miConfig.InsuplcAdmdvs
  22991. }
  22992. //psn_info, _ := service.GetPsnByPatientId(id)
  22993. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  22994. 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)
  22995. }
  22996. //}
  22997. //else {
  22998. // var insa string
  22999. // if len(patient.InsuplcAdmdvs) > 0 {
  23000. // insa = patient.InsuplcAdmdvs
  23001. // } else {
  23002. // insa = miConfig.InsuplcAdmdvs
  23003. // }
  23004. // 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)
  23005. //}
  23006. if id_card_type == 4 || id_card_type == 1 {
  23007. psn_info, _ := service.GetPsnByPatientId(id)
  23008. PsnNo = psn_info.PsnNo
  23009. PsnCertType = psn_info.PsnCertType
  23010. Certno = psn_info.Certno
  23011. PsnName = psn_info.PsnName
  23012. Gend = psn_info.Gend
  23013. Naty = psn_info.Naty
  23014. Brdy = psn_info.Brdy
  23015. Age = psn_info.Age
  23016. infoStr = psn_info.Insuinfo
  23017. idetinfoStr = psn_info.Idetinfo
  23018. infocode = 0
  23019. verify_number = psn_info.VerifyNumber
  23020. } else {
  23021. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23022. if miConfig.Code == "H15049901371" {
  23023. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23024. utils.ErrorLog("解析失败:%v", err)
  23025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23026. return
  23027. }
  23028. res.ErrMsg = res10265.ErrMsg
  23029. res.Output = res10265.Output
  23030. res.InfRefmsgid = res10265.InfRefmsgid
  23031. } else {
  23032. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23033. utils.ErrorLog("解析失败:%v", err)
  23034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23035. return
  23036. }
  23037. }
  23038. PsnNo = res.Output.Baseinfo.PsnNo
  23039. PsnCertType = res.Output.Baseinfo.PsnCertType
  23040. Certno = res.Output.Baseinfo.Certno
  23041. PsnName = res.Output.Baseinfo.PsnName
  23042. Gend = res.Output.Baseinfo.Gend
  23043. Naty = res.Output.Baseinfo.Naty
  23044. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23045. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23046. infoStr = string(Iinfos)
  23047. idetinfoStr = string(Idetinfos)
  23048. if miConfig.Code == "H15049901371" {
  23049. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23050. } else {
  23051. infocode = res.Infcode
  23052. }
  23053. }
  23054. }
  23055. if infocode == 0 {
  23056. his := models.VMHisPatient{
  23057. Name: name,
  23058. Gender: gender,
  23059. Birthday: birthUnix,
  23060. MedicalTreatmentType: medical_care,
  23061. IdType: certificates,
  23062. IdCardNo: id_card,
  23063. BalanceAccountsType: settlementValue,
  23064. SocialType: social_type,
  23065. MedicalInsuranceNumber: medical_insurance_card,
  23066. RegisterType: register_type,
  23067. RegisterCost: registration_fee,
  23068. TreatmentCost: medical_expenses,
  23069. Status: 1,
  23070. Ctime: time.Now().Unix(),
  23071. Mtime: time.Now().Unix(),
  23072. PsnNo: PsnNo,
  23073. PsnCertType: PsnCertType,
  23074. Certno: Certno,
  23075. PsnName: PsnName,
  23076. Gend: Gend,
  23077. Naty: Naty,
  23078. Brdy: Brdy,
  23079. Age: Age,
  23080. Iinfo: infoStr,
  23081. Idetinfo: idetinfoStr,
  23082. PatientId: patient.ID,
  23083. RecordDate: theTime.Unix(),
  23084. UserOrgId: adminInfo.CurrentOrgId,
  23085. AdminUserId: admin_user_id,
  23086. IsReturn: 1,
  23087. IdCardType: id_card_type,
  23088. Doctor: doctor,
  23089. Departments: department,
  23090. MdtrtGrpType: mdtrt_type,
  23091. }
  23092. timestamp := time.Now().Unix()
  23093. tempTime := time.Unix(timestamp, 0)
  23094. timeFormat := tempTime.Format("20060102150405")
  23095. chrgBchno := rand.Intn(100000) + 10000
  23096. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23097. his.Number = ipt_otp_no
  23098. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23099. department, _ := service.GetDepartMentDetail(department)
  23100. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23101. IdCardNo := ""
  23102. if id_card_type == 1 {
  23103. // IdCardNo = medical_insurance_card
  23104. IdCardNo = patient.IdCardNo
  23105. } else {
  23106. IdCardNo = patient.IdCardNo
  23107. }
  23108. var rf []*ResultFive
  23109. json.Unmarshal([]byte(his.Iinfo), &rf)
  23110. var insutypes []*ResultFive
  23111. var insutype string
  23112. var insuplc_admdvs_temp string
  23113. var is390 int = 0
  23114. var is310 int = 0
  23115. for _, item := range rf {
  23116. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23117. insutypes = append(insutypes, item)
  23118. }
  23119. }
  23120. if len(insutypes) == 1 {
  23121. insutype = insutypes[0].Insutype
  23122. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23123. if insutype == "390" {
  23124. is390 = 1
  23125. }
  23126. if insutype == "310" {
  23127. is310 = 1
  23128. }
  23129. } else {
  23130. for _, i := range insutypes {
  23131. if i.Insutype == "390" {
  23132. is390 = 1
  23133. }
  23134. if i.Insutype == "310" {
  23135. is310 = 1
  23136. }
  23137. }
  23138. }
  23139. if is390 == 1 {
  23140. insutype = "390"
  23141. }
  23142. if is310 == 1 {
  23143. insutype = "310"
  23144. }
  23145. fmt.Println(social_type)
  23146. if social_type > 0 {
  23147. insutype = strconv.FormatInt(social_type, 10)
  23148. }
  23149. var infocode int64
  23150. var resThree ResultThree
  23151. var resThree10265 ResultThree10265
  23152. if len(insuplc_admdvs) == 0 {
  23153. psn_info, _ := service.GetPsnByPatientId(id)
  23154. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23155. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23156. //}
  23157. } else {
  23158. insuplc_admdvs_temp = insuplc_admdvs
  23159. }
  23160. if miConfig.MdtrtareaAdmvs == "421300" {
  23161. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23162. psn_info, _ := service.GetPsnByPatientId(id)
  23163. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23164. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23165. "&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
  23166. resp, requestErr := http.Get(api)
  23167. if requestErr != nil {
  23168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23169. return
  23170. }
  23171. body, ioErr := ioutil.ReadAll(resp.Body)
  23172. if ioErr != nil {
  23173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23175. return
  23176. }
  23177. var respJSON map[string]interface{}
  23178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23181. return
  23182. }
  23183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23184. result, _ := json.Marshal(respJSON)
  23185. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23186. utils.ErrorLog("解析失败:%v", err)
  23187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23188. return
  23189. }
  23190. infocode = resThree.Infcode
  23191. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23192. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23193. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23194. // insuplc_admdvs_temp =
  23195. //}
  23196. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23197. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23198. //}
  23199. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23200. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23201. "&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
  23202. resp, requestErr := http.Get(api)
  23203. if requestErr != nil {
  23204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23205. return
  23206. }
  23207. body, ioErr := ioutil.ReadAll(resp.Body)
  23208. if ioErr != nil {
  23209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23211. return
  23212. }
  23213. var respJSON map[string]interface{}
  23214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23217. return
  23218. }
  23219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23220. result, _ := json.Marshal(respJSON)
  23221. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23222. utils.ErrorLog("解析失败:%v", err)
  23223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23224. return
  23225. }
  23226. infocode = resThree.Infcode
  23227. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23228. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23229. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23230. // insuplc_admdvs_temp =
  23231. //}
  23232. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23233. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23234. //}
  23235. utils.ErrorLog("解析失败:%v", insutype)
  23236. utils.ErrorLog("解析失败:%v", PsnNo)
  23237. utils.ErrorLog("解析失败:%v", Certno)
  23238. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23239. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23240. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23241. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23242. utils.ErrorLog("解析失败:%v", PsnNo)
  23243. utils.ErrorLog("解析失败:%v", department.Number)
  23244. utils.ErrorLog("解析失败:%v", department.Name)
  23245. utils.ErrorLog("解析失败:%v", roles.UserName)
  23246. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23247. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23248. "&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
  23249. resp, requestErr := http.Get(api)
  23250. if requestErr != nil {
  23251. utils.ErrorLog("解析失败:%v", requestErr)
  23252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23253. return
  23254. }
  23255. body, ioErr := ioutil.ReadAll(resp.Body)
  23256. if ioErr != nil {
  23257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23259. return
  23260. }
  23261. var respJSON map[string]interface{}
  23262. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23265. return
  23266. }
  23267. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23268. result, _ := json.Marshal(respJSON)
  23269. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23270. utils.ErrorLog("解析失败:%v", err)
  23271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23272. return
  23273. }
  23274. infocode = resThree.Infcode
  23275. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23276. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23277. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23278. // insuplc_admdvs_temp =
  23279. //}
  23280. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23281. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23282. //}
  23283. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23284. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23285. "&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
  23286. resp, requestErr := http.Get(api)
  23287. if requestErr != nil {
  23288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23289. return
  23290. }
  23291. body, ioErr := ioutil.ReadAll(resp.Body)
  23292. if ioErr != nil {
  23293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23295. return
  23296. }
  23297. var respJSON map[string]interface{}
  23298. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23301. return
  23302. }
  23303. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23304. result, _ := json.Marshal(respJSON)
  23305. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23306. utils.ErrorLog("解析失败:%v", err)
  23307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23308. return
  23309. }
  23310. infocode = resThree.Infcode
  23311. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23312. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23313. psn_info, _ := service.GetPsnByPatientId(id)
  23314. var verify_number string
  23315. if id_card_type == 4 {
  23316. verify_number = psn_info.VerifyNumber
  23317. } else if id_card_type == 1 {
  23318. bas := strings.Split(psn_info.CardInfo, "|")
  23319. cardNumber := bas[2]
  23320. verify_number = cardNumber
  23321. }
  23322. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23323. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23324. "&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
  23325. resp, requestErr := http.Get(api)
  23326. if requestErr != nil {
  23327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23328. return
  23329. }
  23330. body, ioErr := ioutil.ReadAll(resp.Body)
  23331. if ioErr != nil {
  23332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23334. return
  23335. }
  23336. var respJSON map[string]interface{}
  23337. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23340. return
  23341. }
  23342. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23343. result, _ := json.Marshal(respJSON)
  23344. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23345. // utils.ErrorLog("解析失败:%v", err)
  23346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23347. // return
  23348. //}
  23349. //infocode = resThree.Infcode
  23350. //result, _ := json.Marshal(respJSON)
  23351. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23352. utils.ErrorLog("解析失败:%v", err)
  23353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23354. return
  23355. }
  23356. resThree.ErrMsg = resThree10265.ErrMsg
  23357. resThree.Output = resThree10265.Output
  23358. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23359. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23360. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23361. psn_info, _ := service.GetPsnByPatientId(id)
  23362. his.PsnNo = psn_info.PsnNo
  23363. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23364. var cert_no string
  23365. if id_card_type == 3 {
  23366. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  23367. cert_no = IdCardNo
  23368. } else if id_card_type == 4 {
  23369. cert_no = IdCardNo
  23370. psn_info.VerifyNumber = psn_info.VerifyNumber
  23371. } else {
  23372. bas := strings.Split(psn_info.CardInfo, "|")
  23373. cert_no = bas[2]
  23374. }
  23375. var hisPrescription []*models.HisPrescription
  23376. for _, item := range rf {
  23377. if item.Insutype == insutype {
  23378. //insuplc_admdvs = item.InsuplcAdmdvs
  23379. his.InsuplcAdmdvs = insuplc_admdvs
  23380. }
  23381. }
  23382. his.Insutype = insutype
  23383. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23384. fmt.Println(res3101)
  23385. fmt.Println(res3101.Infcode)
  23386. if res3101.Infcode == "0" {
  23387. fmt.Println("33333333")
  23388. if len(res3101.Output.Result) > 0 {
  23389. fmt.Println("222222")
  23390. for _, item := range res3101.Output.Result {
  23391. if len(res3101.ErrMsg) == 0 {
  23392. res3101.ErrMsg = item.VolaCont
  23393. } else {
  23394. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23395. }
  23396. }
  23397. c.ServeSuccessJSON(map[string]interface{}{
  23398. "failed_code": -10,
  23399. "msg": res3101.ErrMsg,
  23400. })
  23401. return
  23402. } else {
  23403. fmt.Println("11111")
  23404. var api string
  23405. if miConfig.MdtrtareaAdmvs == "320921" {
  23406. ipt_otp_no = timeFormat
  23407. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23408. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23409. "&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
  23410. } else {
  23411. ipt_otp_no = timeFormat
  23412. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23413. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23414. "&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
  23415. }
  23416. resp, requestErr := http.Get(api)
  23417. if requestErr != nil {
  23418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23419. return
  23420. }
  23421. body, ioErr := ioutil.ReadAll(resp.Body)
  23422. if ioErr != nil {
  23423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23425. return
  23426. }
  23427. var respJSON map[string]interface{}
  23428. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23431. return
  23432. }
  23433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23434. result, _ := json.Marshal(respJSON)
  23435. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23436. utils.ErrorLog("解析失败:%v", err)
  23437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23438. return
  23439. }
  23440. resThree.ErrMsg = resThree10265.ErrMsg
  23441. resThree.Output = resThree10265.Output
  23442. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23443. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23444. }
  23445. } else if res3101.Infcode != "0" {
  23446. c.ServeSuccessJSON(map[string]interface{}{
  23447. "failed_code": -10,
  23448. "msg": res3101.ErrMsg,
  23449. })
  23450. return
  23451. }
  23452. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23453. psn_info, _ := service.GetPsnByPatientId(id)
  23454. var cert_no string
  23455. if id_card_type == 1 {
  23456. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  23457. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23458. } else if id_card_type == 4 {
  23459. cert_no = psn_info.VerifyNumber
  23460. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23461. } else {
  23462. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23463. cert_no = psn_info.VerifyNumber
  23464. }
  23465. 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)
  23466. saveLog(result, requestLog, "2201", "挂号")
  23467. if miConfig.Code == "H15049901371" {
  23468. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23469. utils.ErrorLog("解析失败:%v", err)
  23470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23471. return
  23472. }
  23473. resThree.ErrMsg = resThree10265.ErrMsg
  23474. resThree.Output = resThree10265.Output
  23475. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23476. } else {
  23477. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23478. utils.ErrorLog("解析失败:%v", err)
  23479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23480. return
  23481. }
  23482. }
  23483. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23484. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  23485. psn_info, _ := service.GetPsnByPatientId(id)
  23486. var result string
  23487. var requestLog string
  23488. if id_card_type == 1 {
  23489. bas := strings.Split(psn_info.CardInfo, "|")
  23490. basNumber := bas[2]
  23491. card_sn := bas[3]
  23492. 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)
  23493. saveLog(result, requestLog, "2201A", "挂号")
  23494. } else if id_card_type == 2 {
  23495. 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, "", "", "", "", "", "")
  23496. saveLog(result, requestLog, "2201A", "挂号")
  23497. } else {
  23498. result, requestLog = service.Jxyb2201(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, psn_info.VerifyNumber, "", "", "01", IdCardNo, "15", psn_info.PsnName)
  23499. saveLog(result, requestLog, "2201A", "挂号")
  23500. }
  23501. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23502. utils.ErrorLog("解析失败:%v", err)
  23503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23504. return
  23505. }
  23506. infocode = resThree.Infcode
  23507. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  23508. psn_info, _ := service.GetPsnByPatientId(id)
  23509. var result string
  23510. var requestLog string
  23511. if id_card_type == 1 {
  23512. bas := strings.Split(psn_info.CardInfo, "|")
  23513. basNumber := bas[2]
  23514. card_sn := ""
  23515. 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)
  23516. saveLog(result, requestLog, "2201A", "挂号")
  23517. } else if id_card_type == 2 {
  23518. 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, "", "", "", "", "", "")
  23519. saveLog(result, requestLog, "2201A", "挂号")
  23520. } else {
  23521. result, requestLog = service.Jxyb2201(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, psn_info.VerifyNumber, "", "", "01", IdCardNo, "15", psn_info.PsnName)
  23522. saveLog(result, requestLog, "2201A", "挂号")
  23523. }
  23524. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23525. utils.ErrorLog("解析失败:%v", err)
  23526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23527. return
  23528. }
  23529. infocode = resThree.Infcode
  23530. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23531. psn_info, _ := service.GetPsnByPatientId(id)
  23532. his.PsnNo = psn_info.PsnNo
  23533. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23534. var cert_no string
  23535. if id_card_type == 1 {
  23536. bas := strings.Split(psn_info.CardInfo, "|")
  23537. cert_no = bas[2]
  23538. } else if id_card_type == 4 {
  23539. cert_no = IdCardNo
  23540. psn_info.VerifyNumber = psn_info.VerifyNumber
  23541. } else {
  23542. cert_no = IdCardNo
  23543. psn_info.VerifyNumber = cert_no
  23544. }
  23545. for _, item := range rf {
  23546. if item.Insutype == insutype {
  23547. his.InsuplcAdmdvs = insuplc_admdvs
  23548. }
  23549. }
  23550. his.Insutype = insutype
  23551. var api string
  23552. ipt_otp_no = timeFormat
  23553. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23554. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23555. "&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
  23556. resp, requestErr := http.Get(api)
  23557. if requestErr != nil {
  23558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23559. return
  23560. }
  23561. body, ioErr := ioutil.ReadAll(resp.Body)
  23562. if ioErr != nil {
  23563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23565. return
  23566. }
  23567. var respJSON map[string]interface{}
  23568. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23571. return
  23572. }
  23573. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23574. if status == "0" {
  23575. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23576. c.ServeSuccessJSON(map[string]interface{}{
  23577. "failed_code": -10,
  23578. "msg": err_msg,
  23579. })
  23580. return
  23581. }
  23582. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23583. result, _ := json.Marshal(respJSON)
  23584. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23585. utils.ErrorLog("解析失败:%v", err)
  23586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23587. return
  23588. }
  23589. infocode = resThree.Infcode
  23590. } else if miConfig.MdtrtareaAdmvs == "340699" {
  23591. psn_info, _ := service.GetPsnByPatientId(id)
  23592. his.PsnNo = psn_info.PsnNo
  23593. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23594. var cert_no string
  23595. if id_card_type == 1 {
  23596. bas := strings.Split(psn_info.CardInfo, "|")
  23597. cert_no = bas[2]
  23598. } else if id_card_type == 4 {
  23599. cert_no = IdCardNo
  23600. psn_info.VerifyNumber = psn_info.VerifyNumber
  23601. } else {
  23602. cert_no = IdCardNo
  23603. psn_info.VerifyNumber = cert_no
  23604. }
  23605. for _, item := range rf {
  23606. if item.Insutype == insutype {
  23607. his.InsuplcAdmdvs = insuplc_admdvs
  23608. }
  23609. }
  23610. his.Insutype = insutype
  23611. var api string
  23612. ipt_otp_no = timeFormat
  23613. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23614. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23615. "&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
  23616. resp, requestErr := http.Get(api)
  23617. if requestErr != nil {
  23618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23619. return
  23620. }
  23621. body, ioErr := ioutil.ReadAll(resp.Body)
  23622. if ioErr != nil {
  23623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23625. return
  23626. }
  23627. var respJSON map[string]interface{}
  23628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23631. return
  23632. }
  23633. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23634. if status == "0" {
  23635. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23636. c.ServeSuccessJSON(map[string]interface{}{
  23637. "failed_code": -10,
  23638. "msg": err_msg,
  23639. })
  23640. return
  23641. }
  23642. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23643. result, _ := json.Marshal(respJSON)
  23644. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23645. utils.ErrorLog("解析失败:%v", err)
  23646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23647. return
  23648. }
  23649. infocode = resThree.Infcode
  23650. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23651. psn_info, _ := service.GetPsnByPatientId(id)
  23652. var result string
  23653. var requestLog string
  23654. if id_card_type == 1 {
  23655. bas := strings.Split(psn_info.CardInfo, "|")
  23656. basNumber := bas[2]
  23657. card_sn := bas[3]
  23658. 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)
  23659. saveLog(result, requestLog, "2201A", "挂号")
  23660. } else if id_card_type == 2 {
  23661. 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, "", "")
  23662. saveLog(result, requestLog, "2201A", "挂号")
  23663. } else {
  23664. 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, "", "")
  23665. saveLog(result, requestLog, "2201A", "挂号")
  23666. }
  23667. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23668. utils.ErrorLog("解析失败:%v", err)
  23669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23670. return
  23671. }
  23672. infocode = resThree.Infcode
  23673. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23674. psn_info, _ := service.GetPsnByPatientId(id)
  23675. 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)
  23676. saveLog(result, requestLog, "2201A", "挂号")
  23677. if miConfig.Code == "H15049901371" {
  23678. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23679. utils.ErrorLog("解析失败:%v", err)
  23680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23681. return
  23682. }
  23683. resThree.ErrMsg = resThree10265.ErrMsg
  23684. resThree.Output = resThree10265.Output
  23685. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23686. } else {
  23687. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23688. utils.ErrorLog("解析失败:%v", err)
  23689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23690. return
  23691. }
  23692. }
  23693. if miConfig.Code == "H15049901371" {
  23694. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23695. } else {
  23696. infocode = resThree.Infcode
  23697. }
  23698. } else {
  23699. psn_info, _ := service.GetPsnByPatientId(id)
  23700. if id_card_type == 4 || id_card_type == 1 {
  23701. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23702. }
  23703. var rf []*ResultFive
  23704. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  23705. var insutypes []*ResultFive
  23706. var insutype string
  23707. var is390 int = 0
  23708. var is310 int = 0
  23709. for _, item := range rf {
  23710. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23711. insutypes = append(insutypes, item)
  23712. }
  23713. }
  23714. if len(insutypes) == 1 {
  23715. insutype = insutypes[0].Insutype
  23716. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23717. } else {
  23718. for _, i := range insutypes {
  23719. if i.Insutype == "390" {
  23720. is390 = 1
  23721. }
  23722. if i.Insutype == "310" {
  23723. is310 = 1
  23724. }
  23725. }
  23726. }
  23727. if is390 == 1 {
  23728. insutype = "390"
  23729. }
  23730. if is310 == 1 {
  23731. insutype = "310"
  23732. }
  23733. fmt.Println(len(insutypes))
  23734. if len(insutypes) == 0 {
  23735. for index, item := range rf {
  23736. if index == 0 {
  23737. insutype = item.Insutype
  23738. insuplc_admdvs = item.InsuplcAdmdvs
  23739. }
  23740. }
  23741. fmt.Println(insutype)
  23742. fmt.Println(insuplc_admdvs)
  23743. }
  23744. if social_type > 0 {
  23745. insutype = strconv.FormatInt(social_type, 10)
  23746. }
  23747. fmt.Println("--------")
  23748. fmt.Println(psn_info)
  23749. fmt.Println(psn_info.PsnNo)
  23750. if miConfig.MdtrtareaAdmvs == "441202" {
  23751. var hisPrescription []*models.HisPrescription
  23752. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23753. if res3101.Infcode == 0 {
  23754. fmt.Println("33333333")
  23755. if len(res3101.Output.Result) > 0 {
  23756. fmt.Println("222222")
  23757. for _, item := range res3101.Output.Result {
  23758. if len(res3101.ErrMsg) == 0 {
  23759. res3101.ErrMsg = item.VolaCont
  23760. } else {
  23761. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23762. }
  23763. }
  23764. c.ServeSuccessJSON(map[string]interface{}{
  23765. "failed_code": -10,
  23766. "msg": res3101.ErrMsg,
  23767. })
  23768. return
  23769. } else {
  23770. hour := time.Now().Format("15")
  23771. min := time.Now().Format("04")
  23772. sec := time.Now().Format("05")
  23773. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  23774. fmt.Println(record_time_two)
  23775. 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)
  23776. saveLog(result, requestLog, "2201A", "挂号")
  23777. if miConfig.Code == "H15049901371" {
  23778. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23779. utils.ErrorLog("解析失败:%v", err)
  23780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23781. return
  23782. }
  23783. resThree.ErrMsg = resThree10265.ErrMsg
  23784. resThree.Output = resThree10265.Output
  23785. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23786. } else {
  23787. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23788. utils.ErrorLog("解析失败:%v", err)
  23789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23790. return
  23791. }
  23792. }
  23793. if miConfig.Code == "H15049901371" {
  23794. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23795. } else {
  23796. infocode = resThree.Infcode
  23797. }
  23798. }
  23799. } else if res3101.Infcode != 0 {
  23800. c.ServeSuccessJSON(map[string]interface{}{
  23801. "failed_code": -10,
  23802. "msg": res3101.ErrMsg,
  23803. })
  23804. return
  23805. }
  23806. } else if miConfig.MdtrtareaAdmvs == "440205" {
  23807. var hisPrescription []*models.HisPrescription
  23808. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23809. if res3101.Infcode == 0 {
  23810. fmt.Println("33333333")
  23811. if len(res3101.Output.Result) > 0 {
  23812. fmt.Println("222222")
  23813. for _, item := range res3101.Output.Result {
  23814. if len(res3101.ErrMsg) == 0 {
  23815. res3101.ErrMsg = item.VolaCont
  23816. } else {
  23817. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23818. }
  23819. }
  23820. c.ServeSuccessJSON(map[string]interface{}{
  23821. "failed_code": -10,
  23822. "msg": res3101.ErrMsg,
  23823. })
  23824. return
  23825. } else {
  23826. hour := time.Now().Format("15")
  23827. min := time.Now().Format("04")
  23828. sec := time.Now().Format("05")
  23829. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  23830. fmt.Println(record_time_two)
  23831. 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)
  23832. saveLog(result, requestLog, "2201A", "挂号")
  23833. if miConfig.Code == "H15049901371" {
  23834. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23835. utils.ErrorLog("解析失败:%v", err)
  23836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23837. return
  23838. }
  23839. resThree.ErrMsg = resThree10265.ErrMsg
  23840. resThree.Output = resThree10265.Output
  23841. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23842. } else {
  23843. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23844. utils.ErrorLog("解析失败:%v", err)
  23845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23846. return
  23847. }
  23848. }
  23849. if miConfig.Code == "H15049901371" {
  23850. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23851. } else {
  23852. infocode = resThree.Infcode
  23853. }
  23854. }
  23855. } else if res3101.Infcode != 0 {
  23856. c.ServeSuccessJSON(map[string]interface{}{
  23857. "failed_code": -10,
  23858. "msg": res3101.ErrMsg,
  23859. })
  23860. return
  23861. }
  23862. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23863. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23864. psn_info, _ := service.GetPsnByPatientId(id)
  23865. var verify_number string
  23866. if id_card_type == 4 {
  23867. verify_number = psn_info.VerifyNumber
  23868. } else if id_card_type == 1 {
  23869. bas := strings.Split(psn_info.CardInfo, "|")
  23870. cardNumber := bas[2]
  23871. verify_number = cardNumber
  23872. } else {
  23873. verify_number = psn_info.Certno
  23874. }
  23875. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23876. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23877. "&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
  23878. resp, requestErr := http.Get(api)
  23879. if requestErr != nil {
  23880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23881. return
  23882. }
  23883. body, ioErr := ioutil.ReadAll(resp.Body)
  23884. if ioErr != nil {
  23885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23887. return
  23888. }
  23889. var respJSON map[string]interface{}
  23890. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23893. return
  23894. }
  23895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23896. result, _ := json.Marshal(respJSON)
  23897. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23898. utils.ErrorLog("解析失败:%v", err)
  23899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23900. return
  23901. }
  23902. infocode = resThree.Infcode
  23903. } else {
  23904. hour := time.Now().Format("15")
  23905. min := time.Now().Format("04")
  23906. sec := time.Now().Format("05")
  23907. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  23908. if id_card_type == 1 {
  23909. for _, item := range rf {
  23910. if item.Insutype == strconv.FormatInt(social_type, 10) {
  23911. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  23912. insuplc_admdvs_temp = item.InsuplcAdmdvs
  23913. } else if strconv.FormatInt(social_type, 10) == "390" {
  23914. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23915. } else {
  23916. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23917. }
  23918. }
  23919. }
  23920. }
  23921. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  23922. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23923. }
  23924. if id_card_type == 1 {
  23925. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  23926. bas := strings.Split(psn_info.CardInfo, "|")
  23927. basNumber := bas[1]
  23928. IdCardNo = basNumber
  23929. }
  23930. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  23931. IdCardNo = psn_info.VerifyNumber
  23932. }
  23933. if len(insuplc_admdvs_temp) == 0 {
  23934. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23935. }
  23936. 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)
  23937. saveLog(result, requestLog, "2201A", "挂号")
  23938. if miConfig.Code == "H15049901371" {
  23939. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23940. utils.ErrorLog("解析失败:%v", err)
  23941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23942. return
  23943. }
  23944. resThree.ErrMsg = resThree10265.ErrMsg
  23945. resThree.Output = resThree10265.Output
  23946. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23947. } else {
  23948. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23949. utils.ErrorLog("解析失败:%v", err)
  23950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23951. return
  23952. }
  23953. }
  23954. if miConfig.Code == "H15049901371" {
  23955. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23956. } else {
  23957. infocode = resThree.Infcode
  23958. }
  23959. }
  23960. }
  23961. if infocode == -1 {
  23962. adminUser := c.GetAdminUserInfo()
  23963. errlog := &models.HisOrderError{
  23964. UserOrgId: adminUser.CurrentOrgId,
  23965. Ctime: time.Now().Unix(),
  23966. Mtime: time.Now().Unix(),
  23967. ErrMsg: resThree.ErrMsg,
  23968. Status: 1,
  23969. PatientId: id,
  23970. RecordTime: recordDateTime,
  23971. Stage: 2,
  23972. }
  23973. service.CreateErrMsgLog(errlog)
  23974. c.ServeSuccessJSON(map[string]interface{}{
  23975. "failed_code": -10,
  23976. "msg": resThree.ErrMsg,
  23977. })
  23978. return
  23979. }
  23980. his.Number = resThree.Output.Data.MdtrtID
  23981. his.PsnNo = resThree.Output.Data.PsnNo
  23982. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  23983. his.IdCardNo = patient.IdCardNo
  23984. his.PhoneNumber = patient.Phone
  23985. his.UserOrgId = adminInfo.CurrentOrgId
  23986. his.Insutype = insutype
  23987. his.Ctime = time.Now().Unix()
  23988. his.Mtime = time.Now().Unix()
  23989. his.InsuplcAdmdvs = insuplc_admdvs_temp
  23990. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  23991. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  23992. }
  23993. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  23994. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  23995. }
  23996. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  23997. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  23998. }
  23999. his.Status = 1
  24000. his.MdtrtGrpType = mdtrt_type
  24001. service.UpdateHisPatientStatus(&his)
  24002. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24003. c.ServeSuccessJSON(map[string]interface{}{
  24004. "his_info": his,
  24005. })
  24006. } else {
  24007. adminUser := c.GetAdminUserInfo()
  24008. errlog := &models.HisOrderError{
  24009. UserOrgId: adminUser.CurrentOrgId,
  24010. Ctime: time.Now().Unix(),
  24011. Mtime: time.Now().Unix(),
  24012. ErrMsg: res.ErrMsg,
  24013. Status: 1,
  24014. PatientId: id,
  24015. RecordTime: recordDateTime,
  24016. Stage: 1,
  24017. }
  24018. service.CreateErrMsgLog(errlog)
  24019. c.ServeSuccessJSON(map[string]interface{}{
  24020. "failed_code": -10,
  24021. "msg": res.ErrMsg,
  24022. })
  24023. return
  24024. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24025. }
  24026. }
  24027. }
  24028. func (c *HisApiController) GetUploadInfo() {
  24029. id, _ := c.GetInt64("id")
  24030. record_time := c.GetString("record_time")
  24031. his_patient_id, _ := c.GetInt64("his_patient_id")
  24032. order_id, _ := c.GetInt64("order_id")
  24033. pay_way, _ := c.GetInt64("pay_way")
  24034. pay_ways := c.GetString("pay_ways")
  24035. oth_desc := c.GetString("oth_desc")
  24036. pay_price, _ := c.GetFloat("pay_price")
  24037. pay_card_no := c.GetString("pay_card_no")
  24038. discount_price, _ := c.GetFloat("discount_price")
  24039. preferential_price, _ := c.GetFloat("preferential_price")
  24040. reality_price, _ := c.GetFloat("reality_price")
  24041. found_price, _ := c.GetFloat("found_price")
  24042. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24043. private_price, _ := c.GetFloat("private_price")
  24044. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24045. admin_user_id, _ := c.GetInt64("admin_user_id")
  24046. fapiao_code := c.GetString("fapiao_code")
  24047. fapiao_number := c.GetString("fapiao_number")
  24048. diagnosis_id := c.GetString("diagnosis")
  24049. sick_type, _ := c.GetInt64("sick_type")
  24050. reg_type, _ := c.GetInt64("p_type")
  24051. begin_time := c.GetString("begin_time")
  24052. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24053. cash_pay := c.GetString("cash_pay")
  24054. band_card_pay := c.GetString("band_card_pay")
  24055. wechat_pay := c.GetString("wechat_pay")
  24056. ali_pay := c.GetString("ali_pay")
  24057. jifen_pay := c.GetString("jifen_pay")
  24058. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24059. fmt.Println(acct_used_flag)
  24060. id_str := c.GetString("ids")
  24061. ids_arr := strings.Split(id_str, ",")
  24062. timeLayout := "2006-01-02"
  24063. loc, _ := time.LoadLocation("Local")
  24064. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24065. if err != nil {
  24066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24067. return
  24068. }
  24069. recordDateTime := theTime.Unix()
  24070. adminUser := c.GetAdminUserInfo()
  24071. var tempOrder models.HisOrder
  24072. tempOrder, _ = service.GetHisOrderByID(order_id)
  24073. var prescriptions []*models.HisPrescription
  24074. var start_time int64
  24075. var end_time int64
  24076. //押金模块
  24077. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24078. tmp_decimal := c.GetString("tmp_decimal")
  24079. var decimal float64 //本次使用的押金
  24080. var errmsg error
  24081. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24082. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24083. return
  24084. }
  24085. if len(tmp_decimal) > 0 {
  24086. if tmp_decimal[0] == 45 {
  24087. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24088. return
  24089. }
  24090. }
  24091. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24092. fmt.Println(errs)
  24093. decimal = tt
  24094. //if adminUser.CurrentOrgId == 10106{
  24095. // if len(fapiao_code) == 0{
  24096. // fapiao_code = "144072080589"
  24097. // }
  24098. // if len(fapiao_number) == 0{
  24099. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24100. // if order.ID == 0{
  24101. // fapiao_number = "00001520"
  24102. // }else{
  24103. // //fapiao_code = "00001520"
  24104. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24105. // var zero string
  24106. // if fpNumber >= 1000{
  24107. // zero = "0000" + strconv.Itoa(fpNumber)
  24108. // }else if fpNumber >= 10000{
  24109. // zero = "000" + strconv.Itoa(fpNumber)
  24110. // } else if fpNumber >= 100000{
  24111. // zero = "00" + strconv.Itoa(fpNumber)
  24112. // } else if fpNumber >= 1000000{
  24113. // zero = "0" + strconv.Itoa(fpNumber)
  24114. // }else {
  24115. // zero = strconv.Itoa(fpNumber)
  24116. // }
  24117. // fapiao_number = zero
  24118. // }
  24119. // }
  24120. //}
  24121. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24122. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24123. var patientPrescription models.HisPrescriptionInfo
  24124. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24125. if patientPrescription.ID == 0 {
  24126. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24127. }
  24128. //if patientPrescription.Do
  24129. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24130. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24131. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24132. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24133. var config []*models.HisXtDiagnoseConfig
  24134. for _, item := range diagnosis_ids {
  24135. id, _ := strconv.ParseInt(item, 10, 64)
  24136. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24137. config = append(config, &diagnosisConfig)
  24138. }
  24139. sickConfig, _ := service.FindSickById(sick_type)
  24140. //if tempOrder.ID == 0 {
  24141. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24142. //}
  24143. if tempOrder.ID == 0 {
  24144. var result string
  24145. var requestLog string
  24146. var res2 ResultSix
  24147. var res3 GZResultSix
  24148. var ressix10265 ResultSix10265
  24149. if miConfig.MdtrtareaAdmvs == "421300" {
  24150. data := make(map[string]interface{})
  24151. client := &http.Client{}
  24152. data["psn_no"] = his.PsnNo
  24153. data["mdtrt_id"] = his.Number
  24154. data["opter"] = roles.UserName
  24155. data["org_name"] = miConfig.OrgName
  24156. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24157. data["doctor_id"] = doctor_info.DoctorNumber
  24158. data["doctor_name"] = doctor_info.UserName
  24159. data["department"] = department.Name
  24160. data["fixmedins_code"] = miConfig.Code
  24161. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24162. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24163. data["secret_key"] = miConfig.SecretKey
  24164. data["sick_code"] = sickConfig.CountryCode
  24165. data["sick_name"] = sickConfig.ClassName
  24166. data["dept"] = strconv.FormatInt(department.ID, 10)
  24167. data["config"] = config
  24168. data["begin_time"] = begin_time
  24169. bytesData, _ := json.Marshal(data)
  24170. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24171. resp, _ := client.Do(req)
  24172. defer resp.Body.Close()
  24173. body, ioErr := ioutil.ReadAll(resp.Body)
  24174. if ioErr != nil {
  24175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24177. return
  24178. }
  24179. var respJSON map[string]interface{}
  24180. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24183. return
  24184. }
  24185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24186. userJSONBytes, _ := json.Marshal(respJSON)
  24187. fmt.Println("log")
  24188. fmt.Println(string(userJSONBytes))
  24189. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24190. utils.ErrorLog("解析失败:%v", err)
  24191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24192. return
  24193. }
  24194. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24195. data := make(map[string]interface{})
  24196. client := &http.Client{}
  24197. data["psn_no"] = his.PsnNo
  24198. data["mdtrt_id"] = his.Number
  24199. data["opter"] = roles.UserName
  24200. data["org_name"] = miConfig.OrgName
  24201. if reg_type == 11 && his.Insutype == "390" {
  24202. data["med_type"] = "110104"
  24203. } else {
  24204. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24205. }
  24206. data["doctor_id"] = doctor_info.DoctorNumber
  24207. data["doctor_name"] = doctor_info.UserName
  24208. data["department"] = department.Name
  24209. data["fixmedins_code"] = miConfig.Code
  24210. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24211. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24212. data["secret_key"] = miConfig.SecretKey
  24213. data["sick_code"] = sickConfig.CountryCode
  24214. data["sick_name"] = sickConfig.ClassName
  24215. data["dept"] = strconv.FormatInt(department.ID, 10)
  24216. data["config"] = config
  24217. data["begin_time"] = begin_time
  24218. bytesData, _ := json.Marshal(data)
  24219. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24220. resp, _ := client.Do(req)
  24221. defer resp.Body.Close()
  24222. body, ioErr := ioutil.ReadAll(resp.Body)
  24223. if ioErr != nil {
  24224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24226. return
  24227. }
  24228. var respJSON map[string]interface{}
  24229. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24232. return
  24233. }
  24234. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24235. userJSONBytes, _ := json.Marshal(respJSON)
  24236. fmt.Println("log")
  24237. fmt.Println(string(userJSONBytes))
  24238. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24239. utils.ErrorLog("解析失败:%v", err)
  24240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24241. return
  24242. }
  24243. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24244. data := make(map[string]interface{})
  24245. client := &http.Client{}
  24246. data["psn_no"] = his.PsnNo
  24247. data["mdtrt_id"] = his.Number
  24248. data["opter"] = roles.UserName
  24249. data["org_name"] = miConfig.OrgName
  24250. if reg_type == 11 && his.Insutype == "390" {
  24251. data["med_type"] = "110104"
  24252. } else {
  24253. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24254. }
  24255. data["doctor_id"] = doctor_info.DoctorNumber
  24256. data["doctor_name"] = doctor_info.UserName
  24257. data["department"] = department.Name
  24258. data["fixmedins_code"] = miConfig.Code
  24259. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24260. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24261. data["secret_key"] = miConfig.SecretKey
  24262. data["sick_code"] = sickConfig.CountryCode
  24263. data["sick_name"] = sickConfig.ClassName
  24264. data["dept"] = strconv.FormatInt(department.ID, 10)
  24265. data["config"] = config
  24266. data["begin_time"] = begin_time
  24267. bytesData, _ := json.Marshal(data)
  24268. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24269. resp, _ := client.Do(req)
  24270. defer resp.Body.Close()
  24271. body, ioErr := ioutil.ReadAll(resp.Body)
  24272. if ioErr != nil {
  24273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24275. return
  24276. }
  24277. var respJSON map[string]interface{}
  24278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24281. return
  24282. }
  24283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24284. userJSONBytes, _ := json.Marshal(respJSON)
  24285. fmt.Println("log")
  24286. fmt.Println(string(userJSONBytes))
  24287. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24288. utils.ErrorLog("解析失败:%v", err)
  24289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24290. return
  24291. }
  24292. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24293. data := make(map[string]interface{})
  24294. client := &http.Client{}
  24295. data["psn_no"] = his.PsnNo
  24296. data["mdtrt_id"] = his.Number
  24297. data["opter"] = roles.UserName
  24298. data["org_name"] = miConfig.OrgName
  24299. if reg_type == 11 && his.Insutype == "390" {
  24300. data["med_type"] = "110104"
  24301. } else {
  24302. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24303. }
  24304. data["doctor_id"] = doctor_info.DoctorNumber
  24305. data["doctor_name"] = doctor_info.UserName
  24306. data["department"] = department.Name
  24307. data["fixmedins_code"] = miConfig.Code
  24308. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24309. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24310. data["secret_key"] = miConfig.SecretKey
  24311. data["sick_code"] = sickConfig.CountryCode
  24312. data["sick_name"] = sickConfig.ClassName
  24313. data["dept"] = strconv.FormatInt(department.ID, 10)
  24314. data["config"] = config
  24315. data["begin_time"] = begin_time
  24316. bytesData, _ := json.Marshal(data)
  24317. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24318. resp, _ := client.Do(req)
  24319. defer resp.Body.Close()
  24320. body, ioErr := ioutil.ReadAll(resp.Body)
  24321. if ioErr != nil {
  24322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24324. return
  24325. }
  24326. var respJSON map[string]interface{}
  24327. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24330. return
  24331. }
  24332. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24333. userJSONBytes, _ := json.Marshal(respJSON)
  24334. fmt.Println("log")
  24335. fmt.Println(string(userJSONBytes))
  24336. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24337. utils.ErrorLog("解析失败:%v", err)
  24338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24339. return
  24340. }
  24341. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24342. data := make(map[string]interface{})
  24343. client := &http.Client{}
  24344. data["psn_no"] = his.PsnNo
  24345. data["mdtrt_id"] = his.Number
  24346. data["doctor"] = roles.UserName
  24347. data["department"] = department.Name
  24348. data["org_name"] = miConfig.OrgName
  24349. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24350. data["doctor_id"] = doctor_info.DoctorNumber
  24351. data["new_doctor_name"] = doctor_info.UserName
  24352. data["fixmedins_code"] = miConfig.Code
  24353. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24354. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24355. data["secret_key"] = miConfig.SecretKey
  24356. data["sick_code"] = sickConfig.CountryCode
  24357. data["sick_name"] = sickConfig.ClassName
  24358. data["url"] = miConfig.Url
  24359. data["ak"] = miConfig.AccessKey
  24360. data["begin_time"] = begin_time
  24361. data["cainfo"] = miConfig.Cainfo
  24362. data["dept"] = strconv.FormatInt(department.ID, 10)
  24363. data["config"] = config
  24364. bytesData, _ := json.Marshal(data)
  24365. var req *http.Request
  24366. if miConfig.MdtrtareaAdmvs == "320921" {
  24367. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24368. //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 +
  24369. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  24370. } else {
  24371. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24372. }
  24373. resp, _ := client.Do(req)
  24374. defer resp.Body.Close()
  24375. body, ioErr := ioutil.ReadAll(resp.Body)
  24376. if ioErr != nil {
  24377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24379. return
  24380. }
  24381. var respJSON map[string]interface{}
  24382. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24385. return
  24386. }
  24387. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24388. userJSONBytes, _ := json.Marshal(respJSON)
  24389. fmt.Println("log")
  24390. fmt.Println(string(userJSONBytes))
  24391. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  24392. utils.ErrorLog("解析失败:%v", err)
  24393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24394. return
  24395. }
  24396. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24397. res2.Output = ressix10265.Output
  24398. res2.ErrMsg = ressix10265.ErrMsg
  24399. res2.Cainfo = ressix10265.Cainfo
  24400. res2.WarnMsg = ressix10265.WarnMsg
  24401. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24402. res2.Infcode = infocode
  24403. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24404. data := make(map[string]interface{})
  24405. client := &http.Client{}
  24406. data["psn_no"] = his.PsnNo
  24407. data["mdtrt_id"] = his.Number
  24408. data["doctor"] = roles.UserName
  24409. data["department"] = department.Name
  24410. data["org_name"] = miConfig.OrgName
  24411. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24412. data["doctor_id"] = doctor_info.DoctorNumber
  24413. data["new_doctor_name"] = doctor_info.UserName
  24414. data["fixmedins_code"] = miConfig.Code
  24415. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24416. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24417. data["secret_key"] = miConfig.SecretKey
  24418. data["sick_code"] = sickConfig.CountryCode
  24419. data["sick_name"] = sickConfig.ClassName
  24420. data["url"] = miConfig.Url
  24421. data["ak"] = miConfig.AccessKey
  24422. data["begin_time"] = begin_time
  24423. data["cainfo"] = miConfig.Cainfo
  24424. data["dept"] = strconv.FormatInt(department.ID, 10)
  24425. data["config"] = config
  24426. bytesData, _ := json.Marshal(data)
  24427. var req *http.Request
  24428. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  24429. resp, _ := client.Do(req)
  24430. defer resp.Body.Close()
  24431. body, ioErr := ioutil.ReadAll(resp.Body)
  24432. if ioErr != nil {
  24433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24435. return
  24436. }
  24437. var respJSON map[string]interface{}
  24438. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24441. return
  24442. }
  24443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24444. userJSONBytes, _ := json.Marshal(respJSON)
  24445. fmt.Println("log")
  24446. fmt.Println(string(userJSONBytes))
  24447. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  24448. utils.ErrorLog("解析失败:%v", err)
  24449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24450. return
  24451. }
  24452. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24453. res2.Output = ressix10265.Output
  24454. res2.ErrMsg = ressix10265.ErrMsg
  24455. res2.Cainfo = ressix10265.Cainfo
  24456. res2.WarnMsg = ressix10265.WarnMsg
  24457. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24458. res2.Infcode = infocode
  24459. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24460. 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)
  24461. saveLog(result, requestLog, "2203", "上传就诊信息")
  24462. var respJSON2 map[string]interface{}
  24463. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  24464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24466. return
  24467. }
  24468. userJSONBytes2, _ := json.Marshal(respJSON2)
  24469. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  24470. utils.ErrorLog("解析失败:%v", err)
  24471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24472. return
  24473. }
  24474. 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)
  24475. fmt.Println(result2)
  24476. fmt.Println(src_request)
  24477. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24478. data := make(map[string]interface{})
  24479. client := &http.Client{}
  24480. data["psn_no"] = his.PsnNo
  24481. data["mdtrt_id"] = his.Number
  24482. data["doctor"] = roles.UserName
  24483. data["department"] = department.Name
  24484. data["org_name"] = miConfig.OrgName
  24485. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24486. data["doctor_id"] = doctor_info.DoctorNumber
  24487. data["new_doctor_name"] = doctor_info.UserName
  24488. data["fixmedins_code"] = miConfig.Code
  24489. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24490. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24491. data["secret_key"] = miConfig.SecretKey
  24492. data["sick_code"] = sickConfig.CountryCode
  24493. data["sick_name"] = sickConfig.ClassName
  24494. data["url"] = miConfig.Url
  24495. data["ak"] = miConfig.AccessKey
  24496. data["begin_time"] = begin_time
  24497. data["cainfo"] = miConfig.Cainfo
  24498. data["dept"] = strconv.FormatInt(department.ID, 10)
  24499. data["config"] = config
  24500. bytesData, _ := json.Marshal(data)
  24501. var req *http.Request
  24502. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  24503. resp, _ := client.Do(req)
  24504. defer resp.Body.Close()
  24505. body, ioErr := ioutil.ReadAll(resp.Body)
  24506. if ioErr != nil {
  24507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24509. return
  24510. }
  24511. var respJSON map[string]interface{}
  24512. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24515. return
  24516. }
  24517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24518. userJSONBytes, _ := json.Marshal(respJSON)
  24519. fmt.Println("log")
  24520. fmt.Println(string(userJSONBytes))
  24521. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24522. utils.ErrorLog("解析失败:%v", err)
  24523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24524. return
  24525. }
  24526. } else {
  24527. if miConfig.MdtrtareaAdmvs == "440781" { //
  24528. 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)
  24529. } else {
  24530. if miConfig.Code == "H15049901371" {
  24531. //赤峰地区国家医保医疗类别
  24532. //职工透析:医疗类别选特殊情况门诊990502
  24533. //居民定额血透门慢: 医疗类别选门诊慢病140104
  24534. var med_type string
  24535. if his.Insutype == "390" {
  24536. if reg_type == 14 {
  24537. med_type = "9933"
  24538. } else if reg_type == 11 {
  24539. med_type = "11"
  24540. }
  24541. } else if his.Insutype == "310" {
  24542. if reg_type == 14 {
  24543. med_type = "990502"
  24544. } else if reg_type == 11 {
  24545. med_type = "11"
  24546. }
  24547. }
  24548. 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)
  24549. } else {
  24550. 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)
  24551. }
  24552. }
  24553. saveLog(result, requestLog, "2203", "上传就诊信息")
  24554. var respJSON2 map[string]interface{}
  24555. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  24556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24558. return
  24559. }
  24560. userJSONBytes2, _ := json.Marshal(respJSON2)
  24561. if miConfig.Code == "H15049901371" {
  24562. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  24563. utils.ErrorLog("解析失败:%v", err)
  24564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24565. return
  24566. }
  24567. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24568. res2.Output = ressix10265.Output
  24569. res2.ErrMsg = ressix10265.ErrMsg
  24570. res2.Cainfo = ressix10265.Cainfo
  24571. res2.WarnMsg = ressix10265.WarnMsg
  24572. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24573. res2.Infcode = infocode
  24574. } else {
  24575. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24576. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  24577. utils.ErrorLog("解析失败:%v", err)
  24578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24579. return
  24580. }
  24581. res2.Infcode = res3.Infcode
  24582. } else {
  24583. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  24584. utils.ErrorLog("解析失败:%v", err)
  24585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24586. return
  24587. }
  24588. }
  24589. }
  24590. }
  24591. if res2.Infcode == -1 {
  24592. adminUser := c.GetAdminUserInfo()
  24593. errlog := &models.HisOrderError{
  24594. UserOrgId: adminUser.CurrentOrgId,
  24595. Ctime: time.Now().Unix(),
  24596. Mtime: time.Now().Unix(),
  24597. ErrMsg: res2.ErrMsg,
  24598. Status: 1,
  24599. PatientId: id,
  24600. RecordTime: recordDateTime,
  24601. Stage: 3,
  24602. }
  24603. service.CreateErrMsgLog(errlog)
  24604. c.ServeSuccessJSON(map[string]interface{}{
  24605. "failed_code": -10,
  24606. "msg": res2.ErrMsg,
  24607. })
  24608. return
  24609. } else {
  24610. his.Diagnosis = diagnosis_id
  24611. his.SickType = sickConfig.ID
  24612. //var p_type int64
  24613. //if reg_type == 1111 || reg_type == 1112 {
  24614. // p_type = 11
  24615. //
  24616. //}
  24617. his.PType = fmt.Sprintf("%d", reg_type)
  24618. service.UpdateHisPatientThree(&his)
  24619. data := make(map[string]interface{})
  24620. if settle_accounts_type == 1 { //日结
  24621. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  24622. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  24623. } else {
  24624. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  24625. }
  24626. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  24627. data["pre"] = prescriptions
  24628. } else { //月结
  24629. start_time_str := c.GetString("start_time")
  24630. end_time_str := c.GetString("end_time")
  24631. timeLayout := "2006-01-02"
  24632. loc, _ := time.LoadLocation("Local")
  24633. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  24634. if err != nil {
  24635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24636. return
  24637. }
  24638. recordStartTime := theStartTime.Unix()
  24639. start_time = recordStartTime
  24640. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  24641. if err != nil {
  24642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24643. return
  24644. }
  24645. recordEndTime := theEndTime.Unix()
  24646. end_time = recordEndTime
  24647. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  24648. data["pre"] = prescriptions
  24649. }
  24650. timestamp := time.Now().Unix()
  24651. tempTime := time.Unix(timestamp, 0)
  24652. timeFormat := tempTime.Format("20060102150405")
  24653. chrgBchno := rand.Intn(100000) + 10000
  24654. new_chrg_bchno := ""
  24655. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  24656. new_chrg_bchno = chrg_bchno
  24657. strconv.FormatInt(his.PatientId, 10)
  24658. client := &http.Client{}
  24659. if adminUser.CurrentOrgId == 10265 {
  24660. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  24661. new_chrg_bchno = "0000"
  24662. }
  24663. }
  24664. data["psn_no"] = his.PsnNo
  24665. data["mdtrt_id"] = his.Number
  24666. data["chrg_bchno"] = new_chrg_bchno
  24667. data["org_name"] = miConfig.OrgName
  24668. data["doctor"] = doctor_info.UserName
  24669. data["doctor_id"] = doctor_info.DoctorNumber
  24670. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  24671. data["fixmedins_code"] = miConfig.Code
  24672. data["dept_code"] = department.Number
  24673. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24674. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24675. data["secret_key"] = miConfig.SecretKey
  24676. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  24677. data["url"] = miConfig.Url
  24678. data["ak"] = miConfig.AccessKey
  24679. data["new_doctor_name"] = patientPrescription.Doctor
  24680. data["diag_code"] = sickConfig.CountryCode
  24681. data["cainfo"] = miConfig.Cainfo
  24682. data["opter"] = roles.UserName
  24683. var ids []int64
  24684. for _, item := range prescriptions {
  24685. ids = append(ids, item.ID)
  24686. }
  24687. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24688. if config.IsOpen == 1 { //对接了医保,走医保流程
  24689. var res ResultFour
  24690. var resFour10265 ResultFour10265
  24691. if miConfig.MdtrtareaAdmvs == "421300" {
  24692. bytesData, _ := json.Marshal(data)
  24693. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  24694. resp, _ := client.Do(req)
  24695. defer resp.Body.Close()
  24696. body, ioErr := ioutil.ReadAll(resp.Body)
  24697. if ioErr != nil {
  24698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24700. return
  24701. }
  24702. var respJSON map[string]interface{}
  24703. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24706. return
  24707. }
  24708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24709. userJSONBytes, _ := json.Marshal(respJSON)
  24710. fmt.Println("log")
  24711. fmt.Println(string(userJSONBytes))
  24712. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24713. utils.ErrorLog("解析失败:%v", err)
  24714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24715. return
  24716. }
  24717. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24718. bytesData, _ := json.Marshal(data)
  24719. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  24720. resp, _ := client.Do(req)
  24721. defer resp.Body.Close()
  24722. body, ioErr := ioutil.ReadAll(resp.Body)
  24723. if ioErr != nil {
  24724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24726. return
  24727. }
  24728. var respJSON map[string]interface{}
  24729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24732. return
  24733. }
  24734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24735. userJSONBytes, _ := json.Marshal(respJSON)
  24736. fmt.Println("log")
  24737. fmt.Println(string(userJSONBytes))
  24738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24739. utils.ErrorLog("解析失败:%v", err)
  24740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24741. return
  24742. }
  24743. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24744. bytesData, _ := json.Marshal(data)
  24745. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  24746. resp, _ := client.Do(req)
  24747. defer resp.Body.Close()
  24748. body, ioErr := ioutil.ReadAll(resp.Body)
  24749. if ioErr != nil {
  24750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24752. return
  24753. }
  24754. var respJSON map[string]interface{}
  24755. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24758. return
  24759. }
  24760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24761. userJSONBytes, _ := json.Marshal(respJSON)
  24762. fmt.Println("log")
  24763. fmt.Println(string(userJSONBytes))
  24764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24765. utils.ErrorLog("解析失败:%v", err)
  24766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24767. return
  24768. }
  24769. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24770. bytesData, _ := json.Marshal(data)
  24771. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  24772. resp, _ := client.Do(req)
  24773. defer resp.Body.Close()
  24774. body, ioErr := ioutil.ReadAll(resp.Body)
  24775. if ioErr != nil {
  24776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24778. return
  24779. }
  24780. var respJSON map[string]interface{}
  24781. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24784. return
  24785. }
  24786. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24787. userJSONBytes, _ := json.Marshal(respJSON)
  24788. fmt.Println("log")
  24789. fmt.Println(string(userJSONBytes))
  24790. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24791. utils.ErrorLog("解析失败:%v", err)
  24792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24793. return
  24794. }
  24795. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24796. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  24797. if result3101.Infcode == "0" {
  24798. if len(result3101.Output.Result) > 0 {
  24799. var errMsgs []string
  24800. for _, item := range result3101.Output.Result {
  24801. errMsgs = append(errMsgs, item.VolaCont)
  24802. }
  24803. c.ServeSuccessJSON(map[string]interface{}{
  24804. "failed_code": -10,
  24805. "msg": errMsgs,
  24806. })
  24807. return
  24808. }
  24809. }
  24810. bytesData, _ := json.Marshal(data)
  24811. var req *http.Request
  24812. if miConfig.MdtrtareaAdmvs == "320921" {
  24813. data["diag_code"] = sickConfig.CountryCode
  24814. fmt.Println(data)
  24815. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24816. } else {
  24817. data["diag_code"] = sickConfig.CountryCode
  24818. fmt.Println(data)
  24819. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24820. }
  24821. resp, _ := client.Do(req)
  24822. defer resp.Body.Close()
  24823. body, ioErr := ioutil.ReadAll(resp.Body)
  24824. if ioErr != nil {
  24825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24827. return
  24828. }
  24829. var respJSON map[string]interface{}
  24830. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24833. return
  24834. }
  24835. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24836. userJSONBytes, _ := json.Marshal(respJSON)
  24837. fmt.Println("log")
  24838. fmt.Println(string(userJSONBytes))
  24839. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  24840. utils.ErrorLog("解析失败:%v", err)
  24841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24842. return
  24843. }
  24844. res.InfRefmsgid = resFour10265.InfRefmsgid
  24845. res.Output = resFour10265.Output
  24846. res.ErrMsg = resFour10265.ErrMsg
  24847. res.Cainfo = resFour10265.Cainfo
  24848. res.WarnMsg = resFour10265.WarnMsg
  24849. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  24850. res.Infcode = infocode
  24851. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24852. var pagesize int = 2
  24853. var start int = 1
  24854. var stop int
  24855. var pagecount int
  24856. var curpage int
  24857. var isSuccess bool = true
  24858. data["doctor_id"] = doctor_info.DoctorNumber
  24859. //总页数,向上取整,注意除之前要先转换类型为float64
  24860. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  24861. for curpage = 1; curpage <= pagecount; curpage++ {
  24862. if curpage == 1 {
  24863. start = 1
  24864. } else {
  24865. start = (curpage-1)*pagesize + 1
  24866. }
  24867. stop = curpage * pagesize
  24868. if stop > len(prescriptions) {
  24869. stop = len(prescriptions)
  24870. }
  24871. //var requestLog string
  24872. data["pre"] = prescriptions[start-1 : stop]
  24873. fmt.Println(data["pre"])
  24874. bytesData, _ := json.Marshal(data)
  24875. var req *http.Request
  24876. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  24877. resp, _ := client.Do(req)
  24878. defer resp.Body.Close()
  24879. body, ioErr := ioutil.ReadAll(resp.Body)
  24880. if ioErr != nil {
  24881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24883. return
  24884. }
  24885. var respJSON map[string]interface{}
  24886. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24889. return
  24890. }
  24891. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24892. userJSONBytes, _ := json.Marshal(respJSON)
  24893. fmt.Println("log")
  24894. fmt.Println(string(userJSONBytes))
  24895. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  24896. utils.ErrorLog("解析失败:%v", err)
  24897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24898. return
  24899. }
  24900. res.InfRefmsgid = resFour10265.InfRefmsgid
  24901. res.Output = resFour10265.Output
  24902. res.ErrMsg = resFour10265.ErrMsg
  24903. res.Cainfo = resFour10265.Cainfo
  24904. res.WarnMsg = resFour10265.WarnMsg
  24905. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  24906. res.Infcode = infocode
  24907. if infocode == 0 {
  24908. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  24909. } else {
  24910. isSuccess = false
  24911. errlog := &models.HisOrderError{
  24912. UserOrgId: adminUser.CurrentOrgId,
  24913. Ctime: time.Now().Unix(),
  24914. Mtime: time.Now().Unix(),
  24915. Number: chrg_bchno,
  24916. ErrMsg: "",
  24917. Status: 1,
  24918. PatientId: id,
  24919. RecordTime: recordDateTime,
  24920. Stage: 4,
  24921. }
  24922. service.CreateErrMsgLog(errlog)
  24923. c.ServeSuccessJSON(map[string]interface{}{
  24924. "failed_code": -10,
  24925. "msg": res.ErrMsg,
  24926. })
  24927. return
  24928. }
  24929. }
  24930. if isSuccess {
  24931. res.Infcode = 0
  24932. }
  24933. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24934. 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)
  24935. var dat map[string]interface{}
  24936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24937. fmt.Println(dat)
  24938. } else {
  24939. fmt.Println(err)
  24940. }
  24941. saveLog(result, request_log, "2204", "上传费用明细")
  24942. userJSONBytes, _ := json.Marshal(dat)
  24943. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  24944. utils.ErrorLog("解析失败:%v", err)
  24945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24946. return
  24947. }
  24948. res.InfRefmsgid = resFour10265.InfRefmsgid
  24949. res.Output = resFour10265.Output
  24950. res.ErrMsg = resFour10265.ErrMsg
  24951. res.Cainfo = resFour10265.Cainfo
  24952. res.WarnMsg = resFour10265.WarnMsg
  24953. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  24954. res.Infcode = infocode
  24955. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24956. bytesData, _ := json.Marshal(data)
  24957. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  24958. resp, _ := client.Do(req)
  24959. defer resp.Body.Close()
  24960. body, ioErr := ioutil.ReadAll(resp.Body)
  24961. if ioErr != nil {
  24962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24964. return
  24965. }
  24966. var respJSON map[string]interface{}
  24967. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24970. return
  24971. }
  24972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24973. userJSONBytes, _ := json.Marshal(respJSON)
  24974. fmt.Println("log")
  24975. fmt.Println(string(userJSONBytes))
  24976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24977. utils.ErrorLog("解析失败:%v", err)
  24978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24979. return
  24980. }
  24981. } else {
  24982. if miConfig.Code == "H15049901371" {
  24983. 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)
  24984. var dat map[string]interface{}
  24985. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24986. fmt.Println(dat)
  24987. } else {
  24988. fmt.Println(err)
  24989. }
  24990. saveLog(result, request_log, "2204", "上传费用明细")
  24991. userJSONBytes, _ := json.Marshal(dat)
  24992. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  24993. utils.ErrorLog("解析失败:%v", err)
  24994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24995. return
  24996. }
  24997. res.InfRefmsgid = resFour10265.InfRefmsgid
  24998. res.Output = resFour10265.Output
  24999. res.ErrMsg = resFour10265.ErrMsg
  25000. res.Cainfo = resFour10265.Cainfo
  25001. res.WarnMsg = resFour10265.WarnMsg
  25002. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25003. res.Infcode = infocode
  25004. } else {
  25005. 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)
  25006. var dat map[string]interface{}
  25007. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25008. fmt.Println(dat)
  25009. } else {
  25010. fmt.Println(err)
  25011. }
  25012. saveLog(result, request_log, "2204", "上传费用明细")
  25013. userJSONBytes, _ := json.Marshal(dat)
  25014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25015. utils.ErrorLog("解析失败:%v", err)
  25016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25017. return
  25018. }
  25019. }
  25020. }
  25021. if res.Infcode == 0 {
  25022. order := &models.HisOrder{
  25023. UserOrgId: adminUser.CurrentOrgId,
  25024. HisPatientId: his.ID,
  25025. PatientId: his.PatientId,
  25026. SettleAccountsDate: recordDateTime,
  25027. MdtrtId: his.Number,
  25028. PsnNo: his.PsnNo,
  25029. MedType: strconv.FormatInt(reg_type, 10),
  25030. Ctime: time.Now().Unix(),
  25031. Mtime: time.Now().Unix(),
  25032. Status: 1,
  25033. Number: chrg_bchno,
  25034. Infcode: res.Infcode,
  25035. WarnMsg: res.WarnMsg,
  25036. Cainfo: res.Cainfo,
  25037. ErrMsg: res.ErrMsg,
  25038. RespondTime: res.RefmsgTime,
  25039. InfRefmsgid: res.InfRefmsgid,
  25040. OrderStatus: 1,
  25041. PayWay: pay_way,
  25042. PayWays: pay_ways,
  25043. OthDesc: oth_desc,
  25044. PayPrice: pay_price,
  25045. PayCardNo: pay_card_no,
  25046. DiscountPrice: discount_price,
  25047. PreferentialPrice: preferential_price,
  25048. RealityPrice: reality_price,
  25049. FoundPrice: found_price,
  25050. MedicalInsurancePrice: medical_insurance_price,
  25051. PrivatePrice: private_price,
  25052. IsMedicineInsurance: 1,
  25053. SettleType: settle_accounts_type,
  25054. SettleStartTime: start_time,
  25055. SettleEndTime: end_time,
  25056. Creator: roles.AdminUserId,
  25057. Modify: roles.AdminUserId,
  25058. FaPiaoNumber: fapiao_number,
  25059. FaPiaoCode: fapiao_code,
  25060. PType: 2,
  25061. Diagnosis: diagnosis_id,
  25062. CashPay: cash_pay,
  25063. WechatPay: wechat_pay,
  25064. AliPay: ali_pay,
  25065. JifenPay: jifen_pay,
  25066. BandCardPay: band_card_pay,
  25067. }
  25068. err = service.CreateOrder(order)
  25069. if err != nil {
  25070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25071. return
  25072. }
  25073. for _, item := range res.Output.Result {
  25074. temp := strings.Split(item.FeedetlSn, "-")
  25075. var advice_id int64 = 0
  25076. var project_id int64 = 0
  25077. var types int64 = 0
  25078. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25079. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25080. if temp[1] == "1" {
  25081. advice_id = id
  25082. project_id = 0
  25083. } else if temp[1] == "2" {
  25084. advice_id = 0
  25085. project_id = id
  25086. }
  25087. if item.MedChrgitmType == "9" {
  25088. item.MedChrgitmType = "09"
  25089. }
  25090. info := &models.HisOrderInfo{
  25091. OrderNumber: order.Number,
  25092. FeedetlSn: item.FeedetlSn,
  25093. UploadDate: time.Now().Unix(),
  25094. AdviceId: advice_id,
  25095. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25096. Cnt: item.Cnt,
  25097. Pric: float64(item.Pric),
  25098. PatientId: his.PatientId,
  25099. PricUplmtAmt: item.PricUplmtAmt,
  25100. SelfpayProp: item.SelfpayProp,
  25101. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25102. OverlmtAmt: item.OverlmtAmt,
  25103. PreselfpayAmt: item.PreselfpayAmt,
  25104. BasMednFlag: item.BasMednFlag,
  25105. MedChrgitmType: item.MedChrgitmType,
  25106. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25107. Status: 1,
  25108. Memo: item.Memo,
  25109. Mtime: time.Now().Unix(),
  25110. InscpScpAmt: item.InscpScpAmt,
  25111. DrtReimFlag: item.DrtReimFlag,
  25112. Ctime: time.Now().Unix(),
  25113. ListSpItemFlag: item.ListSpItemFlag,
  25114. ChldMedcFlag: item.ChldMedcFlag,
  25115. LmtUsedFlag: item.LmtUsedFlag,
  25116. ChrgitmLv: item.ChrgitmLv,
  25117. UserOrgId: adminUser.CurrentOrgId,
  25118. HisPatientId: his.ID,
  25119. OrderId: order.ID,
  25120. ProjectId: project_id,
  25121. Type: types,
  25122. }
  25123. service.CreateOrderInfo(info)
  25124. }
  25125. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25126. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25127. var total float64
  25128. for _, item := range prescriptions {
  25129. if item.Type == 1 { //药品
  25130. for _, subItem := range item.HisDoctorAdviceInfo {
  25131. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25132. total_one := price * subItem.PrescribingNumber
  25133. total = total + total_one
  25134. }
  25135. }
  25136. if item.Type == 2 { //项目
  25137. for _, subItem := range item.HisPrescriptionProject {
  25138. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25139. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25140. total_one := price * cnt
  25141. total = total + total_one
  25142. }
  25143. }
  25144. }
  25145. allTotal := fmt.Sprintf("%.2f", total)
  25146. //if adminUser.CurrentOrgId == 9919 {
  25147. //
  25148. // allTotal = fmt.Sprintf("%.2f", total)
  25149. //
  25150. //} else {
  25151. //
  25152. // allTotal = fmt.Sprintf("%.2f", total)
  25153. //
  25154. //}
  25155. if res.Infcode == 0 {
  25156. var rf []*ResultFive
  25157. json.Unmarshal([]byte(his.Iinfo), &rf)
  25158. chrg_bchno := chrg_bchno
  25159. cert_no := his.Certno
  25160. var insutypes []string
  25161. var insutype string
  25162. var is390 int = 0
  25163. var is310 int = 0
  25164. for _, item := range rf {
  25165. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25166. insutypes = append(insutypes, item.Insutype)
  25167. }
  25168. }
  25169. if len(insutypes) == 1 {
  25170. insutype = insutypes[0]
  25171. } else {
  25172. for _, i := range insutypes {
  25173. if i == "390" {
  25174. is390 = 1
  25175. }
  25176. if i == "310" {
  25177. is310 = 1
  25178. }
  25179. }
  25180. }
  25181. if is390 == 1 {
  25182. insutype = "390"
  25183. }
  25184. if is310 == 1 {
  25185. insutype = "310"
  25186. }
  25187. if len(insutypes) == 0 {
  25188. insutype = "310"
  25189. }
  25190. if len(insutypes) == 2 {
  25191. insutype = strconv.FormatInt(his.SocialType, 10)
  25192. }
  25193. insutype = strconv.FormatInt(his.SocialType, 10)
  25194. //insutype = "390"
  25195. if his.IdCardType == 1 {
  25196. // cert_no = his.MedicalInsuranceNumber
  25197. cert_no = his.Certno
  25198. } else {
  25199. cert_no = his.Certno
  25200. }
  25201. var res ResultSeven
  25202. var resSeven10265 ResultSeven10265
  25203. var gzresSeven10265Two GZResultSeven10265Two
  25204. var src_resquest string
  25205. var result2 string
  25206. if miConfig.MdtrtareaAdmvs == "421300" {
  25207. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25208. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25209. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25210. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25211. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25212. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25213. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25214. resp, requestErr := http.Get(api)
  25215. if requestErr != nil {
  25216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25217. return
  25218. }
  25219. body, ioErr := ioutil.ReadAll(resp.Body)
  25220. if ioErr != nil {
  25221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25223. return
  25224. }
  25225. var respJSON map[string]interface{}
  25226. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25229. return
  25230. }
  25231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25232. result, _ := json.Marshal(respJSON)
  25233. if miConfig.Code == "H15049901371" {
  25234. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25235. utils.ErrorLog("解析失败:%v", err)
  25236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25237. return
  25238. }
  25239. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25240. res.Output = resSeven10265.Output
  25241. res.ErrMsg = resSeven10265.ErrMsg
  25242. res.Cainfo = resSeven10265.Cainfo
  25243. res.WarnMsg = resSeven10265.WarnMsg
  25244. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25245. res.Infcode = infocode
  25246. } else {
  25247. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25248. utils.ErrorLog("解析失败:%v", err)
  25249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25250. return
  25251. }
  25252. }
  25253. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25254. if reg_type == 11 && his.Insutype == "390" {
  25255. reg_type = 110104
  25256. }
  25257. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25258. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25259. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25260. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25261. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25262. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25263. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  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. if miConfig.Code == "H15049901371" {
  25284. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25285. utils.ErrorLog("解析失败:%v", err)
  25286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25287. return
  25288. }
  25289. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25290. res.Output = resSeven10265.Output
  25291. res.ErrMsg = resSeven10265.ErrMsg
  25292. res.Cainfo = resSeven10265.Cainfo
  25293. res.WarnMsg = resSeven10265.WarnMsg
  25294. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25295. res.Infcode = infocode
  25296. } else {
  25297. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25298. utils.ErrorLog("解析失败:%v", err)
  25299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25300. return
  25301. }
  25302. }
  25303. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25304. if reg_type == 11 && his.Insutype == "390" {
  25305. reg_type = 110104
  25306. }
  25307. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25308. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25309. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25310. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25311. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25312. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25313. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25314. resp, requestErr := http.Get(api)
  25315. if requestErr != nil {
  25316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25317. return
  25318. }
  25319. body, ioErr := ioutil.ReadAll(resp.Body)
  25320. if ioErr != nil {
  25321. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25323. return
  25324. }
  25325. var respJSON map[string]interface{}
  25326. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25329. return
  25330. }
  25331. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25332. result, _ := json.Marshal(respJSON)
  25333. if miConfig.Code == "H15049901371" {
  25334. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25335. utils.ErrorLog("解析失败:%v", err)
  25336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25337. return
  25338. }
  25339. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25340. res.Output = resSeven10265.Output
  25341. res.ErrMsg = resSeven10265.ErrMsg
  25342. res.Cainfo = resSeven10265.Cainfo
  25343. res.WarnMsg = resSeven10265.WarnMsg
  25344. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25345. res.Infcode = infocode
  25346. } else {
  25347. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25348. utils.ErrorLog("解析失败:%v", err)
  25349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25350. return
  25351. }
  25352. }
  25353. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25354. if reg_type == 11 && his.Insutype == "390" {
  25355. reg_type = 110104
  25356. }
  25357. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25358. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25359. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25360. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25361. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25362. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25363. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25364. resp, requestErr := http.Get(api)
  25365. if requestErr != nil {
  25366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25367. return
  25368. }
  25369. body, ioErr := ioutil.ReadAll(resp.Body)
  25370. if ioErr != nil {
  25371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25373. return
  25374. }
  25375. var respJSON map[string]interface{}
  25376. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25379. return
  25380. }
  25381. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25382. result, _ := json.Marshal(respJSON)
  25383. if miConfig.Code == "H15049901371" {
  25384. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25385. utils.ErrorLog("解析失败:%v", err)
  25386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25387. return
  25388. }
  25389. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25390. res.Output = resSeven10265.Output
  25391. res.ErrMsg = resSeven10265.ErrMsg
  25392. res.Cainfo = resSeven10265.Cainfo
  25393. res.WarnMsg = resSeven10265.WarnMsg
  25394. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25395. res.Infcode = infocode
  25396. } else {
  25397. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25398. utils.ErrorLog("解析失败:%v", err)
  25399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25400. return
  25401. }
  25402. }
  25403. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25404. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  25405. if result3101.Infcode == "0" {
  25406. if len(result3101.Output.Result) > 0 {
  25407. var errMsgs []string
  25408. for _, item := range result3101.Output.Result {
  25409. errMsgs = append(errMsgs, item.VolaCont)
  25410. }
  25411. c.ServeSuccessJSON(map[string]interface{}{
  25412. "failed_code": -10,
  25413. "msg": errMsgs,
  25414. })
  25415. return
  25416. } else {
  25417. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25418. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25419. bas := strings.Split(psn_info.CardInfo, "|")
  25420. if his.IdCardType == 1 {
  25421. cert_no = bas[2]
  25422. } else if his.IdCardType == 3 {
  25423. cert_no = his.Certno
  25424. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25425. } else if his.IdCardType == 4 {
  25426. cert_no = his.Certno
  25427. psn_info.VerifyNumber = psn_info.VerifyNumber
  25428. }
  25429. var api string
  25430. if miConfig.MdtrtareaAdmvs == "320921" {
  25431. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25432. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25433. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25434. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25435. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25436. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25437. "&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
  25438. } else {
  25439. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25440. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25441. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25442. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25443. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25444. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25445. "&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
  25446. }
  25447. resp, requestErr := http.Get(api)
  25448. if requestErr != nil {
  25449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25450. return
  25451. }
  25452. body, ioErr := ioutil.ReadAll(resp.Body)
  25453. if ioErr != nil {
  25454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25456. return
  25457. }
  25458. var respJSON map[string]interface{}
  25459. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25462. return
  25463. }
  25464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25465. result, _ := json.Marshal(respJSON)
  25466. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25467. utils.ErrorLog("解析失败:%v", err)
  25468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25469. return
  25470. }
  25471. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25472. res.Output = resSeven10265.Output
  25473. res.ErrMsg = resSeven10265.ErrMsg
  25474. res.Cainfo = resSeven10265.Cainfo
  25475. res.WarnMsg = resSeven10265.WarnMsg
  25476. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25477. res.Infcode = infocode
  25478. }
  25479. }
  25480. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25481. psn_info, _ := service.GetPsnByPatientId(id)
  25482. var verify_number string
  25483. if psn_info.IdCardType == 4 {
  25484. verify_number = psn_info.VerifyNumber
  25485. } else if psn_info.IdCardType == 1 {
  25486. bas := strings.Split(psn_info.CardInfo, "|")
  25487. cardNumber := bas[2]
  25488. verify_number = cardNumber
  25489. } else {
  25490. psn_info.IdCardType = 2
  25491. verify_number = psn_info.Certno
  25492. }
  25493. var api string
  25494. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25495. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25496. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25497. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25498. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25499. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25500. "&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
  25501. resp, requestErr := http.Get(api)
  25502. if requestErr != nil {
  25503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25504. return
  25505. }
  25506. body, ioErr := ioutil.ReadAll(resp.Body)
  25507. if ioErr != nil {
  25508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25510. return
  25511. }
  25512. var respJSON map[string]interface{}
  25513. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25516. return
  25517. }
  25518. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25519. result, _ := json.Marshal(respJSON)
  25520. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25521. utils.ErrorLog("解析失败:%v", err)
  25522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25523. return
  25524. }
  25525. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25526. res.Output = resSeven10265.Output
  25527. res.ErrMsg = resSeven10265.ErrMsg
  25528. res.Cainfo = resSeven10265.Cainfo
  25529. res.WarnMsg = resSeven10265.WarnMsg
  25530. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25531. res.Infcode = infocode
  25532. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25533. var cert_no string
  25534. if his.IdCardType == 4 {
  25535. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25536. cert_no = psn_info.VerifyNumber
  25537. 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)
  25538. } else if his.IdCardType == 1 {
  25539. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25540. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25541. 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)
  25542. }
  25543. //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)
  25544. var dat map[string]interface{}
  25545. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25546. fmt.Println(dat)
  25547. } else {
  25548. fmt.Println(err)
  25549. }
  25550. saveLog(result2, src_resquest, "2207", "结算")
  25551. userJSONBytes, _ := json.Marshal(dat)
  25552. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  25553. utils.ErrorLog("解析失败:%v", err)
  25554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25555. return
  25556. }
  25557. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25558. res.Output = resSeven10265.Output
  25559. res.ErrMsg = resSeven10265.ErrMsg
  25560. res.Cainfo = resSeven10265.Cainfo
  25561. res.WarnMsg = resSeven10265.WarnMsg
  25562. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25563. res.Infcode = infocode
  25564. } else if miConfig.MdtrtareaAdmvs == "450721" {
  25565. res2 := c.GetoleInfo()
  25566. if res2.Infcode == 0 {
  25567. var result string
  25568. var request_log string
  25569. var result_log string
  25570. if res2.Output.MdtrtCertType == "02" {
  25571. 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)
  25572. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25573. } else if res2.Output.MdtrtCertType == "01" {
  25574. 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)
  25575. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25576. } else {
  25577. 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)
  25578. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25579. }
  25580. var dat map[string]interface{}
  25581. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25582. fmt.Println(dat)
  25583. } else {
  25584. fmt.Println(err)
  25585. }
  25586. userJSONBytes, _ := json.Marshal(dat)
  25587. var res5 ResultTwo
  25588. //var resTwo10265 ResultTwo10265
  25589. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  25590. utils.ErrorLog("解析失败:%v", err)
  25591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25592. return
  25593. }
  25594. if res5.Infcode == -1 {
  25595. c.ServeSuccessJSON(map[string]interface{}{
  25596. "failed_code": -10,
  25597. "msg": res5.ErrMsg,
  25598. })
  25599. return
  25600. }
  25601. var insutypes []string
  25602. var insutype string
  25603. var is390 int = 0
  25604. var is310 int = 0
  25605. for _, item := range res5.Output.Iinfo {
  25606. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25607. insutypes = append(insutypes, item.Insutype)
  25608. }
  25609. }
  25610. if len(insutypes) == 1 {
  25611. insutype = insutypes[0]
  25612. } else {
  25613. for _, i := range insutypes {
  25614. if i == "390" {
  25615. is390 = 1
  25616. }
  25617. if i == "310" {
  25618. is310 = 1
  25619. }
  25620. }
  25621. }
  25622. if is390 == 1 {
  25623. insutype = "390"
  25624. }
  25625. if is310 == 1 {
  25626. insutype = "310"
  25627. }
  25628. if len(insutypes) == 0 {
  25629. insutype = "310"
  25630. }
  25631. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  25632. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  25633. infoStr := string(Iinfos)
  25634. idetinfoStr := string(Idetinfos)
  25635. psn := &models.HisPsn{
  25636. PsnNo: res5.Output.Baseinfo.PsnNo,
  25637. PatientId: id,
  25638. Certno: res5.Output.Baseinfo.Certno,
  25639. Gend: res5.Output.Baseinfo.Gend,
  25640. Naty: res5.Output.Baseinfo.Naty,
  25641. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  25642. PsnName: res5.Output.Baseinfo.PsnName,
  25643. Idetinfo: idetinfoStr,
  25644. Insuinfo: infoStr,
  25645. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  25646. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  25647. VerifyNumber: res2.Output.EcToken,
  25648. }
  25649. if res2.Output.MdtrtCertType == "01" {
  25650. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25651. psn.VerifyNumber = res2.Output.EcToken
  25652. } else if res2.Output.MdtrtCertType == "02" {
  25653. psn.VerifyNumber = res2.Output.CardNo
  25654. } else {
  25655. psn.VerifyNumber = res2.Output.MdtrtCertNo
  25656. }
  25657. service.CreateHisPsn(psn)
  25658. if res2.Output.MdtrtCertType == "01" {
  25659. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25660. token := res2.Output.EcToken
  25661. 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)
  25662. } else if res2.Output.MdtrtCertType == "02" {
  25663. 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)
  25664. } else {
  25665. 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)
  25666. }
  25667. var dat2 map[string]interface{}
  25668. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  25669. fmt.Println(dat2)
  25670. } else {
  25671. fmt.Println(err)
  25672. }
  25673. userJSONBytes3, _ := json.Marshal(dat2)
  25674. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  25675. utils.ErrorLog("解析失败:%v", err)
  25676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25677. return
  25678. }
  25679. saveLog(result2, src_resquest, "2207", "结算")
  25680. } else {
  25681. c.ServeSuccessJSON(map[string]interface{}{
  25682. "failed_code": -10,
  25683. "msg": res2.ErrMsg,
  25684. })
  25685. return
  25686. }
  25687. } else {
  25688. if miConfig.Code == "H15049901371" {
  25689. //赤峰地区国家医保医疗类别
  25690. //职工透析:医疗类别选特殊情况门诊990502
  25691. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25692. var med_type string
  25693. if his.Insutype == "390" {
  25694. if reg_type == 14 {
  25695. med_type = "9933"
  25696. } else if reg_type == 11 {
  25697. med_type = "11"
  25698. }
  25699. } else if his.Insutype == "310" {
  25700. if reg_type == 14 {
  25701. med_type = "990502"
  25702. } else if reg_type == 11 {
  25703. med_type = "11"
  25704. }
  25705. }
  25706. 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)
  25707. } else {
  25708. if his.IdCardType == 4 {
  25709. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25710. var token string
  25711. token = psn_info.VerifyNumber
  25712. 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)
  25713. } else {
  25714. if his.IdCardType == 1 {
  25715. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25716. bas := strings.Split(psn_info.CardInfo, "|")
  25717. basNumber := bas[2]
  25718. cert_no = basNumber
  25719. }
  25720. 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)
  25721. }
  25722. }
  25723. //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)
  25724. var dat map[string]interface{}
  25725. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25726. fmt.Println(dat)
  25727. } else {
  25728. fmt.Println(err)
  25729. }
  25730. saveLog(result2, src_resquest, "2207", "结算")
  25731. userJSONBytes, _ := json.Marshal(dat)
  25732. if miConfig.Code == "H15049901371" {
  25733. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  25734. utils.ErrorLog("解析失败:%v", err)
  25735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25736. return
  25737. }
  25738. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25739. res.Output = resSeven10265.Output
  25740. res.ErrMsg = resSeven10265.ErrMsg
  25741. res.Cainfo = resSeven10265.Cainfo
  25742. res.WarnMsg = resSeven10265.WarnMsg
  25743. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25744. res.Infcode = infocode
  25745. } else {
  25746. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25747. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  25748. utils.ErrorLog("解析失败:%v", err)
  25749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25750. return
  25751. }
  25752. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  25753. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  25754. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  25755. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25756. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  25757. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  25758. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  25759. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25760. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  25761. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25762. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25763. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25764. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25765. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25766. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  25767. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  25768. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  25769. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  25770. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  25771. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  25772. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25773. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  25774. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  25775. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  25776. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  25777. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  25778. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  25779. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  25780. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  25781. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  25782. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  25783. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  25784. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  25785. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  25786. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  25787. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  25788. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  25789. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  25790. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25791. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  25792. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  25793. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  25794. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  25795. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  25796. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  25797. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  25798. res.ErrMsg = gzresSeven10265Two.ErrMsg
  25799. res.Cainfo = gzresSeven10265Two.Cainfo
  25800. res.WarnMsg = gzresSeven10265Two.WarnMsg
  25801. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  25802. //res.Infcode = infocode
  25803. } else {
  25804. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25805. utils.ErrorLog("解析失败:%v", err)
  25806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25807. return
  25808. }
  25809. }
  25810. }
  25811. }
  25812. if res.Infcode == -1 {
  25813. errlog := &models.HisOrderError{
  25814. UserOrgId: adminUser.CurrentOrgId,
  25815. Ctime: time.Now().Unix(),
  25816. Mtime: time.Now().Unix(),
  25817. Number: chrg_bchno,
  25818. ErrMsg: res.ErrMsg,
  25819. Status: 1,
  25820. PatientId: id,
  25821. RecordTime: recordDateTime,
  25822. Stage: 6,
  25823. }
  25824. service.CreateErrMsgLog(errlog)
  25825. c.ServeSuccessJSON(map[string]interface{}{
  25826. "failed_code": -10,
  25827. "msg": res.ErrMsg,
  25828. })
  25829. return
  25830. } else {
  25831. sickConfig, _ := service.FindSickById(his.SickType)
  25832. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  25833. order.OrderStatus = 2
  25834. order.Status = 1
  25835. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  25836. order.SetlId = res.Output.Setlinfo.SetlID
  25837. order.PsnNo = res.Output.Setlinfo.PsnNo
  25838. order.PsnName = res.Output.Setlinfo.PsnName
  25839. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  25840. order.Certno = res.Output.Setlinfo.Certno
  25841. order.Gend = res.Output.Setlinfo.Gend
  25842. order.Naty = res.Output.Setlinfo.Naty
  25843. order.Age = res.Output.Setlinfo.Age
  25844. order.Insutype = res.Output.Setlinfo.Insutype
  25845. order.PsnType = res.Output.Setlinfo.PsnType
  25846. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  25847. order.SetlTime = res.Output.Setlinfo.SetlTime
  25848. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  25849. if res.Output.Setlinfo.MedType == "140101" {
  25850. order.MedType = "14"
  25851. } else {
  25852. if res.Output.Setlinfo.MedType == "110104" {
  25853. order.MedType = "11"
  25854. } else {
  25855. order.MedType = res.Output.Setlinfo.MedType
  25856. }
  25857. }
  25858. if reg_type == 1112 {
  25859. order.MedType = "1112"
  25860. }
  25861. if reg_type == 1111 {
  25862. order.MedType = "1111"
  25863. }
  25864. order.ClrType = res.Output.Setlinfo.ClrType
  25865. if adminUser.CurrentOrgId == 10480 {
  25866. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  25867. order.ClrType = "11"
  25868. } else {
  25869. order.ClrType = "9903"
  25870. }
  25871. }
  25872. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  25873. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  25874. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  25875. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  25876. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  25877. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  25878. order.HifpPay = res.Output.Setlinfo.HifpPay
  25879. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  25880. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  25881. order.HifesPay = res.Output.Setlinfo.HifesPay
  25882. order.HifobPay = res.Output.Setlinfo.HifobPay
  25883. order.MafPay = res.Output.Setlinfo.MafPay
  25884. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  25885. order.OthPay = res.Output.Setlinfo.OthPay
  25886. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  25887. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  25888. order.AcctPay = res.Output.Setlinfo.AcctPay
  25889. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  25890. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  25891. order.Balc = res.Output.Setlinfo.Balc
  25892. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  25893. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  25894. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  25895. //order.ClrType = res.Output.Setlinfo.ClrType
  25896. order.ClrWay = res.Output.Setlinfo.ClrWay
  25897. order.Creator = order.Creator
  25898. order.Modify = roles.AdminUserId
  25899. order.RequestLog = src_resquest
  25900. order.FaPiaoNumber = fapiao_number
  25901. order.FaPiaoCode = fapiao_code
  25902. order.SickName = sickConfig.ClassName
  25903. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  25904. //detailStr := string(setlDetail)
  25905. //order.SetlDetail = detailStr
  25906. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  25907. err = service.UpDateOrder(order)
  25908. if err == nil {
  25909. //判断是否使用了押金
  25910. if dec_way == "true" {
  25911. tmpstring := strconv.FormatInt(order.ID, 10)
  25912. order.Decimal = decimal
  25913. service.UpDateOrder(order)
  25914. //扣押金
  25915. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  25916. if errmsg != nil {
  25917. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  25918. return
  25919. }
  25920. }
  25921. c.ServeSuccessJSON(map[string]interface{}{
  25922. "msg": "结算成功",
  25923. })
  25924. } else {
  25925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  25926. return
  25927. }
  25928. }
  25929. } else {
  25930. adminUser := c.GetAdminUserInfo()
  25931. errlog := &models.HisOrderError{
  25932. UserOrgId: adminUser.CurrentOrgId,
  25933. Ctime: time.Now().Unix(),
  25934. Mtime: time.Now().Unix(),
  25935. ErrMsg: res.ErrMsg,
  25936. Status: 1,
  25937. PatientId: id,
  25938. RecordTime: recordDateTime,
  25939. Stage: 4,
  25940. }
  25941. service.CreateErrMsgLog(errlog)
  25942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  25943. return
  25944. }
  25945. } else {
  25946. adminUser := c.GetAdminUserInfo()
  25947. errlog := &models.HisOrderError{
  25948. UserOrgId: adminUser.CurrentOrgId,
  25949. Ctime: time.Now().Unix(),
  25950. Mtime: time.Now().Unix(),
  25951. ErrMsg: res.ErrMsg,
  25952. Status: 1,
  25953. PatientId: id,
  25954. RecordTime: recordDateTime,
  25955. Stage: 4,
  25956. }
  25957. service.CreateErrMsgLog(errlog)
  25958. c.ServeSuccessJSON(map[string]interface{}{
  25959. "failed_code": -10,
  25960. "msg": res.ErrMsg,
  25961. })
  25962. return
  25963. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  25964. //return
  25965. }
  25966. }
  25967. }
  25968. } else if tempOrder.ID > 0 {
  25969. if tempOrder.IsPre == 1 {
  25970. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  25971. var rf []*ResultFive
  25972. json.Unmarshal([]byte(his.Iinfo), &rf)
  25973. chrg_bchno := tempOrder.Number
  25974. cert_no := his.Certno
  25975. var insutypes []string
  25976. var insutype string
  25977. var is390 int = 0
  25978. var is310 int = 0
  25979. for _, item := range rf {
  25980. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25981. insutypes = append(insutypes, item.Insutype)
  25982. }
  25983. }
  25984. if len(insutypes) == 1 {
  25985. insutype = insutypes[0]
  25986. } else {
  25987. for _, i := range insutypes {
  25988. if i == "390" {
  25989. is390 = 1
  25990. }
  25991. if i == "310" {
  25992. is310 = 1
  25993. }
  25994. }
  25995. }
  25996. if is390 == 1 {
  25997. insutype = "390"
  25998. }
  25999. if is310 == 1 {
  26000. insutype = "310"
  26001. }
  26002. if len(insutypes) == 0 {
  26003. insutype = "310"
  26004. }
  26005. if len(insutypes) == 2 {
  26006. insutype = strconv.FormatInt(his.SocialType, 10)
  26007. }
  26008. //insutype = "390"
  26009. if his.IdCardType == 1 {
  26010. // cert_no = his.MedicalInsuranceNumber
  26011. cert_no = his.Certno
  26012. } else {
  26013. cert_no = his.Certno
  26014. }
  26015. var res ResultSeven
  26016. var ahres ResultSevenAH
  26017. var resSeven10265 ResultSeven10265
  26018. var gzresSeven10265Two GZResultSeven10265Two
  26019. var src_resquest string
  26020. var result2 string
  26021. if miConfig.MdtrtareaAdmvs == "450721" {
  26022. res2 := c.GetoleInfo()
  26023. if res2.Infcode == 0 {
  26024. var result string
  26025. var request_log string
  26026. var result_log string
  26027. if res2.Output.MdtrtCertType == "02" {
  26028. 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)
  26029. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26030. } else if res2.Output.MdtrtCertType == "01" {
  26031. 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)
  26032. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26033. } else {
  26034. 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)
  26035. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26036. }
  26037. var dat map[string]interface{}
  26038. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26039. fmt.Println(dat)
  26040. } else {
  26041. fmt.Println(err)
  26042. }
  26043. userJSONBytes, _ := json.Marshal(dat)
  26044. var res5 ResultTwo
  26045. //var resTwo10265 ResultTwo10265
  26046. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26047. utils.ErrorLog("解析失败:%v", err)
  26048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26049. return
  26050. }
  26051. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26052. if res5.Infcode == -1 {
  26053. c.ServeSuccessJSON(map[string]interface{}{
  26054. "failed_code": -10,
  26055. "msg": res5.ErrMsg,
  26056. })
  26057. return
  26058. }
  26059. var insutypes []string
  26060. var insutype string
  26061. var is390 int = 0
  26062. var is310 int = 0
  26063. for _, item := range res5.Output.Iinfo {
  26064. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26065. insutypes = append(insutypes, item.Insutype)
  26066. }
  26067. }
  26068. if len(insutypes) == 1 {
  26069. insutype = insutypes[0]
  26070. } else {
  26071. for _, i := range insutypes {
  26072. if i == "390" {
  26073. is390 = 1
  26074. }
  26075. if i == "310" {
  26076. is310 = 1
  26077. }
  26078. }
  26079. }
  26080. if is390 == 1 {
  26081. insutype = "390"
  26082. }
  26083. if is310 == 1 {
  26084. insutype = "310"
  26085. }
  26086. if len(insutypes) == 0 {
  26087. insutype = "310"
  26088. }
  26089. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26090. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26091. infoStr := string(Iinfos)
  26092. idetinfoStr := string(Idetinfos)
  26093. psn := &models.HisPsn{
  26094. PsnNo: res5.Output.Baseinfo.PsnNo,
  26095. PatientId: id,
  26096. Certno: res5.Output.Baseinfo.Certno,
  26097. Gend: res5.Output.Baseinfo.Gend,
  26098. Naty: res5.Output.Baseinfo.Naty,
  26099. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26100. PsnName: res5.Output.Baseinfo.PsnName,
  26101. Idetinfo: idetinfoStr,
  26102. Insuinfo: infoStr,
  26103. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26104. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26105. VerifyNumber: res2.Output.EcToken,
  26106. }
  26107. service.CreateHisPsn(psn)
  26108. if res2.Output.MdtrtCertType == "01" {
  26109. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26110. token := res2.Output.EcToken
  26111. 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)
  26112. } else if res2.Output.MdtrtCertType == "02" {
  26113. 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)
  26114. } else {
  26115. 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)
  26116. }
  26117. var dat2 map[string]interface{}
  26118. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26119. fmt.Println(dat2)
  26120. } else {
  26121. fmt.Println(err)
  26122. }
  26123. userJSONBytes3, _ := json.Marshal(dat2)
  26124. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26125. utils.ErrorLog("解析失败:%v", err)
  26126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26127. return
  26128. }
  26129. saveLog(result2, src_resquest, "2207", "结算")
  26130. } else {
  26131. c.ServeSuccessJSON(map[string]interface{}{
  26132. "failed_code": -10,
  26133. "msg": res2.ErrMsg,
  26134. })
  26135. return
  26136. }
  26137. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26138. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26139. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26140. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26141. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26142. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26143. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26144. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26145. resp, requestErr := http.Get(api)
  26146. if requestErr != nil {
  26147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26148. return
  26149. }
  26150. body, ioErr := ioutil.ReadAll(resp.Body)
  26151. if ioErr != nil {
  26152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26154. return
  26155. }
  26156. var respJSON map[string]interface{}
  26157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26160. return
  26161. }
  26162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26163. result, _ := json.Marshal(respJSON)
  26164. fmt.Println("log")
  26165. fmt.Println(string(result))
  26166. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26167. utils.ErrorLog("解析失败:%v", err)
  26168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26169. return
  26170. }
  26171. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26172. if reg_type == 11 && his.Insutype == "390" {
  26173. reg_type = 110104
  26174. }
  26175. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26176. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26177. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26178. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26179. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26180. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26181. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26182. resp, requestErr := http.Get(api)
  26183. if requestErr != nil {
  26184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26185. return
  26186. }
  26187. body, ioErr := ioutil.ReadAll(resp.Body)
  26188. if ioErr != nil {
  26189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26191. return
  26192. }
  26193. var respJSON map[string]interface{}
  26194. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26197. return
  26198. }
  26199. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26200. result, _ := json.Marshal(respJSON)
  26201. fmt.Println("log")
  26202. fmt.Println(string(result))
  26203. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26204. utils.ErrorLog("解析失败:%v", err)
  26205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26206. return
  26207. }
  26208. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26209. if reg_type == 11 && his.Insutype == "390" {
  26210. reg_type = 110104
  26211. }
  26212. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26213. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26214. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26215. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26216. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26217. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26218. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26219. resp, requestErr := http.Get(api)
  26220. if requestErr != nil {
  26221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26222. return
  26223. }
  26224. body, ioErr := ioutil.ReadAll(resp.Body)
  26225. if ioErr != nil {
  26226. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26228. return
  26229. }
  26230. var respJSON map[string]interface{}
  26231. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26234. return
  26235. }
  26236. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26237. result, _ := json.Marshal(respJSON)
  26238. fmt.Println("log")
  26239. fmt.Println(string(result))
  26240. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26241. utils.ErrorLog("解析失败:%v", err)
  26242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26243. return
  26244. }
  26245. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26246. if reg_type == 11 && his.Insutype == "390" {
  26247. reg_type = 110104
  26248. }
  26249. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26250. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26251. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26252. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26253. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26254. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26255. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26256. resp, requestErr := http.Get(api)
  26257. if requestErr != nil {
  26258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26259. return
  26260. }
  26261. body, ioErr := ioutil.ReadAll(resp.Body)
  26262. if ioErr != nil {
  26263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26265. return
  26266. }
  26267. var respJSON map[string]interface{}
  26268. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26271. return
  26272. }
  26273. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26274. result, _ := json.Marshal(respJSON)
  26275. fmt.Println("log")
  26276. fmt.Println(string(result))
  26277. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26278. utils.ErrorLog("解析失败:%v", err)
  26279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26280. return
  26281. }
  26282. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26283. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  26284. if result3101.Infcode == "0" {
  26285. if len(result3101.Output.Result) > 0 {
  26286. var errMsgs []string
  26287. for _, item := range result3101.Output.Result {
  26288. errMsgs = append(errMsgs, item.VolaCont)
  26289. }
  26290. c.ServeSuccessJSON(map[string]interface{}{
  26291. "failed_code": -10,
  26292. "msg": errMsgs,
  26293. })
  26294. return
  26295. } else {
  26296. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26297. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26298. bas := strings.Split(psn_info.CardInfo, "|")
  26299. if his.IdCardType == 1 {
  26300. cert_no = bas[2]
  26301. } else if his.IdCardType == 3 {
  26302. cert_no = his.Certno
  26303. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26304. } else if his.IdCardType == 4 {
  26305. cert_no = his.Certno
  26306. psn_info.VerifyNumber = psn_info.VerifyNumber
  26307. }
  26308. //江苏地区国家医保医疗类别
  26309. //职工透析:医疗类别选特殊情况门诊9933
  26310. //居民血透门慢: 医疗类别选门诊慢病1402
  26311. //var med_type string
  26312. //if his.Insutype == "310" {
  26313. // if reg_type == 14 {
  26314. // med_type = "9933"
  26315. // } else if reg_type == 11 {
  26316. // med_type = "11"
  26317. //
  26318. // }
  26319. //} else if his.Insutype == "390" {
  26320. // if reg_type == 14 {
  26321. // med_type = "1402"
  26322. // } else if reg_type == 11 {
  26323. // med_type = "11"
  26324. // }
  26325. //}
  26326. var api string
  26327. if miConfig.MdtrtareaAdmvs == "320921" {
  26328. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26329. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26330. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26331. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26332. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26333. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26334. "&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
  26335. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26336. } else {
  26337. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26338. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26339. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26340. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26341. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26342. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26343. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26344. "&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
  26345. }
  26346. resp, requestErr := http.Get(api)
  26347. if requestErr != nil {
  26348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26349. return
  26350. }
  26351. body, ioErr := ioutil.ReadAll(resp.Body)
  26352. if ioErr != nil {
  26353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26355. return
  26356. }
  26357. var respJSON map[string]interface{}
  26358. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26361. return
  26362. }
  26363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26364. result, _ := json.Marshal(respJSON)
  26365. fmt.Println("log")
  26366. fmt.Println(string(result))
  26367. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26368. utils.ErrorLog("解析失败:%v", err)
  26369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26370. return
  26371. }
  26372. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26373. res.Output = resSeven10265.Output
  26374. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26375. res.ErrMsg = resSeven10265.ErrMsg
  26376. res.Cainfo = resSeven10265.Cainfo
  26377. res.WarnMsg = resSeven10265.WarnMsg
  26378. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26379. res.Infcode = infocode
  26380. }
  26381. }
  26382. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26383. psn_info, _ := service.GetPsnByPatientId(id)
  26384. var verify_number string
  26385. if psn_info.IdCardType == 4 {
  26386. verify_number = psn_info.VerifyNumber
  26387. } else if psn_info.IdCardType == 1 {
  26388. bas := strings.Split(psn_info.CardInfo, "|")
  26389. cardNumber := bas[2]
  26390. verify_number = cardNumber
  26391. } else {
  26392. verify_number = psn_info.Certno
  26393. psn_info.IdCardType = 2
  26394. }
  26395. var api string
  26396. new_chrg_bchno := chrg_bchno
  26397. if adminUser.CurrentOrgId == 10265 {
  26398. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26399. new_chrg_bchno = "0000"
  26400. }
  26401. }
  26402. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26403. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  26404. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26405. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26406. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  26407. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26408. "&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
  26409. resp, requestErr := http.Get(api)
  26410. if requestErr != nil {
  26411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26412. return
  26413. }
  26414. body, ioErr := ioutil.ReadAll(resp.Body)
  26415. if ioErr != nil {
  26416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26418. return
  26419. }
  26420. var respJSON map[string]interface{}
  26421. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26424. return
  26425. }
  26426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26427. result, _ := json.Marshal(respJSON)
  26428. fmt.Println("log")
  26429. fmt.Println(string(result))
  26430. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26431. utils.ErrorLog("解析失败:%v", err)
  26432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26433. return
  26434. }
  26435. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26436. res.Output = resSeven10265.Output
  26437. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26438. res.ErrMsg = resSeven10265.ErrMsg
  26439. res.Cainfo = resSeven10265.Cainfo
  26440. res.WarnMsg = resSeven10265.WarnMsg
  26441. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26442. res.Infcode = infocode
  26443. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26444. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26445. var cert_no string
  26446. if his.IdCardType == 1 {
  26447. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26448. } else {
  26449. cert_no = psn_info.VerifyNumber
  26450. }
  26451. 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)
  26452. var dat map[string]interface{}
  26453. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26454. fmt.Println(dat)
  26455. } else {
  26456. fmt.Println(err)
  26457. }
  26458. saveLog(result2, src_resquest, "2207", "结算")
  26459. userJSONBytes, _ := json.Marshal(dat)
  26460. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26461. utils.ErrorLog("解析失败:%v", err)
  26462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26463. return
  26464. }
  26465. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26466. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26467. var cert_no string
  26468. var card_sn string
  26469. if his.IdCardType == 1 {
  26470. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26471. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26472. bas := strings.Split(psn_info.CardInfo, "|")
  26473. card_sn = bas[3]
  26474. } else if his.IdCardType == 2 {
  26475. cert_no = his.IdCardNo
  26476. } else {
  26477. cert_no = psn_info.VerifyNumber
  26478. }
  26479. var rf []*ResultFive
  26480. json.Unmarshal([]byte(his.Iinfo), &rf)
  26481. var psn_type string
  26482. for _, item := range rf {
  26483. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  26484. psn_type = item.PsnType
  26485. }
  26486. }
  26487. 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)
  26488. var dat map[string]interface{}
  26489. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26490. fmt.Println(dat)
  26491. } else {
  26492. fmt.Println(err)
  26493. }
  26494. saveLog(result2, src_resquest, "2207", "结算")
  26495. userJSONBytes, _ := json.Marshal(dat)
  26496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26497. utils.ErrorLog("解析失败:%v", err)
  26498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26499. return
  26500. }
  26501. } else if miConfig.MdtrtareaAdmvs == "361025" {
  26502. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26503. var cert_no string
  26504. var card_sn string
  26505. if his.IdCardType == 1 {
  26506. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26507. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26508. //bas := strings.Split(psn_info.CardInfo, "|")
  26509. card_sn = ""
  26510. } else if his.IdCardType == 2 {
  26511. cert_no = his.IdCardNo
  26512. } else {
  26513. cert_no = psn_info.VerifyNumber
  26514. }
  26515. var rf []*ResultFive
  26516. json.Unmarshal([]byte(his.Iinfo), &rf)
  26517. var psn_type string
  26518. for _, item := range rf {
  26519. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  26520. psn_type = item.PsnType
  26521. }
  26522. }
  26523. 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)
  26524. var dat map[string]interface{}
  26525. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26526. fmt.Println(dat)
  26527. } else {
  26528. fmt.Println(err)
  26529. }
  26530. saveLog(result2, src_resquest, "2207", "结算")
  26531. userJSONBytes, _ := json.Marshal(dat)
  26532. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26533. utils.ErrorLog("解析失败:%v", err)
  26534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26535. return
  26536. }
  26537. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26538. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26539. if his.IdCardType == 1 {
  26540. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26541. bas := strings.Split(psn_info.CardInfo, "|")
  26542. cert_no = bas[2]
  26543. } else if his.IdCardType == 3 {
  26544. cert_no = his.Certno
  26545. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26546. } else if his.IdCardType == 4 {
  26547. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26548. cert_no = his.Certno
  26549. psn_info.VerifyNumber = psn_info.VerifyNumber
  26550. } else {
  26551. cert_no = his.Certno
  26552. psn_info.VerifyNumber = his.Certno
  26553. }
  26554. var api string
  26555. var med_type string
  26556. if his.Insutype == "390" {
  26557. if reg_type == 992102 {
  26558. med_type = "992102"
  26559. }
  26560. if reg_type == 140104 {
  26561. med_type = "140104"
  26562. }
  26563. if reg_type == 14 {
  26564. med_type = "14"
  26565. }
  26566. } else if his.Insutype == "310" {
  26567. if reg_type == 992102 {
  26568. med_type = "992102"
  26569. }
  26570. if reg_type == 14 {
  26571. med_type = "14"
  26572. }
  26573. }
  26574. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26575. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26576. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26577. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26578. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26579. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26580. "&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
  26581. resp, requestErr := http.Get(api)
  26582. if requestErr != nil {
  26583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26584. return
  26585. }
  26586. body, ioErr := ioutil.ReadAll(resp.Body)
  26587. if ioErr != nil {
  26588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26590. return
  26591. }
  26592. var respJSON map[string]interface{}
  26593. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26596. return
  26597. }
  26598. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26599. if status == "0" {
  26600. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26601. c.ServeSuccessJSON(map[string]interface{}{
  26602. "failed_code": -10,
  26603. "msg": err_msg,
  26604. })
  26605. return
  26606. }
  26607. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26608. result, _ := json.Marshal(respJSON)
  26609. fmt.Println("log")
  26610. fmt.Println(string(result))
  26611. if err := json.Unmarshal(result, &ahres); err != nil {
  26612. utils.ErrorLog("解析失败:%v", err)
  26613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26614. return
  26615. }
  26616. res.InfRefmsgid = ahres.InfRefmsgid
  26617. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26618. // 创建对应的Time类型
  26619. t := time.UnixMilli(timestamp)
  26620. // 格式化成指定的日期字符串
  26621. str := t.Format("2006-01-02 15:04:05")
  26622. res.Output.Setlinfo.SetlTime = str
  26623. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  26624. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  26625. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26626. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  26627. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  26628. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  26629. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26630. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  26631. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  26632. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26633. res.Output.Setlinfo.ClrType = "11"
  26634. } else {
  26635. res.Output.Setlinfo.ClrType = "9903"
  26636. }
  26637. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  26638. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  26639. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26640. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  26641. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  26642. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  26643. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  26644. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  26645. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  26646. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26647. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  26648. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  26649. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  26650. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  26651. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  26652. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  26653. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  26654. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  26655. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  26656. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  26657. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  26658. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  26659. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  26660. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  26661. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  26662. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  26663. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  26664. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  26665. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  26666. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  26667. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  26668. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  26669. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  26670. res.Output.Setldetail = ahres.Output.Setldetail
  26671. res.ErrMsg = ahres.ErrMsg
  26672. res.Cainfo = ahres.Cainfo
  26673. res.WarnMsg = ahres.WarnMsg
  26674. res.Infcode = ahres.Infcode
  26675. } else if miConfig.MdtrtareaAdmvs == "340699" {
  26676. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26677. if his.IdCardType == 1 {
  26678. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26679. bas := strings.Split(psn_info.CardInfo, "|")
  26680. cert_no = bas[2]
  26681. } else if his.IdCardType == 3 {
  26682. cert_no = his.Certno
  26683. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26684. } else if his.IdCardType == 4 {
  26685. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26686. cert_no = his.Certno
  26687. psn_info.VerifyNumber = psn_info.VerifyNumber
  26688. } else {
  26689. cert_no = his.Certno
  26690. psn_info.VerifyNumber = his.Certno
  26691. }
  26692. var api string
  26693. var med_type string
  26694. if his.Insutype == "390" {
  26695. if reg_type == 992102 {
  26696. med_type = "992102"
  26697. }
  26698. if reg_type == 140104 {
  26699. med_type = "140104"
  26700. }
  26701. if reg_type == 14 {
  26702. med_type = "14"
  26703. }
  26704. if reg_type == 140201 {
  26705. med_type = "140201"
  26706. }
  26707. } else if his.Insutype == "310" {
  26708. if reg_type == 992102 {
  26709. med_type = "992102"
  26710. }
  26711. if reg_type == 14 {
  26712. med_type = "14"
  26713. }
  26714. if reg_type == 140104 {
  26715. med_type = "140104"
  26716. }
  26717. if reg_type == 140201 {
  26718. med_type = "140201"
  26719. }
  26720. }
  26721. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26722. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26723. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26724. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26725. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26726. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26727. "&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
  26728. resp, requestErr := http.Get(api)
  26729. if requestErr != nil {
  26730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26731. return
  26732. }
  26733. body, ioErr := ioutil.ReadAll(resp.Body)
  26734. if ioErr != nil {
  26735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26737. return
  26738. }
  26739. var respJSON map[string]interface{}
  26740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26743. return
  26744. }
  26745. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26746. if status == "0" {
  26747. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26748. c.ServeSuccessJSON(map[string]interface{}{
  26749. "failed_code": -10,
  26750. "msg": err_msg,
  26751. })
  26752. return
  26753. }
  26754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26755. result, _ := json.Marshal(respJSON)
  26756. fmt.Println("log")
  26757. fmt.Println(string(result))
  26758. if err := json.Unmarshal(result, &ahres); err != nil {
  26759. utils.ErrorLog("解析失败:%v", err)
  26760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26761. return
  26762. }
  26763. res.InfRefmsgid = ahres.InfRefmsgid
  26764. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26765. // 创建对应的Time类型
  26766. t := time.UnixMilli(timestamp)
  26767. // 格式化成指定的日期字符串
  26768. str := t.Format("2006-01-02 15:04:05")
  26769. res.Output.Setlinfo.SetlTime = str
  26770. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  26771. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  26772. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26773. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  26774. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  26775. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  26776. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26777. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  26778. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  26779. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26780. res.Output.Setlinfo.ClrType = "11"
  26781. } else {
  26782. res.Output.Setlinfo.ClrType = "9903"
  26783. }
  26784. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  26785. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  26786. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26787. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  26788. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  26789. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  26790. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  26791. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  26792. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  26793. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26794. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  26795. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  26796. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  26797. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  26798. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  26799. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  26800. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  26801. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  26802. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  26803. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  26804. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  26805. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  26806. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  26807. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  26808. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  26809. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  26810. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  26811. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  26812. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  26813. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  26814. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  26815. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  26816. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  26817. res.Output.Setldetail = ahres.Output.Setldetail
  26818. res.ErrMsg = ahres.ErrMsg
  26819. res.Cainfo = ahres.Cainfo
  26820. res.WarnMsg = ahres.WarnMsg
  26821. res.Infcode = ahres.Infcode
  26822. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26823. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26824. var cert_no string
  26825. if his.IdCardType == 1 {
  26826. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26827. } else if his.IdCardType == 2 {
  26828. cert_no = his.IdCardNo
  26829. } else {
  26830. cert_no = psn_info.VerifyNumber
  26831. }
  26832. 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, "")
  26833. var dat map[string]interface{}
  26834. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26835. fmt.Println(dat)
  26836. } else {
  26837. fmt.Println(err)
  26838. }
  26839. saveLog(result2, src_resquest, "2207", "结算")
  26840. userJSONBytes, _ := json.Marshal(dat)
  26841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26842. utils.ErrorLog("解析失败:%v", err)
  26843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26844. return
  26845. }
  26846. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26847. psn_info, _ := service.GetPsnByPatientId(id)
  26848. var verify_number string
  26849. if psn_info.IdCardType == 4 {
  26850. verify_number = psn_info.VerifyNumber
  26851. } else if psn_info.IdCardType == 1 {
  26852. bas := strings.Split(psn_info.CardInfo, "|")
  26853. cardNumber := bas[2]
  26854. verify_number = cardNumber
  26855. } else {
  26856. verify_number = psn_info.Certno
  26857. psn_info.IdCardType = 2
  26858. }
  26859. var api string
  26860. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26861. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26862. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26863. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26864. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  26865. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26866. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  26867. resp, requestErr := http.Get(api)
  26868. if requestErr != nil {
  26869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26870. return
  26871. }
  26872. body, ioErr := ioutil.ReadAll(resp.Body)
  26873. if ioErr != nil {
  26874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26876. return
  26877. }
  26878. var respJSON map[string]interface{}
  26879. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26882. return
  26883. }
  26884. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26885. result, _ := json.Marshal(respJSON)
  26886. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26887. utils.ErrorLog("解析失败:%v", err)
  26888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26889. return
  26890. }
  26891. } else {
  26892. var src_resquest string
  26893. if miConfig.Code == "H15049901371" {
  26894. //赤峰地区国家医保医疗类别
  26895. //职工透析:医疗类别选特殊情况门诊990502
  26896. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26897. var med_type string
  26898. if his.Insutype == "390" {
  26899. if reg_type == 14 {
  26900. med_type = "9933"
  26901. } else if reg_type == 11 {
  26902. med_type = "11"
  26903. }
  26904. } else if his.Insutype == "310" {
  26905. if reg_type == 14 {
  26906. med_type = "990502"
  26907. } else if reg_type == 11 {
  26908. med_type = "11"
  26909. }
  26910. }
  26911. 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)
  26912. } else {
  26913. if his.IdCardType == 4 {
  26914. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26915. token := psn_info.VerifyNumber
  26916. 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)
  26917. } else {
  26918. 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)
  26919. }
  26920. }
  26921. var dat map[string]interface{}
  26922. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26923. fmt.Println(dat)
  26924. } else {
  26925. fmt.Println(err)
  26926. }
  26927. saveLog(result2, src_resquest, "2207", "结算")
  26928. userJSONBytes, _ := json.Marshal(dat)
  26929. if miConfig.Code == "H15049901371" {
  26930. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26931. utils.ErrorLog("解析失败:%v", err)
  26932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26933. return
  26934. }
  26935. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26936. res.Output = resSeven10265.Output
  26937. res.ErrMsg = resSeven10265.ErrMsg
  26938. res.Cainfo = resSeven10265.Cainfo
  26939. res.WarnMsg = resSeven10265.WarnMsg
  26940. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26941. res.Infcode = infocode
  26942. } else {
  26943. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26944. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26945. utils.ErrorLog("解析失败:%v", err)
  26946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26947. return
  26948. }
  26949. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26950. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26951. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26952. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26953. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26954. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26955. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26956. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26957. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26958. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26959. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26960. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26961. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26962. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26963. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26964. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26965. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26966. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26967. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26968. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26969. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26970. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26971. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26972. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26973. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26974. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26975. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26976. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26977. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26978. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26979. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26980. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26981. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26982. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26983. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26984. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26985. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26986. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26987. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26988. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26989. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26990. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26991. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26992. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26993. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26994. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26995. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26996. res.Cainfo = gzresSeven10265Two.Cainfo
  26997. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26998. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26999. //res.Infcode = infocode
  27000. } else {
  27001. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27002. utils.ErrorLog("解析失败:%v", err)
  27003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27004. return
  27005. }
  27006. }
  27007. }
  27008. }
  27009. if res.Infcode == -1 {
  27010. errlog := &models.HisOrderError{
  27011. UserOrgId: adminUser.CurrentOrgId,
  27012. Ctime: time.Now().Unix(),
  27013. Mtime: time.Now().Unix(),
  27014. Number: chrg_bchno,
  27015. ErrMsg: res.ErrMsg,
  27016. Status: 1,
  27017. PatientId: id,
  27018. RecordTime: recordDateTime,
  27019. Stage: 6,
  27020. }
  27021. service.CreateErrMsgLog(errlog)
  27022. c.ServeSuccessJSON(map[string]interface{}{
  27023. "failed_code": -10,
  27024. "msg": res.ErrMsg,
  27025. })
  27026. return
  27027. } else {
  27028. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27029. order.OrderStatus = 2
  27030. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27031. order.SetlId = res.Output.Setlinfo.SetlID
  27032. order.PsnNo = res.Output.Setlinfo.PsnNo
  27033. order.PsnName = res.Output.Setlinfo.PsnName
  27034. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27035. order.Certno = res.Output.Setlinfo.Certno
  27036. order.Gend = res.Output.Setlinfo.Gend
  27037. order.Naty = res.Output.Setlinfo.Naty
  27038. order.Age = res.Output.Setlinfo.Age
  27039. order.Insutype = res.Output.Setlinfo.Insutype
  27040. order.PsnType = res.Output.Setlinfo.PsnType
  27041. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27042. order.SetlTime = res.Output.Setlinfo.SetlTime
  27043. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27044. order.PayWays = pay_ways
  27045. order.AcctUsedFlag = acct_used_flag
  27046. order.WechatPay = wechat_pay
  27047. order.AliPay = ali_pay
  27048. order.JifenPay = jifen_pay
  27049. order.BandCardPay = band_card_pay
  27050. order.CashPay = cash_pay
  27051. order.OthDesc = oth_desc
  27052. //order.MedType = res.Output.Setlinfo.MedType
  27053. if reg_type == 1112 {
  27054. order.MedType = "1112"
  27055. }
  27056. if reg_type == 1111 {
  27057. order.MedType = "1111"
  27058. }
  27059. order.ClrType = res.Output.Setlinfo.ClrType
  27060. if adminUser.CurrentOrgId == 10480 {
  27061. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27062. order.ClrType = "11"
  27063. } else {
  27064. order.ClrType = "9903"
  27065. }
  27066. }
  27067. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27068. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27069. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27070. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27071. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27072. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27073. order.HifpPay = res.Output.Setlinfo.HifpPay
  27074. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27075. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27076. order.HifesPay = res.Output.Setlinfo.HifesPay
  27077. order.HifobPay = res.Output.Setlinfo.HifobPay
  27078. order.MafPay = res.Output.Setlinfo.MafPay
  27079. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27080. order.OthPay = res.Output.Setlinfo.OthPay
  27081. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27082. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27083. order.AcctPay = res.Output.Setlinfo.AcctPay
  27084. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27085. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27086. order.Balc = res.Output.Setlinfo.Balc
  27087. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27088. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27089. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27090. order.ClrWay = res.Output.Setlinfo.ClrWay
  27091. order.Creator = order.Creator
  27092. order.Modify = roles.AdminUserId
  27093. order.RequestLog = src_resquest
  27094. order.Diagnosis = diagnosis_id
  27095. order.FaPiaoNumber = fapiao_number
  27096. order.FaPiaoCode = fapiao_code
  27097. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27098. detailStr := string(setlDetail)
  27099. order.SetlDetail = detailStr
  27100. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27101. err = service.UpDateOrder(order)
  27102. if err == nil {
  27103. //判断是否使用了押金
  27104. if dec_way == "true" {
  27105. tmpstring := strconv.FormatInt(order.ID, 10)
  27106. //扣押金
  27107. order.Decimal = decimal
  27108. service.UpDateOrder(order)
  27109. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27110. if errmsg != nil {
  27111. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27112. return
  27113. }
  27114. }
  27115. c.ServeSuccessJSON(map[string]interface{}{
  27116. "msg": "结算成功",
  27117. })
  27118. } else {
  27119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27120. return
  27121. }
  27122. }
  27123. }
  27124. }
  27125. }
  27126. // 上传明细-预结算-
  27127. func (c *HisApiController) GetPreUploadInfo() {
  27128. id, _ := c.GetInt64("id")
  27129. record_time := c.GetString("record_time")
  27130. his_patient_id, _ := c.GetInt64("his_patient_id")
  27131. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27132. admin_user_id, _ := c.GetInt64("admin_user_id")
  27133. diagnosis_id := c.GetString("diagnosis")
  27134. sick_type, _ := c.GetInt64("sick_type")
  27135. reg_type, _ := c.GetInt64("p_type")
  27136. begin_time := c.GetString("begin_time")
  27137. acct_used_flag := c.GetString("acct_used_flag")
  27138. id_str := c.GetString("ids")
  27139. ids_arr := strings.Split(id_str, ",")
  27140. timeLayout := "2006-01-02"
  27141. loc, _ := time.LoadLocation("Local")
  27142. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27143. if err != nil {
  27144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27145. return
  27146. }
  27147. recordDateTime := theTime.Unix()
  27148. adminUser := c.GetAdminUserInfo()
  27149. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27150. var config []*models.HisXtDiagnoseConfig
  27151. for _, item := range diagnosis_ids {
  27152. id, _ := strconv.ParseInt(item, 10, 64)
  27153. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27154. config = append(config, &diagnosisConfig)
  27155. }
  27156. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27157. sickConfig, _ := service.FindSickById(sick_type)
  27158. var prescriptions []*models.HisPrescription
  27159. var start_time int64
  27160. var end_time int64
  27161. var isSuccess bool = true
  27162. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27163. fmt.Println(his_patient_id)
  27164. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27165. timestamp := time.Now().Unix()
  27166. tempTime := time.Unix(timestamp, 0)
  27167. timeFormat := tempTime.Format("20060102150405")
  27168. chrgBchno := rand.Intn(100000) + 10000
  27169. new_chrg_bchno := ""
  27170. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27171. new_chrg_bchno = chrg_bchno
  27172. if adminUser.CurrentOrgId == 10265 {
  27173. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27174. new_chrg_bchno = "0000"
  27175. }
  27176. }
  27177. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27178. var patientPrescription models.HisPrescriptionInfo
  27179. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27180. if patientPrescription.ID == 0 {
  27181. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27182. }
  27183. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27184. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27185. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27186. strconv.FormatInt(his.PatientId, 10)
  27187. var res2406 Result2406
  27188. //安徽单病种处理
  27189. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27190. data := make(map[string]interface{})
  27191. client := &http.Client{}
  27192. data["psn_no"] = his.PsnNo
  27193. data["mdtrt_id"] = his.Number
  27194. data["operator"] = roles.UserName
  27195. data["cert_no"] = his.IdCardNo
  27196. data["org_name"] = miConfig.OrgName
  27197. data["psn_name"] = his.Name
  27198. data["ipt_otp_no"] = his.IptOtpNo
  27199. data["ipt_psn_sp_flag_type"] = "0901"
  27200. data["ipt_psn_sp_flag"] = "1"
  27201. data["fixmedins_code"] = miConfig.Code
  27202. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27203. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27204. data["url"] = miConfig.Url
  27205. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27206. bytesData, _ := json.Marshal(data)
  27207. var req *http.Request
  27208. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27209. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27210. resp, _ := client.Do(req)
  27211. defer resp.Body.Close()
  27212. body, ioErr := ioutil.ReadAll(resp.Body)
  27213. if ioErr != nil {
  27214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27216. return
  27217. }
  27218. var respJSON map[string]interface{}
  27219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27222. return
  27223. }
  27224. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27225. if status == "0" {
  27226. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27227. c.ServeSuccessJSON(map[string]interface{}{
  27228. "failed_code": -10,
  27229. "msg": err_msg,
  27230. })
  27231. return
  27232. }
  27233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27234. userJSONBytes, _ := json.Marshal(respJSON)
  27235. fmt.Println("log")
  27236. fmt.Println(string(userJSONBytes))
  27237. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27238. utils.ErrorLog("解析失败:%v", err)
  27239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27240. return
  27241. }
  27242. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  27243. data := make(map[string]interface{})
  27244. client := &http.Client{}
  27245. data["psn_no"] = his.PsnNo
  27246. data["mdtrt_id"] = his.Number
  27247. data["operator"] = roles.UserName
  27248. data["cert_no"] = his.IdCardNo
  27249. data["org_name"] = miConfig.OrgName
  27250. data["psn_name"] = his.Name
  27251. data["ipt_otp_no"] = his.IptOtpNo
  27252. data["ipt_psn_sp_flag_type"] = "0901"
  27253. data["ipt_psn_sp_flag"] = "1"
  27254. data["fixmedins_code"] = miConfig.Code
  27255. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27256. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27257. data["url"] = miConfig.Url
  27258. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27259. bytesData, _ := json.Marshal(data)
  27260. var req *http.Request
  27261. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27262. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27263. resp, _ := client.Do(req)
  27264. defer resp.Body.Close()
  27265. body, ioErr := ioutil.ReadAll(resp.Body)
  27266. if ioErr != nil {
  27267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27269. return
  27270. }
  27271. var respJSON map[string]interface{}
  27272. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27275. return
  27276. }
  27277. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27278. if status == "0" {
  27279. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27280. c.ServeSuccessJSON(map[string]interface{}{
  27281. "failed_code": -10,
  27282. "msg": err_msg,
  27283. })
  27284. return
  27285. }
  27286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27287. userJSONBytes, _ := json.Marshal(respJSON)
  27288. fmt.Println("log")
  27289. fmt.Println(string(userJSONBytes))
  27290. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27291. utils.ErrorLog("解析失败:%v", err)
  27292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27293. return
  27294. }
  27295. }
  27296. if res2406.Infcode != 0 {
  27297. adminUser := c.GetAdminUserInfo()
  27298. errlog := &models.HisOrderError{
  27299. UserOrgId: adminUser.CurrentOrgId,
  27300. Ctime: time.Now().Unix(),
  27301. Mtime: time.Now().Unix(),
  27302. ErrMsg: res2406.ErrMsg,
  27303. Status: 1,
  27304. PatientId: id,
  27305. RecordTime: recordDateTime,
  27306. Stage: 3,
  27307. }
  27308. service.CreateErrMsgLog(errlog)
  27309. c.ServeSuccessJSON(map[string]interface{}{
  27310. "failed_code": -10,
  27311. "msg": res2406.ErrMsg,
  27312. })
  27313. return
  27314. }
  27315. var res2 ResultSix
  27316. var res3 GZResultSix
  27317. var resSix10265 ResultSix10265
  27318. //var time_stamp string
  27319. if miConfig.MdtrtareaAdmvs == "421300" {
  27320. data := make(map[string]interface{})
  27321. client := &http.Client{}
  27322. data["psn_no"] = his.PsnNo
  27323. data["mdtrt_id"] = his.Number
  27324. data["department"] = department.Name
  27325. data["org_name"] = miConfig.OrgName
  27326. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27327. data["doctor_id"] = doctor_info.DoctorNumber
  27328. data["doctor_name"] = roles.UserName
  27329. data["fixmedins_code"] = miConfig.Code
  27330. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27331. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27332. data["secret_key"] = miConfig.SecretKey
  27333. data["sick_code"] = sickConfig.CountryCode
  27334. data["sick_name"] = sickConfig.ClassName
  27335. data["begin_time"] = begin_time
  27336. data["dept"] = strconv.FormatInt(department.ID, 10)
  27337. data["config"] = config
  27338. data["opter"] = roles.UserName
  27339. fmt.Println(data)
  27340. bytesData, _ := json.Marshal(data)
  27341. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  27342. resp, _ := client.Do(req)
  27343. defer resp.Body.Close()
  27344. body, ioErr := ioutil.ReadAll(resp.Body)
  27345. if ioErr != nil {
  27346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27348. return
  27349. }
  27350. var respJSON map[string]interface{}
  27351. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27354. return
  27355. }
  27356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27357. userJSONBytes, _ := json.Marshal(respJSON)
  27358. fmt.Println("log")
  27359. fmt.Println(string(userJSONBytes))
  27360. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27361. utils.ErrorLog("解析失败:%v", err)
  27362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27363. return
  27364. }
  27365. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27366. data := make(map[string]interface{})
  27367. client := &http.Client{}
  27368. data["psn_no"] = his.PsnNo
  27369. data["mdtrt_id"] = his.Number
  27370. data["department"] = department.Name
  27371. data["org_name"] = miConfig.OrgName
  27372. if reg_type == 11 && his.Insutype == "390" {
  27373. data["med_type"] = "110104"
  27374. } else {
  27375. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27376. }
  27377. data["doctor_id"] = doctor_info.DoctorNumber
  27378. data["doctor_name"] = roles.UserName
  27379. data["fixmedins_code"] = miConfig.Code
  27380. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27381. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27382. data["secret_key"] = miConfig.SecretKey
  27383. data["sick_code"] = sickConfig.CountryCode
  27384. data["sick_name"] = sickConfig.ClassName
  27385. data["begin_time"] = begin_time
  27386. data["dept"] = strconv.FormatInt(department.ID, 10)
  27387. data["config"] = config
  27388. data["opter"] = roles.UserName
  27389. fmt.Println(data)
  27390. bytesData, _ := json.Marshal(data)
  27391. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  27392. resp, _ := client.Do(req)
  27393. defer resp.Body.Close()
  27394. body, ioErr := ioutil.ReadAll(resp.Body)
  27395. if ioErr != nil {
  27396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27398. return
  27399. }
  27400. var respJSON map[string]interface{}
  27401. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27404. return
  27405. }
  27406. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27407. userJSONBytes, _ := json.Marshal(respJSON)
  27408. fmt.Println("log")
  27409. fmt.Println(string(userJSONBytes))
  27410. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27411. utils.ErrorLog("解析失败:%v", err)
  27412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27413. return
  27414. }
  27415. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27416. data := make(map[string]interface{})
  27417. client := &http.Client{}
  27418. data["psn_no"] = his.PsnNo
  27419. data["mdtrt_id"] = his.Number
  27420. data["department"] = department.Name
  27421. data["org_name"] = miConfig.OrgName
  27422. if reg_type == 11 && his.Insutype == "390" {
  27423. data["med_type"] = "110104"
  27424. } else {
  27425. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27426. }
  27427. data["doctor_id"] = doctor_info.DoctorNumber
  27428. data["doctor_name"] = roles.UserName
  27429. data["fixmedins_code"] = miConfig.Code
  27430. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27431. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27432. data["secret_key"] = miConfig.SecretKey
  27433. data["sick_code"] = sickConfig.CountryCode
  27434. data["sick_name"] = sickConfig.ClassName
  27435. data["begin_time"] = begin_time
  27436. data["dept"] = strconv.FormatInt(department.ID, 10)
  27437. data["config"] = config
  27438. data["opter"] = roles.UserName
  27439. fmt.Println(data)
  27440. bytesData, _ := json.Marshal(data)
  27441. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  27442. resp, _ := client.Do(req)
  27443. defer resp.Body.Close()
  27444. body, ioErr := ioutil.ReadAll(resp.Body)
  27445. if ioErr != nil {
  27446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27448. return
  27449. }
  27450. var respJSON map[string]interface{}
  27451. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27454. return
  27455. }
  27456. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27457. userJSONBytes, _ := json.Marshal(respJSON)
  27458. fmt.Println("log")
  27459. fmt.Println(string(userJSONBytes))
  27460. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27461. utils.ErrorLog("解析失败:%v", err)
  27462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27463. return
  27464. }
  27465. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27466. data := make(map[string]interface{})
  27467. client := &http.Client{}
  27468. data["psn_no"] = his.PsnNo
  27469. data["mdtrt_id"] = his.Number
  27470. data["department"] = department.Name
  27471. data["org_name"] = miConfig.OrgName
  27472. if reg_type == 11 && his.Insutype == "390" {
  27473. data["med_type"] = "110104"
  27474. } else {
  27475. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27476. }
  27477. data["doctor_id"] = doctor_info.DoctorNumber
  27478. data["doctor_name"] = roles.UserName
  27479. data["fixmedins_code"] = miConfig.Code
  27480. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27481. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27482. data["secret_key"] = miConfig.SecretKey
  27483. data["sick_code"] = sickConfig.CountryCode
  27484. data["sick_name"] = sickConfig.ClassName
  27485. data["begin_time"] = begin_time
  27486. data["dept"] = strconv.FormatInt(department.ID, 10)
  27487. data["config"] = config
  27488. data["opter"] = roles.UserName
  27489. fmt.Println(data)
  27490. bytesData, _ := json.Marshal(data)
  27491. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  27492. resp, _ := client.Do(req)
  27493. defer resp.Body.Close()
  27494. body, ioErr := ioutil.ReadAll(resp.Body)
  27495. if ioErr != nil {
  27496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27498. return
  27499. }
  27500. var respJSON map[string]interface{}
  27501. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27504. return
  27505. }
  27506. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27507. userJSONBytes, _ := json.Marshal(respJSON)
  27508. fmt.Println("log")
  27509. fmt.Println(string(userJSONBytes))
  27510. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27511. utils.ErrorLog("解析失败:%v", err)
  27512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27513. return
  27514. }
  27515. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27516. data := make(map[string]interface{})
  27517. client := &http.Client{}
  27518. data["psn_no"] = his.PsnNo
  27519. data["mdtrt_id"] = his.Number
  27520. data["doctor"] = roles.UserName
  27521. data["department"] = department.Name
  27522. data["org_name"] = miConfig.OrgName
  27523. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27524. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  27525. data["fixmedins_code"] = miConfig.Code
  27526. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27527. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27528. data["secret_key"] = miConfig.SecretKey
  27529. data["sick_code"] = sickConfig.CountryCode
  27530. data["sick_name"] = sickConfig.ClassName
  27531. data["begin_time"] = begin_time
  27532. data["dept"] = strconv.FormatInt(department.ID, 10)
  27533. data["config"] = config
  27534. data["url"] = miConfig.Url
  27535. data["ak"] = miConfig.AccessKey
  27536. data["cainfo"] = miConfig.Cainfo
  27537. bytesData, _ := json.Marshal(data)
  27538. var req *http.Request
  27539. if miConfig.MdtrtareaAdmvs == "320921" {
  27540. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  27541. } else {
  27542. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  27543. }
  27544. resp, _ := client.Do(req)
  27545. defer resp.Body.Close()
  27546. body, ioErr := ioutil.ReadAll(resp.Body)
  27547. if ioErr != nil {
  27548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27550. return
  27551. }
  27552. var respJSON map[string]interface{}
  27553. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27556. return
  27557. }
  27558. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  27559. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  27560. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  27561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27562. userJSONBytes, _ := json.Marshal(respJSON)
  27563. fmt.Println("log")
  27564. fmt.Println(string(userJSONBytes))
  27565. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  27566. utils.ErrorLog("解析失败:%v", err)
  27567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27568. return
  27569. }
  27570. res2.InfRefmsgid = resSix10265.InfRefmsgid
  27571. res2.Output = resSix10265.Output
  27572. res2.ErrMsg = resSix10265.ErrMsg
  27573. res2.Cainfo = resSix10265.Cainfo
  27574. res2.WarnMsg = resSix10265.WarnMsg
  27575. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  27576. res2.Infcode = infocode
  27577. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27578. data := make(map[string]interface{})
  27579. client := &http.Client{}
  27580. data["psn_no"] = his.PsnNo
  27581. data["mdtrt_id"] = his.Number
  27582. data["doctor"] = roles.UserName
  27583. data["department"] = department.Name
  27584. data["org_name"] = miConfig.OrgName
  27585. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27586. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  27587. data["fixmedins_code"] = miConfig.Code
  27588. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27589. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27590. data["secret_key"] = miConfig.SecretKey
  27591. data["sick_code"] = sickConfig.CountryCode
  27592. data["sick_name"] = sickConfig.ClassName
  27593. data["begin_time"] = begin_time
  27594. data["dept"] = strconv.FormatInt(department.ID, 10)
  27595. data["config"] = config
  27596. //data["url"] = miConfig.Url
  27597. //data["ak"] = miConfig.AccessKey
  27598. data["cainfo"] = miConfig.Cainfo
  27599. fmt.Println(data)
  27600. bytesData, _ := json.Marshal(data)
  27601. var req *http.Request
  27602. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  27603. resp, _ := client.Do(req)
  27604. defer resp.Body.Close()
  27605. body, ioErr := ioutil.ReadAll(resp.Body)
  27606. if ioErr != nil {
  27607. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27609. return
  27610. }
  27611. var respJSON map[string]interface{}
  27612. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27615. return
  27616. }
  27617. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  27618. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  27619. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  27620. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27621. userJSONBytes, _ := json.Marshal(respJSON)
  27622. fmt.Println("log")
  27623. fmt.Println(string(userJSONBytes))
  27624. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  27625. utils.ErrorLog("解析失败:%v", err)
  27626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27627. return
  27628. }
  27629. res2.InfRefmsgid = resSix10265.InfRefmsgid
  27630. res2.Output = resSix10265.Output
  27631. res2.ErrMsg = resSix10265.ErrMsg
  27632. res2.Cainfo = resSix10265.Cainfo
  27633. res2.WarnMsg = resSix10265.WarnMsg
  27634. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  27635. res2.Infcode = infocode
  27636. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27637. 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)
  27638. saveLog(result, requestLog, "2203", "上传就诊信息")
  27639. var respJSON2 map[string]interface{}
  27640. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  27641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27643. return
  27644. }
  27645. userJSONBytes2, _ := json.Marshal(respJSON2)
  27646. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27647. utils.ErrorLog("解析失败:%v", err)
  27648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27649. return
  27650. }
  27651. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27652. var result string
  27653. var requestLog string
  27654. 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, "")
  27655. saveLog(result, requestLog, "2203", "上传就诊信息")
  27656. var respJSON2 map[string]interface{}
  27657. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  27658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27660. return
  27661. }
  27662. userJSONBytes2, _ := json.Marshal(respJSON2)
  27663. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27664. utils.ErrorLog("解析失败:%v", err)
  27665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27666. return
  27667. }
  27668. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27669. var result string
  27670. var requestLog string
  27671. 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, "")
  27672. saveLog(result, requestLog, "2203", "上传就诊信息")
  27673. var respJSON2 map[string]interface{}
  27674. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  27675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27677. return
  27678. }
  27679. userJSONBytes2, _ := json.Marshal(respJSON2)
  27680. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27681. utils.ErrorLog("解析失败:%v", err)
  27682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27683. return
  27684. }
  27685. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27686. data := make(map[string]interface{})
  27687. client := &http.Client{}
  27688. data["psn_no"] = his.PsnNo
  27689. data["mdtrt_id"] = his.Number
  27690. data["operator"] = roles.UserName
  27691. data["department"] = department.Name
  27692. data["org_name"] = miConfig.OrgName
  27693. var med_type string
  27694. if his.Insutype == "390" {
  27695. if reg_type == 992102 {
  27696. med_type = "992102"
  27697. data["sick_code"] = "ZDZ940"
  27698. data["sick_name"] = "慢性肾衰竭"
  27699. }
  27700. if reg_type == 140104 {
  27701. med_type = "140104"
  27702. data["sick_code"] = sickConfig.CountryCode
  27703. data["sick_name"] = sickConfig.ClassName
  27704. }
  27705. if reg_type == 14 {
  27706. med_type = "140104"
  27707. data["sick_code"] = sickConfig.CountryCode
  27708. data["sick_name"] = sickConfig.ClassName
  27709. }
  27710. } else if his.Insutype == "310" {
  27711. if reg_type == 992102 {
  27712. med_type = "992102"
  27713. data["sick_code"] = "ZDZ940"
  27714. data["sick_name"] = "慢性肾衰竭"
  27715. }
  27716. if reg_type == 140104 {
  27717. med_type = "140104"
  27718. data["sick_code"] = sickConfig.CountryCode
  27719. data["sick_name"] = sickConfig.ClassName
  27720. }
  27721. if reg_type == 14 {
  27722. med_type = "14"
  27723. data["sick_code"] = sickConfig.CountryCode
  27724. data["sick_name"] = sickConfig.ClassName
  27725. }
  27726. }
  27727. data["med_type"] = med_type
  27728. data["doctor_number"] = doctor_info.DoctorNumber
  27729. data["doctor_name"] = doctor_info.UserName
  27730. data["fixmedins_code"] = miConfig.Code
  27731. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27732. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27733. data["secret_key"] = miConfig.SecretKey
  27734. data["begin_time"] = begin_time
  27735. data["dept"] = strconv.FormatInt(department.ID, 10)
  27736. data["config"] = config
  27737. data["url"] = miConfig.Url
  27738. data["ak"] = miConfig.AccessKey
  27739. data["cainfo"] = miConfig.Cainfo
  27740. bytesData, _ := json.Marshal(data)
  27741. var req *http.Request
  27742. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  27743. resp, _ := client.Do(req)
  27744. defer resp.Body.Close()
  27745. body, ioErr := ioutil.ReadAll(resp.Body)
  27746. if ioErr != nil {
  27747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27749. return
  27750. }
  27751. var respJSON map[string]interface{}
  27752. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27755. return
  27756. }
  27757. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27758. if status == "0" {
  27759. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27760. c.ServeSuccessJSON(map[string]interface{}{
  27761. "failed_code": -10,
  27762. "msg": err_msg,
  27763. })
  27764. return
  27765. }
  27766. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27767. userJSONBytes, _ := json.Marshal(respJSON)
  27768. fmt.Println("log")
  27769. fmt.Println(string(userJSONBytes))
  27770. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27771. utils.ErrorLog("解析失败:%v", err)
  27772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27773. return
  27774. }
  27775. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27776. data := make(map[string]interface{})
  27777. client := &http.Client{}
  27778. data["psn_no"] = his.PsnNo
  27779. data["mdtrt_id"] = his.Number
  27780. data["operator"] = roles.UserName
  27781. data["department"] = department.Name
  27782. data["org_name"] = miConfig.OrgName
  27783. var med_type string
  27784. if his.Insutype == "390" {
  27785. if reg_type == 992102 {
  27786. med_type = "992102"
  27787. data["sick_code"] = sickConfig.CountryCode
  27788. data["sick_name"] = sickConfig.ClassName
  27789. }
  27790. if reg_type == 140104 {
  27791. med_type = "140104"
  27792. data["sick_code"] = sickConfig.CountryCode
  27793. data["sick_name"] = sickConfig.ClassName
  27794. }
  27795. if reg_type == 14 {
  27796. med_type = "140104"
  27797. data["sick_code"] = sickConfig.CountryCode
  27798. data["sick_name"] = sickConfig.ClassName
  27799. }
  27800. } else if his.Insutype == "310" {
  27801. if reg_type == 992102 {
  27802. med_type = "992102"
  27803. data["sick_code"] = sickConfig.CountryCode
  27804. data["sick_name"] = sickConfig.CountryCode
  27805. }
  27806. if reg_type == 140104 {
  27807. med_type = "140104"
  27808. data["sick_code"] = sickConfig.CountryCode
  27809. data["sick_name"] = sickConfig.CountryCode
  27810. }
  27811. if reg_type == 14 {
  27812. med_type = "14"
  27813. data["sick_code"] = sickConfig.CountryCode
  27814. data["sick_name"] = sickConfig.ClassName
  27815. }
  27816. }
  27817. data["med_type"] = med_type
  27818. data["doctor_number"] = doctor_info.DoctorNumber
  27819. data["doctor_name"] = doctor_info.UserName
  27820. data["fixmedins_code"] = miConfig.Code
  27821. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27822. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27823. data["secret_key"] = miConfig.SecretKey
  27824. data["begin_time"] = begin_time
  27825. data["dept"] = strconv.FormatInt(department.ID, 10)
  27826. data["config"] = config
  27827. data["url"] = miConfig.Url
  27828. data["ak"] = miConfig.AccessKey
  27829. data["cainfo"] = miConfig.Cainfo
  27830. bytesData, _ := json.Marshal(data)
  27831. var req *http.Request
  27832. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  27833. resp, _ := client.Do(req)
  27834. defer resp.Body.Close()
  27835. body, ioErr := ioutil.ReadAll(resp.Body)
  27836. if ioErr != nil {
  27837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27839. return
  27840. }
  27841. var respJSON map[string]interface{}
  27842. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27845. return
  27846. }
  27847. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27848. if status == "0" {
  27849. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27850. c.ServeSuccessJSON(map[string]interface{}{
  27851. "failed_code": -10,
  27852. "msg": err_msg,
  27853. })
  27854. return
  27855. }
  27856. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27857. userJSONBytes, _ := json.Marshal(respJSON)
  27858. fmt.Println("log")
  27859. fmt.Println(string(userJSONBytes))
  27860. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27861. utils.ErrorLog("解析失败:%v", err)
  27862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27863. return
  27864. }
  27865. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27866. var result string
  27867. var requestLog string
  27868. 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, "")
  27869. saveLog(result, requestLog, "2203", "上传就诊信息")
  27870. var respJSON2 map[string]interface{}
  27871. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  27872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27874. return
  27875. }
  27876. userJSONBytes2, _ := json.Marshal(respJSON2)
  27877. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27878. utils.ErrorLog("解析失败:%v", err)
  27879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27880. return
  27881. }
  27882. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27883. data := make(map[string]interface{})
  27884. client := &http.Client{}
  27885. data["psn_no"] = his.PsnNo
  27886. data["mdtrt_id"] = his.Number
  27887. data["doctor"] = roles.UserName
  27888. data["department"] = department.Name
  27889. data["org_name"] = miConfig.OrgName
  27890. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27891. data["doctor_id"] = doctor_info.DoctorNumber
  27892. data["fixmedins_code"] = miConfig.Code
  27893. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27894. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27895. data["secret_key"] = miConfig.SecretKey
  27896. data["sick_code"] = sickConfig.CountryCode
  27897. data["sick_name"] = sickConfig.ClassName
  27898. data["begin_time"] = begin_time
  27899. data["new_doctor_name"] = doctor_info.UserName
  27900. data["dept"] = strconv.FormatInt(department.ID, 10)
  27901. data["config"] = config
  27902. bytesData, _ := json.Marshal(data)
  27903. var req *http.Request
  27904. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  27905. resp, _ := client.Do(req)
  27906. defer resp.Body.Close()
  27907. body, ioErr := ioutil.ReadAll(resp.Body)
  27908. if ioErr != nil {
  27909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27911. return
  27912. }
  27913. var respJSON map[string]interface{}
  27914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27917. return
  27918. }
  27919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27920. userJSONBytes, _ := json.Marshal(respJSON)
  27921. fmt.Println("log")
  27922. fmt.Println(string(userJSONBytes))
  27923. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27924. utils.ErrorLog("解析失败:%v", err)
  27925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27926. return
  27927. }
  27928. } else {
  27929. var result string
  27930. var requestLog string
  27931. if miConfig.MdtrtareaAdmvs == "440781" { //
  27932. 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)
  27933. } else {
  27934. if miConfig.Code == "H15049901371" {
  27935. //赤峰地区国家医保医疗类别
  27936. //职工透析:医疗类别选特殊情况门诊990502
  27937. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27938. var med_type string
  27939. if his.Insutype == "390" {
  27940. if reg_type == 14 {
  27941. med_type = "9933"
  27942. } else if reg_type == 11 {
  27943. med_type = "11"
  27944. }
  27945. } else if his.Insutype == "310" {
  27946. if reg_type == 14 {
  27947. med_type = "990502"
  27948. } else if reg_type == 11 {
  27949. med_type = "11"
  27950. }
  27951. }
  27952. 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)
  27953. } else {
  27954. 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)
  27955. }
  27956. saveLog(result, requestLog, "2203", "上传就诊信息")
  27957. var respJSON2 map[string]interface{}
  27958. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  27959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27961. return
  27962. }
  27963. userJSONBytes2, _ := json.Marshal(respJSON2)
  27964. if miConfig.Code == "H15049901371" {
  27965. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  27966. utils.ErrorLog("解析失败:%v", err)
  27967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27968. return
  27969. }
  27970. res2.InfRefmsgid = resSix10265.InfRefmsgid
  27971. res2.Output = resSix10265.Output
  27972. res2.ErrMsg = resSix10265.ErrMsg
  27973. res2.Cainfo = resSix10265.Cainfo
  27974. res2.WarnMsg = resSix10265.WarnMsg
  27975. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  27976. res2.Infcode = infocode
  27977. } else {
  27978. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27979. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  27980. utils.ErrorLog("解析失败:%v", err)
  27981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27982. return
  27983. }
  27984. res2.Infcode = res3.Infcode
  27985. } else {
  27986. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27987. utils.ErrorLog("解析失败:%v", err)
  27988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27989. return
  27990. }
  27991. }
  27992. }
  27993. }
  27994. }
  27995. if res2.Infcode == -1 {
  27996. adminUser := c.GetAdminUserInfo()
  27997. errlog := &models.HisOrderError{
  27998. UserOrgId: adminUser.CurrentOrgId,
  27999. Ctime: time.Now().Unix(),
  28000. Mtime: time.Now().Unix(),
  28001. ErrMsg: res2.ErrMsg,
  28002. Status: 1,
  28003. PatientId: id,
  28004. RecordTime: recordDateTime,
  28005. Stage: 3,
  28006. }
  28007. service.CreateErrMsgLog(errlog)
  28008. c.ServeSuccessJSON(map[string]interface{}{
  28009. "failed_code": -10,
  28010. "msg": res2.ErrMsg,
  28011. })
  28012. return
  28013. }
  28014. if res2.Infcode != 0 {
  28015. adminUser := c.GetAdminUserInfo()
  28016. errlog := &models.HisOrderError{
  28017. UserOrgId: adminUser.CurrentOrgId,
  28018. Ctime: time.Now().Unix(),
  28019. Mtime: time.Now().Unix(),
  28020. ErrMsg: res2.ErrMsg,
  28021. Status: 1,
  28022. PatientId: id,
  28023. RecordTime: recordDateTime,
  28024. Stage: 3,
  28025. }
  28026. service.CreateErrMsgLog(errlog)
  28027. c.ServeSuccessJSON(map[string]interface{}{
  28028. "failed_code": -10,
  28029. "msg": res2.ErrMsg,
  28030. })
  28031. return
  28032. } else {
  28033. his.Diagnosis = diagnosis_id
  28034. his.SickType = sickConfig.ID
  28035. his.PType = fmt.Sprintf("%d", reg_type)
  28036. service.UpdateHisPatientThree(&his)
  28037. data := make(map[string]interface{})
  28038. if settle_accounts_type == 1 { //日结
  28039. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28040. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28041. } else {
  28042. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28043. }
  28044. data["pre"] = prescriptions
  28045. } else { //月结
  28046. start_time_str := c.GetString("start_time")
  28047. end_time_str := c.GetString("end_time")
  28048. timeLayout := "2006-01-02"
  28049. loc, _ := time.LoadLocation("Local")
  28050. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28051. if err != nil {
  28052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28053. return
  28054. }
  28055. recordStartTime := theStartTime.Unix()
  28056. start_time = recordStartTime
  28057. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28058. if err != nil {
  28059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28060. return
  28061. }
  28062. recordEndTime := theEndTime.Unix()
  28063. end_time = recordEndTime
  28064. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28065. data["pre"] = prescriptions
  28066. }
  28067. client := &http.Client{}
  28068. data["psn_no"] = his.PsnNo
  28069. data["mdtrt_id"] = his.Number
  28070. data["chrg_bchno"] = new_chrg_bchno
  28071. data["org_name"] = miConfig.OrgName
  28072. data["doctor"] = doctor_info.UserName
  28073. data["doctor_id"] = doctor_info.DoctorNumber
  28074. data["dept"] = department.Name
  28075. data["fixmedins_code"] = miConfig.Code
  28076. data["opter"] = roles.UserName
  28077. data["dept_code"] = department.Number
  28078. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28079. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28080. data["secret_key"] = miConfig.SecretKey
  28081. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28082. data["url"] = miConfig.Url
  28083. data["ak"] = miConfig.AccessKey
  28084. data["new_doctor_name"] = patientPrescription.Doctor
  28085. if his.Insutype == "390" {
  28086. if reg_type == 992102 {
  28087. data["diag_code"] = "ZDZ940"
  28088. }
  28089. if reg_type == 140104 {
  28090. data["diag_code"] = sickConfig.CountryCode
  28091. }
  28092. if reg_type == 14 {
  28093. data["diag_code"] = sickConfig.CountryCode
  28094. }
  28095. } else if his.Insutype == "310" {
  28096. if reg_type == 992102 {
  28097. data["diag_code"] = "ZDZ940"
  28098. }
  28099. if reg_type == 14 {
  28100. data["diag_code"] = sickConfig.CountryCode
  28101. }
  28102. }
  28103. data["cainfo"] = miConfig.Cainfo
  28104. data["opter"] = roles.UserName
  28105. var ids []int64
  28106. for _, item := range prescriptions {
  28107. ids = append(ids, item.ID)
  28108. }
  28109. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28110. if config.IsOpen == 1 { //对接了医保,走医保流程
  28111. var res ResultFour
  28112. var resFour10265 ResultFour10265
  28113. if miConfig.MdtrtareaAdmvs == "421300" {
  28114. bytesData, _ := json.Marshal(data)
  28115. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28116. resp, _ := client.Do(req)
  28117. defer resp.Body.Close()
  28118. body, ioErr := ioutil.ReadAll(resp.Body)
  28119. if ioErr != nil {
  28120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28122. return
  28123. }
  28124. var respJSON map[string]interface{}
  28125. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28128. return
  28129. }
  28130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28131. userJSONBytes, _ := json.Marshal(respJSON)
  28132. fmt.Println("log")
  28133. fmt.Println(string(userJSONBytes))
  28134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28135. utils.ErrorLog("解析失败:%v", err)
  28136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28137. return
  28138. }
  28139. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28140. bytesData, _ := json.Marshal(data)
  28141. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28142. resp, _ := client.Do(req)
  28143. defer resp.Body.Close()
  28144. body, ioErr := ioutil.ReadAll(resp.Body)
  28145. if ioErr != nil {
  28146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28148. return
  28149. }
  28150. var respJSON map[string]interface{}
  28151. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28154. return
  28155. }
  28156. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28157. userJSONBytes, _ := json.Marshal(respJSON)
  28158. fmt.Println("log")
  28159. fmt.Println(string(userJSONBytes))
  28160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28161. utils.ErrorLog("解析失败:%v", err)
  28162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28163. return
  28164. }
  28165. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28166. bytesData, _ := json.Marshal(data)
  28167. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28168. resp, _ := client.Do(req)
  28169. defer resp.Body.Close()
  28170. body, ioErr := ioutil.ReadAll(resp.Body)
  28171. if ioErr != nil {
  28172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28174. return
  28175. }
  28176. var respJSON map[string]interface{}
  28177. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28180. return
  28181. }
  28182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28183. userJSONBytes, _ := json.Marshal(respJSON)
  28184. fmt.Println("log")
  28185. fmt.Println(string(userJSONBytes))
  28186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28187. utils.ErrorLog("解析失败:%v", err)
  28188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28189. return
  28190. }
  28191. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28192. bytesData, _ := json.Marshal(data)
  28193. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28194. resp, _ := client.Do(req)
  28195. defer resp.Body.Close()
  28196. body, ioErr := ioutil.ReadAll(resp.Body)
  28197. if ioErr != nil {
  28198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28200. return
  28201. }
  28202. var respJSON map[string]interface{}
  28203. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28206. return
  28207. }
  28208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28209. userJSONBytes, _ := json.Marshal(respJSON)
  28210. fmt.Println("log")
  28211. fmt.Println(string(userJSONBytes))
  28212. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28213. utils.ErrorLog("解析失败:%v", err)
  28214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28215. return
  28216. }
  28217. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28218. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28219. if result3101.Infcode == "0" {
  28220. if len(result3101.Output.Result) > 0 {
  28221. var errMsgs []string
  28222. for _, item := range result3101.Output.Result {
  28223. errMsgs = append(errMsgs, item.VolaCont)
  28224. }
  28225. c.ServeSuccessJSON(map[string]interface{}{
  28226. "failed_code": -10,
  28227. "msg": errMsgs,
  28228. })
  28229. return
  28230. } else {
  28231. if miConfig.MdtrtareaAdmvs == "320921" {
  28232. data["doctor_id"] = "D320923012139"
  28233. } else {
  28234. data["doctor_id"] = "D371621008686"
  28235. }
  28236. bytesData, _ := json.Marshal(data)
  28237. var req *http.Request
  28238. if miConfig.MdtrtareaAdmvs == "320921" {
  28239. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28240. } else {
  28241. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28242. }
  28243. resp, _ := client.Do(req)
  28244. defer resp.Body.Close()
  28245. body, ioErr := ioutil.ReadAll(resp.Body)
  28246. if ioErr != nil {
  28247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28249. return
  28250. }
  28251. var respJSON map[string]interface{}
  28252. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28255. return
  28256. }
  28257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28258. userJSONBytes, _ := json.Marshal(respJSON)
  28259. fmt.Println("log")
  28260. fmt.Println(string(userJSONBytes))
  28261. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28262. utils.ErrorLog("解析失败:%v", err)
  28263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28264. return
  28265. }
  28266. res.InfRefmsgid = resFour10265.InfRefmsgid
  28267. res.Output = resFour10265.Output
  28268. res.ErrMsg = resFour10265.ErrMsg
  28269. res.Cainfo = resFour10265.Cainfo
  28270. res.WarnMsg = resFour10265.WarnMsg
  28271. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28272. res.Infcode = infocode
  28273. }
  28274. }
  28275. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28276. var pagesize int = 5
  28277. var start int = 1
  28278. var stop int
  28279. var pagecount int
  28280. var curpage int
  28281. data["doctor_id"] = doctor_info.DoctorNumber
  28282. var res2 ResultFour
  28283. //var result res.
  28284. //总页数,向上取整,注意除之前要先转换类型为float64
  28285. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  28286. for curpage = 1; curpage <= pagecount; curpage++ {
  28287. if curpage == 1 {
  28288. start = 1
  28289. } else {
  28290. start = (curpage-1)*pagesize + 1
  28291. }
  28292. stop = curpage * pagesize
  28293. if stop > len(prescriptions) {
  28294. stop = len(prescriptions)
  28295. }
  28296. //var requestLog string
  28297. data["pre"] = prescriptions[start-1 : stop]
  28298. fmt.Println(data["pre"])
  28299. bytesData, _ := json.Marshal(data)
  28300. var req *http.Request
  28301. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", 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. fmt.Println("log")
  28319. fmt.Println(string(userJSONBytes))
  28320. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28321. utils.ErrorLog("解析失败:%v", err)
  28322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28323. return
  28324. }
  28325. res.InfRefmsgid = resFour10265.InfRefmsgid
  28326. res.Output = resFour10265.Output
  28327. res.ErrMsg = resFour10265.ErrMsg
  28328. res.Cainfo = resFour10265.Cainfo
  28329. res.WarnMsg = resFour10265.WarnMsg
  28330. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28331. res.Infcode = infocode
  28332. if infocode == 0 {
  28333. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  28334. } else {
  28335. isSuccess = false
  28336. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  28337. res.Infcode = -1
  28338. res.ErrMsg = resFour10265.ErrMsg
  28339. errlog := &models.HisOrderError{
  28340. UserOrgId: adminUser.CurrentOrgId,
  28341. Ctime: time.Now().Unix(),
  28342. Mtime: time.Now().Unix(),
  28343. Number: chrg_bchno,
  28344. ErrMsg: "",
  28345. Status: 1,
  28346. PatientId: id,
  28347. RecordTime: recordDateTime,
  28348. Stage: 4,
  28349. }
  28350. service.CreateErrMsgLog(errlog)
  28351. }
  28352. }
  28353. if isSuccess {
  28354. res.Infcode = 0
  28355. res.Output.Result = res2.Output.Result
  28356. } else {
  28357. order := &models.HisOrder{
  28358. UserOrgId: adminUser.CurrentOrgId,
  28359. HisPatientId: his.ID,
  28360. PatientId: his.PatientId,
  28361. SettleAccountsDate: recordDateTime,
  28362. Ctime: time.Now().Unix(),
  28363. Mtime: time.Now().Unix(),
  28364. MdtrtId: his.Number,
  28365. PsnNo: his.PsnNo,
  28366. MedType: strconv.FormatInt(reg_type, 10),
  28367. Status: 1,
  28368. Number: chrg_bchno,
  28369. Infcode: res.Infcode,
  28370. WarnMsg: res.WarnMsg,
  28371. Cainfo: res.Cainfo,
  28372. ErrMsg: res.ErrMsg,
  28373. RespondTime: res.RefmsgTime,
  28374. InfRefmsgid: res.InfRefmsgid,
  28375. OrderStatus: 1,
  28376. IsMedicineInsurance: 1,
  28377. SettleType: settle_accounts_type,
  28378. SettleStartTime: start_time,
  28379. SettleEndTime: end_time,
  28380. Creator: roles.AdminUserId,
  28381. Modify: roles.AdminUserId,
  28382. PType: 2,
  28383. Diagnosis: diagnosis_id,
  28384. }
  28385. err = service.CreateOrder(order)
  28386. if err != nil {
  28387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  28388. return
  28389. }
  28390. c.ServeSuccessJSON(map[string]interface{}{
  28391. "failed_code": -10,
  28392. "msg": res2.ErrMsg,
  28393. })
  28394. return
  28395. }
  28396. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28397. 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)
  28398. var dat map[string]interface{}
  28399. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28400. fmt.Println(dat)
  28401. } else {
  28402. fmt.Println(err)
  28403. }
  28404. saveLog(result, request_log, "2204", "上传费用明细")
  28405. userJSONBytes, _ := json.Marshal(dat)
  28406. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28407. utils.ErrorLog("解析失败:%v", err)
  28408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28409. return
  28410. }
  28411. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28412. 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, "", "")
  28413. var dat map[string]interface{}
  28414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28415. fmt.Println(dat)
  28416. } else {
  28417. fmt.Println(err)
  28418. }
  28419. saveLog(result, request_log, "2204", "上传费用明细")
  28420. userJSONBytes, _ := json.Marshal(dat)
  28421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28422. utils.ErrorLog("解析失败:%v", err)
  28423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28424. return
  28425. }
  28426. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28427. 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, "", "")
  28428. var dat map[string]interface{}
  28429. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28430. fmt.Println(dat)
  28431. } else {
  28432. fmt.Println(err)
  28433. }
  28434. saveLog(result, request_log, "2204", "上传费用明细")
  28435. userJSONBytes, _ := json.Marshal(dat)
  28436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28437. utils.ErrorLog("解析失败:%v", err)
  28438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28439. return
  28440. }
  28441. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28442. bytesData, _ := json.Marshal(data)
  28443. var req *http.Request
  28444. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  28445. resp, _ := client.Do(req)
  28446. defer resp.Body.Close()
  28447. body, ioErr := ioutil.ReadAll(resp.Body)
  28448. if ioErr != nil {
  28449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28451. return
  28452. }
  28453. var respJSON map[string]interface{}
  28454. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28457. return
  28458. }
  28459. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28460. if status == "0" {
  28461. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28462. c.ServeSuccessJSON(map[string]interface{}{
  28463. "failed_code": -10,
  28464. "msg": err_msg,
  28465. })
  28466. return
  28467. }
  28468. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28469. userJSONBytes, _ := json.Marshal(respJSON)
  28470. fmt.Println("log")
  28471. fmt.Println(string(userJSONBytes))
  28472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28473. utils.ErrorLog("解析失败:%v", err)
  28474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28475. return
  28476. }
  28477. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28478. bytesData, _ := json.Marshal(data)
  28479. var req *http.Request
  28480. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  28481. resp, _ := client.Do(req)
  28482. defer resp.Body.Close()
  28483. body, ioErr := ioutil.ReadAll(resp.Body)
  28484. if ioErr != nil {
  28485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28487. return
  28488. }
  28489. var respJSON map[string]interface{}
  28490. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28493. return
  28494. }
  28495. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28496. if status == "0" {
  28497. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28498. c.ServeSuccessJSON(map[string]interface{}{
  28499. "failed_code": -10,
  28500. "msg": err_msg,
  28501. })
  28502. return
  28503. }
  28504. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28505. userJSONBytes, _ := json.Marshal(respJSON)
  28506. fmt.Println("log")
  28507. fmt.Println(string(userJSONBytes))
  28508. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28509. utils.ErrorLog("解析失败:%v", err)
  28510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28511. return
  28512. }
  28513. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28514. 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, "", "")
  28515. var dat map[string]interface{}
  28516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28517. fmt.Println(dat)
  28518. } else {
  28519. fmt.Println(err)
  28520. }
  28521. saveLog(result, request_log, "2204", "上传费用明细")
  28522. userJSONBytes, _ := json.Marshal(dat)
  28523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28524. utils.ErrorLog("解析失败:%v", err)
  28525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28526. return
  28527. }
  28528. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28529. bytesData, _ := json.Marshal(data)
  28530. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  28531. resp, _ := client.Do(req)
  28532. defer resp.Body.Close()
  28533. body, ioErr := ioutil.ReadAll(resp.Body)
  28534. if ioErr != nil {
  28535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28537. return
  28538. }
  28539. var respJSON map[string]interface{}
  28540. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28543. return
  28544. }
  28545. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28546. userJSONBytes, _ := json.Marshal(respJSON)
  28547. fmt.Println("log")
  28548. fmt.Println(string(userJSONBytes))
  28549. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28550. utils.ErrorLog("解析失败:%v", err)
  28551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28552. return
  28553. }
  28554. } else {
  28555. if miConfig.MdtrtareaAdmvs == "441202" {
  28556. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28557. if result3101.Infcode == 0 {
  28558. if len(result3101.Output.Result) > 0 {
  28559. var errMsgs []string
  28560. for _, item := range result3101.Output.Result {
  28561. errMsgs = append(errMsgs, item.VolaCont)
  28562. }
  28563. c.ServeSuccessJSON(map[string]interface{}{
  28564. "failed_code": -10,
  28565. "msg": errMsgs,
  28566. })
  28567. return
  28568. } else {
  28569. 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)
  28570. var dat map[string]interface{}
  28571. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28572. fmt.Println(dat)
  28573. } else {
  28574. fmt.Println(err)
  28575. }
  28576. saveLog(result, request_log, "2204", "上传费用明细")
  28577. userJSONBytes, _ := json.Marshal(dat)
  28578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28579. utils.ErrorLog("解析失败:%v", err)
  28580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28581. return
  28582. }
  28583. }
  28584. } else {
  28585. c.ServeSuccessJSON(map[string]interface{}{
  28586. "failed_code": -10,
  28587. "msg": result3101.ErrMsg,
  28588. })
  28589. return
  28590. }
  28591. } else if miConfig.MdtrtareaAdmvs == "440205" {
  28592. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28593. if result3101.Infcode == 0 {
  28594. if len(result3101.Output.Result) > 0 {
  28595. var errMsgs []string
  28596. for _, item := range result3101.Output.Result {
  28597. errMsgs = append(errMsgs, item.VolaCont)
  28598. }
  28599. c.ServeSuccessJSON(map[string]interface{}{
  28600. "failed_code": -10,
  28601. "msg": errMsgs,
  28602. })
  28603. return
  28604. } else {
  28605. 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)
  28606. var dat map[string]interface{}
  28607. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28608. fmt.Println(dat)
  28609. } else {
  28610. fmt.Println(err)
  28611. }
  28612. saveLog(result, request_log, "2204", "上传费用明细")
  28613. userJSONBytes, _ := json.Marshal(dat)
  28614. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28615. utils.ErrorLog("解析失败:%v", err)
  28616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28617. return
  28618. }
  28619. }
  28620. } else {
  28621. c.ServeSuccessJSON(map[string]interface{}{
  28622. "failed_code": -10,
  28623. "msg": result3101.ErrMsg,
  28624. })
  28625. return
  28626. }
  28627. } else {
  28628. if miConfig.Code == "H15049901371" {
  28629. 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)
  28630. var dat map[string]interface{}
  28631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28632. fmt.Println(dat)
  28633. } else {
  28634. fmt.Println(err)
  28635. }
  28636. saveLog(result, request_log, "2204", "上传费用明细")
  28637. userJSONBytes, _ := json.Marshal(dat)
  28638. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28639. utils.ErrorLog("解析失败:%v", err)
  28640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28641. return
  28642. }
  28643. res.InfRefmsgid = resFour10265.InfRefmsgid
  28644. res.Output = resFour10265.Output
  28645. res.ErrMsg = resFour10265.ErrMsg
  28646. res.Cainfo = resFour10265.Cainfo
  28647. res.WarnMsg = resFour10265.WarnMsg
  28648. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28649. res.Infcode = infocode
  28650. } else {
  28651. 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)
  28652. var dat map[string]interface{}
  28653. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28654. fmt.Println(dat)
  28655. } else {
  28656. fmt.Println(err)
  28657. }
  28658. saveLog(result, request_log, "2204", "上传费用明细")
  28659. userJSONBytes, _ := json.Marshal(dat)
  28660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28661. utils.ErrorLog("解析失败:%v", err)
  28662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28663. return
  28664. }
  28665. }
  28666. }
  28667. }
  28668. var total_two float64
  28669. if res.Infcode == -1 {
  28670. errlog := &models.HisOrderError{
  28671. UserOrgId: adminUser.CurrentOrgId,
  28672. Ctime: time.Now().Unix(),
  28673. Mtime: time.Now().Unix(),
  28674. Number: chrg_bchno,
  28675. ErrMsg: res.ErrMsg,
  28676. Status: 1,
  28677. PatientId: id,
  28678. RecordTime: recordDateTime,
  28679. Stage: 4,
  28680. }
  28681. service.CreateErrMsgLog(errlog)
  28682. c.ServeSuccessJSON(map[string]interface{}{
  28683. "failed_code": -10,
  28684. "msg": res.ErrMsg,
  28685. })
  28686. return
  28687. }
  28688. if res.Infcode == 0 {
  28689. order := &models.HisOrder{
  28690. UserOrgId: adminUser.CurrentOrgId,
  28691. HisPatientId: his.ID,
  28692. PatientId: his.PatientId,
  28693. SettleAccountsDate: recordDateTime,
  28694. Ctime: time.Now().Unix(),
  28695. Mtime: time.Now().Unix(),
  28696. MdtrtId: his.Number,
  28697. PsnNo: his.PsnNo,
  28698. MedType: strconv.FormatInt(reg_type, 10),
  28699. Status: 1,
  28700. Number: chrg_bchno,
  28701. Infcode: res.Infcode,
  28702. WarnMsg: res.WarnMsg,
  28703. Cainfo: res.Cainfo,
  28704. ErrMsg: res.ErrMsg,
  28705. RespondTime: res.RefmsgTime,
  28706. InfRefmsgid: res.InfRefmsgid,
  28707. OrderStatus: 1,
  28708. IsMedicineInsurance: 1,
  28709. SettleType: settle_accounts_type,
  28710. SettleStartTime: start_time,
  28711. SettleEndTime: end_time,
  28712. Creator: roles.AdminUserId,
  28713. Modify: roles.AdminUserId,
  28714. PType: 2,
  28715. Diagnosis: diagnosis_id,
  28716. }
  28717. err = service.CreateOrder(order)
  28718. if err != nil {
  28719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  28720. return
  28721. }
  28722. for _, item := range res.Output.Result {
  28723. temp := strings.Split(item.FeedetlSn, "-")
  28724. var advice_id int64 = 0
  28725. var project_id int64 = 0
  28726. var types int64 = 0
  28727. id, _ := strconv.ParseInt(temp[2], 10, 64)
  28728. types, _ = strconv.ParseInt(temp[1], 10, 64)
  28729. if temp[1] == "1" {
  28730. advice_id = id
  28731. project_id = 0
  28732. } else if temp[1] == "2" {
  28733. advice_id = 0
  28734. project_id = id
  28735. }
  28736. total_two = total_two + item.DetItemFeeSumamt
  28737. info := &models.HisOrderInfo{
  28738. OrderNumber: order.Number,
  28739. FeedetlSn: item.FeedetlSn,
  28740. UploadDate: time.Now().Unix(),
  28741. AdviceId: advice_id,
  28742. DetItemFeeSumamt: item.DetItemFeeSumamt,
  28743. Cnt: item.Cnt,
  28744. Pric: float64(item.Pric),
  28745. PatientId: his.PatientId,
  28746. PricUplmtAmt: item.PricUplmtAmt,
  28747. SelfpayProp: item.SelfpayProp,
  28748. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  28749. OverlmtAmt: item.OverlmtAmt,
  28750. PreselfpayAmt: item.PreselfpayAmt,
  28751. BasMednFlag: item.BasMednFlag,
  28752. MedChrgitmType: item.MedChrgitmType,
  28753. HiNegoDrugFlag: item.HiNegoDrugFlag,
  28754. Status: 1,
  28755. Memo: item.Memo,
  28756. Mtime: time.Now().Unix(),
  28757. InscpScpAmt: item.InscpScpAmt,
  28758. DrtReimFlag: item.DrtReimFlag,
  28759. Ctime: time.Now().Unix(),
  28760. ListSpItemFlag: item.ListSpItemFlag,
  28761. ChldMedcFlag: item.ChldMedcFlag,
  28762. LmtUsedFlag: item.LmtUsedFlag,
  28763. ChrgitmLv: item.ChrgitmLv,
  28764. UserOrgId: adminUser.CurrentOrgId,
  28765. HisPatientId: his.ID,
  28766. OrderId: order.ID,
  28767. ProjectId: project_id,
  28768. Type: types,
  28769. }
  28770. service.CreateOrderInfo(info)
  28771. }
  28772. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  28773. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  28774. var total float64
  28775. for _, item := range prescriptions {
  28776. if item.Type == 1 { //药品
  28777. for _, subItem := range item.HisDoctorAdviceInfo {
  28778. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  28779. total_one := price * subItem.PrescribingNumber
  28780. fmt.Println("subItem")
  28781. fmt.Println(subItem.Price)
  28782. fmt.Println("price")
  28783. fmt.Println(price)
  28784. fmt.Println("total_one")
  28785. fmt.Println(total_one)
  28786. total = total + total_one
  28787. fmt.Println(total)
  28788. }
  28789. }
  28790. if item.Type == 2 { //项目
  28791. for _, subItem := range item.HisPrescriptionProject {
  28792. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  28793. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  28794. total_one := price * cnt
  28795. total = total + total_one
  28796. }
  28797. }
  28798. }
  28799. allTotal := fmt.Sprintf("%.2f", total)
  28800. if res.Infcode == 0 {
  28801. var rf []*ResultFive
  28802. json.Unmarshal([]byte(his.Iinfo), &rf)
  28803. chrg_bchno := chrg_bchno
  28804. cert_no := his.Certno
  28805. var insutypes []string
  28806. var insutype string
  28807. var is390 int = 0
  28808. var is310 int = 0
  28809. for _, item := range rf {
  28810. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28811. insutypes = append(insutypes, item.Insutype)
  28812. }
  28813. }
  28814. if len(insutypes) == 1 {
  28815. insutype = insutypes[0]
  28816. } else {
  28817. for _, i := range insutypes {
  28818. if i == "390" {
  28819. is390 = 1
  28820. }
  28821. if i == "310" {
  28822. is310 = 1
  28823. }
  28824. }
  28825. }
  28826. if is390 == 1 {
  28827. insutype = "390"
  28828. }
  28829. if is310 == 1 {
  28830. insutype = "310"
  28831. }
  28832. if len(insutypes) == 0 {
  28833. insutype = "390"
  28834. }
  28835. if len(insutypes) == 2 {
  28836. insutype = strconv.FormatInt(his.SocialType, 10)
  28837. }
  28838. //insutype = "390"
  28839. if his.IdCardType == 1 {
  28840. cert_no = his.MedicalInsuranceNumber
  28841. } else {
  28842. cert_no = his.Certno
  28843. }
  28844. var res ResultSeven
  28845. var ahres ResultSevenAH
  28846. var resSeven10265 ResultSeven10265
  28847. var resSeven10265Two ResultSeven10265Two
  28848. var gzresSeven10265Two GZResultSeven10265Two
  28849. if miConfig.MdtrtareaAdmvs == "421300" {
  28850. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  28851. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28852. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28853. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28854. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28855. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28856. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28857. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  28858. resp, requestErr := http.Get(api)
  28859. if requestErr != nil {
  28860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28861. return
  28862. }
  28863. body, ioErr := ioutil.ReadAll(resp.Body)
  28864. if ioErr != nil {
  28865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28867. return
  28868. }
  28869. var respJSON map[string]interface{}
  28870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28873. return
  28874. }
  28875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28876. result, _ := json.Marshal(respJSON)
  28877. fmt.Println("log")
  28878. fmt.Println(string(result))
  28879. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28880. utils.ErrorLog("解析失败:%v", err)
  28881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28882. return
  28883. }
  28884. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28885. if reg_type == 11 && his.Insutype == "390" {
  28886. reg_type = 110104
  28887. }
  28888. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28889. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28890. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28891. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28892. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28893. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28894. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  28895. resp, requestErr := http.Get(api)
  28896. if requestErr != nil {
  28897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28898. return
  28899. }
  28900. body, ioErr := ioutil.ReadAll(resp.Body)
  28901. if ioErr != nil {
  28902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28904. return
  28905. }
  28906. var respJSON map[string]interface{}
  28907. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28910. return
  28911. }
  28912. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28913. result, _ := json.Marshal(respJSON)
  28914. fmt.Println("log")
  28915. fmt.Println(string(result))
  28916. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28917. utils.ErrorLog("解析失败:%v", err)
  28918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28919. return
  28920. }
  28921. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28922. if reg_type == 11 && his.Insutype == "390" {
  28923. reg_type = 110104
  28924. }
  28925. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28926. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28927. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28928. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28929. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28930. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28931. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  28932. resp, requestErr := http.Get(api)
  28933. if requestErr != nil {
  28934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28935. return
  28936. }
  28937. body, ioErr := ioutil.ReadAll(resp.Body)
  28938. if ioErr != nil {
  28939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28941. return
  28942. }
  28943. var respJSON map[string]interface{}
  28944. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28947. return
  28948. }
  28949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28950. result, _ := json.Marshal(respJSON)
  28951. fmt.Println("log")
  28952. fmt.Println(string(result))
  28953. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28954. utils.ErrorLog("解析失败:%v", err)
  28955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28956. return
  28957. }
  28958. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28959. if reg_type == 11 && his.Insutype == "390" {
  28960. reg_type = 110104
  28961. }
  28962. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28963. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28964. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28965. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28966. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28967. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28968. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  28969. resp, requestErr := http.Get(api)
  28970. if requestErr != nil {
  28971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28972. return
  28973. }
  28974. body, ioErr := ioutil.ReadAll(resp.Body)
  28975. if ioErr != nil {
  28976. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28978. return
  28979. }
  28980. var respJSON map[string]interface{}
  28981. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28984. return
  28985. }
  28986. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28987. result, _ := json.Marshal(respJSON)
  28988. fmt.Println("log")
  28989. fmt.Println(string(result))
  28990. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28991. utils.ErrorLog("解析失败:%v", err)
  28992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28993. return
  28994. }
  28995. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28996. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  28997. if result3101.Infcode == "0" {
  28998. if len(result3101.Output.Result) > 0 {
  28999. var errMsgs []string
  29000. for _, item := range result3101.Output.Result {
  29001. errMsgs = append(errMsgs, item.VolaCont)
  29002. }
  29003. c.ServeSuccessJSON(map[string]interface{}{
  29004. "failed_code": -10,
  29005. "msg": errMsgs,
  29006. })
  29007. return
  29008. } else {
  29009. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29010. if his.IdCardType != 4 {
  29011. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29012. bas := strings.Split(psn_info.CardInfo, "|")
  29013. if his.IdCardType == 1 {
  29014. cert_no = bas[2]
  29015. } else {
  29016. cert_no = bas[1]
  29017. }
  29018. } else {
  29019. cert_no = his.Certno
  29020. }
  29021. //江苏地区国家医保医疗类别
  29022. //职工透析:医疗类别选特殊情况门诊9933
  29023. //居民血透门慢: 医疗类别选门诊慢病1402
  29024. //var med_type string
  29025. //if his.Insutype == "310" {
  29026. // if reg_type == 14 {
  29027. // med_type = "9933"
  29028. // } else if reg_type == 11 {
  29029. // med_type = "11"
  29030. //
  29031. // }
  29032. //} else if his.Insutype == "390" {
  29033. // if reg_type == 14 {
  29034. // med_type = "1402"
  29035. // } else if reg_type == 11 {
  29036. // med_type = "11"
  29037. // }
  29038. //}
  29039. var api string
  29040. if miConfig.MdtrtareaAdmvs == "320921" {
  29041. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29042. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29043. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29044. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29045. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29046. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29047. "&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
  29048. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29049. } else {
  29050. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29051. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29052. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29053. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29054. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29055. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29056. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29057. "&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
  29058. }
  29059. resp, requestErr := http.Get(api)
  29060. if requestErr != nil {
  29061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29062. return
  29063. }
  29064. body, ioErr := ioutil.ReadAll(resp.Body)
  29065. if ioErr != nil {
  29066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29068. return
  29069. }
  29070. var respJSON map[string]interface{}
  29071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29074. return
  29075. }
  29076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29077. result, _ := json.Marshal(respJSON)
  29078. fmt.Println("log")
  29079. fmt.Println(string(result))
  29080. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29081. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29082. utils.ErrorLog("解析失败:%v", err)
  29083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29084. return
  29085. }
  29086. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29087. res.Output = resSeven10265.Output
  29088. res.ErrMsg = resSeven10265.ErrMsg
  29089. res.Cainfo = resSeven10265.Cainfo
  29090. res.WarnMsg = resSeven10265.WarnMsg
  29091. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29092. res.Infcode = infocode
  29093. } else {
  29094. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29095. utils.ErrorLog("解析失败:%v", err)
  29096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29097. return
  29098. }
  29099. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29100. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29101. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29102. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29103. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29104. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29105. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29106. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29107. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29108. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29109. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29110. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29111. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29112. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29113. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29114. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29115. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29116. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29117. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29118. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29119. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29120. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29121. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29122. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29123. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29124. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29125. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29126. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29127. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29128. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29129. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29130. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29131. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29132. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29133. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29134. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29135. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29136. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29137. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29138. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29139. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  29140. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  29141. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  29142. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  29143. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  29144. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  29145. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  29146. res.ErrMsg = resSeven10265Two.ErrMsg
  29147. res.Cainfo = resSeven10265Two.Cainfo
  29148. res.WarnMsg = resSeven10265Two.WarnMsg
  29149. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29150. res.Infcode = infocode
  29151. }
  29152. }
  29153. }
  29154. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29155. psn_info, _ := service.GetPsnByPatientId(id)
  29156. var verify_number string
  29157. if psn_info.IdCardType == 4 {
  29158. verify_number = psn_info.VerifyNumber
  29159. } else if psn_info.IdCardType == 1 {
  29160. bas := strings.Split(psn_info.CardInfo, "|")
  29161. cardNumber := bas[2]
  29162. verify_number = cardNumber
  29163. } else {
  29164. psn_info.IdCardType = 2
  29165. verify_number = psn_info.Certno
  29166. }
  29167. var api string
  29168. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29169. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  29170. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29171. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29172. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29173. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29174. "&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
  29175. resp, requestErr := http.Get(api)
  29176. if requestErr != nil {
  29177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29178. return
  29179. }
  29180. body, ioErr := ioutil.ReadAll(resp.Body)
  29181. if ioErr != nil {
  29182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29184. return
  29185. }
  29186. var respJSON map[string]interface{}
  29187. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29190. return
  29191. }
  29192. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29193. result, _ := json.Marshal(respJSON)
  29194. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29195. utils.ErrorLog("解析失败:%v", err)
  29196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29197. return
  29198. }
  29199. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29200. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  29201. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  29202. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29203. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  29204. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  29205. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  29206. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  29207. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  29208. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  29209. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  29210. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  29211. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  29212. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29213. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  29214. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  29215. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  29216. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  29217. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  29218. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  29219. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29220. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  29221. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  29222. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  29223. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  29224. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  29225. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  29226. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  29227. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  29228. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  29229. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  29230. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  29231. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  29232. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  29233. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29234. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  29235. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  29236. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  29237. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  29238. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  29239. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  29240. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  29241. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  29242. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  29243. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  29244. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  29245. res.ErrMsg = resSeven10265.ErrMsg
  29246. res.Cainfo = resSeven10265.Cainfo
  29247. res.WarnMsg = resSeven10265.WarnMsg
  29248. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29249. res.Infcode = infocode
  29250. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29251. acct_used_flag := "1"
  29252. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  29253. var result string
  29254. var request_log string
  29255. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  29256. 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)
  29257. } else {
  29258. 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)
  29259. }
  29260. var dat map[string]interface{}
  29261. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29262. fmt.Println(dat)
  29263. } else {
  29264. fmt.Println(err)
  29265. }
  29266. saveLog(result, request_log, "2206", "预结算")
  29267. userJSONBytes, _ := json.Marshal(dat)
  29268. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29269. utils.ErrorLog("解析失败:%v", err)
  29270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29271. return
  29272. }
  29273. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29274. var result string
  29275. var request_log string
  29276. if his.IdCardType == 2 {
  29277. 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, "")
  29278. } else if his.IdCardType == 1 {
  29279. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29280. bas := strings.Split(psn_info.CardInfo, "|")
  29281. basNumber := bas[2]
  29282. card_sn := bas[3]
  29283. var rf []*ResultFive
  29284. json.Unmarshal([]byte(his.Iinfo), &rf)
  29285. var psn_type string
  29286. for _, item := range rf {
  29287. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29288. psn_type = item.PsnType
  29289. }
  29290. }
  29291. 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)
  29292. } else {
  29293. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29294. //bas := strings.Split(psn_info.CardInfo, "|")
  29295. //basNumber := bas[2]
  29296. //card_sn := bas[3]
  29297. var rf []*ResultFive
  29298. json.Unmarshal([]byte(his.Iinfo), &rf)
  29299. var psn_type string
  29300. for _, item := range rf {
  29301. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29302. psn_type = item.PsnType
  29303. }
  29304. }
  29305. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29306. 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, psn_info.VerifyNumber, "", "", his.PsnCertType, his.Certno, psn_type, his.PsnName)
  29307. }
  29308. var dat map[string]interface{}
  29309. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29310. fmt.Println(dat)
  29311. } else {
  29312. fmt.Println(err)
  29313. }
  29314. saveLog(result, request_log, "2206", "预结算")
  29315. userJSONBytes, _ := json.Marshal(dat)
  29316. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29317. utils.ErrorLog("解析失败:%v", err)
  29318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29319. return
  29320. }
  29321. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29322. var result string
  29323. var request_log string
  29324. if his.IdCardType == 2 {
  29325. 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, "")
  29326. } else if his.IdCardType == 1 {
  29327. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29328. bas := strings.Split(psn_info.CardInfo, "|")
  29329. basNumber := bas[0]
  29330. card_sn := ""
  29331. var rf []*ResultFive
  29332. json.Unmarshal([]byte(his.Iinfo), &rf)
  29333. var psn_type string
  29334. for _, item := range rf {
  29335. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29336. psn_type = item.PsnType
  29337. }
  29338. }
  29339. 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)
  29340. } else {
  29341. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29342. //bas := strings.Split(psn_info.CardInfo, "|")
  29343. //basNumber := bas[2]
  29344. //card_sn := bas[3]
  29345. var rf []*ResultFive
  29346. json.Unmarshal([]byte(his.Iinfo), &rf)
  29347. var psn_type string
  29348. for _, item := range rf {
  29349. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29350. psn_type = item.PsnType
  29351. }
  29352. }
  29353. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29354. 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, psn_info.VerifyNumber, "", "", his.PsnCertType, his.Certno, psn_type, his.PsnName)
  29355. }
  29356. var dat map[string]interface{}
  29357. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29358. fmt.Println(dat)
  29359. } else {
  29360. fmt.Println(err)
  29361. }
  29362. saveLog(result, request_log, "2206", "预结算")
  29363. userJSONBytes, _ := json.Marshal(dat)
  29364. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29365. utils.ErrorLog("解析失败:%v", err)
  29366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29367. return
  29368. }
  29369. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29370. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29371. if his.IdCardType == 4 {
  29372. psn_info.VerifyNumber = psn_info.VerifyNumber
  29373. cert_no = psn_info.Certno
  29374. } else if his.IdCardType == 2 {
  29375. cert_no = psn_info.Certno
  29376. psn_info.VerifyNumber = psn_info.Certno
  29377. } else {
  29378. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29379. bas := strings.Split(psn_info.CardInfo, "|")
  29380. if his.IdCardType == 1 {
  29381. cert_no = bas[2]
  29382. } else {
  29383. cert_no = bas[1]
  29384. }
  29385. }
  29386. var api string
  29387. var med_type string
  29388. if his.Insutype == "390" {
  29389. if reg_type == 992102 {
  29390. med_type = "992102"
  29391. }
  29392. if reg_type == 140104 {
  29393. med_type = "140104"
  29394. }
  29395. if reg_type == 14 {
  29396. med_type = "140104"
  29397. }
  29398. } else if his.Insutype == "310" {
  29399. if reg_type == 992102 {
  29400. med_type = "992102"
  29401. }
  29402. if reg_type == 14 {
  29403. med_type = "14"
  29404. }
  29405. }
  29406. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29407. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29408. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29409. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29410. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29411. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29412. "&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
  29413. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29414. resp, requestErr := http.Get(api)
  29415. if requestErr != nil {
  29416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29417. return
  29418. }
  29419. body, ioErr := ioutil.ReadAll(resp.Body)
  29420. if ioErr != nil {
  29421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29423. return
  29424. }
  29425. var respJSON map[string]interface{}
  29426. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29429. return
  29430. }
  29431. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29432. if status == "0" {
  29433. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29434. c.ServeSuccessJSON(map[string]interface{}{
  29435. "failed_code": -10,
  29436. "msg": err_msg,
  29437. })
  29438. return
  29439. }
  29440. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29441. result, _ := json.Marshal(respJSON)
  29442. fmt.Println("log")
  29443. fmt.Println(string(result))
  29444. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  29445. utils.ErrorLog("解析失败:%v", err)
  29446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29447. return
  29448. }
  29449. res.InfRefmsgid = ahres.InfRefmsgid
  29450. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29451. // 创建对应的Time类型
  29452. t := time.UnixMilli(timestamp)
  29453. // 格式化成指定的日期字符串
  29454. str := t.Format("2006-01-02 15:04:05")
  29455. res.Output.Setlinfo.SetlTime = str
  29456. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29457. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29458. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29459. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29460. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29461. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29462. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29463. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29464. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29465. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  29466. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29467. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29468. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29469. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29470. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29471. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29472. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29473. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29474. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29475. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29476. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29477. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29478. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29479. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29480. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29481. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29482. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29483. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29484. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29485. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29486. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29487. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29488. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29489. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29490. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29491. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29492. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29493. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29494. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29495. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29496. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29497. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29498. //res.Output.Setldetail = ahres.Output.Setldetail
  29499. res.ErrMsg = ahres.ErrMsg
  29500. res.Cainfo = ahres.Cainfo
  29501. res.WarnMsg = ahres.WarnMsg
  29502. res.Infcode = ahres.Infcode
  29503. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29504. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29505. if his.IdCardType == 4 {
  29506. psn_info.VerifyNumber = psn_info.VerifyNumber
  29507. cert_no = psn_info.Certno
  29508. } else if his.IdCardType == 2 {
  29509. cert_no = psn_info.Certno
  29510. psn_info.VerifyNumber = psn_info.Certno
  29511. } else {
  29512. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29513. bas := strings.Split(psn_info.CardInfo, "|")
  29514. if his.IdCardType == 1 {
  29515. cert_no = bas[2]
  29516. } else {
  29517. cert_no = bas[1]
  29518. }
  29519. }
  29520. var api string
  29521. var med_type string
  29522. if his.Insutype == "390" {
  29523. if reg_type == 992102 {
  29524. med_type = "992102"
  29525. }
  29526. if reg_type == 140104 {
  29527. med_type = "140104"
  29528. }
  29529. if reg_type == 14 {
  29530. med_type = "140104"
  29531. }
  29532. } else if his.Insutype == "310" {
  29533. if reg_type == 992102 {
  29534. med_type = "992102"
  29535. }
  29536. if reg_type == 14 {
  29537. med_type = "14"
  29538. }
  29539. }
  29540. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29541. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29542. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29543. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29544. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29545. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29546. "&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
  29547. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29548. resp, requestErr := http.Get(api)
  29549. if requestErr != nil {
  29550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29551. return
  29552. }
  29553. body, ioErr := ioutil.ReadAll(resp.Body)
  29554. if ioErr != nil {
  29555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29557. return
  29558. }
  29559. var respJSON map[string]interface{}
  29560. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29563. return
  29564. }
  29565. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29566. if status == "0" {
  29567. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29568. c.ServeSuccessJSON(map[string]interface{}{
  29569. "failed_code": -10,
  29570. "msg": err_msg,
  29571. })
  29572. return
  29573. }
  29574. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29575. result, _ := json.Marshal(respJSON)
  29576. fmt.Println("log")
  29577. fmt.Println(string(result))
  29578. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  29579. utils.ErrorLog("解析失败:%v", err)
  29580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29581. return
  29582. }
  29583. res.InfRefmsgid = ahres.InfRefmsgid
  29584. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29585. // 创建对应的Time类型
  29586. t := time.UnixMilli(timestamp)
  29587. // 格式化成指定的日期字符串
  29588. str := t.Format("2006-01-02 15:04:05")
  29589. res.Output.Setlinfo.SetlTime = str
  29590. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29591. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29592. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29593. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29594. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29595. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29596. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29597. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29598. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29599. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  29600. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29601. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29602. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29603. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29604. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29605. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29606. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29607. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29608. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29609. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29610. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29611. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29612. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29613. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29614. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29615. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29616. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29617. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29618. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29619. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29620. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29621. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29622. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29623. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29624. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29625. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29626. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29627. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29628. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29629. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29630. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29631. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29632. //res.Output.Setldetail = ahres.Output.Setldetail
  29633. res.ErrMsg = ahres.ErrMsg
  29634. res.Cainfo = ahres.Cainfo
  29635. res.WarnMsg = ahres.WarnMsg
  29636. res.Infcode = ahres.Infcode
  29637. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29638. var result string
  29639. var request_log string
  29640. if his.IdCardType == 2 {
  29641. 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")
  29642. } else if his.IdCardType == 1 {
  29643. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29644. bas := strings.Split(psn_info.CardInfo, "|")
  29645. basNumber := bas[2]
  29646. card_sn := bas[3]
  29647. 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")
  29648. } else {
  29649. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29650. 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")
  29651. }
  29652. var dat map[string]interface{}
  29653. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29654. fmt.Println(dat)
  29655. } else {
  29656. fmt.Println(err)
  29657. }
  29658. saveLog(result, request_log, "2206", "预结算")
  29659. userJSONBytes, _ := json.Marshal(dat)
  29660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29661. utils.ErrorLog("解析失败:%v", err)
  29662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29663. return
  29664. }
  29665. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29666. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29667. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29668. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29669. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29670. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29671. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29672. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29673. resp, requestErr := http.Get(api)
  29674. if requestErr != nil {
  29675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29676. return
  29677. }
  29678. body, ioErr := ioutil.ReadAll(resp.Body)
  29679. if ioErr != nil {
  29680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29682. return
  29683. }
  29684. var respJSON map[string]interface{}
  29685. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29688. return
  29689. }
  29690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29691. result, _ := json.Marshal(respJSON)
  29692. fmt.Println("log")
  29693. fmt.Println(string(result))
  29694. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29695. utils.ErrorLog("解析失败:%v", err)
  29696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29697. return
  29698. }
  29699. } else {
  29700. if miConfig.MdtrtareaAdmvs == "441202" {
  29701. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29702. if result3101.Infcode == 0 {
  29703. if len(result3101.Output.Result) > 0 {
  29704. var errMsgs []string
  29705. for _, item := range result3101.Output.Result {
  29706. errMsgs = append(errMsgs, item.VolaCont)
  29707. }
  29708. c.ServeSuccessJSON(map[string]interface{}{
  29709. "failed_code": -10,
  29710. "msg": errMsgs,
  29711. })
  29712. return
  29713. } else {
  29714. var result string
  29715. var request_log string
  29716. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29717. allTotal = fmt.Sprintf("%.2f", total_two)
  29718. if his.IdCardType == 4 {
  29719. 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)
  29720. } else {
  29721. 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)
  29722. }
  29723. var dat map[string]interface{}
  29724. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29725. fmt.Println(dat)
  29726. } else {
  29727. fmt.Println(err)
  29728. }
  29729. saveLog(result, request_log, "2206", "预结算")
  29730. //userJSONBytes, _ := json.Marshal(dat)
  29731. //
  29732. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29733. // utils.ErrorLog("解析失败:%v", err)
  29734. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29735. // return
  29736. //}
  29737. userJSONBytes, _ := json.Marshal(dat)
  29738. if miConfig.Code == "H15049901371" {
  29739. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29740. utils.ErrorLog("解析失败:%v", err)
  29741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29742. return
  29743. }
  29744. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29745. res.Output = resSeven10265.Output
  29746. res.ErrMsg = resSeven10265.ErrMsg
  29747. res.Cainfo = resSeven10265.Cainfo
  29748. res.WarnMsg = resSeven10265.WarnMsg
  29749. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29750. res.Infcode = infocode
  29751. } else {
  29752. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29753. utils.ErrorLog("解析失败:%v", err)
  29754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29755. return
  29756. }
  29757. }
  29758. }
  29759. } else {
  29760. c.ServeSuccessJSON(map[string]interface{}{
  29761. "failed_code": -10,
  29762. "msg": result3101.ErrMsg,
  29763. })
  29764. return
  29765. }
  29766. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29767. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29768. if result3101.Infcode == 0 {
  29769. if len(result3101.Output.Result) > 0 {
  29770. var errMsgs []string
  29771. for _, item := range result3101.Output.Result {
  29772. errMsgs = append(errMsgs, item.VolaCont)
  29773. }
  29774. c.ServeSuccessJSON(map[string]interface{}{
  29775. "failed_code": -10,
  29776. "msg": errMsgs,
  29777. })
  29778. return
  29779. } else {
  29780. var result string
  29781. var request_log string
  29782. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29783. allTotal = fmt.Sprintf("%.2f", total_two)
  29784. if his.IdCardType == 4 {
  29785. 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)
  29786. } else {
  29787. 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)
  29788. }
  29789. var dat map[string]interface{}
  29790. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29791. fmt.Println(dat)
  29792. } else {
  29793. fmt.Println(err)
  29794. }
  29795. saveLog(result, request_log, "2206", "预结算")
  29796. //userJSONBytes, _ := json.Marshal(dat)
  29797. //
  29798. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29799. // utils.ErrorLog("解析失败:%v", err)
  29800. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29801. // return
  29802. //}
  29803. userJSONBytes, _ := json.Marshal(dat)
  29804. if miConfig.Code == "H15049901371" {
  29805. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29806. utils.ErrorLog("解析失败:%v", err)
  29807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29808. return
  29809. }
  29810. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29811. res.Output = resSeven10265.Output
  29812. res.ErrMsg = resSeven10265.ErrMsg
  29813. res.Cainfo = resSeven10265.Cainfo
  29814. res.WarnMsg = resSeven10265.WarnMsg
  29815. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29816. res.Infcode = infocode
  29817. } else {
  29818. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29819. utils.ErrorLog("解析失败:%v", err)
  29820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29821. return
  29822. }
  29823. }
  29824. }
  29825. } else {
  29826. c.ServeSuccessJSON(map[string]interface{}{
  29827. "failed_code": -10,
  29828. "msg": result3101.ErrMsg,
  29829. })
  29830. return
  29831. }
  29832. } else {
  29833. var result string
  29834. var request_log string
  29835. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29836. allTotal = fmt.Sprintf("%.2f", total_two)
  29837. if his.IdCardType == 4 {
  29838. 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)
  29839. } else {
  29840. 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)
  29841. }
  29842. var dat map[string]interface{}
  29843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29844. fmt.Println(dat)
  29845. } else {
  29846. fmt.Println(err)
  29847. }
  29848. saveLog(result, request_log, "2206", "预结算")
  29849. //userJSONBytes, _ := json.Marshal(dat)
  29850. //
  29851. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29852. // utils.ErrorLog("解析失败:%v", err)
  29853. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29854. // return
  29855. //}
  29856. userJSONBytes, _ := json.Marshal(dat)
  29857. if miConfig.Code == "H15049901371" {
  29858. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29859. utils.ErrorLog("解析失败:%v", err)
  29860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29861. return
  29862. }
  29863. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29864. res.Output = resSeven10265.Output
  29865. res.ErrMsg = resSeven10265.ErrMsg
  29866. res.Cainfo = resSeven10265.Cainfo
  29867. res.WarnMsg = resSeven10265.WarnMsg
  29868. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29869. res.Infcode = infocode
  29870. } else {
  29871. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29872. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29873. utils.ErrorLog("解析失败:%v", err)
  29874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29875. return
  29876. }
  29877. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29878. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29879. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29880. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29881. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29882. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29883. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29884. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29885. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29886. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29887. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29888. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29889. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29890. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29891. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29892. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29893. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29894. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29895. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29896. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29897. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29898. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29899. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29900. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29901. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29902. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29903. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29904. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29905. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29906. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29907. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29908. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29909. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29910. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29911. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29912. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29913. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29914. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29915. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29916. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29917. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29918. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29919. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29920. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29921. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29922. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29923. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29924. res.Cainfo = gzresSeven10265Two.Cainfo
  29925. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29926. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29927. //res.Infcode = infocode
  29928. } else {
  29929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29930. utils.ErrorLog("解析失败:%v", err)
  29931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29932. return
  29933. }
  29934. }
  29935. }
  29936. }
  29937. }
  29938. utils.ErrorLog("解析失败:%v", res.Infcode)
  29939. if res.Infcode == -1 {
  29940. errlog := &models.HisOrderError{
  29941. UserOrgId: adminUser.CurrentOrgId,
  29942. Ctime: time.Now().Unix(),
  29943. Mtime: time.Now().Unix(),
  29944. Number: chrg_bchno,
  29945. ErrMsg: res.ErrMsg,
  29946. Status: 1,
  29947. PatientId: id,
  29948. RecordTime: recordDateTime,
  29949. Stage: 20,
  29950. }
  29951. service.CreateErrMsgLog(errlog)
  29952. c.ServeSuccessJSON(map[string]interface{}{
  29953. "failed_code": -10,
  29954. "msg": res.ErrMsg,
  29955. })
  29956. return
  29957. }
  29958. if res.Infcode != 0 {
  29959. errlog := &models.HisOrderError{
  29960. UserOrgId: adminUser.CurrentOrgId,
  29961. Ctime: time.Now().Unix(),
  29962. Mtime: time.Now().Unix(),
  29963. Number: chrg_bchno,
  29964. ErrMsg: res.ErrMsg,
  29965. Status: 1,
  29966. PatientId: id,
  29967. RecordTime: recordDateTime,
  29968. Stage: 20,
  29969. }
  29970. service.CreateErrMsgLog(errlog)
  29971. c.ServeSuccessJSON(map[string]interface{}{
  29972. "failed_code": -10,
  29973. "msg": res.ErrMsg,
  29974. })
  29975. return
  29976. } else {
  29977. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29978. order.OrderStatus = 1
  29979. order.IsPre = 1
  29980. order.Status = 1
  29981. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29982. order.SetlId = res.Output.Setlinfo.SetlID
  29983. order.PsnNo = res.Output.Setlinfo.PsnNo
  29984. order.PsnName = res.Output.Setlinfo.PsnName
  29985. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29986. order.Certno = res.Output.Setlinfo.Certno
  29987. order.Gend = res.Output.Setlinfo.Gend
  29988. order.Naty = res.Output.Setlinfo.Naty
  29989. order.Age = res.Output.Setlinfo.Age
  29990. order.Insutype = res.Output.Setlinfo.Insutype
  29991. order.PsnType = res.Output.Setlinfo.PsnType
  29992. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29993. order.SetlTime = res.Output.Setlinfo.SetlTime
  29994. order.AcctUsedFlag = acct_used_flag
  29995. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29996. if res.Output.Setlinfo.MedType == "140101" {
  29997. order.MedType = "14"
  29998. } else {
  29999. if res.Output.Setlinfo.MedType == "110104" {
  30000. order.MedType = "11"
  30001. } else {
  30002. order.MedType = res.Output.Setlinfo.MedType
  30003. }
  30004. }
  30005. if res.Output.Setlinfo.MedType == "992102" {
  30006. order.MedType = "992102"
  30007. }
  30008. if res.Output.Setlinfo.MedType == "140104" {
  30009. order.MedType = "140104"
  30010. }
  30011. if res.Output.Setlinfo.MedType == "14" {
  30012. order.MedType = "14"
  30013. }
  30014. if reg_type == 1112 {
  30015. order.MedType = "1112"
  30016. }
  30017. if reg_type == 1111 {
  30018. order.MedType = "1111"
  30019. }
  30020. order.ClrType = res.Output.Setlinfo.ClrType
  30021. if adminUser.CurrentOrgId == 10480 {
  30022. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30023. order.ClrType = "11"
  30024. } else {
  30025. order.ClrType = "9903"
  30026. }
  30027. }
  30028. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30029. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30030. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30031. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30032. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30033. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30034. order.HifpPay = res.Output.Setlinfo.HifpPay
  30035. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30036. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30037. order.HifesPay = res.Output.Setlinfo.HifesPay
  30038. order.HifobPay = res.Output.Setlinfo.HifobPay
  30039. order.MafPay = res.Output.Setlinfo.MafPay
  30040. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30041. order.OthPay = res.Output.Setlinfo.OthPay
  30042. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30043. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30044. order.AcctPay = res.Output.Setlinfo.AcctPay
  30045. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30046. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30047. order.Balc = res.Output.Setlinfo.Balc
  30048. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30049. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30050. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30051. order.ClrWay = res.Output.Setlinfo.ClrWay
  30052. order.Creator = order.Creator
  30053. order.Modify = roles.AdminUserId
  30054. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30055. //detailStr := string(setlDetail)
  30056. //order.SetlDetail = detailStr
  30057. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30058. err = service.UpDateOrder(order)
  30059. if err == nil {
  30060. c.ServeSuccessJSON(map[string]interface{}{
  30061. "msg": "预结算成功",
  30062. })
  30063. } else {
  30064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30065. return
  30066. }
  30067. }
  30068. } else {
  30069. adminUser := c.GetAdminUserInfo()
  30070. errlog := &models.HisOrderError{
  30071. UserOrgId: adminUser.CurrentOrgId,
  30072. Ctime: time.Now().Unix(),
  30073. Mtime: time.Now().Unix(),
  30074. ErrMsg: res.ErrMsg,
  30075. Status: 1,
  30076. PatientId: id,
  30077. RecordTime: recordDateTime,
  30078. Stage: 4,
  30079. }
  30080. service.CreateErrMsgLog(errlog)
  30081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  30082. return
  30083. }
  30084. } else {
  30085. if miConfig.MdtrtareaAdmvs == "150499" {
  30086. order := &models.HisOrder{
  30087. UserOrgId: adminUser.CurrentOrgId,
  30088. HisPatientId: his.ID,
  30089. PatientId: his.PatientId,
  30090. SettleAccountsDate: recordDateTime,
  30091. Ctime: time.Now().Unix(),
  30092. Mtime: time.Now().Unix(),
  30093. MdtrtId: his.Number,
  30094. PsnNo: his.PsnNo,
  30095. MedType: strconv.FormatInt(reg_type, 10),
  30096. Status: 1,
  30097. Number: chrg_bchno,
  30098. Infcode: res.Infcode,
  30099. WarnMsg: res.WarnMsg,
  30100. Cainfo: res.Cainfo,
  30101. ErrMsg: res.ErrMsg,
  30102. RespondTime: res.RefmsgTime,
  30103. InfRefmsgid: res.InfRefmsgid,
  30104. OrderStatus: 1,
  30105. IsMedicineInsurance: 1,
  30106. SettleType: settle_accounts_type,
  30107. SettleStartTime: start_time,
  30108. SettleEndTime: end_time,
  30109. Creator: roles.AdminUserId,
  30110. Modify: roles.AdminUserId,
  30111. PType: 2,
  30112. Diagnosis: diagnosis_id,
  30113. }
  30114. err = service.CreateOrder(order)
  30115. if err != nil {
  30116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30117. return
  30118. }
  30119. }
  30120. adminUser := c.GetAdminUserInfo()
  30121. errlog := &models.HisOrderError{
  30122. UserOrgId: adminUser.CurrentOrgId,
  30123. Ctime: time.Now().Unix(),
  30124. Mtime: time.Now().Unix(),
  30125. ErrMsg: res.ErrMsg,
  30126. Status: 1,
  30127. PatientId: id,
  30128. RecordTime: recordDateTime,
  30129. Stage: 4,
  30130. }
  30131. service.CreateErrMsgLog(errlog)
  30132. c.ServeSuccessJSON(map[string]interface{}{
  30133. "failed_code": -10,
  30134. "msg": res.ErrMsg,
  30135. })
  30136. return
  30137. }
  30138. }
  30139. }
  30140. }
  30141. // 退款
  30142. func (c *HisApiController) Refund() {
  30143. order_id, _ := c.GetInt64("order_id")
  30144. admin_user_id, _ := c.GetInt64("admin_user_id")
  30145. adminUser := c.GetAdminUserInfo()
  30146. var order models.HisOrder
  30147. order, _ = service.GetHisOrderByID(order_id)
  30148. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  30149. if fapiao.ID > 0 {
  30150. c.ServeSuccessJSON(map[string]interface{}{
  30151. "failed_code": -10,
  30152. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  30153. })
  30154. return
  30155. }
  30156. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30157. if order.ID == 0 {
  30158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30159. return
  30160. }
  30161. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30162. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30163. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30164. if config.IsOpen == 1 { //对接了医保,走医保流程
  30165. var res ResultSixteen
  30166. var ahres ResultSevenAH
  30167. var resSixteen10265 ResultSixteen10265
  30168. var resSixteen10265Two ResultSixteen10265Two
  30169. var gz ResultgzSixteen10265Two
  30170. var src_resquest string
  30171. var result string
  30172. if miConfig.MdtrtareaAdmvs == "421300" {
  30173. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30174. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30175. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30176. resp3, requestErr3 := http.Get(api3)
  30177. if requestErr3 != nil {
  30178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30179. return
  30180. }
  30181. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30182. if ioErr3 != nil {
  30183. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30185. return
  30186. }
  30187. var respJSON3 map[string]interface{}
  30188. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30191. return
  30192. }
  30193. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30194. userJSONBytes3, _ := json.Marshal(respJSON3)
  30195. fmt.Println("log")
  30196. fmt.Println(string(userJSONBytes3))
  30197. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30198. utils.ErrorLog("解析失败:%v", err)
  30199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30200. return
  30201. }
  30202. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30203. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30204. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30205. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30206. resp3, requestErr3 := http.Get(api3)
  30207. if requestErr3 != nil {
  30208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30209. return
  30210. }
  30211. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30212. if ioErr3 != nil {
  30213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30215. return
  30216. }
  30217. var respJSON3 map[string]interface{}
  30218. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30221. return
  30222. }
  30223. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30224. userJSONBytes3, _ := json.Marshal(respJSON3)
  30225. fmt.Println("log")
  30226. fmt.Println(string(userJSONBytes3))
  30227. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30228. utils.ErrorLog("解析失败:%v", err)
  30229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30230. return
  30231. }
  30232. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30233. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  30234. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30235. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30236. resp3, requestErr3 := http.Get(api3)
  30237. if requestErr3 != nil {
  30238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30239. return
  30240. }
  30241. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30242. if ioErr3 != nil {
  30243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30245. return
  30246. }
  30247. var respJSON3 map[string]interface{}
  30248. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30251. return
  30252. }
  30253. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30254. userJSONBytes3, _ := json.Marshal(respJSON3)
  30255. fmt.Println("log")
  30256. fmt.Println(string(userJSONBytes3))
  30257. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30258. utils.ErrorLog("解析失败:%v", err)
  30259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30260. return
  30261. }
  30262. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30263. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  30264. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30265. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30266. resp3, requestErr3 := http.Get(api3)
  30267. if requestErr3 != nil {
  30268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30269. return
  30270. }
  30271. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30272. if ioErr3 != nil {
  30273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30275. return
  30276. }
  30277. var respJSON3 map[string]interface{}
  30278. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30281. return
  30282. }
  30283. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30284. userJSONBytes3, _ := json.Marshal(respJSON3)
  30285. fmt.Println("log")
  30286. fmt.Println(string(userJSONBytes3))
  30287. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30288. utils.ErrorLog("解析失败:%v", err)
  30289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30290. return
  30291. }
  30292. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30293. var api3 string
  30294. if miConfig.MdtrtareaAdmvs == "320921" {
  30295. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  30296. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30297. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30298. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30299. } else {
  30300. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30301. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  30302. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30303. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30304. }
  30305. resp3, requestErr3 := http.Get(api3)
  30306. if requestErr3 != nil {
  30307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30308. return
  30309. }
  30310. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30311. if ioErr3 != nil {
  30312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30314. return
  30315. }
  30316. var respJSON3 map[string]interface{}
  30317. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30320. return
  30321. }
  30322. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30323. userJSONBytes3, _ := json.Marshal(respJSON3)
  30324. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  30325. utils.ErrorLog("解析失败:%v", err)
  30326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30327. return
  30328. }
  30329. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  30330. res.Output = resSixteen10265.Output
  30331. res.ErrMsg = resSixteen10265.ErrMsg
  30332. res.Cainfo = resSixteen10265.Cainfo
  30333. res.WarnMsg = resSixteen10265.WarnMsg
  30334. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  30335. res.Infcode = infocode
  30336. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30337. var api3 string
  30338. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  30339. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30340. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30341. resp3, requestErr3 := http.Get(api3)
  30342. if requestErr3 != nil {
  30343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30344. return
  30345. }
  30346. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30347. if ioErr3 != nil {
  30348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30350. return
  30351. }
  30352. var respJSON3 map[string]interface{}
  30353. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30356. return
  30357. }
  30358. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30359. userJSONBytes3, _ := json.Marshal(respJSON3)
  30360. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  30361. utils.ErrorLog("解析失败:%v", err)
  30362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30363. return
  30364. }
  30365. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  30366. res.Output = resSixteen10265.Output
  30367. res.ErrMsg = resSixteen10265.ErrMsg
  30368. res.Cainfo = resSixteen10265.Cainfo
  30369. res.WarnMsg = resSixteen10265.WarnMsg
  30370. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  30371. res.Infcode = infocode
  30372. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30373. 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)
  30374. var dat map[string]interface{}
  30375. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30376. fmt.Println(dat)
  30377. } else {
  30378. fmt.Println(err)
  30379. }
  30380. saveLog(result, src_resquest, "2208", "退费")
  30381. userJSONBytes, _ := json.Marshal(dat)
  30382. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30383. utils.ErrorLog("解析失败:%v", err)
  30384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30385. return
  30386. }
  30387. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30388. 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, "")
  30389. var dat map[string]interface{}
  30390. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30391. fmt.Println(dat)
  30392. } else {
  30393. fmt.Println(err)
  30394. }
  30395. saveLog(result, src_resquest, "2208", "退费")
  30396. userJSONBytes, _ := json.Marshal(dat)
  30397. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30398. utils.ErrorLog("解析失败:%v", err)
  30399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30400. return
  30401. }
  30402. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30403. 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, "")
  30404. var dat map[string]interface{}
  30405. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30406. fmt.Println(dat)
  30407. } else {
  30408. fmt.Println(err)
  30409. }
  30410. saveLog(result, src_resquest, "2208", "退费")
  30411. userJSONBytes, _ := json.Marshal(dat)
  30412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30413. utils.ErrorLog("解析失败:%v", err)
  30414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30415. return
  30416. }
  30417. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30418. var api3 string
  30419. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  30420. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30421. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30422. resp3, requestErr3 := http.Get(api3)
  30423. if requestErr3 != nil {
  30424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30425. return
  30426. }
  30427. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30428. if ioErr3 != nil {
  30429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30431. return
  30432. }
  30433. var respJSON3 map[string]interface{}
  30434. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30437. return
  30438. }
  30439. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  30440. if status == "0" {
  30441. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  30442. c.ServeSuccessJSON(map[string]interface{}{
  30443. "failed_code": -10,
  30444. "msg": err_msg,
  30445. })
  30446. return
  30447. }
  30448. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30449. userJSONBytes3, _ := json.Marshal(respJSON3)
  30450. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30451. // utils.ErrorLog("解析失败:%v", err)
  30452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30453. // return
  30454. //}
  30455. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  30456. utils.ErrorLog("解析失败:%v", err)
  30457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30458. return
  30459. }
  30460. res.InfRefmsgid = ahres.InfRefmsgid
  30461. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30462. // 创建对应的Time类型
  30463. t := time.UnixMilli(timestamp)
  30464. // 格式化成指定的日期字符串
  30465. str := t.Format("2006-01-02 15:04:05")
  30466. res.Output.Setlinfo.SetlTime = str
  30467. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30468. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30469. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30470. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30471. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30472. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30473. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30474. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30475. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30476. //
  30477. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30478. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30479. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30480. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30481. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30482. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30483. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30484. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30485. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30486. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30487. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30488. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30489. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30490. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30491. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30492. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30493. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30494. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30495. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30496. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30497. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30498. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30499. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30500. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30501. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30502. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30503. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30504. //res.Output.Setldetail = ahres.Output.Setldetail
  30505. res.ErrMsg = ahres.ErrMsg
  30506. res.Cainfo = ahres.Cainfo
  30507. res.WarnMsg = ahres.WarnMsg
  30508. res.Infcode = ahres.Infcode
  30509. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30510. var api3 string
  30511. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  30512. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30513. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30514. resp3, requestErr3 := http.Get(api3)
  30515. if requestErr3 != nil {
  30516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30517. return
  30518. }
  30519. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30520. if ioErr3 != nil {
  30521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30523. return
  30524. }
  30525. var respJSON3 map[string]interface{}
  30526. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30529. return
  30530. }
  30531. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  30532. if status == "0" {
  30533. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  30534. c.ServeSuccessJSON(map[string]interface{}{
  30535. "failed_code": -10,
  30536. "msg": err_msg,
  30537. })
  30538. return
  30539. }
  30540. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30541. userJSONBytes3, _ := json.Marshal(respJSON3)
  30542. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30543. // utils.ErrorLog("解析失败:%v", err)
  30544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30545. // return
  30546. //}
  30547. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  30548. utils.ErrorLog("解析失败:%v", err)
  30549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30550. return
  30551. }
  30552. res.InfRefmsgid = ahres.InfRefmsgid
  30553. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30554. // 创建对应的Time类型
  30555. t := time.UnixMilli(timestamp)
  30556. // 格式化成指定的日期字符串
  30557. str := t.Format("2006-01-02 15:04:05")
  30558. res.Output.Setlinfo.SetlTime = str
  30559. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30560. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30561. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30562. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30563. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30564. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30565. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30566. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30567. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30568. //
  30569. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30570. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30571. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30572. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30573. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30574. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30575. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30576. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30577. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30578. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30579. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30580. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30581. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30582. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30583. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30584. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30585. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30586. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30587. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30588. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30589. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30590. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30591. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30592. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30593. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30594. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30595. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30596. //res.Output.Setldetail = ahres.Output.Setldetail
  30597. res.ErrMsg = ahres.ErrMsg
  30598. res.Cainfo = ahres.Cainfo
  30599. res.WarnMsg = ahres.WarnMsg
  30600. res.Infcode = ahres.Infcode
  30601. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30602. 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, "")
  30603. var dat map[string]interface{}
  30604. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30605. fmt.Println(dat)
  30606. } else {
  30607. fmt.Println(err)
  30608. }
  30609. saveLog(result, src_resquest, "2208", "退费")
  30610. userJSONBytes, _ := json.Marshal(dat)
  30611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30612. utils.ErrorLog("解析失败:%v", err)
  30613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30614. return
  30615. }
  30616. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30617. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  30618. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30619. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30620. resp3, requestErr3 := http.Get(api3)
  30621. if requestErr3 != nil {
  30622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30623. return
  30624. }
  30625. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30626. if ioErr3 != nil {
  30627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30629. return
  30630. }
  30631. var respJSON3 map[string]interface{}
  30632. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30635. return
  30636. }
  30637. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30638. userJSONBytes3, _ := json.Marshal(respJSON3)
  30639. fmt.Println("log")
  30640. fmt.Println(string(userJSONBytes3))
  30641. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30642. utils.ErrorLog("解析失败:%v", err)
  30643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30644. return
  30645. }
  30646. } else {
  30647. if miConfig.Code == "H15049901371" {
  30648. 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)
  30649. var dat map[string]interface{}
  30650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30651. fmt.Println(dat)
  30652. } else {
  30653. fmt.Println(err)
  30654. }
  30655. saveLog(result, src_resquest, "2208", "退费")
  30656. if strings.Contains(result, "Post") {
  30657. res.Infcode = -1
  30658. res.ErrMsg = result
  30659. }
  30660. userJSONBytes, _ := json.Marshal(dat)
  30661. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  30662. utils.ErrorLog("解析失败:%v", err)
  30663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30664. return
  30665. }
  30666. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  30667. res.Output = resSixteen10265.Output
  30668. res.ErrMsg = resSixteen10265.ErrMsg
  30669. res.Cainfo = resSixteen10265.Cainfo
  30670. res.WarnMsg = resSixteen10265.WarnMsg
  30671. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  30672. res.Infcode = infocode
  30673. } else {
  30674. 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)
  30675. var dat map[string]interface{}
  30676. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30677. fmt.Println(dat)
  30678. } else {
  30679. fmt.Println(err)
  30680. }
  30681. saveLog(result, src_resquest, "2208", "退费")
  30682. userJSONBytes, _ := json.Marshal(dat)
  30683. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30684. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  30685. utils.ErrorLog("解析失败:%v", err)
  30686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30687. return
  30688. }
  30689. res.Infcode = gz.Infcode
  30690. } else {
  30691. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30692. utils.ErrorLog("解析失败:%v", err)
  30693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30694. return
  30695. }
  30696. }
  30697. if strings.Contains(result, "Post") {
  30698. res.Infcode = -1
  30699. res.ErrMsg = result
  30700. }
  30701. }
  30702. }
  30703. if res.Infcode == -1 {
  30704. c.ServeSuccessJSON(map[string]interface{}{
  30705. "failed_code": -10,
  30706. "msg": res.ErrMsg,
  30707. })
  30708. return
  30709. }
  30710. if res.Infcode != -1 {
  30711. var res2 ResultSix
  30712. var resSix10265 ResultSix10265
  30713. if miConfig.MdtrtareaAdmvs == "421300" {
  30714. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  30715. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30716. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30717. resp3, requestErr3 := http.Get(api3)
  30718. if requestErr3 != nil {
  30719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30720. return
  30721. }
  30722. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30723. if ioErr3 != nil {
  30724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30726. return
  30727. }
  30728. var respJSON3 map[string]interface{}
  30729. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30732. return
  30733. }
  30734. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30735. userJSONBytes3, _ := json.Marshal(respJSON3)
  30736. fmt.Println("log")
  30737. fmt.Println(string(userJSONBytes3))
  30738. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30739. utils.ErrorLog("解析失败:%v", err)
  30740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30741. return
  30742. }
  30743. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30744. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  30745. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30746. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30747. resp3, requestErr3 := http.Get(api3)
  30748. if requestErr3 != nil {
  30749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30750. return
  30751. }
  30752. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30753. if ioErr3 != nil {
  30754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30756. return
  30757. }
  30758. var respJSON3 map[string]interface{}
  30759. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30762. return
  30763. }
  30764. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30765. userJSONBytes3, _ := json.Marshal(respJSON3)
  30766. fmt.Println("log")
  30767. fmt.Println(string(userJSONBytes3))
  30768. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30769. utils.ErrorLog("解析失败:%v", err)
  30770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30771. return
  30772. }
  30773. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30774. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  30775. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30776. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30777. resp3, requestErr3 := http.Get(api3)
  30778. if requestErr3 != nil {
  30779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30780. return
  30781. }
  30782. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30783. if ioErr3 != nil {
  30784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30786. return
  30787. }
  30788. var respJSON3 map[string]interface{}
  30789. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30792. return
  30793. }
  30794. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30795. userJSONBytes3, _ := json.Marshal(respJSON3)
  30796. fmt.Println("log")
  30797. fmt.Println(string(userJSONBytes3))
  30798. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30799. utils.ErrorLog("解析失败:%v", err)
  30800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30801. return
  30802. }
  30803. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30804. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  30805. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30806. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30807. resp3, requestErr3 := http.Get(api3)
  30808. if requestErr3 != nil {
  30809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30810. return
  30811. }
  30812. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30813. if ioErr3 != nil {
  30814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30816. return
  30817. }
  30818. var respJSON3 map[string]interface{}
  30819. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30822. return
  30823. }
  30824. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30825. userJSONBytes3, _ := json.Marshal(respJSON3)
  30826. fmt.Println("log")
  30827. fmt.Println(string(userJSONBytes3))
  30828. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30829. utils.ErrorLog("解析失败:%v", err)
  30830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30831. return
  30832. }
  30833. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30834. var api3 string
  30835. if miConfig.MdtrtareaAdmvs == "320921" {
  30836. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  30837. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30838. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30839. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30840. } else {
  30841. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30842. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  30843. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30844. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30845. }
  30846. resp3, requestErr3 := http.Get(api3)
  30847. if requestErr3 != nil {
  30848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30849. return
  30850. }
  30851. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30852. if ioErr3 != nil {
  30853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30855. return
  30856. }
  30857. var respJSON3 map[string]interface{}
  30858. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30861. return
  30862. }
  30863. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30864. userJSONBytes3, _ := json.Marshal(respJSON3)
  30865. fmt.Println("log")
  30866. fmt.Println(string(userJSONBytes3))
  30867. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  30868. utils.ErrorLog("解析失败:%v", err)
  30869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30870. return
  30871. }
  30872. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30873. res2.Output = resSix10265.Output
  30874. res2.ErrMsg = resSix10265.ErrMsg
  30875. res2.Cainfo = resSix10265.Cainfo
  30876. res2.WarnMsg = resSix10265.WarnMsg
  30877. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30878. res2.Infcode = infocode
  30879. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30880. var api3 string
  30881. new_chrg_bchno := order.Number
  30882. if adminUser.CurrentOrgId == 10265 {
  30883. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  30884. new_chrg_bchno = "0000"
  30885. }
  30886. }
  30887. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  30888. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30889. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30890. resp3, requestErr3 := http.Get(api3)
  30891. if requestErr3 != nil {
  30892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30893. return
  30894. }
  30895. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30896. if ioErr3 != nil {
  30897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30899. return
  30900. }
  30901. var respJSON3 map[string]interface{}
  30902. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30905. return
  30906. }
  30907. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30908. userJSONBytes3, _ := json.Marshal(respJSON3)
  30909. fmt.Println("log")
  30910. fmt.Println(string(userJSONBytes3))
  30911. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  30912. utils.ErrorLog("解析失败:%v", err)
  30913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30914. return
  30915. }
  30916. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30917. res2.Output = resSix10265.Output
  30918. res2.ErrMsg = resSix10265.ErrMsg
  30919. res2.Cainfo = resSix10265.Cainfo
  30920. res2.WarnMsg = resSix10265.WarnMsg
  30921. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30922. res2.Infcode = infocode
  30923. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30924. 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)
  30925. var dat map[string]interface{}
  30926. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30927. fmt.Println(dat)
  30928. } else {
  30929. fmt.Println(err)
  30930. }
  30931. saveLog(result2, src_request, "2205", "撤销明细")
  30932. userJSONBytes, _ := json.Marshal(dat)
  30933. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30934. utils.ErrorLog("解析失败:%v", err)
  30935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30936. return
  30937. }
  30938. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30939. 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, "")
  30940. var dat map[string]interface{}
  30941. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30942. fmt.Println(dat)
  30943. } else {
  30944. fmt.Println(err)
  30945. }
  30946. saveLog(result2, src_request, "2205", "撤销明细")
  30947. userJSONBytes, _ := json.Marshal(dat)
  30948. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30949. utils.ErrorLog("解析失败:%v", err)
  30950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30951. return
  30952. }
  30953. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30954. 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, "")
  30955. var dat map[string]interface{}
  30956. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30957. fmt.Println(dat)
  30958. } else {
  30959. fmt.Println(err)
  30960. }
  30961. saveLog(result2, src_request, "2205", "撤销明细")
  30962. userJSONBytes, _ := json.Marshal(dat)
  30963. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30964. utils.ErrorLog("解析失败:%v", err)
  30965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30966. return
  30967. }
  30968. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30969. var api3 string
  30970. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  30971. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30972. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30973. resp3, requestErr3 := http.Get(api3)
  30974. if requestErr3 != nil {
  30975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30976. return
  30977. }
  30978. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30979. if ioErr3 != nil {
  30980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30982. return
  30983. }
  30984. var respJSON3 map[string]interface{}
  30985. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30988. return
  30989. }
  30990. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  30991. if status == "0" {
  30992. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  30993. c.ServeSuccessJSON(map[string]interface{}{
  30994. "failed_code": -10,
  30995. "msg": err_msg,
  30996. })
  30997. return
  30998. }
  30999. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31000. userJSONBytes3, _ := json.Marshal(respJSON3)
  31001. fmt.Println("log")
  31002. fmt.Println(string(userJSONBytes3))
  31003. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31004. utils.ErrorLog("解析失败:%v", err)
  31005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31006. return
  31007. }
  31008. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31009. 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, "")
  31010. var dat map[string]interface{}
  31011. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31012. fmt.Println(dat)
  31013. } else {
  31014. fmt.Println(err)
  31015. }
  31016. saveLog(result2, src_request, "2205", "撤销明细")
  31017. userJSONBytes, _ := json.Marshal(dat)
  31018. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31019. utils.ErrorLog("解析失败:%v", err)
  31020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31021. return
  31022. }
  31023. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31024. 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, "")
  31025. var dat map[string]interface{}
  31026. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31027. fmt.Println(dat)
  31028. } else {
  31029. fmt.Println(err)
  31030. }
  31031. saveLog(result2, src_request, "2205", "撤销明细")
  31032. userJSONBytes, _ := json.Marshal(dat)
  31033. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31034. utils.ErrorLog("解析失败:%v", err)
  31035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31036. return
  31037. }
  31038. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31039. var api3 string
  31040. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31041. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31042. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31043. resp3, requestErr3 := http.Get(api3)
  31044. if requestErr3 != nil {
  31045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31046. return
  31047. }
  31048. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31049. if ioErr3 != nil {
  31050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31052. return
  31053. }
  31054. var respJSON3 map[string]interface{}
  31055. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31058. return
  31059. }
  31060. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31061. if status == "0" {
  31062. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31063. c.ServeSuccessJSON(map[string]interface{}{
  31064. "failed_code": -10,
  31065. "msg": err_msg,
  31066. })
  31067. return
  31068. }
  31069. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31070. userJSONBytes3, _ := json.Marshal(respJSON3)
  31071. fmt.Println("log")
  31072. fmt.Println(string(userJSONBytes3))
  31073. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31074. utils.ErrorLog("解析失败:%v", err)
  31075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31076. return
  31077. }
  31078. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31079. 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, "")
  31080. var dat map[string]interface{}
  31081. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31082. fmt.Println(dat)
  31083. } else {
  31084. fmt.Println(err)
  31085. }
  31086. saveLog(result2, src_request, "2205", "撤销明细")
  31087. userJSONBytes, _ := json.Marshal(dat)
  31088. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31089. utils.ErrorLog("解析失败:%v", err)
  31090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31091. return
  31092. }
  31093. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31094. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  31095. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31096. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31097. resp3, requestErr3 := http.Get(api3)
  31098. if requestErr3 != nil {
  31099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31100. return
  31101. }
  31102. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31103. if ioErr3 != nil {
  31104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31106. return
  31107. }
  31108. var respJSON3 map[string]interface{}
  31109. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31112. return
  31113. }
  31114. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31115. userJSONBytes3, _ := json.Marshal(respJSON3)
  31116. fmt.Println("log")
  31117. fmt.Println(string(userJSONBytes3))
  31118. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31119. utils.ErrorLog("解析失败:%v", err)
  31120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31121. return
  31122. }
  31123. } else {
  31124. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31125. res2.Infcode = 0
  31126. } else {
  31127. 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)
  31128. var dat map[string]interface{}
  31129. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31130. fmt.Println(dat)
  31131. } else {
  31132. fmt.Println(err)
  31133. }
  31134. saveLog(result2, src_request, "2205", "撤销明细")
  31135. userJSONBytes, _ := json.Marshal(dat)
  31136. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31137. utils.ErrorLog("解析失败:%v", err)
  31138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31139. return
  31140. }
  31141. }
  31142. }
  31143. if res2.Infcode == -1 {
  31144. c.ServeSuccessJSON(map[string]interface{}{
  31145. "failed_code": -10,
  31146. "msg": res2.ErrMsg,
  31147. })
  31148. return
  31149. }
  31150. if res2.Infcode == 0 {
  31151. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  31152. if err == nil {
  31153. //当押金不为零时产生退费记录
  31154. if order.Decimal != 0 {
  31155. tmp := strconv.FormatInt(order.ID, 10)
  31156. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  31157. if err != nil {
  31158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31159. return
  31160. }
  31161. }
  31162. c.ServeSuccessJSON(map[string]interface{}{
  31163. "msg": "退费成功",
  31164. })
  31165. } else {
  31166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31167. return
  31168. }
  31169. } else {
  31170. c.ServeSuccessJSON(map[string]interface{}{
  31171. "failed_code": -10,
  31172. "msg": res2.ErrMsg,
  31173. })
  31174. }
  31175. } else {
  31176. c.ServeSuccessJSON(map[string]interface{}{
  31177. "failed_code": -10,
  31178. "msg": res.ErrMsg,
  31179. })
  31180. }
  31181. }
  31182. }
  31183. func (c *HisApiController) RefundNumber() {
  31184. record_time := c.GetString("record_time")
  31185. //patient_id, _ := c.GetInt64("patient_id")
  31186. admin_user_id, _ := c.GetInt64("admin_user_id")
  31187. his_patient_id, _ := c.GetInt64("id")
  31188. timeLayout := "2006-01-02"
  31189. loc, _ := time.LoadLocation("Local")
  31190. adminUser := c.GetAdminUserInfo()
  31191. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31192. fmt.Println(err)
  31193. if err != nil {
  31194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31195. return
  31196. }
  31197. recordDateTime := theTime.Unix()
  31198. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31199. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  31200. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31201. //order, _ := service.GetHisOrderByID(order_id)
  31202. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31203. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31204. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31205. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  31206. if count > 0 {
  31207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  31208. return
  31209. }
  31210. if config.IsOpen == 1 { //对接了医保,走医保流程
  31211. var res2 ResultSix
  31212. var res3 GZResultSix
  31213. var resSix10265 ResultSix10265
  31214. if miConfig.MdtrtareaAdmvs == "421300" {
  31215. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  31216. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31217. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31218. resp3, requestErr3 := http.Get(api3)
  31219. if requestErr3 != nil {
  31220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31221. return
  31222. }
  31223. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31224. if ioErr3 != nil {
  31225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31227. return
  31228. }
  31229. var respJSON3 map[string]interface{}
  31230. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31233. return
  31234. }
  31235. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31236. userJSONBytes3, _ := json.Marshal(respJSON3)
  31237. fmt.Println("log")
  31238. fmt.Println(string(userJSONBytes3))
  31239. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31240. utils.ErrorLog("解析失败:%v", err)
  31241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31242. return
  31243. }
  31244. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31245. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  31246. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31247. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31248. resp3, requestErr3 := http.Get(api3)
  31249. if requestErr3 != nil {
  31250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31251. return
  31252. }
  31253. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31254. if ioErr3 != nil {
  31255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31257. return
  31258. }
  31259. var respJSON3 map[string]interface{}
  31260. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31263. return
  31264. }
  31265. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31266. userJSONBytes3, _ := json.Marshal(respJSON3)
  31267. fmt.Println("log")
  31268. fmt.Println(string(userJSONBytes3))
  31269. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31270. utils.ErrorLog("解析失败:%v", err)
  31271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31272. return
  31273. }
  31274. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31275. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  31276. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31277. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31278. resp3, requestErr3 := http.Get(api3)
  31279. if requestErr3 != nil {
  31280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31281. return
  31282. }
  31283. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31284. if ioErr3 != nil {
  31285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31287. return
  31288. }
  31289. var respJSON3 map[string]interface{}
  31290. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31293. return
  31294. }
  31295. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31296. userJSONBytes3, _ := json.Marshal(respJSON3)
  31297. fmt.Println("log")
  31298. fmt.Println(string(userJSONBytes3))
  31299. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31300. utils.ErrorLog("解析失败:%v", err)
  31301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31302. return
  31303. }
  31304. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31305. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  31306. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31307. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31308. resp3, requestErr3 := http.Get(api3)
  31309. if requestErr3 != nil {
  31310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31311. return
  31312. }
  31313. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31314. if ioErr3 != nil {
  31315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31317. return
  31318. }
  31319. var respJSON3 map[string]interface{}
  31320. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31323. return
  31324. }
  31325. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31326. userJSONBytes3, _ := json.Marshal(respJSON3)
  31327. fmt.Println("log")
  31328. fmt.Println(string(userJSONBytes3))
  31329. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31330. utils.ErrorLog("解析失败:%v", err)
  31331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31332. return
  31333. }
  31334. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31335. var api3 string
  31336. if miConfig.MdtrtareaAdmvs == "320921" {
  31337. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  31338. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31339. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31340. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31341. } else {
  31342. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31343. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  31344. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31345. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31346. }
  31347. resp3, requestErr3 := http.Get(api3)
  31348. if requestErr3 != nil {
  31349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31350. return
  31351. }
  31352. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31353. if ioErr3 != nil {
  31354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31356. return
  31357. }
  31358. var respJSON3 map[string]interface{}
  31359. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31362. return
  31363. }
  31364. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31365. userJSONBytes3, _ := json.Marshal(respJSON3)
  31366. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31367. utils.ErrorLog("解析失败:%v", err)
  31368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31369. return
  31370. }
  31371. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31372. res2.Output = resSix10265.Output
  31373. res2.ErrMsg = resSix10265.ErrMsg
  31374. res2.Cainfo = resSix10265.Cainfo
  31375. res2.WarnMsg = resSix10265.WarnMsg
  31376. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31377. res2.Infcode = infocode
  31378. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31379. var api3 string
  31380. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  31381. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31382. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31383. resp3, requestErr3 := http.Get(api3)
  31384. if requestErr3 != nil {
  31385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31386. return
  31387. }
  31388. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31389. if ioErr3 != nil {
  31390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31392. return
  31393. }
  31394. var respJSON3 map[string]interface{}
  31395. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31398. return
  31399. }
  31400. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31401. userJSONBytes3, _ := json.Marshal(respJSON3)
  31402. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31403. utils.ErrorLog("解析失败:%v", err)
  31404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31405. return
  31406. }
  31407. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31408. res2.Output = resSix10265.Output
  31409. res2.ErrMsg = resSix10265.ErrMsg
  31410. res2.Cainfo = resSix10265.Cainfo
  31411. res2.WarnMsg = resSix10265.WarnMsg
  31412. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31413. res2.Infcode = infocode
  31414. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31415. 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)
  31416. var dat map[string]interface{}
  31417. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31418. fmt.Println(dat)
  31419. } else {
  31420. fmt.Println(err)
  31421. }
  31422. saveLog(result, request, "2202", "退号")
  31423. userJSONBytes, _ := json.Marshal(dat)
  31424. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31425. utils.ErrorLog("解析失败:%v", err)
  31426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31427. return
  31428. }
  31429. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31430. 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, "")
  31431. var dat map[string]interface{}
  31432. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31433. fmt.Println(dat)
  31434. } else {
  31435. fmt.Println(err)
  31436. }
  31437. saveLog(result, request, "2202", "退号")
  31438. userJSONBytes, _ := json.Marshal(dat)
  31439. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31440. utils.ErrorLog("解析失败:%v", err)
  31441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31442. return
  31443. }
  31444. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31445. 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, "")
  31446. var dat map[string]interface{}
  31447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31448. fmt.Println(dat)
  31449. } else {
  31450. fmt.Println(err)
  31451. }
  31452. saveLog(result, request, "2202", "退号")
  31453. userJSONBytes, _ := json.Marshal(dat)
  31454. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31455. utils.ErrorLog("解析失败:%v", err)
  31456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31457. return
  31458. }
  31459. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31460. var api3 string
  31461. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  31462. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31463. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31464. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31465. resp3, requestErr3 := http.Get(api3)
  31466. if requestErr3 != nil {
  31467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31468. return
  31469. }
  31470. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31471. if ioErr3 != nil {
  31472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31474. return
  31475. }
  31476. var respJSON3 map[string]interface{}
  31477. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31480. return
  31481. }
  31482. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31483. if status == "0" {
  31484. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31485. c.ServeSuccessJSON(map[string]interface{}{
  31486. "failed_code": -10,
  31487. "msg": err_msg,
  31488. })
  31489. return
  31490. }
  31491. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31492. userJSONBytes3, _ := json.Marshal(respJSON3)
  31493. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31494. utils.ErrorLog("解析失败:%v", err)
  31495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31496. return
  31497. }
  31498. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  31499. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31500. var api3 string
  31501. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  31502. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31503. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31504. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31505. resp3, requestErr3 := http.Get(api3)
  31506. if requestErr3 != nil {
  31507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31508. return
  31509. }
  31510. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31511. if ioErr3 != nil {
  31512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31514. return
  31515. }
  31516. var respJSON3 map[string]interface{}
  31517. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31520. return
  31521. }
  31522. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31523. if status == "0" {
  31524. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31525. c.ServeSuccessJSON(map[string]interface{}{
  31526. "failed_code": -10,
  31527. "msg": err_msg,
  31528. })
  31529. return
  31530. }
  31531. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31532. userJSONBytes3, _ := json.Marshal(respJSON3)
  31533. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31534. utils.ErrorLog("解析失败:%v", err)
  31535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31536. return
  31537. }
  31538. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  31539. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31540. 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, "")
  31541. var dat map[string]interface{}
  31542. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31543. fmt.Println(dat)
  31544. } else {
  31545. fmt.Println(err)
  31546. }
  31547. saveLog(result, request, "2202", "退号")
  31548. userJSONBytes, _ := json.Marshal(dat)
  31549. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31550. utils.ErrorLog("解析失败:%v", err)
  31551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31552. return
  31553. }
  31554. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31555. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  31556. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31557. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  31558. resp3, requestErr3 := http.Get(api3)
  31559. if requestErr3 != nil {
  31560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31561. return
  31562. }
  31563. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31564. if ioErr3 != nil {
  31565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31567. return
  31568. }
  31569. var respJSON3 map[string]interface{}
  31570. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31573. return
  31574. }
  31575. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31576. userJSONBytes3, _ := json.Marshal(respJSON3)
  31577. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31578. utils.ErrorLog("解析失败:%v", err)
  31579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31580. return
  31581. }
  31582. } else {
  31583. var api3 string
  31584. if miConfig.Code == "H15049901371" {
  31585. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  31586. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31587. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31588. } else {
  31589. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  31590. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31591. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  31592. }
  31593. resp3, requestErr3 := http.Get(api3)
  31594. if requestErr3 != nil {
  31595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31596. return
  31597. }
  31598. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31599. if ioErr3 != nil {
  31600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31602. return
  31603. }
  31604. var respJSON3 map[string]interface{}
  31605. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31608. return
  31609. }
  31610. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31611. userJSONBytes3, _ := json.Marshal(respJSON3)
  31612. if miConfig.Code == "H15049901371" {
  31613. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31614. utils.ErrorLog("解析失败:%v", err)
  31615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31616. return
  31617. }
  31618. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31619. res2.Output = resSix10265.Output
  31620. res2.ErrMsg = resSix10265.ErrMsg
  31621. res2.Cainfo = resSix10265.Cainfo
  31622. res2.WarnMsg = resSix10265.WarnMsg
  31623. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31624. res2.Infcode = infocode
  31625. } else {
  31626. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31627. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  31628. utils.ErrorLog("解析失败:%v", err)
  31629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31630. return
  31631. }
  31632. res2.Infcode = res3.Infcode
  31633. } else {
  31634. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31635. utils.ErrorLog("解析失败:%v", err)
  31636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31637. return
  31638. }
  31639. }
  31640. }
  31641. }
  31642. if res2.Infcode == -1 {
  31643. c.ServeSuccessJSON(map[string]interface{}{
  31644. "failed_code": -10,
  31645. "msg": res2.ErrMsg,
  31646. })
  31647. return
  31648. }
  31649. if res2.Infcode == 0 {
  31650. if err == nil {
  31651. c.ServeSuccessJSON(map[string]interface{}{
  31652. "msg": "退号成功",
  31653. })
  31654. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  31655. } else {
  31656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31657. return
  31658. }
  31659. }
  31660. } else {
  31661. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  31662. //if err == nil {
  31663. // c.ServeSuccessJSON(map[string]interface{}{
  31664. // "msg": "退费成功",
  31665. // })
  31666. //} else {
  31667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31668. // return
  31669. //}
  31670. }
  31671. }
  31672. func (c *HisApiController) RefundDetail() {
  31673. order_id, _ := c.GetInt64("order_id")
  31674. admin_user_id, _ := c.GetInt64("admin_user_id")
  31675. //his_patient_id, _ := c.GetInt64("his_patient_id")
  31676. number := c.GetString("number")
  31677. record_time := c.GetString("record_time")
  31678. patient_id, _ := c.GetInt64("patient_id")
  31679. //med_type, _ := c.GetInt64("med_type")
  31680. timeLayout := "2006-01-02"
  31681. loc, _ := time.LoadLocation("Local")
  31682. adminUser := c.GetAdminUserInfo()
  31683. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31684. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31685. fmt.Println(err)
  31686. if err != nil {
  31687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31688. return
  31689. }
  31690. recordDateTime := theTime.Unix()
  31691. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  31692. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31693. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31694. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31695. var order models.HisOrder
  31696. order, _ = service.GetHisOrderByID(order_id)
  31697. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31698. if config.IsOpen == 1 { //对接了医保,走医保流程
  31699. var res2 ResultSix
  31700. if miConfig.MdtrtareaAdmvs == "421300" {
  31701. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31702. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31703. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31704. resp3, requestErr3 := http.Get(api3)
  31705. if requestErr3 != nil {
  31706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31707. return
  31708. }
  31709. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31710. if ioErr3 != nil {
  31711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31713. return
  31714. }
  31715. var respJSON3 map[string]interface{}
  31716. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31719. return
  31720. }
  31721. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31722. userJSONBytes3, _ := json.Marshal(respJSON3)
  31723. fmt.Println("log")
  31724. fmt.Println(string(userJSONBytes3))
  31725. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31726. utils.ErrorLog("解析失败:%v", err)
  31727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31728. return
  31729. }
  31730. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31731. if err == nil {
  31732. c.ServeSuccessJSON(map[string]interface{}{
  31733. "msg": "撤销明细成功",
  31734. })
  31735. return
  31736. } else {
  31737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31738. return
  31739. }
  31740. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31741. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31742. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31743. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31744. resp3, requestErr3 := http.Get(api3)
  31745. if requestErr3 != nil {
  31746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31747. return
  31748. }
  31749. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31750. if ioErr3 != nil {
  31751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31753. return
  31754. }
  31755. var respJSON3 map[string]interface{}
  31756. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31759. return
  31760. }
  31761. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31762. userJSONBytes3, _ := json.Marshal(respJSON3)
  31763. fmt.Println("log")
  31764. fmt.Println(string(userJSONBytes3))
  31765. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31766. utils.ErrorLog("解析失败:%v", err)
  31767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31768. return
  31769. }
  31770. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31771. if err == nil {
  31772. c.ServeSuccessJSON(map[string]interface{}{
  31773. "msg": "撤销明细成功",
  31774. })
  31775. return
  31776. } else {
  31777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31778. return
  31779. }
  31780. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31781. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31782. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31783. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31784. resp3, requestErr3 := http.Get(api3)
  31785. if requestErr3 != nil {
  31786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31787. return
  31788. }
  31789. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31790. if ioErr3 != nil {
  31791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31793. return
  31794. }
  31795. var respJSON3 map[string]interface{}
  31796. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31799. return
  31800. }
  31801. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31802. userJSONBytes3, _ := json.Marshal(respJSON3)
  31803. fmt.Println("log")
  31804. fmt.Println(string(userJSONBytes3))
  31805. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31806. utils.ErrorLog("解析失败:%v", err)
  31807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31808. return
  31809. }
  31810. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31811. if err == nil {
  31812. c.ServeSuccessJSON(map[string]interface{}{
  31813. "msg": "撤销明细成功",
  31814. })
  31815. return
  31816. } else {
  31817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31818. return
  31819. }
  31820. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31821. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31822. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31823. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31824. resp3, requestErr3 := http.Get(api3)
  31825. if requestErr3 != nil {
  31826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31827. return
  31828. }
  31829. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31830. if ioErr3 != nil {
  31831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31833. return
  31834. }
  31835. var respJSON3 map[string]interface{}
  31836. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31839. return
  31840. }
  31841. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31842. userJSONBytes3, _ := json.Marshal(respJSON3)
  31843. fmt.Println("log")
  31844. fmt.Println(string(userJSONBytes3))
  31845. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31846. utils.ErrorLog("解析失败:%v", err)
  31847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31848. return
  31849. }
  31850. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31851. if err == nil {
  31852. c.ServeSuccessJSON(map[string]interface{}{
  31853. "msg": "撤销明细成功",
  31854. })
  31855. return
  31856. } else {
  31857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31858. return
  31859. }
  31860. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31861. var resSix10265 ResultSix10265
  31862. var api3 string
  31863. if miConfig.MdtrtareaAdmvs == "320921" {
  31864. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31865. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31866. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31867. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31868. } else {
  31869. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31870. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31871. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31872. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31873. }
  31874. resp3, requestErr3 := http.Get(api3)
  31875. utils.ErrorLog("接口: %v", requestErr3)
  31876. if requestErr3 != nil {
  31877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31878. return
  31879. }
  31880. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31881. if ioErr3 != nil {
  31882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31884. return
  31885. }
  31886. var respJSON3 map[string]interface{}
  31887. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31890. return
  31891. }
  31892. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31893. userJSONBytes3, _ := json.Marshal(respJSON3)
  31894. fmt.Println("log")
  31895. fmt.Println(string(userJSONBytes3))
  31896. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31897. utils.ErrorLog("解析失败:%v", err)
  31898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31899. return
  31900. }
  31901. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31902. res2.Output = resSix10265.Output
  31903. res2.ErrMsg = resSix10265.ErrMsg
  31904. res2.Cainfo = resSix10265.Cainfo
  31905. res2.WarnMsg = resSix10265.WarnMsg
  31906. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31907. res2.Infcode = infocode
  31908. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31909. if err == nil {
  31910. c.ServeSuccessJSON(map[string]interface{}{
  31911. "msg": "撤销明细成功",
  31912. })
  31913. return
  31914. } else {
  31915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31916. return
  31917. }
  31918. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31919. var api3 string
  31920. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31921. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31922. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31923. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31924. resp3, requestErr3 := http.Get(api3)
  31925. utils.ErrorLog("接口: %v", requestErr3)
  31926. if requestErr3 != nil {
  31927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31928. return
  31929. }
  31930. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31931. if ioErr3 != nil {
  31932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31934. return
  31935. }
  31936. var respJSON3 map[string]interface{}
  31937. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31940. return
  31941. }
  31942. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31943. if status == "0" {
  31944. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31945. c.ServeSuccessJSON(map[string]interface{}{
  31946. "failed_code": -10,
  31947. "msg": err_msg,
  31948. })
  31949. return
  31950. }
  31951. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31952. userJSONBytes3, _ := json.Marshal(respJSON3)
  31953. fmt.Println("log")
  31954. fmt.Println(string(userJSONBytes3))
  31955. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31956. utils.ErrorLog("解析失败:%v", err)
  31957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31958. return
  31959. }
  31960. fmt.Println(res2.Infcode)
  31961. if res2.Infcode == -1 {
  31962. c.ServeSuccessJSON(map[string]interface{}{
  31963. "failed_code": -10,
  31964. "msg": res2.ErrMsg,
  31965. })
  31966. return
  31967. }
  31968. if res2.Infcode == 0 {
  31969. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31970. if err == nil {
  31971. c.ServeSuccessJSON(map[string]interface{}{
  31972. "msg": "撤销明细成功",
  31973. })
  31974. return
  31975. } else {
  31976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31977. return
  31978. }
  31979. } else {
  31980. c.ServeSuccessJSON(map[string]interface{}{
  31981. "failed_code": -10,
  31982. "msg": res2.ErrMsg,
  31983. })
  31984. }
  31985. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  31986. if err == nil {
  31987. c.ServeSuccessJSON(map[string]interface{}{
  31988. "msg": "撤销明细成功",
  31989. })
  31990. return
  31991. } else {
  31992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31993. return
  31994. }
  31995. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31996. var api3 string
  31997. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31998. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31999. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32000. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32001. resp3, requestErr3 := http.Get(api3)
  32002. utils.ErrorLog("接口: %v", requestErr3)
  32003. if requestErr3 != nil {
  32004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32005. return
  32006. }
  32007. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32008. if ioErr3 != nil {
  32009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32011. return
  32012. }
  32013. var respJSON3 map[string]interface{}
  32014. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32017. return
  32018. }
  32019. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32020. if status == "0" {
  32021. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32022. c.ServeSuccessJSON(map[string]interface{}{
  32023. "failed_code": -10,
  32024. "msg": err_msg,
  32025. })
  32026. return
  32027. }
  32028. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32029. userJSONBytes3, _ := json.Marshal(respJSON3)
  32030. fmt.Println("log")
  32031. fmt.Println(string(userJSONBytes3))
  32032. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32033. utils.ErrorLog("解析失败:%v", err)
  32034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32035. return
  32036. }
  32037. fmt.Println(res2.Infcode)
  32038. if res2.Infcode == -1 {
  32039. c.ServeSuccessJSON(map[string]interface{}{
  32040. "failed_code": -10,
  32041. "msg": res2.ErrMsg,
  32042. })
  32043. return
  32044. }
  32045. if res2.Infcode == 0 {
  32046. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32047. if err == nil {
  32048. c.ServeSuccessJSON(map[string]interface{}{
  32049. "msg": "撤销明细成功",
  32050. })
  32051. return
  32052. } else {
  32053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32054. return
  32055. }
  32056. } else {
  32057. c.ServeSuccessJSON(map[string]interface{}{
  32058. "failed_code": -10,
  32059. "msg": res2.ErrMsg,
  32060. })
  32061. }
  32062. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32063. if err == nil {
  32064. c.ServeSuccessJSON(map[string]interface{}{
  32065. "msg": "撤销明细成功",
  32066. })
  32067. return
  32068. } else {
  32069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32070. return
  32071. }
  32072. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32073. var resSix10265 ResultSix10265
  32074. new_chrg_bchno := order.Number
  32075. if adminUser.CurrentOrgId == 10265 {
  32076. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32077. new_chrg_bchno = "0000"
  32078. }
  32079. }
  32080. var api3 string
  32081. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32082. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32083. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32084. resp3, requestErr3 := http.Get(api3)
  32085. if requestErr3 != nil {
  32086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32087. return
  32088. }
  32089. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32090. if ioErr3 != nil {
  32091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32093. return
  32094. }
  32095. var respJSON3 map[string]interface{}
  32096. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32099. return
  32100. }
  32101. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32102. userJSONBytes3, _ := json.Marshal(respJSON3)
  32103. fmt.Println("log")
  32104. fmt.Println(string(userJSONBytes3))
  32105. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32106. utils.ErrorLog("解析失败:%v", err)
  32107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32108. return
  32109. }
  32110. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32111. res2.Output = resSix10265.Output
  32112. res2.ErrMsg = resSix10265.ErrMsg
  32113. res2.Cainfo = resSix10265.Cainfo
  32114. res2.WarnMsg = resSix10265.WarnMsg
  32115. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32116. res2.Infcode = infocode
  32117. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32118. if err == nil {
  32119. c.ServeSuccessJSON(map[string]interface{}{
  32120. "msg": "撤销明细成功",
  32121. })
  32122. return
  32123. } else {
  32124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32125. return
  32126. }
  32127. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32128. 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)
  32129. var dat map[string]interface{}
  32130. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32131. fmt.Println(dat)
  32132. } else {
  32133. fmt.Println(err)
  32134. }
  32135. saveLog(result2, src_request, "2205", "撤销明细")
  32136. userJSONBytes, _ := json.Marshal(dat)
  32137. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32138. utils.ErrorLog("解析失败:%v", err)
  32139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32140. return
  32141. }
  32142. if res2.Infcode == 0 {
  32143. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32144. if err == nil {
  32145. c.ServeSuccessJSON(map[string]interface{}{
  32146. "msg": "撤销明细成功",
  32147. })
  32148. return
  32149. } else {
  32150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32151. return
  32152. }
  32153. } else {
  32154. c.ServeSuccessJSON(map[string]interface{}{
  32155. "failed_code": -10,
  32156. "msg": res2.ErrMsg,
  32157. })
  32158. }
  32159. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32160. 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, "")
  32161. var dat map[string]interface{}
  32162. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32163. fmt.Println(dat)
  32164. } else {
  32165. fmt.Println(err)
  32166. }
  32167. saveLog(result2, src_request, "2205", "撤销明细")
  32168. userJSONBytes, _ := json.Marshal(dat)
  32169. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32170. utils.ErrorLog("解析失败:%v", err)
  32171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32172. return
  32173. }
  32174. if res2.Infcode == 0 {
  32175. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32176. if err == nil {
  32177. c.ServeSuccessJSON(map[string]interface{}{
  32178. "msg": "撤销明细成功",
  32179. })
  32180. return
  32181. } else {
  32182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32183. return
  32184. }
  32185. } else {
  32186. c.ServeSuccessJSON(map[string]interface{}{
  32187. "failed_code": -10,
  32188. "msg": res2.ErrMsg,
  32189. })
  32190. }
  32191. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32192. 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, "")
  32193. var dat map[string]interface{}
  32194. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32195. fmt.Println(dat)
  32196. } else {
  32197. fmt.Println(err)
  32198. }
  32199. saveLog(result2, src_request, "2205", "撤销明细")
  32200. userJSONBytes, _ := json.Marshal(dat)
  32201. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32202. utils.ErrorLog("解析失败:%v", err)
  32203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32204. return
  32205. }
  32206. if res2.Infcode == 0 {
  32207. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32208. if err == nil {
  32209. c.ServeSuccessJSON(map[string]interface{}{
  32210. "msg": "撤销明细成功",
  32211. })
  32212. return
  32213. } else {
  32214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32215. return
  32216. }
  32217. } else {
  32218. c.ServeSuccessJSON(map[string]interface{}{
  32219. "failed_code": -10,
  32220. "msg": res2.ErrMsg,
  32221. })
  32222. }
  32223. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32224. 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, "")
  32225. var dat map[string]interface{}
  32226. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32227. fmt.Println(dat)
  32228. } else {
  32229. fmt.Println(err)
  32230. }
  32231. saveLog(result2, src_request, "2205", "撤销明细")
  32232. userJSONBytes, _ := json.Marshal(dat)
  32233. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32234. utils.ErrorLog("解析失败:%v", err)
  32235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32236. return
  32237. }
  32238. if res2.Infcode == 0 {
  32239. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32240. if err == nil {
  32241. c.ServeSuccessJSON(map[string]interface{}{
  32242. "msg": "撤销明细成功",
  32243. })
  32244. return
  32245. } else {
  32246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32247. return
  32248. }
  32249. } else {
  32250. c.ServeSuccessJSON(map[string]interface{}{
  32251. "failed_code": -10,
  32252. "msg": res2.ErrMsg,
  32253. })
  32254. }
  32255. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32256. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  32257. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32258. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32259. resp2, requestErr2 := http.Get(api2)
  32260. if requestErr2 != nil {
  32261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32262. return
  32263. }
  32264. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32265. if ioErr2 != nil {
  32266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32268. return
  32269. }
  32270. var respJSON2 map[string]interface{}
  32271. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32274. return
  32275. }
  32276. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32277. userJSONBytes3, _ := json.Marshal(respJSON2)
  32278. fmt.Println("log")
  32279. fmt.Println(string(userJSONBytes3))
  32280. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32281. utils.ErrorLog("解析失败:%v", err)
  32282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32283. return
  32284. }
  32285. if res2.Infcode == 0 {
  32286. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32287. if err == nil {
  32288. c.ServeSuccessJSON(map[string]interface{}{
  32289. "msg": "撤销明细成功",
  32290. })
  32291. return
  32292. } else {
  32293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32294. return
  32295. }
  32296. } else {
  32297. c.ServeSuccessJSON(map[string]interface{}{
  32298. "failed_code": -10,
  32299. "msg": res2.ErrMsg,
  32300. })
  32301. }
  32302. } else {
  32303. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  32304. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32305. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32306. resp2, requestErr2 := http.Get(api2)
  32307. if requestErr2 != nil {
  32308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32309. return
  32310. }
  32311. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32312. if ioErr2 != nil {
  32313. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32315. return
  32316. }
  32317. var respJSON2 map[string]interface{}
  32318. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32321. return
  32322. }
  32323. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32324. userJSONBytes3, _ := json.Marshal(respJSON2)
  32325. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32326. utils.ErrorLog("解析失败:%v", err)
  32327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32328. return
  32329. }
  32330. if res2.Infcode == -1 {
  32331. c.ServeSuccessJSON(map[string]interface{}{
  32332. "failed_code": -10,
  32333. "msg": res2.ErrMsg,
  32334. })
  32335. return
  32336. } else {
  32337. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32338. if err == nil {
  32339. c.ServeSuccessJSON(map[string]interface{}{
  32340. "msg": "撤销明细成功",
  32341. })
  32342. return
  32343. } else {
  32344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32345. return
  32346. }
  32347. }
  32348. }
  32349. } else {
  32350. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32351. if err == nil {
  32352. c.ServeSuccessJSON(map[string]interface{}{
  32353. "msg": "退费成功",
  32354. })
  32355. } else {
  32356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32357. return
  32358. }
  32359. }
  32360. }
  32361. // 对账
  32362. func (c *HisApiController) GetCheckAccount() {
  32363. start_time := c.GetString("start_time")
  32364. end_time := c.GetString("end_time")
  32365. insutype := c.GetString("insutype")
  32366. clr_type := c.GetString("clr_type")
  32367. clr_org := c.GetString("clr_optins")
  32368. admin_user_id, _ := c.GetInt64("admin_user_id")
  32369. adminUser := c.GetAdminUserInfo()
  32370. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32371. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32372. if len(clr_org) == 0 {
  32373. clr_org = miConfig.InsuplcAdmdvs
  32374. }
  32375. timeLayout := "2006-01-02"
  32376. loc, _ := time.LoadLocation("Local")
  32377. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  32378. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  32379. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  32380. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  32381. fixmedins_setl_cnt := int64(len(orders))
  32382. var medfee_sumamt float64
  32383. var acct_pay float64
  32384. var fund_pay_sumamt float64
  32385. for _, item := range orders {
  32386. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  32387. acct_pay = acct_pay + item.AcctPay
  32388. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  32389. }
  32390. var user_name string
  32391. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32392. if role.ID == 0 {
  32393. user_name = "xxx"
  32394. } else {
  32395. user_name = role.UserName
  32396. }
  32397. var res ResultEight
  32398. var res10188 ResultEightFor10188
  32399. if config.IsOpen == 1 {
  32400. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32401. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  32402. "insutype=" + insutype +
  32403. "&clr_type=" + clr_type +
  32404. "&setl_optins=" + clr_org +
  32405. "&stmt_begndate=" + start_time +
  32406. "&stm_enddate=" + end_time +
  32407. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32408. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32409. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32410. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  32411. "&fixmedins_code=" + miConfig.Code +
  32412. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32413. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32414. "&secret_key=" + miConfig.SecretKey +
  32415. "&org_name=" + miConfig.OrgName +
  32416. "&doctor=" + user_name +
  32417. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32418. fmt.Println(api)
  32419. resp, requestErr := http.Get(api)
  32420. if requestErr != nil {
  32421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32422. return
  32423. }
  32424. body, ioErr := ioutil.ReadAll(resp.Body)
  32425. fmt.Println(body)
  32426. if ioErr != nil {
  32427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32429. return
  32430. }
  32431. var respJSON map[string]interface{}
  32432. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32435. return
  32436. }
  32437. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32438. userJSONBytes, _ := json.Marshal(respJSON)
  32439. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32440. utils.ErrorLog("解析失败:%v", err)
  32441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32442. return
  32443. }
  32444. res.InfRefmsgid = res10188.InfRefmsgid
  32445. res.Output = res10188.Output
  32446. res.ErrMsg = res10188.ErrMsg
  32447. res.Cainfo = res10188.Cainfo
  32448. res.WarnMsg = res10188.WarnMsg
  32449. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  32450. res.Infcode = infocode
  32451. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32452. if clr_type != "9903" {
  32453. clr_type = "99" // 就诊 ID(来自2201接口返回)
  32454. }
  32455. if clr_type == "9903" {
  32456. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  32457. }
  32458. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  32459. "insutype=" + insutype +
  32460. "&clr_type=" + clr_type +
  32461. "&setl_optins=" + clr_org +
  32462. "&stmt_begndate=" + start_time +
  32463. "&stm_enddate=" + end_time +
  32464. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32465. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32466. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32467. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  32468. "&fixmedins_code=" + miConfig.Code +
  32469. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32470. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32471. "&secret_key=" + miConfig.SecretKey +
  32472. "&org_name=" + miConfig.OrgName +
  32473. "&doctor=" + user_name
  32474. resp, requestErr := http.Get(api)
  32475. if requestErr != nil {
  32476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32477. return
  32478. }
  32479. body, ioErr := ioutil.ReadAll(resp.Body)
  32480. if ioErr != nil {
  32481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32483. return
  32484. }
  32485. var respJSON map[string]interface{}
  32486. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32489. return
  32490. }
  32491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32492. result, _ := json.Marshal(respJSON)
  32493. fmt.Println("log")
  32494. fmt.Println(string(result))
  32495. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  32496. utils.ErrorLog("解析失败:%v", err)
  32497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32498. return
  32499. }
  32500. res.InfRefmsgid = res10188.InfRefmsgid
  32501. res.Output = res10188.Output
  32502. res.ErrMsg = res10188.ErrMsg
  32503. res.Cainfo = res10188.Cainfo
  32504. res.WarnMsg = res10188.WarnMsg
  32505. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  32506. res.Infcode = infocode
  32507. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32508. var baseParams models.BaseParams
  32509. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  32510. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  32511. baseParams.SecretKey = miConfig.SecretKey
  32512. baseParams.OrgName = miConfig.OrgName
  32513. baseParams.FixmedinsCode = miConfig.Code
  32514. baseParams.EncKey = miConfig.EncKey
  32515. baseParams.AppSecret = miConfig.AppSecret
  32516. baseParams.SignKey = miConfig.SignKey
  32517. baseParams.AppID = miConfig.Code
  32518. baseParams.Doctor = role.UserName
  32519. baseParams.RequestUrl = miConfig.Url
  32520. businessParams := models.BusinessParams{
  32521. Insutype: insutype,
  32522. ClrType: clr_type,
  32523. SetlOptins: clr_org,
  32524. StmtBegndate: start_time,
  32525. StmtEnddate: end_time,
  32526. MedfeeSumamt: medfee_sumamt,
  32527. FundPaySumamt: fund_pay_sumamt,
  32528. AcctPay: acct_pay,
  32529. FixmedinsSetlCnt: fixmedins_setl_cnt,
  32530. }
  32531. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  32532. fmt.Println(requestLog)
  32533. fmt.Println(result)
  32534. fmt.Println(err_msg)
  32535. var dat map[string]interface{}
  32536. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32537. fmt.Println(dat)
  32538. } else {
  32539. fmt.Println(err)
  32540. }
  32541. userJSONBytes, _ := json.Marshal(dat)
  32542. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32543. utils.ErrorLog("解析失败:%v", err)
  32544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32545. return
  32546. }
  32547. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32548. var baseParams models.BaseParams
  32549. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  32550. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  32551. baseParams.SecretKey = miConfig.SecretKey
  32552. baseParams.OrgName = miConfig.OrgName
  32553. baseParams.FixmedinsCode = miConfig.Code
  32554. baseParams.EncKey = miConfig.EncKey
  32555. baseParams.AppSecret = miConfig.AppSecret
  32556. baseParams.SignKey = miConfig.SignKey
  32557. baseParams.AppID = miConfig.Code
  32558. baseParams.Doctor = role.UserName
  32559. baseParams.RequestUrl = miConfig.Url
  32560. baseParams.AccessKey = miConfig.AccessKey
  32561. businessParams := models.BusinessParams{
  32562. Insutype: insutype,
  32563. ClrType: clr_type,
  32564. SetlOptins: "430822",
  32565. StmtBegndate: start_time,
  32566. StmtEnddate: end_time,
  32567. MedfeeSumamt: medfee_sumamt,
  32568. FundPaySumamt: fund_pay_sumamt,
  32569. AcctPay: acct_pay,
  32570. FixmedinsSetlCnt: fixmedins_setl_cnt,
  32571. }
  32572. 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)
  32573. fmt.Println(requestLog)
  32574. fmt.Println(result)
  32575. var dat map[string]interface{}
  32576. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32577. fmt.Println(dat)
  32578. } else {
  32579. fmt.Println(err)
  32580. }
  32581. userJSONBytes, _ := json.Marshal(dat)
  32582. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32583. utils.ErrorLog("解析失败:%v", err)
  32584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32585. return
  32586. }
  32587. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32588. var baseParams models.BaseParams
  32589. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  32590. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  32591. baseParams.SecretKey = miConfig.SecretKey
  32592. baseParams.OrgName = miConfig.OrgName
  32593. baseParams.FixmedinsCode = miConfig.Code
  32594. baseParams.EncKey = miConfig.EncKey
  32595. baseParams.AppSecret = miConfig.AppSecret
  32596. baseParams.SignKey = miConfig.SignKey
  32597. baseParams.AppID = miConfig.Code
  32598. baseParams.Doctor = role.UserName
  32599. baseParams.RequestUrl = miConfig.Url
  32600. businessParams := models.BusinessParams{
  32601. Insutype: insutype,
  32602. ClrType: clr_type,
  32603. SetlOptins: clr_org,
  32604. StmtBegndate: start_time,
  32605. StmtEnddate: end_time,
  32606. MedfeeSumamt: medfee_sumamt,
  32607. FundPaySumamt: fund_pay_sumamt,
  32608. AcctPay: acct_pay,
  32609. FixmedinsSetlCnt: fixmedins_setl_cnt,
  32610. }
  32611. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  32612. fmt.Println(requestLog)
  32613. fmt.Println(result)
  32614. fmt.Println(err_msg)
  32615. var dat map[string]interface{}
  32616. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32617. fmt.Println(dat)
  32618. } else {
  32619. fmt.Println(err)
  32620. }
  32621. userJSONBytes, _ := json.Marshal(dat)
  32622. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32623. utils.ErrorLog("解析失败:%v", err)
  32624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32625. return
  32626. }
  32627. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32628. if len(clr_type) == 0 {
  32629. clr_type = "11"
  32630. }
  32631. api := miConfig.Url + "gdyb/ten?" +
  32632. "insutype=" + insutype +
  32633. "&clr_type=" + clr_type +
  32634. "&setl_optins=" + clr_org +
  32635. "&stmt_begndate=" + start_time +
  32636. "&stm_enddate=" + end_time +
  32637. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32638. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32639. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32640. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  32641. "&fixmedins_code=" + miConfig.Code +
  32642. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32643. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32644. "&secret_key=" + miConfig.SecretKey +
  32645. "&org_name=" + miConfig.OrgName +
  32646. "&doctor=" + user_name
  32647. fmt.Println(api)
  32648. resp, requestErr := http.Get(api)
  32649. if requestErr != nil {
  32650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32651. return
  32652. }
  32653. body, ioErr := ioutil.ReadAll(resp.Body)
  32654. fmt.Println(body)
  32655. if ioErr != nil {
  32656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32658. return
  32659. }
  32660. var respJSON map[string]interface{}
  32661. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32664. return
  32665. }
  32666. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32667. userJSONBytes, _ := json.Marshal(respJSON)
  32668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32669. utils.ErrorLog("解析失败:%v", err)
  32670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32671. return
  32672. }
  32673. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32674. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  32675. //fixmedins_setl_cnt := int64(len(orders_two))
  32676. //var medfee_sumamt float64
  32677. //var acct_pay float64
  32678. //var fund_pay_sumamt float64
  32679. //for _, item := range orders_two {
  32680. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  32681. // acct_pay = acct_pay + item.AcctPay
  32682. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  32683. //}
  32684. var baseParams models.BaseParams
  32685. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  32686. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  32687. baseParams.SecretKey = miConfig.SecretKey
  32688. baseParams.OrgName = miConfig.OrgName
  32689. baseParams.FixmedinsCode = miConfig.Code
  32690. baseParams.EncKey = miConfig.EncKey
  32691. baseParams.AppSecret = miConfig.AppSecret
  32692. baseParams.SignKey = miConfig.SignKey
  32693. baseParams.AppID = miConfig.Code
  32694. baseParams.Doctor = role.UserName
  32695. baseParams.RequestUrl = miConfig.Url
  32696. if clr_type == "9903" {
  32697. clr_type = "9994"
  32698. }
  32699. businessParams := models.BusinessParams{
  32700. Insutype: insutype,
  32701. ClrType: clr_type,
  32702. SetlOptins: "360302",
  32703. StmtBegndate: start_time,
  32704. StmtEnddate: end_time,
  32705. MedfeeSumamt: 0,
  32706. FundPaySumamt: 0,
  32707. AcctPay: 0,
  32708. FixmedinsSetlCnt: fixmedins_setl_cnt,
  32709. }
  32710. 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))
  32711. fmt.Println(requestLog)
  32712. fmt.Println(result)
  32713. var dat map[string]interface{}
  32714. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32715. fmt.Println(dat)
  32716. } else {
  32717. fmt.Println(err)
  32718. }
  32719. userJSONBytes, _ := json.Marshal(dat)
  32720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32721. utils.ErrorLog("解析失败:%v", err)
  32722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32723. return
  32724. }
  32725. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32726. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  32727. fixmedins_setl_cnt := int64(len(orders_two))
  32728. var medfee_sumamt float64
  32729. var acct_pay float64
  32730. var fund_pay_sumamt float64
  32731. for _, item := range orders_two {
  32732. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  32733. acct_pay = acct_pay + item.AcctPay
  32734. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  32735. }
  32736. var baseParams models.BaseParams
  32737. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  32738. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  32739. baseParams.SecretKey = miConfig.SecretKey
  32740. baseParams.OrgName = miConfig.OrgName
  32741. baseParams.FixmedinsCode = miConfig.Code
  32742. baseParams.EncKey = miConfig.EncKey
  32743. baseParams.AppSecret = miConfig.AppSecret
  32744. baseParams.SignKey = miConfig.SignKey
  32745. baseParams.AppID = miConfig.Code
  32746. baseParams.Doctor = role.UserName
  32747. baseParams.RequestUrl = miConfig.Url
  32748. if clr_type == "9903" {
  32749. clr_type = "9994"
  32750. }
  32751. businessParams := models.BusinessParams{
  32752. Insutype: insutype,
  32753. ClrType: clr_type,
  32754. SetlOptins: "361025",
  32755. StmtBegndate: start_time,
  32756. StmtEnddate: end_time,
  32757. MedfeeSumamt: 0,
  32758. FundPaySumamt: 0,
  32759. AcctPay: 0,
  32760. FixmedinsSetlCnt: fixmedins_setl_cnt,
  32761. }
  32762. 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))
  32763. fmt.Println(requestLog)
  32764. fmt.Println(result)
  32765. var dat map[string]interface{}
  32766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32767. fmt.Println(dat)
  32768. } else {
  32769. fmt.Println(err)
  32770. }
  32771. userJSONBytes, _ := json.Marshal(dat)
  32772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32773. utils.ErrorLog("解析失败:%v", err)
  32774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32775. return
  32776. }
  32777. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32778. var api string
  32779. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  32780. "&clr_type=" + clr_type +
  32781. "&setl_optins=" + clr_org +
  32782. "&stmt_begndate=" + start_time +
  32783. "&stm_enddate=" + end_time +
  32784. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32785. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32786. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32787. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  32788. "&fixmedins_code=" + miConfig.Code +
  32789. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32790. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32791. "&secret_key=" + miConfig.SecretKey +
  32792. "&org_name=" + miConfig.OrgName +
  32793. "&doctor=" + user_name + "&url=" + miConfig.Url
  32794. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32795. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32796. resp, requestErr := http.Get(api)
  32797. if requestErr != nil {
  32798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32799. return
  32800. }
  32801. body, ioErr := ioutil.ReadAll(resp.Body)
  32802. if ioErr != nil {
  32803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32805. return
  32806. }
  32807. var respJSON map[string]interface{}
  32808. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32811. return
  32812. }
  32813. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32814. if status == "0" {
  32815. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32816. c.ServeSuccessJSON(map[string]interface{}{
  32817. "failed_code": -10,
  32818. "msg": err_msg,
  32819. })
  32820. return
  32821. }
  32822. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32823. userJSONBytes, _ := json.Marshal(respJSON)
  32824. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32825. utils.ErrorLog("解析失败:%v", err)
  32826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32827. return
  32828. }
  32829. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32830. var api string
  32831. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  32832. "&clr_type=" + clr_type +
  32833. "&setl_optins=" + clr_org +
  32834. "&stmt_begndate=" + start_time +
  32835. "&stm_enddate=" + end_time +
  32836. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32837. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32838. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32839. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  32840. "&fixmedins_code=" + miConfig.Code +
  32841. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32842. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32843. "&secret_key=" + miConfig.SecretKey +
  32844. "&org_name=" + miConfig.OrgName +
  32845. "&doctor=" + user_name + "&url=" + miConfig.Url
  32846. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32847. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32848. resp, requestErr := http.Get(api)
  32849. if requestErr != nil {
  32850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32851. return
  32852. }
  32853. body, ioErr := ioutil.ReadAll(resp.Body)
  32854. if ioErr != nil {
  32855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32857. return
  32858. }
  32859. var respJSON map[string]interface{}
  32860. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32863. return
  32864. }
  32865. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32866. if status == "0" {
  32867. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32868. c.ServeSuccessJSON(map[string]interface{}{
  32869. "failed_code": -10,
  32870. "msg": err_msg,
  32871. })
  32872. return
  32873. }
  32874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32875. userJSONBytes, _ := json.Marshal(respJSON)
  32876. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32877. utils.ErrorLog("解析失败:%v", err)
  32878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32879. return
  32880. }
  32881. } else {
  32882. if len(clr_type) == 0 {
  32883. clr_type = "11"
  32884. }
  32885. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  32886. "insutype=" + insutype +
  32887. "&clr_type=" + clr_type +
  32888. "&setl_optins=" + clr_org +
  32889. "&stmt_begndate=" + start_time +
  32890. "&stm_enddate=" + end_time +
  32891. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32892. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32893. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32894. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  32895. "&fixmedins_code=" + miConfig.Code +
  32896. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32897. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32898. "&secret_key=" + miConfig.SecretKey +
  32899. "&org_name=" + miConfig.OrgName +
  32900. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32901. fmt.Println(api)
  32902. resp, requestErr := http.Get(api)
  32903. if requestErr != nil {
  32904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32905. return
  32906. }
  32907. body, ioErr := ioutil.ReadAll(resp.Body)
  32908. fmt.Println(body)
  32909. if ioErr != nil {
  32910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32912. return
  32913. }
  32914. var respJSON map[string]interface{}
  32915. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32918. return
  32919. }
  32920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32921. userJSONBytes, _ := json.Marshal(respJSON)
  32922. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32923. utils.ErrorLog("解析失败:%v", err)
  32924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32925. return
  32926. }
  32927. }
  32928. if res.Infcode == 0 {
  32929. if res.Output.Stmtinfo.StmtRslt == "0" {
  32930. micc := &models.MedicalInsuranceCostCompare{
  32931. StartTime: startime.Unix(),
  32932. EndTime: endtime.Unix(),
  32933. Insutype: insutype,
  32934. CheckType: 1,
  32935. Num: fixmedins_setl_cnt,
  32936. Mtime: time.Now().Unix(),
  32937. Status: 1,
  32938. UserOrgId: adminUser.CurrentOrgId,
  32939. CostTotal: medfee_sumamt,
  32940. FuncTotal: fund_pay_sumamt,
  32941. PsnPay: acct_pay,
  32942. Creator: admin_user_id,
  32943. Ctime: time.Now().Unix(),
  32944. ClrType: clr_type,
  32945. }
  32946. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  32947. if err == nil {
  32948. c.ServeSuccessJSON(map[string]interface{}{
  32949. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  32950. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  32951. })
  32952. } else {
  32953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32954. }
  32955. } else {
  32956. c.ServeSuccessJSON(map[string]interface{}{
  32957. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  32958. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  32959. })
  32960. }
  32961. } else {
  32962. c.ServeSuccessJSON(map[string]interface{}{
  32963. "failed_code": -10,
  32964. "msg": res.ErrMsg,
  32965. })
  32966. }
  32967. }
  32968. }
  32969. func (c *HisApiController) Check310() {
  32970. adminUser := c.GetAdminUserInfo()
  32971. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32972. var user_name string
  32973. user_name = "高慧裕"
  32974. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  32975. "insutype=" + "310" +
  32976. "&clr_type=" + "" +
  32977. "&setl_optins=" + "441202" +
  32978. "&stmt_begndate=" + "2022-03-01" +
  32979. "&stm_enddate=" + "2022-03-31" +
  32980. "&medfee_sumamt=" + "194930.12" +
  32981. "&fund_pay_sumamt=" + "188741.46" +
  32982. "&acct_pay=" + "0" +
  32983. "&fixmedins_setl_cnt=" + "452" +
  32984. "&fixmedins_code=" + miConfig.Code +
  32985. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32986. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32987. "&secret_key=" + miConfig.SecretKey +
  32988. "&org_name=" + miConfig.OrgName +
  32989. "&doctor=" + user_name
  32990. fmt.Println(api)
  32991. resp, requestErr := http.Get(api)
  32992. if requestErr != nil {
  32993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32994. return
  32995. }
  32996. body, ioErr := ioutil.ReadAll(resp.Body)
  32997. fmt.Println(body)
  32998. if ioErr != nil {
  32999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33001. return
  33002. }
  33003. var respJSON map[string]interface{}
  33004. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33007. return
  33008. }
  33009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33010. userJSONBytes, _ := json.Marshal(respJSON)
  33011. var res ResultEight
  33012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33013. utils.ErrorLog("解析失败:%v", err)
  33014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33015. return
  33016. }
  33017. }
  33018. func (c *HisApiController) Check390() {
  33019. adminUser := c.GetAdminUserInfo()
  33020. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33021. var user_name string
  33022. user_name = "高慧裕"
  33023. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33024. "insutype=" + "390" +
  33025. "&clr_type=" + "" +
  33026. "&setl_optins=" + "441202" +
  33027. "&stmt_begndate=" + "2022-03-01" +
  33028. "&stm_enddate=" + "2022-03-31" +
  33029. "&medfee_sumamt=" + "1068448.89" +
  33030. "&fund_pay_sumamt=" + "1014677.62" +
  33031. "&acct_pay=" + "0" +
  33032. "&fixmedins_setl_cnt=" + "1950" +
  33033. "&fixmedins_code=" + miConfig.Code +
  33034. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33035. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33036. "&secret_key=" + miConfig.SecretKey +
  33037. "&org_name=" + miConfig.OrgName +
  33038. "&doctor=" + user_name
  33039. fmt.Println(api)
  33040. resp, requestErr := http.Get(api)
  33041. if requestErr != nil {
  33042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33043. return
  33044. }
  33045. body, ioErr := ioutil.ReadAll(resp.Body)
  33046. fmt.Println(body)
  33047. if ioErr != nil {
  33048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33050. return
  33051. }
  33052. var respJSON map[string]interface{}
  33053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33056. return
  33057. }
  33058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33059. userJSONBytes, _ := json.Marshal(respJSON)
  33060. var res ResultEight
  33061. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33062. utils.ErrorLog("解析失败:%v", err)
  33063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33064. return
  33065. }
  33066. }
  33067. // 对账明细
  33068. func (c *HisApiController) GetCheckDetailAccount() {
  33069. start_time := c.GetString("start_time")
  33070. end_time := c.GetString("end_time")
  33071. admin_user_id, _ := c.GetInt64("admin_user_id")
  33072. adminUser := c.GetAdminUserInfo()
  33073. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33074. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33075. timeLayout := "2006-01-02"
  33076. loc, _ := time.LoadLocation("Local")
  33077. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33078. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33079. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33080. rand.Seed(time.Now().UnixNano())
  33081. num := rand.Intn(30000)
  33082. Mkdir(miConfig.OrgName)
  33083. file := strconv.FormatInt(int64(num), 10)
  33084. file_name := file + ".txt"
  33085. zip_name := file + ".zip"
  33086. zip_path := miConfig.OrgName + "/" + zip_name
  33087. file_path := miConfig.OrgName + "/" + file_name
  33088. decimal.DivisionPrecision = 2
  33089. var medfee_sumamt float64
  33090. var psn_cash_pay float64
  33091. var fund_pay_sumamt float64
  33092. fixmedins_setl_cnt := int64(len(orders))
  33093. for _, item := range orders {
  33094. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33095. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  33096. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33097. }
  33098. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  33099. defer f.Close()
  33100. if err != nil {
  33101. fmt.Println(err.Error())
  33102. } else {
  33103. for _, item := range orders {
  33104. var refd_setl_flag string
  33105. if item.OrderStatus == 2 {
  33106. refd_setl_flag = "0"
  33107. var str string
  33108. str = item.SetlId + " " +
  33109. item.MdtrtId + " " +
  33110. item.PsnNo + " " +
  33111. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33112. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33113. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  33114. _, err = f.Write([]byte(str))
  33115. }
  33116. if item.OrderStatus == 3 {
  33117. var str string
  33118. str = item.SetlId + " " +
  33119. item.MdtrtId + " " +
  33120. item.PsnNo + " " +
  33121. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33122. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33123. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  33124. _, err = f.Write([]byte(str))
  33125. var str2 string
  33126. str2 = item.SetlId + " " +
  33127. item.MdtrtId + " " +
  33128. item.PsnNo + " " +
  33129. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  33130. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  33131. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  33132. _, err = f.Write([]byte(str2))
  33133. }
  33134. }
  33135. }
  33136. Zip(file_path, zip_path)
  33137. fmt.Println(ReadFile(zip_path))
  33138. fmt.Println(string(ReadFile(zip_path)))
  33139. if config.IsOpen == 1 {
  33140. var user_name string
  33141. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33142. if role.ID == 0 {
  33143. user_name = "管理员"
  33144. } else {
  33145. user_name = role.UserName
  33146. }
  33147. baseParams := models.BaseParams{
  33148. SecretKey: miConfig.SecretKey,
  33149. FixmedinsCode: miConfig.Code,
  33150. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33151. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33152. OrgName: miConfig.OrgName,
  33153. Doctor: user_name,
  33154. }
  33155. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  33156. var dat map[string]interface{}
  33157. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33158. fmt.Println(dat)
  33159. } else {
  33160. fmt.Println(err)
  33161. }
  33162. userJSONBytes, _ := json.Marshal(dat)
  33163. var res ResultNine
  33164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33165. utils.ErrorLog("解析失败:%v", err)
  33166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33167. return
  33168. }
  33169. if res.Infcode == 0 {
  33170. fileNo := res.Output.FileQuryNo
  33171. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  33172. "file_qury_no=" + fileNo +
  33173. "&setl_optins=" + "定点医保中心" +
  33174. "&stmt_begndate=" + start_time +
  33175. "&stm_enddate=" + end_time +
  33176. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33177. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33178. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  33179. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33180. "&fixmedins_code=" + miConfig.Code +
  33181. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33182. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33183. "&secret_key=" + miConfig.SecretKey +
  33184. "&org_name=" + miConfig.OrgName +
  33185. "&doctor=" + user_name
  33186. resp, requestErr := http.Get(api)
  33187. if requestErr != nil {
  33188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33189. return
  33190. }
  33191. body, ioErr := ioutil.ReadAll(resp.Body)
  33192. if ioErr != nil {
  33193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33195. return
  33196. }
  33197. var respJSON map[string]interface{}
  33198. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33201. return
  33202. }
  33203. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33204. userJSONBytes, _ := json.Marshal(respJSON)
  33205. var res ResultTen
  33206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33207. utils.ErrorLog("解析失败:%v", err)
  33208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33209. return
  33210. }
  33211. if res.Infcode == 0 {
  33212. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  33213. micc := &models.MedicalInsuranceCostCompare{
  33214. StartTime: startime.Unix(),
  33215. EndTime: endtime.Unix(),
  33216. Insutype: "0",
  33217. CheckType: 2,
  33218. Num: fixmedins_setl_cnt,
  33219. Mtime: time.Now().Unix(),
  33220. Status: 1,
  33221. UserOrgId: adminUser.CurrentOrgId,
  33222. CostTotal: medfee_sumamt,
  33223. FuncTotal: fund_pay_sumamt,
  33224. PsnPay: psn_cash_pay,
  33225. Creator: admin_user_id,
  33226. Ctime: time.Now().Unix(),
  33227. }
  33228. service.CreateMedicalInsuranceCostCompareRecord(micc)
  33229. c.ServeSuccessJSON(map[string]interface{}{
  33230. "msg": "明细对账成功",
  33231. })
  33232. }
  33233. } else {
  33234. }
  33235. }
  33236. }
  33237. type CustomOrderInfo struct {
  33238. Name string
  33239. Spec string
  33240. Unit string
  33241. Count float64
  33242. Price float64
  33243. Total float64
  33244. }
  33245. func (c *HisApiController) GetBatchSettleAccounts() {
  33246. admin_user_id, _ := c.GetInt64("admin_user_id")
  33247. order_ids := c.GetString("order_ids")
  33248. order_ids_arr := strings.Split(order_ids, ",")
  33249. data3 := []map[string]interface{}{}
  33250. for _, item := range order_ids_arr {
  33251. id, _ := strconv.ParseInt(item, 10, 64)
  33252. order_id := id
  33253. adminUser := c.GetAdminUserInfo()
  33254. order, _ := service.GetHisOrderByID(order_id)
  33255. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33256. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  33257. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  33258. orderInfos = append(orderInfos, orderInfos_two...)
  33259. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  33260. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  33261. var diagnosis_ids []string
  33262. if his.ID > 0 {
  33263. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  33264. } else {
  33265. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  33266. }
  33267. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  33268. var dia_config []*models.HisXtDiagnoseConfig
  33269. var name string
  33270. for _, item := range diagnosis_ids {
  33271. id, _ := strconv.ParseInt(item, 10, 64)
  33272. diagnosisConfig, _ := service.FindDiagnoseById(id)
  33273. dia_config = append(dia_config, &diagnosisConfig)
  33274. if len(name) == 0 {
  33275. name = diagnosisConfig.ClassName
  33276. }
  33277. //} else {
  33278. // name = name + "," + diagnosisConfig.ClassName
  33279. //}
  33280. }
  33281. var bedCostTotal float64 = 0 //床位总费
  33282. var bedCostSelfTotal float64 = 0 //床位自费
  33283. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  33284. var bedSelfTotal float64 = 0 //床位部分项目自费
  33285. var bedInscpTotal float64 = 0 //床位部分项目自费
  33286. var operationCostTotal float64 = 0 //手术费
  33287. var operationCostSelfTotal float64 = 0 //手术费
  33288. var operationCostPartSelfTotal float64 = 0 //手术费
  33289. var operationSelfTotal float64 = 0 //床位部分项目自费
  33290. var operationInscpTotal float64 = 0 //床位部分项目自费
  33291. var otherCostTotal float64 = 0 //其他费用
  33292. var otherCostSelfTotal float64 = 0 //其他费用
  33293. var otherCostPartSelfTotal float64 = 0 //其他费用
  33294. var otherSelfTotal float64 = 0 //床位部分项目自费
  33295. var otherInscpTotal float64 = 0 //床位部分项目自费
  33296. var materialCostTotal float64 = 0 //材料费
  33297. var materialCostSelfTotal float64 = 0 //材料费
  33298. var materialCostPartSelfTotal float64 = 0 //材料费
  33299. var materialSelfTotal float64 = 0 //床位部分项目自费
  33300. var materialInscpTotal float64 = 0 //床位部分项目自费
  33301. var westernMedicineCostTotal float64 = 0 //西药费
  33302. var westernMedicineCostSelfTotal float64 = 0 //西药费
  33303. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  33304. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  33305. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  33306. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  33307. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  33308. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  33309. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  33310. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  33311. var checkCostTotal float64 = 0 //检查费
  33312. var checkCostSelfTotal float64 = 0 //检查费
  33313. var checkCostPartSelfTotal float64 = 0 //检查费
  33314. var checkSelfTotal float64 = 0 //床位部分项目自费
  33315. var checkInscpTotal float64 = 0 //床位部分项目自费
  33316. var laboratoryCostTotal float64 = 0 //化验费
  33317. var laboratoryCostSelfTotal float64 = 0 //化验费
  33318. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  33319. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  33320. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  33321. var treatCostTotal float64 = 0 //治疗费用
  33322. var treatCostSelfTotal float64 = 0 //治疗费用
  33323. var treatCostPartSelfTotal float64 = 0 //治疗费用
  33324. var treatSelfTotal float64 = 0 //床位部分项目自费
  33325. var treatInscpTotal float64 = 0 //床位部分项目自费
  33326. decimal.DivisionPrecision = 2
  33327. for _, item := range orderInfos {
  33328. if item.MedChrgitmType == "01" { //床位费
  33329. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33330. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33331. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33332. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33333. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33334. }
  33335. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  33336. if item.MedChrgitmType == "03" { //检查费
  33337. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33338. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33339. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33340. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33341. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33342. }
  33343. } else {
  33344. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  33345. fmt.Println("------------")
  33346. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33347. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33348. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33349. }
  33350. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  33351. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33352. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33353. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33354. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33355. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33356. }
  33357. }
  33358. if item.MedChrgitmType == "04" { //化验费
  33359. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33360. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33361. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33362. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33363. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33364. }
  33365. if item.MedChrgitmType == "05" { //治疗费
  33366. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33367. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33368. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33369. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33370. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33371. }
  33372. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  33373. fmt.Println("------------")
  33374. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33375. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33376. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33377. }
  33378. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  33379. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33380. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33381. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33382. }
  33383. //if item.MedChrgitmType == "06" { //手术费
  33384. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33385. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33386. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33387. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33388. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33389. //
  33390. //}
  33391. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  33392. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33393. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33394. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33395. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33396. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33397. }
  33398. if item.MedChrgitmType == "09" { //西药费
  33399. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33400. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33401. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33402. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33403. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33404. }
  33405. if item.MedChrgitmType == "11" { //中成费
  33406. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33407. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33408. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33409. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33410. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33411. }
  33412. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  33413. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33414. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33415. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33416. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33417. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33418. }
  33419. }
  33420. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33421. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33422. var user_name string
  33423. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33424. if role.ID == 0 {
  33425. user_name = "管理员"
  33426. } else {
  33427. user_name = role.UserName
  33428. }
  33429. baseParams := models.BaseParams{
  33430. SecretKey: miConfig.SecretKey,
  33431. FixmedinsCode: miConfig.Code,
  33432. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33433. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33434. OrgName: miConfig.OrgName,
  33435. Doctor: user_name,
  33436. RequestUrl: miConfig.Url,
  33437. AccessKey: miConfig.AccessKey,
  33438. }
  33439. businessParams := models.BusinessParams{
  33440. PsnNo: order.PsnNo,
  33441. MdtrtId: order.MdtrtId,
  33442. SetlId: order.SetlId,
  33443. }
  33444. var res ResultEleven
  33445. var resEleven10265 ResultEleven10265
  33446. if config.IsOpen == 1 {
  33447. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  33448. result := service.Gdyb5203(baseParams, businessParams)
  33449. service.Gdyb5204(baseParams, businessParams)
  33450. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  33451. var dat map[string]interface{}
  33452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33453. fmt.Println(dat)
  33454. } else {
  33455. fmt.Println(err)
  33456. }
  33457. userJSONBytes, _ := json.Marshal(dat)
  33458. if miConfig.Code == "H15049901371" {
  33459. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  33460. utils.ErrorLog("解析失败:%v", err)
  33461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33462. return
  33463. }
  33464. res.InfRefmsgid = resEleven10265.InfRefmsgid
  33465. res.Output = resEleven10265.Output
  33466. res.ErrMsg = resEleven10265.ErrMsg
  33467. res.Cainfo = resEleven10265.Cainfo
  33468. res.WarnMsg = resEleven10265.WarnMsg
  33469. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  33470. res.Infcode = infocode
  33471. } else {
  33472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33473. utils.ErrorLog("解析失败:%v", err)
  33474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33475. return
  33476. }
  33477. }
  33478. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33479. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  33480. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  33481. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  33482. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  33483. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33484. var doctor_name string
  33485. if roles.ID == 0 {
  33486. doctor_name = "管理员"
  33487. } else {
  33488. doctor_name = roles.UserName
  33489. }
  33490. yiliao_leibie := ""
  33491. switch order.MedType {
  33492. case "11":
  33493. yiliao_leibie = "普通门诊"
  33494. break
  33495. case "12":
  33496. yiliao_leibie = "门诊挂号"
  33497. break
  33498. case "13":
  33499. yiliao_leibie = "急诊"
  33500. break
  33501. case "14":
  33502. yiliao_leibie = "门诊特殊病"
  33503. break
  33504. case "15":
  33505. yiliao_leibie = "门诊统筹"
  33506. break
  33507. case "16":
  33508. yiliao_leibie = "门诊慢性病"
  33509. break
  33510. case "21":
  33511. yiliao_leibie = "普通住院"
  33512. break
  33513. }
  33514. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  33515. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  33516. if res.Infcode == 0 {
  33517. data2 := map[string]interface{}{
  33518. "diagnosis": name,
  33519. "order_infos": orderInfos,
  33520. "number": order.MdtrtId,
  33521. "date": order.SettleAccountsDate,
  33522. "charge_admin": charge_admin,
  33523. "printor_admin": printor_admin,
  33524. "info": res.Output.Setlinfo,
  33525. "order": order,
  33526. "bedCostTotal": bedCostTotal,
  33527. "bedCostSelfTotal": bedCostSelfTotal,
  33528. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  33529. "bedSelfTotal": bedSelfTotal,
  33530. "bedInscpTotal": bedInscpTotal,
  33531. "operationCostTotal": operationCostTotal,
  33532. "operationCostSelfTotal": operationCostSelfTotal,
  33533. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  33534. "operationSelfTotal": operationSelfTotal,
  33535. "operationInscpTotal": operationInscpTotal,
  33536. "otherCostTotal": otherCostTotal,
  33537. "otherCostSelfTotal": otherCostSelfTotal,
  33538. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  33539. "otherSelfTotal": otherSelfTotal,
  33540. "otherInscpTotal": otherInscpTotal,
  33541. "materialCostTotal": materialCostTotal,
  33542. "materialCostSelfTotal": materialCostSelfTotal,
  33543. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  33544. "materialSelfTotal": materialSelfTotal,
  33545. "materialInscpTotal": materialInscpTotal,
  33546. "westernMedicineCostTotal": westernMedicineCostTotal,
  33547. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  33548. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  33549. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  33550. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  33551. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  33552. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  33553. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  33554. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  33555. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  33556. "checkCostTotal": checkCostTotal,
  33557. "checkCostSelfTotal": checkCostSelfTotal,
  33558. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  33559. "checkSelfTotal": checkSelfTotal,
  33560. "checkInscpTotal": checkInscpTotal,
  33561. "laboratoryCostTotal": laboratoryCostTotal,
  33562. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  33563. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  33564. "laboratorySelfTotal": laboratorySelfTotal,
  33565. "laboratoryInscpTotal": laboratoryInscpTotal,
  33566. "treatCostTotal": treatCostTotal,
  33567. "treatCostSelfTotal": treatCostSelfTotal,
  33568. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  33569. "treatSelfTotal": treatSelfTotal,
  33570. "treatInscpTotal": treatInscpTotal,
  33571. "doctor_info": doctor_info,
  33572. "doctor_code": adminRole_two.DoctorCode,
  33573. "doctor_name": doctor_name,
  33574. "health_card_no": order.PsnNo,
  33575. "department": departments.Name,
  33576. "yiliao_leibie": yiliao_leibie,
  33577. "after_money": order.AccountPrice,
  33578. "patient": patient,
  33579. "org_name": miConfig.OrgName,
  33580. "org_code": miConfig.Code,
  33581. "order_number": order.Number,
  33582. "his_hospital": his_hospital,
  33583. "his": his,
  33584. "dia_config": dia_config,
  33585. "psn_cash_pay": order.PsnCashPay,
  33586. //"check_order_info": cus_slice,
  33587. }
  33588. data3 = append(data3, data2)
  33589. }
  33590. }
  33591. }
  33592. c.ServeSuccessJSON(map[string]interface{}{
  33593. "infos": data3,
  33594. })
  33595. }
  33596. func (c *HisApiController) GetSettleAccounts() {
  33597. //id, _ := c.GetInt64("id")
  33598. //record_time := c.GetString("record_time")
  33599. order_id, _ := c.GetInt64("order_id")
  33600. admin_user_id, _ := c.GetInt64("admin_user_id")
  33601. //timeLayout := "2006-01-02"
  33602. //loc, _ := time.LoadLocation("Local")
  33603. //
  33604. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33605. //if err != nil {
  33606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33607. // return
  33608. //}Hbyb5203
  33609. //recordDateTime := theTime.Unix()
  33610. adminUser := c.GetAdminUserInfo()
  33611. order, _ := service.GetHisOrderByID(order_id)
  33612. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33613. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  33614. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  33615. orderInfos = append(orderInfos, orderInfos_two...)
  33616. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  33617. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  33618. var diagnosis_ids []string
  33619. if his.ID > 0 {
  33620. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  33621. } else {
  33622. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  33623. }
  33624. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  33625. var dia_config []*models.HisXtDiagnoseConfig
  33626. var name string
  33627. for _, item := range diagnosis_ids {
  33628. id, _ := strconv.ParseInt(item, 10, 64)
  33629. diagnosisConfig, _ := service.FindDiagnoseById(id)
  33630. dia_config = append(dia_config, &diagnosisConfig)
  33631. if len(name) == 0 {
  33632. name = diagnosisConfig.ClassName
  33633. } else {
  33634. name = name + "," + diagnosisConfig.ClassName
  33635. }
  33636. }
  33637. if patient.UserOrgId == 10215 {
  33638. name = "慢性肾功能不全(血透治疗)"
  33639. }
  33640. var bedCostTotal float64 = 0 //床位总费
  33641. var bedCostSelfTotal float64 = 0 //床位自费
  33642. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  33643. var bedSelfTotal float64 = 0 //床位部分项目自费
  33644. var bedInscpTotal float64 = 0 //床位部分项目自费
  33645. var operationCostTotal float64 = 0 //手术费
  33646. var operationCostSelfTotal float64 = 0 //手术费
  33647. var operationCostPartSelfTotal float64 = 0 //手术费
  33648. var operationSelfTotal float64 = 0 //床位部分项目自费
  33649. var operationInscpTotal float64 = 0 //床位部分项目自费
  33650. var otherCostTotal float64 = 0 //其他费用
  33651. var otherCostSelfTotal float64 = 0 //其他费用
  33652. var otherCostPartSelfTotal float64 = 0 //其他费用
  33653. var otherSelfTotal float64 = 0 //床位部分项目自费
  33654. var otherInscpTotal float64 = 0 //床位部分项目自费
  33655. var materialCostTotal float64 = 0 //材料费
  33656. var materialCostSelfTotal float64 = 0 //材料费
  33657. var materialCostPartSelfTotal float64 = 0 //材料费
  33658. var materialSelfTotal float64 = 0 //床位部分项目自费
  33659. var materialInscpTotal float64 = 0 //床位部分项目自费
  33660. var westernMedicineCostTotal float64 = 0 //西药费
  33661. var westernMedicineCostSelfTotal float64 = 0 //西药费
  33662. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  33663. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  33664. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  33665. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  33666. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  33667. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  33668. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  33669. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  33670. var checkCostTotal float64 = 0 //检查费
  33671. var checkCostSelfTotal float64 = 0 //检查费
  33672. var checkCostPartSelfTotal float64 = 0 //检查费
  33673. var checkSelfTotal float64 = 0 //床位部分项目自费
  33674. var checkInscpTotal float64 = 0 //床位部分项目自费
  33675. var laboratoryCostTotal float64 = 0 //化验费
  33676. var laboratoryCostSelfTotal float64 = 0 //化验费
  33677. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  33678. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  33679. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  33680. var treatCostTotal float64 = 0 //治疗费用
  33681. var treatCostSelfTotal float64 = 0 //治疗费用
  33682. var treatCostPartSelfTotal float64 = 0 //治疗费用
  33683. var treatSelfTotal float64 = 0 //床位部分项目自费
  33684. var treatInscpTotal float64 = 0 //床位部分项目自费
  33685. var zcCostTotal float64 = 0 //治疗费用
  33686. var zcCostSelfTotal float64 = 0 //治疗费用
  33687. var zcCostPartSelfTotal float64 = 0 //治疗费用
  33688. var zcSelfTotal float64 = 0 //床位部分项目自费
  33689. var zcInscpTotal float64 = 0 //床位部分项目自费
  33690. var huliCostTotal float64 = 0 //治疗费用
  33691. var huliCostSelfTotal float64 = 0 //治疗费用
  33692. var huliCostPartSelfTotal float64 = 0 //治疗费用
  33693. var huliSelfTotal float64 = 0 //床位部分项目自费
  33694. var huliInscpTotal float64 = 0 //床位部分项目自费
  33695. decimal.DivisionPrecision = 2
  33696. for _, item := range orderInfos {
  33697. if item.MedChrgitmType == "01" { //床位费
  33698. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33699. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33700. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33701. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33702. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33703. }
  33704. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  33705. if item.MedChrgitmType == "03" { //检查费
  33706. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33707. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33708. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33709. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33710. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33711. }
  33712. } else {
  33713. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  33714. fmt.Println("------------")
  33715. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33716. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33717. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33718. }
  33719. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  33720. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33721. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33722. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33723. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33724. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33725. }
  33726. }
  33727. if item.MedChrgitmType == "04" { //化验费
  33728. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33729. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33730. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33731. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33732. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33733. }
  33734. if item.MedChrgitmType == "05" { //治疗费
  33735. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33736. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33737. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33738. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33739. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33740. }
  33741. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  33742. fmt.Println("------------")
  33743. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33744. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33745. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33746. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33747. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33748. }
  33749. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  33750. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33751. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33752. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33753. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33754. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33755. }
  33756. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  33757. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33758. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33759. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33760. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33761. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33762. }
  33763. if item.MedChrgitmType == "09" { //西药费
  33764. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33765. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33766. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33767. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33768. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33769. }
  33770. if item.MedChrgitmType == "11" { //中成费
  33771. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33772. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33773. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33774. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33775. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33776. }
  33777. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  33778. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33779. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33780. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33781. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33782. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33783. }
  33784. if item.MedChrgitmType == "02" { //其他费
  33785. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33786. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33787. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33788. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33789. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33790. }
  33791. if item.MedChrgitmType == "07" { //其他费
  33792. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33793. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33794. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33795. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33796. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33797. }
  33798. }
  33799. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33800. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33801. var user_name string
  33802. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33803. if role.ID == 0 {
  33804. user_name = "管理员"
  33805. } else {
  33806. user_name = role.UserName
  33807. }
  33808. baseParams := models.BaseParams{
  33809. SecretKey: miConfig.SecretKey,
  33810. FixmedinsCode: miConfig.Code,
  33811. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33812. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33813. OrgName: miConfig.OrgName,
  33814. Doctor: user_name,
  33815. RequestUrl: miConfig.Url,
  33816. AccessKey: miConfig.AccessKey,
  33817. }
  33818. businessParams := models.BusinessParams{
  33819. PsnNo: order.PsnNo,
  33820. MdtrtId: order.MdtrtId,
  33821. SetlId: order.SetlId,
  33822. }
  33823. var res ResultEleven
  33824. var resah ResultElevenah
  33825. var resEleven10265 ResultEleven10265
  33826. if config.IsOpen == 1 {
  33827. if miConfig.MdtrtareaAdmvs == "421300" {
  33828. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  33829. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  33830. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33831. resp, requestErr := http.Get(api)
  33832. if requestErr != nil {
  33833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33834. return
  33835. }
  33836. body, ioErr := ioutil.ReadAll(resp.Body)
  33837. if ioErr != nil {
  33838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33840. return
  33841. }
  33842. var respJSON map[string]interface{}
  33843. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33846. return
  33847. }
  33848. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33849. result, _ := json.Marshal(respJSON)
  33850. fmt.Println("log")
  33851. fmt.Println(string(result))
  33852. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33853. utils.ErrorLog("解析失败:%v", err)
  33854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33855. return
  33856. }
  33857. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33858. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  33859. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  33860. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33861. resp, requestErr := http.Get(api)
  33862. if requestErr != nil {
  33863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33864. return
  33865. }
  33866. body, ioErr := ioutil.ReadAll(resp.Body)
  33867. if ioErr != nil {
  33868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33870. return
  33871. }
  33872. var respJSON map[string]interface{}
  33873. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33876. return
  33877. }
  33878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33879. result, _ := json.Marshal(respJSON)
  33880. fmt.Println("log")
  33881. fmt.Println(string(result))
  33882. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33883. utils.ErrorLog("解析失败:%v", err)
  33884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33885. return
  33886. }
  33887. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33888. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  33889. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  33890. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33891. resp, requestErr := http.Get(api)
  33892. if requestErr != nil {
  33893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33894. return
  33895. }
  33896. body, ioErr := ioutil.ReadAll(resp.Body)
  33897. if ioErr != nil {
  33898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33900. return
  33901. }
  33902. var respJSON map[string]interface{}
  33903. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33906. return
  33907. }
  33908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33909. result, _ := json.Marshal(respJSON)
  33910. fmt.Println("log")
  33911. fmt.Println(string(result))
  33912. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33913. utils.ErrorLog("解析失败:%v", err)
  33914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33915. return
  33916. }
  33917. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33918. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  33919. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  33920. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  33921. resp, requestErr := http.Get(api)
  33922. if requestErr != nil {
  33923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33924. return
  33925. }
  33926. body, ioErr := ioutil.ReadAll(resp.Body)
  33927. if ioErr != nil {
  33928. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33930. return
  33931. }
  33932. var respJSON map[string]interface{}
  33933. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33936. return
  33937. }
  33938. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33939. result, _ := json.Marshal(respJSON)
  33940. fmt.Println("log")
  33941. fmt.Println(string(result))
  33942. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33943. utils.ErrorLog("解析失败:%v", err)
  33944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33945. return
  33946. }
  33947. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33948. var api string
  33949. if miConfig.MdtrtareaAdmvs == "320921" {
  33950. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  33951. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  33952. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33953. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33954. } else {
  33955. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33956. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  33957. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  33958. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33959. }
  33960. resp, requestErr := http.Get(api)
  33961. if requestErr != nil {
  33962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33963. return
  33964. }
  33965. body, ioErr := ioutil.ReadAll(resp.Body)
  33966. if ioErr != nil {
  33967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33969. return
  33970. }
  33971. var respJSON map[string]interface{}
  33972. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33975. return
  33976. }
  33977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33978. result, _ := json.Marshal(respJSON)
  33979. fmt.Println("log")
  33980. fmt.Println(string(result))
  33981. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  33982. utils.ErrorLog("解析失败:%v", err)
  33983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33984. return
  33985. }
  33986. res.InfRefmsgid = resEleven10265.InfRefmsgid
  33987. res.Output = resEleven10265.Output
  33988. res.ErrMsg = resEleven10265.ErrMsg
  33989. res.Cainfo = resEleven10265.Cainfo
  33990. res.WarnMsg = resEleven10265.WarnMsg
  33991. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  33992. res.Infcode = infocode
  33993. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33994. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  33995. saveLog(result, requestLog, "5203", "结算单")
  33996. var dat map[string]interface{}
  33997. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33998. fmt.Println(dat)
  33999. } else {
  34000. fmt.Println(err)
  34001. }
  34002. userJSONBytes, _ := json.Marshal(dat)
  34003. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34004. utils.ErrorLog("解析失败:%v", err)
  34005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34006. return
  34007. }
  34008. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34009. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34010. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  34011. fmt.Println(result3)
  34012. fmt.Println(requestLog3)
  34013. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  34014. fmt.Println(result2)
  34015. fmt.Println(requestLog2)
  34016. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34017. saveLog(result, requestLog, "5203", "结算单")
  34018. var dat map[string]interface{}
  34019. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34020. fmt.Println(dat)
  34021. } else {
  34022. fmt.Println(err)
  34023. }
  34024. userJSONBytes, _ := json.Marshal(dat)
  34025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34026. utils.ErrorLog("解析失败:%v", err)
  34027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34028. return
  34029. }
  34030. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34031. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34032. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  34033. fmt.Println(result3)
  34034. fmt.Println(requestLog3)
  34035. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  34036. fmt.Println(result2)
  34037. fmt.Println(requestLog2)
  34038. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34039. saveLog(result, requestLog, "5203", "结算单")
  34040. var dat map[string]interface{}
  34041. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34042. fmt.Println(dat)
  34043. } else {
  34044. fmt.Println(err)
  34045. }
  34046. userJSONBytes, _ := json.Marshal(dat)
  34047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34048. utils.ErrorLog("解析失败:%v", err)
  34049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34050. return
  34051. }
  34052. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34053. var api string
  34054. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34055. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34056. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34057. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34058. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34059. resp, requestErr := http.Get(api)
  34060. if requestErr != nil {
  34061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34062. return
  34063. }
  34064. body, ioErr := ioutil.ReadAll(resp.Body)
  34065. if ioErr != nil {
  34066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34068. return
  34069. }
  34070. var respJSON map[string]interface{}
  34071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34074. return
  34075. }
  34076. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34077. if status == "0" {
  34078. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34079. c.ServeSuccessJSON(map[string]interface{}{
  34080. "failed_code": -10,
  34081. "msg": err_msg,
  34082. })
  34083. return
  34084. }
  34085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34086. result, _ := json.Marshal(respJSON)
  34087. fmt.Println("log")
  34088. fmt.Println(string(result))
  34089. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34090. utils.ErrorLog("解析失败:%v", err)
  34091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34092. return
  34093. }
  34094. res.InfRefmsgid = resah.InfRefmsgid
  34095. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34096. // 创建对应的Time类型
  34097. t := time.UnixMilli(timestamp)
  34098. // 格式化成指定的日期字符串
  34099. str := t.Format("2006-01-02 15:04:05")
  34100. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34101. // 创建对应的Time类型
  34102. t3 := time.UnixMilli(timestamp2)
  34103. // 格式化成指定的日期字符串
  34104. str2 := t3.Format("2006-01-02 15:04:05")
  34105. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34106. // 创建对应的Time类型
  34107. t4 := time.UnixMilli(timestamp3)
  34108. // 格式化成指定的日期字符串
  34109. str3 := t4.Format("2006-01-02 15:04:05")
  34110. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34111. // 创建对应的Time类型
  34112. t5 := time.UnixMilli(timestamp4)
  34113. // 格式化成指定的日期字符串
  34114. str5 := t5.Format("2006-01-02 15:04:05")
  34115. res.Output.Setlinfo.Brdy = str2
  34116. res.Output.Setlinfo.SetlTime = str
  34117. res.Output.Setlinfo.Begndate = str3
  34118. res.Output.Setlinfo.Enddate = str5
  34119. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34120. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34121. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34122. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34123. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34124. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34125. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34126. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34127. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34128. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34129. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34130. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34131. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34132. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34133. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34134. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34135. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34136. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34137. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34138. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34139. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34140. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34141. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34142. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34143. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34144. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34145. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34146. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34147. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34148. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34149. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34150. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34151. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34152. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34153. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34154. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34155. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34156. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34157. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34158. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34159. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34160. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34161. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34162. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34163. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34164. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34165. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  34166. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  34167. //res.Output.Setldetail = resah.Output.Setldetail
  34168. res.ErrMsg = resah.ErrMsg
  34169. res.Cainfo = resah.Cainfo
  34170. res.WarnMsg = resah.WarnMsg
  34171. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34172. var api string
  34173. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34174. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34175. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34176. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34177. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34178. resp, requestErr := http.Get(api)
  34179. if requestErr != nil {
  34180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34181. return
  34182. }
  34183. body, ioErr := ioutil.ReadAll(resp.Body)
  34184. if ioErr != nil {
  34185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34187. return
  34188. }
  34189. var respJSON map[string]interface{}
  34190. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34193. return
  34194. }
  34195. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34196. if status == "0" {
  34197. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34198. c.ServeSuccessJSON(map[string]interface{}{
  34199. "failed_code": -10,
  34200. "msg": err_msg,
  34201. })
  34202. return
  34203. }
  34204. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34205. result, _ := json.Marshal(respJSON)
  34206. fmt.Println("log")
  34207. fmt.Println(string(result))
  34208. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34209. utils.ErrorLog("解析失败:%v", err)
  34210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34211. return
  34212. }
  34213. res.InfRefmsgid = resah.InfRefmsgid
  34214. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34215. // 创建对应的Time类型
  34216. t := time.UnixMilli(timestamp)
  34217. // 格式化成指定的日期字符串
  34218. str := t.Format("2006-01-02 15:04:05")
  34219. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34220. // 创建对应的Time类型
  34221. t3 := time.UnixMilli(timestamp2)
  34222. // 格式化成指定的日期字符串
  34223. str2 := t3.Format("2006-01-02 15:04:05")
  34224. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34225. // 创建对应的Time类型
  34226. t4 := time.UnixMilli(timestamp3)
  34227. // 格式化成指定的日期字符串
  34228. str3 := t4.Format("2006-01-02 15:04:05")
  34229. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34230. // 创建对应的Time类型
  34231. t5 := time.UnixMilli(timestamp4)
  34232. // 格式化成指定的日期字符串
  34233. str5 := t5.Format("2006-01-02 15:04:05")
  34234. res.Output.Setlinfo.Brdy = str2
  34235. res.Output.Setlinfo.SetlTime = str
  34236. res.Output.Setlinfo.Begndate = str3
  34237. res.Output.Setlinfo.Enddate = str5
  34238. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34239. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34240. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34241. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34242. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34243. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34244. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34245. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34246. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34247. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34248. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34249. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34250. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34251. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34252. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34253. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34254. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34255. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34256. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34257. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34258. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34259. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34260. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34261. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34262. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34263. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34264. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34265. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34266. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34267. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34268. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34269. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34270. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34271. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34272. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34273. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34274. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34275. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34276. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34277. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34278. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34279. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34280. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34281. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34282. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34283. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34284. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  34285. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  34286. //res.Output.Setldetail = resah.Output.Setldetail
  34287. res.ErrMsg = resah.ErrMsg
  34288. res.Cainfo = resah.Cainfo
  34289. res.WarnMsg = resah.WarnMsg
  34290. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34291. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  34292. saveLog(result, requestLog, "5203", "结算单")
  34293. var dat map[string]interface{}
  34294. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34295. fmt.Println(dat)
  34296. } else {
  34297. fmt.Println(err)
  34298. }
  34299. userJSONBytes, _ := json.Marshal(dat)
  34300. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34301. utils.ErrorLog("解析失败:%v", err)
  34302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34303. return
  34304. }
  34305. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34306. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34307. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34308. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34309. resp, requestErr := http.Get(api)
  34310. if requestErr != nil {
  34311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34312. return
  34313. }
  34314. body, ioErr := ioutil.ReadAll(resp.Body)
  34315. if ioErr != nil {
  34316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34318. return
  34319. }
  34320. var respJSON map[string]interface{}
  34321. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34324. return
  34325. }
  34326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34327. result, _ := json.Marshal(respJSON)
  34328. fmt.Println("log")
  34329. fmt.Println(string(result))
  34330. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34331. utils.ErrorLog("解析失败:%v", err)
  34332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34333. return
  34334. }
  34335. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34336. res.Output = resEleven10265.Output
  34337. res.ErrMsg = resEleven10265.ErrMsg
  34338. res.Cainfo = resEleven10265.Cainfo
  34339. res.WarnMsg = resEleven10265.WarnMsg
  34340. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34341. res.Infcode = infocode
  34342. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34343. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34344. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34345. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34346. resp, requestErr := http.Get(api)
  34347. if requestErr != nil {
  34348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34349. return
  34350. }
  34351. body, ioErr := ioutil.ReadAll(resp.Body)
  34352. if ioErr != nil {
  34353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34355. return
  34356. }
  34357. var respJSON map[string]interface{}
  34358. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34361. return
  34362. }
  34363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34364. result, _ := json.Marshal(respJSON)
  34365. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34366. utils.ErrorLog("解析失败:%v", err)
  34367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34368. return
  34369. }
  34370. } else if miConfig.MdtrtareaAdmvs == "450721" {
  34371. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  34372. //return
  34373. } else {
  34374. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34375. if len(his.InsuplcAdmdvs) == 0 {
  34376. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34377. } else {
  34378. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34379. }
  34380. result := service.Gdyb5203(baseParams, businessParams)
  34381. //service.Gdyb5204(baseParams, businessParams)
  34382. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34383. var dat map[string]interface{}
  34384. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34385. fmt.Println(dat)
  34386. } else {
  34387. fmt.Println(err)
  34388. }
  34389. userJSONBytes, _ := json.Marshal(dat)
  34390. if miConfig.Code == "H15049901371" {
  34391. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34392. utils.ErrorLog("解析失败:%v", err)
  34393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34394. return
  34395. }
  34396. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34397. res.Output = resEleven10265.Output
  34398. res.ErrMsg = resEleven10265.ErrMsg
  34399. res.Cainfo = resEleven10265.Cainfo
  34400. res.WarnMsg = resEleven10265.WarnMsg
  34401. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34402. res.Infcode = infocode
  34403. } else {
  34404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34405. utils.ErrorLog("解析失败:%v", err)
  34406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34407. return
  34408. }
  34409. }
  34410. }
  34411. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34412. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34413. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34414. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34415. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34416. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34417. var doctor_name string
  34418. if roles.ID == 0 {
  34419. doctor_name = "管理员"
  34420. } else {
  34421. doctor_name = roles.UserName
  34422. }
  34423. yiliao_leibie := ""
  34424. switch order.MedType {
  34425. case "11":
  34426. yiliao_leibie = "普通门诊"
  34427. break
  34428. case "12":
  34429. yiliao_leibie = "门诊挂号"
  34430. break
  34431. case "13":
  34432. yiliao_leibie = "急诊"
  34433. break
  34434. case "14":
  34435. yiliao_leibie = "门诊特殊病"
  34436. break
  34437. case "15":
  34438. yiliao_leibie = "门诊统筹"
  34439. break
  34440. case "16":
  34441. yiliao_leibie = "门诊慢性病"
  34442. break
  34443. case "21":
  34444. yiliao_leibie = "普通住院"
  34445. break
  34446. }
  34447. //var rf []CustomFundPay
  34448. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  34449. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34450. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  34451. if res.Infcode == 0 {
  34452. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10454 || adminUser.CurrentOrgId == 10644 || adminUser.CurrentOrgId == 10653 {
  34453. c.ServeSuccessJSON(map[string]interface{}{
  34454. "diagnosis": name,
  34455. "order_infos": orderInfos,
  34456. "number": order.MdtrtId,
  34457. "date": order.SettleAccountsDate,
  34458. "charge_admin": charge_admin,
  34459. "printor_admin": printor_admin,
  34460. "info": res.Output.Setlinfo,
  34461. "order": order,
  34462. "bedCostTotal": bedCostTotal,
  34463. "bedCostSelfTotal": bedCostSelfTotal,
  34464. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34465. "bedSelfTotal": bedSelfTotal,
  34466. "bedInscpTotal": bedInscpTotal,
  34467. "operationCostTotal": operationCostTotal,
  34468. "operationCostSelfTotal": operationCostSelfTotal,
  34469. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34470. "operationSelfTotal": operationSelfTotal,
  34471. "operationInscpTotal": operationInscpTotal,
  34472. "otherCostTotal": otherCostTotal,
  34473. "otherCostSelfTotal": otherCostSelfTotal,
  34474. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34475. "otherSelfTotal": otherSelfTotal,
  34476. "otherInscpTotal": otherInscpTotal,
  34477. "materialCostTotal": materialCostTotal,
  34478. "materialCostSelfTotal": materialCostSelfTotal,
  34479. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34480. "materialSelfTotal": materialSelfTotal,
  34481. "materialInscpTotal": materialInscpTotal,
  34482. "westernMedicineCostTotal": westernMedicineCostTotal,
  34483. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34484. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34485. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34486. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34487. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34488. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34489. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34490. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34491. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34492. "checkCostTotal": checkCostTotal,
  34493. "checkCostSelfTotal": checkCostSelfTotal,
  34494. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34495. "checkSelfTotal": checkSelfTotal,
  34496. "checkInscpTotal": checkInscpTotal,
  34497. "laboratoryCostTotal": laboratoryCostTotal,
  34498. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34499. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34500. "laboratorySelfTotal": laboratorySelfTotal,
  34501. "laboratoryInscpTotal": laboratoryInscpTotal,
  34502. "treatCostTotal": treatCostTotal,
  34503. "treatCostSelfTotal": treatCostSelfTotal,
  34504. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34505. "treatSelfTotal": treatSelfTotal,
  34506. "treatInscpTotal": treatInscpTotal,
  34507. "doctor_info": doctor_info,
  34508. "doctor_code": adminRole_two.DoctorCode,
  34509. "doctor_name": doctor_name,
  34510. "health_card_no": order.PsnNo,
  34511. "department": departments.Name,
  34512. "yiliao_leibie": yiliao_leibie,
  34513. "after_money": order.AccountPrice,
  34514. "patient": patient,
  34515. "org_name": miConfig.OrgName,
  34516. "org_code": miConfig.Code,
  34517. "order_number": order.Number,
  34518. "his_hospital": his_hospital,
  34519. "his": his,
  34520. "dia_config": dia_config,
  34521. "psn_cash_pay": order.PsnCashPay,
  34522. "zcCostTotal": zcCostTotal,
  34523. "zcCostSelfTotal": zcCostSelfTotal,
  34524. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  34525. "zcSelfTotal": zcSelfTotal,
  34526. "zcInscpTotal": zcInscpTotal,
  34527. "huliCostTotal": huliCostTotal,
  34528. "huliCostSelfTotal": huliCostSelfTotal,
  34529. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  34530. "huliSelfTotal": huliSelfTotal,
  34531. "huliInscpTotal": huliInscpTotal,
  34532. //"funds": rf,
  34533. //"check_order_info": cus_slice,
  34534. })
  34535. } else {
  34536. c.ServeSuccessJSON(map[string]interface{}{
  34537. "diagnosis": name,
  34538. "order_infos": orderInfos,
  34539. "number": order.MdtrtId,
  34540. "date": order.SettleAccountsDate,
  34541. "charge_admin": charge_admin,
  34542. "printor_admin": printor_admin,
  34543. "info": order,
  34544. "order": order,
  34545. "bedCostTotal": bedCostTotal,
  34546. "bedCostSelfTotal": bedCostSelfTotal,
  34547. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34548. "bedSelfTotal": bedSelfTotal,
  34549. "bedInscpTotal": bedInscpTotal,
  34550. "operationCostTotal": operationCostTotal,
  34551. "operationCostSelfTotal": operationCostSelfTotal,
  34552. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34553. "operationSelfTotal": operationSelfTotal,
  34554. "operationInscpTotal": operationInscpTotal,
  34555. "otherCostTotal": otherCostTotal,
  34556. "otherCostSelfTotal": otherCostSelfTotal,
  34557. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34558. "otherSelfTotal": otherSelfTotal,
  34559. "otherInscpTotal": otherInscpTotal,
  34560. "materialCostTotal": materialCostTotal,
  34561. "materialCostSelfTotal": materialCostSelfTotal,
  34562. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34563. "materialSelfTotal": materialSelfTotal,
  34564. "materialInscpTotal": materialInscpTotal,
  34565. "westernMedicineCostTotal": westernMedicineCostTotal,
  34566. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34567. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34568. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34569. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34570. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34571. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34572. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34573. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34574. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34575. "checkCostTotal": checkCostTotal,
  34576. "checkCostSelfTotal": checkCostSelfTotal,
  34577. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34578. "checkSelfTotal": checkSelfTotal,
  34579. "checkInscpTotal": checkInscpTotal,
  34580. "laboratoryCostTotal": laboratoryCostTotal,
  34581. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34582. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34583. "laboratorySelfTotal": laboratorySelfTotal,
  34584. "laboratoryInscpTotal": laboratoryInscpTotal,
  34585. "treatCostTotal": treatCostTotal,
  34586. "treatCostSelfTotal": treatCostSelfTotal,
  34587. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34588. "treatSelfTotal": treatSelfTotal,
  34589. "treatInscpTotal": treatInscpTotal,
  34590. "doctor_info": doctor_info,
  34591. "doctor_code": adminRole_two.DoctorCode,
  34592. "doctor_name": doctor_name,
  34593. "health_card_no": order.PsnNo,
  34594. "department": departments.Name,
  34595. "yiliao_leibie": yiliao_leibie,
  34596. "after_money": order.AccountPrice,
  34597. "patient": patient,
  34598. "org_name": miConfig.OrgName,
  34599. "org_code": miConfig.Code,
  34600. "order_number": order.Number,
  34601. "his_hospital": his_hospital,
  34602. "his": his,
  34603. "dia_config": dia_config,
  34604. "psn_cash_pay": order.PsnCashPay,
  34605. "zcCostTotal": zcCostTotal,
  34606. "zcCostSelfTotal": zcCostSelfTotal,
  34607. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  34608. "zcSelfTotal": zcSelfTotal,
  34609. "zcInscpTotal": zcInscpTotal,
  34610. "huliCostTotal": huliCostTotal,
  34611. "huliCostSelfTotal": huliCostSelfTotal,
  34612. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  34613. "huliSelfTotal": huliSelfTotal,
  34614. "huliInscpTotal": huliInscpTotal,
  34615. //"funds": rf,
  34616. //"check_order_info": cus_slice,
  34617. })
  34618. }
  34619. }
  34620. }
  34621. }
  34622. //func (c *HisApiController) CheckTreatment() {
  34623. // patient_id, _ := c.GetInt64("patient_id")
  34624. // id_card_no := c.GetString("id_card_no")
  34625. // insutype := c.GetString("insutype")
  34626. // med_type := c.GetString("med_type")
  34627. // admin_user_id, _ := c.GetInt64("admin_user_id")
  34628. //
  34629. // adminUser := c.GetAdminUserInfo()
  34630. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  34631. //
  34632. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34633. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34634. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34635. //
  34636. // if miConfig.MdtrtareaAdmvs == "421300" {
  34637. // var res ResultTwo
  34638. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  34639. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  34640. // "&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)
  34641. // resp, requestErr := http.Get(api)
  34642. // if requestErr != nil {
  34643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34644. // return
  34645. // }
  34646. //
  34647. // body, ioErr := ioutil.ReadAll(resp.Body)
  34648. // if ioErr != nil {
  34649. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34651. // return
  34652. // }
  34653. // var respJSON map[string]interface{}
  34654. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34655. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34657. // return
  34658. // }
  34659. //
  34660. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34661. // result, _ := json.Marshal(respJSON)
  34662. //
  34663. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  34664. // utils.ErrorLog("解析失败:%v", err)
  34665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34666. // return
  34667. // }
  34668. //
  34669. // if res.Infcode == 0 {
  34670. //
  34671. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  34672. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  34673. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  34674. // resp, requestErr := http.Get(api)
  34675. // if requestErr != nil {
  34676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34677. // return
  34678. // }
  34679. //
  34680. // body, ioErr := ioutil.ReadAll(resp.Body)
  34681. // if ioErr != nil {
  34682. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34683. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34684. // return
  34685. // }
  34686. // var respJSON map[string]interface{}
  34687. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34688. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34690. // return
  34691. // }
  34692. // var res Result2001
  34693. //
  34694. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34695. // result2, _ := json.Marshal(respJSON)
  34696. //
  34697. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  34698. // utils.ErrorLog("解析失败:%v", err)
  34699. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34700. // return
  34701. // }
  34702. //
  34703. // if res.Infcode == 0 {
  34704. // c.ServeSuccessJSON(map[string]interface{}{
  34705. // "msg": res.Output.Trtinfo,
  34706. // })
  34707. // }
  34708. //
  34709. // } else {
  34710. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34711. // return
  34712. // }
  34713. //
  34714. // } else {
  34715. //
  34716. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  34717. // var dat map[string]interface{}
  34718. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34719. // fmt.Println(dat)
  34720. // } else {
  34721. // fmt.Println(err)
  34722. // }
  34723. // userJSONBytes, _ := json.Marshal(dat)
  34724. // var res ResultTwo
  34725. // var res10265 ResultTwo10265
  34726. // if miConfig.Code == "H15049901371" {
  34727. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  34728. // utils.ErrorLog("解析失败:%v", err)
  34729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34730. // return
  34731. // }
  34732. // res.ErrMsg = res10265.ErrMsg
  34733. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34734. // res.Infcode = infocode
  34735. // res.Output = res10265.Output
  34736. // res.InfRefmsgid = res10265.InfRefmsgid
  34737. // } else {
  34738. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34739. // utils.ErrorLog("解析失败:%v", err)
  34740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34741. // return
  34742. // }
  34743. // }
  34744. //
  34745. // var user_name string
  34746. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  34747. // if role.ID == 0 {
  34748. // user_name = "xxx"
  34749. // } else {
  34750. // user_name = role.UserName
  34751. // }
  34752. //
  34753. // baseParams := models.BaseParams{
  34754. // SecretKey: miConfig.SecretKey,
  34755. // FixmedinsCode: miConfig.Code,
  34756. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34757. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34758. // OrgName: miConfig.OrgName,
  34759. // Doctor: user_name,
  34760. // }
  34761. //
  34762. // if config.IsOpen == 1 {
  34763. // if miConfig.Code == "H15049901371" {
  34764. // if med_type == "14" {
  34765. // if insutype == "390" {
  34766. // med_type = "9933"
  34767. // } else if insutype == "310" {
  34768. // med_type = "990502"
  34769. // }
  34770. // } else if med_type == "11" {
  34771. // med_type = "11"
  34772. // }
  34773. // }
  34774. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  34775. // var dat map[string]interface{}
  34776. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34777. // fmt.Println(dat)
  34778. // } else {
  34779. // fmt.Println(err)
  34780. // }
  34781. // var res Result2001
  34782. // var res10265 Result2001Org10265
  34783. // if miConfig.Code == "H15049901371" {
  34784. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  34785. // utils.ErrorLog("解析失败:%v", err)
  34786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34787. // return
  34788. // }
  34789. // res.ErrMsg = res10265.ErrMsg
  34790. // res.Output = res10265.Output
  34791. // res.InfRefmsgid = res10265.InfRefmsgid
  34792. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34793. // res.Infcode = infocode
  34794. // } else {
  34795. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  34796. // utils.ErrorLog("解析失败:%v", err)
  34797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34798. // return
  34799. // }
  34800. // }
  34801. // if res.Infcode == 0 {
  34802. // c.ServeSuccessJSON(map[string]interface{}{
  34803. // "msg": res.Output.Trtinfo,
  34804. // })
  34805. // }
  34806. // }
  34807. // }
  34808. //}
  34809. //func (c *HisApiController) PutRecord() {
  34810. // id, _ := c.GetInt64("id")
  34811. // record_time := c.GetString("record_time")
  34812. // timeLayout := "2006-01-02"
  34813. // loc, _ := time.LoadLocation("Local")
  34814. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34815. // if err != nil {
  34816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34817. // return
  34818. // }
  34819. // recordDateTime := theTime.Unix()
  34820. //
  34821. // adminInfo := c.GetAdminUserInfo()
  34822. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  34823. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  34824. //
  34825. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  34826. //
  34827. // fmt.Println(miConfig.SecretKey)
  34828. //
  34829. // if patient == nil {
  34830. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  34831. // return
  34832. // }
  34833. // if len(patient.IdCardNo) == 0 {
  34834. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  34835. // return
  34836. // }
  34837. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  34838. // if config.IsOpen == 1 {
  34839. // 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
  34840. // resp, requestErr := http.Get(api)
  34841. // if requestErr != nil {
  34842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34843. // return
  34844. // }
  34845. // defer resp.Body.Close()
  34846. // body, ioErr := ioutil.ReadAll(resp.Body)
  34847. // if ioErr != nil {
  34848. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34850. // return
  34851. // }
  34852. // var respJSON map[string]interface{}
  34853. //
  34854. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34855. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34856. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34857. // return
  34858. // }
  34859. //
  34860. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34861. // userJSONBytes, _ := json.Marshal(userJSON)
  34862. // var res ResultTwo
  34863. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34864. // utils.ErrorLog("解析失败:%v", err)
  34865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34866. // return
  34867. // }
  34868. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34869. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34870. // infoStr := string(Iinfos)
  34871. // idetinfoStr := string(Idetinfos)
  34872. //
  34873. // if res.Infcode == 0 {
  34874. // his := models.VMHisPatient{
  34875. // Status: 1,
  34876. // Ctime: time.Now().Unix(),
  34877. // Mtime: time.Now().Unix(),
  34878. // PsnNo: res.Output.Baseinfo.PsnNo,
  34879. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  34880. // Certno: res.Output.Baseinfo.Certno,
  34881. // PsnName: res.Output.Baseinfo.PsnName,
  34882. // Gend: res.Output.Baseinfo.Gend,
  34883. // Naty: res.Output.Baseinfo.Naty,
  34884. // Brdy: res.Output.Baseinfo.Brdy,
  34885. // Age: res.Output.Baseinfo.Age,
  34886. // Iinfo: infoStr,
  34887. // Idetinfo: idetinfoStr,
  34888. // PatientId: patient.ID,
  34889. // RecordDate: theTime.Unix(),
  34890. // UserOrgId: adminInfo.CurrentOrgId,
  34891. // AdminUserId: adminInfo.AdminUser.Id,
  34892. // IsReturn: 1,
  34893. // }
  34894. //
  34895. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  34896. // //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")
  34897. // //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")
  34898. //
  34899. // //var dat map[string]interface{}
  34900. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34901. // // fmt.Println(dat)
  34902. // //} else {
  34903. // // fmt.Println(err)
  34904. // //}
  34905. //
  34906. // var dat2 map[string]interface{}
  34907. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  34908. // fmt.Println(dat2)
  34909. // } else {
  34910. // fmt.Println(err)
  34911. // }
  34912. //
  34913. // } else {
  34914. // adminUser := c.GetAdminUserInfo()
  34915. // errlog := &models.HisOrderError{
  34916. // UserOrgId: adminUser.CurrentOrgId,
  34917. // Ctime: time.Now().Unix(),
  34918. // Mtime: time.Now().Unix(),
  34919. // ErrMsg: res.ErrMsg,
  34920. // Status: 1,
  34921. // PatientId: id,
  34922. // RecordTime: recordDateTime,
  34923. // Stage: 1,
  34924. // }
  34925. // service.CreateErrMsgLog(errlog)
  34926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  34927. // return
  34928. // }
  34929. // }
  34930. //
  34931. //}
  34932. //func (c *HisApiController) GetUploadDiag() {
  34933. // id, _ := c.GetInt64("id")
  34934. // record_time := c.GetString("record_time")
  34935. //
  34936. // diagnosis_id, _ := c.GetInt64("diagnosis")
  34937. // sick_type, _ := c.GetInt64("sick_type")
  34938. // reg_type, _ := c.GetInt64("reg_type")
  34939. //
  34940. // timeLayout := "2006-01-02"
  34941. // loc, _ := time.LoadLocation("Local")
  34942. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34943. // if err != nil {
  34944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34945. // return
  34946. // }
  34947. //
  34948. // var patientPrescription models.HisPrescriptionInfo
  34949. // recordDateTime := theTime.Unix()
  34950. // adminInfo := c.GetAdminUserInfo()
  34951. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  34952. //
  34953. // if patientPrescription.ID == 0 {
  34954. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  34955. // }
  34956. //
  34957. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  34958. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  34959. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  34960. // sickConfig, _ := service.FindSickById(sick_type)
  34961. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34962. //
  34963. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  34964. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  34965. // "&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 +
  34966. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  34967. // resp2, requestErr2 := http.Get(api2)
  34968. // if requestErr2 != nil {
  34969. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34970. // return
  34971. // }
  34972. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  34973. // if ioErr2 != nil {
  34974. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  34975. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34976. // return
  34977. // }
  34978. // var respJSON2 map[string]interface{}
  34979. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  34980. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34981. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34982. // return
  34983. // }
  34984. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34985. // userJSONBytes2, _ := json.Marshal(respJSON2)
  34986. //
  34987. // var res2 ResultSix
  34988. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  34989. // utils.ErrorLog("解析失败:%v", err)
  34990. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34991. // return
  34992. // }
  34993. // if res2.Infcode != 0 {
  34994. // adminUser := c.GetAdminUserInfo()
  34995. // errlog := &models.HisOrderError{
  34996. // UserOrgId: adminUser.CurrentOrgId,
  34997. // Ctime: time.Now().Unix(),
  34998. // Mtime: time.Now().Unix(),
  34999. // ErrMsg: res2.ErrMsg,
  35000. // Status: 1,
  35001. // PatientId: id,
  35002. // RecordTime: recordDateTime,
  35003. // Stage: 3,
  35004. // }
  35005. // service.CreateErrMsgLog(errlog)
  35006. //
  35007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35008. // return
  35009. // }
  35010. //
  35011. // c.ServeSuccessJSON(map[string]interface{}{
  35012. // "msg": "上传成功",
  35013. // })
  35014. //
  35015. //}
  35016. type QueryResult struct {
  35017. ID int64
  35018. Name string
  35019. Code string
  35020. List_type_code string
  35021. }
  35022. func (c *HisApiController) GetCheckCode() {
  35023. ids_str := c.GetString("ids")
  35024. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35025. ids_arr := strings.Split(ids_str, ",")
  35026. var queryResult []QueryResult
  35027. ids := make([]int64, 0)
  35028. for _, item := range ids_arr {
  35029. id, _ := strconv.ParseInt(item, 10, 64)
  35030. ids = append(ids, id)
  35031. }
  35032. if record_type == 1 {
  35033. drugs, _ := service.GetBatchDrugList(ids)
  35034. for _, item := range drugs {
  35035. result := QueryResult{
  35036. ID: item.ID,
  35037. Name: item.DrugName,
  35038. Code: item.MedicalInsuranceNumber,
  35039. List_type_code: "101",
  35040. }
  35041. queryResult = append(queryResult, result)
  35042. }
  35043. } else if record_type == 2 {
  35044. goods, _ := service.GetBatchGoodInformationList(ids)
  35045. fmt.Println(goods)
  35046. for _, item := range goods {
  35047. result := QueryResult{
  35048. ID: item.ID,
  35049. Name: item.GoodName,
  35050. Code: item.SocialSecurityDirectoryCode,
  35051. List_type_code: "301",
  35052. }
  35053. queryResult = append(queryResult, result)
  35054. }
  35055. } else if record_type == 3 {
  35056. projects, _ := service.GetBathchMyPorjecgList(ids)
  35057. for _, item := range projects {
  35058. result := QueryResult{
  35059. ID: item.ID,
  35060. Name: item.ProjectName,
  35061. Code: item.MedicalCode,
  35062. List_type_code: "201",
  35063. }
  35064. queryResult = append(queryResult, result)
  35065. }
  35066. }
  35067. admin_user_id, _ := c.GetInt64("admin_user_id")
  35068. adminUser := c.GetAdminUserInfo()
  35069. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35070. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35071. var user_name string
  35072. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35073. if role.ID == 0 {
  35074. user_name = "管理员"
  35075. } else {
  35076. user_name = role.UserName
  35077. }
  35078. baseParams := models.BaseParams{
  35079. SecretKey: miConfig.SecretKey,
  35080. FixmedinsCode: miConfig.Code,
  35081. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35082. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35083. OrgName: miConfig.OrgName,
  35084. Doctor: user_name,
  35085. }
  35086. var result string
  35087. if miConfig.MdtrtareaAdmvs == "430800" {
  35088. for _, item := range queryResult {
  35089. if record_type == 1 {
  35090. 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)
  35091. } else if record_type == 2 {
  35092. fmt.Println(item.Code)
  35093. 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)
  35094. } else if record_type == 3 {
  35095. 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)
  35096. }
  35097. var dat map[string]interface{}
  35098. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35099. fmt.Println(dat)
  35100. } else {
  35101. fmt.Println(err)
  35102. }
  35103. userJSONBytes, _ := json.Marshal(dat)
  35104. var res ResultSix
  35105. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35106. utils.ErrorLog("解析失败:%v", err)
  35107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35108. return
  35109. }
  35110. if res.Infcode == 0 {
  35111. if record_type == 1 {
  35112. service.UpdateBaseDrugById(item.ID)
  35113. } else if record_type == 2 {
  35114. service.UpdateGoodInformaitonByDetail(item.ID)
  35115. } else if record_type == 3 {
  35116. service.UpdateProjectById(item.ID)
  35117. }
  35118. c.ServeSuccessJSON(map[string]interface{}{
  35119. "failed_code": 0,
  35120. "msg": "目录对照成功",
  35121. })
  35122. } else {
  35123. c.ServeSuccessJSON(map[string]interface{}{
  35124. "failed_code": -10,
  35125. "msg": res.ErrMsg,
  35126. })
  35127. }
  35128. }
  35129. } else {
  35130. for _, item := range queryResult {
  35131. var result string
  35132. if record_type == 1 {
  35133. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35134. } else if record_type == 2 {
  35135. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35136. } else if record_type == 3 {
  35137. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35138. }
  35139. var dat map[string]interface{}
  35140. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35141. fmt.Println(dat)
  35142. } else {
  35143. fmt.Println(err)
  35144. }
  35145. userJSONBytes, _ := json.Marshal(dat)
  35146. var res ResultSix
  35147. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35148. utils.ErrorLog("解析失败:%v", err)
  35149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35150. return
  35151. }
  35152. if res.Infcode == 0 {
  35153. if record_type == 1 {
  35154. service.UpdateBaseDrugById(item.ID)
  35155. } else if record_type == 2 {
  35156. service.UpdateGoodInformaitonByDetail(item.ID)
  35157. } else if record_type == 3 {
  35158. service.UpdateProjectById(item.ID)
  35159. }
  35160. c.ServeSuccessJSON(map[string]interface{}{
  35161. "failed_code": 0,
  35162. "msg": "目录对照成功",
  35163. })
  35164. } else {
  35165. c.ServeSuccessJSON(map[string]interface{}{
  35166. "failed_code": -10,
  35167. "msg": res.ErrMsg,
  35168. })
  35169. }
  35170. }
  35171. }
  35172. }
  35173. func (c *HisApiController) UnCheckCode() {
  35174. ids_str := c.GetString("ids")
  35175. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35176. admin_user_id, _ := c.GetInt64("admin_user_id")
  35177. ids_arr := strings.Split(ids_str, ",")
  35178. var queryResult []QueryResult
  35179. ids := make([]int64, 0)
  35180. for _, item := range ids_arr {
  35181. id, _ := strconv.ParseInt(item, 10, 64)
  35182. ids = append(ids, id)
  35183. }
  35184. if record_type == 1 {
  35185. drugs, _ := service.GetBatchDrugList(ids)
  35186. for _, item := range drugs {
  35187. result := QueryResult{
  35188. ID: item.ID,
  35189. Name: item.DrugName,
  35190. Code: item.MedicalInsuranceNumber,
  35191. List_type_code: "101",
  35192. }
  35193. queryResult = append(queryResult, result)
  35194. }
  35195. } else if record_type == 2 {
  35196. goods, _ := service.GetBatchGoodInformationList(ids)
  35197. for _, item := range goods {
  35198. result := QueryResult{
  35199. ID: item.ID,
  35200. Name: item.GoodName,
  35201. Code: item.SocialSecurityDirectoryCode,
  35202. List_type_code: "301",
  35203. }
  35204. queryResult = append(queryResult, result)
  35205. }
  35206. } else if record_type == 3 {
  35207. projects, _ := service.GetBathchMyPorjecgList(ids)
  35208. for _, item := range projects {
  35209. result := QueryResult{
  35210. ID: item.ID,
  35211. Name: item.ProjectName,
  35212. Code: item.MedicalCode,
  35213. List_type_code: "201",
  35214. }
  35215. queryResult = append(queryResult, result)
  35216. }
  35217. }
  35218. adminUser := c.GetAdminUserInfo()
  35219. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35220. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35221. var user_name string
  35222. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35223. if role.ID == 0 {
  35224. user_name = "xxx"
  35225. } else {
  35226. user_name = role.UserName
  35227. }
  35228. baseParams := &models.BaseParams{
  35229. SecretKey: miConfig.SecretKey,
  35230. FixmedinsCode: miConfig.Code,
  35231. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35232. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35233. OrgName: miConfig.OrgName,
  35234. Doctor: user_name,
  35235. }
  35236. if config.IsOpen == 1 {
  35237. if miConfig.MdtrtareaAdmvs == "430800" {
  35238. for _, item := range queryResult {
  35239. var result string
  35240. if record_type == 1 {
  35241. 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)
  35242. } else if record_type == 2 {
  35243. fmt.Println(item.Code)
  35244. 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)
  35245. } else if record_type == 3 {
  35246. 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)
  35247. }
  35248. var dat map[string]interface{}
  35249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35250. fmt.Println(dat)
  35251. } else {
  35252. fmt.Println(err)
  35253. }
  35254. userJSONBytes, _ := json.Marshal(dat)
  35255. var res ResultSix
  35256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35257. utils.ErrorLog("解析失败:%v", err)
  35258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35259. return
  35260. }
  35261. if res.Infcode == 0 {
  35262. if record_type == 1 {
  35263. service.UpdateBaseDrugById(item.ID)
  35264. } else if record_type == 2 {
  35265. service.UpdateGoodInformaitonByDetail(item.ID)
  35266. } else if record_type == 3 {
  35267. service.UpdateProjectById(item.ID)
  35268. }
  35269. c.ServeSuccessJSON(map[string]interface{}{
  35270. "failed_code": 0,
  35271. "msg": "目录对照成功",
  35272. })
  35273. } else {
  35274. c.ServeSuccessJSON(map[string]interface{}{
  35275. "failed_code": -10,
  35276. "msg": res.ErrMsg,
  35277. })
  35278. }
  35279. }
  35280. } else {
  35281. for _, item := range queryResult {
  35282. var result string
  35283. if record_type == 1 {
  35284. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  35285. } else if record_type == 2 {
  35286. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  35287. } else if record_type == 3 {
  35288. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  35289. }
  35290. var dat2 map[string]interface{}
  35291. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  35292. fmt.Println(dat2)
  35293. } else {
  35294. fmt.Println(err)
  35295. }
  35296. userJSONBytes, _ := json.Marshal(dat2)
  35297. var res ResultSix
  35298. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35299. utils.ErrorLog("解析失败:%v", err)
  35300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35301. return
  35302. }
  35303. if res.Infcode == 0 {
  35304. if record_type == 1 {
  35305. service.UpdateDrugByIdDetail(item.ID)
  35306. } else if record_type == 2 {
  35307. service.UpdateGoodInfoById(item.ID)
  35308. } else if record_type == 3 {
  35309. service.UpdateMyProjectById(item.ID)
  35310. }
  35311. c.ServeSuccessJSON(map[string]interface{}{
  35312. "failed_code": 0,
  35313. "msg": "撤销目录对照成功",
  35314. })
  35315. } else {
  35316. c.ServeSuccessJSON(map[string]interface{}{
  35317. "failed_code": -10,
  35318. "msg": res.ErrMsg,
  35319. })
  35320. }
  35321. }
  35322. }
  35323. }
  35324. }
  35325. func (c *HisApiController) GetPatientInfo() {
  35326. id_card_no := c.GetString("id_card_no")
  35327. admin_user_id, _ := c.GetInt64("admin_user_id")
  35328. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  35329. if patient.ID == 0 {
  35330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35331. return
  35332. }
  35333. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  35334. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35335. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  35336. var res ResultTwo
  35337. var res10265 ResultTwo10265
  35338. if config.IsOpen == 1 {
  35339. if miConfig.MdtrtareaAdmvs == "150499" {
  35340. //请求内网数据
  35341. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  35342. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  35343. "&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
  35344. resp, requestErr := http.Get(api)
  35345. if requestErr != nil {
  35346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35347. return
  35348. }
  35349. body, ioErr := ioutil.ReadAll(resp.Body)
  35350. if ioErr != nil {
  35351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35353. return
  35354. }
  35355. var respJSON map[string]interface{}
  35356. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35359. return
  35360. }
  35361. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35362. result_byte, _ := json.Marshal(respJSON)
  35363. result := string(result_byte)
  35364. var dat map[string]interface{}
  35365. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35366. fmt.Println(dat)
  35367. } else {
  35368. fmt.Println(err)
  35369. }
  35370. userJSONBytes, _ := json.Marshal(dat)
  35371. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35372. utils.ErrorLog("解析失败:%v", err)
  35373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35374. return
  35375. }
  35376. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35377. res.Infcode = Infcode
  35378. res.ErrMsg = res10265.ErrMsg
  35379. res.Output = res10265.Output
  35380. res.InfRefmsgid = res10265.InfRefmsgid
  35381. res.RespondTime = res10265.RespondTime
  35382. res.WarnInfo = res10265.WarnInfo
  35383. } else {
  35384. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35385. var dat map[string]interface{}
  35386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35387. fmt.Println(dat)
  35388. } else {
  35389. fmt.Println(err)
  35390. }
  35391. userJSONBytes, _ := json.Marshal(dat)
  35392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35393. utils.ErrorLog("解析失败:%v", err)
  35394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35395. return
  35396. }
  35397. }
  35398. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35399. // utils.ErrorLog("解析失败:%v", err)
  35400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35401. // return
  35402. //}
  35403. for index, item := range res.Output.Iinfo {
  35404. if item.PsnInsuStas == "2" {
  35405. fmt.Println("--------")
  35406. res.Output.Iinfo[index].Insutype = "300"
  35407. res.Output.Iinfo[index].PsnInsuStas = "1"
  35408. }
  35409. }
  35410. fmt.Println(res.Output.Iinfo)
  35411. if res.Infcode != 0 {
  35412. c.ServeSuccessJSON(map[string]interface{}{
  35413. "failed_code": -10,
  35414. "msg": res.ErrMsg,
  35415. })
  35416. } else {
  35417. c.ServeSuccessJSON(map[string]interface{}{
  35418. "failed_code": 0,
  35419. "info": res,
  35420. })
  35421. }
  35422. }
  35423. }
  35424. func (c *HisApiController) PsnPutOnRecord() {
  35425. record_type, _ := c.GetInt64("type")
  35426. patient_id, _ := c.GetInt64("patient_id")
  35427. admin_user_id, _ := c.GetInt64("admin_user_id")
  35428. start_time := c.GetString("start_time")
  35429. end_time := c.GetString("end_time")
  35430. adminUser := c.GetAdminUserInfo()
  35431. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35432. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35433. var patients []*models.Patients
  35434. if record_type == 1 { //全部备案
  35435. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  35436. patients = append(patients, patient...)
  35437. } else { //单个备案
  35438. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35439. patients = append(patients, patient)
  35440. }
  35441. var user_name string
  35442. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35443. if role.ID == 0 {
  35444. user_name = "xxx"
  35445. } else {
  35446. user_name = role.UserName
  35447. }
  35448. if config.IsOpen == 1 {
  35449. for _, item := range patients {
  35450. 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
  35451. resp, requestErr := http.Get(api)
  35452. if requestErr != nil {
  35453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35454. return
  35455. }
  35456. defer resp.Body.Close()
  35457. body, ioErr := ioutil.ReadAll(resp.Body)
  35458. if ioErr != nil {
  35459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35461. return
  35462. }
  35463. var respJSON map[string]interface{}
  35464. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35467. return
  35468. }
  35469. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35470. userJSONBytes, _ := json.Marshal(userJSON)
  35471. var res ResultTwo
  35472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35473. utils.ErrorLog("解析失败:%v", err)
  35474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35475. return
  35476. }
  35477. if res.Infcode == 0 {
  35478. 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)
  35479. var dat map[string]interface{}
  35480. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35481. fmt.Println(dat)
  35482. } else {
  35483. fmt.Println(err)
  35484. }
  35485. userJSONBytes, _ := json.Marshal(dat)
  35486. var res2 ResultThirteen
  35487. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35488. utils.ErrorLog("解析失败:%v", err)
  35489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35490. return
  35491. }
  35492. if res2.Infcode == 0 {
  35493. psnResult := &models.GdybPsnRecord{
  35494. UserOrgId: adminUser.CurrentOrgId,
  35495. PatientId: item.ID,
  35496. PsnNo: res.Output.Baseinfo.PsnNo,
  35497. Ctime: time.Now().Unix(),
  35498. Mtime: time.Now().Unix(),
  35499. Status: 1,
  35500. IsCancel: 1,
  35501. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  35502. }
  35503. service.CreatePsnRecord(psnResult)
  35504. } else {
  35505. c.ServeSuccessJSON(map[string]interface{}{
  35506. "failed_code": -10,
  35507. "msg": res2.ErrMsg,
  35508. })
  35509. return
  35510. }
  35511. }
  35512. }
  35513. }
  35514. }
  35515. func (c *HisApiController) PsnUnPutOnRecord() {
  35516. id, _ := c.GetInt64("id")
  35517. //record_type, _ := c.GetInt64("type")
  35518. admin_user_id, _ := c.GetInt64("admin_user_id")
  35519. adminUser := c.GetAdminUserInfo()
  35520. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35521. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35522. var user_name string
  35523. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35524. if role.ID == 0 {
  35525. user_name = "xxx"
  35526. } else {
  35527. user_name = role.UserName
  35528. }
  35529. psn_record, _ := service.GetPsnRecordById(id)
  35530. if psn_record.ID == 0 {
  35531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  35532. return
  35533. }
  35534. if config.IsOpen == 1 {
  35535. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  35536. var dat map[string]interface{}
  35537. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35538. fmt.Println(dat)
  35539. } else {
  35540. fmt.Println(err)
  35541. }
  35542. userJSONBytes, _ := json.Marshal(dat)
  35543. var res ResultFourteen
  35544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35545. utils.ErrorLog("解析失败:%v", err)
  35546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35547. return
  35548. }
  35549. if res.Infcode == 0 {
  35550. psn_record.IsCancel = 2
  35551. service.CreatePsnRecord(&psn_record)
  35552. } else {
  35553. c.ServeSuccessJSON(map[string]interface{}{
  35554. "failed_code": -10,
  35555. "msg": res.ErrMsg,
  35556. })
  35557. return
  35558. }
  35559. }
  35560. }
  35561. func (c *HisApiController) PsnPutNCDSOnRecord() {
  35562. patient_id, _ := c.GetInt64("patient_id")
  35563. insutype_two := c.GetString("insutype")
  35564. psn_no := c.GetString("psn_no")
  35565. doctor_id, _ := c.GetInt64("doctor_id")
  35566. sick_id, _ := c.GetInt64("sick_id")
  35567. department_id, _ := c.GetInt64("department_id")
  35568. start_time := c.GetString("start_time")
  35569. end_time := c.GetString("end_time")
  35570. check_time := c.GetString("check_time")
  35571. hospital_code := c.GetString("hospital_code")
  35572. hospital_name := c.GetString("hospital_name")
  35573. adminUser := c.GetAdminUserInfo()
  35574. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35575. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35576. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35577. sick, _ := service.FindSickById(sick_id)
  35578. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  35579. if len(hospital_code) == 0 {
  35580. hospital_code = miConfig.Code
  35581. }
  35582. if len(hospital_name) == 0 {
  35583. hospital_name = miConfig.OrgName
  35584. }
  35585. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  35586. var res ResultTwo
  35587. var res10265 ResultTwo10265
  35588. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  35589. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  35590. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  35591. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  35592. "&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
  35593. resp, requestErr := http.Get(api)
  35594. if requestErr != nil {
  35595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35596. return
  35597. }
  35598. body, ioErr := ioutil.ReadAll(resp.Body)
  35599. if ioErr != nil {
  35600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35602. return
  35603. }
  35604. var respJSON map[string]interface{}
  35605. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35608. return
  35609. }
  35610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35611. result, _ := json.Marshal(respJSON)
  35612. fmt.Println("log")
  35613. fmt.Println(string(result))
  35614. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35615. utils.ErrorLog("解析失败:%v", err)
  35616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35617. return
  35618. }
  35619. res.ErrMsg = res10265.ErrMsg
  35620. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35621. res.Infcode = infocode
  35622. res.Output = res10265.Output
  35623. res.InfRefmsgid = res10265.InfRefmsgid
  35624. } else {
  35625. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  35626. if miConfig.Code == "H15049901371" {
  35627. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35628. utils.ErrorLog("解析失败:%v", err)
  35629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35630. return
  35631. }
  35632. res.ErrMsg = res10265.ErrMsg
  35633. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35634. res.Infcode = infocode
  35635. res.Output = res10265.Output
  35636. res.InfRefmsgid = res10265.InfRefmsgid
  35637. } else {
  35638. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35639. utils.ErrorLog("解析失败:%v", err)
  35640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35641. return
  35642. }
  35643. }
  35644. }
  35645. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35646. infoStr := string(Iinfos)
  35647. var rf []*ResultFive
  35648. json.Unmarshal([]byte(infoStr), &rf)
  35649. var insuplc_admdvs string
  35650. var insutype string
  35651. var is390 int = 0
  35652. var is310 int = 0
  35653. var insutypes []*ResultFive
  35654. for _, item := range rf {
  35655. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  35656. insutypes = append(insutypes, item)
  35657. }
  35658. }
  35659. if len(insutypes) == 1 {
  35660. insutype = insutypes[0].Insutype
  35661. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  35662. } else {
  35663. for _, i := range insutypes {
  35664. if i.Insutype == "390" {
  35665. is390 = 1
  35666. }
  35667. if i.Insutype == "310" {
  35668. is310 = 1
  35669. }
  35670. }
  35671. }
  35672. if is390 == 1 {
  35673. insutype = "390"
  35674. }
  35675. if is310 == 1 {
  35676. insutype = "310"
  35677. }
  35678. if len(insutypes) == 2 {
  35679. insutype = insutype_two
  35680. }
  35681. if len(insutypes) == 0 {
  35682. insutype = "310"
  35683. }
  35684. insutype = insutype_two
  35685. fmt.Println(insutype)
  35686. for _, item := range rf {
  35687. fmt.Println(item.Insutype)
  35688. fmt.Println(insutype)
  35689. if item.Insutype == insutype {
  35690. fmt.Println(item.Insutype)
  35691. fmt.Println(insutype)
  35692. insuplc_admdvs = item.InsuplcAdmdvs
  35693. }
  35694. }
  35695. fmt.Println(insuplc_admdvs)
  35696. var res2 ResultThirteen
  35697. var res10265_2 ResultThirteen10265
  35698. if config.IsOpen == 1 {
  35699. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  35700. } else {
  35701. if miConfig.MdtrtareaAdmvs == "150499" {
  35702. //
  35703. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  35704. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  35705. // "&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
  35706. //resp, requestErr := http.Get(api)
  35707. //if requestErr != nil {
  35708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35709. // return
  35710. //}
  35711. //
  35712. //body, ioErr := ioutil.ReadAll(resp.Body)
  35713. //if ioErr != nil {
  35714. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35715. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35716. // return
  35717. //}
  35718. //var respJSON map[string]interface{}
  35719. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35720. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35722. // return
  35723. //}
  35724. //
  35725. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35726. //result, _ := json.Marshal(respJSON)
  35727. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  35728. // utils.ErrorLog("解析失败:%v", err)
  35729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35730. // return
  35731. //}
  35732. //infocode = resThree.Infcode
  35733. //result, _ := json.Marshal(respJSON)
  35734. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  35735. // utils.ErrorLog("解析失败:%v", err)
  35736. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35737. // return
  35738. //}
  35739. //
  35740. //resThree.ErrMsg = resThree10265.ErrMsg
  35741. //
  35742. //resThree.Output = resThree10265.Output
  35743. //
  35744. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  35745. //
  35746. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  35747. //
  35748. } else {
  35749. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, doctor.DoctorNumber, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time, hospital_code, hospital_name)
  35750. var dat map[string]interface{}
  35751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35752. fmt.Println(dat)
  35753. } else {
  35754. fmt.Println(err)
  35755. }
  35756. userJSONBytes, _ := json.Marshal(dat)
  35757. if miConfig.Code == "H15049901371" {
  35758. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  35759. utils.ErrorLog("解析失败:%v", err)
  35760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35761. return
  35762. }
  35763. res2.ErrMsg = res10265_2.ErrMsg
  35764. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  35765. res2.Infcode = infocode
  35766. res2.Output = res10265_2.Output
  35767. res2.InfRefmsgid = res10265_2.InfRefmsgid
  35768. } else {
  35769. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35770. utils.ErrorLog("解析失败:%v", err)
  35771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35772. return
  35773. }
  35774. }
  35775. }
  35776. }
  35777. if res2.Infcode == 0 {
  35778. psnResult := &models.GdybPsnNcdsRecord{
  35779. UserOrgId: adminUser.CurrentOrgId,
  35780. PatientId: patient.ID,
  35781. PsnNo: psn_no,
  35782. DoctorId: doctor.AdminUserId,
  35783. DepartmentId: department_id,
  35784. SickType: sick_id,
  35785. Insutype: insutype,
  35786. Ctime: time.Now().Unix(),
  35787. Mtime: time.Now().Unix(),
  35788. Status: 1,
  35789. IsCancel: 1,
  35790. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  35791. }
  35792. service.CreatePsnNCDSRecord(psnResult)
  35793. c.ServeSuccessJSON(map[string]interface{}{
  35794. "failed_code": 0,
  35795. "msg": "备案成功",
  35796. "result": psnResult,
  35797. })
  35798. } else {
  35799. c.ServeSuccessJSON(map[string]interface{}{
  35800. "failed_code": -10,
  35801. "msg": res2.ErrMsg,
  35802. })
  35803. return
  35804. }
  35805. }
  35806. }
  35807. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  35808. id, _ := c.GetInt64("id")
  35809. admin_user_id, _ := c.GetInt64("admin_user_id")
  35810. adminUser := c.GetAdminUserInfo()
  35811. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35812. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35813. //config, _ := service.Ge(adminUser.CurrentOrgId)
  35814. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  35815. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35816. //var user_name string
  35817. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35818. //if role.ID == 0 {
  35819. // user_name = "xxx"
  35820. //} else {
  35821. // user_name = role.UserName
  35822. //}
  35823. psn_record, _ := service.GetPsnNCDSRecordById(id)
  35824. if psn_record.ID == 0 {
  35825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  35826. return
  35827. }
  35828. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  35829. var res ResultTwo
  35830. var res10265 ResultTwo10265
  35831. if miConfig.Code == "H15049901371" {
  35832. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35833. utils.ErrorLog("解析失败:%v", err)
  35834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35835. return
  35836. }
  35837. res.ErrMsg = res10265.ErrMsg
  35838. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35839. res.Infcode = infocode
  35840. res.Output = res10265.Output
  35841. res.InfRefmsgid = res10265.InfRefmsgid
  35842. } else {
  35843. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35844. utils.ErrorLog("解析失败:%v", err)
  35845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35846. return
  35847. }
  35848. }
  35849. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35850. infoStr := string(Iinfos)
  35851. var rf []*ResultFive
  35852. json.Unmarshal([]byte(infoStr), &rf)
  35853. var insuplc_admdvs string
  35854. var insutype string
  35855. var is390 int = 0
  35856. var is310 int = 0
  35857. var insutypes []*ResultFive
  35858. for _, item := range rf {
  35859. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  35860. insutypes = append(insutypes, item)
  35861. }
  35862. }
  35863. if len(insutypes) == 1 {
  35864. insutype = insutypes[0].Insutype
  35865. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  35866. } else {
  35867. for _, i := range insutypes {
  35868. if i.Insutype == "390" {
  35869. is390 = 1
  35870. }
  35871. if i.Insutype == "310" {
  35872. is310 = 1
  35873. }
  35874. }
  35875. }
  35876. if is390 == 1 {
  35877. insutype = "390"
  35878. }
  35879. if is310 == 1 {
  35880. insutype = "310"
  35881. }
  35882. if len(insutypes) == 0 {
  35883. insutype = "310"
  35884. }
  35885. insutype = psn_record.Insutype
  35886. for _, item := range rf {
  35887. if item.Insutype == insutype {
  35888. insuplc_admdvs = item.InsuplcAdmdvs
  35889. }
  35890. }
  35891. if config.IsOpen == 1 {
  35892. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  35893. var dat map[string]interface{}
  35894. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35895. fmt.Println(dat)
  35896. } else {
  35897. fmt.Println(err)
  35898. }
  35899. userJSONBytes, _ := json.Marshal(dat)
  35900. var res ResultFourteen
  35901. var res10265 ResultFourteen10265
  35902. if miConfig.Code == "H15049901371" {
  35903. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35904. utils.ErrorLog("解析失败:%v", err)
  35905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35906. return
  35907. }
  35908. res.ErrMsg = res10265.ErrMsg
  35909. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35910. res.Infcode = infocode
  35911. res.Output = res10265.Output
  35912. res.InfRefmsgid = res10265.InfRefmsgid
  35913. } else {
  35914. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35915. utils.ErrorLog("解析失败:%v", err)
  35916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35917. return
  35918. }
  35919. }
  35920. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35921. // utils.ErrorLog("解析失败:%v", err)
  35922. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35923. // return
  35924. //}
  35925. if res.Infcode == 0 {
  35926. psn_record.IsCancel = 2
  35927. service.CreatePsnNCDSRecord(&psn_record)
  35928. c.ServeSuccessJSON(map[string]interface{}{
  35929. "failed_code": 0,
  35930. "msg": "撤销备案成功",
  35931. })
  35932. } else {
  35933. c.ServeSuccessJSON(map[string]interface{}{
  35934. "failed_code": -10,
  35935. "msg": res.ErrMsg,
  35936. })
  35937. return
  35938. }
  35939. }
  35940. }
  35941. func (c *HisApiController) TestTest() {
  35942. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  35943. fmt.Println(patient.Iinfo)
  35944. }
  35945. type CustomData struct {
  35946. MsgId string
  35947. PsnNo string
  35948. Info string
  35949. }
  35950. func (c *HisApiController) ReversalData() {
  35951. var customData []*CustomData
  35952. custom := &CustomData{
  35953. MsgId: "H44022900158202103301714472004",
  35954. PsnNo: "44020000001101329945",
  35955. Info: "2207",
  35956. }
  35957. customData = append(customData, custom)
  35958. custom1 := &CustomData{
  35959. MsgId: "H4402290015820210330172057803",
  35960. PsnNo: "44020000001101161813",
  35961. Info: "2207",
  35962. }
  35963. customData = append(customData, custom1)
  35964. custom2 := &CustomData{
  35965. MsgId: "H44022900158202103301705198813",
  35966. PsnNo: "44190000133097375417",
  35967. Info: "2207",
  35968. }
  35969. customData = append(customData, custom2)
  35970. custom3 := &CustomData{
  35971. MsgId: "H44022900158202103301715524756",
  35972. PsnNo: "44020000001100187221",
  35973. Info: "2207",
  35974. }
  35975. customData = append(customData, custom3)
  35976. custom4 := &CustomData{
  35977. MsgId: "H44022900158202103301730376224",
  35978. PsnNo: "44020000001101959155",
  35979. Info: "2207",
  35980. }
  35981. customData = append(customData, custom4)
  35982. custom5 := &CustomData{
  35983. MsgId: "H44022900158202103301748008725",
  35984. PsnNo: "44020000001104246641",
  35985. Info: "2207",
  35986. }
  35987. customData = append(customData, custom5)
  35988. custom6 := &CustomData{
  35989. MsgId: "H44022900158202103301718096755",
  35990. PsnNo: "44020000001102211860",
  35991. Info: "2207",
  35992. }
  35993. customData = append(customData, custom6)
  35994. custom7 := &CustomData{
  35995. MsgId: "H44022900158202103301736551640",
  35996. PsnNo: "44020000001102687718",
  35997. Info: "2207",
  35998. }
  35999. customData = append(customData, custom7)
  36000. custom8 := &CustomData{
  36001. MsgId: "H44022900158202103301743097676",
  36002. PsnNo: "44020000001102127785",
  36003. Info: "2207",
  36004. }
  36005. customData = append(customData, custom8)
  36006. custom9 := &CustomData{
  36007. MsgId: "H44022900158202103301712304203",
  36008. PsnNo: "44020000001101518097",
  36009. Info: "2207",
  36010. }
  36011. customData = append(customData, custom9)
  36012. custom10 := &CustomData{
  36013. MsgId: "H44022900158202103301738448785",
  36014. PsnNo: "44020000001100500813",
  36015. Info: "2207",
  36016. }
  36017. customData = append(customData, custom10)
  36018. custom11 := &CustomData{
  36019. MsgId: "H44022900158202103301732455843",
  36020. PsnNo: "44020000001102690557",
  36021. Info: "2207",
  36022. }
  36023. customData = append(customData, custom11)
  36024. custom12 := &CustomData{
  36025. MsgId: "H44022900158202103301745421708",
  36026. PsnNo: "44020000001102211928",
  36027. Info: "2207",
  36028. }
  36029. customData = append(customData, custom12)
  36030. custom1212 := &CustomData{
  36031. MsgId: "H440229001582021033017351627",
  36032. PsnNo: "44020000001102481733",
  36033. Info: "2207",
  36034. }
  36035. customData = append(customData, custom1212)
  36036. custom13 := &CustomData{
  36037. MsgId: "H44022900158202103301740327951",
  36038. PsnNo: "44020000001103174866",
  36039. Info: "2207",
  36040. }
  36041. customData = append(customData, custom13)
  36042. custom14 := &CustomData{
  36043. MsgId: "H4402290015820210330174922668",
  36044. PsnNo: "44020000001102927272",
  36045. Info: "2207",
  36046. }
  36047. customData = append(customData, custom14)
  36048. custom15 := &CustomData{
  36049. MsgId: "H44022900158202103301752362273",
  36050. PsnNo: "44020000001102942890",
  36051. Info: "2207",
  36052. }
  36053. customData = append(customData, custom15)
  36054. custom16 := &CustomData{
  36055. MsgId: "H44022900158202103301751082917",
  36056. PsnNo: "44020000001101662162",
  36057. Info: "2207",
  36058. }
  36059. customData = append(customData, custom16)
  36060. custom17 := &CustomData{
  36061. MsgId: "H44022900158202103301754147728",
  36062. PsnNo: "44020000000229014511",
  36063. Info: "2207",
  36064. }
  36065. customData = append(customData, custom17)
  36066. adminUser := c.GetAdminUserInfo()
  36067. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36068. for _, item := range customData {
  36069. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36070. fmt.Println(result)
  36071. }
  36072. }
  36073. func (c *HisApiController) GetAllopatry() {
  36074. year := c.GetString("year")
  36075. month := c.GetString("month")
  36076. admin_user_id, _ := c.GetInt64("admin_user_id")
  36077. adminUser := c.GetAdminUserInfo()
  36078. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36079. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36080. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36081. var dat map[string]interface{}
  36082. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36083. fmt.Println(dat)
  36084. } else {
  36085. fmt.Println(err)
  36086. }
  36087. userJSONBytes, _ := json.Marshal(dat)
  36088. var res models.Result9001
  36089. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36090. utils.ErrorLog("解析失败:%v", err)
  36091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36092. return
  36093. }
  36094. fmt.Println(res.Output.Signinoutb)
  36095. fmt.Println(res.Output.Signinoutb.SignNo)
  36096. fmt.Println(string(userJSONBytes))
  36097. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36098. var dat3 map[string]interface{}
  36099. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  36100. fmt.Println(dat3)
  36101. } else {
  36102. fmt.Println(err)
  36103. }
  36104. userJSONBytes3, _ := json.Marshal(dat3)
  36105. var res3 models.Result3260
  36106. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  36107. utils.ErrorLog("解析失败:%v", err)
  36108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36109. return
  36110. }
  36111. var curpage int
  36112. var pagesize int = 100
  36113. var start int = 1
  36114. //var stop int
  36115. //pagecount := 10
  36116. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  36117. var res22 []models.Result3260
  36118. for curpage = 1; curpage <= pagecount; curpage++ {
  36119. if curpage == 1 {
  36120. start = 0
  36121. } else {
  36122. start = (curpage-1)*pagesize + 1
  36123. }
  36124. fmt.Println(start)
  36125. //stop = curpage * pagesize
  36126. //if stop > int(res3.Output.Totalrow) {
  36127. // stop =int(res3.Output.Totalrow)
  36128. //}
  36129. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  36130. var dat2 map[string]interface{}
  36131. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36132. fmt.Println(dat)
  36133. } else {
  36134. fmt.Println(err)
  36135. }
  36136. userJSONBytes2, _ := json.Marshal(dat2)
  36137. var res2 models.Result3260
  36138. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36139. utils.ErrorLog("解析失败:%v", err)
  36140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36141. return
  36142. }
  36143. if res2.Infcode == 0 {
  36144. res22 = append(res22, res2)
  36145. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36146. //var dat2 map[string]interface{}
  36147. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36148. // fmt.Println(dat)
  36149. //} else {
  36150. // fmt.Println(err)
  36151. //}
  36152. //c.ServeSuccessJSON(map[string]interface{}{
  36153. // "list": res2.Output.Data,
  36154. //})
  36155. //continue
  36156. }
  36157. }
  36158. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36159. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36160. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  36161. //var dat2 map[string]interface{}
  36162. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36163. // fmt.Println(dat)
  36164. //} else {
  36165. // fmt.Println(err)
  36166. //}
  36167. //userJSONBytes2, _ := json.Marshal(dat2)
  36168. //var res2 models.Result3260
  36169. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36170. // utils.ErrorLog("解析失败:%v", err)
  36171. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36172. // return
  36173. //}
  36174. //if res2.Infcode == 0 {
  36175. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36176. // var dat2 map[string]interface{}
  36177. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36178. // fmt.Println(dat)
  36179. // } else {
  36180. // fmt.Println(err)
  36181. // }
  36182. // c.ServeSuccessJSON(map[string]interface{}{
  36183. // "list": res2.Output.Data,
  36184. // })
  36185. //}
  36186. }
  36187. func (c *HisApiController) ComfirmAllopatry() {
  36188. year := c.GetString("year")
  36189. month := c.GetString("month")
  36190. admin_user_id, _ := c.GetInt64("admin_user_id")
  36191. adminUser := c.GetAdminUserInfo()
  36192. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36193. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36194. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36195. var dat map[string]interface{}
  36196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36197. fmt.Println(dat)
  36198. } else {
  36199. fmt.Println(err)
  36200. }
  36201. userJSONBytes, _ := json.Marshal(dat)
  36202. var res models.Result9001
  36203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36204. utils.ErrorLog("解析失败:%v", err)
  36205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36206. return
  36207. }
  36208. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36209. var dat2 map[string]interface{}
  36210. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36211. fmt.Println(dat)
  36212. } else {
  36213. fmt.Println(err)
  36214. }
  36215. userJSONBytes2, _ := json.Marshal(dat2)
  36216. var res2 models.Result3260
  36217. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36218. utils.ErrorLog("解析失败:%v", err)
  36219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36220. return
  36221. }
  36222. //if res2.Infcode == 0 {
  36223. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36224. // var dat map[string]interface{}
  36225. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36226. // fmt.Println(dat)
  36227. // } else {
  36228. // fmt.Println(err)
  36229. // }
  36230. // userJSONBytes, _ := json.Marshal(dat)
  36231. // var res3 models.Result3261
  36232. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  36233. // utils.ErrorLog("解析失败:%v", err)
  36234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36235. // return
  36236. // }
  36237. //
  36238. // if res3.Infcode == 0 {
  36239. // record := &models.HisYidiClearRecord{
  36240. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  36241. // Ctime: time.Now().Unix(),
  36242. // Mtime: time.Now().Unix(),
  36243. // Status: 1,
  36244. // MsgId: msgId,
  36245. // }
  36246. // service.SaveClearRecord(record)
  36247. // c.ServeSuccessJSON(map[string]interface{}{
  36248. // "msg": "提取成功",
  36249. // })
  36250. // }
  36251. //}
  36252. }
  36253. func (c *HisApiController) RefundAllopatry() {
  36254. year := c.GetString("year")
  36255. month := c.GetString("month")
  36256. //id, _ := c.GetInt64("id")
  36257. admin_user_id, _ := c.GetInt64("admin_user_id")
  36258. adminUser := c.GetAdminUserInfo()
  36259. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36260. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36261. //record, _ := service.GetClearRecordById(id)
  36262. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36263. var dat map[string]interface{}
  36264. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  36265. fmt.Println(dat)
  36266. } else {
  36267. fmt.Println(err)
  36268. }
  36269. userJSONBytes, _ := json.Marshal(dat)
  36270. var res models.Result9001
  36271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36272. utils.ErrorLog("解析失败:%v", err)
  36273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36274. return
  36275. }
  36276. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  36277. var dat2 map[string]interface{}
  36278. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36279. fmt.Println(dat)
  36280. } else {
  36281. fmt.Println(err)
  36282. }
  36283. userJSONBytes2, _ := json.Marshal(dat2)
  36284. var empty ResultFourteen
  36285. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  36286. utils.ErrorLog("解析失败:%v", err)
  36287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36288. return
  36289. }
  36290. if empty.Infcode == 0 {
  36291. c.ServeSuccessJSON(map[string]interface{}{
  36292. "msg": "撤销成功",
  36293. })
  36294. return
  36295. }
  36296. }
  36297. func (c *HisApiController) ReversalOtherData() {
  36298. var customData []*CustomData
  36299. custom := &CustomData{
  36300. MsgId: "H44022900158202103301714472004",
  36301. PsnNo: "44020000001101329945",
  36302. Info: "2208",
  36303. }
  36304. customData = append(customData, custom)
  36305. custom1 := &CustomData{
  36306. MsgId: "H4402290015820210330172057803",
  36307. PsnNo: "44020000001101161813",
  36308. Info: "2208",
  36309. }
  36310. customData = append(customData, custom1)
  36311. custom2 := &CustomData{
  36312. MsgId: "H44022900158202103301705198813",
  36313. PsnNo: "44190000133097375417",
  36314. Info: "2208",
  36315. }
  36316. customData = append(customData, custom2)
  36317. custom3 := &CustomData{
  36318. MsgId: "H44022900158202103301715524756",
  36319. PsnNo: "44020000001100187221",
  36320. Info: "2208",
  36321. }
  36322. customData = append(customData, custom3)
  36323. custom4 := &CustomData{
  36324. MsgId: "H44022900158202103301730376224",
  36325. PsnNo: "44020000001101959155",
  36326. Info: "2208",
  36327. }
  36328. customData = append(customData, custom4)
  36329. custom5 := &CustomData{
  36330. MsgId: "H44022900158202103301748008725",
  36331. PsnNo: "44020000001104246641",
  36332. Info: "2208",
  36333. }
  36334. customData = append(customData, custom5)
  36335. custom6 := &CustomData{
  36336. MsgId: "H44022900158202103301718096755",
  36337. PsnNo: "44020000001102211860",
  36338. Info: "2208",
  36339. }
  36340. customData = append(customData, custom6)
  36341. custom7 := &CustomData{
  36342. MsgId: "H44022900158202103301736551640",
  36343. PsnNo: "44020000001102687718",
  36344. Info: "2208",
  36345. }
  36346. customData = append(customData, custom7)
  36347. custom8 := &CustomData{
  36348. MsgId: "H44022900158202103301743097676",
  36349. PsnNo: "44020000001102127785",
  36350. Info: "2208",
  36351. }
  36352. customData = append(customData, custom8)
  36353. custom9 := &CustomData{
  36354. MsgId: "H44022900158202103301712304203",
  36355. PsnNo: "44020000001101518097",
  36356. Info: "2208",
  36357. }
  36358. customData = append(customData, custom9)
  36359. custom10 := &CustomData{
  36360. MsgId: "H44022900158202103301738448785",
  36361. PsnNo: "44020000001100500813",
  36362. Info: "2208",
  36363. }
  36364. customData = append(customData, custom10)
  36365. custom11 := &CustomData{
  36366. MsgId: "H44022900158202103301732455843",
  36367. PsnNo: "44020000001102690557",
  36368. Info: "2208",
  36369. }
  36370. customData = append(customData, custom11)
  36371. custom12 := &CustomData{
  36372. MsgId: "H44022900158202103301745421708",
  36373. PsnNo: "44020000001102211928",
  36374. Info: "2208",
  36375. }
  36376. customData = append(customData, custom12)
  36377. custom1212 := &CustomData{
  36378. MsgId: "H440229001582021033017351627",
  36379. PsnNo: "44020000001102481733",
  36380. Info: "2208",
  36381. }
  36382. customData = append(customData, custom1212)
  36383. custom13 := &CustomData{
  36384. MsgId: "H44022900158202103301740327951",
  36385. PsnNo: "44020000001103174866",
  36386. Info: "2208",
  36387. }
  36388. customData = append(customData, custom13)
  36389. custom14 := &CustomData{
  36390. MsgId: "H4402290015820210330174922668",
  36391. PsnNo: "44020000001102927272",
  36392. Info: "2208",
  36393. }
  36394. customData = append(customData, custom14)
  36395. custom15 := &CustomData{
  36396. MsgId: "H44022900158202103301752362273",
  36397. PsnNo: "44020000001102942890",
  36398. Info: "2208",
  36399. }
  36400. customData = append(customData, custom15)
  36401. custom16 := &CustomData{
  36402. MsgId: "H44022900158202103301751082917",
  36403. PsnNo: "44020000001101662162",
  36404. Info: "2208",
  36405. }
  36406. customData = append(customData, custom16)
  36407. custom17 := &CustomData{
  36408. MsgId: "H44022900158202103301754147728",
  36409. PsnNo: "44020000000229014511",
  36410. Info: "2208",
  36411. }
  36412. customData = append(customData, custom17)
  36413. adminUser := c.GetAdminUserInfo()
  36414. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36415. for _, item := range customData {
  36416. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36417. fmt.Println(result)
  36418. }
  36419. }
  36420. func PathExists(path string) (bool, error) {
  36421. _, err := os.Stat(path)
  36422. if err == nil {
  36423. return true, nil
  36424. }
  36425. if os.IsNotExist(err) {
  36426. return false, nil
  36427. }
  36428. return false, err
  36429. }
  36430. // 创建文件夹
  36431. func Mkdir(dir string) {
  36432. // 创建文件夹
  36433. exist, err := PathExists(dir)
  36434. if err != nil {
  36435. fmt.Println(err.Error())
  36436. } else {
  36437. if exist {
  36438. fmt.Println(dir + "文件夹已存在!")
  36439. } else {
  36440. // 文件夹名称,权限
  36441. err := os.Mkdir(dir, os.ModePerm)
  36442. if err != nil {
  36443. fmt.Println(dir+"文件夹创建失败:", err.Error())
  36444. } else {
  36445. fmt.Println(dir + "文件夹创建成功!")
  36446. }
  36447. }
  36448. }
  36449. }
  36450. // 压缩文件
  36451. func Zip(srcFile string, destZip string) error {
  36452. zipfile, err := os.Create(destZip)
  36453. if err != nil {
  36454. return err
  36455. }
  36456. defer zipfile.Close()
  36457. archive := zip.NewWriter(zipfile)
  36458. defer archive.Close()
  36459. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  36460. if err != nil {
  36461. return err
  36462. }
  36463. header, err := zip.FileInfoHeader(info)
  36464. if err != nil {
  36465. return err
  36466. }
  36467. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  36468. // header.Name = path
  36469. if info.IsDir() {
  36470. header.Name += "/"
  36471. } else {
  36472. header.Method = zip.Deflate
  36473. }
  36474. writer, err := archive.CreateHeader(header)
  36475. if err != nil {
  36476. return err
  36477. }
  36478. if !info.IsDir() {
  36479. file, err := os.Open(path)
  36480. if err != nil {
  36481. return err
  36482. }
  36483. defer file.Close()
  36484. _, err = io.Copy(writer, file)
  36485. }
  36486. return err
  36487. })
  36488. return err
  36489. }
  36490. func ReadFile(filePath string) []byte {
  36491. f, err := os.Open(filePath)
  36492. if err != nil {
  36493. fmt.Println("read file fail", err)
  36494. return nil
  36495. }
  36496. defer f.Close()
  36497. fd, err := ioutil.ReadAll(f)
  36498. if err != nil {
  36499. fmt.Println("read to fd fail", err)
  36500. return nil
  36501. }
  36502. return fd
  36503. }
  36504. func saveLogq(result string, request string, infno string, desc string) {
  36505. dir := "日志"
  36506. utils.Mkdir(dir)
  36507. month := time.Unix(1557042972, 0).Format("1")
  36508. year := time.Now().Format("2006")
  36509. month = time.Now().Format("01")
  36510. day := time.Now().Format("02")
  36511. hour := time.Now().Format("15")
  36512. min := time.Now().Format("04")
  36513. sec := time.Now().Format("05")
  36514. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  36515. file := year + month + day + "_log"
  36516. file_name := file + ".txt"
  36517. file_path := "日志" + "/" + file_name
  36518. exist, _ := utils.PathExists(file_path)
  36519. if exist { //存在
  36520. fmt.Println("存在")
  36521. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  36522. if err != nil {
  36523. fmt.Println("read fail")
  36524. }
  36525. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  36526. n, _ := f.Seek(0, 2)
  36527. _, err = f.WriteAt([]byte(content), n)
  36528. } else { //不存在
  36529. fmt.Println("文件不存在,创建文件")
  36530. f, err := os.Create("日志" + "/" + file_name)
  36531. defer f.Close()
  36532. if err != nil {
  36533. } else {
  36534. _, err = f.Write([]byte("记录日志"))
  36535. }
  36536. }
  36537. }
  36538. func saveLog(result string, request string, infno string, desc string) {
  36539. org_id, _ := beego.AppConfig.Int64("org_id")
  36540. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  36541. dir := miConfig.OrgName + "日志"
  36542. utils.Mkdir(dir)
  36543. month := time.Unix(1557042972, 0).Format("1")
  36544. year := time.Now().Format("2006")
  36545. month = time.Now().Format("01")
  36546. day := time.Now().Format("02")
  36547. hour := time.Now().Format("15")
  36548. min := time.Now().Format("04")
  36549. sec := time.Now().Format("05")
  36550. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  36551. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  36552. file_name := file + ".txt"
  36553. file_path := miConfig.OrgName + "日志" + "/" + file_name
  36554. exist, _ := utils.PathExists(file_path)
  36555. if exist { //存在
  36556. fmt.Println("存在")
  36557. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  36558. if err != nil {
  36559. fmt.Println("read fail")
  36560. }
  36561. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  36562. n, _ := f.Seek(0, 2)
  36563. _, err = f.WriteAt([]byte(content), n)
  36564. } else { //不存在
  36565. fmt.Println("文件不存在,创建文件")
  36566. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  36567. defer f.Close()
  36568. if err != nil {
  36569. } else {
  36570. _, err = f.Write([]byte("记录日志"))
  36571. }
  36572. }
  36573. }
  36574. type Charset string
  36575. const (
  36576. UTF8 = Charset("UTF-8")
  36577. GB18030 = Charset("GB18030")
  36578. )
  36579. func ConvertToString(src string, srcCode string, tagCode string) string {
  36580. srcCoder := mahonia.NewDecoder(srcCode)
  36581. srcResult := srcCoder.ConvertString(src)
  36582. tagCoder := mahonia.NewDecoder(tagCode)
  36583. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  36584. result := string(cdata)
  36585. return result
  36586. }
  36587. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  36588. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  36589. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  36590. var token string
  36591. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36592. var api string
  36593. if miConfig.MdtrtareaAdmvs == "320921" {
  36594. 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 +
  36595. "&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
  36596. fmt.Println(api)
  36597. } else {
  36598. 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 +
  36599. "&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
  36600. }
  36601. resp, requestErr := http.Get(api)
  36602. if requestErr != nil {
  36603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36604. return ""
  36605. }
  36606. body, ioErr := ioutil.ReadAll(resp.Body)
  36607. if ioErr != nil {
  36608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36610. return ""
  36611. }
  36612. var respJSON map[string]interface{}
  36613. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36616. return ""
  36617. }
  36618. var status string
  36619. status = respJSON["data"].(map[string]interface{})["status"].(string)
  36620. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  36621. var res ResultTwo //1101结果
  36622. var res10265 ResultTwo10265 //1101结果
  36623. if status == "0" { //读卡成功
  36624. var card_info string //卡信息
  36625. var busi_card_info string
  36626. token = respJSON["data"].(map[string]interface{})["token"].(string)
  36627. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  36628. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  36629. fmt.Println(card_info)
  36630. fmt.Println(busi_card_info)
  36631. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  36632. result, _ := json.Marshal(respJSON)
  36633. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36634. utils.ErrorLog("解析失败:%v", err)
  36635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36636. return ""
  36637. }
  36638. res.ErrMsg = res10265.ErrMsg
  36639. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36640. res.Infcode = infocode
  36641. res.Output = res10265.Output
  36642. res.InfRefmsgid = res10265.InfRefmsgid
  36643. if res.Infcode == 0 {
  36644. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  36645. if err == gorm.ErrRecordNotFound {
  36646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  36647. return ""
  36648. } else if err != nil {
  36649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  36650. return ""
  36651. } else {
  36652. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36653. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  36654. infoStr := string(Iinfos)
  36655. idetinfoStr := string(Idetinfos)
  36656. psn := &models.HisPsn{
  36657. PsnNo: res.Output.Baseinfo.PsnNo,
  36658. PatientId: patient.ID,
  36659. Certno: res.Output.Baseinfo.Certno,
  36660. Gend: res.Output.Baseinfo.Gend,
  36661. Naty: res.Output.Baseinfo.Naty,
  36662. PsnCertType: res.Output.Baseinfo.PsnCertType,
  36663. PsnName: res.Output.Baseinfo.PsnName,
  36664. Idetinfo: idetinfoStr,
  36665. Insuinfo: infoStr,
  36666. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  36667. CardInfo: card_info,
  36668. VerifyNumber: token,
  36669. }
  36670. service.CreateHisPsn(psn)
  36671. return token
  36672. }
  36673. }
  36674. } else {
  36675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  36676. return ""
  36677. }
  36678. } else { //读卡失败
  36679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  36680. return ""
  36681. }
  36682. return token
  36683. }
  36684. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  36685. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  36686. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  36687. var token string
  36688. var api string
  36689. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  36690. "&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
  36691. fmt.Println(api)
  36692. resp, requestErr := http.Get(api)
  36693. if requestErr != nil {
  36694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36695. return ""
  36696. }
  36697. body, ioErr := ioutil.ReadAll(resp.Body)
  36698. if ioErr != nil {
  36699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36701. return ""
  36702. }
  36703. var respJSON map[string]interface{}
  36704. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36707. return ""
  36708. }
  36709. var status string
  36710. status = respJSON["data"].(map[string]interface{})["status"].(string)
  36711. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  36712. var res ResultTwo //1101结果
  36713. if status == "1" { //读卡成功
  36714. var card_info string //卡信息
  36715. var busi_card_info string
  36716. token = respJSON["data"].(map[string]interface{})["token"].(string)
  36717. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  36718. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  36719. fmt.Println(card_info)
  36720. fmt.Println(busi_card_info)
  36721. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  36722. result, _ := json.Marshal(respJSON)
  36723. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36724. utils.ErrorLog("解析失败:%v", err)
  36725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36726. return ""
  36727. }
  36728. if res.Infcode == 0 {
  36729. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  36730. if err == gorm.ErrRecordNotFound {
  36731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  36732. return ""
  36733. } else if err != nil {
  36734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  36735. return ""
  36736. } else {
  36737. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36738. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  36739. infoStr := string(Iinfos)
  36740. idetinfoStr := string(Idetinfos)
  36741. psn := &models.HisPsn{
  36742. PsnNo: res.Output.Baseinfo.PsnNo,
  36743. PatientId: patient.ID,
  36744. Certno: res.Output.Baseinfo.Certno,
  36745. Gend: res.Output.Baseinfo.Gend,
  36746. Naty: res.Output.Baseinfo.Naty,
  36747. PsnCertType: res.Output.Baseinfo.PsnCertType,
  36748. PsnName: res.Output.Baseinfo.PsnName,
  36749. Idetinfo: idetinfoStr,
  36750. Insuinfo: infoStr,
  36751. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  36752. CardInfo: card_info,
  36753. VerifyNumber: token,
  36754. }
  36755. service.CreateHisPsn(psn)
  36756. return token
  36757. }
  36758. }
  36759. } else {
  36760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  36761. return ""
  36762. }
  36763. return token
  36764. }
  36765. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  36766. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  36767. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  36768. var token string
  36769. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36770. var api string
  36771. if miConfig.MdtrtareaAdmvs == "320921" {
  36772. 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 +
  36773. "&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
  36774. fmt.Println(api)
  36775. } else {
  36776. 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 +
  36777. "&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
  36778. }
  36779. resp, requestErr := http.Get(api)
  36780. if requestErr != nil {
  36781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36782. return ""
  36783. }
  36784. body, ioErr := ioutil.ReadAll(resp.Body)
  36785. if ioErr != nil {
  36786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36788. return ""
  36789. }
  36790. var respJSON map[string]interface{}
  36791. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36794. return ""
  36795. }
  36796. var status string
  36797. status = respJSON["data"].(map[string]interface{})["status"].(string)
  36798. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  36799. var res ResultTwo //1101结果
  36800. var res10265 ResultTwo10265 //1101结果
  36801. if status == "0" { //读卡成功
  36802. var card_info string //卡信息
  36803. var busi_card_info string
  36804. token = respJSON["data"].(map[string]interface{})["token"].(string)
  36805. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  36806. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  36807. fmt.Println(card_info)
  36808. fmt.Println(busi_card_info)
  36809. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  36810. result, _ := json.Marshal(respJSON)
  36811. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36812. utils.ErrorLog("解析失败:%v", err)
  36813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36814. return ""
  36815. }
  36816. res.ErrMsg = res10265.ErrMsg
  36817. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36818. res.Infcode = infocode
  36819. res.Output = res10265.Output
  36820. res.InfRefmsgid = res10265.InfRefmsgid
  36821. if res.Infcode == 0 {
  36822. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  36823. if err == gorm.ErrRecordNotFound {
  36824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  36825. return ""
  36826. } else if err != nil {
  36827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  36828. return ""
  36829. } else {
  36830. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36831. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  36832. infoStr := string(Iinfos)
  36833. idetinfoStr := string(Idetinfos)
  36834. psn := &models.HisPsn{
  36835. PsnNo: res.Output.Baseinfo.PsnNo,
  36836. PatientId: patient.ID,
  36837. Certno: res.Output.Baseinfo.Certno,
  36838. Gend: res.Output.Baseinfo.Gend,
  36839. Naty: res.Output.Baseinfo.Naty,
  36840. PsnCertType: res.Output.Baseinfo.PsnCertType,
  36841. PsnName: res.Output.Baseinfo.PsnName,
  36842. Idetinfo: idetinfoStr,
  36843. Insuinfo: infoStr,
  36844. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  36845. CardInfo: card_info,
  36846. VerifyNumber: token,
  36847. }
  36848. service.CreateHisPsn(psn)
  36849. return token
  36850. }
  36851. }
  36852. } else {
  36853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  36854. return ""
  36855. }
  36856. } else { //读卡失败
  36857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  36858. return ""
  36859. }
  36860. return token
  36861. }
  36862. func DeleteExtraSpaceTwo(s string) string {
  36863. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  36864. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  36865. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  36866. reg, _ := regexp.Compile(regstr) //编译正则表达式
  36867. s2 := make([]byte, len(s1)) //定义字符数组切片
  36868. copy(s2, s1) //将字符串复制到切片
  36869. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  36870. for len(spc_index) > 0 { //找到适配项
  36871. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  36872. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  36873. }
  36874. return string(s2)
  36875. }
  36876. func Remove0000(s string) string {
  36877. str := make([]rune, 0, len(s))
  36878. for _, v := range []rune(s) {
  36879. if v == 0 {
  36880. continue
  36881. }
  36882. str = append(str, v)
  36883. }
  36884. return string(str)
  36885. }
  36886. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  36887. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  36888. readCard := DllDef.MustFindProc("EcQuery")
  36889. pCardInfo := make([]byte, 8192)
  36890. pBusiCardInfo := make([]byte, 8192)
  36891. data := make(map[string]interface{})
  36892. //pData := make(map[string]interface{})
  36893. inputData := make(map[string]interface{})
  36894. inputData["orgId"] = code
  36895. inputData["businessType"] = "01101"
  36896. inputData["operatorId"] = operator_id
  36897. inputData["operatorName"] = operator_name
  36898. inputData["officeId"] = "001"
  36899. inputData["officeName"] = "血透室"
  36900. //
  36901. data["data"] = inputData
  36902. data["transType"] = "ec.query"
  36903. data["orgId"] = code
  36904. bytesData, _ := json.Marshal(data)
  36905. pCardInfo = bytesData
  36906. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  36907. fmt.Println(ret2)
  36908. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  36909. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  36910. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  36911. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  36912. if ret2 != 0 {
  36913. return "", ""
  36914. }
  36915. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  36916. }
  36917. func DeleteExtraSpace(s string) string {
  36918. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  36919. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  36920. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  36921. reg, _ := regexp.Compile(regstr) //编译正则表达式
  36922. s2 := make([]byte, len(s1)) //定义字符数组切片
  36923. copy(s2, s1) //将字符串复制到切片
  36924. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  36925. for len(spc_index) > 0 { //找到适配项
  36926. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  36927. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  36928. }
  36929. return string(s2)
  36930. }
  36931. // 对账
  36932. func (c *HisApiController) Post3202() {
  36933. start_time := c.GetString("start_time")
  36934. end_time := c.GetString("end_time")
  36935. //insutype := c.GetString("insutype")
  36936. clr_type := c.GetString("clr_type")
  36937. clr_org := c.GetString("clr_optins")
  36938. admin_user_id, _ := c.GetInt64("admin_user_id")
  36939. adminUser := c.GetAdminUserInfo()
  36940. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36941. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36942. if len(clr_org) == 0 {
  36943. clr_org = miConfig.MdtrtareaAdmvs
  36944. }
  36945. timeLayout := "2006-01-02"
  36946. loc, _ := time.LoadLocation("Local")
  36947. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  36948. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  36949. var orders []*models.HisOrder
  36950. if clr_org == "421300" {
  36951. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36952. } else if clr_org == "420902" {
  36953. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36954. } else {
  36955. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36956. }
  36957. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  36958. //fixmedins_setl_cnt := int64(len(orders))
  36959. var medfee_sumamt float64
  36960. var acct_pay float64
  36961. var fund_pay_sumamt float64
  36962. for _, item := range orders {
  36963. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  36964. acct_pay = acct_pay + item.AcctPay
  36965. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  36966. }
  36967. //var medfee_sumamt_two float64
  36968. //var acct_pay_two float64
  36969. //var fund_pay_sumamt_two float64
  36970. //for _, item := range orders_two {
  36971. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  36972. // acct_pay_two = acct_pay_two + item.AcctPay
  36973. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  36974. //}
  36975. //var user_name string
  36976. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36977. //if role.ID == 0 {
  36978. // user_name = "xxx"
  36979. //} else {
  36980. // user_name = role.UserName
  36981. //}
  36982. var res ResultSix
  36983. if config.IsOpen == 1 {
  36984. var bps []*models.BusinessParamsTwo
  36985. var bp models.BusinessParamsTwo
  36986. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  36987. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  36988. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  36989. bp.MedfeeSumamt = medfee_sumamt_str
  36990. bp.AcctPay = acct_pay_str
  36991. bp.FundPaySumamt = fund_pay_sumamt_str
  36992. bp.Insutype = ""
  36993. bp.StmtBegndate = start_time
  36994. bp.ClrType = clr_type
  36995. bp.SetlOptins = clr_org
  36996. bp.StmtEnddate = end_time
  36997. bps = append(bps, &bp)
  36998. data := make(map[string]interface{})
  36999. data["bps"] = bps
  37000. data["org_name"] = miConfig.OrgName
  37001. data["doctor"] = role.UserName
  37002. data["fixmedins_code"] = miConfig.Code
  37003. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37004. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37005. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37006. if miConfig.MdtrtareaAdmvs == "421300" {
  37007. client := &http.Client{}
  37008. bytesData, _ := json.Marshal(data)
  37009. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37010. resp, _ := client.Do(req)
  37011. defer resp.Body.Close()
  37012. body, ioErr := ioutil.ReadAll(resp.Body)
  37013. if ioErr != nil {
  37014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37016. return
  37017. }
  37018. var respJSON map[string]interface{}
  37019. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37022. return
  37023. }
  37024. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37025. userJSONBytes, _ := json.Marshal(respJSON)
  37026. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37027. utils.ErrorLog("解析失败:%v", err)
  37028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37029. return
  37030. }
  37031. }
  37032. if miConfig.MdtrtareaAdmvs == "420200" {
  37033. client := &http.Client{}
  37034. bytesData, _ := json.Marshal(data)
  37035. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37036. resp, _ := client.Do(req)
  37037. defer resp.Body.Close()
  37038. body, ioErr := ioutil.ReadAll(resp.Body)
  37039. if ioErr != nil {
  37040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37042. return
  37043. }
  37044. var respJSON map[string]interface{}
  37045. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37048. return
  37049. }
  37050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37051. userJSONBytes, _ := json.Marshal(respJSON)
  37052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37053. utils.ErrorLog("解析失败:%v", err)
  37054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37055. return
  37056. }
  37057. }
  37058. if miConfig.MdtrtareaAdmvs == "421182" {
  37059. client := &http.Client{}
  37060. bytesData, _ := json.Marshal(data)
  37061. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37062. resp, _ := client.Do(req)
  37063. defer resp.Body.Close()
  37064. body, ioErr := ioutil.ReadAll(resp.Body)
  37065. if ioErr != nil {
  37066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37068. return
  37069. }
  37070. var respJSON map[string]interface{}
  37071. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37074. return
  37075. }
  37076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37077. userJSONBytes, _ := json.Marshal(respJSON)
  37078. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37079. utils.ErrorLog("解析失败:%v", err)
  37080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37081. return
  37082. }
  37083. }
  37084. if miConfig.MdtrtareaAdmvs == "420902" {
  37085. client := &http.Client{}
  37086. bytesData, _ := json.Marshal(data)
  37087. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37088. resp, _ := client.Do(req)
  37089. defer resp.Body.Close()
  37090. body, ioErr := ioutil.ReadAll(resp.Body)
  37091. if ioErr != nil {
  37092. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37094. return
  37095. }
  37096. var respJSON map[string]interface{}
  37097. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37100. return
  37101. }
  37102. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37103. userJSONBytes, _ := json.Marshal(respJSON)
  37104. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37105. utils.ErrorLog("解析失败:%v", err)
  37106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37107. return
  37108. }
  37109. }
  37110. if res.Infcode == 0 {
  37111. c.ServeSuccessJSON(map[string]interface{}{
  37112. "msg": "发起成功",
  37113. })
  37114. } else {
  37115. c.ServeSuccessJSON(map[string]interface{}{
  37116. "failed_code": -10,
  37117. "msg": res.ErrMsg,
  37118. })
  37119. }
  37120. }
  37121. }
  37122. func (c *HisApiController) Post3204a() {
  37123. start_time := c.GetString("start_time")
  37124. end_time := c.GetString("end_time")
  37125. //insutype := c.GetString("insutype")
  37126. clr_type := c.GetString("clr_type")
  37127. clr_org := c.GetString("clr_optins")
  37128. admin_user_id, _ := c.GetInt64("admin_user_id")
  37129. adminUser := c.GetAdminUserInfo()
  37130. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37131. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37132. if len(clr_org) == 0 {
  37133. clr_org = miConfig.MdtrtareaAdmvs
  37134. }
  37135. timeLayout := "2006-01-02"
  37136. loc, _ := time.LoadLocation("Local")
  37137. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37138. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37139. var orders []*models.HisOrder
  37140. if clr_org == "421300" {
  37141. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37142. } else if clr_org == "420902" {
  37143. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37144. } else {
  37145. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37146. }
  37147. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37148. //fixmedins_setl_cnt := int64(len(orders))
  37149. var medfee_sumamt float64
  37150. var acct_pay float64
  37151. var fund_pay_sumamt float64
  37152. for _, item := range orders {
  37153. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37154. acct_pay = acct_pay + item.AcctPay
  37155. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37156. }
  37157. //var medfee_sumamt_two float64
  37158. //var acct_pay_two float64
  37159. //var fund_pay_sumamt_two float64
  37160. //for _, item := range orders_two {
  37161. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37162. // acct_pay_two = acct_pay_two + item.AcctPay
  37163. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37164. //}
  37165. //var user_name string
  37166. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37167. //if role.ID == 0 {
  37168. // user_name = "xxx"
  37169. //} else {
  37170. // user_name = role.UserName
  37171. //}
  37172. var res ResultSix
  37173. if config.IsOpen == 1 {
  37174. var bps []*models.BusinessParamsTwo
  37175. var bp models.BusinessParamsTwo
  37176. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37177. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37178. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37179. bp.MedfeeSumamt = medfee_sumamt_str
  37180. bp.AcctPay = acct_pay_str
  37181. bp.FundPaySumamt = fund_pay_sumamt_str
  37182. bp.Insutype = ""
  37183. bp.StmtBegndate = start_time
  37184. bp.ClrType = clr_type
  37185. bp.SetlOptins = clr_org
  37186. bp.StmtEnddate = end_time
  37187. bps = append(bps, &bp)
  37188. data := make(map[string]interface{})
  37189. data["bps"] = bps
  37190. data["org_name"] = miConfig.OrgName
  37191. data["doctor"] = role.UserName
  37192. data["fixmedins_code"] = miConfig.Code
  37193. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37194. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37195. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37196. if miConfig.MdtrtareaAdmvs == "421300" {
  37197. client := &http.Client{}
  37198. bytesData, _ := json.Marshal(data)
  37199. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37200. resp, _ := client.Do(req)
  37201. defer resp.Body.Close()
  37202. body, ioErr := ioutil.ReadAll(resp.Body)
  37203. if ioErr != nil {
  37204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37206. return
  37207. }
  37208. var respJSON map[string]interface{}
  37209. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37212. return
  37213. }
  37214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37215. userJSONBytes, _ := json.Marshal(respJSON)
  37216. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37217. utils.ErrorLog("解析失败:%v", err)
  37218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37219. return
  37220. }
  37221. }
  37222. if miConfig.MdtrtareaAdmvs == "420200" {
  37223. client := &http.Client{}
  37224. bytesData, _ := json.Marshal(data)
  37225. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37226. resp, _ := client.Do(req)
  37227. defer resp.Body.Close()
  37228. body, ioErr := ioutil.ReadAll(resp.Body)
  37229. if ioErr != nil {
  37230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37232. return
  37233. }
  37234. var respJSON map[string]interface{}
  37235. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37238. return
  37239. }
  37240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37241. userJSONBytes, _ := json.Marshal(respJSON)
  37242. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37243. utils.ErrorLog("解析失败:%v", err)
  37244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37245. return
  37246. }
  37247. }
  37248. if miConfig.MdtrtareaAdmvs == "421182" {
  37249. client := &http.Client{}
  37250. bytesData, _ := json.Marshal(data)
  37251. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  37252. resp, _ := client.Do(req)
  37253. defer resp.Body.Close()
  37254. body, ioErr := ioutil.ReadAll(resp.Body)
  37255. if ioErr != nil {
  37256. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37258. return
  37259. }
  37260. var respJSON map[string]interface{}
  37261. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37264. return
  37265. }
  37266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37267. userJSONBytes, _ := json.Marshal(respJSON)
  37268. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37269. utils.ErrorLog("解析失败:%v", err)
  37270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37271. return
  37272. }
  37273. }
  37274. if miConfig.MdtrtareaAdmvs == "420902" {
  37275. client := &http.Client{}
  37276. bytesData, _ := json.Marshal(data)
  37277. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  37278. resp, _ := client.Do(req)
  37279. defer resp.Body.Close()
  37280. body, ioErr := ioutil.ReadAll(resp.Body)
  37281. if ioErr != nil {
  37282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37284. return
  37285. }
  37286. var respJSON map[string]interface{}
  37287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37290. return
  37291. }
  37292. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37293. userJSONBytes, _ := json.Marshal(respJSON)
  37294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37295. utils.ErrorLog("解析失败:%v", err)
  37296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37297. return
  37298. }
  37299. }
  37300. if res.Infcode == 0 {
  37301. c.ServeSuccessJSON(map[string]interface{}{
  37302. "msg": "撤销成功",
  37303. })
  37304. } else {
  37305. c.ServeSuccessJSON(map[string]interface{}{
  37306. "failed_code": -10,
  37307. "msg": res.ErrMsg,
  37308. })
  37309. }
  37310. }
  37311. }
  37312. func (c *HisApiController) Post3204() {
  37313. admin_user_id, _ := c.GetInt64("admin_user_id")
  37314. id := c.GetString("id")
  37315. adminUser := c.GetAdminUserInfo()
  37316. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37317. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37318. //clr_org := miConfig.MdtrtareaAdmvs
  37319. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37320. var res ResultSix
  37321. if config.IsOpen == 1 {
  37322. data := make(map[string]interface{})
  37323. data["id"] = id
  37324. data["org_name"] = miConfig.OrgName
  37325. data["doctor"] = role.UserName
  37326. data["fixmedins_code"] = miConfig.Code
  37327. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37328. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37329. client := &http.Client{}
  37330. bytesData, _ := json.Marshal(data)
  37331. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  37332. resp, _ := client.Do(req)
  37333. defer resp.Body.Close()
  37334. body, ioErr := ioutil.ReadAll(resp.Body)
  37335. if ioErr != nil {
  37336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37338. return
  37339. }
  37340. var respJSON map[string]interface{}
  37341. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37344. return
  37345. }
  37346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37347. userJSONBytes, _ := json.Marshal(respJSON)
  37348. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37349. utils.ErrorLog("解析失败:%v", err)
  37350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37351. return
  37352. }
  37353. if res.Infcode == 0 {
  37354. c.ServeSuccessJSON(map[string]interface{}{
  37355. "msg": "发起成功",
  37356. })
  37357. } else {
  37358. c.ServeSuccessJSON(map[string]interface{}{
  37359. "failed_code": -10,
  37360. "msg": res.ErrMsg,
  37361. })
  37362. }
  37363. }
  37364. }
  37365. func (c *HisApiController) Post8404() {
  37366. admin_user_id, _ := c.GetInt64("admin_user_id")
  37367. month := c.GetString("month")
  37368. adminUser := c.GetAdminUserInfo()
  37369. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37370. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37371. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37372. var res ResultSix
  37373. if config.IsOpen == 1 {
  37374. data := make(map[string]interface{})
  37375. data["month"] = month
  37376. data["org_name"] = miConfig.OrgName
  37377. data["doctor"] = role.UserName
  37378. data["fixmedins_code"] = miConfig.Code
  37379. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37380. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37381. client := &http.Client{}
  37382. bytesData, _ := json.Marshal(data)
  37383. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  37384. resp, _ := client.Do(req)
  37385. defer resp.Body.Close()
  37386. body, ioErr := ioutil.ReadAll(resp.Body)
  37387. if ioErr != nil {
  37388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37390. return
  37391. }
  37392. var respJSON map[string]interface{}
  37393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37396. return
  37397. }
  37398. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37399. userJSONBytes, _ := json.Marshal(respJSON)
  37400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37401. utils.ErrorLog("解析失败:%v", err)
  37402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37403. return
  37404. }
  37405. if res.Infcode == 0 {
  37406. c.ServeSuccessJSON(map[string]interface{}{
  37407. "msg": "查询成功",
  37408. })
  37409. } else {
  37410. c.ServeSuccessJSON(map[string]interface{}{
  37411. "failed_code": -10,
  37412. "msg": res.ErrMsg,
  37413. })
  37414. }
  37415. }
  37416. }
  37417. func (c *HisApiController) Post3202b() {
  37418. start_time := c.GetString("start_time")
  37419. end_time := c.GetString("end_time")
  37420. //insutype := c.GetString("insutype")
  37421. clr_type := c.GetString("clr_type")
  37422. clr_org := c.GetString("clr_optins")
  37423. admin_user_id, _ := c.GetInt64("admin_user_id")
  37424. adminUser := c.GetAdminUserInfo()
  37425. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37426. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37427. if len(clr_org) == 0 {
  37428. clr_org = miConfig.MdtrtareaAdmvs
  37429. }
  37430. timeLayout := "2006-01-02"
  37431. loc, _ := time.LoadLocation("Local")
  37432. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37433. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37434. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37435. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37436. //fixmedins_setl_cnt := int64(len(orders))
  37437. var medfee_sumamt float64
  37438. var acct_pay float64
  37439. var fund_pay_sumamt float64
  37440. for _, item := range orders {
  37441. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37442. acct_pay = acct_pay + item.AcctPay
  37443. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37444. }
  37445. //var medfee_sumamt_two float64
  37446. //var acct_pay_two float64
  37447. //var fund_pay_sumamt_two float64
  37448. //for _, item := range orders_two {
  37449. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37450. // acct_pay_two = acct_pay_two + item.AcctPay
  37451. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37452. //}
  37453. //var user_name string
  37454. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37455. //if role.ID == 0 {
  37456. // user_name = "xxx"
  37457. //} else {
  37458. // user_name = role.UserName
  37459. //}
  37460. var res ResultSix
  37461. if config.IsOpen == 1 {
  37462. var bps []*models.BusinessParamsTwo
  37463. var bp models.BusinessParamsTwo
  37464. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37465. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37466. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37467. bp.MedfeeSumamt = medfee_sumamt_str
  37468. bp.AcctPay = acct_pay_str
  37469. bp.FundPaySumamt = fund_pay_sumamt_str
  37470. bp.Insutype = "390"
  37471. bp.StmtBegndate = start_time
  37472. bp.ClrType = clr_type
  37473. bp.SetlOptins = clr_org
  37474. bp.StmtEnddate = end_time
  37475. bps = append(bps, &bp)
  37476. data := make(map[string]interface{})
  37477. data["bps"] = bps
  37478. data["org_name"] = miConfig.OrgName
  37479. data["doctor"] = role.UserName
  37480. data["fixmedins_code"] = miConfig.Code
  37481. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37482. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37483. if miConfig.MdtrtareaAdmvs == "421300" {
  37484. client := &http.Client{}
  37485. bytesData, _ := json.Marshal(data)
  37486. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  37487. resp, _ := client.Do(req)
  37488. defer resp.Body.Close()
  37489. body, ioErr := ioutil.ReadAll(resp.Body)
  37490. if ioErr != nil {
  37491. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37493. return
  37494. }
  37495. var respJSON map[string]interface{}
  37496. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37499. return
  37500. }
  37501. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37502. userJSONBytes, _ := json.Marshal(respJSON)
  37503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37504. utils.ErrorLog("解析失败:%v", err)
  37505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37506. return
  37507. }
  37508. }
  37509. if miConfig.MdtrtareaAdmvs == "420200" {
  37510. client := &http.Client{}
  37511. bytesData, _ := json.Marshal(data)
  37512. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  37513. resp, _ := client.Do(req)
  37514. defer resp.Body.Close()
  37515. body, ioErr := ioutil.ReadAll(resp.Body)
  37516. if ioErr != nil {
  37517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37519. return
  37520. }
  37521. var respJSON map[string]interface{}
  37522. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37525. return
  37526. }
  37527. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37528. userJSONBytes, _ := json.Marshal(respJSON)
  37529. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37530. utils.ErrorLog("解析失败:%v", err)
  37531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37532. return
  37533. }
  37534. }
  37535. if miConfig.MdtrtareaAdmvs == "421182" {
  37536. client := &http.Client{}
  37537. bytesData, _ := json.Marshal(data)
  37538. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  37539. resp, _ := client.Do(req)
  37540. defer resp.Body.Close()
  37541. body, ioErr := ioutil.ReadAll(resp.Body)
  37542. if ioErr != nil {
  37543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37545. return
  37546. }
  37547. var respJSON map[string]interface{}
  37548. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37551. return
  37552. }
  37553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37554. userJSONBytes, _ := json.Marshal(respJSON)
  37555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37556. utils.ErrorLog("解析失败:%v", err)
  37557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37558. return
  37559. }
  37560. }
  37561. if res.Infcode == 0 {
  37562. c.ServeSuccessJSON(map[string]interface{}{
  37563. "msg": "发起成功",
  37564. })
  37565. } else {
  37566. c.ServeSuccessJSON(map[string]interface{}{
  37567. "failed_code": -10,
  37568. "msg": res.ErrMsg,
  37569. })
  37570. }
  37571. }
  37572. }
  37573. func (c *HisApiController) Post1608() {
  37574. start_time := c.GetString("start_time")
  37575. end_time := c.GetString("end_time")
  37576. admin_user_id, _ := c.GetInt64("admin_user_id")
  37577. adminUser := c.GetAdminUserInfo()
  37578. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37579. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37580. timeLayout := "2006-01-02"
  37581. loc, _ := time.LoadLocation("Local")
  37582. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37583. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37584. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37585. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37586. fixmedins_setl_cnt := int64(len(orders))
  37587. var medfee_sumamt float64
  37588. var func_smamt float64
  37589. for _, item := range orders {
  37590. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37591. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  37592. }
  37593. times := strings.Split(start_time, "-")
  37594. time_tows := strings.Split(end_time, "-")
  37595. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37596. var res ResultSix
  37597. if config.IsOpen == 1 {
  37598. //var bps []*models.BusinessParamsTwo
  37599. //var bp models.BusinessParamsTwo
  37600. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37601. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  37602. data := make(map[string]interface{})
  37603. data["org_name"] = miConfig.OrgName
  37604. data["doctor"] = role.UserName
  37605. data["func_smamt"] = func_smamt_str
  37606. data["fixmedins_code"] = miConfig.Code
  37607. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37608. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37609. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  37610. data["medfee_sumamt"] = medfee_sumamt_str
  37611. data["start_time"] = times[0] + times[1] + times[2]
  37612. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  37613. if miConfig.MdtrtareaAdmvs == "421300" {
  37614. client := &http.Client{}
  37615. bytesData, _ := json.Marshal(data)
  37616. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  37617. resp, _ := client.Do(req)
  37618. defer resp.Body.Close()
  37619. body, ioErr := ioutil.ReadAll(resp.Body)
  37620. if ioErr != nil {
  37621. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37623. return
  37624. }
  37625. var respJSON map[string]interface{}
  37626. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37629. return
  37630. }
  37631. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37632. userJSONBytes, _ := json.Marshal(respJSON)
  37633. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37634. utils.ErrorLog("解析失败:%v", err)
  37635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37636. return
  37637. }
  37638. }
  37639. if miConfig.MdtrtareaAdmvs == "420200" {
  37640. client := &http.Client{}
  37641. bytesData, _ := json.Marshal(data)
  37642. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  37643. resp, _ := client.Do(req)
  37644. defer resp.Body.Close()
  37645. body, ioErr := ioutil.ReadAll(resp.Body)
  37646. if ioErr != nil {
  37647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37649. return
  37650. }
  37651. var respJSON map[string]interface{}
  37652. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37655. return
  37656. }
  37657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37658. userJSONBytes, _ := json.Marshal(respJSON)
  37659. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37660. utils.ErrorLog("解析失败:%v", err)
  37661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37662. return
  37663. }
  37664. }
  37665. if miConfig.MdtrtareaAdmvs == "421182" {
  37666. client := &http.Client{}
  37667. bytesData, _ := json.Marshal(data)
  37668. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  37669. resp, _ := client.Do(req)
  37670. defer resp.Body.Close()
  37671. body, ioErr := ioutil.ReadAll(resp.Body)
  37672. if ioErr != nil {
  37673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37675. return
  37676. }
  37677. var respJSON map[string]interface{}
  37678. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37681. return
  37682. }
  37683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37684. userJSONBytes, _ := json.Marshal(respJSON)
  37685. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37686. utils.ErrorLog("解析失败:%v", err)
  37687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37688. return
  37689. }
  37690. }
  37691. if res.Infcode == 0 {
  37692. c.ServeSuccessJSON(map[string]interface{}{
  37693. "msg": "发起成功",
  37694. })
  37695. } else {
  37696. c.ServeSuccessJSON(map[string]interface{}{
  37697. "failed_code": -10,
  37698. "msg": res.ErrMsg,
  37699. })
  37700. }
  37701. }
  37702. }
  37703. // 5.11.1.1【5262】结算信息按时间段查询
  37704. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  37705. admin_user_id, _ := c.GetInt64("admin_user_id")
  37706. adminUser := c.GetAdminUserInfo()
  37707. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37708. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37709. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37710. var res Result5262
  37711. if config.IsOpen == 1 {
  37712. if miConfig.MdtrtareaAdmvs == "421300" {
  37713. data := make(map[string]interface{})
  37714. data["bps"] = bp
  37715. data["org_name"] = miConfig.OrgName
  37716. data["doctor"] = role.UserName
  37717. data["fixmedins_code"] = miConfig.Code
  37718. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37719. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37720. data["page"] = strconv.FormatInt(page, 10)
  37721. data["limit"] = strconv.FormatInt(limit, 10)
  37722. fmt.Println(data)
  37723. client := &http.Client{}
  37724. bytesData, _ := json.Marshal(data)
  37725. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  37726. resp, _ := client.Do(req)
  37727. defer resp.Body.Close()
  37728. body, ioErr := ioutil.ReadAll(resp.Body)
  37729. if ioErr != nil {
  37730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37732. return
  37733. }
  37734. var respJSON map[string]interface{}
  37735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37738. return
  37739. }
  37740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37741. userJSONBytes, _ := json.Marshal(respJSON)
  37742. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37743. utils.ErrorLog("解析失败:%v", err)
  37744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37745. return
  37746. }
  37747. }
  37748. if miConfig.MdtrtareaAdmvs == "420200" {
  37749. data := make(map[string]interface{})
  37750. data["bps"] = bp
  37751. data["org_name"] = miConfig.OrgName
  37752. data["doctor"] = role.UserName
  37753. data["fixmedins_code"] = miConfig.Code
  37754. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37755. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37756. data["page"] = strconv.FormatInt(page, 10)
  37757. data["limit"] = strconv.FormatInt(limit, 10)
  37758. fmt.Println(data)
  37759. client := &http.Client{}
  37760. bytesData, _ := json.Marshal(data)
  37761. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  37762. resp, _ := client.Do(req)
  37763. defer resp.Body.Close()
  37764. body, ioErr := ioutil.ReadAll(resp.Body)
  37765. if ioErr != nil {
  37766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37768. return
  37769. }
  37770. var respJSON map[string]interface{}
  37771. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37774. return
  37775. }
  37776. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37777. userJSONBytes, _ := json.Marshal(respJSON)
  37778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37779. utils.ErrorLog("解析失败:%v", err)
  37780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37781. return
  37782. }
  37783. }
  37784. if miConfig.MdtrtareaAdmvs == "421182" {
  37785. data := make(map[string]interface{})
  37786. data["bps"] = bp
  37787. data["org_name"] = miConfig.OrgName
  37788. data["doctor"] = role.UserName
  37789. data["fixmedins_code"] = miConfig.Code
  37790. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37791. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37792. data["page"] = strconv.FormatInt(page, 10)
  37793. data["limit"] = strconv.FormatInt(limit, 10)
  37794. fmt.Println(data)
  37795. client := &http.Client{}
  37796. bytesData, _ := json.Marshal(data)
  37797. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  37798. resp, _ := client.Do(req)
  37799. defer resp.Body.Close()
  37800. body, ioErr := ioutil.ReadAll(resp.Body)
  37801. if ioErr != nil {
  37802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37804. return
  37805. }
  37806. var respJSON map[string]interface{}
  37807. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37810. return
  37811. }
  37812. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37813. userJSONBytes, _ := json.Marshal(respJSON)
  37814. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37815. utils.ErrorLog("解析失败:%v", err)
  37816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37817. return
  37818. }
  37819. }
  37820. if miConfig.MdtrtareaAdmvs == "420902" {
  37821. data := make(map[string]interface{})
  37822. data["bps"] = bp
  37823. data["org_name"] = miConfig.OrgName
  37824. data["doctor"] = role.UserName
  37825. data["fixmedins_code"] = miConfig.Code
  37826. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37827. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37828. data["page"] = strconv.FormatInt(page, 10)
  37829. data["limit"] = strconv.FormatInt(limit, 10)
  37830. fmt.Println(data)
  37831. client := &http.Client{}
  37832. bytesData, _ := json.Marshal(data)
  37833. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  37834. resp, _ := client.Do(req)
  37835. defer resp.Body.Close()
  37836. body, ioErr := ioutil.ReadAll(resp.Body)
  37837. if ioErr != nil {
  37838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37840. return
  37841. }
  37842. var respJSON map[string]interface{}
  37843. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37846. return
  37847. }
  37848. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37849. userJSONBytes, _ := json.Marshal(respJSON)
  37850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37851. utils.ErrorLog("解析失败:%v", err)
  37852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37853. return
  37854. }
  37855. }
  37856. if res.Infcode == 0 {
  37857. c.ServeSuccessJSON(map[string]interface{}{
  37858. "order": res.Output.Result,
  37859. "total": res.Output.PageInfo.RecordCounts,
  37860. })
  37861. } else {
  37862. c.ServeSuccessJSON(map[string]interface{}{
  37863. "failed_code": -10,
  37864. "msg": res.ErrMsg,
  37865. })
  37866. }
  37867. }
  37868. }
  37869. // 5.11.1.2【5267】异地结算信息时间段查询
  37870. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  37871. admin_user_id, _ := c.GetInt64("admin_user_id")
  37872. adminUser := c.GetAdminUserInfo()
  37873. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37874. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37875. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37876. var res Result5267
  37877. if config.IsOpen == 1 {
  37878. if miConfig.MdtrtareaAdmvs == "421300" {
  37879. data := make(map[string]interface{})
  37880. data["bps"] = bp
  37881. data["org_name"] = miConfig.OrgName
  37882. data["doctor"] = role.UserName
  37883. data["fixmedins_code"] = miConfig.Code
  37884. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37885. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37886. data["page"] = page
  37887. data["limit"] = limit
  37888. fmt.Println(data)
  37889. client := &http.Client{}
  37890. bytesData, _ := json.Marshal(data)
  37891. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  37892. resp, _ := client.Do(req)
  37893. defer resp.Body.Close()
  37894. body, ioErr := ioutil.ReadAll(resp.Body)
  37895. if ioErr != nil {
  37896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37898. return
  37899. }
  37900. var respJSON map[string]interface{}
  37901. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37904. return
  37905. }
  37906. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37907. userJSONBytes, _ := json.Marshal(respJSON)
  37908. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37909. utils.ErrorLog("解析失败:%v", err)
  37910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37911. return
  37912. }
  37913. }
  37914. if miConfig.MdtrtareaAdmvs == "420200" {
  37915. data := make(map[string]interface{})
  37916. data["bps"] = bp
  37917. data["org_name"] = miConfig.OrgName
  37918. data["doctor"] = role.UserName
  37919. data["fixmedins_code"] = miConfig.Code
  37920. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37921. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37922. data["page"] = page
  37923. data["limit"] = limit
  37924. fmt.Println(data)
  37925. client := &http.Client{}
  37926. bytesData, _ := json.Marshal(data)
  37927. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  37928. resp, _ := client.Do(req)
  37929. defer resp.Body.Close()
  37930. body, ioErr := ioutil.ReadAll(resp.Body)
  37931. if ioErr != nil {
  37932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37934. return
  37935. }
  37936. var respJSON map[string]interface{}
  37937. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37940. return
  37941. }
  37942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37943. userJSONBytes, _ := json.Marshal(respJSON)
  37944. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37945. utils.ErrorLog("解析失败:%v", err)
  37946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37947. return
  37948. }
  37949. }
  37950. if miConfig.MdtrtareaAdmvs == "421182" {
  37951. data := make(map[string]interface{})
  37952. data["bps"] = bp
  37953. data["org_name"] = miConfig.OrgName
  37954. data["doctor"] = role.UserName
  37955. data["fixmedins_code"] = miConfig.Code
  37956. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37957. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37958. data["page"] = page
  37959. data["limit"] = limit
  37960. fmt.Println(data)
  37961. client := &http.Client{}
  37962. bytesData, _ := json.Marshal(data)
  37963. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  37964. resp, _ := client.Do(req)
  37965. defer resp.Body.Close()
  37966. body, ioErr := ioutil.ReadAll(resp.Body)
  37967. if ioErr != nil {
  37968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37970. return
  37971. }
  37972. var respJSON map[string]interface{}
  37973. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37976. return
  37977. }
  37978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37979. userJSONBytes, _ := json.Marshal(respJSON)
  37980. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37981. utils.ErrorLog("解析失败:%v", err)
  37982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37983. return
  37984. }
  37985. }
  37986. if res.Infcode == 0 {
  37987. c.ServeSuccessJSON(map[string]interface{}{
  37988. "order": res.Output.Result,
  37989. "total": res.Output.PageInfo.RecordCounts,
  37990. })
  37991. } else {
  37992. c.ServeSuccessJSON(map[string]interface{}{
  37993. "failed_code": -10,
  37994. "msg": res.ErrMsg,
  37995. })
  37996. }
  37997. }
  37998. }
  37999. func (c *HisApiController) Post3501() {
  38000. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38001. data := make(map[string]interface{})
  38002. var struct3501s []models.Struct3501
  38003. var struct3501 models.Struct3501
  38004. struct3501.OrgName = miConfig.OrgName
  38005. struct3501.AccessKey = miConfig.AccessKey
  38006. struct3501.RequestUrl = miConfig.Url
  38007. struct3501.SecretKey = miConfig.SecretKey
  38008. struct3501.ManuDate = "2022-08-17"
  38009. struct3501.FixmedinsBchno = ""
  38010. struct3501.ManuLotnum = ""
  38011. struct3501.RxFlag = "0"
  38012. struct3501.ExpyEnd = "2022-08-17"
  38013. struct3501.Invdate = "2022-08-17"
  38014. struct3501.InvCnt = "20.25"
  38015. struct3501.Memo = ""
  38016. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38017. struct3501.FixmedinsHilistId = miConfig.Code
  38018. struct3501.FixmedinsHilistName = miConfig.OrgName
  38019. struct3501s = append(struct3501s, struct3501)
  38020. data["struct_3501s"] = struct3501s
  38021. client := &http.Client{}
  38022. bytesData, _ := json.Marshal(data)
  38023. var req *http.Request
  38024. if miConfig.MdtrtareaAdmvs == "320921" {
  38025. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38026. } else {
  38027. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38028. }
  38029. resp, _ := client.Do(req)
  38030. defer resp.Body.Close()
  38031. body, ioErr := ioutil.ReadAll(resp.Body)
  38032. if ioErr != nil {
  38033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38035. return
  38036. }
  38037. var respJSON map[string]interface{}
  38038. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38041. return
  38042. }
  38043. var res ResultSix
  38044. var resSix10265 ResultSix10265 //1101结果
  38045. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38046. result, _ := json.Marshal(respJSON)
  38047. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38048. utils.ErrorLog("解析失败:%v", err)
  38049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38050. return
  38051. }
  38052. res.InfRefmsgid = resSix10265.InfRefmsgid
  38053. res.Output = resSix10265.Output
  38054. res.ErrMsg = resSix10265.ErrMsg
  38055. res.Cainfo = resSix10265.Cainfo
  38056. res.WarnMsg = resSix10265.WarnMsg
  38057. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38058. res.Infcode = infocode
  38059. if infocode == 0 {
  38060. c.ServeSuccessJSON(map[string]interface{}{
  38061. "msg": "上传成功",
  38062. })
  38063. return
  38064. } else {
  38065. c.ServeSuccessJSON(map[string]interface{}{
  38066. "failed_code": -10,
  38067. "msg": res.ErrMsg,
  38068. })
  38069. return
  38070. }
  38071. }
  38072. func (c *HisApiController) Post3502() {
  38073. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38074. data := make(map[string]interface{})
  38075. var struct3502s []models.Struct3502
  38076. var struct3502 models.Struct3502
  38077. struct3502.OrgName = miConfig.OrgName
  38078. struct3502.AccessKey = miConfig.AccessKey
  38079. struct3502.RequestUrl = miConfig.Url
  38080. struct3502.SecretKey = miConfig.SecretKey
  38081. struct3502.ManuDate = "2022-08-15"
  38082. struct3502.FixmedinsBchno = ""
  38083. struct3502.ManuLotnum = ""
  38084. struct3502.RxFlag = "0"
  38085. struct3502.ExpyEnd = "2022-08-15"
  38086. struct3502.Invdate = "2022-08-15"
  38087. struct3502.InvCnt = "20.25"
  38088. struct3502.Memo = ""
  38089. struct3502.MedListCodg = "XB01ABD056B002020200517"
  38090. struct3502.FixmedinsHilistId = miConfig.Code
  38091. struct3502.FixmedinsHilistName = miConfig.OrgName
  38092. struct3502s = append(struct3502s, struct3502)
  38093. data["struct_3502s"] = struct3502s
  38094. client := &http.Client{}
  38095. bytesData, _ := json.Marshal(data)
  38096. var req *http.Request
  38097. if miConfig.MdtrtareaAdmvs == "320921" {
  38098. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38099. } else {
  38100. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38101. }
  38102. resp, _ := client.Do(req)
  38103. defer resp.Body.Close()
  38104. body, ioErr := ioutil.ReadAll(resp.Body)
  38105. if ioErr != nil {
  38106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38108. return
  38109. }
  38110. var respJSON map[string]interface{}
  38111. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38114. return
  38115. }
  38116. var res ResultSix
  38117. var resSix10265 ResultSix10265 //1101结果
  38118. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38119. result, _ := json.Marshal(respJSON)
  38120. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38121. utils.ErrorLog("解析失败:%v", err)
  38122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38123. return
  38124. }
  38125. res.InfRefmsgid = resSix10265.InfRefmsgid
  38126. res.Output = resSix10265.Output
  38127. res.ErrMsg = resSix10265.ErrMsg
  38128. res.Cainfo = resSix10265.Cainfo
  38129. res.WarnMsg = resSix10265.WarnMsg
  38130. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38131. res.Infcode = infocode
  38132. if infocode == 0 {
  38133. c.ServeSuccessJSON(map[string]interface{}{
  38134. "msg": "上传成功",
  38135. })
  38136. return
  38137. } else {
  38138. c.ServeSuccessJSON(map[string]interface{}{
  38139. "failed_code": -10,
  38140. "msg": res.ErrMsg,
  38141. })
  38142. return
  38143. }
  38144. }
  38145. func (c *HisApiController) Post3503() {
  38146. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38147. data := make(map[string]interface{})
  38148. var struct3501s []models.Struct3501
  38149. var struct3501 models.Struct3501
  38150. struct3501.OrgName = miConfig.OrgName
  38151. struct3501.AccessKey = miConfig.AccessKey
  38152. struct3501.RequestUrl = miConfig.Url
  38153. struct3501.SecretKey = miConfig.SecretKey
  38154. struct3501.ManuDate = "2022-08-15"
  38155. struct3501.FixmedinsBchno = ""
  38156. struct3501.ManuLotnum = ""
  38157. struct3501.RxFlag = "0"
  38158. struct3501.ExpyEnd = "2022-08-15"
  38159. struct3501.Invdate = "2022-08-15"
  38160. struct3501.InvCnt = "20.25"
  38161. struct3501.Memo = ""
  38162. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38163. struct3501.FixmedinsHilistId = miConfig.Code
  38164. struct3501.FixmedinsHilistName = miConfig.OrgName
  38165. struct3501s = append(struct3501s, struct3501)
  38166. data["struct_3501s"] = struct3501s
  38167. client := &http.Client{}
  38168. bytesData, _ := json.Marshal(data)
  38169. var req *http.Request
  38170. if miConfig.MdtrtareaAdmvs == "320921" {
  38171. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38172. } else {
  38173. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38174. }
  38175. resp, _ := client.Do(req)
  38176. defer resp.Body.Close()
  38177. body, ioErr := ioutil.ReadAll(resp.Body)
  38178. if ioErr != nil {
  38179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38181. return
  38182. }
  38183. var respJSON map[string]interface{}
  38184. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38187. return
  38188. }
  38189. var res ResultSix
  38190. var resSix10265 ResultSix10265 //1101结果
  38191. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38192. result, _ := json.Marshal(respJSON)
  38193. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38194. utils.ErrorLog("解析失败:%v", err)
  38195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38196. return
  38197. }
  38198. res.InfRefmsgid = resSix10265.InfRefmsgid
  38199. res.Output = resSix10265.Output
  38200. res.ErrMsg = resSix10265.ErrMsg
  38201. res.Cainfo = resSix10265.Cainfo
  38202. res.WarnMsg = resSix10265.WarnMsg
  38203. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38204. res.Infcode = infocode
  38205. if infocode == 0 {
  38206. c.ServeSuccessJSON(map[string]interface{}{
  38207. "msg": "上传成功",
  38208. })
  38209. return
  38210. } else {
  38211. c.ServeSuccessJSON(map[string]interface{}{
  38212. "failed_code": -10,
  38213. "msg": res.ErrMsg,
  38214. })
  38215. return
  38216. }
  38217. }
  38218. func (c *HisApiController) Post3504() {
  38219. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38220. data := make(map[string]interface{})
  38221. var struct3501s []models.Struct3501
  38222. var struct3501 models.Struct3501
  38223. struct3501.OrgName = miConfig.OrgName
  38224. struct3501.AccessKey = miConfig.AccessKey
  38225. struct3501.RequestUrl = miConfig.Url
  38226. struct3501.SecretKey = miConfig.SecretKey
  38227. struct3501.ManuDate = "2022-08-15"
  38228. struct3501.FixmedinsBchno = ""
  38229. struct3501.ManuLotnum = ""
  38230. struct3501.RxFlag = "0"
  38231. struct3501.ExpyEnd = "2022-08-15"
  38232. struct3501.Invdate = "2022-08-15"
  38233. struct3501.InvCnt = "20.25"
  38234. struct3501.Memo = ""
  38235. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38236. struct3501.FixmedinsHilistId = miConfig.Code
  38237. struct3501.FixmedinsHilistName = miConfig.OrgName
  38238. struct3501s = append(struct3501s, struct3501)
  38239. data["struct_3501s"] = struct3501s
  38240. client := &http.Client{}
  38241. bytesData, _ := json.Marshal(data)
  38242. var req *http.Request
  38243. if miConfig.MdtrtareaAdmvs == "320921" {
  38244. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38245. } else {
  38246. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38247. }
  38248. resp, _ := client.Do(req)
  38249. defer resp.Body.Close()
  38250. body, ioErr := ioutil.ReadAll(resp.Body)
  38251. if ioErr != nil {
  38252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38254. return
  38255. }
  38256. var respJSON map[string]interface{}
  38257. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38260. return
  38261. }
  38262. var res ResultSix
  38263. var resSix10265 ResultSix10265 //1101结果
  38264. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38265. result, _ := json.Marshal(respJSON)
  38266. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38267. utils.ErrorLog("解析失败:%v", err)
  38268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38269. return
  38270. }
  38271. res.InfRefmsgid = resSix10265.InfRefmsgid
  38272. res.Output = resSix10265.Output
  38273. res.ErrMsg = resSix10265.ErrMsg
  38274. res.Cainfo = resSix10265.Cainfo
  38275. res.WarnMsg = resSix10265.WarnMsg
  38276. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38277. res.Infcode = infocode
  38278. if infocode == 0 {
  38279. c.ServeSuccessJSON(map[string]interface{}{
  38280. "msg": "上传成功",
  38281. })
  38282. return
  38283. } else {
  38284. c.ServeSuccessJSON(map[string]interface{}{
  38285. "failed_code": -10,
  38286. "msg": res.ErrMsg,
  38287. })
  38288. return
  38289. }
  38290. }
  38291. func (c *HisApiController) Post3505() {
  38292. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38293. data := make(map[string]interface{})
  38294. var struct3501s []models.Struct3501
  38295. var struct3501 models.Struct3501
  38296. struct3501.OrgName = miConfig.OrgName
  38297. struct3501.AccessKey = miConfig.AccessKey
  38298. struct3501.RequestUrl = miConfig.Url
  38299. struct3501.SecretKey = miConfig.SecretKey
  38300. struct3501.ManuDate = "2022-08-15"
  38301. struct3501.FixmedinsBchno = ""
  38302. struct3501.ManuLotnum = ""
  38303. struct3501.RxFlag = "0"
  38304. struct3501.ExpyEnd = "2022-08-15"
  38305. struct3501.Invdate = "2022-08-15"
  38306. struct3501.InvCnt = "20.25"
  38307. struct3501.Memo = ""
  38308. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38309. struct3501.FixmedinsHilistId = miConfig.Code
  38310. struct3501.FixmedinsHilistName = miConfig.OrgName
  38311. struct3501s = append(struct3501s, struct3501)
  38312. data["struct_3501s"] = struct3501s
  38313. client := &http.Client{}
  38314. bytesData, _ := json.Marshal(data)
  38315. var req *http.Request
  38316. if miConfig.MdtrtareaAdmvs == "320921" {
  38317. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38318. } else {
  38319. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38320. }
  38321. resp, _ := client.Do(req)
  38322. defer resp.Body.Close()
  38323. body, ioErr := ioutil.ReadAll(resp.Body)
  38324. if ioErr != nil {
  38325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38327. return
  38328. }
  38329. var respJSON map[string]interface{}
  38330. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38333. return
  38334. }
  38335. var res ResultSix
  38336. var resSix10265 ResultSix10265 //1101结果
  38337. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38338. result, _ := json.Marshal(respJSON)
  38339. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38340. utils.ErrorLog("解析失败:%v", err)
  38341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38342. return
  38343. }
  38344. res.InfRefmsgid = resSix10265.InfRefmsgid
  38345. res.Output = resSix10265.Output
  38346. res.ErrMsg = resSix10265.ErrMsg
  38347. res.Cainfo = resSix10265.Cainfo
  38348. res.WarnMsg = resSix10265.WarnMsg
  38349. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38350. res.Infcode = infocode
  38351. if infocode == 0 {
  38352. c.ServeSuccessJSON(map[string]interface{}{
  38353. "msg": "上传成功",
  38354. })
  38355. return
  38356. } else {
  38357. c.ServeSuccessJSON(map[string]interface{}{
  38358. "failed_code": -10,
  38359. "msg": res.ErrMsg,
  38360. })
  38361. return
  38362. }
  38363. }
  38364. func (c *HisApiController) Post3506() {
  38365. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38366. data := make(map[string]interface{})
  38367. var struct3501s []models.Struct3501
  38368. var struct3501 models.Struct3501
  38369. struct3501.OrgName = miConfig.OrgName
  38370. struct3501.AccessKey = miConfig.AccessKey
  38371. struct3501.RequestUrl = miConfig.Url
  38372. struct3501.SecretKey = miConfig.SecretKey
  38373. struct3501.ManuDate = "2022-08-15"
  38374. struct3501.FixmedinsBchno = ""
  38375. struct3501.ManuLotnum = ""
  38376. struct3501.RxFlag = "0"
  38377. struct3501.ExpyEnd = "2022-08-15"
  38378. struct3501.Invdate = "2022-08-15"
  38379. struct3501.InvCnt = "20.25"
  38380. struct3501.Memo = ""
  38381. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38382. struct3501.FixmedinsHilistId = miConfig.Code
  38383. struct3501.FixmedinsHilistName = miConfig.OrgName
  38384. struct3501s = append(struct3501s, struct3501)
  38385. data["struct_3501s"] = struct3501s
  38386. client := &http.Client{}
  38387. bytesData, _ := json.Marshal(data)
  38388. var req *http.Request
  38389. if miConfig.MdtrtareaAdmvs == "320921" {
  38390. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38391. } else {
  38392. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38393. }
  38394. resp, _ := client.Do(req)
  38395. defer resp.Body.Close()
  38396. body, ioErr := ioutil.ReadAll(resp.Body)
  38397. if ioErr != nil {
  38398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38400. return
  38401. }
  38402. var respJSON map[string]interface{}
  38403. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38406. return
  38407. }
  38408. var res ResultSix
  38409. var resSix10265 ResultSix10265 //1101结果
  38410. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38411. result, _ := json.Marshal(respJSON)
  38412. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38413. utils.ErrorLog("解析失败:%v", err)
  38414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38415. return
  38416. }
  38417. res.InfRefmsgid = resSix10265.InfRefmsgid
  38418. res.Output = resSix10265.Output
  38419. res.ErrMsg = resSix10265.ErrMsg
  38420. res.Cainfo = resSix10265.Cainfo
  38421. res.WarnMsg = resSix10265.WarnMsg
  38422. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38423. res.Infcode = infocode
  38424. if infocode == 0 {
  38425. c.ServeSuccessJSON(map[string]interface{}{
  38426. "msg": "上传成功",
  38427. })
  38428. return
  38429. } else {
  38430. c.ServeSuccessJSON(map[string]interface{}{
  38431. "failed_code": -10,
  38432. "msg": res.ErrMsg,
  38433. })
  38434. return
  38435. }
  38436. }
  38437. func (c *HisApiController) Post3507() {
  38438. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38439. data := make(map[string]interface{})
  38440. var struct3501s []models.Struct3501
  38441. var struct3501 models.Struct3501
  38442. struct3501.OrgName = miConfig.OrgName
  38443. struct3501.AccessKey = miConfig.AccessKey
  38444. struct3501.RequestUrl = miConfig.Url
  38445. struct3501.SecretKey = miConfig.SecretKey
  38446. struct3501.ManuDate = "2022-08-15"
  38447. struct3501.FixmedinsBchno = ""
  38448. struct3501.ManuLotnum = ""
  38449. struct3501.RxFlag = "0"
  38450. struct3501.ExpyEnd = "2022-08-15"
  38451. struct3501.Invdate = "2022-08-15"
  38452. struct3501.InvCnt = "20.25"
  38453. struct3501.Memo = ""
  38454. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38455. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  38456. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  38457. struct3501s = append(struct3501s, struct3501)
  38458. data["struct_3501s"] = struct3501s
  38459. client := &http.Client{}
  38460. bytesData, _ := json.Marshal(data)
  38461. var req *http.Request
  38462. if miConfig.MdtrtareaAdmvs == "320921" {
  38463. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38464. } else {
  38465. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38466. }
  38467. resp, _ := client.Do(req)
  38468. defer resp.Body.Close()
  38469. body, ioErr := ioutil.ReadAll(resp.Body)
  38470. if ioErr != nil {
  38471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38473. return
  38474. }
  38475. var respJSON map[string]interface{}
  38476. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38479. return
  38480. }
  38481. var res ResultSix
  38482. var resSix10265 ResultSix10265 //1101结果
  38483. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38484. result, _ := json.Marshal(respJSON)
  38485. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38486. utils.ErrorLog("解析失败:%v", err)
  38487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38488. return
  38489. }
  38490. res.InfRefmsgid = resSix10265.InfRefmsgid
  38491. res.Output = resSix10265.Output
  38492. res.ErrMsg = resSix10265.ErrMsg
  38493. res.Cainfo = resSix10265.Cainfo
  38494. res.WarnMsg = resSix10265.WarnMsg
  38495. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38496. res.Infcode = infocode
  38497. if infocode == 0 {
  38498. c.ServeSuccessJSON(map[string]interface{}{
  38499. "msg": "上传成功",
  38500. })
  38501. return
  38502. } else {
  38503. c.ServeSuccessJSON(map[string]interface{}{
  38504. "failed_code": -10,
  38505. "msg": res.ErrMsg,
  38506. })
  38507. return
  38508. }
  38509. }
  38510. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  38511. // WebSocket服务器地址
  38512. serverURL := "ws://127.0.0.1:8899"
  38513. // 解析WebSocket服务器地址
  38514. u, err := url.Parse(serverURL)
  38515. if err != nil {
  38516. }
  38517. // 建立WebSocket连接
  38518. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38519. if err != nil {
  38520. }
  38521. defer conn.Close()
  38522. input2 := make(map[string]interface{})
  38523. input := make(map[string]interface{})
  38524. inputData := make(map[string]interface{})
  38525. inputData["orgId"] = code
  38526. inputData["businessType"] = "01101"
  38527. inputData["operatorId"] = operator_id
  38528. inputData["operatorName"] = operator_name
  38529. inputData["officeId"] = "001"
  38530. inputData["officeName"] = "血透室"
  38531. inputData["deviceType"] = ""
  38532. input["data"] = inputData
  38533. input["orgId"] = code
  38534. input["transType"] = "ec.query"
  38535. //if md == ""
  38536. if md[:4] == "4403" {
  38537. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38538. } else if md[:4] == "4401" {
  38539. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38540. } else {
  38541. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38542. }
  38543. input2["indata"] = input
  38544. fmt.Println(input2)
  38545. bytesData, _ := json.Marshal(input2)
  38546. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38547. if err != nil {
  38548. fmt.Println(err)
  38549. }
  38550. // 接收消息
  38551. _, receivedMessage, err := conn.ReadMessage()
  38552. if err != nil {
  38553. fmt.Println(err)
  38554. }
  38555. return "", string(receivedMessage)
  38556. }
  38557. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  38558. // WebSocket服务器地址
  38559. serverURL := "ws://127.0.0.1:8899"
  38560. // 解析WebSocket服务器地址
  38561. u, err := url.Parse(serverURL)
  38562. if err != nil {
  38563. }
  38564. // 建立WebSocket连接
  38565. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38566. if err != nil {
  38567. }
  38568. defer conn.Close()
  38569. input2 := make(map[string]interface{})
  38570. input := make(map[string]interface{})
  38571. inputData := make(map[string]interface{})
  38572. inputData["orgId"] = code
  38573. inputData["businessType"] = "01101"
  38574. inputData["operatorId"] = operator_id
  38575. inputData["operatorName"] = operator_name
  38576. inputData["officeId"] = "001"
  38577. inputData["officeName"] = "血透室"
  38578. inputData["deviceType"] = ""
  38579. input["data"] = inputData
  38580. input["orgId"] = code
  38581. input["transType"] = "ec.query"
  38582. //if md == ""
  38583. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  38584. input2["indata"] = input
  38585. fmt.Println(input2)
  38586. bytesData, _ := json.Marshal(input2)
  38587. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38588. if err != nil {
  38589. fmt.Println(err)
  38590. }
  38591. // 接收消息
  38592. _, receivedMessage, err := conn.ReadMessage()
  38593. if err != nil {
  38594. fmt.Println(err)
  38595. }
  38596. return "", string(receivedMessage)
  38597. }
  38598. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  38599. // WebSocket服务器地址
  38600. serverURL := "ws://127.0.0.1:8899"
  38601. // 解析WebSocket服务器地址
  38602. u, err := url.Parse(serverURL)
  38603. if err != nil {
  38604. }
  38605. // 建立WebSocket连接
  38606. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38607. if err != nil {
  38608. }
  38609. defer conn.Close()
  38610. input2 := make(map[string]interface{})
  38611. input := make(map[string]interface{})
  38612. inputData := make(map[string]interface{})
  38613. inputData["orgId"] = code
  38614. inputData["businessType"] = "01301"
  38615. inputData["operatorId"] = operator_id
  38616. inputData["operatorName"] = operator_name
  38617. inputData["officeId"] = "001"
  38618. inputData["officeName"] = "血透室"
  38619. inputData["deviceType"] = ""
  38620. input["data"] = inputData
  38621. input["orgId"] = code
  38622. input["transType"] = "ec.query"
  38623. //if md == ""
  38624. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  38625. input2["indata"] = input
  38626. fmt.Println(input2)
  38627. bytesData, _ := json.Marshal(input2)
  38628. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38629. if err != nil {
  38630. fmt.Println(err)
  38631. }
  38632. // 接收消息
  38633. _, receivedMessage, err := conn.ReadMessage()
  38634. if err != nil {
  38635. fmt.Println(err)
  38636. }
  38637. return "", string(receivedMessage)
  38638. }
  38639. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  38640. // WebSocket服务器地址
  38641. serverURL := "ws://127.0.0.1:8899"
  38642. // 解析WebSocket服务器地址
  38643. u, err := url.Parse(serverURL)
  38644. if err != nil {
  38645. }
  38646. // 建立WebSocket连接
  38647. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38648. if err != nil {
  38649. }
  38650. defer conn.Close()
  38651. input2 := make(map[string]interface{})
  38652. input := make(map[string]interface{})
  38653. inputData := make(map[string]interface{})
  38654. inputData["orgId"] = code
  38655. inputData["businessType"] = "01103"
  38656. inputData["operatorId"] = operator_id
  38657. inputData["operatorName"] = operator_name
  38658. inputData["officeId"] = "001"
  38659. inputData["officeName"] = "血透室"
  38660. inputData["deviceType"] = ""
  38661. input["data"] = inputData
  38662. input["orgId"] = code
  38663. input["transType"] = "ec.query"
  38664. //if md ==
  38665. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  38666. input2["indata"] = input
  38667. fmt.Println(input2)
  38668. bytesData, _ := json.Marshal(input2)
  38669. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38670. if err != nil {
  38671. fmt.Println(err)
  38672. }
  38673. // 接收消息
  38674. _, receivedMessage, err := conn.ReadMessage()
  38675. if err != nil {
  38676. fmt.Println(err)
  38677. }
  38678. return "", string(receivedMessage)
  38679. }
  38680. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  38681. // WebSocket服务器地址
  38682. serverURL := "ws://127.0.0.1:8899"
  38683. // 解析WebSocket服务器地址
  38684. u, err := url.Parse(serverURL)
  38685. if err != nil {
  38686. }
  38687. // 建立WebSocket连接
  38688. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38689. if err != nil {
  38690. }
  38691. defer conn.Close()
  38692. input2 := make(map[string]interface{})
  38693. input := make(map[string]interface{})
  38694. inputData := make(map[string]interface{})
  38695. inputData["orgId"] = code
  38696. inputData["businessType"] = "01101"
  38697. inputData["operatorId"] = operator_id
  38698. inputData["operatorName"] = operator_name
  38699. inputData["officeId"] = "001"
  38700. inputData["officeName"] = "血透室"
  38701. inputData["deviceType"] = ""
  38702. input["data"] = inputData
  38703. input["orgId"] = code
  38704. input["transType"] = "ec.query"
  38705. //if md == ""
  38706. if md[:4] == "4403" {
  38707. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38708. } else if md[:4] == "4401" {
  38709. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38710. } else {
  38711. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38712. }
  38713. input2["indata"] = input
  38714. fmt.Println(input2)
  38715. bytesData, _ := json.Marshal(input2)
  38716. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38717. if err != nil {
  38718. fmt.Println(err)
  38719. }
  38720. // 接收消息
  38721. _, receivedMessage, err := conn.ReadMessage()
  38722. if err != nil {
  38723. fmt.Println(err)
  38724. }
  38725. return "", string(receivedMessage)
  38726. }
  38727. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  38728. // WebSocket服务器地址
  38729. serverURL := "ws://127.0.0.1:8899"
  38730. // 解析WebSocket服务器地址
  38731. u, err := url.Parse(serverURL)
  38732. if err != nil {
  38733. }
  38734. // 建立WebSocket连接
  38735. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38736. if err != nil {
  38737. }
  38738. defer conn.Close()
  38739. input2 := make(map[string]interface{})
  38740. input := make(map[string]interface{})
  38741. inputData := make(map[string]interface{})
  38742. inputData["orgId"] = code
  38743. inputData["businessType"] = "01301"
  38744. inputData["operatorId"] = operator_id
  38745. inputData["operatorName"] = operator_name
  38746. inputData["officeId"] = "001"
  38747. inputData["officeName"] = "血透室"
  38748. inputData["deviceType"] = ""
  38749. input["data"] = inputData
  38750. input["orgId"] = code
  38751. input["transType"] = "ec.query"
  38752. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38753. input2["indata"] = input
  38754. bytesData, _ := json.Marshal(input2)
  38755. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38756. if err != nil {
  38757. fmt.Println(err)
  38758. }
  38759. // 接收消息
  38760. _, receivedMessage, err := conn.ReadMessage()
  38761. if err != nil {
  38762. fmt.Println(err)
  38763. }
  38764. return "", string(receivedMessage)
  38765. }
  38766. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  38767. newArr = make([]string, 0)
  38768. for i := 0; i < len(arr); i++ {
  38769. repeat := false
  38770. for j := i + 1; j < len(arr); j++ {
  38771. if arr[i] == arr[j] {
  38772. repeat = true
  38773. break
  38774. }
  38775. }
  38776. if !repeat {
  38777. newArr = append(newArr, arr[i])
  38778. }
  38779. }
  38780. return
  38781. }
  38782. func getBirthdateAndAge(idNumber string) (string, int, error) {
  38783. if len(idNumber) != 18 {
  38784. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  38785. }
  38786. // 提取出生日期
  38787. year, err := strconv.Atoi(idNumber[6:10])
  38788. if err != nil {
  38789. return "", 0, err
  38790. }
  38791. month, err := strconv.Atoi(idNumber[10:12])
  38792. if err != nil {
  38793. return "", 0, err
  38794. }
  38795. day, err := strconv.Atoi(idNumber[12:14])
  38796. if err != nil {
  38797. return "", 0, err
  38798. }
  38799. // 格式化生日字符串
  38800. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  38801. birthdateFormatted := birthdate.Format("2006-01-02")
  38802. // 计算年龄
  38803. today := time.Now()
  38804. age := today.Year() - birthdate.Year()
  38805. if today.YearDay() < birthdate.YearDay() {
  38806. age--
  38807. }
  38808. return birthdateFormatted, age, nil
  38809. }
  38810. // 从身份证号码中提取出生年月日
  38811. func getBirthDateFromIDCard(idCard string) (string, error) {
  38812. // 身份证号码长度应为18位
  38813. if len(idCard) != 18 {
  38814. return "", fmt.Errorf("身份证号码长度应为18位")
  38815. }
  38816. // 提取出生日期部分 (YYYYMMDD)
  38817. birthDateStr := idCard[6:14]
  38818. // 解析出生日期
  38819. birthDate, err := time.Parse("20060102", birthDateStr)
  38820. if err != nil {
  38821. return "", fmt.Errorf("解析出生日期失败: %v", err)
  38822. }
  38823. // 格式化出生日期为 YYYY-MM-DD
  38824. formattedDate := birthDate.Format("2006-01-02")
  38825. return formattedDate, nil
  38826. }