his_api_controller.go 1.6MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. //"encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. "github.com/go-ole/go-ole"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  42. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  43. //上传就诊信息-上传明细-结算
  44. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  45. //查询
  46. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  47. //对总账
  48. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  49. //对明细
  50. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  51. //退费,退明细
  52. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  53. //退号
  54. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  55. //退明细
  56. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  57. //上传就诊信息-上传明细-预结算
  58. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  59. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  60. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  61. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  62. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  63. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  64. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  65. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  66. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  67. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  68. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  69. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  70. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  71. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  72. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  73. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  74. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  75. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  76. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  81. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  82. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  83. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  84. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  85. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  86. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  87. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  88. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  89. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  90. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  91. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  92. //beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  93. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  94. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  95. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  96. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  97. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  98. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  99. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  100. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  101. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  102. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  103. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. //beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  107. //beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  108. //beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  109. //beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  110. //beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  111. //beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  112. //beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  113. //beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  114. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  115. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  116. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  117. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  118. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  119. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  120. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  121. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  122. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  123. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  124. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  125. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  126. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  127. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  128. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  129. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  130. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  131. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  132. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  133. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  134. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  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/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  170. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  171. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  172. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  173. }
  174. func (c *HisApiController) Get3201() {
  175. adminUser := c.GetAdminUserInfo()
  176. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  177. 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)
  178. var response Response
  179. if err := json.Unmarshal([]byte(result), &response); err != nil {
  180. fmt.Println("Error decoding JSON:", err)
  181. return
  182. }
  183. }
  184. func (c *HisApiController) TestNet() {
  185. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  186. //return
  187. c.ServeSuccessJSON(map[string]interface{}{
  188. "msg": "成功",
  189. })
  190. }
  191. func (c *HisApiController) Get3508() {
  192. admin_user_id, _ := c.GetInt64("admin_user_id")
  193. drug_id, _ := c.GetInt64("id")
  194. start_time := c.GetString("start_time")
  195. end_time := c.GetString("end_time")
  196. adminUser := c.GetAdminUserInfo()
  197. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  199. drug, _ := service.GetDrugByID(drug_id)
  200. var struct3508 models.Struct3508
  201. struct3508.OrgName = miConfig.OrgName
  202. struct3508.FixmedinsCode = miConfig.Code
  203. struct3508.AccessKey = miConfig.AccessKey
  204. struct3508.Opter = curRoles.UserName
  205. struct3508.RequestUrl = miConfig.Url
  206. struct3508.Url = miConfig.Url
  207. struct3508.AppId = miConfig.Cainfo
  208. struct3508.AppSecret = miConfig.AppSecret
  209. struct3508.Enckey = miConfig.EncKey
  210. struct3508.SignKey = miConfig.SignKey
  211. struct3508.SecretKey = miConfig.SecretKey
  212. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  213. struct3508.Begndate = start_time
  214. struct3508.Enddate = end_time
  215. result1, result2, _ := service.FJyb3508(struct3508)
  216. saveLog(result1, result2, "3508", "3508")
  217. var res models.Result3508
  218. var respJSON2 map[string]interface{}
  219. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  222. return
  223. }
  224. userJSONBytes2, _ := json.Marshal(respJSON2)
  225. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  226. utils.ErrorLog("解析失败:%v", err)
  227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  228. return
  229. }
  230. if res.Infcode == -1 {
  231. c.ServeSuccessJSON(map[string]interface{}{
  232. "failed_code": -10,
  233. "msg": res.ErrMsg,
  234. })
  235. } else {
  236. c.ServeSuccessJSON(map[string]interface{}{
  237. "info": res.Output,
  238. })
  239. }
  240. }
  241. func (c *HisApiController) Get3509() {
  242. admin_user_id, _ := c.GetInt64("admin_user_id")
  243. drug_id, _ := c.GetInt64("id")
  244. start_time := c.GetString("start_time")
  245. end_time := c.GetString("end_time")
  246. adminUser := c.GetAdminUserInfo()
  247. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  248. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  249. drug, _ := service.GetDrugByID(drug_id)
  250. var struct3508 models.Struct3509
  251. struct3508.OrgName = miConfig.OrgName
  252. struct3508.FixmedinsCode = miConfig.Code
  253. struct3508.AccessKey = miConfig.AccessKey
  254. struct3508.Opter = curRoles.UserName
  255. struct3508.RequestUrl = miConfig.Url
  256. struct3508.Url = miConfig.Url
  257. struct3508.AppId = miConfig.Cainfo
  258. struct3508.AppSecret = miConfig.AppSecret
  259. struct3508.Enckey = miConfig.EncKey
  260. struct3508.SignKey = miConfig.SignKey
  261. struct3508.SecretKey = miConfig.SecretKey
  262. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  263. struct3508.Begndate = start_time
  264. struct3508.Enddate = end_time
  265. result1, result2, _ := service.FJyb3509(struct3508)
  266. saveLog(result1, result2, "3509", "3509")
  267. var res models.Result3509
  268. var respJSON2 map[string]interface{}
  269. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  272. return
  273. }
  274. userJSONBytes2, _ := json.Marshal(respJSON2)
  275. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  276. utils.ErrorLog("解析失败:%v", err)
  277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  278. return
  279. }
  280. if res.Infcode == -1 {
  281. c.ServeSuccessJSON(map[string]interface{}{
  282. "failed_code": -10,
  283. "msg": res.ErrMsg,
  284. })
  285. } else {
  286. c.ServeSuccessJSON(map[string]interface{}{
  287. "info": res.Output,
  288. })
  289. }
  290. }
  291. func (c *HisApiController) Get3510() {
  292. admin_user_id, _ := c.GetInt64("admin_user_id")
  293. drug_id, _ := c.GetInt64("id")
  294. start_time := c.GetString("start_time")
  295. end_time := c.GetString("end_time")
  296. adminUser := c.GetAdminUserInfo()
  297. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  298. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  299. drug, _ := service.GetDrugByID(drug_id)
  300. var struct3508 models.Struct3510
  301. struct3508.FixmedinsCode = miConfig.Code
  302. struct3508.OrgName = miConfig.OrgName
  303. struct3508.AccessKey = miConfig.AccessKey
  304. struct3508.Opter = curRoles.UserName
  305. struct3508.RequestUrl = miConfig.Url
  306. struct3508.Url = miConfig.Url
  307. struct3508.AppId = miConfig.Cainfo
  308. struct3508.AppSecret = miConfig.AppSecret
  309. struct3508.Enckey = miConfig.EncKey
  310. struct3508.SignKey = miConfig.SignKey
  311. struct3508.SecretKey = miConfig.SecretKey
  312. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  313. struct3508.Begndate = start_time
  314. struct3508.Enddate = end_time
  315. result1, result2, _ := service.FJyb3510(struct3508)
  316. saveLog(result1, result2, "3510", "3510")
  317. var res models.Result3510
  318. var respJSON2 map[string]interface{}
  319. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  322. return
  323. }
  324. userJSONBytes2, _ := json.Marshal(respJSON2)
  325. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  326. utils.ErrorLog("解析失败:%v", err)
  327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  328. return
  329. }
  330. if res.Infcode == -1 {
  331. c.ServeSuccessJSON(map[string]interface{}{
  332. "failed_code": -10,
  333. "msg": res.ErrMsg,
  334. })
  335. } else {
  336. c.ServeSuccessJSON(map[string]interface{}{
  337. "info": res.Output,
  338. })
  339. }
  340. }
  341. func (c *HisApiController) Get3511() {
  342. admin_user_id, _ := c.GetInt64("admin_user_id")
  343. drug_id, _ := c.GetInt64("id")
  344. start_time := c.GetString("start_time")
  345. end_time := c.GetString("end_time")
  346. adminUser := c.GetAdminUserInfo()
  347. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  348. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  349. drug, _ := service.GetDrugByID(drug_id)
  350. var struct3508 models.Struct3511
  351. struct3508.FixmedinsCode = miConfig.Code
  352. struct3508.OrgName = miConfig.OrgName
  353. struct3508.AccessKey = miConfig.AccessKey
  354. struct3508.Opter = curRoles.UserName
  355. struct3508.RequestUrl = miConfig.Url
  356. struct3508.Url = miConfig.Url
  357. struct3508.AppId = miConfig.Cainfo
  358. struct3508.AppSecret = miConfig.AppSecret
  359. struct3508.Enckey = miConfig.EncKey
  360. struct3508.SignKey = miConfig.SignKey
  361. struct3508.SecretKey = miConfig.SecretKey
  362. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  363. struct3508.Begndate = start_time
  364. struct3508.Enddate = end_time
  365. result1, result2, _ := service.FJyb3511(struct3508)
  366. saveLog(result1, result2, "3511", "3511")
  367. var res models.Result3511
  368. var respJSON2 map[string]interface{}
  369. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  372. return
  373. }
  374. userJSONBytes2, _ := json.Marshal(respJSON2)
  375. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  376. utils.ErrorLog("解析失败:%v", err)
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  378. return
  379. }
  380. if res.Infcode == -1 {
  381. c.ServeSuccessJSON(map[string]interface{}{
  382. "failed_code": -10,
  383. "msg": res.ErrMsg,
  384. })
  385. } else {
  386. c.ServeSuccessJSON(map[string]interface{}{
  387. "info": res.Output,
  388. })
  389. }
  390. }
  391. func (c *HisApiController) Get3512() {
  392. admin_user_id, _ := c.GetInt64("admin_user_id")
  393. drug_id, _ := c.GetInt64("id")
  394. start_time := c.GetString("start_time")
  395. end_time := c.GetString("end_time")
  396. adminUser := c.GetAdminUserInfo()
  397. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  398. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  399. drug, _ := service.GetDrugByID(drug_id)
  400. var struct3508 models.Struct3512
  401. struct3508.FixmedinsCode = miConfig.Code
  402. struct3508.OrgName = miConfig.OrgName
  403. struct3508.AccessKey = miConfig.AccessKey
  404. struct3508.Opter = curRoles.UserName
  405. struct3508.RequestUrl = miConfig.Url
  406. struct3508.Url = miConfig.Url
  407. struct3508.AppId = miConfig.Cainfo
  408. struct3508.AppSecret = miConfig.AppSecret
  409. struct3508.Enckey = miConfig.EncKey
  410. struct3508.SignKey = miConfig.SignKey
  411. struct3508.SecretKey = miConfig.SecretKey
  412. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  413. struct3508.Begndate = start_time
  414. struct3508.Enddate = end_time
  415. result1, result2, _ := service.FJyb3512(struct3508)
  416. saveLog(result1, result2, "3512", "3512")
  417. var res models.Result3512
  418. var respJSON2 map[string]interface{}
  419. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  422. return
  423. }
  424. userJSONBytes2, _ := json.Marshal(respJSON2)
  425. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  426. utils.ErrorLog("解析失败:%v", err)
  427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  428. return
  429. }
  430. if res.Infcode == -1 {
  431. c.ServeSuccessJSON(map[string]interface{}{
  432. "failed_code": -10,
  433. "msg": res.ErrMsg,
  434. })
  435. } else {
  436. c.ServeSuccessJSON(map[string]interface{}{
  437. "info": res.Output,
  438. })
  439. }
  440. }
  441. func (c *HisApiController) Get3513() {
  442. admin_user_id, _ := c.GetInt64("admin_user_id")
  443. drug_id, _ := c.GetInt64("id")
  444. start_time := c.GetString("start_time")
  445. end_time := c.GetString("end_time")
  446. adminUser := c.GetAdminUserInfo()
  447. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  448. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  449. drug, _ := service.GetDrugByID(drug_id)
  450. var struct3508 models.Struct3513
  451. struct3508.FixmedinsCode = miConfig.Code
  452. struct3508.OrgName = miConfig.OrgName
  453. struct3508.AccessKey = miConfig.AccessKey
  454. struct3508.Opter = curRoles.UserName
  455. struct3508.RequestUrl = miConfig.Url
  456. struct3508.Url = miConfig.Url
  457. struct3508.AppId = miConfig.Cainfo
  458. struct3508.AppSecret = miConfig.AppSecret
  459. struct3508.Enckey = miConfig.EncKey
  460. struct3508.SignKey = miConfig.SignKey
  461. struct3508.SecretKey = miConfig.SecretKey
  462. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  463. struct3508.Begndate = start_time
  464. struct3508.Enddate = end_time
  465. result1, result2, _ := service.FJyb3513(struct3508)
  466. saveLog(result1, result2, "3513", "3513")
  467. var res models.Result3513
  468. var respJSON2 map[string]interface{}
  469. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  472. return
  473. }
  474. userJSONBytes2, _ := json.Marshal(respJSON2)
  475. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  476. utils.ErrorLog("解析失败:%v", err)
  477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  478. return
  479. }
  480. if res.Infcode == -1 {
  481. c.ServeSuccessJSON(map[string]interface{}{
  482. "failed_code": -10,
  483. "msg": res.ErrMsg,
  484. })
  485. } else {
  486. c.ServeSuccessJSON(map[string]interface{}{
  487. "info": res.Output,
  488. })
  489. }
  490. }
  491. func (c *HisApiController) Get35081() {
  492. admin_user_id, _ := c.GetInt64("admin_user_id")
  493. drug_id, _ := c.GetInt64("id")
  494. //start_time := c.GetString("start_time")
  495. //end_time := c.GetString("end_time")
  496. page, _ := c.GetInt("page")
  497. adminUser := c.GetAdminUserInfo()
  498. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  499. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  500. drug, _ := service.GetDrugByID(drug_id)
  501. var struct3508 models.Struct35081
  502. struct3508.FixmedinsCode = miConfig.Code
  503. struct3508.OrgName = miConfig.OrgName
  504. struct3508.AccessKey = miConfig.AccessKey
  505. struct3508.Opter = curRoles.UserName
  506. struct3508.RequestUrl = miConfig.Url
  507. struct3508.Url = miConfig.Url
  508. struct3508.AppId = miConfig.Cainfo
  509. struct3508.AppSecret = miConfig.AppSecret
  510. struct3508.Enckey = miConfig.EncKey
  511. struct3508.SignKey = miConfig.SignKey
  512. struct3508.SecretKey = miConfig.SecretKey
  513. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  514. struct3508.PageNum = page
  515. struct3508.PageSize = 10
  516. result1, result2, _ := service.FJyb35081(struct3508)
  517. saveLog(result1, result2, "35081", "35081")
  518. var res models.Result35081
  519. var respJSON2 map[string]interface{}
  520. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  523. return
  524. }
  525. userJSONBytes2, _ := json.Marshal(respJSON2)
  526. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  527. utils.ErrorLog("解析失败:%v", err)
  528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  529. return
  530. }
  531. if res.Infcode == -1 {
  532. c.ServeSuccessJSON(map[string]interface{}{
  533. "failed_code": -10,
  534. "msg": res.ErrMsg,
  535. })
  536. } else {
  537. c.ServeSuccessJSON(map[string]interface{}{
  538. "info": res.Output,
  539. })
  540. }
  541. }
  542. func (c *HisApiController) Get35082() {
  543. admin_user_id, _ := c.GetInt64("admin_user_id")
  544. drug_id, _ := c.GetInt64("id")
  545. //start_time := c.GetString("start_time")
  546. //end_time := c.GetString("end_time")
  547. page, _ := c.GetInt("page")
  548. adminUser := c.GetAdminUserInfo()
  549. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  550. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  551. drug, _ := service.GetDrugByID(drug_id)
  552. var struct3508 models.Struct35082
  553. struct3508.FixmedinsCode = miConfig.Code
  554. struct3508.OrgName = miConfig.OrgName
  555. struct3508.AccessKey = miConfig.AccessKey
  556. struct3508.Opter = curRoles.UserName
  557. struct3508.RequestUrl = miConfig.Url
  558. struct3508.Url = miConfig.Url
  559. struct3508.AppId = miConfig.Cainfo
  560. struct3508.AppSecret = miConfig.AppSecret
  561. struct3508.Enckey = miConfig.EncKey
  562. struct3508.SignKey = miConfig.SignKey
  563. struct3508.SecretKey = miConfig.SecretKey
  564. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  565. struct3508.PageNum = page
  566. struct3508.PageSize = 10
  567. result1, result2, _ := service.FJyb35082(struct3508)
  568. saveLog(result1, result2, "35082", "35082")
  569. var res models.Result35082
  570. var respJSON2 map[string]interface{}
  571. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  572. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  574. return
  575. }
  576. userJSONBytes2, _ := json.Marshal(respJSON2)
  577. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  578. utils.ErrorLog("解析失败:%v", err)
  579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  580. return
  581. }
  582. if res.Infcode == -1 {
  583. c.ServeSuccessJSON(map[string]interface{}{
  584. "failed_code": -10,
  585. "msg": res.ErrMsg,
  586. })
  587. } else {
  588. c.ServeSuccessJSON(map[string]interface{}{
  589. "info": res.Output,
  590. })
  591. }
  592. }
  593. func (c *HisApiController) FJ3501AND3502() {
  594. ids := c.GetString("ids")
  595. admin_user_id, _ := c.GetInt64("admin_user_id")
  596. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  597. id_arr := strings.Split(ids, ",")
  598. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  599. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  600. //库盘
  601. var errs []string
  602. for _, drug := range drugs {
  603. if drug.IsPc == 0 {
  604. var res2 ResultSix
  605. var res3 ResultSix
  606. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  607. var struct3501 models.Struct3501
  608. struct3501.Code = miConfig.Code
  609. struct3501.OrgName = miConfig.OrgName
  610. struct3501.AccessKey = miConfig.AccessKey
  611. struct3501.Opter = roles.UserName
  612. struct3501.RequestUrl = miConfig.Url
  613. struct3501.Url = miConfig.Url
  614. struct3501.AppId = miConfig.Cainfo
  615. struct3501.AppSecret = miConfig.AppSecret
  616. struct3501.Enckey = miConfig.EncKey
  617. struct3501.SignKey = miConfig.SignKey
  618. struct3501.SecretKey = miConfig.SecretKey
  619. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  620. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  621. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  622. struct3501.RxFlag = "1"
  623. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  624. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  625. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  626. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  627. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  628. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  629. struct3501.FixmedinsBchno = number
  630. struct3501.DrugTracCodg = drug.DrugCode
  631. memo := make(map[string]interface{})
  632. memo["pric"] = drug.Price
  633. bytesData, _ := json.Marshal(memo)
  634. struct3501.Memo = string(bytesData)
  635. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  636. result1, result2, _ := service.FJyb3501(struct3501)
  637. saveLog(result1, result2, "3501", "3501")
  638. //saveLog(result, requestLog, "2201", "挂号")
  639. var respJSON2 map[string]interface{}
  640. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  643. return
  644. }
  645. userJSONBytes2, _ := json.Marshal(respJSON2)
  646. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  647. utils.ErrorLog("解析失败:%v", err)
  648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  649. return
  650. }
  651. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  652. data := make(map[string]interface{})
  653. data["struct_3501s"] = struct3501
  654. client := &http.Client{}
  655. bytesData, _ := json.Marshal(data)
  656. var req *http.Request
  657. if miConfig.MdtrtareaAdmvs == "320921" {
  658. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  659. } else {
  660. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  661. }
  662. resp, _ := client.Do(req)
  663. defer resp.Body.Close()
  664. body, ioErr := ioutil.ReadAll(resp.Body)
  665. if ioErr != nil {
  666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  667. }
  668. var respJSON map[string]interface{}
  669. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  672. return
  673. }
  674. var resSix10265 ResultSix10265 //1101结果
  675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  676. result, _ := json.Marshal(respJSON)
  677. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  678. utils.ErrorLog("解析失败:%v", err)
  679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  680. return
  681. }
  682. res2.InfRefmsgid = resSix10265.InfRefmsgid
  683. res2.Output = resSix10265.Output
  684. res2.ErrMsg = resSix10265.ErrMsg
  685. res2.Cainfo = resSix10265.Cainfo
  686. res2.WarnMsg = resSix10265.WarnMsg
  687. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  688. res2.Infcode = infocode
  689. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  690. data := make(map[string]interface{})
  691. data["struct_3501s"] = struct3501
  692. client := &http.Client{}
  693. bytesData, _ := json.Marshal(data)
  694. var req *http.Request
  695. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  696. resp, _ := client.Do(req)
  697. defer resp.Body.Close()
  698. body, ioErr := ioutil.ReadAll(resp.Body)
  699. if ioErr != nil {
  700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  701. }
  702. var respJSON map[string]interface{}
  703. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  706. return
  707. }
  708. var resSix10265 ResultSix10265 //1101结果
  709. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  710. result, _ := json.Marshal(respJSON)
  711. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  712. utils.ErrorLog("解析失败:%v", err)
  713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  714. return
  715. }
  716. res2.InfRefmsgid = resSix10265.InfRefmsgid
  717. res2.Output = resSix10265.Output
  718. res2.ErrMsg = resSix10265.ErrMsg
  719. res2.Cainfo = resSix10265.Cainfo
  720. res2.WarnMsg = resSix10265.WarnMsg
  721. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  722. res2.Infcode = infocode
  723. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  724. data := make(map[string]interface{})
  725. data["struct_3501s"] = struct3501
  726. client := &http.Client{}
  727. bytesData, _ := json.Marshal(data)
  728. var req *http.Request
  729. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  730. resp, _ := client.Do(req)
  731. defer resp.Body.Close()
  732. body, ioErr := ioutil.ReadAll(resp.Body)
  733. if ioErr != nil {
  734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  735. }
  736. var respJSON map[string]interface{}
  737. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  740. return
  741. }
  742. var resSix10265 ResultSix10265 //1101结果
  743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  744. result, _ := json.Marshal(respJSON)
  745. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  746. utils.ErrorLog("解析失败:%v", err)
  747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  748. return
  749. }
  750. res2.InfRefmsgid = resSix10265.InfRefmsgid
  751. res2.Output = resSix10265.Output
  752. res2.ErrMsg = resSix10265.ErrMsg
  753. res2.Cainfo = resSix10265.Cainfo
  754. res2.WarnMsg = resSix10265.WarnMsg
  755. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  756. res2.Infcode = infocode
  757. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  758. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  759. saveLog(result1, result2, "3501", "3501")
  760. //saveLog(result, requestLog, "2201", "挂号")
  761. var respJSON2 map[string]interface{}
  762. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. userJSONBytes2, _ := json.Marshal(respJSON2)
  768. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  769. utils.ErrorLog("解析失败:%v", err)
  770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  771. return
  772. }
  773. }
  774. if res2.Infcode != -1 {
  775. drug.IsPc = 1
  776. drug.Bchno = number
  777. drug.PcDate = time.Now().Unix()
  778. err := service.SaveW(drug)
  779. if err == nil {
  780. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  781. var struct3502 models.Struct3502
  782. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  783. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  784. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  785. struct3502.FixmedinsCode = miConfig.Code
  786. struct3502.Code = miConfig.Code
  787. struct3502.RxFlag = "0"
  788. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  789. struct3502.OrgName = miConfig.OrgName
  790. struct3502.Opter = roles.UserName
  791. struct3502.AccessKey = miConfig.AccessKey
  792. struct3502.RequestUrl = miConfig.Url
  793. struct3502.SecretKey = miConfig.SecretKey
  794. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  795. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  796. struct3502.Url = miConfig.Url
  797. struct3502.AppId = miConfig.Cainfo
  798. struct3502.AppSecret = miConfig.AppSecret
  799. struct3502.Enckey = miConfig.EncKey
  800. struct3502.SignKey = miConfig.SignKey
  801. struct3502.SecretKey = miConfig.SecretKey
  802. struct3502.DrugTracCodg = drug.DrugCode
  803. struct3502.Memo = ""
  804. struct3502.InvChgType = "108"
  805. struct3502.FixmedinsBchno = bg_number
  806. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  807. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  808. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  809. result11, result22, _ := service.FJyb3502(struct3502)
  810. saveLog(result11, result22, "3502", "3502")
  811. var respJSON3 map[string]interface{}
  812. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  815. return
  816. }
  817. userJSONBytes3, _ := json.Marshal(respJSON3)
  818. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  819. utils.ErrorLog("解析失败:%v", err)
  820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  821. return
  822. }
  823. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  824. data := make(map[string]interface{})
  825. data["struct_3502s"] = struct3502
  826. client := &http.Client{}
  827. bytesData, _ := json.Marshal(data)
  828. var req *http.Request
  829. if miConfig.MdtrtareaAdmvs == "320921" {
  830. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  831. } else {
  832. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  833. }
  834. resp, _ := client.Do(req)
  835. defer resp.Body.Close()
  836. body, ioErr := ioutil.ReadAll(resp.Body)
  837. if ioErr != nil {
  838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  839. }
  840. var respJSON map[string]interface{}
  841. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  844. return
  845. }
  846. var resSix10265 ResultSix10265 //1101结果
  847. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  848. result, _ := json.Marshal(respJSON)
  849. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  850. utils.ErrorLog("解析失败:%v", err)
  851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  852. return
  853. }
  854. res3.InfRefmsgid = resSix10265.InfRefmsgid
  855. res3.Output = resSix10265.Output
  856. res3.ErrMsg = resSix10265.ErrMsg
  857. res3.Cainfo = resSix10265.Cainfo
  858. res3.WarnMsg = resSix10265.WarnMsg
  859. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  860. res3.Infcode = infocode
  861. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  862. data := make(map[string]interface{})
  863. data["struct_3502s"] = struct3502
  864. client := &http.Client{}
  865. bytesData, _ := json.Marshal(data)
  866. var req *http.Request
  867. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  868. resp, _ := client.Do(req)
  869. defer resp.Body.Close()
  870. body, ioErr := ioutil.ReadAll(resp.Body)
  871. if ioErr != nil {
  872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  873. }
  874. var respJSON map[string]interface{}
  875. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  878. return
  879. }
  880. var resSix10265 ResultSix10265 //1101结果
  881. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  882. result, _ := json.Marshal(respJSON)
  883. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  884. utils.ErrorLog("解析失败:%v", err)
  885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  886. return
  887. }
  888. res3.InfRefmsgid = resSix10265.InfRefmsgid
  889. res3.Output = resSix10265.Output
  890. res3.ErrMsg = resSix10265.ErrMsg
  891. res3.Cainfo = resSix10265.Cainfo
  892. res3.WarnMsg = resSix10265.WarnMsg
  893. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  894. res3.Infcode = infocode
  895. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  896. data := make(map[string]interface{})
  897. data["struct_3501s"] = struct3501
  898. client := &http.Client{}
  899. bytesData, _ := json.Marshal(data)
  900. var req *http.Request
  901. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  902. resp, _ := client.Do(req)
  903. defer resp.Body.Close()
  904. body, ioErr := ioutil.ReadAll(resp.Body)
  905. if ioErr != nil {
  906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  907. }
  908. var respJSON map[string]interface{}
  909. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  912. return
  913. }
  914. var resSix10265 ResultSix10265 //1101结果
  915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  916. result, _ := json.Marshal(respJSON)
  917. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  918. utils.ErrorLog("解析失败:%v", err)
  919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  920. return
  921. }
  922. res2.InfRefmsgid = resSix10265.InfRefmsgid
  923. res2.Output = resSix10265.Output
  924. res2.ErrMsg = resSix10265.ErrMsg
  925. res2.Cainfo = resSix10265.Cainfo
  926. res2.WarnMsg = resSix10265.WarnMsg
  927. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  928. res2.Infcode = infocode
  929. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  930. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  931. saveLog(result11, result22, "3502", "3502")
  932. var respJSON3 map[string]interface{}
  933. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  936. return
  937. }
  938. userJSONBytes3, _ := json.Marshal(respJSON3)
  939. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  940. utils.ErrorLog("解析失败:%v", err)
  941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  942. return
  943. }
  944. }
  945. if res3.Infcode == -1 {
  946. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  947. c.ServeSuccessJSON(map[string]interface{}{
  948. "failed_code": -10,
  949. "msg": res3.ErrMsg,
  950. })
  951. } else {
  952. drug.IsBg = 1
  953. drug.BgBchno = bg_number
  954. service.SaveW(drug)
  955. }
  956. }
  957. } else {
  958. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  959. }
  960. }
  961. //变更
  962. }
  963. if len(errs) == 0 {
  964. c.ServeSuccessJSON(map[string]interface{}{
  965. "msg": "盘存变更成功",
  966. })
  967. } else {
  968. c.ServeSuccessJSON(map[string]interface{}{
  969. "failed_code": -10,
  970. "msg": errs,
  971. })
  972. }
  973. }
  974. func (c *HisApiController) DeletePCandBG() {
  975. ids := c.GetString("ids")
  976. id_arr := strings.Split(ids, ",")
  977. admin_user_id, _ := c.GetInt64("admin_user_id")
  978. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  979. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  980. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  981. var err []string
  982. for _, item := range drugs {
  983. if item.IsPc == 1 && item.IsBg == 1 {
  984. var res FJ3507Result
  985. var res2 FJ3507Result
  986. var struct3507 models.Struct3507
  987. struct3507.FixmedinsBchno = item.Bchno
  988. struct3507.InvDataType = "1"
  989. struct3507.Opter = roles.UserName
  990. struct3507.OrgName = miConfig.OrgName
  991. struct3507.AccessKey = miConfig.AccessKey
  992. struct3507.RequestUrl = miConfig.Url
  993. struct3507.FixmedinsCode = miConfig.Code
  994. struct3507.Code = miConfig.Code
  995. struct3507.SecretKey = miConfig.SecretKey
  996. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  997. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  998. struct3507.Url = miConfig.Url
  999. struct3507.AppId = miConfig.Cainfo
  1000. struct3507.AppSecret = miConfig.AppSecret
  1001. struct3507.Enckey = miConfig.EncKey
  1002. struct3507.SignKey = miConfig.SignKey
  1003. struct3507.SecretKey = miConfig.SecretKey
  1004. if miConfig.MdtrtareaAdmvs == "350500" {
  1005. result, result1, _ := service.FJyb3507(struct3507)
  1006. saveLog(result, result1, "3507", "3507")
  1007. var respJSON2 map[string]interface{}
  1008. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1011. return
  1012. }
  1013. userJSONBytes2, _ := json.Marshal(respJSON2)
  1014. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1015. utils.ErrorLog("解析失败:%v", err)
  1016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1017. return
  1018. }
  1019. } else {
  1020. data := make(map[string]interface{})
  1021. data["struct_3507s"] = struct3507
  1022. client := &http.Client{}
  1023. bytesData, _ := json.Marshal(data)
  1024. var req *http.Request
  1025. if miConfig.MdtrtareaAdmvs == "320921" {
  1026. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1027. } else {
  1028. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1029. }
  1030. resp, _ := client.Do(req)
  1031. defer resp.Body.Close()
  1032. body, ioErr := ioutil.ReadAll(resp.Body)
  1033. if ioErr != nil {
  1034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1035. }
  1036. var respJSON map[string]interface{}
  1037. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1040. return
  1041. }
  1042. var resSix10265 ResultSix10265 //1101结果
  1043. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1044. result, _ := json.Marshal(respJSON)
  1045. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1046. utils.ErrorLog("解析失败:%v", err)
  1047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1048. return
  1049. }
  1050. res.InfRefmsgid = resSix10265.InfRefmsgid
  1051. //res.Output = resSix10265.Output
  1052. res.ErrMsg = resSix10265.ErrMsg
  1053. res.Cainfo = resSix10265.Cainfo
  1054. res.WarnMsg = resSix10265.WarnMsg
  1055. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1056. res.Infcode = infocode
  1057. }
  1058. if res.Infcode == 0 {
  1059. item.IsPc = 0
  1060. err2 := service.SaveW(item)
  1061. if err2 == nil {
  1062. var struct3507_2 models.Struct3507
  1063. struct3507_2.OrgName = miConfig.OrgName
  1064. struct3507_2.AccessKey = miConfig.AccessKey
  1065. struct3507_2.RequestUrl = miConfig.Url
  1066. struct3507_2.Opter = roles.UserName
  1067. struct3507_2.FixmedinsCode = miConfig.Code
  1068. struct3507_2.Code = miConfig.Code
  1069. struct3507_2.SecretKey = miConfig.SecretKey
  1070. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1071. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1072. struct3507_2.Url = miConfig.Url
  1073. struct3507_2.AppId = miConfig.Cainfo
  1074. struct3507_2.AppSecret = miConfig.AppSecret
  1075. struct3507_2.Enckey = miConfig.EncKey
  1076. struct3507_2.SignKey = miConfig.SignKey
  1077. struct3507_2.SecretKey = miConfig.SecretKey
  1078. struct3507_2.FixmedinsBchno = item.BgBchno
  1079. struct3507_2.InvDataType = "2"
  1080. if miConfig.MdtrtareaAdmvs == "350500" {
  1081. result11, result22, _ := service.FJyb3507(struct3507_2)
  1082. saveLog(result11, result22, "3507", "3507")
  1083. var respJSON3 map[string]interface{}
  1084. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1087. return
  1088. }
  1089. userJSONBytes3, _ := json.Marshal(respJSON3)
  1090. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1091. utils.ErrorLog("解析失败:%v", err)
  1092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1093. return
  1094. }
  1095. } else {
  1096. data := make(map[string]interface{})
  1097. data["struct_3507s"] = struct3507_2
  1098. client := &http.Client{}
  1099. bytesData, _ := json.Marshal(data)
  1100. var req *http.Request
  1101. if miConfig.MdtrtareaAdmvs == "320921" {
  1102. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1103. } else {
  1104. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1105. }
  1106. resp, _ := client.Do(req)
  1107. defer resp.Body.Close()
  1108. body, ioErr := ioutil.ReadAll(resp.Body)
  1109. if ioErr != nil {
  1110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1111. }
  1112. var respJSON map[string]interface{}
  1113. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1116. return
  1117. }
  1118. var resSix10265 ResultSix10265 //1101结果
  1119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1120. result, _ := json.Marshal(respJSON)
  1121. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1122. utils.ErrorLog("解析失败:%v", err)
  1123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1124. return
  1125. }
  1126. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1127. //res2.Output = resSix10265.Output
  1128. res2.ErrMsg = resSix10265.ErrMsg
  1129. res2.Cainfo = resSix10265.Cainfo
  1130. res2.WarnMsg = resSix10265.WarnMsg
  1131. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1132. res2.Infcode = infocode
  1133. }
  1134. if res2.Infcode != -1 {
  1135. item.IsBg = 0
  1136. item.Bchno = ""
  1137. item.BgBchno = ""
  1138. item.PcDate = 0
  1139. service.SaveW(item)
  1140. } else {
  1141. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1142. }
  1143. }
  1144. } else {
  1145. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1146. }
  1147. }
  1148. if item.IsPc == 1 && item.IsBg == 0 {
  1149. var res FJ3507Result
  1150. var struct3507 models.Struct3507
  1151. struct3507.FixmedinsBchno = item.Bchno
  1152. struct3507.InvDataType = "1"
  1153. struct3507.Opter = roles.UserName
  1154. struct3507.FixmedinsCode = miConfig.Code
  1155. struct3507.Code = miConfig.Code
  1156. struct3507.OrgName = miConfig.OrgName
  1157. struct3507.AccessKey = miConfig.AccessKey
  1158. struct3507.RequestUrl = miConfig.Url
  1159. struct3507.SecretKey = miConfig.SecretKey
  1160. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1161. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1162. struct3507.Url = miConfig.Url
  1163. struct3507.AppId = miConfig.Cainfo
  1164. struct3507.AppSecret = miConfig.AppSecret
  1165. struct3507.Enckey = miConfig.EncKey
  1166. struct3507.SignKey = miConfig.SignKey
  1167. struct3507.SecretKey = miConfig.SecretKey
  1168. //result, result1, _ := service.FJyb3507(struct3507)
  1169. //saveLog(result, result1, "3507", "3507")
  1170. if miConfig.MdtrtareaAdmvs == "350500" {
  1171. result, result1, _ := service.FJyb3507(struct3507)
  1172. saveLog(result, result1, "3507", "3507")
  1173. var respJSON2 map[string]interface{}
  1174. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1177. return
  1178. }
  1179. userJSONBytes2, _ := json.Marshal(respJSON2)
  1180. if err := json.Unmarshal(userJSONBytes2, &res); 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
  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. res.InfRefmsgid = resSix10265.InfRefmsgid
  1217. //res.Output = resSix10265.Output
  1218. res.ErrMsg = resSix10265.ErrMsg
  1219. res.Cainfo = resSix10265.Cainfo
  1220. res.WarnMsg = resSix10265.WarnMsg
  1221. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1222. res.Infcode = infocode
  1223. }
  1224. if res.Infcode == 0 {
  1225. item.IsPc = 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. if item.IsPc == 0 && item.IsBg == 1 {
  1235. var res FJ3507Result
  1236. var struct3507 models.Struct3507
  1237. struct3507.FixmedinsBchno = item.BgBchno
  1238. struct3507.InvDataType = "2"
  1239. struct3507.Opter = roles.UserName
  1240. struct3507.FixmedinsCode = miConfig.Code
  1241. struct3507.OrgName = miConfig.OrgName
  1242. struct3507.AccessKey = miConfig.AccessKey
  1243. struct3507.RequestUrl = miConfig.Url
  1244. struct3507.SecretKey = miConfig.SecretKey
  1245. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1246. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1247. struct3507.Url = miConfig.Url
  1248. struct3507.AppId = miConfig.Cainfo
  1249. struct3507.AppSecret = miConfig.AppSecret
  1250. struct3507.Enckey = miConfig.EncKey
  1251. struct3507.SignKey = miConfig.SignKey
  1252. struct3507.SecretKey = miConfig.SecretKey
  1253. //result, result1, _ := service.FJyb3507(struct3507)
  1254. //saveLog(result, result1, "3507", "3507")
  1255. if miConfig.MdtrtareaAdmvs == "350500" {
  1256. result, result1, _ := service.FJyb3507(struct3507)
  1257. saveLog(result, result1, "3507", "3507")
  1258. var respJSON2 map[string]interface{}
  1259. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1262. return
  1263. }
  1264. userJSONBytes2, _ := json.Marshal(respJSON2)
  1265. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1266. utils.ErrorLog("解析失败:%v", err)
  1267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1268. return
  1269. }
  1270. } else {
  1271. data := make(map[string]interface{})
  1272. data["struct_3507s"] = struct3507
  1273. client := &http.Client{}
  1274. bytesData, _ := json.Marshal(data)
  1275. var req *http.Request
  1276. if miConfig.MdtrtareaAdmvs == "320921" {
  1277. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1278. } else {
  1279. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1280. }
  1281. resp, _ := client.Do(req)
  1282. defer resp.Body.Close()
  1283. body, ioErr := ioutil.ReadAll(resp.Body)
  1284. if ioErr != nil {
  1285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1286. }
  1287. var respJSON map[string]interface{}
  1288. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1291. return
  1292. }
  1293. var resSix10265 ResultSix10265 //1101结果
  1294. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1295. result, _ := json.Marshal(respJSON)
  1296. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1297. utils.ErrorLog("解析失败:%v", err)
  1298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1299. return
  1300. }
  1301. res.InfRefmsgid = resSix10265.InfRefmsgid
  1302. //res.Output = resSix10265.Output
  1303. res.ErrMsg = resSix10265.ErrMsg
  1304. res.Cainfo = resSix10265.Cainfo
  1305. res.WarnMsg = resSix10265.WarnMsg
  1306. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1307. res.Infcode = infocode
  1308. }
  1309. if res.Infcode == 0 {
  1310. item.IsBg = 0
  1311. item.Bchno = ""
  1312. item.BgBchno = ""
  1313. item.PcDate = 0
  1314. service.SaveW(item)
  1315. } else {
  1316. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1317. }
  1318. }
  1319. }
  1320. if len(err) == 0 {
  1321. c.ServeSuccessJSON(map[string]interface{}{
  1322. "msg": "删除盘存变更成功",
  1323. })
  1324. } else {
  1325. c.ServeSuccessJSON(map[string]interface{}{
  1326. "failed_code": -10,
  1327. "msg": err,
  1328. })
  1329. }
  1330. }
  1331. func (c *HisApiController) DeleteXSandBG() {
  1332. ids := c.GetString("ids")
  1333. id_arr := strings.Split(ids, ",")
  1334. admin_user_id, _ := c.GetInt64("admin_user_id")
  1335. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1336. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1337. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1338. var err []string
  1339. for _, item := range flows {
  1340. if item.IsSale == 1 && item.IsChange == 1 {
  1341. var res FJ3507Result
  1342. var res2 FJ3507Result
  1343. var struct3507 models.Struct3507
  1344. struct3507.FixmedinsBchno = item.Bchno
  1345. struct3507.InvDataType = "4"
  1346. struct3507.Opter = roles.UserName
  1347. struct3507.OrgName = miConfig.OrgName
  1348. struct3507.AccessKey = miConfig.AccessKey
  1349. struct3507.RequestUrl = miConfig.Url
  1350. struct3507.FixmedinsCode = miConfig.Code
  1351. struct3507.SecretKey = miConfig.SecretKey
  1352. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1353. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1354. struct3507.Url = miConfig.Url
  1355. struct3507.AppId = miConfig.Cainfo
  1356. struct3507.AppSecret = miConfig.AppSecret
  1357. struct3507.Enckey = miConfig.EncKey
  1358. struct3507.SignKey = miConfig.SignKey
  1359. struct3507.SecretKey = miConfig.SecretKey
  1360. //result, result1, _ := service.FJyb3507(struct3507)
  1361. //saveLog(result, result1, "3507", "3507")
  1362. if miConfig.MdtrtareaAdmvs == "350500" {
  1363. result, result1, _ := service.FJyb3507(struct3507)
  1364. saveLog(result, result1, "3507", "3507")
  1365. var respJSON2 map[string]interface{}
  1366. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1369. return
  1370. }
  1371. userJSONBytes2, _ := json.Marshal(respJSON2)
  1372. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1373. utils.ErrorLog("解析失败:%v", err)
  1374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1375. return
  1376. }
  1377. } else {
  1378. data := make(map[string]interface{})
  1379. data["struct_3507s"] = struct3507
  1380. client := &http.Client{}
  1381. bytesData, _ := json.Marshal(data)
  1382. var req *http.Request
  1383. if miConfig.MdtrtareaAdmvs == "320921" {
  1384. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1385. } else {
  1386. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1387. }
  1388. resp, _ := client.Do(req)
  1389. defer resp.Body.Close()
  1390. body, ioErr := ioutil.ReadAll(resp.Body)
  1391. if ioErr != nil {
  1392. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1393. }
  1394. var respJSON map[string]interface{}
  1395. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1398. return
  1399. }
  1400. var resSix10265 ResultSix10265 //1101结果
  1401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1402. result, _ := json.Marshal(respJSON)
  1403. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1404. utils.ErrorLog("解析失败:%v", err)
  1405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1406. return
  1407. }
  1408. res.InfRefmsgid = resSix10265.InfRefmsgid
  1409. //res.Output = resSix10265.Output
  1410. res.ErrMsg = resSix10265.ErrMsg
  1411. res.Cainfo = resSix10265.Cainfo
  1412. res.WarnMsg = resSix10265.WarnMsg
  1413. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1414. res.Infcode = infocode
  1415. }
  1416. if res.Infcode == 0 {
  1417. item.IsSale = 0
  1418. item.SaleDate = ""
  1419. item.Bchno = ""
  1420. err2 := service.SaveDF(item)
  1421. if err2 == nil {
  1422. var struct3507_2 models.Struct3507
  1423. struct3507_2.OrgName = miConfig.OrgName
  1424. struct3507_2.AccessKey = miConfig.AccessKey
  1425. struct3507_2.RequestUrl = miConfig.Url
  1426. struct3507_2.Opter = roles.UserName
  1427. struct3507_2.FixmedinsCode = miConfig.Code
  1428. struct3507_2.Code = miConfig.Code
  1429. struct3507_2.SecretKey = miConfig.SecretKey
  1430. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1431. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1432. struct3507_2.Url = miConfig.Url
  1433. struct3507_2.AppId = miConfig.Cainfo
  1434. struct3507_2.AppSecret = miConfig.AppSecret
  1435. struct3507_2.Enckey = miConfig.EncKey
  1436. struct3507_2.SignKey = miConfig.SignKey
  1437. struct3507_2.SecretKey = miConfig.SecretKey
  1438. struct3507_2.FixmedinsBchno = item.BgBchno
  1439. struct3507_2.InvDataType = "2"
  1440. if miConfig.MdtrtareaAdmvs == "350500" {
  1441. result11, result22, _ := service.FJyb3507(struct3507_2)
  1442. saveLog(result11, result22, "3507", "3507")
  1443. var respJSON3 map[string]interface{}
  1444. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. return
  1448. }
  1449. userJSONBytes3, _ := json.Marshal(respJSON3)
  1450. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1451. utils.ErrorLog("解析失败:%v", err)
  1452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1453. return
  1454. }
  1455. } else {
  1456. data := make(map[string]interface{})
  1457. data["struct_3507s"] = struct3507_2
  1458. client := &http.Client{}
  1459. bytesData, _ := json.Marshal(data)
  1460. var req *http.Request
  1461. if miConfig.MdtrtareaAdmvs == "320921" {
  1462. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1463. } else {
  1464. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1465. }
  1466. resp, _ := client.Do(req)
  1467. defer resp.Body.Close()
  1468. body, ioErr := ioutil.ReadAll(resp.Body)
  1469. if ioErr != nil {
  1470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1471. }
  1472. var respJSON map[string]interface{}
  1473. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1476. return
  1477. }
  1478. var resSix10265 ResultSix10265 //1101结果
  1479. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1480. result, _ := json.Marshal(respJSON)
  1481. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1482. utils.ErrorLog("解析失败:%v", err)
  1483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1484. return
  1485. }
  1486. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1487. //res.Output = resSix10265.Output
  1488. res2.ErrMsg = resSix10265.ErrMsg
  1489. res2.Cainfo = resSix10265.Cainfo
  1490. res2.WarnMsg = resSix10265.WarnMsg
  1491. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1492. res2.Infcode = infocode
  1493. }
  1494. if res2.Infcode == 0 {
  1495. item.IsChange = 0
  1496. item.BgBchno = ""
  1497. service.SaveDF2(item)
  1498. } else {
  1499. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1500. }
  1501. }
  1502. } else {
  1503. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1504. }
  1505. }
  1506. if item.IsSale == 2 && item.IsChange == 1 {
  1507. var res FJ3507Result
  1508. var res2 FJ3507Result
  1509. var struct3507 models.Struct3507
  1510. struct3507.FixmedinsBchno = item.Bchno
  1511. struct3507.InvDataType = "4"
  1512. struct3507.Opter = roles.UserName
  1513. struct3507.OrgName = miConfig.OrgName
  1514. struct3507.AccessKey = miConfig.AccessKey
  1515. struct3507.RequestUrl = miConfig.Url
  1516. struct3507.FixmedinsCode = miConfig.Code
  1517. struct3507.Code = miConfig.Code
  1518. struct3507.SecretKey = miConfig.SecretKey
  1519. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1520. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1521. struct3507.Url = miConfig.Url
  1522. struct3507.AppId = miConfig.Cainfo
  1523. struct3507.AppSecret = miConfig.AppSecret
  1524. struct3507.Enckey = miConfig.EncKey
  1525. struct3507.SignKey = miConfig.SignKey
  1526. struct3507.SecretKey = miConfig.SecretKey
  1527. //result, result1, _ := service.FJyb3507(struct3507)
  1528. //saveLog(result, result1, "3507", "3507")
  1529. //
  1530. //var respJSON2 map[string]interface{}
  1531. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1532. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1534. // return
  1535. //}
  1536. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1537. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1538. // utils.ErrorLog("解析失败:%v", err)
  1539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1540. // return
  1541. //}
  1542. if miConfig.MdtrtareaAdmvs == "350500" {
  1543. result, result1, _ := service.FJyb3507(struct3507)
  1544. saveLog(result, result1, "3507", "3507")
  1545. var respJSON2 map[string]interface{}
  1546. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1549. return
  1550. }
  1551. userJSONBytes2, _ := json.Marshal(respJSON2)
  1552. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1553. utils.ErrorLog("解析失败:%v", err)
  1554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1555. return
  1556. }
  1557. } else {
  1558. data := make(map[string]interface{})
  1559. data["struct_3507s"] = struct3507
  1560. client := &http.Client{}
  1561. bytesData, _ := json.Marshal(data)
  1562. var req *http.Request
  1563. if miConfig.MdtrtareaAdmvs == "320921" {
  1564. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1565. } else {
  1566. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1567. }
  1568. resp, _ := client.Do(req)
  1569. defer resp.Body.Close()
  1570. body, ioErr := ioutil.ReadAll(resp.Body)
  1571. if ioErr != nil {
  1572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1573. }
  1574. var respJSON map[string]interface{}
  1575. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1578. return
  1579. }
  1580. var resSix10265 ResultSix10265 //1101结果
  1581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1582. result, _ := json.Marshal(respJSON)
  1583. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1584. utils.ErrorLog("解析失败:%v", err)
  1585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1586. return
  1587. }
  1588. res.InfRefmsgid = resSix10265.InfRefmsgid
  1589. //res.Output = resSix10265.Output
  1590. res.ErrMsg = resSix10265.ErrMsg
  1591. res.Cainfo = resSix10265.Cainfo
  1592. res.WarnMsg = resSix10265.WarnMsg
  1593. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1594. res.Infcode = infocode
  1595. }
  1596. if res.Infcode == 0 {
  1597. item.IsSale = 0
  1598. item.SaleDate = ""
  1599. item.Bchno = ""
  1600. err2 := service.SaveDF(item)
  1601. if err2 == nil {
  1602. var struct3507_2 models.Struct3507
  1603. struct3507_2.OrgName = miConfig.OrgName
  1604. struct3507_2.AccessKey = miConfig.AccessKey
  1605. struct3507_2.RequestUrl = miConfig.Url
  1606. struct3507_2.Opter = roles.UserName
  1607. struct3507_2.FixmedinsCode = miConfig.Code
  1608. struct3507_2.Code = miConfig.Code
  1609. struct3507_2.SecretKey = miConfig.SecretKey
  1610. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1611. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1612. struct3507_2.Url = miConfig.Url
  1613. struct3507_2.AppId = miConfig.Cainfo
  1614. struct3507_2.AppSecret = miConfig.AppSecret
  1615. struct3507_2.Enckey = miConfig.EncKey
  1616. struct3507_2.SignKey = miConfig.SignKey
  1617. struct3507_2.SecretKey = miConfig.SecretKey
  1618. struct3507_2.FixmedinsBchno = item.BgBchno
  1619. struct3507_2.InvDataType = "2"
  1620. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1621. //saveLog(result11, result22, "3507", "3507")
  1622. //var respJSON3 map[string]interface{}
  1623. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1624. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1625. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1626. // return
  1627. //}
  1628. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1629. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1630. // utils.ErrorLog("解析失败:%v", err)
  1631. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1632. // return
  1633. //}
  1634. if miConfig.MdtrtareaAdmvs == "350500" {
  1635. result11, result22, _ := service.FJyb3507(struct3507_2)
  1636. saveLog(result11, result22, "3507", "3507")
  1637. var respJSON3 map[string]interface{}
  1638. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1641. return
  1642. }
  1643. userJSONBytes3, _ := json.Marshal(respJSON3)
  1644. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1645. utils.ErrorLog("解析失败:%v", err)
  1646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1647. return
  1648. }
  1649. } else {
  1650. data := make(map[string]interface{})
  1651. data["struct_3507s"] = struct3507_2
  1652. client := &http.Client{}
  1653. bytesData, _ := json.Marshal(data)
  1654. var req *http.Request
  1655. if miConfig.MdtrtareaAdmvs == "320921" {
  1656. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1657. } else {
  1658. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1659. }
  1660. resp, _ := client.Do(req)
  1661. defer resp.Body.Close()
  1662. body, ioErr := ioutil.ReadAll(resp.Body)
  1663. if ioErr != nil {
  1664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1665. }
  1666. var respJSON map[string]interface{}
  1667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1670. return
  1671. }
  1672. var resSix10265 ResultSix10265 //1101结果
  1673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1674. result, _ := json.Marshal(respJSON)
  1675. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1676. utils.ErrorLog("解析失败:%v", err)
  1677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1678. return
  1679. }
  1680. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1681. //res.Output = resSix10265.Output
  1682. res2.ErrMsg = resSix10265.ErrMsg
  1683. res2.Cainfo = resSix10265.Cainfo
  1684. res2.WarnMsg = resSix10265.WarnMsg
  1685. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1686. res2.Infcode = infocode
  1687. }
  1688. if res2.Infcode == 0 {
  1689. item.IsChange = 0
  1690. item.BgBchno = ""
  1691. service.SaveDF2(item)
  1692. } else {
  1693. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1694. }
  1695. }
  1696. } else {
  1697. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1698. }
  1699. }
  1700. if item.IsSale == 1 && item.IsChange == 0 {
  1701. var res FJ3507Result
  1702. var struct3507 models.Struct3507
  1703. struct3507.FixmedinsBchno = item.Bchno
  1704. struct3507.InvDataType = "4"
  1705. struct3507.Opter = roles.UserName
  1706. struct3507.FixmedinsCode = miConfig.Code
  1707. struct3507.Code = miConfig.Code
  1708. struct3507.OrgName = miConfig.OrgName
  1709. struct3507.AccessKey = miConfig.AccessKey
  1710. struct3507.RequestUrl = miConfig.Url
  1711. struct3507.SecretKey = miConfig.SecretKey
  1712. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1713. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1714. struct3507.Url = miConfig.Url
  1715. struct3507.AppId = miConfig.Cainfo
  1716. struct3507.AppSecret = miConfig.AppSecret
  1717. struct3507.Enckey = miConfig.EncKey
  1718. struct3507.SignKey = miConfig.SignKey
  1719. struct3507.SecretKey = miConfig.SecretKey
  1720. //result, result1, _ := service.FJyb3507(struct3507)
  1721. //saveLog(result, result1, "3507", "3507")
  1722. //
  1723. //var respJSON3 map[string]interface{}
  1724. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1725. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1727. // return
  1728. //}
  1729. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1730. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1731. // utils.ErrorLog("解析失败:%v", err)
  1732. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1733. // return
  1734. //}
  1735. if miConfig.MdtrtareaAdmvs == "350500" {
  1736. result, result1, _ := service.FJyb3507(struct3507)
  1737. saveLog(result, result1, "3507", "3507")
  1738. var respJSON2 map[string]interface{}
  1739. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1742. return
  1743. }
  1744. userJSONBytes2, _ := json.Marshal(respJSON2)
  1745. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1746. utils.ErrorLog("解析失败:%v", err)
  1747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1748. return
  1749. }
  1750. } else {
  1751. data := make(map[string]interface{})
  1752. data["struct_3507s"] = struct3507
  1753. client := &http.Client{}
  1754. bytesData, _ := json.Marshal(data)
  1755. var req *http.Request
  1756. if miConfig.MdtrtareaAdmvs == "320921" {
  1757. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1758. } else {
  1759. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1760. }
  1761. resp, _ := client.Do(req)
  1762. defer resp.Body.Close()
  1763. body, ioErr := ioutil.ReadAll(resp.Body)
  1764. if ioErr != nil {
  1765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1766. }
  1767. var respJSON map[string]interface{}
  1768. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1771. return
  1772. }
  1773. var resSix10265 ResultSix10265 //1101结果
  1774. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1775. result, _ := json.Marshal(respJSON)
  1776. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1777. utils.ErrorLog("解析失败:%v", err)
  1778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1779. return
  1780. }
  1781. res.InfRefmsgid = resSix10265.InfRefmsgid
  1782. //res.Output = resSix10265.Output
  1783. res.ErrMsg = resSix10265.ErrMsg
  1784. res.Cainfo = resSix10265.Cainfo
  1785. res.WarnMsg = resSix10265.WarnMsg
  1786. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1787. res.Infcode = infocode
  1788. }
  1789. if res.Infcode == 0 {
  1790. item.IsSale = 0
  1791. item.SaleDate = ""
  1792. service.SaveDF(item)
  1793. } else {
  1794. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1795. }
  1796. }
  1797. if item.IsSale == 2 && item.IsChange == 0 {
  1798. var res FJ3507Result
  1799. var struct3507 models.Struct3507
  1800. struct3507.FixmedinsBchno = item.Bchno
  1801. struct3507.InvDataType = "4"
  1802. struct3507.Opter = roles.UserName
  1803. struct3507.FixmedinsCode = miConfig.Code
  1804. struct3507.Code = miConfig.Code
  1805. struct3507.OrgName = miConfig.OrgName
  1806. struct3507.AccessKey = miConfig.AccessKey
  1807. struct3507.RequestUrl = miConfig.Url
  1808. struct3507.SecretKey = miConfig.SecretKey
  1809. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1810. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1811. struct3507.Url = miConfig.Url
  1812. struct3507.AppId = miConfig.Cainfo
  1813. struct3507.AppSecret = miConfig.AppSecret
  1814. struct3507.Enckey = miConfig.EncKey
  1815. struct3507.SignKey = miConfig.SignKey
  1816. struct3507.SecretKey = miConfig.SecretKey
  1817. //result, result1, _ := service.FJyb3507(struct3507)
  1818. //saveLog(result, result1, "3507", "3507")
  1819. //
  1820. //var respJSON3 map[string]interface{}
  1821. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1822. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1824. // return
  1825. //}
  1826. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1827. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1828. // utils.ErrorLog("解析失败:%v", err)
  1829. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1830. // return
  1831. //}
  1832. if miConfig.MdtrtareaAdmvs == "350500" {
  1833. result, result1, _ := service.FJyb3507(struct3507)
  1834. saveLog(result, result1, "3507", "3507")
  1835. var respJSON2 map[string]interface{}
  1836. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1839. return
  1840. }
  1841. userJSONBytes2, _ := json.Marshal(respJSON2)
  1842. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1843. utils.ErrorLog("解析失败:%v", err)
  1844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1845. return
  1846. }
  1847. } else {
  1848. data := make(map[string]interface{})
  1849. data["struct_3507s"] = struct3507
  1850. client := &http.Client{}
  1851. bytesData, _ := json.Marshal(data)
  1852. var req *http.Request
  1853. if miConfig.MdtrtareaAdmvs == "320921" {
  1854. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1855. } else {
  1856. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1857. }
  1858. resp, _ := client.Do(req)
  1859. defer resp.Body.Close()
  1860. body, ioErr := ioutil.ReadAll(resp.Body)
  1861. if ioErr != nil {
  1862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1863. }
  1864. var respJSON map[string]interface{}
  1865. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1868. return
  1869. }
  1870. var resSix10265 ResultSix10265 //1101结果
  1871. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1872. result, _ := json.Marshal(respJSON)
  1873. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1874. utils.ErrorLog("解析失败:%v", err)
  1875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1876. return
  1877. }
  1878. res.InfRefmsgid = resSix10265.InfRefmsgid
  1879. //res.Output = resSix10265.Output
  1880. res.ErrMsg = resSix10265.ErrMsg
  1881. res.Cainfo = resSix10265.Cainfo
  1882. res.WarnMsg = resSix10265.WarnMsg
  1883. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1884. res.Infcode = infocode
  1885. }
  1886. if res.Infcode == 0 {
  1887. item.IsSale = 0
  1888. item.SaleDate = ""
  1889. item.Bchno = ""
  1890. service.SaveDF(item)
  1891. } else {
  1892. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1893. }
  1894. }
  1895. if item.IsSale == 0 && item.IsChange == 1 {
  1896. var res FJ3507Result
  1897. var struct3507 models.Struct3507
  1898. struct3507.FixmedinsBchno = item.BgBchno
  1899. struct3507.InvDataType = "2"
  1900. struct3507.Opter = roles.UserName
  1901. struct3507.FixmedinsCode = miConfig.Code
  1902. struct3507.Code = miConfig.Code
  1903. struct3507.OrgName = miConfig.OrgName
  1904. struct3507.AccessKey = miConfig.AccessKey
  1905. struct3507.RequestUrl = miConfig.Url
  1906. struct3507.SecretKey = miConfig.SecretKey
  1907. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1908. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1909. struct3507.Url = miConfig.Url
  1910. struct3507.AppId = miConfig.Cainfo
  1911. struct3507.AppSecret = miConfig.AppSecret
  1912. struct3507.Enckey = miConfig.EncKey
  1913. struct3507.SignKey = miConfig.SignKey
  1914. struct3507.SecretKey = miConfig.SecretKey
  1915. //result, result1, _ := service.FJyb3507(struct3507)
  1916. //saveLog(result, result1, "3507", "3507")
  1917. //
  1918. //var respJSON3 map[string]interface{}
  1919. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1920. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1922. // return
  1923. //}
  1924. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1925. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1926. // utils.ErrorLog("解析失败:%v", err)
  1927. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1928. // return
  1929. //}
  1930. if miConfig.MdtrtareaAdmvs == "350500" {
  1931. result, result1, _ := service.FJyb3507(struct3507)
  1932. saveLog(result, result1, "3507", "3507")
  1933. var respJSON2 map[string]interface{}
  1934. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1937. return
  1938. }
  1939. userJSONBytes2, _ := json.Marshal(respJSON2)
  1940. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1941. utils.ErrorLog("解析失败:%v", err)
  1942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1943. return
  1944. }
  1945. } else {
  1946. data := make(map[string]interface{})
  1947. data["struct_3507s"] = struct3507
  1948. client := &http.Client{}
  1949. bytesData, _ := json.Marshal(data)
  1950. var req *http.Request
  1951. if miConfig.MdtrtareaAdmvs == "320921" {
  1952. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1953. } else {
  1954. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1955. }
  1956. resp, _ := client.Do(req)
  1957. defer resp.Body.Close()
  1958. body, ioErr := ioutil.ReadAll(resp.Body)
  1959. if ioErr != nil {
  1960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1961. }
  1962. var respJSON map[string]interface{}
  1963. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1966. return
  1967. }
  1968. var resSix10265 ResultSix10265 //1101结果
  1969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1970. result, _ := json.Marshal(respJSON)
  1971. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1972. utils.ErrorLog("解析失败:%v", err)
  1973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1974. return
  1975. }
  1976. res.InfRefmsgid = resSix10265.InfRefmsgid
  1977. //res.Output = resSix10265.Output
  1978. res.ErrMsg = resSix10265.ErrMsg
  1979. res.Cainfo = resSix10265.Cainfo
  1980. res.WarnMsg = resSix10265.WarnMsg
  1981. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1982. res.Infcode = infocode
  1983. }
  1984. if res.Infcode == 0 {
  1985. item.IsChange = 0
  1986. item.BgBchno = ""
  1987. service.SaveDF2(item)
  1988. } else {
  1989. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1990. }
  1991. }
  1992. }
  1993. if len(err) == 0 {
  1994. c.ServeSuccessJSON(map[string]interface{}{
  1995. "msg": "删除销售变更成功",
  1996. })
  1997. } else {
  1998. c.ServeSuccessJSON(map[string]interface{}{
  1999. "failed_code": -10,
  2000. "msg": err,
  2001. })
  2002. }
  2003. }
  2004. //func (c *HisApiController) BatchFJ3501AND3502() {
  2005. // //ids := c.GetString("ids")
  2006. // start_time := c.GetString("start_time")
  2007. // end_time := c.GetString("end_time")
  2008. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2009. //
  2010. //
  2011. // timeLayout := "2006-01-02"
  2012. // loc, _ := time.LoadLocation("Local")
  2013. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2014. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2015. //
  2016. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2017. // //id_arr := strings.Split(ids, ",")
  2018. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2019. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2020. // //库盘
  2021. // var errs []string
  2022. // for _, drug := range drugs {
  2023. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2024. // var res2 ResultSix
  2025. // var res3 ResultSix
  2026. //
  2027. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2028. // var struct3501 models.Struct3501
  2029. // struct3501.Code = miConfig.Code
  2030. // struct3501.OrgName = miConfig.OrgName
  2031. // struct3501.AccessKey = miConfig.AccessKey
  2032. // struct3501.Opter = roles.UserName
  2033. // struct3501.RequestUrl = miConfig.Url
  2034. // struct3501.Url = miConfig.Url
  2035. // struct3501.AppId = miConfig.Cainfo
  2036. // struct3501.AppSecret = miConfig.AppSecret
  2037. // struct3501.Enckey = miConfig.EncKey
  2038. // struct3501.SignKey = miConfig.SignKey
  2039. // struct3501.SecretKey = miConfig.SecretKey
  2040. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2041. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2042. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2043. // struct3501.RxFlag = "1"
  2044. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2045. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2046. //
  2047. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2048. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2049. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2050. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2051. // struct3501.FixmedinsBchno = number
  2052. // struct3501.DrugTracCodg = drug.DrugCode
  2053. // memo := make(map[string]interface{})
  2054. // memo["pric"] = drug.Price
  2055. // bytesData, _ := json.Marshal(memo)
  2056. // struct3501.Memo = string(bytesData)
  2057. //
  2058. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2059. //
  2060. // result1, result2, _ := service.FJyb3501(struct3501)
  2061. // saveLog(result1, result2, "3501", "3501")
  2062. // //saveLog(result, requestLog, "2201", "挂号")
  2063. //
  2064. // var respJSON2 map[string]interface{}
  2065. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2066. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2067. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2068. // return
  2069. // }
  2070. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2071. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2072. // utils.ErrorLog("解析失败:%v", err)
  2073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2074. // return
  2075. // }
  2076. //
  2077. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2078. // data := make(map[string]interface{})
  2079. // data["struct_3501s"] = struct3501
  2080. // client := &http.Client{}
  2081. // bytesData, _ := json.Marshal(data)
  2082. // var req *http.Request
  2083. // if miConfig.MdtrtareaAdmvs == "320921" {
  2084. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2085. // } else {
  2086. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2087. // }
  2088. //
  2089. // resp, _ := client.Do(req)
  2090. // defer resp.Body.Close()
  2091. // body, ioErr := ioutil.ReadAll(resp.Body)
  2092. // if ioErr != nil {
  2093. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2094. // }
  2095. // var respJSON map[string]interface{}
  2096. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2097. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2099. // return
  2100. // }
  2101. // var resSix10265 ResultSix10265 //1101结果
  2102. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2103. // result, _ := json.Marshal(respJSON)
  2104. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2105. // utils.ErrorLog("解析失败:%v", err)
  2106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2107. // return
  2108. // }
  2109. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2110. // res2.Output = resSix10265.Output
  2111. // res2.ErrMsg = resSix10265.ErrMsg
  2112. // res2.Cainfo = resSix10265.Cainfo
  2113. // res2.WarnMsg = resSix10265.WarnMsg
  2114. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2115. // res2.Infcode = infocode
  2116. //
  2117. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2118. // data := make(map[string]interface{})
  2119. // data["struct_3501s"] = struct3501
  2120. // client := &http.Client{}
  2121. // bytesData, _ := json.Marshal(data)
  2122. // var req *http.Request
  2123. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2124. // resp, _ := client.Do(req)
  2125. // defer resp.Body.Close()
  2126. // body, ioErr := ioutil.ReadAll(resp.Body)
  2127. // if ioErr != nil {
  2128. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2129. // }
  2130. // var respJSON map[string]interface{}
  2131. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2132. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2133. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2134. // return
  2135. // }
  2136. // var resSix10265 ResultSix10265 //1101结果
  2137. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2138. // result, _ := json.Marshal(respJSON)
  2139. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2140. // utils.ErrorLog("解析失败:%v", err)
  2141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2142. // return
  2143. // }
  2144. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2145. // res2.Output = resSix10265.Output
  2146. // res2.ErrMsg = resSix10265.ErrMsg
  2147. // res2.Cainfo = resSix10265.Cainfo
  2148. // res2.WarnMsg = resSix10265.WarnMsg
  2149. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2150. // res2.Infcode = infocode
  2151. //
  2152. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2153. // data := make(map[string]interface{})
  2154. // data["struct_3501s"] = struct3501
  2155. // client := &http.Client{}
  2156. // bytesData, _ := json.Marshal(data)
  2157. // var req *http.Request
  2158. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2159. // resp, _ := client.Do(req)
  2160. // defer resp.Body.Close()
  2161. // body, ioErr := ioutil.ReadAll(resp.Body)
  2162. // if ioErr != nil {
  2163. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2164. // }
  2165. // var respJSON map[string]interface{}
  2166. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2167. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2169. // return
  2170. // }
  2171. // var resSix10265 ResultSix10265 //1101结果
  2172. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2173. // result, _ := json.Marshal(respJSON)
  2174. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2175. // utils.ErrorLog("解析失败:%v", err)
  2176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2177. // return
  2178. // }
  2179. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2180. // res2.Output = resSix10265.Output
  2181. // res2.ErrMsg = resSix10265.ErrMsg
  2182. // res2.Cainfo = resSix10265.Cainfo
  2183. // res2.WarnMsg = resSix10265.WarnMsg
  2184. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2185. // res2.Infcode = infocode
  2186. //
  2187. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2188. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2189. // saveLog(result1, result2, "3501", "3501")
  2190. // //saveLog(result, requestLog, "2201", "挂号")
  2191. //
  2192. // var respJSON2 map[string]interface{}
  2193. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2194. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2196. // return
  2197. // }
  2198. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2199. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2200. // utils.ErrorLog("解析失败:%v", err)
  2201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2202. // return
  2203. // }
  2204. //
  2205. // }
  2206. //
  2207. // if res2.Infcode != -1 {
  2208. // drug.IsPc = 1
  2209. // drug.Bchno = number
  2210. // drug.PcDate = time.Now().Unix()
  2211. // err := service.SaveW(drug)
  2212. // if err == nil {
  2213. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2214. // var struct3502 models.Struct3502
  2215. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2216. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2217. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2218. // struct3502.FixmedinsCode = miConfig.Code
  2219. // struct3502.Code = miConfig.Code
  2220. //
  2221. // struct3502.RxFlag = "0"
  2222. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2223. // struct3502.OrgName = miConfig.OrgName
  2224. // struct3502.Opter = roles.UserName
  2225. // struct3502.AccessKey = miConfig.AccessKey
  2226. // struct3502.RequestUrl = miConfig.Url
  2227. // struct3502.SecretKey = miConfig.SecretKey
  2228. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2229. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2230. // struct3502.Url = miConfig.Url
  2231. // struct3502.AppId = miConfig.Cainfo
  2232. // struct3502.AppSecret = miConfig.AppSecret
  2233. // struct3502.Enckey = miConfig.EncKey
  2234. // struct3502.SignKey = miConfig.SignKey
  2235. // struct3502.SecretKey = miConfig.SecretKey
  2236. // struct3502.DrugTracCodg = drug.DrugCode
  2237. //
  2238. // struct3502.Memo = ""
  2239. // struct3502.InvChgType = "108"
  2240. // struct3502.FixmedinsBchno = bg_number
  2241. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2242. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2243. //
  2244. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2245. // result11, result22, _ := service.FJyb3502(struct3502)
  2246. // saveLog(result11, result22, "3502", "3502")
  2247. //
  2248. // var respJSON3 map[string]interface{}
  2249. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2250. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2251. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2252. // return
  2253. // }
  2254. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2255. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2256. // utils.ErrorLog("解析失败:%v", err)
  2257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2258. // return
  2259. // }
  2260. //
  2261. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2262. // data := make(map[string]interface{})
  2263. // data["struct_3502s"] = struct3502
  2264. // client := &http.Client{}
  2265. // bytesData, _ := json.Marshal(data)
  2266. // var req *http.Request
  2267. // if miConfig.MdtrtareaAdmvs == "320921" {
  2268. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2269. // } else {
  2270. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2271. // }
  2272. //
  2273. // resp, _ := client.Do(req)
  2274. // defer resp.Body.Close()
  2275. // body, ioErr := ioutil.ReadAll(resp.Body)
  2276. // if ioErr != nil {
  2277. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2278. // }
  2279. // var respJSON map[string]interface{}
  2280. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2281. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2283. // return
  2284. // }
  2285. // var resSix10265 ResultSix10265 //1101结果
  2286. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2287. // result, _ := json.Marshal(respJSON)
  2288. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2289. // utils.ErrorLog("解析失败:%v", err)
  2290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2291. // return
  2292. // }
  2293. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2294. // res3.Output = resSix10265.Output
  2295. // res3.ErrMsg = resSix10265.ErrMsg
  2296. // res3.Cainfo = resSix10265.Cainfo
  2297. // res3.WarnMsg = resSix10265.WarnMsg
  2298. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2299. // res3.Infcode = infocode
  2300. //
  2301. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2302. //
  2303. // data := make(map[string]interface{})
  2304. // data["struct_3502s"] = struct3502
  2305. // client := &http.Client{}
  2306. // bytesData, _ := json.Marshal(data)
  2307. // var req *http.Request
  2308. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2309. // resp, _ := client.Do(req)
  2310. // defer resp.Body.Close()
  2311. // body, ioErr := ioutil.ReadAll(resp.Body)
  2312. // if ioErr != nil {
  2313. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2314. // }
  2315. // var respJSON map[string]interface{}
  2316. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2317. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2318. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2319. // return
  2320. // }
  2321. // var resSix10265 ResultSix10265 //1101结果
  2322. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2323. // result, _ := json.Marshal(respJSON)
  2324. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2325. // utils.ErrorLog("解析失败:%v", err)
  2326. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2327. // return
  2328. // }
  2329. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2330. // res3.Output = resSix10265.Output
  2331. // res3.ErrMsg = resSix10265.ErrMsg
  2332. // res3.Cainfo = resSix10265.Cainfo
  2333. // res3.WarnMsg = resSix10265.WarnMsg
  2334. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2335. // res3.Infcode = infocode
  2336. //
  2337. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2338. //
  2339. // data := make(map[string]interface{})
  2340. // data["struct_3501s"] = struct3501
  2341. // client := &http.Client{}
  2342. // bytesData, _ := json.Marshal(data)
  2343. // var req *http.Request
  2344. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2345. // resp, _ := client.Do(req)
  2346. // defer resp.Body.Close()
  2347. // body, ioErr := ioutil.ReadAll(resp.Body)
  2348. // if ioErr != nil {
  2349. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2350. // }
  2351. // var respJSON map[string]interface{}
  2352. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2353. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2354. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2355. // return
  2356. // }
  2357. // var resSix10265 ResultSix10265 //1101结果
  2358. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2359. // result, _ := json.Marshal(respJSON)
  2360. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2361. // utils.ErrorLog("解析失败:%v", err)
  2362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2363. // return
  2364. // }
  2365. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2366. // res2.Output = resSix10265.Output
  2367. // res2.ErrMsg = resSix10265.ErrMsg
  2368. // res2.Cainfo = resSix10265.Cainfo
  2369. // res2.WarnMsg = resSix10265.WarnMsg
  2370. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2371. // res2.Infcode = infocode
  2372. //
  2373. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2374. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2375. // saveLog(result11, result22, "3502", "3502")
  2376. //
  2377. // var respJSON3 map[string]interface{}
  2378. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2379. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2381. // return
  2382. // }
  2383. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2384. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2385. // utils.ErrorLog("解析失败:%v", err)
  2386. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2387. // return
  2388. // }
  2389. // }
  2390. // if res3.Infcode == -1 {
  2391. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2392. // c.ServeSuccessJSON(map[string]interface{}{
  2393. // "failed_code": -10,
  2394. // "msg": res3.ErrMsg,
  2395. // })
  2396. // } else {
  2397. // drug.IsBg = 1
  2398. // drug.BgBchno = bg_number
  2399. // service.SaveW(drug)
  2400. // }
  2401. // }
  2402. // } else {
  2403. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2404. // }
  2405. // }
  2406. // //变更
  2407. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2408. // var res3 ResultSix
  2409. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2410. //
  2411. // var struct3502 models.Struct3502
  2412. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2413. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2414. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2415. // struct3502.FixmedinsCode = miConfig.Code
  2416. // struct3502.Code = miConfig.Code
  2417. //
  2418. // struct3502.Opter = roles.UserName
  2419. // struct3502.RxFlag = "0"
  2420. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2421. // struct3502.OrgName = miConfig.OrgName
  2422. // struct3502.AccessKey = miConfig.AccessKey
  2423. // struct3502.RequestUrl = miConfig.Url
  2424. // struct3502.SecretKey = miConfig.SecretKey
  2425. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2426. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2427. // struct3502.InvChgType = "108"
  2428. // struct3502.DrugTracCodg = drug.DrugCode
  2429. //
  2430. // struct3502.Url = miConfig.Url
  2431. // struct3502.AppId = miConfig.Cainfo
  2432. // struct3502.AppSecret = miConfig.AppSecret
  2433. // struct3502.Enckey = miConfig.EncKey
  2434. // struct3502.SignKey = miConfig.SignKey
  2435. // struct3502.SecretKey = miConfig.SecretKey
  2436. //
  2437. // struct3502.FixmedinsBchno = bg_number
  2438. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2439. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2440. //
  2441. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2442. // result1, result2, _ := service.FJyb3502(struct3502)
  2443. // saveLog(result1, result2, "3502", "3502")
  2444. // var respJSON3 map[string]interface{}
  2445. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2446. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2447. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2448. // return
  2449. // }
  2450. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2451. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2452. // utils.ErrorLog("解析失败:%v", err)
  2453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2454. // return
  2455. // }
  2456. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2457. // data := make(map[string]interface{})
  2458. // data["struct_3502s"] = struct3502
  2459. // client := &http.Client{}
  2460. // bytesData, _ := json.Marshal(data)
  2461. // var req *http.Request
  2462. // if miConfig.MdtrtareaAdmvs == "320921" {
  2463. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2464. // } else {
  2465. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2466. // }
  2467. // resp, _ := client.Do(req)
  2468. // defer resp.Body.Close()
  2469. // body, ioErr := ioutil.ReadAll(resp.Body)
  2470. // if ioErr != nil {
  2471. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2472. // }
  2473. // var respJSON map[string]interface{}
  2474. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2475. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2477. // return
  2478. // }
  2479. // var resSix10265 ResultSix10265 //1101结果
  2480. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2481. // result, _ := json.Marshal(respJSON)
  2482. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2483. // utils.ErrorLog("解析失败:%v", err)
  2484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2485. // return
  2486. // }
  2487. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2488. // res3.Output = resSix10265.Output
  2489. // res3.ErrMsg = resSix10265.ErrMsg
  2490. // res3.Cainfo = resSix10265.Cainfo
  2491. // res3.WarnMsg = resSix10265.WarnMsg
  2492. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2493. // res3.Infcode = infocode
  2494. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2495. //
  2496. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2497. //
  2498. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2499. //
  2500. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2501. //
  2502. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2503. // saveLog(result1, result2, "3501", "3501")
  2504. // //saveLog(result, requestLog, "2201", "挂号")
  2505. //
  2506. // var respJSON2 map[string]interface{}
  2507. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2508. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2510. // return
  2511. // }
  2512. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2513. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2514. // utils.ErrorLog("解析失败:%v", err)
  2515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2516. // return
  2517. // }
  2518. //
  2519. // }
  2520. // if res3.Infcode == -1 {
  2521. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2522. // } else {
  2523. // drug.IsBg = 1
  2524. // drug.BgBchno = bg_number
  2525. // service.SaveW(drug)
  2526. // }
  2527. // }
  2528. // }
  2529. //
  2530. // if len(errs) == 0 {
  2531. // c.ServeSuccessJSON(map[string]interface{}{
  2532. // "msg": "盘存变更成功",
  2533. // })
  2534. // } else {
  2535. // c.ServeSuccessJSON(map[string]interface{}{
  2536. // "failed_code": -10,
  2537. // "msg": errs,
  2538. // })
  2539. // }
  2540. //}
  2541. func (c *HisApiController) DeleteXSandBGTwo() {
  2542. patient_id, _ := c.GetInt64("patient_id")
  2543. admin_user_id, _ := c.GetInt64("admin_user_id")
  2544. times := c.GetString("time", "")
  2545. timeLayout := "2006-01-02"
  2546. loc, _ := time.LoadLocation("Local")
  2547. var stime, etime int64
  2548. if times == "" {
  2549. stime, etime = GetNowTime()
  2550. } else {
  2551. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2552. stime = stmp.Unix()
  2553. etime = stime + 86399
  2554. }
  2555. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2556. var flows []*models.DrugFlow
  2557. for _, item := range advicelist {
  2558. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2559. flows = append(flows, flow...)
  2560. }
  2561. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2562. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2563. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2564. var err []string
  2565. for _, item := range flows {
  2566. if item.IsSale == 1 {
  2567. var res FJ3507Result
  2568. var struct3507 models.Struct3507
  2569. struct3507.FixmedinsBchno = item.Bchno
  2570. struct3507.InvDataType = "4"
  2571. struct3507.Opter = roles.UserName
  2572. struct3507.OrgName = miConfig.OrgName
  2573. struct3507.AccessKey = miConfig.AccessKey
  2574. struct3507.RequestUrl = miConfig.Url
  2575. struct3507.FixmedinsCode = miConfig.Code
  2576. struct3507.SecretKey = miConfig.SecretKey
  2577. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2578. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2579. struct3507.Url = miConfig.Url
  2580. struct3507.AppId = miConfig.Cainfo
  2581. struct3507.AppSecret = miConfig.AppSecret
  2582. struct3507.Enckey = miConfig.EncKey
  2583. struct3507.SignKey = miConfig.SignKey
  2584. struct3507.SecretKey = miConfig.SecretKey
  2585. if miConfig.MdtrtareaAdmvs == "350500" {
  2586. result, result1, _ := service.FJyb3507(struct3507)
  2587. saveLog(result, result1, "3507", "3507")
  2588. var respJSON2 map[string]interface{}
  2589. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2592. return
  2593. }
  2594. userJSONBytes2, _ := json.Marshal(respJSON2)
  2595. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2596. utils.ErrorLog("解析失败:%v", err)
  2597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2598. return
  2599. }
  2600. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2601. data := make(map[string]interface{})
  2602. data["struct_3507s"] = struct3507
  2603. client := &http.Client{}
  2604. bytesData, _ := json.Marshal(data)
  2605. var req *http.Request
  2606. if miConfig.MdtrtareaAdmvs == "320921" {
  2607. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2608. } else {
  2609. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2610. }
  2611. resp, _ := client.Do(req)
  2612. defer resp.Body.Close()
  2613. body, ioErr := ioutil.ReadAll(resp.Body)
  2614. if ioErr != nil {
  2615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2616. }
  2617. var respJSON map[string]interface{}
  2618. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2621. return
  2622. }
  2623. var resSix10265 ResultSix10265 //1101结果
  2624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2625. result, _ := json.Marshal(respJSON)
  2626. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2627. utils.ErrorLog("解析失败:%v", err)
  2628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2629. return
  2630. }
  2631. res.InfRefmsgid = resSix10265.InfRefmsgid
  2632. //res.Output = resSix10265.Output
  2633. res.ErrMsg = resSix10265.ErrMsg
  2634. res.Cainfo = resSix10265.Cainfo
  2635. res.WarnMsg = resSix10265.WarnMsg
  2636. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2637. res.Infcode = infocode
  2638. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2639. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2640. saveLog(result2, result1, "3507", "3507")
  2641. var respJSON2 map[string]interface{}
  2642. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2645. return
  2646. }
  2647. userJSONBytes2, _ := json.Marshal(respJSON2)
  2648. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2649. utils.ErrorLog("解析失败:%v", err)
  2650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2651. return
  2652. }
  2653. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2654. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2655. saveLog(result2, result1, "3507", "3507")
  2656. var respJSON2 map[string]interface{}
  2657. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2660. return
  2661. }
  2662. userJSONBytes2, _ := json.Marshal(respJSON2)
  2663. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2664. utils.ErrorLog("解析失败:%v", err)
  2665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2666. return
  2667. }
  2668. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2669. result1, result2 := service.Jxyb3507(struct3507)
  2670. saveLog(result2, result1, "3507", "3507")
  2671. var respJSON2 map[string]interface{}
  2672. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2675. return
  2676. }
  2677. userJSONBytes2, _ := json.Marshal(respJSON2)
  2678. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2679. utils.ErrorLog("解析失败:%v", err)
  2680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2681. return
  2682. }
  2683. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2684. result1, result2 := service.AHyb3507(struct3507)
  2685. saveLog(result2, result1, "3507", "3507")
  2686. var respJSON2 map[string]interface{}
  2687. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2690. return
  2691. }
  2692. userJSONBytes2, _ := json.Marshal(respJSON2)
  2693. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2694. utils.ErrorLog("解析失败:%v", err)
  2695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2696. return
  2697. }
  2698. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2699. data := make(map[string]interface{})
  2700. data["struct_3507s"] = struct3507
  2701. client := &http.Client{}
  2702. bytesData, _ := json.Marshal(data)
  2703. var req *http.Request
  2704. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2705. resp, _ := client.Do(req)
  2706. defer resp.Body.Close()
  2707. body, ioErr := ioutil.ReadAll(resp.Body)
  2708. if ioErr != nil {
  2709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2710. }
  2711. var respJSON map[string]interface{}
  2712. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2714. }
  2715. var resSix10265 ResultSix10265 //1101结果
  2716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2717. result, _ := json.Marshal(respJSON)
  2718. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2719. utils.ErrorLog("解析失败:%v", err)
  2720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2721. return
  2722. }
  2723. res.InfRefmsgid = resSix10265.InfRefmsgid
  2724. res.ErrMsg = resSix10265.ErrMsg
  2725. res.Cainfo = resSix10265.Cainfo
  2726. res.WarnMsg = resSix10265.WarnMsg
  2727. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2728. res.Infcode = infocode
  2729. }
  2730. if res.Infcode == 0 {
  2731. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2732. item.IsSale = 0
  2733. item.SaleDate = ""
  2734. item.Bchno = ""
  2735. service.SaveDF(item)
  2736. } else {
  2737. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2738. }
  2739. }
  2740. }
  2741. c.ServeSuccessJSON(map[string]interface{}{
  2742. "msg": "删除销售数据成功",
  2743. })
  2744. }
  2745. // 删除
  2746. func (c *HisApiController) DeleteXSandBGThree() {
  2747. id, _ := c.GetInt64("id")
  2748. admin_user_id, _ := c.GetInt64("admin_user_id")
  2749. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2750. var flows []*models.DrugFlow
  2751. for _, item := range advicelist {
  2752. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2753. flows = append(flows, flow...)
  2754. }
  2755. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2756. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2757. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2758. var err []string
  2759. for _, item := range flows {
  2760. if item.IsSale == 1 {
  2761. var res FJ3507Result
  2762. var struct3507 models.Struct3507
  2763. struct3507.FixmedinsBchno = item.Bchno
  2764. struct3507.InvDataType = "4"
  2765. struct3507.Opter = roles.UserName
  2766. struct3507.OrgName = miConfig.OrgName
  2767. struct3507.AccessKey = miConfig.AccessKey
  2768. struct3507.RequestUrl = miConfig.Url
  2769. struct3507.FixmedinsCode = miConfig.Code
  2770. struct3507.SecretKey = miConfig.SecretKey
  2771. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2772. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2773. struct3507.Url = miConfig.Url
  2774. struct3507.AppId = miConfig.Cainfo
  2775. struct3507.AppSecret = miConfig.AppSecret
  2776. struct3507.Enckey = miConfig.EncKey
  2777. struct3507.SignKey = miConfig.SignKey
  2778. struct3507.SecretKey = miConfig.SecretKey
  2779. if miConfig.MdtrtareaAdmvs == "350500" {
  2780. result, result1, _ := service.FJyb3507(struct3507)
  2781. saveLog(result, result1, "3507", "3507")
  2782. var respJSON2 map[string]interface{}
  2783. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2786. return
  2787. }
  2788. userJSONBytes2, _ := json.Marshal(respJSON2)
  2789. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2790. utils.ErrorLog("解析失败:%v", err)
  2791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2792. return
  2793. }
  2794. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2795. data := make(map[string]interface{})
  2796. data["struct_3507s"] = struct3507
  2797. client := &http.Client{}
  2798. bytesData, _ := json.Marshal(data)
  2799. var req *http.Request
  2800. if miConfig.MdtrtareaAdmvs == "320921" {
  2801. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2802. } else {
  2803. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2804. }
  2805. resp, _ := client.Do(req)
  2806. defer resp.Body.Close()
  2807. body, ioErr := ioutil.ReadAll(resp.Body)
  2808. if ioErr != nil {
  2809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2810. }
  2811. var respJSON map[string]interface{}
  2812. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2815. return
  2816. }
  2817. var resSix10265 ResultSix10265 //1101结果
  2818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2819. result, _ := json.Marshal(respJSON)
  2820. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2821. utils.ErrorLog("解析失败:%v", err)
  2822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2823. return
  2824. }
  2825. res.InfRefmsgid = resSix10265.InfRefmsgid
  2826. //res.Output = resSix10265.Output
  2827. res.ErrMsg = resSix10265.ErrMsg
  2828. res.Cainfo = resSix10265.Cainfo
  2829. res.WarnMsg = resSix10265.WarnMsg
  2830. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2831. res.Infcode = infocode
  2832. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2833. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2834. saveLog(result2, result1, "3507", "3507")
  2835. var respJSON2 map[string]interface{}
  2836. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2839. return
  2840. }
  2841. userJSONBytes2, _ := json.Marshal(respJSON2)
  2842. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2843. utils.ErrorLog("解析失败:%v", err)
  2844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2845. return
  2846. }
  2847. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2848. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2849. saveLog(result2, result1, "3507", "3507")
  2850. var respJSON2 map[string]interface{}
  2851. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2854. return
  2855. }
  2856. userJSONBytes2, _ := json.Marshal(respJSON2)
  2857. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2858. utils.ErrorLog("解析失败:%v", err)
  2859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2860. return
  2861. }
  2862. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2863. result1, result2 := service.Jxyb3507(struct3507)
  2864. saveLog(result2, result1, "3507", "3507")
  2865. var respJSON2 map[string]interface{}
  2866. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2869. return
  2870. }
  2871. userJSONBytes2, _ := json.Marshal(respJSON2)
  2872. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2873. utils.ErrorLog("解析失败:%v", err)
  2874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2875. return
  2876. }
  2877. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2878. result1, result2 := service.AHyb3507(struct3507)
  2879. saveLog(result2, result1, "3507", "3507")
  2880. var respJSON2 map[string]interface{}
  2881. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2884. return
  2885. }
  2886. userJSONBytes2, _ := json.Marshal(respJSON2)
  2887. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2888. utils.ErrorLog("解析失败:%v", err)
  2889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2890. return
  2891. }
  2892. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2893. data := make(map[string]interface{})
  2894. data["struct_3507s"] = struct3507
  2895. client := &http.Client{}
  2896. bytesData, _ := json.Marshal(data)
  2897. var req *http.Request
  2898. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2899. resp, _ := client.Do(req)
  2900. defer resp.Body.Close()
  2901. body, ioErr := ioutil.ReadAll(resp.Body)
  2902. if ioErr != nil {
  2903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2904. }
  2905. var respJSON map[string]interface{}
  2906. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2908. }
  2909. var resSix10265 ResultSix10265 //1101结果
  2910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2911. result, _ := json.Marshal(respJSON)
  2912. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2913. utils.ErrorLog("解析失败:%v", err)
  2914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2915. return
  2916. }
  2917. res.InfRefmsgid = resSix10265.InfRefmsgid
  2918. res.ErrMsg = resSix10265.ErrMsg
  2919. res.Cainfo = resSix10265.Cainfo
  2920. res.WarnMsg = resSix10265.WarnMsg
  2921. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2922. res.Infcode = infocode
  2923. }
  2924. if res.Infcode == 0 {
  2925. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2926. item.IsSale = 0
  2927. item.SaleDate = ""
  2928. item.Bchno = ""
  2929. service.SaveDF(item)
  2930. } else {
  2931. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2932. }
  2933. }
  2934. }
  2935. c.ServeSuccessJSON(map[string]interface{}{
  2936. "msg": "删除销售数据成功",
  2937. })
  2938. }
  2939. // 获取当天起止时间戳
  2940. func GetNowTime() (int64, int64) {
  2941. t := time.Now()
  2942. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2943. timesamp := addTime.Unix()
  2944. return timesamp, timesamp + 86399
  2945. }
  2946. func (c *HisApiController) ChangeDrugfour() {
  2947. patient_id, _ := c.GetInt64("patient_id")
  2948. admin_user_id, _ := c.GetInt64("admin_user_id")
  2949. times := c.GetString("time", "")
  2950. timeLayout := "2006-01-02"
  2951. loc, _ := time.LoadLocation("Local")
  2952. var stime, etime int64
  2953. if times == "" {
  2954. stime, etime = GetNowTime()
  2955. } else {
  2956. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2957. stime = stmp.Unix()
  2958. etime = stime + 86399
  2959. }
  2960. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2961. var flows []*models.DrugFlow
  2962. for _, item := range advicelist {
  2963. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2964. flows = append(flows, flow...)
  2965. }
  2966. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2967. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2968. var err []string
  2969. for _, item := range flows {
  2970. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2971. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2972. if prescription.OrderStatus == 2 {
  2973. if item.IsSale == 0 {
  2974. var res FJ3507Result
  2975. var res3507for10188 FJ3507ResultFor10188
  2976. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2977. //进行商品销售接口
  2978. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2979. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2980. var respJSON3 map[string]interface{}
  2981. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2984. return
  2985. }
  2986. userJSONBytes3, _ := json.Marshal(respJSON3)
  2987. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2988. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2989. utils.ErrorLog("解析失败:%v", err)
  2990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2991. return
  2992. }
  2993. //if res3507for10188.Infcode
  2994. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2995. //res.Output = resSix10265.Output
  2996. res.ErrMsg = res3507for10188.ErrMsg
  2997. res.Cainfo = res3507for10188.Cainfo
  2998. res.WarnMsg = res3507for10188.WarnMsg
  2999. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3000. res.Infcode = infocode
  3001. } else {
  3002. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3003. utils.ErrorLog("解析失败:%v", err)
  3004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3005. return
  3006. }
  3007. }
  3008. if res.Infcode == 0 {
  3009. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3010. item.IsSale = 1
  3011. item.Bchno = number
  3012. item.SaleDate = time.Now().Format("2006-01-02")
  3013. service.SaveDF(item)
  3014. } else {
  3015. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3016. }
  3017. }
  3018. } else { //还没结,提示用户去结算,并药品追溯上传
  3019. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3020. }
  3021. }
  3022. }
  3023. str := strings.Join(err, " ")
  3024. saveLog(str, str, "3505", "3505自动上传日志")
  3025. c.ServeSuccessJSON(map[string]interface{}{
  3026. "status": "1",
  3027. "msg": err,
  3028. })
  3029. }
  3030. func (c *HisApiController) ChangeDrugFive() {
  3031. id, _ := c.GetInt64("id")
  3032. admin_user_id, _ := c.GetInt64("admin_user_id")
  3033. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3034. var flows []*models.DrugFlow
  3035. for _, item := range advicelist {
  3036. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3037. flows = append(flows, flow...)
  3038. }
  3039. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3040. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3041. var err []string
  3042. for _, item := range flows {
  3043. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3044. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3045. if prescription.OrderStatus == 2 {
  3046. if item.IsSale == 0 {
  3047. var res FJ3507Result
  3048. var res3507for10188 FJ3507ResultFor10188
  3049. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3050. //进行商品销售接口
  3051. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3052. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3053. var respJSON3 map[string]interface{}
  3054. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3057. return
  3058. }
  3059. userJSONBytes3, _ := json.Marshal(respJSON3)
  3060. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3061. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3062. utils.ErrorLog("解析失败:%v", err)
  3063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3064. return
  3065. }
  3066. //if res3507for10188.Infcode
  3067. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3068. //res.Output = resSix10265.Output
  3069. res.ErrMsg = res3507for10188.ErrMsg
  3070. res.Cainfo = res3507for10188.Cainfo
  3071. res.WarnMsg = res3507for10188.WarnMsg
  3072. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3073. res.Infcode = infocode
  3074. } else {
  3075. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3076. utils.ErrorLog("解析失败:%v", err)
  3077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3078. return
  3079. }
  3080. }
  3081. if res.Infcode == 0 {
  3082. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3083. item.IsSale = 1
  3084. item.Bchno = number
  3085. item.SaleDate = time.Now().Format("2006-01-02")
  3086. service.SaveDF(item)
  3087. } else {
  3088. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3089. }
  3090. }
  3091. } else { //还没结,提示用户去结算,并药品追溯上传
  3092. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3093. }
  3094. }
  3095. }
  3096. str := strings.Join(err, " ")
  3097. saveLog(str, str, "3505", "3505自动上传日志")
  3098. c.ServeSuccessJSON(map[string]interface{}{
  3099. "status": "1",
  3100. "msg": err,
  3101. })
  3102. }
  3103. //func (c *HisApiController) ChangeDrugfour() {
  3104. // patient_id, _ := c.GetInt64("patient_id")
  3105. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3106. // //id_arr := strings.Split(ids, ",")
  3107. // times := c.GetString("time", "")
  3108. // timeLayout := "2006-01-02"
  3109. // loc, _ := time.LoadLocation("Local")
  3110. // var stime, etime int64
  3111. // if times == "" {
  3112. // stime, etime = GetNowTime()
  3113. // } else {
  3114. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3115. // stime = stmp.Unix()
  3116. // etime = stime + 86399
  3117. // }
  3118. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3119. // var flows []*models.DrugFlow
  3120. // for _, item := range advicelist {
  3121. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3122. // flows = append(flows, flow...)
  3123. // }
  3124. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3125. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3126. // var err []string
  3127. //
  3128. // for _, item := range flows {
  3129. // var res3 ResultSix
  3130. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3131. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3132. // if prescription.OrderStatus == 2 {
  3133. // //已经结算
  3134. // //判断是否已经销售
  3135. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3136. // //是否已经变更 1是 0否
  3137. // if item.IsChange == 0 { //没变更,进行变更操作
  3138. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3139. //
  3140. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3141. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3142. // var respJSON3 map[string]interface{}
  3143. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3144. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3146. // return
  3147. // }
  3148. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3149. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3150. // utils.ErrorLog("解析失败:%v", err)
  3151. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3152. // return
  3153. // }
  3154. // if res3.Infcode == 0 {
  3155. // item.IsChange = 1
  3156. // item.BgBchno = bg_number
  3157. // service.SaveDF2(item)
  3158. // } else {
  3159. //
  3160. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3161. // }
  3162. // }
  3163. // } else { //没销售,
  3164. // var res FJ3507Result
  3165. // var res3507for10188 FJ3507ResultFor10188
  3166. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3167. //
  3168. // //进行商品销售接口
  3169. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3170. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3171. // var respJSON3 map[string]interface{}
  3172. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3173. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3175. // return
  3176. // }
  3177. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3178. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3179. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3180. // utils.ErrorLog("解析失败:%v", err)
  3181. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3182. // return
  3183. // }
  3184. // //if res3507for10188.Infcode
  3185. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3186. // //res.Output = resSix10265.Output
  3187. // res.ErrMsg = res3507for10188.ErrMsg
  3188. // res.Cainfo = res3507for10188.Cainfo
  3189. // res.WarnMsg = res3507for10188.WarnMsg
  3190. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3191. // res.Infcode = infocode
  3192. // } else {
  3193. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3194. // utils.ErrorLog("解析失败:%v", err)
  3195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3196. // return
  3197. // }
  3198. //
  3199. // }
  3200. // if res.Infcode == 0 {
  3201. // item.IsSale = 1
  3202. // item.Bchno = number
  3203. // item.SaleDate = time.Now().Format("2006-01-02")
  3204. //
  3205. // err5 := service.SaveDF(item)
  3206. // if err5 == nil {
  3207. // if item.IsChange == 0 { //没变更,进行变更操作
  3208. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3209. //
  3210. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3211. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3212. //
  3213. // var respJSON3 map[string]interface{}
  3214. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3215. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3217. // return
  3218. // }
  3219. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3220. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3221. // utils.ErrorLog("解析失败:%v", err)
  3222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3223. // return
  3224. // }
  3225. // //if res3507for10188.Infcode
  3226. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3227. // //res.Output = resSix10265.Output
  3228. // res3.ErrMsg = res3507for10188.ErrMsg
  3229. // res3.Cainfo = res3507for10188.Cainfo
  3230. // res3.WarnMsg = res3507for10188.WarnMsg
  3231. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3232. // res3.Infcode = infocode
  3233. // } else {
  3234. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3235. // utils.ErrorLog("解析失败:%v", err)
  3236. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3237. // return
  3238. // }
  3239. // }
  3240. // if res3.Infcode == 0 {
  3241. // item.IsChange = 1
  3242. // item.BgBchno = bg_number
  3243. // service.SaveDF2(item)
  3244. // } else {
  3245. //
  3246. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3247. // }
  3248. // }
  3249. // }
  3250. // } else {
  3251. //
  3252. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3253. // }
  3254. // }
  3255. //
  3256. // } else { //还没结,提示用户去结算,并药品追溯上传
  3257. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3258. // }
  3259. // }
  3260. // }
  3261. // if len(err) == 0 {
  3262. // c.ServeSuccessJSON(map[string]interface{}{
  3263. // "msg": "销售变更成功",
  3264. // })
  3265. // } else {
  3266. // c.ServeSuccessJSON(map[string]interface{}{
  3267. // "failed_code": -10,
  3268. // "msg": err,
  3269. // })
  3270. // }
  3271. //}
  3272. func (c *HisApiController) ChangeDrug() {
  3273. ids := c.GetString("ids")
  3274. id_arr := strings.Split(ids, ",")
  3275. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3276. admin_user_id, _ := c.GetInt64("admin_user_id")
  3277. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3278. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3279. var err []string
  3280. for _, item := range flows {
  3281. var res3 ResultSix
  3282. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3283. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3284. if prescription.OrderStatus == 2 {
  3285. //已经结算
  3286. //判断是否已经销售
  3287. if item.IsSale == 1 { //是否已经销售,1是 0否
  3288. //是否已经变更 1是 0否
  3289. if item.IsChange == 0 { //没变更,进行变更操作
  3290. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3291. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3292. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3293. var respJSON3 map[string]interface{}
  3294. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3297. return
  3298. }
  3299. userJSONBytes3, _ := json.Marshal(respJSON3)
  3300. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3301. utils.ErrorLog("解析失败:%v", err)
  3302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3303. return
  3304. }
  3305. if res3.Infcode == 0 {
  3306. item.IsChange = 1
  3307. item.BgBchno = bg_number
  3308. service.SaveDF2(item)
  3309. } else {
  3310. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3311. }
  3312. }
  3313. } else { //没销售,
  3314. var res FJ3507Result
  3315. var res3507for10188 FJ3507ResultFor10188
  3316. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3317. //进行商品销售接口
  3318. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3319. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3320. var respJSON3 map[string]interface{}
  3321. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3324. return
  3325. }
  3326. userJSONBytes3, _ := json.Marshal(respJSON3)
  3327. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3328. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3329. utils.ErrorLog("解析失败:%v", err)
  3330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3331. return
  3332. }
  3333. //if res3507for10188.Infcode
  3334. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3335. //res.Output = resSix10265.Output
  3336. res.ErrMsg = res3507for10188.ErrMsg
  3337. res.Cainfo = res3507for10188.Cainfo
  3338. res.WarnMsg = res3507for10188.WarnMsg
  3339. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3340. res.Infcode = infocode
  3341. } else {
  3342. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3343. utils.ErrorLog("解析失败:%v", err)
  3344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3345. return
  3346. }
  3347. }
  3348. if res.Infcode == 0 {
  3349. item.IsSale = 1
  3350. item.Bchno = number
  3351. item.SaleDate = time.Now().Format("2006-01-02")
  3352. err5 := service.SaveDF(item)
  3353. if err5 == nil {
  3354. if item.IsChange == 0 { //没变更,进行变更操作
  3355. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3356. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3357. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3358. var respJSON3 map[string]interface{}
  3359. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3362. return
  3363. }
  3364. userJSONBytes3, _ := json.Marshal(respJSON3)
  3365. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3366. utils.ErrorLog("解析失败:%v", err)
  3367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3368. return
  3369. }
  3370. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3371. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3372. utils.ErrorLog("解析失败:%v", err)
  3373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3374. return
  3375. }
  3376. //if res3507for10188.Infcode
  3377. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3378. //res.Output = resSix10265.Output
  3379. res3.ErrMsg = res3507for10188.ErrMsg
  3380. res3.Cainfo = res3507for10188.Cainfo
  3381. res3.WarnMsg = res3507for10188.WarnMsg
  3382. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3383. res3.Infcode = infocode
  3384. } else {
  3385. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3386. utils.ErrorLog("解析失败:%v", err)
  3387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3388. return
  3389. }
  3390. }
  3391. if res3.Infcode == 0 {
  3392. item.IsChange = 1
  3393. item.BgBchno = bg_number
  3394. service.SaveDF2(item)
  3395. } else {
  3396. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3397. }
  3398. }
  3399. }
  3400. } else {
  3401. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3402. }
  3403. }
  3404. } else { //还没结算
  3405. var res3507for10188 FJ3507ResultFor10188
  3406. if item.IsChange == 0 { //没变更,进行变更操作
  3407. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3408. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3409. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3410. var respJSON3 map[string]interface{}
  3411. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3414. return
  3415. }
  3416. userJSONBytes3, _ := json.Marshal(respJSON3)
  3417. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3418. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3419. utils.ErrorLog("解析失败:%v", err)
  3420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3421. return
  3422. }
  3423. //if res3507for10188.Infcode
  3424. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3425. //res.Output = resSix10265.Output
  3426. res3.ErrMsg = res3507for10188.ErrMsg
  3427. res3.Cainfo = res3507for10188.Cainfo
  3428. res3.WarnMsg = res3507for10188.WarnMsg
  3429. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3430. res3.Infcode = infocode
  3431. } else {
  3432. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3433. utils.ErrorLog("解析失败:%v", err)
  3434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3435. return
  3436. }
  3437. }
  3438. if res3.Infcode == 0 {
  3439. item.IsChange = 1
  3440. item.BgBchno = bg_number
  3441. service.SaveDF2(item)
  3442. } else {
  3443. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3444. }
  3445. }
  3446. }
  3447. } else if item.ConsumableType == 7 {
  3448. var res3507for10188 FJ3507ResultFor10188
  3449. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3450. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3451. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3452. //判断是否已经销售
  3453. if item.IsSale == 2 { //是否已经销售,1是 0否
  3454. //是否已经变更 1是 0否
  3455. if item.IsChange == 0 { //没变更,进行变更操作
  3456. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3457. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3458. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3459. var respJSON3 map[string]interface{}
  3460. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3463. return
  3464. }
  3465. userJSONBytes3, _ := json.Marshal(respJSON3)
  3466. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3467. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3468. utils.ErrorLog("解析失败:%v", err)
  3469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3470. return
  3471. }
  3472. //if res3507for10188.Infcode
  3473. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3474. //res.Output = resSix10265.Output
  3475. res3.ErrMsg = res3507for10188.ErrMsg
  3476. res3.Cainfo = res3507for10188.Cainfo
  3477. res3.WarnMsg = res3507for10188.WarnMsg
  3478. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3479. res3.Infcode = infocode
  3480. } else {
  3481. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3482. utils.ErrorLog("解析失败:%v", err)
  3483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3484. return
  3485. }
  3486. }
  3487. if res3.Infcode == 0 {
  3488. item.IsChange = 1
  3489. item.BgBchno = bg_number
  3490. service.SaveDF2(item)
  3491. } else {
  3492. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3493. }
  3494. }
  3495. } else { //没销售,
  3496. //进行商品销售退货接口
  3497. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3498. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3499. saveLog(result111, result222, "3506", "销售退货")
  3500. var res7 FJ3507Result
  3501. //进行商品销售接口
  3502. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3503. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3504. var respJSON3 map[string]interface{}
  3505. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3508. return
  3509. }
  3510. userJSONBytes3, _ := json.Marshal(respJSON3)
  3511. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3512. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3513. utils.ErrorLog("解析失败:%v", err)
  3514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3515. return
  3516. }
  3517. //if res3507for10188.Infcode
  3518. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3519. //res.Output = resSix10265.Output
  3520. res7.ErrMsg = res3507for10188.ErrMsg
  3521. res7.Cainfo = res3507for10188.Cainfo
  3522. res7.WarnMsg = res3507for10188.WarnMsg
  3523. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3524. res7.Infcode = infocode
  3525. } else {
  3526. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3527. utils.ErrorLog("解析失败:%v", err)
  3528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3529. return
  3530. }
  3531. }
  3532. if res7.Infcode == 0 {
  3533. item.IsSale = 2
  3534. item.SaleDate = item.SaleDate
  3535. item.Bchno = number
  3536. service.SaveDF(item)
  3537. if item.IsChange == 0 { //没变更,进行变更操作
  3538. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3539. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3540. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3541. var respJSON3 map[string]interface{}
  3542. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3545. return
  3546. }
  3547. userJSONBytes3, _ := json.Marshal(respJSON3)
  3548. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3549. // utils.ErrorLog("解析失败:%v", err)
  3550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3551. // return
  3552. //}
  3553. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3554. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3555. utils.ErrorLog("解析失败:%v", err)
  3556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3557. return
  3558. }
  3559. //if res3507for10188.Infcode
  3560. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3561. //res.Output = resSix10265.Output
  3562. res3.ErrMsg = res3507for10188.ErrMsg
  3563. res3.Cainfo = res3507for10188.Cainfo
  3564. res3.WarnMsg = res3507for10188.WarnMsg
  3565. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3566. res3.Infcode = infocode
  3567. } else {
  3568. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3569. utils.ErrorLog("解析失败:%v", err)
  3570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3571. return
  3572. }
  3573. }
  3574. if res3.Infcode == 0 {
  3575. item.IsChange = 1
  3576. item.BgBchno = bg_number
  3577. service.SaveDF2(item)
  3578. } else {
  3579. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3580. }
  3581. }
  3582. } else {
  3583. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3584. }
  3585. }
  3586. } else { //还没结算
  3587. if item.IsChange == 0 { //没变更,进行变更操作
  3588. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3589. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3590. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3591. var respJSON3 map[string]interface{}
  3592. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3595. return
  3596. }
  3597. userJSONBytes3, _ := json.Marshal(respJSON3)
  3598. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3599. // utils.ErrorLog("解析失败:%v", err)
  3600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3601. // return
  3602. //}
  3603. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3604. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3605. utils.ErrorLog("解析失败:%v", err)
  3606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3607. return
  3608. }
  3609. //if res3507for10188.Infcode
  3610. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3611. //res.Output = resSix10265.Output
  3612. res3.ErrMsg = res3507for10188.ErrMsg
  3613. res3.Cainfo = res3507for10188.Cainfo
  3614. res3.WarnMsg = res3507for10188.WarnMsg
  3615. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3616. res3.Infcode = infocode
  3617. } else {
  3618. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3619. utils.ErrorLog("解析失败:%v", err)
  3620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3621. return
  3622. }
  3623. }
  3624. if res3.Infcode == 0 {
  3625. item.IsChange = 1
  3626. item.BgBchno = bg_number
  3627. service.SaveDF2(item)
  3628. } else {
  3629. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3630. }
  3631. }
  3632. }
  3633. }
  3634. }
  3635. if len(err) == 0 {
  3636. c.ServeSuccessJSON(map[string]interface{}{
  3637. "msg": "销售变更成功",
  3638. })
  3639. } else {
  3640. c.ServeSuccessJSON(map[string]interface{}{
  3641. "failed_code": -10,
  3642. "msg": err,
  3643. })
  3644. }
  3645. }
  3646. func (c *HisApiController) ChangeDrugtwo() {
  3647. //ids := c.GetString("ids")
  3648. //id_arr := strings.Split(ids, ",")
  3649. flows, _ := service.GetNewDrugFlowInfothree123()
  3650. admin_user_id, _ := c.GetInt64("admin_user_id")
  3651. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3652. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3653. var err []string
  3654. for _, item := range flows {
  3655. var res3 ResultSix
  3656. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3657. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3658. if prescription.OrderStatus == 2 {
  3659. //已经结算
  3660. //判断是否已经销售
  3661. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3662. // //是否已经变更 1是 0否
  3663. // if item.IsChange == 0 { //没变更,进行变更操作
  3664. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3665. //
  3666. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3667. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3668. // var respJSON3 map[string]interface{}
  3669. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3670. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3671. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3672. // return
  3673. // }
  3674. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3675. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3676. // utils.ErrorLog("解析失败:%v", err)
  3677. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3678. // return
  3679. // }
  3680. // if res3.Infcode == 0 {
  3681. // item.IsChange = 1
  3682. // item.BgBchno = bg_number
  3683. // service.SaveDF2(item)
  3684. // } else {
  3685. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3686. // }
  3687. // }
  3688. //}
  3689. //else
  3690. { //没销售,
  3691. var res FJ3507Result
  3692. var res3507for10188 FJ3507ResultFor10188
  3693. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3694. //进行商品销售接口
  3695. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3696. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3697. var respJSON3 map[string]interface{}
  3698. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3701. return
  3702. }
  3703. userJSONBytes3, _ := json.Marshal(respJSON3)
  3704. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3705. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3706. utils.ErrorLog("解析失败:%v", err)
  3707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3708. return
  3709. }
  3710. //if res3507for10188.Infcode
  3711. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3712. //res.Output = resSix10265.Output
  3713. res.ErrMsg = res3507for10188.ErrMsg
  3714. res.Cainfo = res3507for10188.Cainfo
  3715. res.WarnMsg = res3507for10188.WarnMsg
  3716. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3717. res.Infcode = infocode
  3718. } else {
  3719. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3720. utils.ErrorLog("解析失败:%v", err)
  3721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3722. return
  3723. }
  3724. }
  3725. if res.Infcode == 0 {
  3726. item.IsSale = 1
  3727. item.Bchno = number
  3728. item.SaleDate = time.Now().Format("2006-01-02")
  3729. service.SaveDF(item)
  3730. //if err5 == nil {
  3731. // if item.IsChange == 0 { //没变更,进行变更操作
  3732. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3733. //
  3734. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3735. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3736. //
  3737. // var respJSON3 map[string]interface{}
  3738. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3739. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3740. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3741. // return
  3742. // }
  3743. //
  3744. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3745. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3746. // utils.ErrorLog("解析失败:%v", err)
  3747. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3748. // return
  3749. // }
  3750. // //if res3507for10188.Infcode
  3751. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3752. // //res.Output = resSix10265.Output
  3753. // res3.ErrMsg = res3507for10188.ErrMsg
  3754. // res3.Cainfo = res3507for10188.Cainfo
  3755. // res3.WarnMsg = res3507for10188.WarnMsg
  3756. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3757. // res3.Infcode = infocode
  3758. // } else {
  3759. //
  3760. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3761. // utils.ErrorLog("解析失败:%v", err)
  3762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3763. // return
  3764. // }
  3765. //
  3766. // }
  3767. //
  3768. // if res3.Infcode == 0 {
  3769. // item.IsChange = 1
  3770. // item.BgBchno = bg_number
  3771. // service.SaveDF2(item)
  3772. // } else {
  3773. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3774. // }
  3775. // }
  3776. //}
  3777. } else {
  3778. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3779. }
  3780. }
  3781. } else { //还没结算
  3782. var res3507for10188 FJ3507ResultFor10188
  3783. if item.IsChange == 0 { //没变更,进行变更操作
  3784. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3785. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3786. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3787. var respJSON3 map[string]interface{}
  3788. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3791. return
  3792. }
  3793. userJSONBytes3, _ := json.Marshal(respJSON3)
  3794. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3795. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3796. utils.ErrorLog("解析失败:%v", err)
  3797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3798. return
  3799. }
  3800. //if res3507for10188.Infcode
  3801. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3802. //res.Output = resSix10265.Output
  3803. res3.ErrMsg = res3507for10188.ErrMsg
  3804. res3.Cainfo = res3507for10188.Cainfo
  3805. res3.WarnMsg = res3507for10188.WarnMsg
  3806. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3807. res3.Infcode = infocode
  3808. } else {
  3809. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3810. utils.ErrorLog("解析失败:%v", err)
  3811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3812. return
  3813. }
  3814. }
  3815. if res3.Infcode == 0 {
  3816. item.IsChange = 1
  3817. item.BgBchno = bg_number
  3818. service.SaveDF2(item)
  3819. } else {
  3820. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3821. }
  3822. }
  3823. }
  3824. }
  3825. //if item.ConsumableType == 7 {
  3826. // var res3507for10188 FJ3507ResultFor10188
  3827. //
  3828. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3829. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3830. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3831. // //判断是否已经销售
  3832. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3833. // //是否已经变更 1是 0否
  3834. // if item.IsChange == 0 { //没变更,进行变更操作
  3835. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3836. //
  3837. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3838. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3839. //
  3840. // var respJSON3 map[string]interface{}
  3841. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3842. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3843. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3844. // return
  3845. // }
  3846. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3847. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3848. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3849. // utils.ErrorLog("解析失败:%v", err)
  3850. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3851. // return
  3852. // }
  3853. // //if res3507for10188.Infcode
  3854. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3855. // //res.Output = resSix10265.Output
  3856. // res3.ErrMsg = res3507for10188.ErrMsg
  3857. // res3.Cainfo = res3507for10188.Cainfo
  3858. // res3.WarnMsg = res3507for10188.WarnMsg
  3859. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3860. // res3.Infcode = infocode
  3861. // } else {
  3862. //
  3863. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3864. // utils.ErrorLog("解析失败:%v", err)
  3865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3866. // return
  3867. // }
  3868. //
  3869. // }
  3870. // if res3.Infcode == 0 {
  3871. // item.IsChange = 1
  3872. // item.BgBchno = bg_number
  3873. // service.SaveDF2(item)
  3874. // } else {
  3875. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3876. // }
  3877. // }
  3878. // } else { //没销售,
  3879. // //进行商品销售退货接口
  3880. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3881. //
  3882. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3883. // saveLog(result111, result222, "3506", "销售退货")
  3884. // var res7 FJ3507Result
  3885. //
  3886. // //进行商品销售接口
  3887. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3888. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3889. // var respJSON3 map[string]interface{}
  3890. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3891. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3893. // return
  3894. // }
  3895. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3896. //
  3897. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3898. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3899. // utils.ErrorLog("解析失败:%v", err)
  3900. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3901. // return
  3902. // }
  3903. // //if res3507for10188.Infcode
  3904. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3905. // //res.Output = resSix10265.Output
  3906. // res7.ErrMsg = res3507for10188.ErrMsg
  3907. // res7.Cainfo = res3507for10188.Cainfo
  3908. // res7.WarnMsg = res3507for10188.WarnMsg
  3909. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3910. // res7.Infcode = infocode
  3911. // } else {
  3912. //
  3913. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3914. // utils.ErrorLog("解析失败:%v", err)
  3915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3916. // return
  3917. // }
  3918. //
  3919. // }
  3920. // if res7.Infcode == 0 {
  3921. // item.IsSale = 2
  3922. // item.SaleDate = item.SaleDate
  3923. // item.Bchno = number
  3924. // service.SaveDF(item)
  3925. // if item.IsChange == 0 { //没变更,进行变更操作
  3926. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3927. //
  3928. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3929. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3930. //
  3931. // var respJSON3 map[string]interface{}
  3932. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3933. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3935. // return
  3936. // }
  3937. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3938. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3939. // // utils.ErrorLog("解析失败:%v", err)
  3940. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3941. // // return
  3942. // //}
  3943. //
  3944. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3945. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3946. // utils.ErrorLog("解析失败:%v", err)
  3947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3948. // return
  3949. // }
  3950. // //if res3507for10188.Infcode
  3951. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3952. // //res.Output = resSix10265.Output
  3953. // res3.ErrMsg = res3507for10188.ErrMsg
  3954. // res3.Cainfo = res3507for10188.Cainfo
  3955. // res3.WarnMsg = res3507for10188.WarnMsg
  3956. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3957. // res3.Infcode = infocode
  3958. // } else {
  3959. //
  3960. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3961. // utils.ErrorLog("解析失败:%v", err)
  3962. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3963. // return
  3964. // }
  3965. //
  3966. // }
  3967. // if res3.Infcode == 0 {
  3968. // item.IsChange = 1
  3969. // item.BgBchno = bg_number
  3970. // service.SaveDF2(item)
  3971. // } else {
  3972. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3973. // }
  3974. // }
  3975. // } else {
  3976. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3977. // }
  3978. // }
  3979. // } else { //还没结算
  3980. // if item.IsChange == 0 { //没变更,进行变更操作
  3981. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3982. //
  3983. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3984. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3985. //
  3986. // var respJSON3 map[string]interface{}
  3987. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3988. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3989. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3990. // return
  3991. // }
  3992. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3993. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3994. // // utils.ErrorLog("解析失败:%v", err)
  3995. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3996. // // return
  3997. // //}
  3998. //
  3999. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  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 {
  4014. //
  4015. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4016. // utils.ErrorLog("解析失败:%v", err)
  4017. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4018. // return
  4019. // }
  4020. //
  4021. // }
  4022. // if res3.Infcode == 0 {
  4023. // item.IsChange = 1
  4024. // item.BgBchno = bg_number
  4025. // service.SaveDF2(item)
  4026. // } else {
  4027. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4028. // }
  4029. // }
  4030. // }
  4031. //}
  4032. }
  4033. if len(err) == 0 {
  4034. c.ServeSuccessJSON(map[string]interface{}{
  4035. "msg": "销售变更成功",
  4036. })
  4037. } else {
  4038. c.ServeSuccessJSON(map[string]interface{}{
  4039. "failed_code": -10,
  4040. "msg": err,
  4041. })
  4042. }
  4043. }
  4044. func (c *HisApiController) ChangeDrugthree() {
  4045. //ids := c.GetString("ids")
  4046. //id_arr := strings.Split(ids, ",")
  4047. flows, _ := service.GetNewDrugFlowInfothree()
  4048. admin_user_id, _ := c.GetInt64("admin_user_id")
  4049. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4050. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4051. var err []string
  4052. for _, item := range flows {
  4053. var res3 ResultSix
  4054. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4055. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4056. if prescription.OrderStatus == 2 {
  4057. //已经结算
  4058. //判断是否已经销售
  4059. if item.IsSale == 1 { //是否已经销售,1是 0否
  4060. //是否已经变更 1是 0否
  4061. if item.IsChange == 0 { //没变更,进行变更操作
  4062. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4063. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4064. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4065. var respJSON3 map[string]interface{}
  4066. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4069. return
  4070. }
  4071. userJSONBytes3, _ := json.Marshal(respJSON3)
  4072. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4073. utils.ErrorLog("解析失败:%v", err)
  4074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4075. return
  4076. }
  4077. if res3.Infcode == 0 {
  4078. item.IsChange = 1
  4079. item.BgBchno = bg_number
  4080. service.SaveDF2(item)
  4081. } else {
  4082. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4083. }
  4084. }
  4085. } else { //没销售,
  4086. var res FJ3507Result
  4087. var res3507for10188 FJ3507ResultFor10188
  4088. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4089. //进行商品销售接口
  4090. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4091. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4092. var respJSON3 map[string]interface{}
  4093. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4096. return
  4097. }
  4098. userJSONBytes3, _ := json.Marshal(respJSON3)
  4099. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4100. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4101. utils.ErrorLog("解析失败:%v", err)
  4102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4103. return
  4104. }
  4105. //if res3507for10188.Infcode
  4106. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4107. //res.Output = resSix10265.Output
  4108. res.ErrMsg = res3507for10188.ErrMsg
  4109. res.Cainfo = res3507for10188.Cainfo
  4110. res.WarnMsg = res3507for10188.WarnMsg
  4111. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4112. res.Infcode = infocode
  4113. } else {
  4114. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4115. utils.ErrorLog("解析失败:%v", err)
  4116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4117. return
  4118. }
  4119. }
  4120. if res.Infcode == 0 {
  4121. item.IsSale = 1
  4122. item.Bchno = number
  4123. item.SaleDate = time.Now().Format("2006-01-02")
  4124. err5 := service.SaveDF(item)
  4125. if err5 == nil {
  4126. if item.IsChange == 0 { //没变更,进行变更操作
  4127. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4128. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4129. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4130. var respJSON3 map[string]interface{}
  4131. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4134. return
  4135. }
  4136. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4137. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4138. utils.ErrorLog("解析失败:%v", err)
  4139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4140. return
  4141. }
  4142. //if res3507for10188.Infcode
  4143. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4144. //res.Output = resSix10265.Output
  4145. res3.ErrMsg = res3507for10188.ErrMsg
  4146. res3.Cainfo = res3507for10188.Cainfo
  4147. res3.WarnMsg = res3507for10188.WarnMsg
  4148. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4149. res3.Infcode = infocode
  4150. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4151. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4152. utils.ErrorLog("解析失败:%v", err)
  4153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4154. return
  4155. }
  4156. //if res3507for10188.Infcode
  4157. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4158. //res.Output = resSix10265.Output
  4159. res3.ErrMsg = res3507for10188.ErrMsg
  4160. res3.Cainfo = res3507for10188.Cainfo
  4161. res3.WarnMsg = res3507for10188.WarnMsg
  4162. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4163. res3.Infcode = infocode
  4164. } else {
  4165. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4166. utils.ErrorLog("解析失败:%v", err)
  4167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4168. return
  4169. }
  4170. }
  4171. if res3.Infcode == 0 {
  4172. item.IsChange = 1
  4173. item.BgBchno = bg_number
  4174. service.SaveDF2(item)
  4175. } else {
  4176. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4177. }
  4178. }
  4179. }
  4180. } else {
  4181. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4182. }
  4183. }
  4184. } else { //还没结算
  4185. var res3507for10188 FJ3507ResultFor10188
  4186. if item.IsChange == 0 { //没变更,进行变更操作
  4187. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4188. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4189. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4190. var respJSON3 map[string]interface{}
  4191. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4194. return
  4195. }
  4196. userJSONBytes3, _ := json.Marshal(respJSON3)
  4197. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4198. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4199. utils.ErrorLog("解析失败:%v", err)
  4200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4201. return
  4202. }
  4203. //if res3507for10188.Infcode
  4204. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4205. //res.Output = resSix10265.Output
  4206. res3.ErrMsg = res3507for10188.ErrMsg
  4207. res3.Cainfo = res3507for10188.Cainfo
  4208. res3.WarnMsg = res3507for10188.WarnMsg
  4209. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4210. res3.Infcode = infocode
  4211. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4212. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4213. utils.ErrorLog("解析失败:%v", err)
  4214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4215. return
  4216. }
  4217. //if res3507for10188.Infcode
  4218. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4219. //res.Output = resSix10265.Output
  4220. res3.ErrMsg = res3507for10188.ErrMsg
  4221. res3.Cainfo = res3507for10188.Cainfo
  4222. res3.WarnMsg = res3507for10188.WarnMsg
  4223. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4224. res3.Infcode = infocode
  4225. } else {
  4226. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4227. utils.ErrorLog("解析失败:%v", err)
  4228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4229. return
  4230. }
  4231. }
  4232. if res3.Infcode == 0 {
  4233. item.IsChange = 1
  4234. item.BgBchno = bg_number
  4235. service.SaveDF2(item)
  4236. } else {
  4237. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4238. }
  4239. }
  4240. }
  4241. } else if item.ConsumableType == 7 {
  4242. var res3507for10188 FJ3507ResultFor10188
  4243. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4244. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4245. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4246. //判断是否已经销售
  4247. if item.IsSale == 2 { //是否已经销售,1是 0否
  4248. //是否已经变更 1是 0否
  4249. if item.IsChange == 0 { //没变更,进行变更操作
  4250. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4251. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4252. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4253. var respJSON3 map[string]interface{}
  4254. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4257. return
  4258. }
  4259. userJSONBytes3, _ := json.Marshal(respJSON3)
  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. } else { //没销售,
  4290. //进行商品销售退货接口
  4291. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4292. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4293. saveLog(result111, result222, "3506", "销售退货")
  4294. var res7 FJ3507Result
  4295. //进行商品销售接口
  4296. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4297. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4298. var respJSON3 map[string]interface{}
  4299. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4302. return
  4303. }
  4304. userJSONBytes3, _ := json.Marshal(respJSON3)
  4305. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4306. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4307. utils.ErrorLog("解析失败:%v", err)
  4308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4309. return
  4310. }
  4311. //if res3507for10188.Infcode
  4312. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4313. //res.Output = resSix10265.Output
  4314. res7.ErrMsg = res3507for10188.ErrMsg
  4315. res7.Cainfo = res3507for10188.Cainfo
  4316. res7.WarnMsg = res3507for10188.WarnMsg
  4317. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4318. res7.Infcode = infocode
  4319. } else {
  4320. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4321. utils.ErrorLog("解析失败:%v", err)
  4322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4323. return
  4324. }
  4325. }
  4326. if res7.Infcode == 0 {
  4327. item.IsSale = 2
  4328. item.SaleDate = item.SaleDate
  4329. item.Bchno = number
  4330. service.SaveDF(item)
  4331. if item.IsChange == 0 { //没变更,进行变更操作
  4332. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4333. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4334. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4335. var respJSON3 map[string]interface{}
  4336. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4339. return
  4340. }
  4341. userJSONBytes3, _ := json.Marshal(respJSON3)
  4342. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4343. // utils.ErrorLog("解析失败:%v", err)
  4344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4345. // return
  4346. //}
  4347. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4348. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4349. utils.ErrorLog("解析失败:%v", err)
  4350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4351. return
  4352. }
  4353. //if res3507for10188.Infcode
  4354. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4355. //res.Output = resSix10265.Output
  4356. res3.ErrMsg = res3507for10188.ErrMsg
  4357. res3.Cainfo = res3507for10188.Cainfo
  4358. res3.WarnMsg = res3507for10188.WarnMsg
  4359. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4360. res3.Infcode = infocode
  4361. } else {
  4362. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4363. utils.ErrorLog("解析失败:%v", err)
  4364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4365. return
  4366. }
  4367. }
  4368. if res3.Infcode == 0 {
  4369. item.IsChange = 1
  4370. item.BgBchno = bg_number
  4371. service.SaveDF2(item)
  4372. } else {
  4373. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4374. }
  4375. }
  4376. } else {
  4377. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4378. }
  4379. }
  4380. } else { //还没结算
  4381. if item.IsChange == 0 { //没变更,进行变更操作
  4382. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4383. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4384. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4385. var respJSON3 map[string]interface{}
  4386. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4389. return
  4390. }
  4391. userJSONBytes3, _ := json.Marshal(respJSON3)
  4392. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4393. // utils.ErrorLog("解析失败:%v", err)
  4394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4395. // return
  4396. //}
  4397. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4398. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4399. utils.ErrorLog("解析失败:%v", err)
  4400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4401. return
  4402. }
  4403. //if res3507for10188.Infcode
  4404. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4405. //res.Output = resSix10265.Output
  4406. res3.ErrMsg = res3507for10188.ErrMsg
  4407. res3.Cainfo = res3507for10188.Cainfo
  4408. res3.WarnMsg = res3507for10188.WarnMsg
  4409. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4410. res3.Infcode = infocode
  4411. } else {
  4412. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4413. utils.ErrorLog("解析失败:%v", err)
  4414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4415. return
  4416. }
  4417. }
  4418. if res3.Infcode == 0 {
  4419. item.IsChange = 1
  4420. item.BgBchno = bg_number
  4421. service.SaveDF2(item)
  4422. } else {
  4423. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4424. }
  4425. }
  4426. }
  4427. }
  4428. }
  4429. if len(err) == 0 {
  4430. c.ServeSuccessJSON(map[string]interface{}{
  4431. "msg": "销售变更成功",
  4432. })
  4433. } else {
  4434. c.ServeSuccessJSON(map[string]interface{}{
  4435. "failed_code": -10,
  4436. "msg": err,
  4437. })
  4438. }
  4439. }
  4440. func (c *HisApiController) ChangeDrugTen() {
  4441. start_time_str := c.GetString("start_time")
  4442. end_time_str := c.GetString("end_time")
  4443. //ids := c.GetString("ids")
  4444. //id_arr := strings.Split(ids, ",")
  4445. timeLayout := "2006-01-02"
  4446. loc, _ := time.LoadLocation("Local")
  4447. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4448. recordStartTime := theStartTime.Unix()
  4449. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4450. recordEndTime := theEndTime.Unix()
  4451. //timestamp := int64(1729612800)
  4452. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4453. admin_user_id, _ := c.GetInt64("admin_user_id")
  4454. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4455. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4456. var err []string
  4457. for _, item := range flows {
  4458. var res3 ResultSix
  4459. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4460. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4461. continue
  4462. }
  4463. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4464. continue
  4465. }
  4466. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4467. if prescription.OrderStatus == 2 {
  4468. //已经结算
  4469. //判断 是否已经销售
  4470. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4471. ////是否已经变更 1是 0否
  4472. //if item.IsChange == 0 { //没变更,进行变更操作
  4473. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4474. //
  4475. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4476. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4477. // var respJSON3 map[string]interface{}
  4478. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4479. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4481. // return
  4482. // }
  4483. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4484. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4485. // utils.ErrorLog("解析失败:%v", err)
  4486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4487. // return
  4488. // }
  4489. // if res3.Infcode == 0 {
  4490. // item.IsChange = 1
  4491. // item.BgBchno = bg_number
  4492. // service.SaveDF2(item)
  4493. // } else {
  4494. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4495. // }
  4496. //}
  4497. //} else
  4498. if item.IsSale == 0 { //没销售,
  4499. var res FJ3507Result
  4500. var res3507for10188 FJ3507ResultFor10188
  4501. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4502. //进行商品销售接口
  4503. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4504. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4505. var respJSON3 map[string]interface{}
  4506. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4509. return
  4510. }
  4511. userJSONBytes3, _ := json.Marshal(respJSON3)
  4512. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4513. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4514. utils.ErrorLog("解析失败:%v", err)
  4515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4516. return
  4517. }
  4518. //if res3507for10188.Infcode
  4519. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4520. //res.Output = resSix10265.Output
  4521. res.ErrMsg = res3507for10188.ErrMsg
  4522. res.Cainfo = res3507for10188.Cainfo
  4523. res.WarnMsg = res3507for10188.WarnMsg
  4524. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4525. res.Infcode = infocode
  4526. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4527. } else {
  4528. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4529. utils.ErrorLog("解析失败:%v", err)
  4530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4531. return
  4532. }
  4533. }
  4534. if res.Infcode == 0 {
  4535. item.IsSale = 1
  4536. item.Bchno = number
  4537. item.SaleDate = time.Now().Format("2006-01-02")
  4538. err5 := service.SaveDF(item)
  4539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4540. //if err5 == nil {
  4541. //
  4542. // if item.IsChange == 1 { //没变更,进行变更操作
  4543. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4544. //
  4545. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4546. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4547. //
  4548. // var respJSON3 map[string]interface{}
  4549. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4550. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4552. // return
  4553. // }
  4554. //
  4555. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4556. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4557. // utils.ErrorLog("解析失败:%v", err)
  4558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4559. // return
  4560. // }
  4561. // //if res3507for10188.Infcode
  4562. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4563. // //res.Output = resSix10265.Output
  4564. // res3.ErrMsg = res3507for10188.ErrMsg
  4565. // res3.Cainfo = res3507for10188.Cainfo
  4566. // res3.WarnMsg = res3507for10188.WarnMsg
  4567. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4568. // res3.Infcode = infocode
  4569. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4570. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4571. // utils.ErrorLog("解析失败:%v", err)
  4572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4573. // return
  4574. // }
  4575. // //if res3507for10188.Infcode
  4576. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4577. // //res.Output = resSix10265.Output
  4578. // res3.ErrMsg = res3507for10188.ErrMsg
  4579. // res3.Cainfo = res3507for10188.Cainfo
  4580. // res3.WarnMsg = res3507for10188.WarnMsg
  4581. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4582. // res3.Infcode = infocode
  4583. //
  4584. // } else {
  4585. //
  4586. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4587. // utils.ErrorLog("解析失败:%v", err)
  4588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4589. // return
  4590. // }
  4591. //
  4592. // }
  4593. //
  4594. // if res3.Infcode == 0 {
  4595. // item.IsChange = 1
  4596. // item.BgBchno = bg_number
  4597. // service.SaveDF2(item)
  4598. // return
  4599. // } else {
  4600. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4601. // }
  4602. // }
  4603. //}
  4604. } else {
  4605. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4606. }
  4607. }
  4608. }
  4609. } else if item.ConsumableType == 7 {
  4610. var res3507for10188 FJ3507ResultFor10188
  4611. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4612. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4613. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4614. //判断是否已经销售
  4615. if item.IsSale == 2 { //是否已经销售,1是 0否
  4616. //是否已经变更 1是 0否
  4617. if item.IsChange == 0 { //没变更,进行变更操作
  4618. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4619. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4620. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4621. var respJSON3 map[string]interface{}
  4622. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4625. return
  4626. }
  4627. userJSONBytes3, _ := json.Marshal(respJSON3)
  4628. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4629. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4630. utils.ErrorLog("解析失败:%v", err)
  4631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4632. return
  4633. }
  4634. //if res3507for10188.Infcode
  4635. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4636. //res.Output = resSix10265.Output
  4637. res3.ErrMsg = res3507for10188.ErrMsg
  4638. res3.Cainfo = res3507for10188.Cainfo
  4639. res3.WarnMsg = res3507for10188.WarnMsg
  4640. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4641. res3.Infcode = infocode
  4642. } else {
  4643. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4644. utils.ErrorLog("解析失败:%v", err)
  4645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4646. return
  4647. }
  4648. }
  4649. if res3.Infcode == 0 {
  4650. item.IsChange = 1
  4651. item.BgBchno = bg_number
  4652. service.SaveDF2(item)
  4653. } else {
  4654. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4655. }
  4656. }
  4657. } else { //没销售,
  4658. //进行商品销售退货接口
  4659. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4660. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4661. saveLog(result111, result222, "3506", "销售退货")
  4662. var res7 FJ3507Result
  4663. //进行商品销售接口
  4664. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4665. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4666. var respJSON3 map[string]interface{}
  4667. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4670. return
  4671. }
  4672. userJSONBytes3, _ := json.Marshal(respJSON3)
  4673. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4674. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4675. utils.ErrorLog("解析失败:%v", err)
  4676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4677. return
  4678. }
  4679. //if res3507for10188.Infcode
  4680. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4681. //res.Output = resSix10265.Output
  4682. res7.ErrMsg = res3507for10188.ErrMsg
  4683. res7.Cainfo = res3507for10188.Cainfo
  4684. res7.WarnMsg = res3507for10188.WarnMsg
  4685. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4686. res7.Infcode = infocode
  4687. } else {
  4688. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4689. utils.ErrorLog("解析失败:%v", err)
  4690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4691. return
  4692. }
  4693. }
  4694. if res7.Infcode == 0 {
  4695. item.IsSale = 2
  4696. item.SaleDate = item.SaleDate
  4697. item.Bchno = number
  4698. service.SaveDF(item)
  4699. if item.IsChange == 0 { //没变更,进行变更操作
  4700. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4701. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4702. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4703. var respJSON3 map[string]interface{}
  4704. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4707. return
  4708. }
  4709. userJSONBytes3, _ := json.Marshal(respJSON3)
  4710. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4711. // utils.ErrorLog("解析失败:%v", err)
  4712. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4713. // return
  4714. //}
  4715. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4716. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4717. utils.ErrorLog("解析失败:%v", err)
  4718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4719. return
  4720. }
  4721. //if res3507for10188.Infcode
  4722. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4723. //res.Output = resSix10265.Output
  4724. res3.ErrMsg = res3507for10188.ErrMsg
  4725. res3.Cainfo = res3507for10188.Cainfo
  4726. res3.WarnMsg = res3507for10188.WarnMsg
  4727. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4728. res3.Infcode = infocode
  4729. } else {
  4730. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4731. utils.ErrorLog("解析失败:%v", err)
  4732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4733. return
  4734. }
  4735. }
  4736. if res3.Infcode == 0 {
  4737. item.IsChange = 1
  4738. item.BgBchno = bg_number
  4739. service.SaveDF2(item)
  4740. } else {
  4741. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4742. }
  4743. }
  4744. } else {
  4745. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4746. }
  4747. }
  4748. } else { //还没结算
  4749. if item.IsChange == 0 { //没变更,进行变更操作
  4750. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4751. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4752. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4753. var respJSON3 map[string]interface{}
  4754. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4757. return
  4758. }
  4759. userJSONBytes3, _ := json.Marshal(respJSON3)
  4760. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4761. // utils.ErrorLog("解析失败:%v", err)
  4762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4763. // return
  4764. //}
  4765. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4766. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4767. utils.ErrorLog("解析失败:%v", err)
  4768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4769. return
  4770. }
  4771. //if res3507for10188.Infcode
  4772. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4773. //res.Output = resSix10265.Output
  4774. res3.ErrMsg = res3507for10188.ErrMsg
  4775. res3.Cainfo = res3507for10188.Cainfo
  4776. res3.WarnMsg = res3507for10188.WarnMsg
  4777. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4778. res3.Infcode = infocode
  4779. } else {
  4780. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4781. utils.ErrorLog("解析失败:%v", err)
  4782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4783. return
  4784. }
  4785. }
  4786. if res3.Infcode == 0 {
  4787. item.IsChange = 1
  4788. item.BgBchno = bg_number
  4789. service.SaveDF2(item)
  4790. } else {
  4791. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4792. }
  4793. }
  4794. }
  4795. }
  4796. }
  4797. if len(err) == 0 {
  4798. c.ServeSuccessJSON(map[string]interface{}{
  4799. "msg": "销售变更成功",
  4800. })
  4801. } else {
  4802. c.ServeSuccessJSON(map[string]interface{}{
  4803. "failed_code": -10,
  4804. "msg": err,
  4805. })
  4806. }
  4807. }
  4808. func ChangeDrugTenone() {
  4809. //ids := c.GetString("ids")
  4810. //id_arr := strings.Split(ids, ",")
  4811. now := time.Now()
  4812. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4813. //timestamp := int64(1729612800)
  4814. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4815. admin_user_id := int64(2463)
  4816. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4817. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4818. var err []string
  4819. for _, item := range flows {
  4820. var res3 ResultSix
  4821. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4822. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4823. continue
  4824. }
  4825. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4826. continue
  4827. }
  4828. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4829. if prescription.OrderStatus == 2 {
  4830. //已经结算
  4831. //判断是否已经销售
  4832. if item.IsSale == 1 { //是否已经销售,1是 0否
  4833. //是否已经变更 1是 0否
  4834. if item.IsChange == 0 { //没变更,进行变更操作
  4835. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4836. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4837. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4838. var respJSON3 map[string]interface{}
  4839. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4841. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4842. return
  4843. }
  4844. userJSONBytes3, _ := json.Marshal(respJSON3)
  4845. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4846. utils.ErrorLog("解析失败:%v", err)
  4847. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4848. return
  4849. }
  4850. if res3.Infcode == 0 {
  4851. item.IsChange = 1
  4852. item.BgBchno = bg_number
  4853. service.SaveDF2(item)
  4854. } else {
  4855. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4856. }
  4857. }
  4858. } else { //没销售,
  4859. var res FJ3507Result
  4860. var res3507for10188 FJ3507ResultFor10188
  4861. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4862. //进行商品销售接口
  4863. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4864. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4865. var respJSON3 map[string]interface{}
  4866. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4868. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4869. return
  4870. }
  4871. userJSONBytes3, _ := json.Marshal(respJSON3)
  4872. {
  4873. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4874. utils.ErrorLog("解析失败:%v", err)
  4875. return
  4876. }
  4877. //if res3507for10188.Infcode
  4878. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4879. //res.Output = resSix10265.Output
  4880. res.ErrMsg = res3507for10188.ErrMsg
  4881. res.Cainfo = res3507for10188.Cainfo
  4882. res.WarnMsg = res3507for10188.WarnMsg
  4883. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4884. res.Infcode = infocode
  4885. }
  4886. if res.Infcode == 0 {
  4887. item.IsSale = 1
  4888. item.Bchno = number
  4889. item.SaleDate = time.Now().Format("2006-01-02")
  4890. err5 := service.SaveDF(item)
  4891. if err5 == nil {
  4892. if item.IsChange == 1 { //没变更,进行变更操作
  4893. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4894. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4895. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4896. var respJSON3 map[string]interface{}
  4897. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4899. return
  4900. }
  4901. {
  4902. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4903. utils.ErrorLog("解析失败:%v", err)
  4904. return
  4905. }
  4906. //if res3507for10188.Infcode
  4907. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4908. //res.Output = resSix10265.Output
  4909. res3.ErrMsg = res3507for10188.ErrMsg
  4910. res3.Cainfo = res3507for10188.Cainfo
  4911. res3.WarnMsg = res3507for10188.WarnMsg
  4912. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4913. res3.Infcode = infocode
  4914. }
  4915. if res3.Infcode == 0 {
  4916. item.IsChange = 1
  4917. item.BgBchno = bg_number
  4918. service.SaveDF2(item)
  4919. } else {
  4920. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4921. }
  4922. }
  4923. }
  4924. } else {
  4925. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4926. }
  4927. }
  4928. }
  4929. }
  4930. }
  4931. }
  4932. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4933. var struct3502 models.Struct3502
  4934. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4935. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4936. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4937. struct3502.FixmedinsCode = miConfig.Code
  4938. struct3502.Code = miConfig.Code
  4939. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4940. struct3502.Opter = role.UserName
  4941. struct3502.RxFlag = "1"
  4942. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4943. struct3502.OrgName = miConfig.OrgName
  4944. struct3502.AccessKey = miConfig.AccessKey
  4945. struct3502.RequestUrl = miConfig.Url
  4946. struct3502.SecretKey = miConfig.SecretKey
  4947. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4948. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4949. struct3502.Url = miConfig.Url
  4950. struct3502.AppId = miConfig.Cainfo
  4951. struct3502.AppSecret = miConfig.AppSecret
  4952. struct3502.Enckey = miConfig.EncKey
  4953. struct3502.SignKey = miConfig.SignKey
  4954. struct3502.SecretKey = miConfig.SecretKey
  4955. struct3502.InvChgType = chgType
  4956. struct3502.FixmedinsBchno = number
  4957. struct3502.Cnt = strconv.FormatInt(count, 10)
  4958. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4959. //result1, result2, _ := service.FJyb3502(struct3502)
  4960. if miConfig.MdtrtareaAdmvs == "350500" {
  4961. result1, result2, _ := service.FJyb3502(struct3502)
  4962. //saveLog(result1, result2, "3502", "3502")
  4963. return result1, result2
  4964. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4965. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4966. return result1, result2
  4967. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4968. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4969. return result1, result2
  4970. } else {
  4971. data := make(map[string]interface{})
  4972. data["struct_3502s"] = struct3502
  4973. client := &http.Client{}
  4974. bytesData, _ := json.Marshal(data)
  4975. var req *http.Request
  4976. if miConfig.MdtrtareaAdmvs == "320921" {
  4977. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4978. } else {
  4979. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4980. }
  4981. resp, _ := client.Do(req)
  4982. defer resp.Body.Close()
  4983. body, ioErr := ioutil.ReadAll(resp.Body)
  4984. if ioErr != nil {
  4985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4986. }
  4987. var respJSON map[string]interface{}
  4988. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4990. }
  4991. //var resSix10265 ResultSix10265 //1101结果
  4992. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4993. result, _ := json.Marshal(respJSON)
  4994. return string(result), ""
  4995. }
  4996. }
  4997. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4998. var struct3505 models.Struct3505
  4999. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5000. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5001. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5002. struct3505.FixmedinsBchno = number
  5003. struct3505.Opter = role.UserName
  5004. struct3505.Bchno = "---"
  5005. struct3505.FixmedinsCode = miConfig.Code
  5006. struct3505.Code = miConfig.Code
  5007. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.HisDoctorAdviceInfo.Price, 'f', -1, 64)
  5008. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5009. struct3505.PrscDrName = roles.UserName
  5010. if org_id == 10191 {
  5011. struct3505.PharName = "刘水山"
  5012. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5013. }
  5014. if org_id == 10188 {
  5015. struct3505.PharName = "李汉清"
  5016. struct3505.PharPracCertNo = "30220200932022010034"
  5017. }
  5018. if org_id == 10217 {
  5019. struct3505.PharName = "张敏"
  5020. struct3505.PharPracCertNo = "30220230432090100108"
  5021. }
  5022. if org_id == 10318 {
  5023. struct3505.PharName = "邹刘阳"
  5024. struct3505.PharPracCertNo = "210441200001378"
  5025. }
  5026. if org_id == 10402 {
  5027. struct3505.PharName = "刘韶健"
  5028. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5029. }
  5030. if org_id == 9919 {
  5031. struct3505.PharName = "周君权"
  5032. struct3505.PharPracCertNo = "089644396094401375"
  5033. }
  5034. if org_id == 10644 {
  5035. struct3505.PharName = "陈金娣"
  5036. struct3505.PharPracCertNo = "20181441500320100066"
  5037. }
  5038. if org_id == 10567 {
  5039. struct3505.PharName = "范小兰"
  5040. struct3505.PharPracCertNo = "0200102079485"
  5041. }
  5042. if org_id == 10721 {
  5043. struct3505.PharName = "孙莉侠"
  5044. struct3505.PharPracCertNo = "060399"
  5045. }
  5046. if org_id == 10726 {
  5047. struct3505.PharName = "彭建福"
  5048. struct3505.PharPracCertNo = "D445281006261"
  5049. }
  5050. if org_id == 10265 {
  5051. struct3505.PharName = "李彩星"
  5052. struct3505.PharPracCertNo = "20171110600110100019"
  5053. }
  5054. if org_id == 10028 {
  5055. struct3505.PharName = "曾细平"
  5056. struct3505.PharPracCertNo = "D440307022134"
  5057. }
  5058. if org_id == 10138 {
  5059. struct3505.PharName = "彭斯遥"
  5060. struct3505.PharPracCertNo = "30220200943042010052"
  5061. }
  5062. if org_id == 10278 {
  5063. struct3505.PharName = "彭斯遥"
  5064. struct3505.PharPracCertNo = "30220200943042010052"
  5065. }
  5066. if org_id == 10610 {
  5067. struct3505.PharName = "彭斯遥"
  5068. struct3505.PharPracCertNo = "30220200943042010052"
  5069. }
  5070. if org_id == 10537 {
  5071. struct3505.PharName = "彭斯遥"
  5072. struct3505.PharPracCertNo = "30220200943042010052"
  5073. }
  5074. if org_id == 9504 {
  5075. struct3505.PharName = "资美红"
  5076. struct3505.PharPracCertNo = "D440904006635"
  5077. }
  5078. if org_id == 10480 {
  5079. struct3505.PharName = "陈思"
  5080. struct3505.PharPracCertNo = "30220240434110010470"
  5081. }
  5082. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5083. struct3505.SetlId = order.SetlId
  5084. struct3505.MdtrtSn = order.MdtrtId
  5085. struct3505.ManuLotnum = drug.BatchNumber
  5086. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5087. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5088. struct3505.RxFlag = "1"
  5089. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5090. struct3505.TrdnFlag = "0"
  5091. } else {
  5092. struct3505.TrdnFlag = "1"
  5093. }
  5094. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5095. struct3505.TrdnFlag = "1"
  5096. }
  5097. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5098. struct3505.TrdnFlag = "0"
  5099. }
  5100. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537{
  5101. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 1 {
  5102. struct3505.TrdnFlag = "1"
  5103. }
  5104. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 2 {
  5105. struct3505.TrdnFlag = "0"
  5106. }
  5107. }
  5108. struct3505.RtalDocno = order.Number
  5109. struct3505.PsnCertType = "01"
  5110. struct3505.CertNo = order.Certno
  5111. struct3505.PsnNo = order.PsnNo
  5112. struct3505.PsnName = order.PsnName
  5113. struct3505.Url = miConfig.Url
  5114. struct3505.AppId = miConfig.Cainfo
  5115. struct3505.AppSecret = miConfig.AppSecret
  5116. struct3505.Enckey = miConfig.EncKey
  5117. struct3505.SignKey = miConfig.SignKey
  5118. struct3505.SecretKey = miConfig.SecretKey
  5119. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5120. struct3505.SelRetnCnt = strValue
  5121. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5122. struct3505.SelRetnOpterName = role.UserName
  5123. if order.IsMedicineInsurance == 1 {
  5124. struct3505.MdtrtSetlType = "1"
  5125. } else {
  5126. struct3505.MdtrtSetlType = "2"
  5127. }
  5128. struct3505.OrgName = miConfig.OrgName
  5129. struct3505.AccessKey = miConfig.AccessKey
  5130. struct3505.RequestUrl = miConfig.Url
  5131. struct3505.SecretKey = miConfig.SecretKey
  5132. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5133. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5134. struct3505.Cainfo = miConfig.Cainfo
  5135. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5136. if miConfig.MdtrtareaAdmvs == "350500" {
  5137. result1, result2, _ := service.FJyb3505(struct3505)
  5138. return result1, result2
  5139. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5140. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5141. return result1, result2
  5142. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5143. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5144. return result1, result2
  5145. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5146. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5147. return result1, result2
  5148. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5149. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5150. return result1, result2
  5151. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5152. data := make(map[string]interface{})
  5153. data["struct_3505s"] = struct3505
  5154. client := &http.Client{}
  5155. bytesData, _ := json.Marshal(data)
  5156. var req *http.Request
  5157. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5158. resp, _ := client.Do(req)
  5159. defer resp.Body.Close()
  5160. body, ioErr := ioutil.ReadAll(resp.Body)
  5161. if ioErr != nil {
  5162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5163. }
  5164. var respJSON map[string]interface{}
  5165. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5167. }
  5168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5169. result, _ := json.Marshal(respJSON)
  5170. return string(result), ""
  5171. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5172. data := make(map[string]interface{})
  5173. data["struct_3505s"] = struct3505
  5174. client := &http.Client{}
  5175. bytesData, _ := json.Marshal(data)
  5176. var req *http.Request
  5177. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5178. resp, _ := client.Do(req)
  5179. defer resp.Body.Close()
  5180. body, ioErr := ioutil.ReadAll(resp.Body)
  5181. if ioErr != nil {
  5182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5183. }
  5184. var respJSON map[string]interface{}
  5185. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5187. }
  5188. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5189. if status == "0" {
  5190. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5191. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5192. }
  5193. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5194. result, _ := json.Marshal(respJSON)
  5195. return string(result), ""
  5196. } else {
  5197. data := make(map[string]interface{})
  5198. data["struct_3505s"] = struct3505
  5199. client := &http.Client{}
  5200. bytesData, _ := json.Marshal(data)
  5201. var req *http.Request
  5202. if miConfig.MdtrtareaAdmvs == "320921" {
  5203. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5204. } else {
  5205. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5206. }
  5207. resp, _ := client.Do(req)
  5208. defer resp.Body.Close()
  5209. body, ioErr := ioutil.ReadAll(resp.Body)
  5210. if ioErr != nil {
  5211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5212. }
  5213. var respJSON map[string]interface{}
  5214. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5216. }
  5217. //var resSix10265 ResultSix10265 //1101结果
  5218. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5219. result, _ := json.Marshal(respJSON)
  5220. return string(result), ""
  5221. }
  5222. }
  5223. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5224. var struct3505 models.Struct3505
  5225. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5226. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5227. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5228. struct3505.FixmedinsBchno = number
  5229. struct3505.Opter = role.UserName
  5230. struct3505.FixmedinsCode = miConfig.Code
  5231. struct3505.Code = miConfig.Code
  5232. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5233. struct3505.PrscDrName = roles.UserName
  5234. if org_id == 10191 {
  5235. struct3505.PharName = "刘水山"
  5236. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5237. }
  5238. if org_id == 10188 {
  5239. struct3505.PharName = "李汉清"
  5240. struct3505.PharPracCertNo = "30220200932022010034"
  5241. }
  5242. if org_id == 10217 {
  5243. struct3505.PharName = "张敏"
  5244. struct3505.PharPracCertNo = "30220230432090100108"
  5245. }
  5246. if org_id == 10318 {
  5247. struct3505.PharName = "邹刘阳"
  5248. struct3505.PharPracCertNo = "210441200001378"
  5249. }
  5250. if org_id == 10402 {
  5251. struct3505.PharName = "刘韶健"
  5252. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5253. }
  5254. if org_id == 9919 {
  5255. struct3505.PharName = "周君权"
  5256. struct3505.PharPracCertNo = "089644396094401375"
  5257. }
  5258. if org_id == 10644 {
  5259. struct3505.PharName = "陈金娣"
  5260. struct3505.PharPracCertNo = "20181441500320100066"
  5261. }
  5262. if org_id == 10567 {
  5263. struct3505.PharName = "范小兰"
  5264. struct3505.PharPracCertNo = "0200102079485"
  5265. }
  5266. if org_id == 10721 {
  5267. struct3505.PharName = "孙莉侠"
  5268. struct3505.PharPracCertNo = "060399"
  5269. }
  5270. if org_id == 10726 {
  5271. struct3505.PharName = "彭建福"
  5272. struct3505.PharPracCertNo = "D445281006261"
  5273. }
  5274. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5275. struct3505.SetlId = order.SetlId
  5276. struct3505.MdtrtSn = order.MdtrtId
  5277. struct3505.ManuLotnum = drug.Number
  5278. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5279. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5280. struct3505.RxFlag = "1"
  5281. struct3505.TrdnFlag = "0"
  5282. struct3505.RtalDocno = order.Number
  5283. struct3505.PsnCertType = "01"
  5284. struct3505.CertNo = order.Certno
  5285. struct3505.PsnNo = order.PsnNo
  5286. struct3505.PsnName = order.PsnName
  5287. struct3505.Url = miConfig.Url
  5288. struct3505.AppId = miConfig.Cainfo
  5289. struct3505.AppSecret = miConfig.AppSecret
  5290. struct3505.Enckey = miConfig.EncKey
  5291. struct3505.SignKey = miConfig.SignKey
  5292. struct3505.SecretKey = miConfig.SecretKey
  5293. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5294. struct3505.SelRetnCnt = strValue
  5295. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5296. struct3505.SelRetnOpterName = role.UserName
  5297. if order.IsMedicineInsurance == 1 {
  5298. struct3505.MdtrtSetlType = "1"
  5299. } else {
  5300. struct3505.MdtrtSetlType = "2"
  5301. }
  5302. struct3505.OrgName = miConfig.OrgName
  5303. struct3505.AccessKey = miConfig.AccessKey
  5304. struct3505.RequestUrl = miConfig.Url
  5305. struct3505.SecretKey = miConfig.SecretKey
  5306. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5307. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5308. struct3505.Cainfo = miConfig.Cainfo
  5309. struct3505.DrugTracCodg = drug.DrugCode
  5310. if miConfig.MdtrtareaAdmvs == "350500" {
  5311. result1, result2, _ := service.FJyb3505(struct3505)
  5312. return result1, result2
  5313. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5314. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5315. return result1, result2
  5316. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5317. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5318. return result1, result2
  5319. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5320. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5321. return result1, result2
  5322. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5323. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5324. return result1, result2
  5325. } else {
  5326. data := make(map[string]interface{})
  5327. data["struct_3505s"] = struct3505
  5328. client := &http.Client{}
  5329. bytesData, _ := json.Marshal(data)
  5330. var req *http.Request
  5331. if miConfig.MdtrtareaAdmvs == "320921" {
  5332. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5333. } else {
  5334. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5335. }
  5336. resp, _ := client.Do(req)
  5337. defer resp.Body.Close()
  5338. body, ioErr := ioutil.ReadAll(resp.Body)
  5339. if ioErr != nil {
  5340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5341. }
  5342. var respJSON map[string]interface{}
  5343. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5345. }
  5346. //var resSix10265 ResultSix10265 //1101结果
  5347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5348. result, _ := json.Marshal(respJSON)
  5349. return string(result), ""
  5350. }
  5351. }
  5352. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5353. var struct3506 models.Struct3506
  5354. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5355. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5356. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5357. struct3506.FixmedinsCode = miConfig.Code
  5358. struct3506.Code = miConfig.Code
  5359. struct3506.FixmedinsBchno = number
  5360. struct3506.Opter = role.UserName
  5361. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5362. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5363. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5364. struct3506.MdtrtSn = order.MdtrtId
  5365. struct3506.ExpyEnd = ""
  5366. struct3506.RxFlag = "0"
  5367. struct3506.TrdnFlag = "1"
  5368. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5369. struct3506.SelRetnCnt = strValue
  5370. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5371. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5372. struct3506.SelRetnOpterName = role.UserName
  5373. struct3506.OrgName = miConfig.OrgName
  5374. struct3506.AccessKey = miConfig.AccessKey
  5375. struct3506.RequestUrl = miConfig.Url
  5376. struct3506.SecretKey = miConfig.SecretKey
  5377. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5378. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5379. struct3506.Url = miConfig.Url
  5380. struct3506.AppId = miConfig.Cainfo
  5381. struct3506.AppSecret = miConfig.AppSecret
  5382. struct3506.Enckey = miConfig.EncKey
  5383. struct3506.SignKey = miConfig.SignKey
  5384. struct3506.SecretKey = miConfig.SecretKey
  5385. struct3506.DrugTracCodg = drug.DrugCode
  5386. if miConfig.MdtrtareaAdmvs == "350500" {
  5387. result1, result2, _ := service.FJyb3506(struct3506)
  5388. return result1, result2
  5389. } else {
  5390. data := make(map[string]interface{})
  5391. data["struct_3506s"] = struct3506
  5392. client := &http.Client{}
  5393. bytesData, _ := json.Marshal(data)
  5394. var req *http.Request
  5395. if miConfig.MdtrtareaAdmvs == "320921" {
  5396. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5397. } else {
  5398. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5399. }
  5400. resp, _ := client.Do(req)
  5401. defer resp.Body.Close()
  5402. body, ioErr := ioutil.ReadAll(resp.Body)
  5403. if ioErr != nil {
  5404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5405. }
  5406. var respJSON map[string]interface{}
  5407. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5409. }
  5410. //var resSix10265 ResultSix10265 //1101结果
  5411. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5412. result, _ := json.Marshal(respJSON)
  5413. return string(result), ""
  5414. }
  5415. }
  5416. func (c *HisApiController) Get1318() {
  5417. adminUser := c.GetAdminUserInfo()
  5418. admin_user_id, _ := c.GetInt64("admin_user_id")
  5419. code := c.GetString("code")
  5420. code = ""
  5421. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5422. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5423. api := ""
  5424. if miConfig.MdtrtareaAdmvs == "320921" {
  5425. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5426. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5427. } else {
  5428. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5429. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5430. }
  5431. resp, requestErr := http.Get(api)
  5432. if requestErr != nil {
  5433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5434. return
  5435. }
  5436. body, ioErr := ioutil.ReadAll(resp.Body)
  5437. if ioErr != nil {
  5438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5440. return
  5441. }
  5442. var respJSON map[string]interface{}
  5443. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5446. return
  5447. }
  5448. //var res Result2406
  5449. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5450. result, _ := json.Marshal(respJSON)
  5451. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5452. utils.ErrorLog("解析失败:%v", err)
  5453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5454. return
  5455. }
  5456. if res.Infcode == "0" {
  5457. c.ServeSuccessJSON(map[string]interface{}{
  5458. "result": "",
  5459. })
  5460. } else {
  5461. c.ServeSuccessJSON(map[string]interface{}{
  5462. "failed_code": -10,
  5463. "msg": res.ErrMsg,
  5464. })
  5465. */return
  5466. //}
  5467. }
  5468. func (c *HisApiController) Get2503() {
  5469. adminUser := c.GetAdminUserInfo()
  5470. admin_user_id, _ := c.GetInt64("admin_user_id")
  5471. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5472. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5473. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5474. }
  5475. func (c *HisApiController) Get2406() {
  5476. id, _ := c.GetInt64("id")
  5477. record_time := c.GetString("record_time")
  5478. his_patient_id, _ := c.GetInt64("his_patient_id")
  5479. admin_user_id, _ := c.GetInt64("admin_user_id")
  5480. diagnosis_id := c.GetString("diagnosis")
  5481. timeLayout := "2006-01-02"
  5482. loc, _ := time.LoadLocation("Local")
  5483. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5484. if err != nil {
  5485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5486. return
  5487. }
  5488. recordDateTime := theTime.Unix()
  5489. adminUser := c.GetAdminUserInfo()
  5490. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5491. var config []*models.HisXtDiagnoseConfig
  5492. for _, item := range diagnosis_ids {
  5493. id, _ := strconv.ParseInt(item, 10, 64)
  5494. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5495. config = append(config, &diagnosisConfig)
  5496. }
  5497. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5498. fmt.Println(his_patient_id)
  5499. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5500. //timestamp := time.Now().Unix()
  5501. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5502. var patientPrescription models.HisPrescriptionInfo
  5503. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5504. if patientPrescription.ID == 0 {
  5505. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5506. }
  5507. var res2 Result2406
  5508. if miConfig.MdtrtareaAdmvs == "341203" {
  5509. data := make(map[string]interface{})
  5510. client := &http.Client{}
  5511. data["psn_no"] = his.PsnNo
  5512. data["mdtrt_id"] = his.Number
  5513. data["operator"] = roles.UserName
  5514. data["cert_no"] = his.IdCardNo
  5515. data["org_name"] = miConfig.OrgName
  5516. data["psn_name"] = his.Name
  5517. data["ipt_otp_no"] = his.IptOtpNo
  5518. data["ipt_psn_sp_flag_type"] = "0901"
  5519. data["ipt_psn_sp_flag"] = "1"
  5520. data["fixmedins_code"] = miConfig.Code
  5521. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5522. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5523. data["url"] = miConfig.Url
  5524. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5525. bytesData, _ := json.Marshal(data)
  5526. var req *http.Request
  5527. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5528. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5529. resp, _ := client.Do(req)
  5530. defer resp.Body.Close()
  5531. body, ioErr := ioutil.ReadAll(resp.Body)
  5532. if ioErr != nil {
  5533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5535. return
  5536. }
  5537. var respJSON map[string]interface{}
  5538. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5541. return
  5542. }
  5543. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5544. if status == "0" {
  5545. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5546. c.ServeSuccessJSON(map[string]interface{}{
  5547. "failed_code": -10,
  5548. "msg": err_msg,
  5549. })
  5550. return
  5551. }
  5552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5553. userJSONBytes, _ := json.Marshal(respJSON)
  5554. fmt.Println("log")
  5555. fmt.Println(string(userJSONBytes))
  5556. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5557. utils.ErrorLog("解析失败:%v", err)
  5558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5559. return
  5560. }
  5561. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5562. data := make(map[string]interface{})
  5563. client := &http.Client{}
  5564. data["psn_no"] = his.PsnNo
  5565. data["mdtrt_id"] = his.Number
  5566. data["operator"] = roles.UserName
  5567. data["cert_no"] = his.IdCardNo
  5568. data["org_name"] = miConfig.OrgName
  5569. data["psn_name"] = his.Name
  5570. data["ipt_otp_no"] = his.IptOtpNo
  5571. data["ipt_psn_sp_flag_type"] = "0901"
  5572. data["ipt_psn_sp_flag"] = "1"
  5573. data["fixmedins_code"] = miConfig.Code
  5574. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5575. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5576. data["url"] = miConfig.Url
  5577. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5578. bytesData, _ := json.Marshal(data)
  5579. var req *http.Request
  5580. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5581. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5582. resp, _ := client.Do(req)
  5583. defer resp.Body.Close()
  5584. body, ioErr := ioutil.ReadAll(resp.Body)
  5585. if ioErr != nil {
  5586. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5588. return
  5589. }
  5590. var respJSON map[string]interface{}
  5591. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5594. return
  5595. }
  5596. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5597. if status == "0" {
  5598. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5599. c.ServeSuccessJSON(map[string]interface{}{
  5600. "failed_code": -10,
  5601. "msg": err_msg,
  5602. })
  5603. return
  5604. }
  5605. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5606. userJSONBytes, _ := json.Marshal(respJSON)
  5607. fmt.Println("log")
  5608. fmt.Println(string(userJSONBytes))
  5609. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5610. utils.ErrorLog("解析失败:%v", err)
  5611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5612. return
  5613. }
  5614. }
  5615. if res2.Infcode != 0 {
  5616. adminUser := c.GetAdminUserInfo()
  5617. errlog := &models.HisOrderError{
  5618. UserOrgId: adminUser.CurrentOrgId,
  5619. Ctime: time.Now().Unix(),
  5620. Mtime: time.Now().Unix(),
  5621. ErrMsg: res2.ErrMsg,
  5622. Status: 1,
  5623. PatientId: id,
  5624. RecordTime: recordDateTime,
  5625. Stage: 3,
  5626. }
  5627. service.CreateErrMsgLog(errlog)
  5628. c.ServeSuccessJSON(map[string]interface{}{
  5629. "failed_code": -10,
  5630. "msg": res2.ErrMsg,
  5631. })
  5632. return
  5633. } else {
  5634. c.ServeSuccessJSON(map[string]interface{}{
  5635. "msg": "上传成功",
  5636. })
  5637. return
  5638. }
  5639. }
  5640. func (c *HisApiController) Get4105() {
  5641. }
  5642. func (c *HisApiController) Post5302() {
  5643. patient_id, _ := c.GetInt64("id")
  5644. admin_user_id, _ := c.GetInt64("admin_user_id")
  5645. p, _ := service.GetHisPatientById(patient_id)
  5646. adminUser := c.GetAdminUserInfo()
  5647. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5648. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5649. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5650. }
  5651. func (c *HisApiController) Get4104() {
  5652. }
  5653. type Output struct {
  5654. CertNo string `json:"certno"`
  5655. PsnName string `json:"psn_name"`
  5656. CardNo string `json:"card_no"`
  5657. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5658. CardSN string `json:"card_sn"`
  5659. PsnCertType string `json:"psn_cert_type"`
  5660. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5661. MdtrtCertType string `json:"mdtrt_cert_type"`
  5662. QRCode string `json:"qrCode"`
  5663. EcToken string `json:"ecToken"`
  5664. }
  5665. type AHResponse struct {
  5666. Body AHBody `json:"body"`
  5667. Code int `json:"code"`
  5668. CSBCode int `json:"csbCode"`
  5669. Message string `json:"message"`
  5670. RequestID string `json:"requestId"`
  5671. State struct{} `json:"state"`
  5672. }
  5673. type AHBody struct {
  5674. ErrMsg string `json:"err_msg"`
  5675. InfRefMsgID string `json:"inf_refmsgid"`
  5676. InfCode int `json:"infcode"`
  5677. Output struct {
  5678. Result []struct {
  5679. BasMednFlag string `json:"bas_medn_flag"`
  5680. ChldMedcFlag string `json:"chld_medc_flag"`
  5681. ChrgitmLv string `json:"chrgitm_lv"`
  5682. Cnt float64 `json:"cnt"`
  5683. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5684. DrtReimFlag string `json:"drt_reim_flag"`
  5685. FeedetlSn string `json:"feedetl_sn"`
  5686. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5687. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5688. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5689. ListSpItemFlag string `json:"list_sp_item_flag"`
  5690. LmtUsedFlag string `json:"lmt_used_flag"`
  5691. MedChrgitmType string `json:"med_chrgitm_type"`
  5692. Memo string `json:"memo"`
  5693. OverlmtAmt float64 `json:"overlmt_amt"`
  5694. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5695. Pric float64 `json:"pric"`
  5696. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5697. SelfpayProp float64 `json:"selfpay_prop"`
  5698. } `json:"result"`
  5699. } `json:"output"`
  5700. }
  5701. type Response struct {
  5702. Output Output `json:"output"`
  5703. Infcode int `json:"infcode"`
  5704. InfRefMsgID string `json:"inf_refmsgid"`
  5705. RefMsgTime string `json:"refmsg_time"`
  5706. RespondTime string `json:"respond_time"`
  5707. ErrMsg string `json:"err_msg"`
  5708. WarnMsg string `json:"warn_msg"`
  5709. SignType string `json:"signtype"`
  5710. CAInfo string `json:"cainfo"`
  5711. }
  5712. func (c *HisApiController) Getquerydata() {
  5713. query_type, _ := c.GetInt64("type")
  5714. refd_setl_flag := c.GetString("refd_setl_flag")
  5715. med_type := c.GetString("med_type")
  5716. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5717. cert_no := c.GetString("cert_no")
  5718. psn_no := c.GetString("psn_no")
  5719. start_time := c.GetString("start_time")
  5720. end_time := c.GetString("end_time")
  5721. page, _ := c.GetInt64("page")
  5722. limit, _ := c.GetInt64("limit")
  5723. var bp models.BusinessParams5262
  5724. bp.RefdSetlFlag = refd_setl_flag
  5725. bp.MedType = med_type
  5726. bp.Certno = cert_no
  5727. bp.Psnno = psn_no
  5728. bp.QBegntime = start_time
  5729. bp.QEndtime = end_time
  5730. if query_type == 1 { //本地
  5731. Post5262(c, bp, page, limit)
  5732. } else { //异地
  5733. Post5267(c, bp, page, limit)
  5734. }
  5735. }
  5736. func (c *HisApiController) Drugscheck() {
  5737. admin_user_id, _ := c.GetInt64("admin_user_id")
  5738. adminUser := c.GetAdminUserInfo()
  5739. var queryResult []QueryResult
  5740. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5741. for _, item := range drugs {
  5742. result := QueryResult{
  5743. ID: item.ID,
  5744. Name: item.DrugName,
  5745. Code: item.MedicalInsuranceNumber,
  5746. List_type_code: "101",
  5747. }
  5748. queryResult = append(queryResult, result)
  5749. }
  5750. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5751. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5752. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5753. for _, item := range queryResult {
  5754. 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)
  5755. }
  5756. }
  5757. func (c *HisApiController) Goodcheck() {
  5758. admin_user_id, _ := c.GetInt64("admin_user_id")
  5759. adminUser := c.GetAdminUserInfo()
  5760. var queryResult []QueryResult
  5761. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5762. for _, item := range goods {
  5763. result := QueryResult{
  5764. ID: item.ID,
  5765. Name: item.GoodName,
  5766. Code: item.SocialSecurityDirectoryCode,
  5767. List_type_code: "301",
  5768. }
  5769. queryResult = append(queryResult, result)
  5770. }
  5771. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5772. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5773. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5774. for _, item := range queryResult {
  5775. 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)
  5776. //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)
  5777. }
  5778. }
  5779. func (c *HisApiController) Projectcheck() {
  5780. admin_user_id, _ := c.GetInt64("admin_user_id")
  5781. adminUser := c.GetAdminUserInfo()
  5782. var queryResult []QueryResult
  5783. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5784. for _, item := range projects {
  5785. result := QueryResult{
  5786. ID: item.ID,
  5787. Name: item.ProjectName,
  5788. Code: item.MedicalCode,
  5789. List_type_code: "201",
  5790. }
  5791. queryResult = append(queryResult, result)
  5792. }
  5793. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5794. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5795. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5796. for _, item := range queryResult {
  5797. 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)
  5798. }
  5799. }
  5800. //func (c *HisApiController)CancleDia(){
  5801. //
  5802. // id, _ := c.GetInt64("id")
  5803. // record_time := c.GetString("record_time")
  5804. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5805. //
  5806. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5807. //
  5808. // diagnosis_id := c.GetString("diagnosis")
  5809. // sick_type, _ := c.GetInt64("sick_type")
  5810. // reg_type, _ := c.GetInt64("p_type")
  5811. // begin_time := c.GetString("begin_time")
  5812. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5813. //
  5814. //
  5815. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5816. //
  5817. // fmt.Println(acct_used_flag)
  5818. //
  5819. //
  5820. // timeLayout := "2006-01-02"
  5821. // loc, _ := time.LoadLocation("Local")
  5822. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5823. // if err != nil {
  5824. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5825. // return
  5826. // }
  5827. // recordDateTime := theTime.Unix()
  5828. // adminUser := c.GetAdminUserInfo()
  5829. //
  5830. //
  5831. //
  5832. //
  5833. //
  5834. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5835. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5836. // var patientPrescription models.HisPrescriptionInfo
  5837. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5838. // if patientPrescription.ID == 0 {
  5839. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5840. // }
  5841. // //if patientPrescription.Do
  5842. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5843. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5844. //
  5845. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5846. //
  5847. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5848. //
  5849. // var config []*models.HisXtDiagnoseConfig
  5850. // for _, item := range diagnosis_ids {
  5851. // id, _ := strconv.ParseInt(item, 10, 64)
  5852. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5853. // config = append(config, &diagnosisConfig)
  5854. // }
  5855. //
  5856. // sickConfig, _ := service.FindSickById(sick_type)
  5857. //
  5858. //
  5859. // data := make(map[string]interface{})
  5860. // client := &http.Client{}
  5861. // data["psn_no"] = his.PsnNo
  5862. // data["mdtrt_id"] = his.Number
  5863. // data["doctor"] = roles.UserName
  5864. // data["department"] = department.Name
  5865. // data["org_name"] = miConfig.OrgName
  5866. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5867. // data["doctor_id"] = doctor_info.DoctorNumber
  5868. // data["new_doctor_name"] = doctor_info.UserName
  5869. // data["fixmedins_code"] = miConfig.Code
  5870. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5871. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5872. // data["secret_key"] = miConfig.SecretKey
  5873. // data["sick_code"] = sickConfig.CountryCode
  5874. // data["sick_name"] = sickConfig.ClassName
  5875. // data["url"] = miConfig.Url
  5876. // data["ak"] = miConfig.AccessKey
  5877. // data["begin_time"] = begin_time
  5878. // data["cainfo"] = miConfig.Cainfo
  5879. // data["is_vaild"] = "0"
  5880. //
  5881. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5882. // data["config"] = config
  5883. // bytesData, _ := json.Marshal(data)
  5884. //
  5885. // var req *http.Request
  5886. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5887. // resp, _ := client.Do(req)
  5888. // defer resp.Body.Close()
  5889. // body, ioErr := ioutil.ReadAll(resp.Body)
  5890. // if ioErr != nil {
  5891. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5893. // return
  5894. // }
  5895. // var respJSON map[string]interface{}
  5896. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5897. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5899. // return
  5900. // }
  5901. //
  5902. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5903. // userJSONBytes, _ := json.Marshal(respJSON)
  5904. // fmt.Println("log")
  5905. // fmt.Println(string(userJSONBytes))
  5906. //
  5907. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5908. // utils.ErrorLog("解析失败:%v", err)
  5909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5910. // return
  5911. // }
  5912. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5913. // res2.Output = ressix10265.Output
  5914. // res2.ErrMsg = ressix10265.ErrMsg
  5915. // res2.Cainfo = ressix10265.Cainfo
  5916. // res2.WarnMsg = ressix10265.WarnMsg
  5917. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5918. // res2.Infcode = infocode
  5919. //
  5920. //}
  5921. func (c *HisApiController) Get4102() {
  5922. order_id, _ := c.GetInt64("order_id")
  5923. admin_user_id, _ := c.GetInt64("admin_user_id")
  5924. stas_type := c.GetString("stas_type")
  5925. order, _ := service.GetHisOrderByIDTwo(order_id)
  5926. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5927. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5928. var pp models.PublicParams
  5929. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5930. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5931. pp.FixmedinsName = miConfig.OrgName
  5932. pp.FixmedinsCode = miConfig.Code
  5933. pp.RequestUrl = miConfig.Url
  5934. pp.Cainfo = miConfig.Cainfo
  5935. pp.SecretKey = miConfig.SecretKey
  5936. pp.AccessKey = miConfig.AccessKey
  5937. pp.OpterName = curRoles.UserName
  5938. if miConfig.MdtrtareaAdmvs == "350500" {
  5939. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5940. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5941. saveLog(result, request, "4102", "清单确认")
  5942. var dat map[string]interface{}
  5943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5944. fmt.Println(dat)
  5945. } else {
  5946. fmt.Println(err)
  5947. }
  5948. var empty ResultFourteen
  5949. userJSONBytes, _ := json.Marshal(dat)
  5950. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5951. utils.ErrorLog("解析失败:%v", err)
  5952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5953. return
  5954. }
  5955. if empty.Infcode == 0 {
  5956. c.ServeSuccessJSON(map[string]interface{}{
  5957. "msg": "确认成功",
  5958. })
  5959. return
  5960. }
  5961. } else {
  5962. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5963. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5964. result3, request3 := service.Jxyb4105(pp)
  5965. saveLog(result, request, "4102", "清单确认")
  5966. saveLog(result2, request2, "4103", "清单确认")
  5967. saveLog(result3, request3, "4105", "清单统计")
  5968. var dat map[string]interface{}
  5969. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5970. fmt.Println(dat)
  5971. } else {
  5972. fmt.Println(err)
  5973. }
  5974. var empty ResultFourteen
  5975. userJSONBytes, _ := json.Marshal(dat)
  5976. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5977. utils.ErrorLog("解析失败:%v", err)
  5978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5979. return
  5980. }
  5981. if empty.Infcode == 0 {
  5982. c.ServeSuccessJSON(map[string]interface{}{
  5983. "msg": "确认成功",
  5984. })
  5985. return
  5986. }
  5987. }
  5988. }
  5989. // 对账权限查询
  5990. func (c *HisApiController) Get3260() {
  5991. admin_user_id, _ := c.GetInt64("admin_user_id")
  5992. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5993. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5994. var api string
  5995. var res models.JSResult3260
  5996. if miConfig.MdtrtareaAdmvs == "320921" {
  5997. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5998. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5999. } else {
  6000. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6001. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6002. }
  6003. resp, requestErr := http.Get(api)
  6004. if requestErr != nil {
  6005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6006. return
  6007. }
  6008. body, ioErr := ioutil.ReadAll(resp.Body)
  6009. if ioErr != nil {
  6010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6012. return
  6013. }
  6014. var respJSON map[string]interface{}
  6015. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6018. return
  6019. }
  6020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6021. result, _ := json.Marshal(respJSON)
  6022. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6023. utils.ErrorLog("解析失败:%v", err)
  6024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6025. return
  6026. }
  6027. if res.Infcode == "0" {
  6028. c.ServeSuccessJSON(map[string]interface{}{
  6029. "result": res.Output.Data,
  6030. })
  6031. } else {
  6032. c.ServeSuccessJSON(map[string]interface{}{
  6033. "failed_code": -10,
  6034. "msg": res.ErrMsg,
  6035. })
  6036. return
  6037. }
  6038. }
  6039. func (c *HisApiController) Get3261() {
  6040. admin_user_id, _ := c.GetInt64("admin_user_id")
  6041. //month := c.GetString("month")
  6042. startTime := c.GetString("start_time")
  6043. //endTime, _ := c.GetString("end_time")
  6044. times := strings.Split(startTime, "-")
  6045. stmt_mon := times[0] + times[1]
  6046. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6047. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6048. var api string
  6049. var res models.JSResult3261
  6050. //var res10265 Result5301For10265
  6051. if miConfig.MdtrtareaAdmvs == "320921" {
  6052. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6053. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6054. } else {
  6055. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6056. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6057. }
  6058. resp, requestErr := http.Get(api)
  6059. if requestErr != nil {
  6060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6061. return
  6062. }
  6063. body, ioErr := ioutil.ReadAll(resp.Body)
  6064. if ioErr != nil {
  6065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6067. return
  6068. }
  6069. var respJSON map[string]interface{}
  6070. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6073. return
  6074. }
  6075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6076. result, _ := json.Marshal(respJSON)
  6077. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6078. utils.ErrorLog("解析失败:%v", err)
  6079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6080. return
  6081. }
  6082. if res.Infcode == "0" {
  6083. c.ServeSuccessJSON(map[string]interface{}{
  6084. "result": res.Output,
  6085. })
  6086. } else {
  6087. c.ServeSuccessJSON(map[string]interface{}{
  6088. "failed_code": -10,
  6089. "msg": res.ErrMsg,
  6090. })
  6091. return
  6092. }
  6093. }
  6094. type TempFun struct {
  6095. FundKey string
  6096. FundCode string
  6097. }
  6098. func (c *HisApiController) Get3262() {
  6099. admin_user_id, _ := c.GetInt64("admin_user_id")
  6100. startTime := c.GetString("start_time")
  6101. endTime := c.GetString("end_time")
  6102. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6103. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6104. //timeLayout := "2006-01-02"
  6105. //loc, _ := time.LoadLocation("Local")
  6106. //var theStartTIme int64
  6107. //if len(startTime) > 0 {
  6108. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6109. // if err != nil {
  6110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6111. // return
  6112. // }
  6113. // theStartTIme = theTime.Unix()
  6114. //}
  6115. //var theEndtTIme int64
  6116. //if len(endTime) > 0 {
  6117. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6118. // if err != nil {
  6119. // utils.ErrorLog(err.Error())
  6120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6121. // return
  6122. // }
  6123. // theEndtTIme = theTime.Unix()
  6124. //}
  6125. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6126. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6127. for _, team := range datas {
  6128. fmt.Println(team.PsnTime)
  6129. for _, team_two := range datas_two {
  6130. fmt.Println(team_two.PsnTime)
  6131. if team.FundKey == team_two.FundKey {
  6132. fmt.Println(team_two.PsnTime)
  6133. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6134. fmt.Println(team.PsnTime)
  6135. }
  6136. }
  6137. }
  6138. fmt.Println("1111")
  6139. fmt.Println(datas)
  6140. fmt.Println("1111")
  6141. var twos []models.FixMonRecDetailFileInTwo
  6142. for _, team := range datas {
  6143. var two models.FixMonRecDetailFileInTwo
  6144. two.MedType = team.MedType
  6145. two.Insutype = team.Insutype
  6146. two.PsnType = team.PsnType
  6147. two.MedType = team.MedType
  6148. two.FixBlngAdmdvs = "999999"
  6149. two.InsuAdmdvs = "555555"
  6150. two.PsnTime = team.PsnTime
  6151. two.PsnCnt = team.PsnCnt
  6152. two.FundKey = team.FundKey
  6153. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6154. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6155. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6156. two.MedfeeSumAmt = ms
  6157. two.InscpAmt = ia
  6158. two.FundPaySumAmt = fps
  6159. twos = append(twos, two)
  6160. }
  6161. //startTime := c.GetString("start_time")
  6162. //endTime, _ := c.GetString("end_time")
  6163. times := strings.Split(startTime, "-")
  6164. stmt_mon := times[0] + times[1]
  6165. var funs []models.FundDetail
  6166. for _, item := range datas {
  6167. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6168. funs = append(funs, fun...)
  6169. }
  6170. var funInfos []models.Fund
  6171. //for _, item := range funs {
  6172. // var rf []models.FundInfo
  6173. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6174. // for _, subitem := range rf {
  6175. // var fund models.Fund
  6176. // fund.FundCode = subitem.FundPayType
  6177. // fund.FundName = subitem.FundPayTypeName
  6178. // fund.FundAmt = subitem.FundPayAmt
  6179. // fund.FundKey = item.FundKey
  6180. // fund.InsuAdmdvs = "555555"
  6181. // fund.FixBlngAdmdvs = "999999"
  6182. // funInfos = append(funInfos, fund)
  6183. // }
  6184. //}
  6185. var tempFuns []TempFun
  6186. for _, funInfo := range funInfos {
  6187. var tempFun TempFun
  6188. tempFun.FundKey = funInfo.FundKey
  6189. tempFun.FundCode = funInfo.FundCode
  6190. tempFuns = append(tempFuns, tempFun)
  6191. }
  6192. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6193. fmt.Println(tempFuns)
  6194. var funInfosTwo []models.Fund
  6195. decimal.DivisionPrecision = 2
  6196. for _, item := range tempFuns {
  6197. var fund models.Fund
  6198. for _, subItem := range funInfos {
  6199. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6200. fund.FundKey = subItem.FundKey
  6201. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6202. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6203. fund.FundName = subItem.FundName
  6204. fund.FundCode = subItem.FundCode
  6205. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6206. }
  6207. }
  6208. funInfosTwo = append(funInfosTwo, fund)
  6209. }
  6210. fmt.Println("funInfosTwo")
  6211. fmt.Println(funInfosTwo)
  6212. var upld_btch string
  6213. var empty models.JSResultEmpty
  6214. data := make(map[string]interface{})
  6215. data["org_name"] = miConfig.OrgName
  6216. data["doctor"] = curRoles.UserName
  6217. data["doctor_name"] = curRoles.UserName
  6218. data["fixmedins_code"] = miConfig.Code
  6219. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6220. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6221. data["secret_key"] = miConfig.SecretKey
  6222. data["url"] = miConfig.Url
  6223. data["ak"] = miConfig.AccessKey
  6224. data["cainfo"] = miConfig.Cainfo
  6225. data["datas"] = twos
  6226. data["fund"] = funInfosTwo
  6227. fmt.Println(twos)
  6228. month := time.Unix(1557042972, 0).Format("1")
  6229. year := time.Now().Format("2006")
  6230. month = time.Now().Format("01")
  6231. day := time.Now().Format("02")
  6232. hour := time.Now().Format("15")
  6233. min := time.Now().Format("04")
  6234. sec := time.Now().Format("05")
  6235. fix_fill_date := year + month + day + hour + min + sec
  6236. data["fix_fill_dept"] = miConfig.OrgName
  6237. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6238. data["fix_fill_psn"] = curRoles.UserName
  6239. data["fix_fill_date"] = fix_fill_date
  6240. data["stmt_loc"] = "2"
  6241. data["setl_mon"] = stmt_mon
  6242. upld_btch = "0"
  6243. data["upld_btch"] = upld_btch
  6244. //fmt.Println(data)
  6245. client := &http.Client{}
  6246. bytesData, _ := json.Marshal(data)
  6247. var req *http.Request
  6248. if miConfig.MdtrtareaAdmvs == "320921" {
  6249. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6250. } else {
  6251. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6252. }
  6253. resp, _ := client.Do(req)
  6254. defer resp.Body.Close()
  6255. body, ioErr := ioutil.ReadAll(resp.Body)
  6256. if ioErr != nil {
  6257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6259. }
  6260. var respJSON map[string]interface{}
  6261. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6264. }
  6265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6266. //fmt.Println(respJSON)
  6267. result, _ := json.Marshal(respJSON)
  6268. //fmt.Println(result)
  6269. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6270. utils.ErrorLog("解析失败:%v", err)
  6271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6272. }
  6273. if empty.Infcode != "0" {
  6274. c.ServeSuccessJSON(map[string]interface{}{
  6275. "failed_code": -10,
  6276. "msg": empty.ErrMsg,
  6277. })
  6278. return
  6279. } else {
  6280. c.ServeSuccessJSON(map[string]interface{}{
  6281. "msg": "上传成功",
  6282. })
  6283. return
  6284. }
  6285. }
  6286. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6287. newArr = make([]TempFun, 0)
  6288. for i := 0; i < len(arr); i++ {
  6289. repeat := false
  6290. for j := i + 1; j < len(arr); j++ {
  6291. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6292. repeat = true
  6293. break
  6294. }
  6295. }
  6296. if !repeat {
  6297. newArr = append(newArr, arr[i])
  6298. }
  6299. }
  6300. return
  6301. }
  6302. func (c *HisApiController) Get3263() {
  6303. admin_user_id, _ := c.GetInt64("admin_user_id")
  6304. startTime := c.GetString("start_time")
  6305. //endTime, _ := c.GetString("end_time")
  6306. times := strings.Split(startTime, "-")
  6307. setl_mon := times[0] + times[1]
  6308. upld_btch := "0"
  6309. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6310. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6311. var result3263 models.JSResult3263
  6312. data := make(map[string]interface{})
  6313. data["org_name"] = miConfig.OrgName
  6314. data["doctor"] = curRoles.UserName
  6315. data["doctor_name"] = curRoles.UserName
  6316. data["fixmedins_code"] = miConfig.Code
  6317. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6318. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6319. data["secret_key"] = miConfig.SecretKey
  6320. data["url"] = miConfig.Url
  6321. data["ak"] = miConfig.AccessKey
  6322. data["cainfo"] = miConfig.Cainfo
  6323. data["setl_mon"] = setl_mon
  6324. data["stmt_loc"] = "2"
  6325. data["upld_btch"] = upld_btch
  6326. client := &http.Client{}
  6327. bytesData, _ := json.Marshal(data)
  6328. var req *http.Request
  6329. if miConfig.MdtrtareaAdmvs == "320921" {
  6330. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6331. } else {
  6332. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6333. }
  6334. resp, _ := client.Do(req)
  6335. defer resp.Body.Close()
  6336. body, ioErr := ioutil.ReadAll(resp.Body)
  6337. if ioErr != nil {
  6338. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6340. }
  6341. var respJSON map[string]interface{}
  6342. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6345. }
  6346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6347. fmt.Println(respJSON)
  6348. result, _ := json.Marshal(respJSON)
  6349. fmt.Println(result)
  6350. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6351. utils.ErrorLog("解析失败:%v", err)
  6352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6353. }
  6354. if result3263.Infcode != "0" {
  6355. c.ServeSuccessJSON(map[string]interface{}{
  6356. "failed_code": -10,
  6357. "msg": result3263.ErrMsg,
  6358. })
  6359. return
  6360. } else {
  6361. c.ServeSuccessJSON(map[string]interface{}{
  6362. "list": result3263.Output,
  6363. })
  6364. return
  6365. }
  6366. }
  6367. func (c *HisApiController) Get3264() {
  6368. admin_user_id, _ := c.GetInt64("admin_user_id")
  6369. startTime := c.GetString("start_time")
  6370. //endTime, _ := c.GetString("end_time")
  6371. times := strings.Split(startTime, "-")
  6372. setl_mon := times[0] + times[1]
  6373. upld_btch := "0"
  6374. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6375. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6376. //solidify_id := []
  6377. var result3263 models.JSResult3263
  6378. data := make(map[string]interface{})
  6379. data["org_name"] = miConfig.OrgName
  6380. data["doctor"] = curRoles.UserName
  6381. data["doctor_name"] = curRoles.UserName
  6382. data["fixmedins_code"] = miConfig.Code
  6383. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6384. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6385. data["secret_key"] = miConfig.SecretKey
  6386. data["url"] = miConfig.Url
  6387. data["ak"] = miConfig.AccessKey
  6388. data["cainfo"] = miConfig.Cainfo
  6389. data["setl_mon"] = setl_mon
  6390. data["stmt_loc"] = "2"
  6391. data["upld_btch"] = upld_btch
  6392. client := &http.Client{}
  6393. bytesData, _ := json.Marshal(data)
  6394. var req3263 *http.Request
  6395. if miConfig.MdtrtareaAdmvs == "320921" {
  6396. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6397. } else {
  6398. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6399. }
  6400. resp, _ := client.Do(req3263)
  6401. defer resp.Body.Close()
  6402. body, ioErr := ioutil.ReadAll(resp.Body)
  6403. if ioErr != nil {
  6404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6406. }
  6407. var respJSON3263 map[string]interface{}
  6408. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6411. }
  6412. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6413. fmt.Println(respJSON3263)
  6414. result, _ := json.Marshal(respJSON3263)
  6415. fmt.Println(result)
  6416. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6417. utils.ErrorLog("解析失败:%v", err)
  6418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6419. }
  6420. var ids []string
  6421. for _, item := range result3263.Output {
  6422. ids = append(ids, item.SolidifyID)
  6423. }
  6424. var empty models.JSResultEmpty
  6425. data2 := make(map[string]interface{})
  6426. data2["org_name"] = miConfig.OrgName
  6427. data2["doctor"] = curRoles.UserName
  6428. data2["doctor_name"] = curRoles.UserName
  6429. data2["fixmedins_code"] = miConfig.Code
  6430. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6431. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6432. data2["secret_key"] = miConfig.SecretKey
  6433. data2["url"] = miConfig.Url
  6434. data2["ak"] = miConfig.AccessKey
  6435. data2["cainfo"] = miConfig.Cainfo
  6436. data2["setl_mon"] = setl_mon
  6437. data2["stmt_loc"] = "2"
  6438. data2["upld_btch"] = upld_btch
  6439. data2["solidify_id"] = ids
  6440. client2 := &http.Client{}
  6441. bytesData2, _ := json.Marshal(data2)
  6442. var req *http.Request
  6443. if miConfig.MdtrtareaAdmvs == "320921" {
  6444. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6445. } else {
  6446. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6447. }
  6448. resp2, _ := client2.Do(req)
  6449. defer resp.Body.Close()
  6450. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6451. if ioErr2 != nil {
  6452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6454. }
  6455. var respJSON map[string]interface{}
  6456. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6459. }
  6460. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6461. fmt.Println(respJSON)
  6462. result2, _ := json.Marshal(respJSON)
  6463. fmt.Println(result2)
  6464. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6465. utils.ErrorLog("解析失败:%v", err)
  6466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6467. }
  6468. if empty.Infcode != "0" {
  6469. c.ServeSuccessJSON(map[string]interface{}{
  6470. "failed_code": -10,
  6471. "msg": empty.ErrMsg,
  6472. })
  6473. return
  6474. } else {
  6475. c.ServeSuccessJSON(map[string]interface{}{
  6476. "msg": "",
  6477. })
  6478. return
  6479. }
  6480. }
  6481. func (c *HisApiController) Get3265() {
  6482. admin_user_id, _ := c.GetInt64("admin_user_id")
  6483. startTime := c.GetString("start_time")
  6484. //endTime, _ := c.GetString("end_time")
  6485. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6486. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6487. times := strings.Split(startTime, "-")
  6488. setl_mon := times[0] + times[1]
  6489. var upld_btch string
  6490. upld_btch = "0"
  6491. //var empty models.JSResultEmpty
  6492. var result3265 models.JSResult3264
  6493. var result3263 models.JSResult3263
  6494. data2 := make(map[string]interface{})
  6495. data2["org_name"] = miConfig.OrgName
  6496. data2["doctor"] = curRoles.UserName
  6497. data2["doctor_name"] = curRoles.UserName
  6498. data2["fixmedins_code"] = miConfig.Code
  6499. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6500. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6501. data2["secret_key"] = miConfig.SecretKey
  6502. data2["url"] = miConfig.Url
  6503. data2["ak"] = miConfig.AccessKey
  6504. data2["cainfo"] = miConfig.Cainfo
  6505. data2["setl_mon"] = setl_mon
  6506. data2["stmt_loc"] = "2"
  6507. data2["upld_btch"] = upld_btch
  6508. client2 := &http.Client{}
  6509. bytesData2, _ := json.Marshal(data2)
  6510. var req3263 *http.Request
  6511. if miConfig.MdtrtareaAdmvs == "320921" {
  6512. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6513. } else {
  6514. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6515. }
  6516. resp2, _ := client2.Do(req3263)
  6517. defer resp2.Body.Close()
  6518. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6519. if ioErr2 != nil {
  6520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6522. }
  6523. var respJSON3263 map[string]interface{}
  6524. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6527. }
  6528. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6529. fmt.Println(respJSON3263)
  6530. result2, _ := json.Marshal(respJSON3263)
  6531. fmt.Println(result2)
  6532. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6533. utils.ErrorLog("解析失败:%v", err)
  6534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6535. }
  6536. var ids []string
  6537. for _, item := range result3263.Output {
  6538. ids = append(ids, item.SolidifyID)
  6539. }
  6540. data := make(map[string]interface{})
  6541. data["org_name"] = miConfig.OrgName
  6542. data["doctor"] = curRoles.UserName
  6543. data["doctor_name"] = curRoles.UserName
  6544. data["fixmedins_code"] = miConfig.Code
  6545. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6546. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6547. data["secret_key"] = miConfig.SecretKey
  6548. data["url"] = miConfig.Url
  6549. data["ak"] = miConfig.AccessKey
  6550. data["cainfo"] = miConfig.Cainfo
  6551. data["setl_mon"] = setl_mon
  6552. data["solidify_id"] = ids
  6553. month := time.Unix(1557042972, 0).Format("1")
  6554. year := time.Now().Format("2006")
  6555. month = time.Now().Format("01")
  6556. day := time.Now().Format("02")
  6557. hour := time.Now().Format("15")
  6558. min := time.Now().Format("04")
  6559. sec := time.Now().Format("05")
  6560. fix_fill_date := year + month + day + hour + min + sec
  6561. data["fix_fill_dept"] = miConfig.OrgName
  6562. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6563. data["fix_fill_psn"] = curRoles.UserName
  6564. data["fix_fill_date"] = fix_fill_date
  6565. data["stmt_loc"] = "2"
  6566. data["upld_btch"] = upld_btch
  6567. client := &http.Client{}
  6568. bytesData, _ := json.Marshal(data)
  6569. var req *http.Request
  6570. if miConfig.MdtrtareaAdmvs == "320921" {
  6571. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6572. } else {
  6573. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6574. }
  6575. resp, _ := client.Do(req)
  6576. defer resp.Body.Close()
  6577. body, ioErr := ioutil.ReadAll(resp.Body)
  6578. if ioErr != nil {
  6579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6581. }
  6582. var respJSON map[string]interface{}
  6583. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6586. }
  6587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6588. fmt.Println(respJSON)
  6589. result, _ := json.Marshal(respJSON)
  6590. fmt.Println(result)
  6591. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6592. utils.ErrorLog("解析失败:%v", err)
  6593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6594. }
  6595. if result3265.Infcode != "0" {
  6596. c.ServeSuccessJSON(map[string]interface{}{
  6597. "failed_code": -10,
  6598. "msg": result3265.ErrMsg,
  6599. })
  6600. return
  6601. } else {
  6602. c.ServeSuccessJSON(map[string]interface{}{
  6603. "info": result3265.Output,
  6604. })
  6605. return
  6606. }
  6607. }
  6608. func (c *HisApiController) Get3266() {
  6609. admin_user_id, _ := c.GetInt64("admin_user_id")
  6610. startTime := c.GetString("start_time")
  6611. //endTime, _ := c.GetString("end_time")
  6612. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6613. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6614. times := strings.Split(startTime, "-")
  6615. stmt_mon := times[0] + times[1]
  6616. var upld_btch string
  6617. //var empty models.JSResultEmpty
  6618. var result3265 models.JSResult3264
  6619. data := make(map[string]interface{})
  6620. data["org_name"] = miConfig.OrgName
  6621. data["doctor"] = curRoles.UserName
  6622. data["doctor_name"] = curRoles.UserName
  6623. data["fixmedins_code"] = miConfig.Code
  6624. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6625. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6626. data["secret_key"] = miConfig.SecretKey
  6627. data["url"] = miConfig.Url
  6628. data["ak"] = miConfig.AccessKey
  6629. data["cainfo"] = miConfig.Cainfo
  6630. data["setl_mon"] = stmt_mon
  6631. month := time.Unix(1557042972, 0).Format("1")
  6632. year := time.Now().Format("2006")
  6633. month = time.Now().Format("01")
  6634. day := time.Now().Format("02")
  6635. hour := time.Now().Format("15")
  6636. min := time.Now().Format("04")
  6637. sec := time.Now().Format("05")
  6638. fix_fill_date := year + month + day + hour + min + sec
  6639. data["fix_fill_dept"] = miConfig.OrgName
  6640. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6641. data["fix_fill_psn"] = curRoles.UserName
  6642. data["fix_fill_date"] = fix_fill_date
  6643. data["stmt_loc"] = "2"
  6644. upld_btch = "0"
  6645. data["upld_btch"] = upld_btch
  6646. client := &http.Client{}
  6647. bytesData, _ := json.Marshal(data)
  6648. var req *http.Request
  6649. if miConfig.MdtrtareaAdmvs == "320921" {
  6650. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6651. } else {
  6652. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6653. }
  6654. resp, _ := client.Do(req)
  6655. defer resp.Body.Close()
  6656. body, ioErr := ioutil.ReadAll(resp.Body)
  6657. if ioErr != nil {
  6658. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6660. }
  6661. var respJSON map[string]interface{}
  6662. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6665. }
  6666. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6667. fmt.Println(respJSON)
  6668. result, _ := json.Marshal(respJSON)
  6669. fmt.Println(result)
  6670. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6671. utils.ErrorLog("解析失败:%v", err)
  6672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6673. }
  6674. if result3265.Infcode != "0" {
  6675. c.ServeSuccessJSON(map[string]interface{}{
  6676. "failed_code": -10,
  6677. "msg": result3265.ErrMsg,
  6678. })
  6679. return
  6680. } else {
  6681. c.ServeSuccessJSON(map[string]interface{}{
  6682. "info": result3265.Output,
  6683. })
  6684. return
  6685. }
  6686. }
  6687. func (c *HisApiController) Get3267() {
  6688. admin_user_id, _ := c.GetInt64("admin_user_id")
  6689. startTime := c.GetString("start_time")
  6690. //endTime, _ := c.GetString("end_time")
  6691. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6692. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6693. times := strings.Split(startTime, "-")
  6694. setl_mon := times[0] + times[1]
  6695. var upld_btch string
  6696. //var empty models.JSResultEmpty
  6697. var result3265 models.JSResult3264
  6698. upld_btch = "0"
  6699. data := make(map[string]interface{})
  6700. data["org_name"] = miConfig.OrgName
  6701. data["doctor"] = curRoles.UserName
  6702. data["doctor_name"] = curRoles.UserName
  6703. data["fixmedins_code"] = miConfig.Code
  6704. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6705. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6706. data["secret_key"] = miConfig.SecretKey
  6707. data["url"] = miConfig.Url
  6708. data["ak"] = miConfig.AccessKey
  6709. data["cainfo"] = miConfig.Cainfo
  6710. data["setl_mon"] = setl_mon
  6711. data["stmt_loc"] = "2"
  6712. data["upld_btch"] = upld_btch
  6713. client := &http.Client{}
  6714. bytesData, _ := json.Marshal(data)
  6715. var req *http.Request
  6716. if miConfig.MdtrtareaAdmvs == "320921" {
  6717. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6718. } else {
  6719. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6720. }
  6721. resp, _ := client.Do(req)
  6722. defer resp.Body.Close()
  6723. body, ioErr := ioutil.ReadAll(resp.Body)
  6724. if ioErr != nil {
  6725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6727. }
  6728. var respJSON map[string]interface{}
  6729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6732. }
  6733. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6734. fmt.Println(respJSON)
  6735. result, _ := json.Marshal(respJSON)
  6736. fmt.Println(result)
  6737. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6738. utils.ErrorLog("解析失败:%v", err)
  6739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6740. }
  6741. if result3265.Infcode != "0" {
  6742. c.ServeSuccessJSON(map[string]interface{}{
  6743. "failed_code": -10,
  6744. "msg": result3265.ErrMsg,
  6745. })
  6746. return
  6747. } else {
  6748. c.ServeSuccessJSON(map[string]interface{}{
  6749. "info": result3265.Output.Data,
  6750. })
  6751. return
  6752. }
  6753. }
  6754. func (c *HisApiController) Get3268() {
  6755. admin_user_id, _ := c.GetInt64("admin_user_id")
  6756. startTime := c.GetString("start_time")
  6757. endTime := c.GetString("end_time")
  6758. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6759. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6760. times := strings.Split(startTime, "-")
  6761. setl_mon := times[0] + times[1]
  6762. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6763. var twos []models.FixMonRecDetailFileInTwo
  6764. var funs []models.FundDetail
  6765. for _, item := range datas {
  6766. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6767. funs = append(funs, fun...)
  6768. }
  6769. var funInfos []models.Fund
  6770. //for _, item := range funs {
  6771. // var rf []models.FundInfo
  6772. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6773. // for _, subitem := range rf {
  6774. // var fund models.Fund
  6775. // fund.FundCode = subitem.FundPayType
  6776. // fund.FundName = subitem.FundPayTypeName
  6777. // fund.FundAmt = subitem.FundPayAmt
  6778. // fund.FundKey = item.FundKey
  6779. // fund.InsuAdmdvs = "555555"
  6780. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6781. // funInfos = append(funInfos, fund)
  6782. // }
  6783. //}
  6784. for _, team := range datas {
  6785. var two models.FixMonRecDetailFileInTwo
  6786. two.SetlDate = time.Now().Format("2006-01-02")
  6787. two.MedType = team.MedType
  6788. two.Insutype = team.Insutype
  6789. two.PsnType = team.PsnType
  6790. two.MedType = team.MedType
  6791. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6792. two.InsuAdmdvs = team.InsuAdmdvs
  6793. two.PsnTime = team.PsnTime
  6794. two.PsnCnt = team.PsnCnt
  6795. two.FundKey = team.FundKey
  6796. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6797. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6798. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6799. two.MedfeeSumAmt = ms
  6800. two.InscpAmt = ia
  6801. two.FundPaySumAmt = fps
  6802. twos = append(twos, two)
  6803. }
  6804. var upld_btch string
  6805. upld_btch = "0"
  6806. var empty models.JSResultEmpty
  6807. data := make(map[string]interface{})
  6808. data["org_name"] = miConfig.OrgName
  6809. data["doctor"] = curRoles.UserName
  6810. data["doctor_name"] = curRoles.UserName
  6811. data["fixmedins_code"] = miConfig.Code
  6812. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6813. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6814. data["secret_key"] = miConfig.SecretKey
  6815. data["url"] = miConfig.Url
  6816. data["ak"] = miConfig.AccessKey
  6817. data["cainfo"] = miConfig.Cainfo
  6818. data["datas"] = twos
  6819. data["fund"] = funInfos
  6820. data["setl_mon"] = setl_mon
  6821. month := time.Unix(1557042972, 0).Format("1")
  6822. year := time.Now().Format("2006")
  6823. month = time.Now().Format("01")
  6824. day := time.Now().Format("02")
  6825. hour := time.Now().Format("15")
  6826. min := time.Now().Format("04")
  6827. sec := time.Now().Format("05")
  6828. fix_fill_date := year + month + day + hour + min + sec
  6829. data["fix_fill_dept"] = miConfig.OrgName
  6830. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6831. data["fix_fill_psn"] = curRoles.UserName
  6832. data["fix_fill_date"] = fix_fill_date
  6833. data["stmt_loc"] = "2"
  6834. data["upld_btch"] = upld_btch
  6835. client := &http.Client{}
  6836. bytesData, _ := json.Marshal(data)
  6837. var req *http.Request
  6838. if miConfig.MdtrtareaAdmvs == "320921" {
  6839. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6840. } else {
  6841. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6842. }
  6843. resp, _ := client.Do(req)
  6844. defer resp.Body.Close()
  6845. body, ioErr := ioutil.ReadAll(resp.Body)
  6846. if ioErr != nil {
  6847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6849. }
  6850. var respJSON map[string]interface{}
  6851. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6854. }
  6855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6856. fmt.Println(respJSON)
  6857. result, _ := json.Marshal(respJSON)
  6858. fmt.Println(result)
  6859. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6860. utils.ErrorLog("解析失败:%v", err)
  6861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6862. }
  6863. if empty.Infcode != "0" {
  6864. c.ServeSuccessJSON(map[string]interface{}{
  6865. "failed_code": -10,
  6866. "msg": empty.ErrMsg,
  6867. })
  6868. return
  6869. } else {
  6870. c.ServeSuccessJSON(map[string]interface{}{
  6871. "msg": "上传成功",
  6872. })
  6873. return
  6874. }
  6875. }
  6876. func (c *HisApiController) Get3269() {
  6877. admin_user_id, _ := c.GetInt64("admin_user_id")
  6878. startTime := c.GetString("start_time")
  6879. //endTime, _ := c.GetString("end_time")
  6880. times := strings.Split(startTime, "-")
  6881. setl_mon := times[0] + times[1]
  6882. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6883. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6884. var result3263 models.JSResult3263
  6885. data := make(map[string]interface{})
  6886. data["org_name"] = miConfig.OrgName
  6887. data["doctor"] = curRoles.UserName
  6888. data["doctor_name"] = curRoles.UserName
  6889. data["fixmedins_code"] = miConfig.Code
  6890. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6891. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6892. data["secret_key"] = miConfig.SecretKey
  6893. data["url"] = miConfig.Url
  6894. data["ak"] = miConfig.AccessKey
  6895. data["cainfo"] = miConfig.Cainfo
  6896. data["setl_mon"] = setl_mon
  6897. data["stmt_loc"] = "2"
  6898. client := &http.Client{}
  6899. bytesData, _ := json.Marshal(data)
  6900. var req *http.Request
  6901. if miConfig.MdtrtareaAdmvs == "320921" {
  6902. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6903. } else {
  6904. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6905. }
  6906. resp, _ := client.Do(req)
  6907. defer resp.Body.Close()
  6908. body, ioErr := ioutil.ReadAll(resp.Body)
  6909. if ioErr != nil {
  6910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6912. }
  6913. var respJSON map[string]interface{}
  6914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6917. }
  6918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6919. fmt.Println(respJSON)
  6920. result, _ := json.Marshal(respJSON)
  6921. fmt.Println(result)
  6922. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6923. utils.ErrorLog("解析失败:%v", err)
  6924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6925. }
  6926. if result3263.Infcode != "0" {
  6927. c.ServeSuccessJSON(map[string]interface{}{
  6928. "failed_code": -10,
  6929. "msg": result3263.ErrMsg,
  6930. })
  6931. return
  6932. } else {
  6933. c.ServeSuccessJSON(map[string]interface{}{
  6934. "msg": "上传成功",
  6935. })
  6936. return
  6937. }
  6938. }
  6939. func (c *HisApiController) Get3270() {
  6940. admin_user_id, _ := c.GetInt64("admin_user_id")
  6941. startTime := c.GetString("start_time")
  6942. //endTime, _ := c.GetString("end_time")
  6943. times := strings.Split(startTime, "-")
  6944. setl_mon := times[0] + times[1]
  6945. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6946. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6947. var result3263 models.JSResult3263
  6948. data2 := make(map[string]interface{})
  6949. data2["org_name"] = miConfig.OrgName
  6950. data2["doctor"] = curRoles.UserName
  6951. data2["doctor_name"] = curRoles.UserName
  6952. data2["fixmedins_code"] = miConfig.Code
  6953. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6954. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6955. data2["secret_key"] = miConfig.SecretKey
  6956. data2["url"] = miConfig.Url
  6957. data2["ak"] = miConfig.AccessKey
  6958. data2["cainfo"] = miConfig.Cainfo
  6959. data2["setl_mon"] = setl_mon
  6960. data2["stmt_loc"] = "2"
  6961. client2 := &http.Client{}
  6962. bytesData2, _ := json.Marshal(data2)
  6963. var req3263 *http.Request
  6964. if miConfig.MdtrtareaAdmvs == "320921" {
  6965. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6966. } else {
  6967. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6968. }
  6969. resp2, _ := client2.Do(req3263)
  6970. defer resp2.Body.Close()
  6971. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6972. if ioErr2 != nil {
  6973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6975. }
  6976. var respJSON3263 map[string]interface{}
  6977. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6980. }
  6981. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6982. fmt.Println(respJSON3263)
  6983. result2, _ := json.Marshal(respJSON3263)
  6984. fmt.Println(result2)
  6985. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6986. utils.ErrorLog("解析失败:%v", err)
  6987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6988. }
  6989. var ids []string
  6990. for _, item := range result3263.Output {
  6991. ids = append(ids, item.SolidifyID)
  6992. }
  6993. var result3264 models.JSResult3264
  6994. data := make(map[string]interface{})
  6995. data["org_name"] = miConfig.OrgName
  6996. data["doctor"] = curRoles.UserName
  6997. data["doctor_name"] = curRoles.UserName
  6998. data["fixmedins_code"] = miConfig.Code
  6999. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7000. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7001. data["secret_key"] = miConfig.SecretKey
  7002. data["url"] = miConfig.Url
  7003. data["ak"] = miConfig.AccessKey
  7004. data["cainfo"] = miConfig.Cainfo
  7005. data["setl_mon"] = setl_mon
  7006. data["stmt_loc"] = "2"
  7007. data["solidify_id"] = ids
  7008. client := &http.Client{}
  7009. bytesData, _ := json.Marshal(data)
  7010. var req *http.Request
  7011. if miConfig.MdtrtareaAdmvs == "320921" {
  7012. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7013. } else {
  7014. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7015. }
  7016. resp, _ := client.Do(req)
  7017. defer resp.Body.Close()
  7018. body, ioErr := ioutil.ReadAll(resp.Body)
  7019. if ioErr != nil {
  7020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7022. }
  7023. var respJSON map[string]interface{}
  7024. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7027. }
  7028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7029. fmt.Println(respJSON)
  7030. result, _ := json.Marshal(respJSON)
  7031. fmt.Println(result)
  7032. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7033. utils.ErrorLog("解析失败:%v", err)
  7034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7035. }
  7036. if result3264.Infcode != "0" {
  7037. c.ServeSuccessJSON(map[string]interface{}{
  7038. "failed_code": -10,
  7039. "msg": result3264.ErrMsg,
  7040. })
  7041. return
  7042. } else {
  7043. c.ServeSuccessJSON(map[string]interface{}{
  7044. "info": result3264.Output,
  7045. })
  7046. return
  7047. }
  7048. }
  7049. func (c *HisApiController) Get3271() {
  7050. admin_user_id, _ := c.GetInt64("admin_user_id")
  7051. startTime := c.GetString("start_time")
  7052. //endTime, _ := c.GetString("end_time")
  7053. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7054. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7055. times := strings.Split(startTime, "-")
  7056. setl_mon := times[0] + times[1]
  7057. //var empty models.JSResultEmpty
  7058. var result3265 models.JSResult3264
  7059. var result3263 models.JSResult3263
  7060. data2 := make(map[string]interface{})
  7061. data2["org_name"] = miConfig.OrgName
  7062. data2["doctor"] = curRoles.UserName
  7063. data2["doctor_name"] = curRoles.UserName
  7064. data2["fixmedins_code"] = miConfig.Code
  7065. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7066. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7067. data2["secret_key"] = miConfig.SecretKey
  7068. data2["url"] = miConfig.Url
  7069. data2["ak"] = miConfig.AccessKey
  7070. data2["cainfo"] = miConfig.Cainfo
  7071. data2["setl_mon"] = setl_mon
  7072. data2["stmt_loc"] = "2"
  7073. client2 := &http.Client{}
  7074. bytesData2, _ := json.Marshal(data2)
  7075. var req3263 *http.Request
  7076. if miConfig.MdtrtareaAdmvs == "320921" {
  7077. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7078. } else {
  7079. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7080. }
  7081. resp2, _ := client2.Do(req3263)
  7082. defer resp2.Body.Close()
  7083. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7084. if ioErr2 != nil {
  7085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7087. }
  7088. var respJSON3263 map[string]interface{}
  7089. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7092. }
  7093. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7094. fmt.Println(respJSON3263)
  7095. result2, _ := json.Marshal(respJSON3263)
  7096. fmt.Println(result2)
  7097. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7098. utils.ErrorLog("解析失败:%v", err)
  7099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7100. }
  7101. var ids []string
  7102. for _, item := range result3263.Output {
  7103. ids = append(ids, item.SolidifyID)
  7104. }
  7105. data := make(map[string]interface{})
  7106. data["org_name"] = miConfig.OrgName
  7107. data["doctor"] = curRoles.UserName
  7108. data["doctor_name"] = curRoles.UserName
  7109. data["fixmedins_code"] = miConfig.Code
  7110. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7111. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7112. data["secret_key"] = miConfig.SecretKey
  7113. data["url"] = miConfig.Url
  7114. data["ak"] = miConfig.AccessKey
  7115. data["cainfo"] = miConfig.Cainfo
  7116. data["setl_mon"] = setl_mon
  7117. data["solidify_id"] = ids
  7118. month := time.Unix(1557042972, 0).Format("1")
  7119. year := time.Now().Format("2006")
  7120. month = time.Now().Format("01")
  7121. day := time.Now().Format("02")
  7122. hour := time.Now().Format("15")
  7123. min := time.Now().Format("04")
  7124. sec := time.Now().Format("05")
  7125. fix_fill_date := year + month + day + hour + min + sec
  7126. data["fix_fill_dept"] = miConfig.OrgName
  7127. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7128. data["fix_fill_psn"] = curRoles.UserName
  7129. data["fix_fill_date"] = fix_fill_date
  7130. data["stmt_loc"] = "2"
  7131. client := &http.Client{}
  7132. bytesData, _ := json.Marshal(data)
  7133. var req *http.Request
  7134. if miConfig.MdtrtareaAdmvs == "320921" {
  7135. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7136. } else {
  7137. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7138. }
  7139. resp, _ := client.Do(req)
  7140. defer resp.Body.Close()
  7141. body, ioErr := ioutil.ReadAll(resp.Body)
  7142. if ioErr != nil {
  7143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7145. }
  7146. var respJSON map[string]interface{}
  7147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7150. }
  7151. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7152. fmt.Println(respJSON)
  7153. result, _ := json.Marshal(respJSON)
  7154. fmt.Println(result)
  7155. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7156. utils.ErrorLog("解析失败:%v", err)
  7157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7158. }
  7159. if result3265.Infcode != "0" {
  7160. c.ServeSuccessJSON(map[string]interface{}{
  7161. "failed_code": -10,
  7162. "msg": result3265.ErrMsg,
  7163. })
  7164. return
  7165. } else {
  7166. c.ServeSuccessJSON(map[string]interface{}{
  7167. "info": result3265.Output.Data,
  7168. })
  7169. return
  7170. }
  7171. }
  7172. func (c *HisApiController) Get3272() {
  7173. admin_user_id, _ := c.GetInt64("admin_user_id")
  7174. startTime := c.GetString("start_time")
  7175. //endTime, _ := c.GetString("end_time")
  7176. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7177. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7178. times := strings.Split(startTime, "-")
  7179. setl_mon := times[0] + times[1]
  7180. var upld_btch string
  7181. //var empty models.JSResultEmpty
  7182. var result3265 models.JSResult3264
  7183. data := make(map[string]interface{})
  7184. data["org_name"] = miConfig.OrgName
  7185. data["doctor"] = curRoles.UserName
  7186. data["doctor_name"] = curRoles.UserName
  7187. data["fixmedins_code"] = miConfig.Code
  7188. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7189. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7190. data["secret_key"] = miConfig.SecretKey
  7191. data["url"] = miConfig.Url
  7192. data["ak"] = miConfig.AccessKey
  7193. data["cainfo"] = miConfig.Cainfo
  7194. data["setl_mon"] = setl_mon
  7195. month := time.Unix(1557042972, 0).Format("1")
  7196. year := time.Now().Format("2006")
  7197. month = time.Now().Format("01")
  7198. day := time.Now().Format("02")
  7199. hour := time.Now().Format("15")
  7200. min := time.Now().Format("04")
  7201. sec := time.Now().Format("05")
  7202. fix_fill_date := year + month + day + hour + min + sec
  7203. data["fix_fill_dept"] = miConfig.OrgName
  7204. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7205. data["fix_fill_psn"] = curRoles.UserName
  7206. data["fix_fill_date"] = fix_fill_date
  7207. data["stmt_loc"] = "2"
  7208. data["upld_btch"] = upld_btch
  7209. client := &http.Client{}
  7210. bytesData, _ := json.Marshal(data)
  7211. var req *http.Request
  7212. if miConfig.MdtrtareaAdmvs == "320921" {
  7213. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7214. } else {
  7215. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7216. }
  7217. resp, _ := client.Do(req)
  7218. defer resp.Body.Close()
  7219. body, ioErr := ioutil.ReadAll(resp.Body)
  7220. if ioErr != nil {
  7221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7223. }
  7224. var respJSON map[string]interface{}
  7225. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7228. }
  7229. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7230. fmt.Println(respJSON)
  7231. result, _ := json.Marshal(respJSON)
  7232. fmt.Println(result)
  7233. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7234. utils.ErrorLog("解析失败:%v", err)
  7235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7236. }
  7237. if result3265.Infcode != "0" {
  7238. c.ServeSuccessJSON(map[string]interface{}{
  7239. "failed_code": -10,
  7240. "msg": result3265.ErrMsg,
  7241. })
  7242. return
  7243. } else {
  7244. c.ServeSuccessJSON(map[string]interface{}{
  7245. "info": result3265.Output,
  7246. })
  7247. return
  7248. }
  7249. }
  7250. func (c *HisApiController) Get3273() {
  7251. admin_user_id, _ := c.GetInt64("admin_user_id")
  7252. startTime := c.GetString("start_time")
  7253. //endTime, _ := c.GetString("end_time")
  7254. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7255. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7256. times := strings.Split(startTime, "-")
  7257. setl_mon := times[0] + times[1]
  7258. var result3265 models.JSResult3264
  7259. data := make(map[string]interface{})
  7260. data["org_name"] = miConfig.OrgName
  7261. data["doctor"] = curRoles.UserName
  7262. data["doctor_name"] = curRoles.UserName
  7263. data["fixmedins_code"] = miConfig.Code
  7264. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7265. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7266. data["secret_key"] = miConfig.SecretKey
  7267. data["url"] = miConfig.Url
  7268. data["ak"] = miConfig.AccessKey
  7269. data["cainfo"] = miConfig.Cainfo
  7270. data["setl_mon"] = setl_mon
  7271. data["stmt_loc"] = "2"
  7272. client := &http.Client{}
  7273. bytesData, _ := json.Marshal(data)
  7274. var req *http.Request
  7275. if miConfig.MdtrtareaAdmvs == "320921" {
  7276. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7277. } else {
  7278. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7279. }
  7280. resp, _ := client.Do(req)
  7281. defer resp.Body.Close()
  7282. body, ioErr := ioutil.ReadAll(resp.Body)
  7283. if ioErr != nil {
  7284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7286. }
  7287. var respJSON map[string]interface{}
  7288. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7291. }
  7292. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7293. fmt.Println(respJSON)
  7294. result, _ := json.Marshal(respJSON)
  7295. fmt.Println(result)
  7296. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7297. utils.ErrorLog("解析失败:%v", err)
  7298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7299. }
  7300. if result3265.Infcode != "0" {
  7301. c.ServeSuccessJSON(map[string]interface{}{
  7302. "failed_code": -10,
  7303. "msg": result3265.ErrMsg,
  7304. })
  7305. return
  7306. } else {
  7307. c.ServeSuccessJSON(map[string]interface{}{
  7308. "info": result3265.Output.Data,
  7309. })
  7310. return
  7311. }
  7312. }
  7313. func (c *HisApiController) Get3274() {
  7314. //if miConfig.MdtrtareaAdmvs == "320921" {
  7315. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7316. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7317. // "&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
  7318. //
  7319. //} else {
  7320. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7321. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7322. // "&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
  7323. //
  7324. //}
  7325. }
  7326. func (c *HisApiController) Get3275() {
  7327. //if miConfig.MdtrtareaAdmvs == "320921" {
  7328. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7329. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7330. // "&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
  7331. //
  7332. //} else {
  7333. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7334. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7335. // "&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
  7336. //
  7337. //}
  7338. }
  7339. func (c *HisApiController) Get3276() {
  7340. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7341. //month := c.GetString("month")
  7342. //
  7343. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7344. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7345. //var api string
  7346. //var res Result5301
  7347. //
  7348. //if miConfig.MdtrtareaAdmvs == "320921" {
  7349. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7350. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7351. //} else {
  7352. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7353. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7354. //}
  7355. //
  7356. //resp, requestErr := http.Get(api)
  7357. //if requestErr != nil {
  7358. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7359. // return
  7360. //}
  7361. //
  7362. //body, ioErr := ioutil.ReadAll(resp.Body)
  7363. //if ioErr != nil {
  7364. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7366. // return
  7367. //}
  7368. //var respJSON map[string]interface{}
  7369. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7370. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7371. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7372. // return
  7373. //}
  7374. //
  7375. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7376. //result, _ := json.Marshal(respJSON)
  7377. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7378. // utils.ErrorLog("解析失败:%v", err)
  7379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7380. // return
  7381. //}
  7382. }
  7383. func (c *HisApiController) Get3277() {
  7384. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7385. //month := c.GetString("month")
  7386. //
  7387. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7388. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7389. //var api string
  7390. //var res Result5301
  7391. //
  7392. //if miConfig.MdtrtareaAdmvs == "320921" {
  7393. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7394. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7395. //} else {
  7396. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7397. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7398. //}
  7399. //
  7400. //resp, requestErr := http.Get(api)
  7401. //if requestErr != nil {
  7402. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7403. // return
  7404. //}
  7405. //
  7406. //body, ioErr := ioutil.ReadAll(resp.Body)
  7407. //if ioErr != nil {
  7408. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7409. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7410. // return
  7411. //}
  7412. //var respJSON map[string]interface{}
  7413. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7414. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7416. // return
  7417. //}
  7418. //
  7419. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7420. //result, _ := json.Marshal(respJSON)
  7421. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7422. // utils.ErrorLog("解析失败:%v", err)
  7423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7424. // return
  7425. //}
  7426. }
  7427. //func (c *HisApiController) GetCFYLJG001() {
  7428. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7429. // patient_id, _ := c.GetInt64("patient_id")
  7430. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7431. // record_time := c.GetString("record_time")
  7432. // admin_user_id = 3626
  7433. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7434. // psn, _ := service.GetPsnByPatientId(patient_id)
  7435. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7436. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7437. // var cFYLJG001 models.CFYLJG001
  7438. //
  7439. // timeLayout := "2006-01-02"
  7440. // loc, _ := time.LoadLocation("Local")
  7441. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7442. // if err != nil {
  7443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7444. // return
  7445. // }
  7446. // recordDateTime := theTime.Unix()
  7447. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7448. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7449. //
  7450. // //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7451. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7452. //
  7453. // //dept, _ := service.GetDepartMentDetail(info.Departments)
  7454. //
  7455. // for _, item := range prescriptions {
  7456. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7457. // if his.IdCardType == 1 {
  7458. // bas := strings.Split(psn.CardInfo, "|")
  7459. // basNumber := bas[1]
  7460. // fmt.Println(basNumber)
  7461. // card_sn := bas[3]
  7462. // card_no := bas[2]
  7463. // cFYLJG001.MdtrtCertType = "03"
  7464. // cFYLJG001.CardSn = card_sn
  7465. // cFYLJG001.MdtrtCertNo = card_no
  7466. // cFYLJG001.EcToken = ""
  7467. // cFYLJG001.AuthNo = ""
  7468. // } else if his.IdCardType == 2 {
  7469. // cFYLJG001.MdtrtCertType = "02"
  7470. // cFYLJG001.CardSn = ""
  7471. // cFYLJG001.MdtrtCertNo = his.IdCardNo
  7472. // cFYLJG001.EcToken = ""
  7473. // cFYLJG001.AuthNo = ""
  7474. // } else if his.IdCardType == 4 {
  7475. // cFYLJG001.MdtrtCertType = "01"
  7476. // cFYLJG001.CardSn = ""
  7477. // cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7478. // cFYLJG001.EcToken = psn.VerifyNumber
  7479. // cFYLJG001.AuthNo = ""
  7480. // }
  7481. // cFYLJG001.BizTypeCode = "01"
  7482. // cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7483. // cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7484. // cFYLJG001.RxTypeCode = "1"
  7485. // tempTime := time.Unix(item.PreTime, 0)
  7486. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7487. // cFYLJG001.PrscTime = timeFormatOne
  7488. // var count float64
  7489. // if item.Type == 1 {
  7490. // for _, sumItem := range item.HisDoctorAdviceInfo {
  7491. // count = count + sumItem.PrescribingNumber
  7492. // }
  7493. // }
  7494. // cFYLJG001.RxDrugCnt = count
  7495. // cFYLJG001.ValiDays = "5"
  7496. // ts := time.Unix(item.PreTime, 0)
  7497. // record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7498. // tempTime3 := time.Unix(record_time2, 0)
  7499. // timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7500. // cFYLJG001.ValiEndTime = timeFormat3
  7501. // cFYLJG001.RxCotnFlag = "0"
  7502. // for _, subItem := range item.HisDoctorAdviceInfo {
  7503. // var drug models.RxDrug
  7504. // drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7505. // drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7506. // drug.RxItemTypeCode = "11"
  7507. //
  7508. // drug.DrugDosform = "乳膏剂" //TODO
  7509. // if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7510. // drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7511. // }
  7512. //
  7513. // drug.MedcWayDscr = subItem.DeliveryWay
  7514. //
  7515. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7516. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7517. // drug.MedcBegntime = timeFormatTwo
  7518. // if subItem.Day > 0 {
  7519. // ts := time.Unix(subItem.StartTime, 0)
  7520. // record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7521. // tempTime4 := time.Unix(record_time, 0)
  7522. // timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7523. // drug.MedcEndtime = timeFormat5
  7524. // } else {
  7525. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7526. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7527. // drug.MedcEndtime = timeFormatTwo
  7528. // }
  7529. //
  7530. // drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7531. // drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7532. // drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7533. // drug.DrugCnt = subItem.PrescribingNumber
  7534. // drug.DrugDosunt = subItem.PrescribingNumberUnit
  7535. // drug.DrugGenname = subItem.AdviceName
  7536. // drug.MedcWayCodg = subItem.DeliveryWay
  7537. // //drug.DrugTotlcnt = subItem.PrescribingNumber
  7538. // drug.SinDoscnt = subItem.SingleDose
  7539. // drug.SinDosunt = subItem.SingleDoseUnit
  7540. // drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7541. // drug.UsedFrquName = subItem.ExecutionFrequency
  7542. // drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7543. // drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7544. // drug.HospApprFlag = "1"
  7545. // cFYLJG001.List = append(cFYLJG001.List, drug)
  7546. // }
  7547. // cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7548. // cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7549. // cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7550. // cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7551. // cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7552. // cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7553. // cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7554. // cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7555. // cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7556. // cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7557. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7558. // cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7559. // cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7560. // cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7561. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7562. // cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7563. // cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7564. // cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7565. // cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7566. // cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7567. // cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7568. // cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7569. // cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7570. // cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7571. // tempTime2 := time.Now().Unix()
  7572. // tempTime6 := time.Unix(tempTime2, 0)
  7573. // timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7574. // cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7575. // cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7576. // cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7577. // cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7578. // cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7579. //
  7580. // //memo := make(map[string]interface{})
  7581. // //inputData := make(map[string]interface{}, 0)
  7582. //
  7583. // //type MyData struct {
  7584. // // Insutype string `json:"insutype"`
  7585. // //}
  7586. // //
  7587. // // data := MyData{
  7588. // // Insutype: his.Insutype,
  7589. // //}
  7590. // //
  7591. //
  7592. // diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7593. // var config []*models.HisXtDiagnoseConfig
  7594. // for _, item := range diagnosis_ids {
  7595. // id, _ := strconv.ParseInt(item, 10, 64)
  7596. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  7597. // config = append(config, &diagnosisConfig)
  7598. // }
  7599. // for index, subitem := range config {
  7600. // if index == 0 {
  7601. // var dia models.DiseInfo
  7602. // dia.DiagType = "1"
  7603. // dia.MaindiagFlag = "1"
  7604. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7605. // dia.DiagCode = subitem.CountryCode
  7606. // dia.DiagName = subitem.ClassName
  7607. // dia.DiagDept = "肾内科"
  7608. // dia.DiagDrNo = doctor.DoctorNumber
  7609. // dia.DiagDrName = doctor.UserName
  7610. // tempTime3 := time.Unix(item.PreTime, 0)
  7611. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7612. // dia.DiagTime = timeFormatTwo
  7613. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7614. // } else {
  7615. // var dia models.DiseInfo
  7616. // dia.DiagType = "1"
  7617. // dia.MaindiagFlag = "0"
  7618. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7619. // dia.DiagCode = subitem.CountryCode
  7620. // dia.DiagName = subitem.ClassName
  7621. // dia.DiagDept = "肾内科"
  7622. // dia.DiagDrNo = doctor.DoctorNumber
  7623. // dia.DiagDrName = doctor.UserName
  7624. // tempTime3 := time.Unix(item.PreTime, 0)
  7625. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7626. // dia.DiagTime = timeFormatTwo
  7627. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7628. // }
  7629. // }
  7630. // if miConfig.MdtrtareaAdmvs == "340699" {
  7631. // //result, request := service.GetAHCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7632. // //saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7633. //
  7634. // } else {
  7635. // result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7636. // saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7637. //
  7638. // }
  7639. //
  7640. // var res ResultCFYLJG001
  7641. // var respJSON2 map[string]interface{}
  7642. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7643. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7644. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7645. // return
  7646. // }
  7647. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7648. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7649. // utils.ErrorLog("解析失败:%v", err)
  7650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7651. // return
  7652. // }
  7653. // if res.Infcode == -1 {
  7654. // c.ServeSuccessJSON(map[string]interface{}{
  7655. // "failed_code": -10,
  7656. // "msg": res.ErrMsg,
  7657. // })
  7658. // return
  7659. //
  7660. // } else {
  7661. // var flow models.HisPrescriptionFlow
  7662. // flow.Ctime = time.Now().Unix()
  7663. // flow.SignDigest = ""
  7664. // flow.RxTraceCode = res.Output.RxTraceCode
  7665. // flow.HiRxno = res.Output.HiRxno
  7666. // flow.MID = his.Number
  7667. // flow.Status = 1
  7668. // flow.DCode = doctor_info.DoctorNumber
  7669. // flow.OriginalRxFile = ""
  7670. // flow.OriginalValue = ""
  7671. // flow.SignCertDn = ""
  7672. // flow.UserOrgId = 10454
  7673. // flow.SignCertSn = ""
  7674. // flow.Mtime = time.Now().Unix()
  7675. //
  7676. // service.Createflow(&flow)
  7677. // c.ServeSuccessJSON(map[string]interface{}{
  7678. // "msg": "上传成功",
  7679. // })
  7680. // }
  7681. // }
  7682. //}
  7683. //func (c *HisApiController) GetCFYLJG002() {
  7684. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7685. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7686. // record_time := c.GetString("record_time")
  7687. // admin_user_id = 3626
  7688. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7689. // //id, _ := c.GetInt64("id")
  7690. // admin_user_id = 3626
  7691. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7692. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7693. //
  7694. // flow, _ := service.Getflowtwo(his.Number)
  7695. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  7696. // //record_time := c.GetString("record_time")
  7697. // patient_id, _ := c.GetInt64("patient_id")
  7698. // //patient_id = 23834
  7699. // //record_time = "2023-09-18"
  7700. // timeLayout := "2006-01-02"
  7701. // loc, _ := time.LoadLocation("Local")
  7702. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7703. // if err != nil {
  7704. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7705. // return
  7706. // }
  7707. // recordDateTime := theTime.Unix()
  7708. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7709. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7710. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7711. //
  7712. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7713. //
  7714. // inputData := make(map[string]interface{})
  7715. // inputData["rxTraceCode"] = flow.RxTraceCode
  7716. // inputData["hiRxno"] = flow.HiRxno
  7717. // inputData["mdtrtId"] = flow.MID
  7718. // inputData["patnName"] = his.PsnName
  7719. // inputData["psnCertType"] = his.PsnCertType
  7720. // inputData["certno"] = his.Certno
  7721. // inputData["fixmedinsName"] = miConfig.OrgName
  7722. // inputData["fixmedinsCode"] = miConfig.Code
  7723. // inputData["drCode"] = doctor_info.DoctorNumber
  7724. // inputData["prscDrName"] = doctor_info.UserName
  7725. // inputData["pharDeptName"] = dept.Name
  7726. // inputData["pharDeptCode"] = dept.Number
  7727. // inputData["pharProfttlCodg"] = dept.Name
  7728. // inputData["pharProfttlName"] = ""
  7729. // inputData["pharCode"] = "HY440309002107"
  7730. // inputData["pharCertType"] = "01"
  7731. // inputData["pharCertno"] = "430482199408260023"
  7732. // inputData["pharName"] = "彭斯遥"
  7733. // inputData["pharPracCertNo"] = ""
  7734. // tempTime2 := time.Unix(info.Ctime, 0)
  7735. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7736. // inputData["pharChkTime"] = timeFormatTwo
  7737. //
  7738. // bytesData, _ := json.Marshal(inputData)
  7739. // fmt.Println(string(bytesData))
  7740. // encoded := base64.StdEncoding.EncodeToString(bytesData)
  7741. // pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7742. // if err != nil {
  7743. // fmt.Println("Error reading PDF file:", err)
  7744. // return
  7745. // }
  7746. //
  7747. // // 将 PDF 文件内容进行 Base64 编码
  7748. // rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7749. //
  7750. // fmt.Println(err)
  7751. //
  7752. // if miConfig.MdtrtareaAdmvs == "340699" {
  7753. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7754. // //saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7755. //
  7756. // } else {
  7757. // result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7758. // //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7759. // saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7760. //
  7761. // }
  7762. //
  7763. // var res2 Result002
  7764. // var respJSON2 map[string]interface{}
  7765. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7766. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7767. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7768. // return
  7769. // }
  7770. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7771. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7772. // utils.ErrorLog("解析失败:%v", err)
  7773. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7774. // return
  7775. // }
  7776. // if res2.Infcode == 0 {
  7777. // flow.Ctime = time.Now().Unix()
  7778. // flow.SignDigest = res2.Output.SignDigest
  7779. // flow.RxFile = res2.Output.RxFile
  7780. // flow.MID = his.Number
  7781. // flow.Status = 1
  7782. // flow.DCode = doctor_info.DoctorNumber
  7783. // flow.OriginalRxFile = rx_encoded
  7784. // flow.OriginalValue = encoded
  7785. // flow.SignCertDn = res2.Output.SignCertDn
  7786. // flow.SignCertSn = res2.Output.SignCertSn
  7787. // flow.Mtime = time.Now().Unix()
  7788. // service.Saveflow(flow)
  7789. // c.ServeSuccessJSON(map[string]interface{}{
  7790. // "msg": "预签名成功",
  7791. // })
  7792. // } else {
  7793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7794. // return
  7795. // }
  7796. //}
  7797. //func (c *HisApiController) GetCFYLJG003() {
  7798. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7799. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7800. // record_time := c.GetString("record_time")
  7801. // admin_user_id = 3626
  7802. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7803. // //id, _ := c.GetInt64("id")
  7804. // admin_user_id = 3626
  7805. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7806. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7807. //
  7808. // flow, _ := service.Getflowtwo(his.Number)
  7809. // //id = 3
  7810. // patient_id, _ := c.GetInt64("patient_id")
  7811. // //patient_id = 23834
  7812. // //record_time = "2023-09-18"
  7813. // timeLayout := "2006-01-02"
  7814. // loc, _ := time.LoadLocation("Local")
  7815. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7816. // if err != nil {
  7817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7818. // return
  7819. // }
  7820. // recordDateTime := theTime.Unix()
  7821. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7822. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7823. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7824. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7825. //
  7826. // //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7827. //
  7828. // var cFYLJG003 models.CFYLJG003
  7829. //
  7830. // cFYLJG003.RxTraceCode = flow.RxTraceCode
  7831. // cFYLJG003.HiRxno = flow.HiRxno
  7832. // cFYLJG003.MdtrtID = flow.MID
  7833. // cFYLJG003.PatnName = his.Name
  7834. // cFYLJG003.Certno = his.Certno
  7835. // cFYLJG003.FixmedinsName = miConfig.OrgName
  7836. // cFYLJG003.FixmedinsCode = miConfig.Code
  7837. //
  7838. // cFYLJG003.DrCode = doctor_info.DoctorNumber
  7839. // cFYLJG003.PrscDrName = doctor_info.UserName
  7840. // cFYLJG003.PharDeptName = dept.Name
  7841. // cFYLJG003.PharDeptCode = dept.Number
  7842. // cFYLJG003.PharCode = "HY440309002107"
  7843. // cFYLJG003.PharCertType = "01"
  7844. // cFYLJG003.PharCertno = "430482199408260023"
  7845. // cFYLJG003.PharName = "彭斯遥"
  7846. // cFYLJG003.PsnCertType = "01"
  7847. // cFYLJG003.RxFile = flow.RxFile
  7848. // cFYLJG003.SignDigest = flow.SignDigest
  7849. // cFYLJG003.FixmedinsCode = miConfig.Code
  7850. // cFYLJG003.PsnCertType = "01"
  7851. // cFYLJG003.PharProfttlCodg = dept.Name
  7852. // //inputData["pharProfttlCodg"] =dept.Name
  7853. //
  7854. // tempTime2 := time.Unix(info.Ctime, 0)
  7855. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7856. // cFYLJG003.PharChkTime = timeFormatTwo
  7857. //
  7858. // if miConfig.MdtrtareaAdmvs == "340699" {
  7859. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7860. // //result, request := service.GetAHCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7861. // //saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  7862. // } else {
  7863. // result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7864. // saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7865. //
  7866. // }
  7867. //
  7868. // var res ResultCFYLJG003
  7869. // var respJSON2 map[string]interface{}
  7870. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7871. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7872. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7873. // return
  7874. // }
  7875. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7876. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7877. // utils.ErrorLog("解析失败:%v", err)
  7878. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7879. // return
  7880. // }
  7881. // if res.Infcode == -1 {
  7882. // c.ServeSuccessJSON(map[string]interface{}{
  7883. // "failed_code": -10,
  7884. // "msg": res.ErrMsg,
  7885. // })
  7886. // return
  7887. // } else {
  7888. // c.ServeSuccessJSON(map[string]interface{}{
  7889. // "info": res.Output,
  7890. // })
  7891. // }
  7892. //
  7893. //}
  7894. //func (c *HisApiController) GetCFYLJG004() {
  7895. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7896. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7897. // record_time := c.GetString("record_time")
  7898. // admin_user_id = 3626
  7899. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7900. // //id, _ := c.GetInt64("id")
  7901. // admin_user_id = 3626
  7902. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7903. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7904. //
  7905. // flow, _ := service.Getflowtwo(his.Number)
  7906. // //id = 3
  7907. // patient_id, _ := c.GetInt64("patient_id")
  7908. // //patient_id = 23834
  7909. // //record_time = "2023-09-18"
  7910. // timeLayout := "2006-01-02"
  7911. // loc, _ := time.LoadLocation("Local")
  7912. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7913. // if err != nil {
  7914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7915. // return
  7916. // }
  7917. // recordDateTime := theTime.Unix()
  7918. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7919. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7920. // var cFYLJG004 models.CFYLJG004
  7921. // cFYLJG004.HiRxno = flow.HiRxno
  7922. // cFYLJG004.FixmedinsCode = miConfig.Code
  7923. // cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7924. // cFYLJG004.UndoDrCertType = "01"
  7925. // cFYLJG004.UndoRea = "撤销处方"
  7926. // cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7927. // cFYLJG004.UndoDrName = doctor_info.UserName
  7928. // cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7929. //
  7930. // if miConfig.MdtrtareaAdmvs == "340699" {
  7931. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7932. // //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7933. // //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  7934. //
  7935. // } else {
  7936. // result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7937. // saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7938. //
  7939. // }
  7940. //
  7941. // var res ResultCFYLJG004
  7942. // var respJSON2 map[string]interface{}
  7943. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7944. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7946. // return
  7947. // }
  7948. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7949. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7950. // utils.ErrorLog("解析失败:%v", err)
  7951. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7952. // return
  7953. // }
  7954. // if res.Infcode == -1 {
  7955. // c.ServeSuccessJSON(map[string]interface{}{
  7956. // "failed_code": -10,
  7957. // "msg": res.ErrMsg,
  7958. // })
  7959. // return
  7960. // } else {
  7961. // flow.Status = 0
  7962. // service.Saveflow(flow)
  7963. // c.ServeSuccessJSON(map[string]interface{}{
  7964. // "msg": "撤销成功",
  7965. // })
  7966. // return
  7967. //
  7968. // }
  7969. //}
  7970. //func (c *HisApiController) GetCFYLJG005() {
  7971. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7972. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7973. // //record_time := c.GetString("record_time")
  7974. // admin_user_id = 3626
  7975. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7976. // //id, _ := c.GetInt64("id")
  7977. // admin_user_id = 3626
  7978. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7979. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7980. //
  7981. // flow, _ := service.Getflowtwo(his.Number)
  7982. // //id = 3
  7983. // var cFYLJG005 models.CFYLJG005
  7984. //
  7985. // //patient_id, _ := c.GetInt64("patient_id")
  7986. // cFYLJG005.HiRxno = flow.HiRxno
  7987. // cFYLJG005.MdtrtID = flow.MID
  7988. // cFYLJG005.EcToken = ""
  7989. // cFYLJG005.PsnName = his.Name
  7990. // cFYLJG005.PsnCertType = "01"
  7991. // cFYLJG005.Certno = his.IdCardNo
  7992. //
  7993. // if miConfig.MdtrtareaAdmvs == "340699" {
  7994. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7995. //
  7996. // //result, request := service.GetAHCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7997. // //saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7998. //
  7999. // } else {
  8000. // result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8001. // saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8002. //
  8003. // }
  8004. //
  8005. // var res ResultCFYLJG005
  8006. // var respJSON2 map[string]interface{}
  8007. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8008. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8009. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8010. // return
  8011. // }
  8012. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8013. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8014. // utils.ErrorLog("解析失败:%v", err)
  8015. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8016. // return
  8017. // }
  8018. // if res.Infcode == -1 {
  8019. // c.ServeSuccessJSON(map[string]interface{}{
  8020. // "failed_code": -10,
  8021. // "msg": res.ErrMsg,
  8022. // })
  8023. // return
  8024. // } else {
  8025. // c.ServeSuccessJSON(map[string]interface{}{
  8026. // "info": res.Output,
  8027. // })
  8028. // return
  8029. // }
  8030. //}
  8031. //func (c *HisApiController) GetCFYLJG006() {
  8032. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8033. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8034. // admin_user_id = 3626
  8035. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8036. // //id, _ := c.GetInt64("id")
  8037. // admin_user_id = 3626
  8038. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8039. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8040. //
  8041. // flow, _ := service.Getflowtwo(his.Number)
  8042. // //id = 3
  8043. // patient_id, _ := c.GetInt64("patient_id")
  8044. // var cFYLJG006 models.CFYLJG006
  8045. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8046. // cFYLJG006.HiRxno = flow.HiRxno
  8047. // cFYLJG006.MdtrtID = flow.MID
  8048. // cFYLJG006.PsnName = patient.Name
  8049. // cFYLJG006.PsnCertType = "01"
  8050. // cFYLJG006.Certno = patient.IdCardNo
  8051. //
  8052. // if miConfig.MdtrtareaAdmvs == "340699" {
  8053. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8054. //
  8055. // result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8056. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8057. // } else {
  8058. // result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8059. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8060. // }
  8061. //
  8062. // var res ResultCFYLJG006
  8063. // var respJSON2 map[string]interface{}
  8064. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8065. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8067. // return
  8068. // }
  8069. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8070. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8071. // utils.ErrorLog("解析失败:%v", err)
  8072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8073. // return
  8074. // }
  8075. // if res.Infcode == -1 {
  8076. // c.ServeSuccessJSON(map[string]interface{}{
  8077. // "failed_code": -10,
  8078. // "msg": res.ErrMsg,
  8079. // })
  8080. // return
  8081. // } else {
  8082. // c.ServeSuccessJSON(map[string]interface{}{
  8083. // "info": res.Output,
  8084. // })
  8085. // return
  8086. // }
  8087. //}
  8088. //func (c *HisApiController) GetCFYLJG007() {
  8089. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8090. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8091. // admin_user_id = 3626
  8092. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8093. // //id, _ := c.GetInt64("id")
  8094. // admin_user_id = 3626
  8095. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8096. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8097. //
  8098. // flow, _ := service.Getflowtwo(his.Number)
  8099. // //id = 3
  8100. // patient_id, _ := c.GetInt64("patient_id")
  8101. // var cFYLJG007 models.CFYLJG007
  8102. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8103. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8104. //
  8105. // cFYLJG007.HiRxno = flow.HiRxno
  8106. // cFYLJG007.MdtrtID = flow.MID
  8107. // cFYLJG007.PsnNo = his.PsnNo
  8108. // cFYLJG007.PsnCertType = "01"
  8109. // cFYLJG007.Certno = patient.IdCardNo
  8110. // cFYLJG007.PsnName = patient.Name
  8111. //
  8112. // if miConfig.MdtrtareaAdmvs == "340699" {
  8113. // result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8114. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8115. // } else {
  8116. // result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8117. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8118. // }
  8119. //
  8120. // var res ResultCFYLJG007
  8121. // var respJSON2 map[string]interface{}
  8122. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8123. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8124. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8125. // return
  8126. // }
  8127. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8128. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8129. // utils.ErrorLog("解析失败:%v", err)
  8130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8131. // return
  8132. // }
  8133. // if res.Infcode == -1 {
  8134. // c.ServeSuccessJSON(map[string]interface{}{
  8135. // "failed_code": -10,
  8136. // "msg": res.ErrMsg,
  8137. // })
  8138. // return
  8139. // } else {
  8140. // c.ServeSuccessJSON(map[string]interface{}{
  8141. // "info": res,
  8142. // })
  8143. // return
  8144. // }
  8145. //}
  8146. //
  8147. //func (c *HisApiController) GetCFYLJG008() {
  8148. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8149. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8150. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8151. // var cFYLJG008 models.CFYLJG008
  8152. // //id, _ := c.GetInt64("id")
  8153. // patient_id, _ := c.GetInt64("patient_id")
  8154. // //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8155. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8156. // //id = 3
  8157. // //flow, _ := service.Getflow(id)
  8158. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  8159. //
  8160. // //
  8161. // //admin_user_id, _ := c.GetInt64("admin_user_id")
  8162. // //patient_id, _ := c.GetInt64("patient_id")
  8163. // //his_patient_id, _ := c.GetInt64("his_patient_id")
  8164. // record_time := c.GetString("record_time")
  8165. //
  8166. // admin_user_id = 3626
  8167. // patient_id = 19424
  8168. // //his_patient_id = 263947
  8169. // record_time = "2023-08-29"
  8170. //
  8171. // timeLayout := "2006-01-02"
  8172. // loc, _ := time.LoadLocation("Local")
  8173. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8174. // if err != nil {
  8175. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8176. // return
  8177. // }
  8178. // recordDateTime := theTime.Unix()
  8179. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8180. //
  8181. // cFYLJG008.FixmedinsName = ""
  8182. // cFYLJG008.Lat = ""
  8183. // cFYLJG008.Lng = ""
  8184. // cFYLJG008.OrderType = "1"
  8185. // cFYLJG008.PoolareaNo = ""
  8186. // cFYLJG008.Lng = ""
  8187. // cFYLJG008.PageNum = 1
  8188. // cFYLJG008.PageSize = 10
  8189. // var MPI models.MedinsProdInvChgDDTO
  8190. // MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8191. // MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8192. // cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8193. //
  8194. // if miConfig.MdtrtareaAdmvs == "340699" {
  8195. // result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8196. // saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8197. //
  8198. // } else {
  8199. // result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8200. // saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8201. //
  8202. // var res ResultCFYLJG008
  8203. // var respJSON2 map[string]interface{}
  8204. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8205. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8207. // return
  8208. // }
  8209. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8210. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8211. // utils.ErrorLog("解析失败:%v", err)
  8212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8213. // return
  8214. // }
  8215. // if res.Infcode == -1 {
  8216. // c.ServeSuccessJSON(map[string]interface{}{
  8217. // "failed_code": -10,
  8218. // "msg": res.ErrMsg,
  8219. // })
  8220. // return
  8221. // } else {
  8222. // c.ServeSuccessJSON(map[string]interface{}{
  8223. // "info": res.Output,
  8224. // })
  8225. // return
  8226. // }
  8227. // }
  8228. //
  8229. //}
  8230. func (c *HisApiController) GetBL4201A() {
  8231. order_id, _ := c.GetInt64("order_id")
  8232. admin_user_id, _ := c.GetInt64("admin_user_id")
  8233. order, _ := service.GetHisOrderByIDTwo(order_id)
  8234. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8235. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8236. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8237. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8238. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8239. department, _ := service.GetDepartMentDetail(his.Departments)
  8240. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8241. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8242. if order.ID == 0 {
  8243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8244. return
  8245. }
  8246. var struct4201A models.Struct4201A
  8247. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8248. for _, items := range order_info {
  8249. memo := make(map[string]interface{})
  8250. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8251. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8252. fsiOPFLD.MedType = "14"
  8253. fsiOPFLD.BkkpSn = items.FeedetlSn
  8254. fsiOPFLD.FixmedinsCode = miConfig.Code
  8255. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8256. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8257. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8258. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8259. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8260. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8261. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8262. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8263. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8264. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8265. fsiOPFLD.BilgDeptName = department.Name
  8266. fsiOPFLD.BilgDeptCodg = department.Number
  8267. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8268. fsiOPFLD.BilgDrName = doctor.UserName
  8269. fsiOPFLD.MedChrgitmType = "09"
  8270. memo["hosp_appr_flag"] = "1"
  8271. memo["invoice_no"] = order.MdtrtId
  8272. memo["memo"] = "自费"
  8273. bytesData, _ := json.Marshal(memo)
  8274. fsiOPFLD.Memo = string(bytesData)
  8275. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8276. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8277. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8278. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8279. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8280. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8281. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8282. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8283. fsiOPFLD.BilgDeptName = department.Name
  8284. fsiOPFLD.BilgDeptCodg = department.Number
  8285. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8286. fsiOPFLD.BilgDrName = doctor.UserName
  8287. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8288. case 0:
  8289. break
  8290. case 1:
  8291. fsiOPFLD.MedChrgitmType = "14"
  8292. break
  8293. case 2:
  8294. fsiOPFLD.MedChrgitmType = "05"
  8295. break
  8296. case 3:
  8297. fsiOPFLD.MedChrgitmType = "03"
  8298. break
  8299. case 4:
  8300. fsiOPFLD.MedChrgitmType = "03"
  8301. break
  8302. case 5:
  8303. fsiOPFLD.MedChrgitmType = "08"
  8304. break
  8305. case 6:
  8306. fsiOPFLD.MedChrgitmType = "14"
  8307. break
  8308. case 7:
  8309. fsiOPFLD.MedChrgitmType = "14"
  8310. break
  8311. case 8:
  8312. fsiOPFLD.MedChrgitmType = "03"
  8313. break
  8314. case 9:
  8315. fsiOPFLD.MedChrgitmType = "14"
  8316. break
  8317. case 10:
  8318. fsiOPFLD.MedChrgitmType = "14"
  8319. break
  8320. case 11:
  8321. fsiOPFLD.MedChrgitmType = "06"
  8322. break
  8323. case 12:
  8324. fsiOPFLD.MedChrgitmType = "12"
  8325. break
  8326. case 13:
  8327. fsiOPFLD.MedChrgitmType = "01"
  8328. break
  8329. case 14:
  8330. fsiOPFLD.MedChrgitmType = "04"
  8331. break
  8332. case 15:
  8333. fsiOPFLD.MedChrgitmType = "14"
  8334. break
  8335. }
  8336. memo["hosp_appr_flag"] = "1"
  8337. memo["invoice_no"] = order.MdtrtId
  8338. memo["memo"] = "自费"
  8339. bytesData, _ := json.Marshal(memo)
  8340. fsiOPFLD.Memo = string(bytesData)
  8341. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8342. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8343. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8344. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8345. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8346. fsiOPFLD.BilgDeptName = department.Name
  8347. fsiOPFLD.BilgDeptCodg = department.Number
  8348. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8349. fsiOPFLD.BilgDrName = doctor.UserName
  8350. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8351. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8352. fsiOPFLD.MedChrgitmType = "08"
  8353. memo["hosp_appr_flag"] = "1"
  8354. memo["invoice_no"] = order.MdtrtId
  8355. memo["memo"] = "自费"
  8356. bytesData, _ := json.Marshal(memo)
  8357. fsiOPFLD.Memo = string(bytesData)
  8358. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8359. }
  8360. }
  8361. }
  8362. for _, items := range order_info_two {
  8363. memo := make(map[string]interface{})
  8364. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8365. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8366. fsiOPFLD.MedType = "14"
  8367. fsiOPFLD.BkkpSn = items.FeedetlSn
  8368. fsiOPFLD.FixmedinsCode = miConfig.Code
  8369. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8370. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8371. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8372. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8373. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8374. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8375. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8376. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8377. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8378. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8379. fsiOPFLD.BilgDeptName = department.Name
  8380. fsiOPFLD.BilgDeptCodg = department.Number
  8381. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8382. fsiOPFLD.BilgDrName = doctor.UserName
  8383. fsiOPFLD.MedChrgitmType = "09"
  8384. memo["hosp_appr_flag"] = "1"
  8385. memo["invoice_no"] = order.MdtrtId
  8386. memo["memo"] = "自费"
  8387. bytesData, _ := json.Marshal(memo)
  8388. fsiOPFLD.Memo = string(bytesData)
  8389. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8390. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8391. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8392. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8393. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8394. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8395. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8396. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8397. fsiOPFLD.BilgDeptName = department.Name
  8398. fsiOPFLD.BilgDeptCodg = department.Number
  8399. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8400. fsiOPFLD.BilgDrName = doctor.UserName
  8401. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8402. case 0:
  8403. break
  8404. case 1:
  8405. fsiOPFLD.MedChrgitmType = "14"
  8406. break
  8407. case 2:
  8408. fsiOPFLD.MedChrgitmType = "05"
  8409. break
  8410. case 3:
  8411. fsiOPFLD.MedChrgitmType = "03"
  8412. break
  8413. case 4:
  8414. fsiOPFLD.MedChrgitmType = "03"
  8415. break
  8416. case 5:
  8417. fsiOPFLD.MedChrgitmType = "08"
  8418. break
  8419. case 6:
  8420. fsiOPFLD.MedChrgitmType = "14"
  8421. break
  8422. case 7:
  8423. fsiOPFLD.MedChrgitmType = "14"
  8424. break
  8425. case 8:
  8426. fsiOPFLD.MedChrgitmType = "03"
  8427. break
  8428. case 9:
  8429. fsiOPFLD.MedChrgitmType = "14"
  8430. break
  8431. case 10:
  8432. fsiOPFLD.MedChrgitmType = "14"
  8433. break
  8434. case 11:
  8435. fsiOPFLD.MedChrgitmType = "06"
  8436. break
  8437. case 12:
  8438. fsiOPFLD.MedChrgitmType = "12"
  8439. break
  8440. case 13:
  8441. fsiOPFLD.MedChrgitmType = "01"
  8442. break
  8443. case 14:
  8444. fsiOPFLD.MedChrgitmType = "04"
  8445. break
  8446. case 15:
  8447. fsiOPFLD.MedChrgitmType = "14"
  8448. break
  8449. }
  8450. memo["hosp_appr_flag"] = "1"
  8451. memo["invoice_no"] = order.MdtrtId
  8452. memo["memo"] = "自费"
  8453. bytesData, _ := json.Marshal(memo)
  8454. fsiOPFLD.Memo = string(bytesData)
  8455. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8456. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8457. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8458. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8459. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8460. fsiOPFLD.BilgDeptName = department.Name
  8461. fsiOPFLD.BilgDeptCodg = department.Number
  8462. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8463. fsiOPFLD.BilgDrName = doctor.UserName
  8464. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8465. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8466. fsiOPFLD.MedChrgitmType = "08"
  8467. memo["hosp_appr_flag"] = "1"
  8468. memo["invoice_no"] = order.MdtrtId
  8469. memo["memo"] = "自费"
  8470. bytesData, _ := json.Marshal(memo)
  8471. fsiOPFLD.Memo = string(bytesData)
  8472. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8473. }
  8474. }
  8475. }
  8476. fmt.Println(fsiOPFLDs)
  8477. struct4201A.Fopfd = fsiOPFLDs
  8478. fmt.Println(struct4201A.Fopfd)
  8479. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8480. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8481. var res2 ResultSix
  8482. var respJSON2 map[string]interface{}
  8483. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8486. return
  8487. }
  8488. userJSONBytes2, _ := json.Marshal(respJSON2)
  8489. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8490. utils.ErrorLog("解析失败:%v", err)
  8491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8492. return
  8493. }
  8494. if res2.Infcode != 0 {
  8495. c.ServeSuccessJSON(map[string]interface{}{
  8496. "failed_code": -10,
  8497. "msg": res2.ErrMsg,
  8498. })
  8499. return
  8500. } else {
  8501. order.IsUploadOrderInfo = 1
  8502. service.UpdateOrder(order)
  8503. c.ServeSuccessJSON(map[string]interface{}{
  8504. "msg": "上传成功",
  8505. })
  8506. }
  8507. }
  8508. func (c *HisApiController) Get3103() {
  8509. admin_user_id, _ := c.GetInt64("admin_user_id")
  8510. warm_type, _ := c.GetInt64("warm_type")
  8511. fk_state, _ := c.GetInt64("fk_state")
  8512. warm_ids := c.GetString("warm_ids")
  8513. desc := c.GetString("desc")
  8514. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8515. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8516. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  8517. saveLog(result, requestLog, "3103", "反馈")
  8518. var res2 ResultSix3103
  8519. var respJSON2 map[string]interface{}
  8520. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8523. return
  8524. }
  8525. userJSONBytes2, _ := json.Marshal(respJSON2)
  8526. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8527. utils.ErrorLog("解析失败:%v", err)
  8528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8529. return
  8530. }
  8531. if res2.Infcode != 0 {
  8532. c.ServeSuccessJSON(map[string]interface{}{
  8533. "failed_code": -10,
  8534. "msg": res2.ErrMsg,
  8535. })
  8536. return
  8537. } else {
  8538. c.ServeSuccessJSON(map[string]interface{}{
  8539. "msg": "反馈成功",
  8540. })
  8541. return
  8542. }
  8543. }
  8544. func (c *HisApiController) Get4201A() {
  8545. order_id, _ := c.GetInt64("order_id")
  8546. admin_user_id, _ := c.GetInt64("admin_user_id")
  8547. order, _ := service.GetHisOrderByIDTwo(order_id)
  8548. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8549. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8550. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8551. //order_info = append(order_info, order_info_two...)
  8552. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8553. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8554. department, _ := service.GetDepartMentDetail(his.Departments)
  8555. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8556. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8557. if order.ID == 0 {
  8558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8559. return
  8560. }
  8561. var struct4201A models.Struct4201A
  8562. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8563. for _, items := range order_info {
  8564. memo := make(map[string]interface{})
  8565. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8566. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8567. fsiOPFLD.MedType = "14"
  8568. fsiOPFLD.BkkpSn = items.FeedetlSn
  8569. fsiOPFLD.FixmedinsCode = miConfig.Code
  8570. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8571. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8572. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8573. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8574. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8575. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8576. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8577. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8578. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8579. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8580. fsiOPFLD.BilgDeptName = department.Name
  8581. fsiOPFLD.BilgDeptCodg = department.Number
  8582. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8583. fsiOPFLD.BilgDrName = doctor.UserName
  8584. fsiOPFLD.MedChrgitmType = "09"
  8585. memo["hosp_appr_flag"] = "1"
  8586. memo["invoice_no"] = order.MdtrtId
  8587. memo["memo"] = "自费"
  8588. bytesData, _ := json.Marshal(memo)
  8589. fsiOPFLD.Memo = string(bytesData)
  8590. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8591. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8592. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8593. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8594. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8595. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8596. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8597. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8598. fsiOPFLD.BilgDeptName = department.Name
  8599. fsiOPFLD.BilgDeptCodg = department.Number
  8600. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8601. fsiOPFLD.BilgDrName = doctor.UserName
  8602. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8603. case 0:
  8604. break
  8605. case 1:
  8606. fsiOPFLD.MedChrgitmType = "14"
  8607. break
  8608. case 2:
  8609. fsiOPFLD.MedChrgitmType = "05"
  8610. break
  8611. case 3:
  8612. fsiOPFLD.MedChrgitmType = "03"
  8613. break
  8614. case 4:
  8615. fsiOPFLD.MedChrgitmType = "03"
  8616. break
  8617. case 5:
  8618. fsiOPFLD.MedChrgitmType = "08"
  8619. break
  8620. case 6:
  8621. fsiOPFLD.MedChrgitmType = "14"
  8622. break
  8623. case 7:
  8624. fsiOPFLD.MedChrgitmType = "14"
  8625. break
  8626. case 8:
  8627. fsiOPFLD.MedChrgitmType = "03"
  8628. break
  8629. case 9:
  8630. fsiOPFLD.MedChrgitmType = "14"
  8631. break
  8632. case 10:
  8633. fsiOPFLD.MedChrgitmType = "14"
  8634. break
  8635. case 11:
  8636. fsiOPFLD.MedChrgitmType = "06"
  8637. break
  8638. case 12:
  8639. fsiOPFLD.MedChrgitmType = "12"
  8640. break
  8641. case 13:
  8642. fsiOPFLD.MedChrgitmType = "01"
  8643. break
  8644. case 14:
  8645. fsiOPFLD.MedChrgitmType = "04"
  8646. break
  8647. case 15:
  8648. fsiOPFLD.MedChrgitmType = "14"
  8649. break
  8650. }
  8651. memo["hosp_appr_flag"] = "1"
  8652. memo["invoice_no"] = order.MdtrtId
  8653. memo["memo"] = "自费"
  8654. bytesData, _ := json.Marshal(memo)
  8655. fsiOPFLD.Memo = string(bytesData)
  8656. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8657. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8658. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8659. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8660. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8661. fsiOPFLD.BilgDeptName = department.Name
  8662. fsiOPFLD.BilgDeptCodg = department.Number
  8663. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8664. fsiOPFLD.BilgDrName = doctor.UserName
  8665. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8666. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8667. fsiOPFLD.MedChrgitmType = "08"
  8668. memo["hosp_appr_flag"] = "1"
  8669. memo["invoice_no"] = order.MdtrtId
  8670. memo["memo"] = "自费"
  8671. bytesData, _ := json.Marshal(memo)
  8672. fsiOPFLD.Memo = string(bytesData)
  8673. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8674. }
  8675. }
  8676. }
  8677. for _, items := range order_info_two {
  8678. memo := make(map[string]interface{})
  8679. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8680. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8681. fsiOPFLD.MedType = "14"
  8682. fsiOPFLD.BkkpSn = items.FeedetlSn
  8683. fsiOPFLD.FixmedinsCode = miConfig.Code
  8684. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8685. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8686. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8687. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8688. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8689. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8690. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8691. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8692. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8693. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8694. fsiOPFLD.BilgDeptName = department.Name
  8695. fsiOPFLD.BilgDeptCodg = department.Number
  8696. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8697. fsiOPFLD.BilgDrName = doctor.UserName
  8698. fsiOPFLD.MedChrgitmType = "09"
  8699. memo["hosp_appr_flag"] = "1"
  8700. memo["invoice_no"] = order.MdtrtId
  8701. memo["memo"] = "自费"
  8702. bytesData, _ := json.Marshal(memo)
  8703. fsiOPFLD.Memo = string(bytesData)
  8704. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8705. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8706. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8707. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8708. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8709. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8710. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8711. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8712. fsiOPFLD.BilgDeptName = department.Name
  8713. fsiOPFLD.BilgDeptCodg = department.Number
  8714. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8715. fsiOPFLD.BilgDrName = doctor.UserName
  8716. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8717. case 0:
  8718. break
  8719. case 1:
  8720. fsiOPFLD.MedChrgitmType = "14"
  8721. break
  8722. case 2:
  8723. fsiOPFLD.MedChrgitmType = "05"
  8724. break
  8725. case 3:
  8726. fsiOPFLD.MedChrgitmType = "03"
  8727. break
  8728. case 4:
  8729. fsiOPFLD.MedChrgitmType = "03"
  8730. break
  8731. case 5:
  8732. fsiOPFLD.MedChrgitmType = "08"
  8733. break
  8734. case 6:
  8735. fsiOPFLD.MedChrgitmType = "14"
  8736. break
  8737. case 7:
  8738. fsiOPFLD.MedChrgitmType = "14"
  8739. break
  8740. case 8:
  8741. fsiOPFLD.MedChrgitmType = "03"
  8742. break
  8743. case 9:
  8744. fsiOPFLD.MedChrgitmType = "14"
  8745. break
  8746. case 10:
  8747. fsiOPFLD.MedChrgitmType = "14"
  8748. break
  8749. case 11:
  8750. fsiOPFLD.MedChrgitmType = "06"
  8751. break
  8752. case 12:
  8753. fsiOPFLD.MedChrgitmType = "12"
  8754. break
  8755. case 13:
  8756. fsiOPFLD.MedChrgitmType = "01"
  8757. break
  8758. case 14:
  8759. fsiOPFLD.MedChrgitmType = "04"
  8760. break
  8761. case 15:
  8762. fsiOPFLD.MedChrgitmType = "14"
  8763. break
  8764. }
  8765. memo["hosp_appr_flag"] = "1"
  8766. memo["invoice_no"] = order.MdtrtId
  8767. memo["memo"] = "自费"
  8768. bytesData, _ := json.Marshal(memo)
  8769. fsiOPFLD.Memo = string(bytesData)
  8770. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8771. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8772. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8773. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8774. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8775. fsiOPFLD.BilgDeptName = department.Name
  8776. fsiOPFLD.BilgDeptCodg = department.Number
  8777. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8778. fsiOPFLD.BilgDrName = doctor.UserName
  8779. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8780. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8781. fsiOPFLD.MedChrgitmType = "08"
  8782. memo["hosp_appr_flag"] = "1"
  8783. memo["invoice_no"] = order.MdtrtId
  8784. memo["memo"] = "自费"
  8785. bytesData, _ := json.Marshal(memo)
  8786. fsiOPFLD.Memo = string(bytesData)
  8787. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8788. }
  8789. }
  8790. }
  8791. fmt.Println(fsiOPFLDs)
  8792. struct4201A.Fopfd = fsiOPFLDs
  8793. fmt.Println(struct4201A.Fopfd)
  8794. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8795. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8796. var res2 ResultSix
  8797. var respJSON2 map[string]interface{}
  8798. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8801. return
  8802. }
  8803. userJSONBytes2, _ := json.Marshal(respJSON2)
  8804. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8805. utils.ErrorLog("解析失败:%v", err)
  8806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8807. return
  8808. }
  8809. if res2.Infcode != 0 {
  8810. c.ServeSuccessJSON(map[string]interface{}{
  8811. "failed_code": -10,
  8812. "msg": res2.ErrMsg,
  8813. })
  8814. return
  8815. } else {
  8816. order.IsUploadOrderInfo = 1
  8817. service.UpdateOrder(order)
  8818. c.ServeSuccessJSON(map[string]interface{}{
  8819. "msg": "上传成功",
  8820. })
  8821. }
  8822. }
  8823. func (c *HisApiController) Get4202() {
  8824. order_id, _ := c.GetInt64("order_id")
  8825. admin_user_id, _ := c.GetInt64("admin_user_id")
  8826. order, _ := service.GetHisOrderByIDTwo(order_id)
  8827. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8828. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8829. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8830. if order.ID == 0 {
  8831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8832. return
  8833. }
  8834. var struct4202 models.Struct4202
  8835. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8836. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8837. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8838. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8839. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8840. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8841. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8842. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8843. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8844. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8845. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8846. var config []*models.HisXtDiagnoseConfig
  8847. for _, item := range diagnosis_ids {
  8848. id, _ := strconv.ParseInt(item, 10, 64)
  8849. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8850. config = append(config, &diagnosisConfig)
  8851. }
  8852. var tempDiaginfos []models.OwnPayPatnDiagListD
  8853. for index, item := range config {
  8854. if index == 0 {
  8855. var tempDiaginfo models.OwnPayPatnDiagListD
  8856. tempDiaginfo.InoutDiagType = "1"
  8857. tempDiaginfo.DiagCode = item.CountryCode
  8858. tempDiaginfo.DiagName = item.CountryContentName
  8859. tempDiaginfo.DiagType = "1"
  8860. tempDiaginfo.DiagSrtNo = "1"
  8861. tempDiaginfo.MaindiagFlag = "1"
  8862. tempDiaginfo.ValiFlag = "1"
  8863. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8864. } else {
  8865. var tempDiaginfo models.OwnPayPatnDiagListD
  8866. tempDiaginfo.DiagCode = item.CountryCode
  8867. tempDiaginfo.DiagName = item.CountryContentName
  8868. tempDiaginfo.DiagType = "2"
  8869. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8870. tempDiaginfo.MaindiagFlag = "0"
  8871. tempDiaginfo.ValiFlag = "1"
  8872. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8873. }
  8874. }
  8875. struct4202.ODiagListD = tempDiaginfos
  8876. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8877. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8878. var res2 ResultSix
  8879. var respJSON2 map[string]interface{}
  8880. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8883. return
  8884. }
  8885. userJSONBytes2, _ := json.Marshal(respJSON2)
  8886. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8887. utils.ErrorLog("解析失败:%v", err)
  8888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8889. return
  8890. }
  8891. if res2.Infcode != 0 {
  8892. c.ServeSuccessJSON(map[string]interface{}{
  8893. "failed_code": -10,
  8894. "msg": res2.ErrMsg,
  8895. })
  8896. return
  8897. } else {
  8898. order.IsUploadDiagnose = 1
  8899. service.UpdateOrder(order)
  8900. c.ServeSuccessJSON(map[string]interface{}{
  8901. "msg": "上传成功",
  8902. })
  8903. }
  8904. }
  8905. func (c *HisApiController) Get4203() {
  8906. admin_user_id, _ := c.GetInt64("admin_user_id")
  8907. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8908. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8909. order_id, _ := c.GetInt64("order_id")
  8910. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8911. number := ""
  8912. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8913. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8914. if his.ID == 0 {
  8915. number = hospital.Number
  8916. } else {
  8917. number = his.Number
  8918. }
  8919. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8920. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8921. var res2 ResultSix
  8922. var respJSON2 map[string]interface{}
  8923. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8926. return
  8927. }
  8928. userJSONBytes2, _ := json.Marshal(respJSON2)
  8929. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8930. utils.ErrorLog("解析失败:%v", err)
  8931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8932. return
  8933. }
  8934. if res2.Infcode != 0 {
  8935. c.ServeSuccessJSON(map[string]interface{}{
  8936. "failed_code": -10,
  8937. "msg": res2.ErrMsg,
  8938. })
  8939. return
  8940. } else {
  8941. order.IsUploadSuccess = 1
  8942. service.UpdateOrderTwo(order)
  8943. c.ServeSuccessJSON(map[string]interface{}{
  8944. "msg": "上传成功",
  8945. })
  8946. }
  8947. }
  8948. func (c *HisApiController) Get4205() {
  8949. order_id, _ := c.GetInt64("order_id")
  8950. admin_user_id, _ := c.GetInt64("admin_user_id")
  8951. fapiao_code := c.GetString("fapiao_code")
  8952. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8953. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8954. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8955. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8956. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8957. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8958. //order_info = append(order_info, order_info_two...)
  8959. department, _ := service.GetDepartMentDetail(his.Departments)
  8960. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8961. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8962. if order.ID == 0 {
  8963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8964. return
  8965. }
  8966. var struct4201A models.Struct4201A
  8967. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8968. for _, items := range order_info {
  8969. memo := make(map[string]interface{})
  8970. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8971. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8972. fsiOPFLD.MedType = pre.MedType
  8973. fsiOPFLD.FixmedinsCode = miConfig.Code
  8974. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8975. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8976. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8977. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8978. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8979. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8980. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8981. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8982. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8983. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8984. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8985. fsiOPFLD.BilgDeptName = department.Name
  8986. fsiOPFLD.BilgDeptCodg = department.Number
  8987. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8988. fsiOPFLD.BilgDrName = doctor.UserName
  8989. fsiOPFLD.MedChrgitmType = "09"
  8990. memo["hosp_appr_flag"] = "1"
  8991. memo["invoice_no"] = fapiao_code
  8992. memo["memo"] = "自费"
  8993. bytesData, _ := json.Marshal(memo)
  8994. fsiOPFLD.Memo = string(bytesData)
  8995. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8996. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8997. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8998. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8999. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9000. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9001. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9002. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9003. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9004. fsiOPFLD.BilgDeptName = department.Name
  9005. fsiOPFLD.BilgDeptCodg = department.Number
  9006. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9007. fsiOPFLD.BilgDrName = doctor.UserName
  9008. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9009. case 0:
  9010. break
  9011. case 1:
  9012. fsiOPFLD.MedChrgitmType = "14"
  9013. break
  9014. case 2:
  9015. fsiOPFLD.MedChrgitmType = "05"
  9016. break
  9017. case 3:
  9018. fsiOPFLD.MedChrgitmType = "03"
  9019. break
  9020. case 4:
  9021. fsiOPFLD.MedChrgitmType = "03"
  9022. break
  9023. case 5:
  9024. fsiOPFLD.MedChrgitmType = "08"
  9025. break
  9026. case 6:
  9027. fsiOPFLD.MedChrgitmType = "14"
  9028. break
  9029. case 7:
  9030. fsiOPFLD.MedChrgitmType = "14"
  9031. break
  9032. case 8:
  9033. fsiOPFLD.MedChrgitmType = "03"
  9034. break
  9035. case 9:
  9036. fsiOPFLD.MedChrgitmType = "14"
  9037. break
  9038. case 10:
  9039. fsiOPFLD.MedChrgitmType = "14"
  9040. break
  9041. case 11:
  9042. fsiOPFLD.MedChrgitmType = "06"
  9043. break
  9044. case 12:
  9045. fsiOPFLD.MedChrgitmType = "12"
  9046. break
  9047. case 13:
  9048. fsiOPFLD.MedChrgitmType = "01"
  9049. break
  9050. case 14:
  9051. fsiOPFLD.MedChrgitmType = "04"
  9052. break
  9053. case 15:
  9054. fsiOPFLD.MedChrgitmType = "14"
  9055. break
  9056. }
  9057. memo["hosp_appr_flag"] = "1"
  9058. memo["invoice_no"] = fapiao_code
  9059. memo["memo"] = "自费"
  9060. bytesData, _ := json.Marshal(memo)
  9061. fsiOPFLD.Memo = string(bytesData)
  9062. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9063. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9064. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9065. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9066. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9067. fsiOPFLD.BilgDeptName = department.Name
  9068. fsiOPFLD.BilgDeptCodg = department.Number
  9069. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9070. fsiOPFLD.BilgDrName = doctor.UserName
  9071. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9072. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9073. fsiOPFLD.MedChrgitmType = "08"
  9074. memo["hosp_appr_flag"] = "1"
  9075. memo["invoice_no"] = fapiao_code
  9076. memo["memo"] = "自费"
  9077. bytesData, _ := json.Marshal(memo)
  9078. fsiOPFLD.Memo = string(bytesData)
  9079. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9080. }
  9081. }
  9082. }
  9083. for _, items := range order_info_two {
  9084. memo := make(map[string]interface{})
  9085. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9086. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9087. fsiOPFLD.MedType = pre.MedType
  9088. fsiOPFLD.BkkpSn = items.FeedetlSn
  9089. fsiOPFLD.FixmedinsCode = miConfig.Code
  9090. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9091. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9092. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9093. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9094. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9095. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9096. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9097. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9098. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9099. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9100. fsiOPFLD.BilgDeptName = department.Name
  9101. fsiOPFLD.BilgDeptCodg = department.Number
  9102. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9103. fsiOPFLD.BilgDrName = doctor.UserName
  9104. fsiOPFLD.MedChrgitmType = "09"
  9105. memo["hosp_appr_flag"] = "1"
  9106. memo["invoice_no"] = fapiao_code
  9107. memo["memo"] = "自费"
  9108. bytesData, _ := json.Marshal(memo)
  9109. fsiOPFLD.Memo = string(bytesData)
  9110. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9111. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9112. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9113. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9114. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9115. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9116. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9117. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9118. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9119. fsiOPFLD.BilgDeptName = department.Name
  9120. fsiOPFLD.BilgDeptCodg = department.Number
  9121. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9122. fsiOPFLD.BilgDrName = doctor.UserName
  9123. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9124. case 0:
  9125. break
  9126. case 1:
  9127. fsiOPFLD.MedChrgitmType = "14"
  9128. break
  9129. case 2:
  9130. fsiOPFLD.MedChrgitmType = "05"
  9131. break
  9132. case 3:
  9133. fsiOPFLD.MedChrgitmType = "03"
  9134. break
  9135. case 4:
  9136. fsiOPFLD.MedChrgitmType = "03"
  9137. break
  9138. case 5:
  9139. fsiOPFLD.MedChrgitmType = "08"
  9140. break
  9141. case 6:
  9142. fsiOPFLD.MedChrgitmType = "14"
  9143. break
  9144. case 7:
  9145. fsiOPFLD.MedChrgitmType = "14"
  9146. break
  9147. case 8:
  9148. fsiOPFLD.MedChrgitmType = "03"
  9149. break
  9150. case 9:
  9151. fsiOPFLD.MedChrgitmType = "14"
  9152. break
  9153. case 10:
  9154. fsiOPFLD.MedChrgitmType = "14"
  9155. break
  9156. case 11:
  9157. fsiOPFLD.MedChrgitmType = "06"
  9158. break
  9159. case 12:
  9160. fsiOPFLD.MedChrgitmType = "12"
  9161. break
  9162. case 13:
  9163. fsiOPFLD.MedChrgitmType = "01"
  9164. break
  9165. case 14:
  9166. fsiOPFLD.MedChrgitmType = "04"
  9167. break
  9168. case 15:
  9169. fsiOPFLD.MedChrgitmType = "14"
  9170. break
  9171. }
  9172. memo["hosp_appr_flag"] = "1"
  9173. memo["invoice_no"] = fapiao_code
  9174. memo["memo"] = "自费"
  9175. bytesData, _ := json.Marshal(memo)
  9176. fsiOPFLD.Memo = string(bytesData)
  9177. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9178. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9179. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9180. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9181. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9182. fsiOPFLD.BilgDeptName = department.Name
  9183. fsiOPFLD.BilgDeptCodg = department.Number
  9184. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9185. fsiOPFLD.BilgDrName = doctor.UserName
  9186. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9187. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9188. fsiOPFLD.MedChrgitmType = "08"
  9189. memo["hosp_appr_flag"] = "1"
  9190. memo["invoice_no"] = fapiao_code
  9191. memo["memo"] = "自费"
  9192. bytesData, _ := json.Marshal(memo)
  9193. fsiOPFLD.Memo = string(bytesData)
  9194. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9195. }
  9196. }
  9197. }
  9198. fmt.Println(fsiOPFLDs)
  9199. struct4201A.Fopfd = fsiOPFLDs
  9200. fmt.Println(struct4201A.Fopfd)
  9201. var struct4202 models.Struct4202
  9202. timeLayout := "2006-01-02 15:04:05"
  9203. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9204. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9205. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9206. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9207. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9208. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9209. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9210. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9211. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9212. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9213. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9214. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9215. var config []*models.HisXtDiagnoseConfig
  9216. for _, item := range diagnosis_ids {
  9217. id, _ := strconv.ParseInt(item, 10, 64)
  9218. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9219. config = append(config, &diagnosisConfig)
  9220. }
  9221. var tempDiaginfos []models.OwnPayPatnDiagListD
  9222. for index, item := range config {
  9223. if index == 0 {
  9224. var tempDiaginfo models.OwnPayPatnDiagListD
  9225. tempDiaginfo.InoutDiagType = "1"
  9226. tempDiaginfo.DiagCode = item.CountryCode
  9227. tempDiaginfo.DiagName = item.CountryContentName
  9228. tempDiaginfo.DiagType = "1"
  9229. tempDiaginfo.DiagSrtNo = "1"
  9230. tempDiaginfo.MaindiagFlag = "1"
  9231. tempDiaginfo.ValiFlag = "1"
  9232. tempDiaginfo.DiagDrName = doctor.UserName
  9233. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9234. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9235. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9236. } else {
  9237. var tempDiaginfo models.OwnPayPatnDiagListD
  9238. tempDiaginfo.DiagCode = item.CountryCode
  9239. tempDiaginfo.DiagName = item.CountryContentName
  9240. tempDiaginfo.DiagType = "2"
  9241. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9242. tempDiaginfo.MaindiagFlag = "0"
  9243. tempDiaginfo.ValiFlag = "1"
  9244. tempDiaginfo.DiagDrName = doctor.UserName
  9245. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9246. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9247. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9248. }
  9249. }
  9250. struct4202.ODiagListD = tempDiaginfos
  9251. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9252. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9253. var res2 ResultSix
  9254. var respJSON2 map[string]interface{}
  9255. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9258. return
  9259. }
  9260. userJSONBytes2, _ := json.Marshal(respJSON2)
  9261. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9262. utils.ErrorLog("解析失败:%v", err)
  9263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9264. return
  9265. }
  9266. if res2.Infcode != 0 {
  9267. c.ServeSuccessJSON(map[string]interface{}{
  9268. "failed_code": -10,
  9269. "msg": res2.ErrMsg,
  9270. })
  9271. return
  9272. } else {
  9273. order.IsUploadDiagnose = 1
  9274. order.IsUploadOrderInfo = 1
  9275. service.UpdateOrderTwo(order)
  9276. c.ServeSuccessJSON(map[string]interface{}{
  9277. "msg": "上传成功",
  9278. })
  9279. }
  9280. }
  9281. func (c *HisApiController) Get4207() {
  9282. admin_user_id, _ := c.GetInt64("admin_user_id")
  9283. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9284. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9285. order_id, _ := c.GetInt64("order_id")
  9286. order, _ := service.GetHisOrderByIDTwo(order_id)
  9287. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9288. var struct4207 models.Struct4207
  9289. struct4207.PageNum = "1"
  9290. struct4207.PageSize = "1000"
  9291. struct4207.FixmedinsCode = miConfig.Code
  9292. struct4207.FixmedinsMdtrtID = order.Number
  9293. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9294. saveLog(result, requestLog, "4207", "查询")
  9295. var res2 ResultSix
  9296. var respJSON2 map[string]interface{}
  9297. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9300. return
  9301. }
  9302. userJSONBytes2, _ := json.Marshal(respJSON2)
  9303. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9304. utils.ErrorLog("解析失败:%v", err)
  9305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9306. return
  9307. }
  9308. if res2.Infcode != 0 {
  9309. c.ServeSuccessJSON(map[string]interface{}{
  9310. "failed_code": -10,
  9311. "msg": res2.ErrMsg,
  9312. })
  9313. return
  9314. } else {
  9315. c.ServeSuccessJSON(map[string]interface{}{
  9316. "msg": "查询成功",
  9317. })
  9318. }
  9319. }
  9320. func (c *HisApiController) Get4208() {
  9321. admin_user_id, _ := c.GetInt64("admin_user_id")
  9322. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9323. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9324. order_id, _ := c.GetInt64("order_id")
  9325. order, _ := service.GetHisOrderByIDTwo(order_id)
  9326. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9327. var struct4208 models.Struct4208
  9328. struct4208.PageNum = "1"
  9329. struct4208.PageSize = "1000"
  9330. struct4208.PsnCertType = "01"
  9331. struct4208.Certno = his.Certno
  9332. struct4208.MedType = order.MedType
  9333. struct4208.PsnName = his.Name
  9334. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9335. saveLog(result, requestLog, "4208", "查询")
  9336. var res2 ResultSix
  9337. var respJSON2 map[string]interface{}
  9338. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9341. return
  9342. }
  9343. userJSONBytes2, _ := json.Marshal(respJSON2)
  9344. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9345. utils.ErrorLog("解析失败:%v", err)
  9346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9347. return
  9348. }
  9349. if res2.Infcode != 0 {
  9350. c.ServeSuccessJSON(map[string]interface{}{
  9351. "failed_code": -10,
  9352. "msg": res2.ErrMsg,
  9353. })
  9354. return
  9355. } else {
  9356. c.ServeSuccessJSON(map[string]interface{}{
  9357. "msg": "查询成功",
  9358. })
  9359. }
  9360. }
  9361. func (c *HisApiController) Get4209() {
  9362. admin_user_id, _ := c.GetInt64("admin_user_id")
  9363. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9364. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9365. order_id, _ := c.GetInt64("order_id")
  9366. order, _ := service.GetHisOrderByIDTwo(order_id)
  9367. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9368. var struct4209 models.Struct4209
  9369. struct4209.FixmedinsMdtrtID = order.Number
  9370. struct4209.FixmedinsCode = miConfig.Code
  9371. struct4209.PageSize = "1000"
  9372. struct4209.PageNum = "1"
  9373. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9374. saveLog(result, requestLog, "4209", "查询")
  9375. var res2 ResultSix
  9376. var respJSON2 map[string]interface{}
  9377. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9380. return
  9381. }
  9382. userJSONBytes2, _ := json.Marshal(respJSON2)
  9383. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9384. utils.ErrorLog("解析失败:%v", err)
  9385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9386. return
  9387. }
  9388. if res2.Infcode != 0 {
  9389. c.ServeSuccessJSON(map[string]interface{}{
  9390. "failed_code": -10,
  9391. "msg": res2.ErrMsg,
  9392. })
  9393. return
  9394. } else {
  9395. c.ServeSuccessJSON(map[string]interface{}{
  9396. "msg": "查询成功",
  9397. })
  9398. }
  9399. }
  9400. type Result3101 struct {
  9401. Infcode string `json:"infcode"`
  9402. InfRefmsgid string `json:"inf_refmsgid"`
  9403. RefmsgTime string `json:"refmsg_time"`
  9404. RespondTime string `json:"respond_time"`
  9405. Enctype string `json:"enctype"`
  9406. Signtype string `json:"signtype"`
  9407. ErrMsg string `json:"err_msg"`
  9408. Output struct {
  9409. Result []struct {
  9410. JudgeResultDetailDtos []struct {
  9411. VolaItemType string `json:"vola_item_type"`
  9412. MdtrtID string `json:"mdtrt_id"`
  9413. JrdID string `json:"jrd_id"`
  9414. PatnID string `json:"patn_id"`
  9415. RxID string `json:"rx_id"`
  9416. VolaAmt interface{} `json:"vola_amt"`
  9417. } `json:"judge_result_detail_dtos"`
  9418. RuleID string `json:"rule_id"`
  9419. VolaEvid string `json:"vola_evid"`
  9420. MdtrtID string `json:"mdtrt_id"`
  9421. RuleName string `json:"rule_name"`
  9422. VolaAmtStas string `json:"vola_amt_stas"`
  9423. JrID string `json:"jr_id"`
  9424. PatnID string `json:"patn_id"`
  9425. SevDeg string `json:"sev_deg"`
  9426. VolaAmt float64 `json:"vola_amt"`
  9427. VolaBhvrType string `json:"vola_bhvr_type"`
  9428. VolaCont string `json:"vola_cont"`
  9429. } `json:"result"`
  9430. } `json:"output"`
  9431. }
  9432. type Resultgd3101 struct {
  9433. Infcode int64 `json:"infcode"`
  9434. InfRefmsgid string `json:"inf_refmsgid"`
  9435. RefmsgTime string `json:"refmsg_time"`
  9436. RespondTime string `json:"respond_time"`
  9437. Enctype string `json:"enctype"`
  9438. Signtype string `json:"signtype"`
  9439. ErrMsg string `json:"err_msg"`
  9440. Output struct {
  9441. Result []struct {
  9442. JudgeResultDetailDtos []struct {
  9443. VolaItemType string `json:"vola_item_type"`
  9444. MdtrtID string `json:"mdtrt_id"`
  9445. JrdID string `json:"jrd_id"`
  9446. PatnID string `json:"patn_id"`
  9447. RxID string `json:"rx_id"`
  9448. VolaAmt interface{} `json:"vola_amt"`
  9449. } `json:"judge_result_detail_dtos"`
  9450. RuleID string `json:"rule_id"`
  9451. VolaEvid string `json:"vola_evid"`
  9452. MdtrtID string `json:"mdtrt_id"`
  9453. RuleName string `json:"rule_name"`
  9454. VolaAmtStas string `json:"vola_amt_stas"`
  9455. JrID string `json:"jr_id"`
  9456. PatnID string `json:"patn_id"`
  9457. SevDeg string `json:"sev_deg"`
  9458. VolaAmt float64 `json:"vola_amt"`
  9459. VolaBhvrType string `json:"vola_bhvr_type"`
  9460. VolaCont string `json:"vola_cont"`
  9461. } `json:"result"`
  9462. } `json:"output"`
  9463. }
  9464. func (c *HisApiController) ReadEleToken() {
  9465. admin_user_id, _ := c.GetInt64("admin_user_id")
  9466. his_patient_id, _ := c.GetInt64("his_patient_id")
  9467. adminUser := c.GetAdminUserInfo()
  9468. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9469. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9470. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9471. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9472. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9473. if len(tokens) > 0 {
  9474. c.ServeSuccessJSON(map[string]interface{}{
  9475. "msg": "读取成功",
  9476. })
  9477. } else {
  9478. c.ServeSuccessJSON(map[string]interface{}{
  9479. "failed_code": -10,
  9480. "msg": "读取失败",
  9481. })
  9482. }
  9483. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9484. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9485. if len(tokens) > 0 {
  9486. c.ServeSuccessJSON(map[string]interface{}{
  9487. "msg": "读取成功",
  9488. })
  9489. } else {
  9490. c.ServeSuccessJSON(map[string]interface{}{
  9491. "failed_code": -10,
  9492. "msg": "读取失败",
  9493. })
  9494. }
  9495. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9496. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9497. if len(tokens) > 0 {
  9498. c.ServeSuccessJSON(map[string]interface{}{
  9499. "msg": "读取成功",
  9500. })
  9501. } else {
  9502. c.ServeSuccessJSON(map[string]interface{}{
  9503. "failed_code": -10,
  9504. "msg": "读取失败",
  9505. })
  9506. }
  9507. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9508. var api string
  9509. 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 +
  9510. "&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"
  9511. resp, requestErr := http.Get(api)
  9512. if requestErr != nil {
  9513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9514. }
  9515. body, ioErr := ioutil.ReadAll(resp.Body)
  9516. if ioErr != nil {
  9517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9519. }
  9520. var respJSON map[string]interface{}
  9521. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9524. return
  9525. }
  9526. var status string
  9527. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9528. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9529. var token string
  9530. var res ResultTwo //1101结果
  9531. var res10265 ResultTwo10265 //1101结果
  9532. if status == "0" { //读卡成功
  9533. var card_info string //卡信息
  9534. var busi_card_info string
  9535. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9536. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9537. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9538. fmt.Println(card_info)
  9539. fmt.Println(busi_card_info)
  9540. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9541. result, _ := json.Marshal(respJSON)
  9542. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9543. utils.ErrorLog("解析失败:%v", err)
  9544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9545. return
  9546. }
  9547. res.ErrMsg = res10265.ErrMsg
  9548. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9549. res.Infcode = infocode
  9550. res.Output = res10265.Output
  9551. res.InfRefmsgid = res10265.InfRefmsgid
  9552. if res.Infcode == 0 {
  9553. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9554. if err == gorm.ErrRecordNotFound {
  9555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9556. return
  9557. } else if err != nil {
  9558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9559. return
  9560. } else {
  9561. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9562. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9563. infoStr := string(Iinfos)
  9564. idetinfoStr := string(Idetinfos)
  9565. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9566. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9567. psn := &models.HisPsn{
  9568. PsnNo: res.Output.Baseinfo.PsnNo,
  9569. PatientId: patient.ID,
  9570. Certno: res.Output.Baseinfo.Certno,
  9571. Gend: res.Output.Baseinfo.Gend,
  9572. Naty: res.Output.Baseinfo.Naty,
  9573. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9574. PsnName: res.Output.Baseinfo.PsnName,
  9575. Age: float64(age),
  9576. Brdy: b,
  9577. Idetinfo: idetinfoStr,
  9578. Insuinfo: infoStr,
  9579. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9580. CardInfo: card_info,
  9581. VerifyNumber: token,
  9582. IdCardType: 4,
  9583. }
  9584. var rf []*ResultFive
  9585. json.Unmarshal([]byte(infoStr), &rf)
  9586. var insutypes []*ResultFive
  9587. var insutype string
  9588. var is390 int = 0
  9589. var is310 int = 0
  9590. for _, item := range rf {
  9591. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9592. insutypes = append(insutypes, item)
  9593. }
  9594. }
  9595. if len(insutypes) == 1 {
  9596. insutype = insutypes[0].Insutype
  9597. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9598. } else {
  9599. for _, i := range insutypes {
  9600. if i.Insutype == "390" {
  9601. is390 = 1
  9602. }
  9603. if i.Insutype == "310" {
  9604. is310 = 1
  9605. }
  9606. }
  9607. }
  9608. if is390 == 1 {
  9609. insutype = "390"
  9610. }
  9611. if is310 == 1 {
  9612. insutype = "310"
  9613. }
  9614. if len(insutypes) == 0 {
  9615. insutype = "310"
  9616. }
  9617. service.CreateHisPsn(psn)
  9618. c.ServeSuccessJSON(map[string]interface{}{
  9619. "patient": patient,
  9620. "number": token,
  9621. "insutype": insutype,
  9622. })
  9623. }
  9624. } else {
  9625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9626. return
  9627. }
  9628. } else { //读卡失败
  9629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9630. return
  9631. }
  9632. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9633. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9634. if len(errMsg) == 0 {
  9635. type ELeData struct {
  9636. Data struct {
  9637. IdNo string `json:"idNo"`
  9638. IdType string `json:"idType"`
  9639. UserName string `json:"userName"`
  9640. EcToken string `json:"ecToken"`
  9641. InsuOrg string `json:"insuOrg"`
  9642. Gender string `json:"gender"`
  9643. Birthday string `json:"birthday"`
  9644. Nationality string `json:"nationality"`
  9645. Email string `json:"email"`
  9646. Extra string `json:"extra"`
  9647. } `json:"data"`
  9648. Code int `json:"code"`
  9649. Message string `json:"message"`
  9650. }
  9651. var ele ELeData
  9652. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9653. if err != nil {
  9654. utils.ErrorLog("解析失败:%v", err)
  9655. }
  9656. token := ele.Data.EcToken
  9657. if len(token) > 0 {
  9658. psn := &models.HisPsn{
  9659. PsnNo: his.PsnNo,
  9660. Age: 0,
  9661. PatientId: his.PatientId,
  9662. Certno: his.Certno,
  9663. Brdy: his.Brdy,
  9664. Gend: his.Gend,
  9665. Naty: his.Naty,
  9666. PsnCertType: his.PsnCertType,
  9667. PsnName: his.PsnName,
  9668. Idetinfo: his.Idetinfo,
  9669. Insuinfo: his.Iinfo,
  9670. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9671. CardInfo: outPutInfo,
  9672. VerifyNumber: token,
  9673. }
  9674. service.CreateHisPsn(psn)
  9675. }
  9676. if len(token) > 0 {
  9677. c.ServeSuccessJSON(map[string]interface{}{
  9678. "msg": "读取成功",
  9679. })
  9680. } else {
  9681. c.ServeSuccessJSON(map[string]interface{}{
  9682. "failed_code": -10,
  9683. "msg": "读取失败",
  9684. })
  9685. }
  9686. }
  9687. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9688. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9689. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9690. type ELeData struct {
  9691. Data struct {
  9692. IdNo string `json:"idNo"`
  9693. IdType string `json:"idType"`
  9694. UserName string `json:"userName"`
  9695. EcToken string `json:"ecToken"`
  9696. InsuOrg string `json:"insuOrg"`
  9697. Gender string `json:"gender"`
  9698. Birthday string `json:"birthday"`
  9699. Nationality string `json:"nationality"`
  9700. Email string `json:"email"`
  9701. Extra string `json:"extra"`
  9702. } `json:"data"`
  9703. Code int `json:"code"`
  9704. Message string `json:"message"`
  9705. }
  9706. var ele ELeData
  9707. err := json.Unmarshal([]byte(result), &ele)
  9708. if err != nil {
  9709. utils.ErrorLog("解析失败:%v", err)
  9710. }
  9711. token := ele.Data.EcToken
  9712. token = Remove0000(token)
  9713. fmt.Println(ele.Data.UserName)
  9714. 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)
  9715. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9716. var res ResultTwo
  9717. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9718. utils.ErrorLog("解析失败:%v", err)
  9719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9720. return
  9721. }
  9722. if res.Infcode == 0 {
  9723. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9724. if err == gorm.ErrRecordNotFound {
  9725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9726. return
  9727. } else if err != nil {
  9728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9729. return
  9730. } else {
  9731. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9732. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9733. infoStr := string(Iinfos)
  9734. idetinfoStr := string(Idetinfos)
  9735. psn := &models.HisPsn{
  9736. PsnNo: res.Output.Baseinfo.PsnNo,
  9737. PatientId: patient.ID,
  9738. Certno: res.Output.Baseinfo.Certno,
  9739. Gend: res.Output.Baseinfo.Gend,
  9740. Naty: res.Output.Baseinfo.Naty,
  9741. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9742. PsnName: res.Output.Baseinfo.PsnName,
  9743. Idetinfo: idetinfoStr,
  9744. Insuinfo: infoStr,
  9745. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9746. CardInfo: "",
  9747. VerifyNumber: token,
  9748. }
  9749. service.CreateHisPsn(psn)
  9750. c.ServeSuccessJSON(map[string]interface{}{
  9751. "patient": patient,
  9752. "number": token,
  9753. })
  9754. }
  9755. } else {
  9756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9757. return
  9758. }
  9759. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9760. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9761. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9762. type ELeData struct {
  9763. Data struct {
  9764. IdNo string `json:"idNo"`
  9765. IdType string `json:"idType"`
  9766. UserName string `json:"userName"`
  9767. EcToken string `json:"ecToken"`
  9768. InsuOrg string `json:"insuOrg"`
  9769. Gender string `json:"gender"`
  9770. Birthday string `json:"birthday"`
  9771. Nationality string `json:"nationality"`
  9772. Email string `json:"email"`
  9773. Extra string `json:"extra"`
  9774. } `json:"data"`
  9775. Code int `json:"code"`
  9776. Message string `json:"message"`
  9777. }
  9778. var ele ELeData
  9779. err := json.Unmarshal([]byte(result), &ele)
  9780. if err != nil {
  9781. utils.ErrorLog("解析失败:%v", err)
  9782. }
  9783. token := ele.Data.EcToken
  9784. token = Remove0000(token)
  9785. fmt.Println(ele.Data.UserName)
  9786. 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)
  9787. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9788. var res ResultTwo
  9789. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9790. utils.ErrorLog("解析失败:%v", err)
  9791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9792. return
  9793. }
  9794. if res.Infcode == 0 {
  9795. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9796. if err == gorm.ErrRecordNotFound {
  9797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9798. return
  9799. } else if err != nil {
  9800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9801. return
  9802. } else {
  9803. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9804. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9805. infoStr := string(Iinfos)
  9806. idetinfoStr := string(Idetinfos)
  9807. psn := &models.HisPsn{
  9808. PsnNo: res.Output.Baseinfo.PsnNo,
  9809. PatientId: patient.ID,
  9810. Certno: res.Output.Baseinfo.Certno,
  9811. Gend: res.Output.Baseinfo.Gend,
  9812. Naty: res.Output.Baseinfo.Naty,
  9813. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9814. PsnName: res.Output.Baseinfo.PsnName,
  9815. Idetinfo: idetinfoStr,
  9816. Insuinfo: infoStr,
  9817. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9818. CardInfo: "",
  9819. VerifyNumber: token,
  9820. }
  9821. service.CreateHisPsn(psn)
  9822. c.ServeSuccessJSON(map[string]interface{}{
  9823. "patient": patient,
  9824. "number": token,
  9825. })
  9826. }
  9827. } else {
  9828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9829. return
  9830. }
  9831. } else if miConfig.MdtrtareaAdmvs == "360100" {
  9832. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9833. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9834. type ELeData struct {
  9835. Data struct {
  9836. IdNo string `json:"idNo"`
  9837. IdType string `json:"idType"`
  9838. UserName string `json:"userName"`
  9839. EcToken string `json:"ecToken"`
  9840. InsuOrg string `json:"insuOrg"`
  9841. Gender string `json:"gender"`
  9842. Birthday string `json:"birthday"`
  9843. Nationality string `json:"nationality"`
  9844. Email string `json:"email"`
  9845. Extra string `json:"extra"`
  9846. } `json:"data"`
  9847. Code int `json:"code"`
  9848. Message string `json:"message"`
  9849. }
  9850. var ele ELeData
  9851. err := json.Unmarshal([]byte(result), &ele)
  9852. if err != nil {
  9853. utils.ErrorLog("解析失败:%v", err)
  9854. }
  9855. token := ele.Data.EcToken
  9856. token = Remove0000(token)
  9857. fmt.Println(ele.Data.UserName)
  9858. 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)
  9859. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9860. var res ResultTwo
  9861. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9862. utils.ErrorLog("解析失败:%v", err)
  9863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9864. return
  9865. }
  9866. if res.Infcode == 0 {
  9867. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9868. if err == gorm.ErrRecordNotFound {
  9869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9870. return
  9871. } else if err != nil {
  9872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9873. return
  9874. } else {
  9875. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9876. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9877. infoStr := string(Iinfos)
  9878. idetinfoStr := string(Idetinfos)
  9879. psn := &models.HisPsn{
  9880. PsnNo: res.Output.Baseinfo.PsnNo,
  9881. PatientId: patient.ID,
  9882. Certno: res.Output.Baseinfo.Certno,
  9883. Gend: res.Output.Baseinfo.Gend,
  9884. Naty: res.Output.Baseinfo.Naty,
  9885. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9886. PsnName: res.Output.Baseinfo.PsnName,
  9887. Idetinfo: idetinfoStr,
  9888. Insuinfo: infoStr,
  9889. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9890. CardInfo: "",
  9891. VerifyNumber: token,
  9892. }
  9893. service.CreateHisPsn(psn)
  9894. c.ServeSuccessJSON(map[string]interface{}{
  9895. "patient": patient,
  9896. "number": token,
  9897. })
  9898. }
  9899. } else {
  9900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9901. return
  9902. }
  9903. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9904. //if initFlag == 0 {
  9905. //c.TestGetJiangXiBasBaseInit()
  9906. //}
  9907. //if initEleFlag == 0 {
  9908. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9909. //}
  9910. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9911. utils.ErrorLog("解析失败:%v", json_result)
  9912. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9913. type ELeData struct {
  9914. Data struct {
  9915. IdNo string `json:"idNo"`
  9916. IdType string `json:"idType"`
  9917. UserName string `json:"userName"`
  9918. EcToken string `json:"ecToken"`
  9919. InsuOrg string `json:"insuOrg"`
  9920. Gender string `json:"gender"`
  9921. Birthday string `json:"birthday"`
  9922. Nationality string `json:"nationality"`
  9923. Email string `json:"email"`
  9924. Extra string `json:"extra"`
  9925. } `json:"data"`
  9926. Code int `json:"code"`
  9927. Message string `json:"message"`
  9928. }
  9929. var ele ELeData
  9930. err := json.Unmarshal([]byte(json_result), &ele)
  9931. if err != nil {
  9932. utils.ErrorLog("解析失败:%v", err)
  9933. }
  9934. token := ele.Data.EcToken
  9935. token = Remove0000(token)
  9936. //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)
  9937. 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)
  9938. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9939. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9940. var res ResultTwo
  9941. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9942. utils.ErrorLog("解析失败:%v", err)
  9943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9944. return
  9945. }
  9946. if res.Infcode == 0 {
  9947. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9948. if err == gorm.ErrRecordNotFound {
  9949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9950. return
  9951. } else if err != nil {
  9952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9953. return
  9954. } else {
  9955. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9956. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9957. infoStr := string(Iinfos)
  9958. idetinfoStr := string(Idetinfos)
  9959. psn := &models.HisPsn{
  9960. PsnNo: res.Output.Baseinfo.PsnNo,
  9961. PatientId: patient.ID,
  9962. Certno: res.Output.Baseinfo.Certno,
  9963. Gend: res.Output.Baseinfo.Gend,
  9964. Naty: res.Output.Baseinfo.Naty,
  9965. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9966. PsnName: res.Output.Baseinfo.PsnName,
  9967. Idetinfo: idetinfoStr,
  9968. Insuinfo: infoStr,
  9969. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9970. CardInfo: "",
  9971. VerifyNumber: token,
  9972. InsuplcAdmdvs: ele.Data.InsuOrg,
  9973. }
  9974. service.CreateHisPsn(psn)
  9975. c.ServeSuccessJSON(map[string]interface{}{
  9976. "patient": patient,
  9977. "number": token,
  9978. })
  9979. }
  9980. } else {
  9981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9982. return
  9983. }
  9984. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9985. res := c.GetoleInfo()
  9986. if res.Infcode == 0 {
  9987. var result string
  9988. if res.Output.MdtrtCertType == "01" {
  9989. 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)
  9990. } else if res.Output.MdtrtCertType == "02" {
  9991. 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)
  9992. } else if res.Output.MdtrtCertType == "03" {
  9993. 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)
  9994. }
  9995. var dat map[string]interface{}
  9996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9997. fmt.Println(dat)
  9998. } else {
  9999. fmt.Println(err)
  10000. }
  10001. userJSONBytes, _ := json.Marshal(dat)
  10002. var res2 ResultTwo
  10003. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10004. utils.ErrorLog("解析失败:%v", err)
  10005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10006. return
  10007. }
  10008. if res2.Infcode == 0 {
  10009. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10010. if err == gorm.ErrRecordNotFound {
  10011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10012. return
  10013. } else if err != nil {
  10014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10015. return
  10016. } else {
  10017. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10018. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10019. infoStr := string(Iinfos)
  10020. idetinfoStr := string(Idetinfos)
  10021. var rf []*ResultFive
  10022. json.Unmarshal([]byte(infoStr), &rf)
  10023. var insutypes []*ResultFive
  10024. var insutype string
  10025. var is390 int = 0
  10026. var is310 int = 0
  10027. //var insuplc_admdvs string
  10028. for _, item := range rf {
  10029. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10030. insutypes = append(insutypes, item)
  10031. }
  10032. }
  10033. if len(insutypes) == 1 {
  10034. insutype = insutypes[0].Insutype
  10035. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10036. } else {
  10037. for _, i := range insutypes {
  10038. if i.Insutype == "390" {
  10039. is390 = 1
  10040. }
  10041. if i.Insutype == "310" {
  10042. is310 = 1
  10043. }
  10044. }
  10045. }
  10046. if is390 == 1 {
  10047. insutype = "390"
  10048. }
  10049. if is310 == 1 {
  10050. insutype = "310"
  10051. }
  10052. if len(insutypes) == 0 {
  10053. insutype = "310"
  10054. }
  10055. psn := &models.HisPsn{
  10056. PsnNo: res2.Output.Baseinfo.PsnNo,
  10057. PatientId: patient.ID,
  10058. Certno: res2.Output.Baseinfo.Certno,
  10059. Gend: res2.Output.Baseinfo.Gend,
  10060. Naty: res2.Output.Baseinfo.Naty,
  10061. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10062. PsnName: res2.Output.Baseinfo.PsnName,
  10063. Idetinfo: idetinfoStr,
  10064. Insuinfo: infoStr,
  10065. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10066. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10067. VerifyNumber: res.Output.EcToken,
  10068. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10069. }
  10070. service.CreateHisPsn(psn)
  10071. c.ServeSuccessJSON(map[string]interface{}{
  10072. "patient": patient,
  10073. "number": res.Output.CardNo,
  10074. "insutype": insutype,
  10075. })
  10076. }
  10077. } else {
  10078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10079. return
  10080. }
  10081. } else {
  10082. c.ServeSuccessJSON(map[string]interface{}{
  10083. "failed_code": -10,
  10084. "msg": res.ErrMsg,
  10085. })
  10086. }
  10087. } else {
  10088. //if initFlag == 0 {
  10089. // c.TestGetBasBaseInit()
  10090. //}
  10091. //token := c.GetEleBaseInfo()
  10092. //token = Remove0000(token)
  10093. type ELeData struct {
  10094. Code string `json:"code"`
  10095. Data struct {
  10096. Aac002 string `json:"aac002"`
  10097. Aaz500 string `json:"aaz500"`
  10098. ActCardNo string `json:"actCardNo"`
  10099. Bab520 string `json:"bab520"`
  10100. Bkz543 string `json:"bkz543"`
  10101. BusinessType string `json:"businessType"`
  10102. CertfCodg string `json:"certfCodg"`
  10103. EcIndexNo string `json:"ecIndexNo"`
  10104. EcToken string `json:"ecToken"`
  10105. ID0000 string `json:"id0000"`
  10106. IDNo string `json:"idNo"`
  10107. IDType string `json:"idType"`
  10108. Idcode string `json:"idcode"`
  10109. IdentityToken string `json:"identity_token"`
  10110. InsuOrg string `json:"insuOrg"`
  10111. OfficeID string `json:"officeId"`
  10112. OfficeName string `json:"officeName"`
  10113. OperatorID string `json:"operatorId"`
  10114. OperatorName string `json:"operatorName"`
  10115. OrgID string `json:"orgId"`
  10116. UserName string `json:"userName"`
  10117. } `json:"data"`
  10118. Infno interface{} `json:"infno"`
  10119. Message string `json:"message"`
  10120. OrgID string `json:"orgId"`
  10121. TransType string `json:"transType"`
  10122. }
  10123. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10124. fmt.Println(result)
  10125. outPutInfo := Remove0000(result)
  10126. fmt.Println(outPutInfo)
  10127. var ele ELeData
  10128. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10129. if err != nil {
  10130. utils.ErrorLog("解析失败:%v", err)
  10131. }
  10132. token := ele.Data.EcToken
  10133. var result2 string
  10134. var requestLog2 string
  10135. if len(token) > 0 {
  10136. if strings.Contains(ele.Data.IDNo, "HKG") {
  10137. 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)
  10138. } else {
  10139. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10140. }
  10141. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10142. var res ResultTwo
  10143. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10144. utils.ErrorLog("解析失败:%v", err)
  10145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10146. return
  10147. }
  10148. if res.Infcode == 0 {
  10149. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10150. if err == gorm.ErrRecordNotFound {
  10151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10152. return
  10153. } else if err != nil {
  10154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10155. return
  10156. } else {
  10157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10159. infoStr := string(Iinfos)
  10160. idetinfoStr := string(Idetinfos)
  10161. psn := &models.HisPsn{
  10162. PsnNo: res.Output.Baseinfo.PsnNo,
  10163. PatientId: patient.ID,
  10164. Certno: res.Output.Baseinfo.Certno,
  10165. Gend: res.Output.Baseinfo.Gend,
  10166. Naty: res.Output.Baseinfo.Naty,
  10167. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10168. PsnName: res.Output.Baseinfo.PsnName,
  10169. Idetinfo: idetinfoStr,
  10170. Insuinfo: infoStr,
  10171. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10172. CardInfo: "",
  10173. VerifyNumber: token,
  10174. }
  10175. service.CreateHisPsn(psn)
  10176. c.ServeSuccessJSON(map[string]interface{}{
  10177. "msg": "读取成功",
  10178. })
  10179. }
  10180. } else {
  10181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10182. return
  10183. }
  10184. } else {
  10185. c.ServeSuccessJSON(map[string]interface{}{
  10186. "failed_code": -10,
  10187. "msg": "读取失败",
  10188. })
  10189. }
  10190. }
  10191. }
  10192. func (c *HisApiController) ReadEleFace() {
  10193. admin_user_id, _ := c.GetInt64("admin_user_id")
  10194. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10195. adminUser := c.GetAdminUserInfo()
  10196. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10197. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10198. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10199. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10200. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10201. if len(tokens) > 0 {
  10202. c.ServeSuccessJSON(map[string]interface{}{
  10203. "msg": "读取成功",
  10204. })
  10205. } else {
  10206. c.ServeSuccessJSON(map[string]interface{}{
  10207. "failed_code": -10,
  10208. "msg": "读取失败",
  10209. })
  10210. }
  10211. }
  10212. }
  10213. func (c *HisApiController) Get9001() {
  10214. adminUser := c.GetAdminUserInfo()
  10215. admin_user_id, _ := c.GetInt64("admin_user_id")
  10216. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10217. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10218. if miConfig.MdtrtareaAdmvs == "350500" {
  10219. service.GetFjAuthorizationInfo(miConfig.Code)
  10220. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10221. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10222. var dat map[string]interface{}
  10223. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10224. fmt.Println(dat)
  10225. } else {
  10226. fmt.Println(err)
  10227. }
  10228. userJSONBytes, _ := json.Marshal(dat)
  10229. var res models.Result9001
  10230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10231. utils.ErrorLog("解析失败:%v", err)
  10232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10233. return
  10234. }
  10235. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10236. fmt.Println(miConfig.SecretKey)
  10237. var res models.Result9001Two
  10238. 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 +
  10239. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10240. resp, requestErr := http.Get(api)
  10241. if requestErr != nil {
  10242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10243. return
  10244. }
  10245. body, ioErr := ioutil.ReadAll(resp.Body)
  10246. if ioErr != nil {
  10247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10249. return
  10250. }
  10251. var respJSON map[string]interface{}
  10252. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10255. return
  10256. }
  10257. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10258. if status == "0" {
  10259. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10260. c.ServeSuccessJSON(map[string]interface{}{
  10261. "failed_code": -10,
  10262. "msg": err_msg,
  10263. })
  10264. return
  10265. }
  10266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10267. result, _ := json.Marshal(respJSON)
  10268. fmt.Println("log")
  10269. fmt.Println(string(result))
  10270. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10271. utils.ErrorLog("解析失败:%v", err)
  10272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10273. return
  10274. }
  10275. if res.Infcode == 0 {
  10276. sign := models.HisSignIn{
  10277. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10278. SignNo: res.Output.Signinoutb.SignNo,
  10279. SignTime: "",
  10280. Ctime: time.Now().Unix(),
  10281. Mtime: time.Now().Unix(),
  10282. Status: 1,
  10283. InputLog: "",
  10284. OutputLog: "",
  10285. FixmedinsCode: miConfig.Code,
  10286. }
  10287. err := service.CreateSignIn(&sign)
  10288. if err == nil {
  10289. c.ServeSuccessJSON(map[string]interface{}{
  10290. "msg": "签到成功",
  10291. })
  10292. }
  10293. } else {
  10294. c.ServeSuccessJSON(map[string]interface{}{
  10295. "failed_code": -10,
  10296. "msg": res.ErrMsg,
  10297. })
  10298. return
  10299. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10300. //return
  10301. }
  10302. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10303. fmt.Println(miConfig.SecretKey)
  10304. var res models.Result9001Two
  10305. 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 +
  10306. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10307. resp, requestErr := http.Get(api)
  10308. if requestErr != nil {
  10309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10310. return
  10311. }
  10312. body, ioErr := ioutil.ReadAll(resp.Body)
  10313. if ioErr != nil {
  10314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10316. return
  10317. }
  10318. var respJSON map[string]interface{}
  10319. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10322. return
  10323. }
  10324. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10325. if status == "0" {
  10326. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10327. c.ServeSuccessJSON(map[string]interface{}{
  10328. "failed_code": -10,
  10329. "msg": err_msg,
  10330. })
  10331. return
  10332. }
  10333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10334. result, _ := json.Marshal(respJSON)
  10335. fmt.Println("log")
  10336. fmt.Println(string(result))
  10337. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10338. utils.ErrorLog("解析失败:%v", err)
  10339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10340. return
  10341. }
  10342. if res.Infcode == 0 {
  10343. sign := models.HisSignIn{
  10344. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10345. SignNo: res.Output.Signinoutb.SignNo,
  10346. SignTime: "",
  10347. Ctime: time.Now().Unix(),
  10348. Mtime: time.Now().Unix(),
  10349. Status: 1,
  10350. InputLog: "",
  10351. OutputLog: "",
  10352. FixmedinsCode: miConfig.Code,
  10353. }
  10354. err := service.CreateSignIn(&sign)
  10355. if err == nil {
  10356. c.ServeSuccessJSON(map[string]interface{}{
  10357. "msg": "签到成功",
  10358. })
  10359. }
  10360. } else {
  10361. c.ServeSuccessJSON(map[string]interface{}{
  10362. "failed_code": -10,
  10363. "msg": res.ErrMsg,
  10364. })
  10365. return
  10366. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10367. //return
  10368. }
  10369. } else {
  10370. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10371. var dat map[string]interface{}
  10372. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10373. fmt.Println(dat)
  10374. } else {
  10375. fmt.Println(err)
  10376. }
  10377. userJSONBytes, _ := json.Marshal(dat)
  10378. var res models.Result9001
  10379. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10380. utils.ErrorLog("解析失败:%v", err)
  10381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10382. return
  10383. }
  10384. if res.Infcode == 0 {
  10385. sign := models.HisSignIn{
  10386. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10387. SignNo: res.Output.Signinoutb.SignNo,
  10388. SignTime: res.Output.Signinoutb.SignTime,
  10389. Ctime: time.Now().Unix(),
  10390. Mtime: time.Now().Unix(),
  10391. Status: 1,
  10392. InputLog: "",
  10393. OutputLog: "",
  10394. FixmedinsCode: miConfig.Code,
  10395. }
  10396. err := service.CreateSignIn(&sign)
  10397. if err == nil {
  10398. c.ServeSuccessJSON(map[string]interface{}{
  10399. "msg": "签到成功",
  10400. })
  10401. }
  10402. }
  10403. }
  10404. }
  10405. 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) {
  10406. var res Result3101
  10407. adminUser := c.GetAdminUserInfo()
  10408. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10409. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10410. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10411. //record_time := c.GetString("record_time")
  10412. //trig_scen := c.GetString("trig_scen")
  10413. timeLayout := "2006-01-02"
  10414. loc, _ := time.LoadLocation("Local")
  10415. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10416. if err != nil {
  10417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10418. return res
  10419. }
  10420. recordDateTime := theTime.Unix()
  10421. var patientPrescription models.HisPrescriptionInfo
  10422. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10423. //if patientPrescription.ID == 0 {
  10424. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10425. //}
  10426. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10427. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10428. //
  10429. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10430. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10431. var pp models.PublicParams
  10432. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10433. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10434. pp.FixmedinsName = miConfig.OrgName
  10435. pp.FixmedinsCode = miConfig.Code
  10436. pp.RequestUrl = miConfig.Url
  10437. pp.Cainfo = miConfig.Cainfo
  10438. pp.SecretKey = miConfig.SecretKey
  10439. pp.AccessKey = miConfig.AccessKey
  10440. pp.OpterName = roles.UserName
  10441. var config []*models.HisXtDiagnoseConfig
  10442. for _, item := range diagnosis_ids {
  10443. id, _ := strconv.ParseInt(item, 10, 64)
  10444. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10445. config = append(config, &diagnosisConfig)
  10446. }
  10447. var pd models.PatientDtos
  10448. pd.PatnID = his.PsnNo
  10449. pd.PatnName = his.Name
  10450. pd.Gend = his.Gend
  10451. pd.Brdy = his.Brdy
  10452. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10453. pd.CurrMdtrtID = his.Number
  10454. var fed models.FsiEncounterDtos
  10455. fed.MdtrtID = his.Number
  10456. fed.MedinsID = miConfig.Code
  10457. fed.MedinsName = miConfig.OrgName
  10458. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10459. fed.MedMdtrtType = "1"
  10460. fed.MedinsType = "1"
  10461. fed.MedinsLv = "11"
  10462. tm := time.Unix(his.RecordDate, 0)
  10463. s_tm := tm.Format("2006-01-02 15:04:05")
  10464. fed.AdmDate = s_tm
  10465. fed.DscgDate = s_tm
  10466. fed.DscgMainDiseCodg = config[0].CountryCode
  10467. fed.DscgMainDiseName = config[0].CountryContentName
  10468. //诊断信息
  10469. var fdds []*models.FsiDiagnoseDtos
  10470. for index, item := range config {
  10471. if index == 0 {
  10472. var fdd models.FsiDiagnoseDtos
  10473. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10474. fdd.InoutDiseType = "1"
  10475. fdd.MaindiseFlag = "1"
  10476. fdd.DiseDate = s_tm
  10477. fdd.DiasSrtNo = "1"
  10478. fdd.DiseName = item.CountryContentName
  10479. fdd.DiseCodg = item.CountryCode
  10480. fdds = append(fdds, &fdd)
  10481. } else {
  10482. var fdd models.FsiDiagnoseDtos
  10483. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10484. fdd.InoutDiseType = "1"
  10485. fdd.MaindiseFlag = "1"
  10486. fdd.DiseDate = s_tm
  10487. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10488. fdd.DiseName = item.CountryContentName
  10489. fdd.DiseCodg = item.CountryCode
  10490. fdds = append(fdds, &fdd)
  10491. }
  10492. }
  10493. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10494. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10495. fed.AdmDeptName = de.Name
  10496. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10497. fed.DscgDeptName = de.Name
  10498. fed.MedMdtrtType = "1"
  10499. fed.MedType = "11"
  10500. //if his.Insutype == "390" {
  10501. // fed.MedType = "1402"
  10502. //} else {
  10503. // fed.MedType = "9933"
  10504. //}
  10505. var orders []*models.FsiOrderDtos
  10506. if trig_scen == "2" {
  10507. //处方医嘱信息
  10508. for _, item := range prescriptions {
  10509. for _, subItem := range item.HisDoctorAdviceInfo {
  10510. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10511. var order models.FsiOrderDtos
  10512. order.RxID = strconv.FormatInt(item.ID, 10)
  10513. order.Rxno = strconv.FormatInt(item.ID, 10)
  10514. order.LongDrordFlag = "0"
  10515. order.HilistType = "1"
  10516. order.ChrgType = "1"
  10517. order.DrordBhvr = "-"
  10518. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10519. order.HosplistName = subItem.BaseDrugLib.DrugName
  10520. order.HilistLv = "1"
  10521. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10522. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10523. order.HosplistName = subItem.BaseDrugLib.DrugName
  10524. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10525. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10526. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10527. order.OwnpayAmt = ""
  10528. order.SelfpayAmt = ""
  10529. order.Spec = ""
  10530. order.SpecUnt = ""
  10531. order.DrordBegnDate = s_tm
  10532. order.DrordStopDate = ""
  10533. order.DrordDrCodg = doctor_info.DoctorNumber
  10534. order.DrordDeptName = department.Name
  10535. order.DrordDeptCodg = department.Number
  10536. order.DrordDrName = doctor_info.UserName
  10537. order.DrordDrProfttl = "234"
  10538. order.CurrDrordFlag = "1"
  10539. orders = append(orders, &order)
  10540. }
  10541. }
  10542. for _, subItem := range item.HisPrescriptionProject {
  10543. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10544. var order models.FsiOrderDtos
  10545. order.RxID = strconv.FormatInt(item.ID, 10)
  10546. order.Rxno = strconv.FormatInt(item.ID, 10)
  10547. order.LongDrordFlag = "0"
  10548. order.HilistType = "1"
  10549. order.ChrgType = "1"
  10550. order.DrordBhvr = "-"
  10551. order.HilistCode = subItem.HisProject.MedicalCode
  10552. order.HosplistName = subItem.HisProject.ProjectName
  10553. order.HilistLv = "1"
  10554. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10555. order.HosplistCode = subItem.HisProject.MedicalCode
  10556. order.HosplistName = subItem.HisProject.ProjectName
  10557. order.Cnt = subItem.Count
  10558. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10559. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10560. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10561. order.OwnpayAmt = ""
  10562. order.SelfpayAmt = ""
  10563. order.Spec = ""
  10564. order.SpecUnt = ""
  10565. order.DrordBegnDate = s_tm
  10566. order.DrordStopDate = ""
  10567. order.DrordDrCodg = doctor_info.DoctorNumber
  10568. order.DrordDeptName = department.Name
  10569. order.DrordDeptCodg = department.Number
  10570. order.DrordDrName = doctor_info.UserName
  10571. order.DrordDrProfttl = "234"
  10572. order.CurrDrordFlag = "1"
  10573. orders = append(orders, &order)
  10574. }
  10575. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10576. var order models.FsiOrderDtos
  10577. order.RxID = strconv.FormatInt(item.ID, 10)
  10578. order.Rxno = strconv.FormatInt(item.ID, 10)
  10579. order.LongDrordFlag = "0"
  10580. order.HilistType = "1"
  10581. order.ChrgType = "1"
  10582. order.DrordBhvr = "-"
  10583. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10584. order.HosplistName = subItem.GoodInfo.GoodName
  10585. order.HilistLv = "1"
  10586. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10587. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10588. order.HosplistName = subItem.GoodInfo.GoodName
  10589. order.Cnt = subItem.Count
  10590. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10591. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10592. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10593. order.OwnpayAmt = ""
  10594. order.SelfpayAmt = ""
  10595. order.Spec = ""
  10596. order.SpecUnt = ""
  10597. order.DrordBegnDate = s_tm
  10598. order.DrordStopDate = ""
  10599. order.DrordDrCodg = doctor_info.DoctorNumber
  10600. order.DrordDeptName = department.Name
  10601. order.DrordDeptCodg = department.Number
  10602. order.DrordDrName = doctor_info.UserName
  10603. order.DrordDrProfttl = "234"
  10604. order.CurrDrordFlag = "1"
  10605. orders = append(orders, &order)
  10606. }
  10607. }
  10608. }
  10609. //处方医嘱信息
  10610. }
  10611. fed.MatnStas = "0"
  10612. fed.MedfeeSumamt = "0"
  10613. fed.OwnpayAmt = "0"
  10614. fed.SelfpayAmt = "0"
  10615. fed.AcctPayamt = "0"
  10616. fed.MaAmt = "0"
  10617. fed.HifpPayamt = "0"
  10618. fed.SetlTotlnum = "1"
  10619. fed.Insutype = his.Insutype
  10620. fed.ReimFlag = "0"
  10621. fed.OutSetlFlag = "0"
  10622. var fopd []*models.FsiOperationDtosData
  10623. data := make(map[string]interface{})
  10624. data["fed"] = fed
  10625. data["fdd"] = fdds
  10626. data["fod"] = orders
  10627. data["pd"] = pd
  10628. data["pp"] = pp
  10629. data["fopd"] = fopd
  10630. data["trig_scen"] = trig_scen
  10631. fmt.Println(data)
  10632. fmt.Println(fed)
  10633. fmt.Println(fdds)
  10634. fmt.Println(orders)
  10635. fmt.Println(pd)
  10636. fmt.Println(pp)
  10637. fmt.Println(fopd)
  10638. client := &http.Client{}
  10639. bytesData, _ := json.Marshal(data)
  10640. var req *http.Request
  10641. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10642. if miConfig.MdtrtareaAdmvs == "320921" {
  10643. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10644. } else {
  10645. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10646. }
  10647. resp, _ := client.Do(req)
  10648. defer resp.Body.Close()
  10649. body, ioErr := ioutil.ReadAll(resp.Body)
  10650. if ioErr != nil {
  10651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10653. return res
  10654. }
  10655. var respJSON map[string]interface{}
  10656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10659. return res
  10660. }
  10661. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10662. fmt.Println(respJSON)
  10663. result, _ := json.Marshal(respJSON)
  10664. fmt.Println(result)
  10665. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10666. utils.ErrorLog("解析失败:%v", err)
  10667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10668. return res
  10669. }
  10670. return res
  10671. } else {
  10672. //if miConfig.MdtrtareaAdmvs == "441202" {
  10673. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10674. saveLog(output, input, "3101", "事前")
  10675. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10676. utils.ErrorLog("解析失败:%v", err)
  10677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10678. return
  10679. }
  10680. return res
  10681. //}
  10682. }
  10683. }
  10684. 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) {
  10685. adminUser := c.GetAdminUserInfo()
  10686. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10687. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10688. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10689. //record_time := c.GetString("record_time")
  10690. //trig_scen := c.GetString("trig_scen")
  10691. timeLayout := "2006-01-02"
  10692. loc, _ := time.LoadLocation("Local")
  10693. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10694. if err != nil {
  10695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10696. return res
  10697. }
  10698. recordDateTime := theTime.Unix()
  10699. var patientPrescription models.HisPrescriptionInfo
  10700. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10701. if patientPrescription.ID == 0 {
  10702. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10703. }
  10704. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10705. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10706. //
  10707. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10708. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10709. var pp models.PublicParams
  10710. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10711. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10712. pp.FixmedinsName = miConfig.OrgName
  10713. pp.FixmedinsCode = miConfig.Code
  10714. pp.RequestUrl = miConfig.Url
  10715. pp.Cainfo = miConfig.Cainfo
  10716. pp.SecretKey = miConfig.SecretKey
  10717. pp.AccessKey = miConfig.AccessKey
  10718. pp.OpterName = roles.UserName
  10719. var config []*models.HisXtDiagnoseConfig
  10720. for _, item := range diagnosis_ids {
  10721. id, _ := strconv.ParseInt(item, 10, 64)
  10722. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10723. config = append(config, &diagnosisConfig)
  10724. }
  10725. var pd models.PatientDtos
  10726. pd.PatnID = his.PsnNo
  10727. pd.PatnName = his.Name
  10728. pd.Gend = his.Gend
  10729. pd.Brdy = his.Brdy
  10730. pd.Poolarea = his.InsuplcAdmdvs
  10731. pd.CurrMdtrtID = his.Number
  10732. var fed models.FsiEncounterDtos
  10733. fed.MdtrtID = his.Number
  10734. fed.MedinsID = miConfig.Code
  10735. fed.MedinsName = miConfig.OrgName
  10736. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10737. fed.MedMdtrtType = "1"
  10738. fed.MedinsType = "1"
  10739. fed.MedinsLv = "11"
  10740. tm := time.Unix(his.RecordDate, 0)
  10741. s_tm := tm.Format("2006-01-02 15:04:05")
  10742. fed.AdmDate = s_tm
  10743. fed.DscgDate = s_tm
  10744. fed.DscgMainDiseCodg = config[0].CountryCode
  10745. fed.DscgMainDiseName = config[0].CountryContentName
  10746. //诊断信息
  10747. var fdds []*models.FsiDiagnoseDtos
  10748. for index, item := range config {
  10749. if index == 0 {
  10750. var fdd models.FsiDiagnoseDtos
  10751. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10752. fdd.InoutDiseType = "1"
  10753. fdd.MaindiseFlag = "1"
  10754. fdd.DiseDate = s_tm
  10755. fdd.DiasSrtNo = "1"
  10756. fdd.DiseName = item.CountryContentName
  10757. fdd.DiseCodg = item.CountryCode
  10758. fdds = append(fdds, &fdd)
  10759. } else {
  10760. var fdd models.FsiDiagnoseDtos
  10761. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10762. fdd.InoutDiseType = "1"
  10763. fdd.MaindiseFlag = "1"
  10764. fdd.DiseDate = s_tm
  10765. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10766. fdd.DiseName = item.CountryContentName
  10767. fdd.DiseCodg = item.CountryCode
  10768. fdds = append(fdds, &fdd)
  10769. }
  10770. }
  10771. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10772. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10773. fed.AdmDeptName = department.Name
  10774. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10775. fed.DscgDeptName = department.Name
  10776. fed.MedMdtrtType = "1"
  10777. fed.MedType = "11"
  10778. //if his.Insutype == "390" {
  10779. // fed.MedType = "1402"
  10780. //} else {
  10781. // fed.MedType = "9933"
  10782. //}
  10783. var orders []*models.FsiOrderDtos
  10784. if trig_scen == "2" {
  10785. //处方医嘱信息
  10786. for _, item := range prescriptions {
  10787. for _, subItem := range item.HisDoctorAdviceInfo {
  10788. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10789. var order models.FsiOrderDtos
  10790. order.RxID = strconv.FormatInt(item.ID, 10)
  10791. order.Rxno = strconv.FormatInt(item.ID, 10)
  10792. order.LongDrordFlag = "0"
  10793. order.HilistType = "1"
  10794. order.ChrgType = "1"
  10795. order.DrordBhvr = "-"
  10796. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10797. order.HosplistName = subItem.BaseDrugLib.DrugName
  10798. order.HilistLv = "1"
  10799. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10800. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10801. order.HosplistName = subItem.BaseDrugLib.DrugName
  10802. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10803. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10804. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10805. order.OwnpayAmt = ""
  10806. order.SelfpayAmt = ""
  10807. order.Spec = ""
  10808. order.SpecUnt = ""
  10809. order.DrordBegnDate = s_tm
  10810. order.DrordStopDate = ""
  10811. order.DrordDrCodg = doctor_info.DoctorNumber
  10812. order.DrordDeptName = department.Name
  10813. order.DrordDeptCodg = department.Number
  10814. order.DrordDrName = doctor_info.UserName
  10815. order.DrordDrProfttl = "234"
  10816. order.CurrDrordFlag = "1"
  10817. orders = append(orders, &order)
  10818. }
  10819. }
  10820. for _, subItem := range item.HisPrescriptionProject {
  10821. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10822. var order models.FsiOrderDtos
  10823. order.RxID = strconv.FormatInt(item.ID, 10)
  10824. order.Rxno = strconv.FormatInt(item.ID, 10)
  10825. order.LongDrordFlag = "0"
  10826. order.HilistType = "1"
  10827. order.ChrgType = "1"
  10828. order.DrordBhvr = "-"
  10829. order.HilistCode = subItem.HisProject.MedicalCode
  10830. order.HosplistName = subItem.HisProject.ProjectName
  10831. order.HilistLv = "1"
  10832. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10833. order.HosplistCode = subItem.HisProject.MedicalCode
  10834. order.HosplistName = subItem.HisProject.ProjectName
  10835. order.Cnt = subItem.Count
  10836. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10837. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10838. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10839. order.OwnpayAmt = ""
  10840. order.SelfpayAmt = ""
  10841. order.Spec = ""
  10842. order.SpecUnt = ""
  10843. order.DrordBegnDate = s_tm
  10844. order.DrordStopDate = ""
  10845. order.DrordDrCodg = doctor_info.DoctorNumber
  10846. order.DrordDeptName = department.Name
  10847. order.DrordDeptCodg = department.Number
  10848. order.DrordDrName = doctor_info.UserName
  10849. order.DrordDrProfttl = "234"
  10850. order.CurrDrordFlag = "1"
  10851. orders = append(orders, &order)
  10852. }
  10853. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10854. var order models.FsiOrderDtos
  10855. order.RxID = strconv.FormatInt(item.ID, 10)
  10856. order.Rxno = strconv.FormatInt(item.ID, 10)
  10857. order.LongDrordFlag = "0"
  10858. order.HilistType = "1"
  10859. order.ChrgType = "1"
  10860. order.DrordBhvr = "-"
  10861. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10862. order.HosplistName = subItem.GoodInfo.GoodName
  10863. order.HilistLv = "1"
  10864. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10865. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10866. order.HosplistName = subItem.GoodInfo.GoodName
  10867. order.Cnt = subItem.Count
  10868. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10869. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10870. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10871. order.OwnpayAmt = ""
  10872. order.SelfpayAmt = ""
  10873. order.Spec = ""
  10874. order.SpecUnt = ""
  10875. order.DrordBegnDate = s_tm
  10876. order.DrordStopDate = ""
  10877. order.DrordDrCodg = doctor_info.DoctorNumber
  10878. order.DrordDeptName = department.Name
  10879. order.DrordDeptCodg = department.Number
  10880. order.DrordDrName = doctor_info.UserName
  10881. order.DrordDrProfttl = "234"
  10882. order.CurrDrordFlag = "1"
  10883. orders = append(orders, &order)
  10884. }
  10885. }
  10886. }
  10887. //处方医嘱信息
  10888. }
  10889. fed.MatnStas = "0"
  10890. fed.MedfeeSumamt = "0"
  10891. fed.OwnpayAmt = "0"
  10892. fed.SelfpayAmt = "0"
  10893. fed.AcctPayamt = "0"
  10894. fed.MaAmt = "0"
  10895. fed.HifpPayamt = "0"
  10896. fed.SetlTotlnum = "1"
  10897. fed.Insutype = his.Insutype
  10898. fed.ReimFlag = "0"
  10899. fed.OutSetlFlag = "0"
  10900. var fopd []*models.FsiOperationDtosData
  10901. data := make(map[string]interface{})
  10902. data["fed"] = fed
  10903. data["fdd"] = fdds
  10904. data["fod"] = orders
  10905. data["pd"] = pd
  10906. data["pp"] = pp
  10907. data["fopd"] = fopd
  10908. data["trig_scen"] = trig_scen
  10909. fmt.Println(data)
  10910. fmt.Println(fed)
  10911. fmt.Println(fdds)
  10912. fmt.Println(orders)
  10913. fmt.Println(pd)
  10914. fmt.Println(pp)
  10915. fmt.Println(fopd)
  10916. client := &http.Client{}
  10917. bytesData, _ := json.Marshal(data)
  10918. var req *http.Request
  10919. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10920. if miConfig.MdtrtareaAdmvs == "320921" {
  10921. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10922. } else {
  10923. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10924. }
  10925. resp, _ := client.Do(req)
  10926. defer resp.Body.Close()
  10927. body, ioErr := ioutil.ReadAll(resp.Body)
  10928. if ioErr != nil {
  10929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10931. return res
  10932. }
  10933. var respJSON map[string]interface{}
  10934. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10937. return res
  10938. }
  10939. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10940. fmt.Println(respJSON)
  10941. result, _ := json.Marshal(respJSON)
  10942. fmt.Println(result)
  10943. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10944. utils.ErrorLog("解析失败:%v", err)
  10945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10946. return res
  10947. }
  10948. return res
  10949. } else {
  10950. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10951. saveLog(output, input, "3101", "事前")
  10952. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10953. utils.ErrorLog("解析失败:%v", err)
  10954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10955. return
  10956. }
  10957. return res
  10958. }
  10959. return res
  10960. }
  10961. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10962. ////patient_id, _ := c.GetInt64("patient_id")
  10963. //order_id, _ := c.GetInt64("order_id")
  10964. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10965. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10966. //trig_scen := c.GetString("trig_scen")
  10967. adminUser := c.GetAdminUserInfo()
  10968. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10969. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10970. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10971. record_time := c.GetString("record_time")
  10972. order, _ := service.GetHisOrderByID(order_id)
  10973. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10974. timeLayout := "2006-01-02"
  10975. loc, _ := time.LoadLocation("Local")
  10976. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10977. if err != nil {
  10978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10979. return
  10980. }
  10981. recordDateTime := theTime.Unix()
  10982. var patientPrescription models.HisPrescriptionInfo
  10983. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10984. if patientPrescription.ID == 0 {
  10985. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10986. }
  10987. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10988. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10989. //
  10990. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10991. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10992. var pp models.PublicParams
  10993. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10994. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10995. pp.FixmedinsName = miConfig.OrgName
  10996. pp.FixmedinsCode = miConfig.Code
  10997. pp.RequestUrl = miConfig.Url
  10998. pp.Cainfo = miConfig.Cainfo
  10999. pp.SecretKey = miConfig.SecretKey
  11000. pp.AccessKey = miConfig.AccessKey
  11001. pp.OpterName = roles.UserName
  11002. var config []*models.HisXtDiagnoseConfig
  11003. for _, item := range diagnosis_ids {
  11004. id, _ := strconv.ParseInt(item, 10, 64)
  11005. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11006. config = append(config, &diagnosisConfig)
  11007. }
  11008. var pd models.PatientDtos
  11009. pd.PatnID = his.PsnNo
  11010. pd.PatnName = his.Name
  11011. pd.Gend = his.Gend
  11012. pd.Brdy = psn_info.Brdy
  11013. pd.Poolarea = his.InsuplcAdmdvs
  11014. pd.CurrMdtrtID = his.Number
  11015. var fed models.FsiEncounterDtos
  11016. fed.MdtrtID = his.Number
  11017. fed.MedinsID = miConfig.Code
  11018. fed.MedinsName = miConfig.OrgName
  11019. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11020. fed.MedMdtrtType = "1"
  11021. fed.MedinsType = "1"
  11022. fed.MedinsLv = "11"
  11023. tm := time.Unix(his.RecordDate, 0)
  11024. s_tm := tm.Format("2006-01-02 15:04:05")
  11025. fed.AdmDate = s_tm
  11026. fed.DscgDate = s_tm
  11027. fed.DscgMainDiseCodg = config[0].CountryCode
  11028. fed.DscgMainDiseName = config[0].CountryContentName
  11029. //诊断信息
  11030. var fdds []*models.FsiDiagnoseDtos
  11031. for index, item := range config {
  11032. if index == 0 {
  11033. var fdd models.FsiDiagnoseDtos
  11034. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11035. fdd.InoutDiseType = "1"
  11036. fdd.MaindiseFlag = "1"
  11037. fdd.DiseDate = s_tm
  11038. fdd.DiasSrtNo = "1"
  11039. fdd.DiseName = item.CountryContentName
  11040. fdd.DiseCodg = item.CountryCode
  11041. fdds = append(fdds, &fdd)
  11042. } else {
  11043. var fdd models.FsiDiagnoseDtos
  11044. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11045. fdd.InoutDiseType = "1"
  11046. fdd.MaindiseFlag = "1"
  11047. fdd.DiseDate = s_tm
  11048. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11049. fdd.DiseName = item.CountryContentName
  11050. fdd.DiseCodg = item.CountryCode
  11051. fdds = append(fdds, &fdd)
  11052. }
  11053. }
  11054. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11055. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11056. fed.AdmDeptName = department.Name
  11057. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11058. fed.DscgDeptName = department.Name
  11059. fed.MedType = order.MedType
  11060. //处方医嘱信息
  11061. var orders []*models.FsiOrderDtos
  11062. //for _, item := range prescriptions {
  11063. // for _, subItem := range item.HisDoctorAdviceInfo {
  11064. // var order models.FsiOrderDtos
  11065. // order.RxID = strconv.FormatInt(item.ID, 10)
  11066. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11067. // order.LongDrordFlag = "0"
  11068. // order.HilistType = "1"
  11069. // order.ChrgType = "1"
  11070. // order.DrordBhvr = "-"
  11071. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11072. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11073. // order.HilistLv = "1"
  11074. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11075. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11076. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11077. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11078. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11079. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11080. // order.OwnpayAmt = ""
  11081. // order.SelfpayAmt = ""
  11082. // order.Spec = ""
  11083. // order.SpecUnt = ""
  11084. // order.DrordBegnDate = s_tm
  11085. // order.DrordStopDate = ""
  11086. // order.DrordDrCodg = "1"
  11087. // order.DrordDeptName = department.Name
  11088. // order.DrordDrCodg = "1"
  11089. // order.DrordDrName = doctor_info.UserName
  11090. // order.DrordDrProfttl = ""
  11091. // order.CurrDrordFlag = "1"
  11092. // orders = append(orders, &order)
  11093. // }
  11094. // for _, subItem := range item.HisPrescriptionProject {
  11095. // if subItem.Type == 2 {
  11096. // var order models.FsiOrderDtos
  11097. // order.RxID = strconv.FormatInt(item.ID, 10)
  11098. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11099. // order.LongDrordFlag = "0"
  11100. // order.HilistType = "1"
  11101. // order.ChrgType = "1"
  11102. // order.DrordBhvr = "-"
  11103. // order.HilistCode = subItem.HisProject.MedicalCode
  11104. // order.HosplistName = subItem.HisProject.ProjectName
  11105. // order.HilistLv = "1"
  11106. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11107. // order.HosplistCode = subItem.HisProject.MedicalCode
  11108. // order.HosplistName = subItem.HisProject.ProjectName
  11109. // order.Cnt = subItem.Count
  11110. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11111. //
  11112. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11113. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11114. // order.OwnpayAmt = ""
  11115. // order.SelfpayAmt = ""
  11116. // order.Spec = ""
  11117. // order.SpecUnt = ""
  11118. // order.DrordBegnDate = s_tm
  11119. // order.DrordStopDate = ""
  11120. // order.DrordDrCodg = "1"
  11121. // order.DrordDeptName = department.Name
  11122. // order.DrordDrCodg = "1"
  11123. // order.DrordDrName = doctor_info.UserName
  11124. // order.DrordDrProfttl = ""
  11125. // order.CurrDrordFlag = "1"
  11126. // orders = append(orders, &order)
  11127. //
  11128. // }
  11129. // if subItem.Type == 3 {
  11130. //
  11131. // var order models.FsiOrderDtos
  11132. // order.RxID = strconv.FormatInt(item.ID, 10)
  11133. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11134. // order.LongDrordFlag = "0"
  11135. // order.HilistType = "1"
  11136. // order.ChrgType = "1"
  11137. // order.DrordBhvr = "-"
  11138. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11139. // order.HosplistName = subItem.GoodInfo.GoodName
  11140. // order.HilistLv = "1"
  11141. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11142. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11143. // order.HosplistName = subItem.GoodInfo.GoodName
  11144. // order.Cnt = subItem.Count
  11145. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11146. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11147. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11148. // order.OwnpayAmt = ""
  11149. // order.SelfpayAmt = ""
  11150. // order.Spec = ""
  11151. // order.SpecUnt = ""
  11152. // order.DrordBegnDate = s_tm
  11153. // order.DrordStopDate = ""
  11154. // order.DrordDrCodg = "1"
  11155. // order.DrordDeptName = department.Name
  11156. // order.DrordDrCodg = "1"
  11157. // order.DrordDrName = doctor_info.UserName
  11158. // order.DrordDrProfttl = ""
  11159. // order.CurrDrordFlag = "1"
  11160. // orders = append(orders, &order)
  11161. //
  11162. // }
  11163. // }
  11164. //}
  11165. for _, item := range prescriptions {
  11166. for _, subItem := range item.HisDoctorAdviceInfo {
  11167. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11168. var order models.FsiOrderDtos
  11169. order.RxID = strconv.FormatInt(item.ID, 10)
  11170. order.Rxno = strconv.FormatInt(item.ID, 10)
  11171. order.LongDrordFlag = "0"
  11172. order.HilistType = "101"
  11173. order.ChrgType = "1"
  11174. order.DrordBhvr = "-"
  11175. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11176. order.HosplistName = subItem.BaseDrugLib.DrugName
  11177. order.HilistLv = "1"
  11178. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11179. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11180. order.HosplistName = subItem.BaseDrugLib.DrugName
  11181. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11182. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11183. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11184. order.OwnpayAmt = ""
  11185. order.SelfpayAmt = ""
  11186. order.Spec = ""
  11187. order.SpecUnt = ""
  11188. order.DrordBegnDate = s_tm
  11189. order.DrordStopDate = ""
  11190. order.DrordDrCodg = doctor_info.DoctorNumber
  11191. order.DrordDeptName = department.Name
  11192. order.DrordDeptCodg = department.Number
  11193. order.DrordDrName = doctor_info.UserName
  11194. order.DrordDrProfttl = "234"
  11195. order.CurrDrordFlag = "1"
  11196. orders = append(orders, &order)
  11197. }
  11198. }
  11199. for _, subItem := range item.HisPrescriptionProject {
  11200. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11201. var order models.FsiOrderDtos
  11202. order.RxID = strconv.FormatInt(item.ID, 10)
  11203. order.Rxno = strconv.FormatInt(item.ID, 10)
  11204. order.LongDrordFlag = "0"
  11205. order.HilistType = "201"
  11206. order.ChrgType = "1"
  11207. order.DrordBhvr = "-"
  11208. order.HilistCode = subItem.HisProject.MedicalCode
  11209. order.HosplistName = subItem.HisProject.ProjectName
  11210. order.HilistLv = "1"
  11211. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11212. order.HosplistCode = subItem.HisProject.MedicalCode
  11213. order.HosplistName = subItem.HisProject.ProjectName
  11214. order.Cnt = subItem.Count
  11215. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11216. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11217. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11218. order.OwnpayAmt = ""
  11219. order.SelfpayAmt = ""
  11220. order.Spec = ""
  11221. order.SpecUnt = ""
  11222. order.DrordBegnDate = s_tm
  11223. order.DrordStopDate = ""
  11224. order.DrordDrCodg = doctor_info.DoctorNumber
  11225. order.DrordDeptName = department.Name
  11226. order.DrordDeptCodg = department.Number
  11227. order.DrordDrName = doctor_info.UserName
  11228. order.DrordDrProfttl = "234"
  11229. order.CurrDrordFlag = "1"
  11230. orders = append(orders, &order)
  11231. }
  11232. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11233. var order models.FsiOrderDtos
  11234. order.RxID = strconv.FormatInt(item.ID, 10)
  11235. order.Rxno = strconv.FormatInt(item.ID, 10)
  11236. order.LongDrordFlag = "0"
  11237. order.HilistType = "301"
  11238. order.ChrgType = "1"
  11239. order.DrordBhvr = "0"
  11240. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11241. order.HosplistName = subItem.GoodInfo.GoodName
  11242. order.HilistLv = "1"
  11243. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11244. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11245. order.HosplistName = subItem.GoodInfo.GoodName
  11246. order.Cnt = subItem.Count
  11247. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11248. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11249. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11250. order.OwnpayAmt = ""
  11251. order.SelfpayAmt = ""
  11252. order.Spec = ""
  11253. order.SpecUnt = ""
  11254. order.DrordBegnDate = s_tm
  11255. order.DrordStopDate = ""
  11256. order.DrordDrCodg = doctor_info.DoctorNumber
  11257. order.DrordDeptName = department.Name
  11258. order.DrordDeptCodg = department.Number
  11259. order.DrordDrName = doctor_info.UserName
  11260. order.DrordDrProfttl = "234"
  11261. order.CurrDrordFlag = "1"
  11262. orders = append(orders, &order)
  11263. }
  11264. }
  11265. }
  11266. //处方医嘱信息
  11267. fed.MatnStas = "0"
  11268. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11269. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11270. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11271. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11272. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11273. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11274. fed.SetlTotlnum = "1"
  11275. fed.Insutype = his.Insutype
  11276. fed.ReimFlag = "0"
  11277. fed.OutSetlFlag = "0"
  11278. var fopd []*models.FsiOperationDtosData
  11279. data := make(map[string]interface{})
  11280. data["fed"] = fed
  11281. data["fdd"] = fdds
  11282. data["fod"] = orders
  11283. data["pd"] = pd
  11284. data["pp"] = pp
  11285. data["fopd"] = fopd
  11286. data["trig_scen"] = trig_scen
  11287. client := &http.Client{}
  11288. bytesData, _ := json.Marshal(data)
  11289. var req *http.Request
  11290. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11291. if miConfig.MdtrtareaAdmvs == "320921" {
  11292. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11293. } else {
  11294. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11295. }
  11296. resp, _ := client.Do(req)
  11297. defer resp.Body.Close()
  11298. body, ioErr := ioutil.ReadAll(resp.Body)
  11299. if ioErr != nil {
  11300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11302. return res
  11303. }
  11304. var respJSON map[string]interface{}
  11305. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11308. return res
  11309. }
  11310. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11311. result, _ := json.Marshal(respJSON)
  11312. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11313. utils.ErrorLog("解析失败:%v", err)
  11314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11315. return res
  11316. }
  11317. return res
  11318. } else {
  11319. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11320. saveLog(output, input, "3102", "事中")
  11321. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11322. utils.ErrorLog("解析失败:%v", err)
  11323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11324. return
  11325. }
  11326. return res
  11327. }
  11328. return res
  11329. }
  11330. 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) {
  11331. var res Resultgd3101
  11332. adminUser := c.GetAdminUserInfo()
  11333. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11334. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11335. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11336. //record_time := c.GetString("record_time")
  11337. //trig_scen := c.GetString("trig_scen")
  11338. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11339. //psn_info, _ := service.GetPatientId(patient_id)
  11340. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11341. timeLayout := "2006-01-02"
  11342. loc, _ := time.LoadLocation("Local")
  11343. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11344. if err != nil {
  11345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11346. return res
  11347. }
  11348. recordDateTime := theTime.Unix()
  11349. var patientPrescription models.HisPrescriptionInfo
  11350. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11351. //if patientPrescription.ID == 0 {
  11352. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11353. //}
  11354. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11355. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11356. //
  11357. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11358. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11359. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11360. var pp models.PublicParams
  11361. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11362. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11363. pp.FixmedinsName = miConfig.OrgName
  11364. pp.FixmedinsCode = miConfig.Code
  11365. pp.RequestUrl = miConfig.Url
  11366. pp.Cainfo = miConfig.Cainfo
  11367. pp.SecretKey = miConfig.SecretKey
  11368. pp.AccessKey = miConfig.AccessKey
  11369. pp.OpterName = roles.UserName
  11370. var config []*models.HisXtDiagnoseConfig
  11371. for _, item := range diagnosis_ids {
  11372. id, _ := strconv.ParseInt(item, 10, 64)
  11373. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11374. config = append(config, &diagnosisConfig)
  11375. }
  11376. var pd models.PatientDtos
  11377. pd.PatnID = his.PsnNo
  11378. pd.PatnName = his.Name
  11379. pd.Gend = his.Gend
  11380. pd.Brdy = str
  11381. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11382. pd.CurrMdtrtID = his.Number
  11383. var fed models.FsiEncounterDtos
  11384. fed.MdtrtID = his.Number
  11385. fed.MedinsID = miConfig.Code
  11386. fed.MedinsName = miConfig.OrgName
  11387. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11388. fed.MedMdtrtType = "1"
  11389. fed.MedinsType = "1"
  11390. fed.MedinsLv = "11"
  11391. tm := time.Unix(his.RecordDate, 0)
  11392. s_tm := tm.Format("2006-01-02 15:04:05")
  11393. fed.AdmDate = s_tm
  11394. fed.DscgDate = s_tm
  11395. fed.DscgMainDiseCodg = config[0].CountryCode
  11396. fed.DscgMainDiseName = config[0].CountryContentName
  11397. //诊断信息
  11398. var fdds []*models.FsiDiagnoseDtos
  11399. for index, item := range config {
  11400. if index == 0 {
  11401. var fdd models.FsiDiagnoseDtos
  11402. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11403. fdd.InoutDiseType = "1"
  11404. fdd.MaindiseFlag = "1"
  11405. fdd.DiseDate = s_tm
  11406. fdd.DiasSrtNo = "1"
  11407. fdd.DiseName = item.CountryContentName
  11408. fdd.DiseCodg = item.CountryCode
  11409. fdds = append(fdds, &fdd)
  11410. } else {
  11411. var fdd models.FsiDiagnoseDtos
  11412. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11413. fdd.InoutDiseType = "1"
  11414. fdd.MaindiseFlag = "1"
  11415. fdd.DiseDate = s_tm
  11416. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11417. fdd.DiseName = item.CountryContentName
  11418. fdd.DiseCodg = item.CountryCode
  11419. fdds = append(fdds, &fdd)
  11420. }
  11421. }
  11422. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11423. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11424. fed.AdmDeptName = de.Name
  11425. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11426. fed.DscgDeptName = de.Name
  11427. fed.MedMdtrtType = "1"
  11428. fed.MedType = "11"
  11429. //if his.Insutype == "390" {
  11430. // fed.MedType = "1402"
  11431. //} else {
  11432. // fed.MedType = "9933"
  11433. //}
  11434. var orders []*models.FsiOrderDtos
  11435. if trig_scen == "2" {
  11436. //处方医嘱信息
  11437. for _, item := range prescriptions {
  11438. for _, subItem := range item.HisDoctorAdviceInfo {
  11439. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11440. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11441. var order models.FsiOrderDtos
  11442. order.RxID = strconv.FormatInt(item.ID, 10)
  11443. order.Rxno = strconv.FormatInt(item.ID, 10)
  11444. order.LongDrordFlag = "0"
  11445. order.HilistType = "101"
  11446. order.ChrgType = "1"
  11447. order.DrordBhvr = "0"
  11448. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11449. order.HosplistName = subItem.BaseDrugLib.DrugName
  11450. order.HilistLv = "1"
  11451. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11452. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11453. order.HosplistName = subItem.BaseDrugLib.DrugName
  11454. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11455. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11456. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11457. order.OwnpayAmt = ""
  11458. order.SelfpayAmt = ""
  11459. order.Spec = spec
  11460. order.SpecUnt = subItem.PrescribingNumberUnit
  11461. order.DrordBegnDate = s_tm
  11462. order.DrordStopDate = ""
  11463. order.DrordDrCodg = doctor_info.DoctorNumber
  11464. order.DrordDeptName = department.Name
  11465. order.DrordDeptCodg = department.Number
  11466. order.DrordDrName = doctor_info.UserName
  11467. order.DrordDrProfttl = "234"
  11468. order.CurrDrordFlag = "1"
  11469. orders = append(orders, &order)
  11470. }
  11471. }
  11472. for _, subItem := range item.HisPrescriptionProject {
  11473. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11474. var order models.FsiOrderDtos
  11475. order.RxID = strconv.FormatInt(item.ID, 10)
  11476. order.Rxno = strconv.FormatInt(item.ID, 10)
  11477. order.LongDrordFlag = "0"
  11478. order.HilistType = "201"
  11479. order.ChrgType = "1"
  11480. order.DrordBhvr = "0"
  11481. order.HilistCode = subItem.HisProject.MedicalCode
  11482. order.HosplistName = subItem.HisProject.ProjectName
  11483. order.HilistLv = "1"
  11484. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11485. order.HosplistCode = subItem.HisProject.MedicalCode
  11486. order.HosplistName = subItem.HisProject.ProjectName
  11487. order.Cnt = subItem.Count
  11488. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11489. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11490. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11491. order.OwnpayAmt = ""
  11492. order.SelfpayAmt = ""
  11493. order.Spec = subItem.Unit
  11494. order.SpecUnt = subItem.Unit
  11495. order.DrordBegnDate = s_tm
  11496. order.DrordStopDate = ""
  11497. order.DrordDrCodg = doctor_info.DoctorNumber
  11498. order.DrordDeptName = department.Name
  11499. order.DrordDeptCodg = department.Number
  11500. order.DrordDrName = doctor_info.UserName
  11501. order.DrordDrProfttl = "234"
  11502. order.CurrDrordFlag = "1"
  11503. orders = append(orders, &order)
  11504. }
  11505. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11506. var order models.FsiOrderDtos
  11507. order.RxID = strconv.FormatInt(item.ID, 10)
  11508. order.Rxno = strconv.FormatInt(item.ID, 10)
  11509. order.LongDrordFlag = "0"
  11510. order.HilistType = "301"
  11511. order.ChrgType = "1"
  11512. order.DrordBhvr = "0"
  11513. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11514. order.HosplistName = subItem.GoodInfo.GoodName
  11515. order.HilistLv = "1"
  11516. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11517. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11518. order.HosplistName = subItem.GoodInfo.GoodName
  11519. order.Cnt = subItem.Count
  11520. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11521. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11522. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11523. order.OwnpayAmt = ""
  11524. order.SelfpayAmt = ""
  11525. order.Spec = subItem.GoodInfo.SpecificationName
  11526. order.SpecUnt = subItem.Unit
  11527. order.DrordBegnDate = s_tm
  11528. order.DrordStopDate = ""
  11529. order.DrordDrCodg = doctor_info.DoctorNumber
  11530. order.DrordDeptName = department.Name
  11531. order.DrordDeptCodg = department.Number
  11532. order.DrordDrName = doctor_info.UserName
  11533. order.DrordDrProfttl = "234"
  11534. order.CurrDrordFlag = "1"
  11535. orders = append(orders, &order)
  11536. }
  11537. }
  11538. }
  11539. //处方医嘱信息
  11540. }
  11541. fed.MatnStas = "0"
  11542. fed.MedfeeSumamt = "0"
  11543. fed.OwnpayAmt = "0"
  11544. fed.SelfpayAmt = "0"
  11545. fed.AcctPayamt = "0"
  11546. fed.MaAmt = "0"
  11547. fed.HifpPayamt = "0"
  11548. fed.SetlTotlnum = "1"
  11549. fed.Insutype = his.Insutype
  11550. fed.ReimFlag = "0"
  11551. fed.OutSetlFlag = "0"
  11552. var fopd []*models.FsiOperationDtosData
  11553. data := make(map[string]interface{})
  11554. data["fed"] = fed
  11555. data["fdd"] = fdds
  11556. data["fod"] = orders
  11557. data["pd"] = pd
  11558. data["pp"] = pp
  11559. data["fopd"] = fopd
  11560. data["trig_scen"] = trig_scen
  11561. fmt.Println(data)
  11562. fmt.Println(fed)
  11563. fmt.Println(fdds)
  11564. fmt.Println(orders)
  11565. fmt.Println(pd)
  11566. fmt.Println(pp)
  11567. fmt.Println(fopd)
  11568. client := &http.Client{}
  11569. bytesData, _ := json.Marshal(data)
  11570. var req *http.Request
  11571. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11572. if miConfig.MdtrtareaAdmvs == "320921" {
  11573. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11574. } else {
  11575. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11576. }
  11577. resp, _ := client.Do(req)
  11578. defer resp.Body.Close()
  11579. body, ioErr := ioutil.ReadAll(resp.Body)
  11580. if ioErr != nil {
  11581. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11583. return res
  11584. }
  11585. var respJSON map[string]interface{}
  11586. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11589. return res
  11590. }
  11591. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11592. fmt.Println(respJSON)
  11593. result, _ := json.Marshal(respJSON)
  11594. fmt.Println(result)
  11595. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11596. utils.ErrorLog("解析失败:%v", err)
  11597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11598. return res
  11599. }
  11600. return res
  11601. } else {
  11602. //if miConfig.MdtrtareaAdmvs == "441202" {
  11603. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11604. saveLog(output, input, "3101", "事前")
  11605. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11606. utils.ErrorLog("解析失败:%v", err)
  11607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11608. return
  11609. }
  11610. return res
  11611. //}
  11612. }
  11613. }
  11614. 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) {
  11615. adminUser := c.GetAdminUserInfo()
  11616. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11617. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11618. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11619. //record_time := c.GetString("record_time")
  11620. //trig_scen := c.GetString("trig_scen")
  11621. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11622. timeLayout := "2006-01-02"
  11623. loc, _ := time.LoadLocation("Local")
  11624. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11625. if err != nil {
  11626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11627. return res
  11628. }
  11629. recordDateTime := theTime.Unix()
  11630. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11631. var patientPrescription models.HisPrescriptionInfo
  11632. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11633. if patientPrescription.ID == 0 {
  11634. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11635. }
  11636. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11637. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11638. //
  11639. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11640. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11641. var pp models.PublicParams
  11642. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11643. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11644. pp.FixmedinsName = miConfig.OrgName
  11645. pp.FixmedinsCode = miConfig.Code
  11646. pp.RequestUrl = miConfig.Url
  11647. pp.Cainfo = miConfig.Cainfo
  11648. pp.SecretKey = miConfig.SecretKey
  11649. pp.AccessKey = miConfig.AccessKey
  11650. pp.OpterName = roles.UserName
  11651. var config []*models.HisXtDiagnoseConfig
  11652. for _, item := range diagnosis_ids {
  11653. id, _ := strconv.ParseInt(item, 10, 64)
  11654. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11655. config = append(config, &diagnosisConfig)
  11656. }
  11657. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11658. var pd models.PatientDtos
  11659. pd.PatnID = his.PsnNo
  11660. pd.PatnName = his.Name
  11661. pd.Gend = his.Gend
  11662. pd.Brdy = str
  11663. pd.Poolarea = his.InsuplcAdmdvs
  11664. pd.CurrMdtrtID = his.Number
  11665. var fed models.FsiEncounterDtos
  11666. fed.MdtrtID = his.Number
  11667. fed.MedinsID = miConfig.Code
  11668. fed.MedinsName = miConfig.OrgName
  11669. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11670. fed.MedMdtrtType = "1"
  11671. fed.MedinsType = "1"
  11672. fed.MedinsLv = "11"
  11673. tm := time.Unix(his.RecordDate, 0)
  11674. s_tm := tm.Format("2006-01-02 15:04:05")
  11675. fed.AdmDate = s_tm
  11676. fed.DscgDate = s_tm
  11677. fed.DscgMainDiseCodg = config[0].CountryCode
  11678. fed.DscgMainDiseName = config[0].CountryContentName
  11679. //诊断信息
  11680. var fdds []*models.FsiDiagnoseDtos
  11681. for index, item := range config {
  11682. if index == 0 {
  11683. var fdd models.FsiDiagnoseDtos
  11684. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11685. fdd.InoutDiseType = "1"
  11686. fdd.MaindiseFlag = "1"
  11687. fdd.DiseDate = s_tm
  11688. fdd.DiasSrtNo = "1"
  11689. fdd.DiseName = item.CountryContentName
  11690. fdd.DiseCodg = item.CountryCode
  11691. fdds = append(fdds, &fdd)
  11692. } else {
  11693. var fdd models.FsiDiagnoseDtos
  11694. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11695. fdd.InoutDiseType = "1"
  11696. fdd.MaindiseFlag = "1"
  11697. fdd.DiseDate = s_tm
  11698. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11699. fdd.DiseName = item.CountryContentName
  11700. fdd.DiseCodg = item.CountryCode
  11701. fdds = append(fdds, &fdd)
  11702. }
  11703. }
  11704. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11705. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11706. fed.AdmDeptName = department.Name
  11707. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11708. fed.DscgDeptName = department.Name
  11709. fed.MedMdtrtType = "1"
  11710. fed.MedType = "11"
  11711. //if his.Insutype == "390" {
  11712. // fed.MedType = "1402"
  11713. //} else {
  11714. // fed.MedType = "9933"
  11715. //}
  11716. var orders []*models.FsiOrderDtos
  11717. if trig_scen == "2" {
  11718. //处方医嘱信息
  11719. for _, item := range prescriptions {
  11720. for _, subItem := range item.HisDoctorAdviceInfo {
  11721. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11722. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11723. var order models.FsiOrderDtos
  11724. order.RxID = strconv.FormatInt(item.ID, 10)
  11725. order.Rxno = strconv.FormatInt(item.ID, 10)
  11726. order.LongDrordFlag = "0"
  11727. order.HilistType = "101"
  11728. order.ChrgType = "1"
  11729. order.DrordBhvr = "0"
  11730. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11731. order.HosplistName = subItem.BaseDrugLib.DrugName
  11732. order.HilistLv = "1"
  11733. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11734. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11735. order.HosplistName = subItem.BaseDrugLib.DrugName
  11736. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11737. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11738. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11739. order.OwnpayAmt = ""
  11740. order.SelfpayAmt = ""
  11741. order.Spec = spec
  11742. order.SpecUnt = subItem.PrescribingNumberUnit
  11743. order.DrordBegnDate = s_tm
  11744. order.DrordStopDate = ""
  11745. order.DrordDrCodg = doctor_info.DoctorNumber
  11746. order.DrordDeptName = department.Name
  11747. order.DrordDeptCodg = department.Number
  11748. order.DrordDrName = doctor_info.UserName
  11749. order.DrordDrProfttl = "234"
  11750. order.CurrDrordFlag = "1"
  11751. orders = append(orders, &order)
  11752. }
  11753. }
  11754. for _, subItem := range item.HisPrescriptionProject {
  11755. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11756. var order models.FsiOrderDtos
  11757. order.RxID = strconv.FormatInt(item.ID, 10)
  11758. order.Rxno = strconv.FormatInt(item.ID, 10)
  11759. order.LongDrordFlag = "0"
  11760. order.HilistType = "201"
  11761. order.ChrgType = "1"
  11762. order.DrordBhvr = "0"
  11763. order.HilistCode = subItem.HisProject.MedicalCode
  11764. order.HosplistName = subItem.HisProject.ProjectName
  11765. order.HilistLv = "1"
  11766. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11767. order.HosplistCode = subItem.HisProject.MedicalCode
  11768. order.HosplistName = subItem.HisProject.ProjectName
  11769. order.Cnt = subItem.Count
  11770. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11771. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11772. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11773. order.OwnpayAmt = ""
  11774. order.SelfpayAmt = ""
  11775. order.Spec = subItem.Unit
  11776. order.SpecUnt = subItem.Unit
  11777. order.DrordBegnDate = s_tm
  11778. order.DrordStopDate = ""
  11779. order.DrordDrCodg = doctor_info.DoctorNumber
  11780. order.DrordDeptName = department.Name
  11781. order.DrordDeptCodg = department.Number
  11782. order.DrordDrName = doctor_info.UserName
  11783. order.DrordDrProfttl = "234"
  11784. order.CurrDrordFlag = "1"
  11785. orders = append(orders, &order)
  11786. }
  11787. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11788. var order models.FsiOrderDtos
  11789. order.RxID = strconv.FormatInt(item.ID, 10)
  11790. order.Rxno = strconv.FormatInt(item.ID, 10)
  11791. order.LongDrordFlag = "0"
  11792. order.HilistType = "301"
  11793. order.ChrgType = "1"
  11794. order.DrordBhvr = "0"
  11795. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11796. order.HosplistName = subItem.GoodInfo.GoodName
  11797. order.HilistLv = "1"
  11798. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11799. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11800. order.HosplistName = subItem.GoodInfo.GoodName
  11801. order.Cnt = subItem.Count
  11802. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11803. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11804. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11805. order.OwnpayAmt = ""
  11806. order.SelfpayAmt = ""
  11807. order.Spec = subItem.GoodInfo.SpecificationName
  11808. order.SpecUnt = subItem.Unit
  11809. order.DrordBegnDate = s_tm
  11810. order.DrordStopDate = ""
  11811. order.DrordDrCodg = doctor_info.DoctorNumber
  11812. order.DrordDeptName = department.Name
  11813. order.DrordDeptCodg = department.Number
  11814. order.DrordDrName = doctor_info.UserName
  11815. order.DrordDrProfttl = "234"
  11816. order.CurrDrordFlag = "1"
  11817. orders = append(orders, &order)
  11818. }
  11819. }
  11820. }
  11821. //处方医嘱信息
  11822. }
  11823. fed.MatnStas = "0"
  11824. fed.MedfeeSumamt = "0"
  11825. fed.OwnpayAmt = "0"
  11826. fed.SelfpayAmt = "0"
  11827. fed.AcctPayamt = "0"
  11828. fed.MaAmt = "0"
  11829. fed.HifpPayamt = "0"
  11830. fed.SetlTotlnum = "1"
  11831. fed.Insutype = his.Insutype
  11832. fed.ReimFlag = "0"
  11833. fed.OutSetlFlag = "0"
  11834. var fopd []*models.FsiOperationDtosData
  11835. data := make(map[string]interface{})
  11836. data["fed"] = fed
  11837. data["fdd"] = fdds
  11838. data["fod"] = orders
  11839. data["pd"] = pd
  11840. data["pp"] = pp
  11841. data["fopd"] = fopd
  11842. data["trig_scen"] = trig_scen
  11843. fmt.Println(data)
  11844. fmt.Println(fed)
  11845. fmt.Println(fdds)
  11846. fmt.Println(orders)
  11847. fmt.Println(pd)
  11848. fmt.Println(pp)
  11849. fmt.Println(fopd)
  11850. client := &http.Client{}
  11851. bytesData, _ := json.Marshal(data)
  11852. var req *http.Request
  11853. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11854. if miConfig.MdtrtareaAdmvs == "320921" {
  11855. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11856. } else {
  11857. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11858. }
  11859. resp, _ := client.Do(req)
  11860. defer resp.Body.Close()
  11861. body, ioErr := ioutil.ReadAll(resp.Body)
  11862. if ioErr != nil {
  11863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11865. return res
  11866. }
  11867. var respJSON map[string]interface{}
  11868. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11871. return res
  11872. }
  11873. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11874. fmt.Println(respJSON)
  11875. result, _ := json.Marshal(respJSON)
  11876. fmt.Println(result)
  11877. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11878. utils.ErrorLog("解析失败:%v", err)
  11879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11880. return res
  11881. }
  11882. return res
  11883. } else {
  11884. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11885. saveLog(output, input, "3101", "事前")
  11886. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11887. utils.ErrorLog("解析失败:%v", err)
  11888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11889. return
  11890. }
  11891. return res
  11892. }
  11893. return res
  11894. }
  11895. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11896. adminUser := c.GetAdminUserInfo()
  11897. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11898. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11899. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11900. record_time := c.GetString("record_time")
  11901. order, _ := service.GetHisOrderByID(order_id)
  11902. timeLayout := "2006-01-02"
  11903. loc, _ := time.LoadLocation("Local")
  11904. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11905. if err != nil {
  11906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11907. return
  11908. }
  11909. recordDateTime := theTime.Unix()
  11910. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11911. var patientPrescription models.HisPrescriptionInfo
  11912. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11913. if patientPrescription.ID == 0 {
  11914. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11915. }
  11916. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11917. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11918. //
  11919. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11920. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11921. var pp models.PublicParams
  11922. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11923. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11924. pp.FixmedinsName = miConfig.OrgName
  11925. pp.FixmedinsCode = miConfig.Code
  11926. pp.RequestUrl = miConfig.Url
  11927. pp.Cainfo = miConfig.Cainfo
  11928. pp.SecretKey = miConfig.SecretKey
  11929. pp.AccessKey = miConfig.AccessKey
  11930. pp.OpterName = roles.UserName
  11931. var config []*models.HisXtDiagnoseConfig
  11932. for _, item := range diagnosis_ids {
  11933. id, _ := strconv.ParseInt(item, 10, 64)
  11934. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11935. config = append(config, &diagnosisConfig)
  11936. }
  11937. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11938. var pd models.PatientDtos
  11939. pd.PatnID = his.PsnNo
  11940. pd.PatnName = his.Name
  11941. pd.Gend = his.Gend
  11942. pd.Brdy = str
  11943. pd.Poolarea = his.InsuplcAdmdvs
  11944. pd.CurrMdtrtID = his.Number
  11945. var fed models.FsiEncounterDtos
  11946. fed.MdtrtID = his.Number
  11947. fed.MedinsID = miConfig.Code
  11948. fed.MedinsName = miConfig.OrgName
  11949. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11950. fed.MedMdtrtType = "1"
  11951. fed.MedinsType = "1"
  11952. fed.MedinsLv = "11"
  11953. tm := time.Unix(his.RecordDate, 0)
  11954. s_tm := tm.Format("2006-01-02 15:04:05")
  11955. fed.AdmDate = s_tm
  11956. fed.DscgDate = s_tm
  11957. fed.DscgMainDiseCodg = config[0].CountryCode
  11958. fed.DscgMainDiseName = config[0].CountryContentName
  11959. //诊断信息
  11960. var fdds []*models.FsiDiagnoseDtos
  11961. for index, item := range config {
  11962. if index == 0 {
  11963. var fdd models.FsiDiagnoseDtos
  11964. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11965. fdd.InoutDiseType = "1"
  11966. fdd.MaindiseFlag = "1"
  11967. fdd.DiseDate = s_tm
  11968. fdd.DiasSrtNo = "1"
  11969. fdd.DiseName = item.CountryContentName
  11970. fdd.DiseCodg = item.CountryCode
  11971. fdds = append(fdds, &fdd)
  11972. } else {
  11973. var fdd models.FsiDiagnoseDtos
  11974. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11975. fdd.InoutDiseType = "1"
  11976. fdd.MaindiseFlag = "1"
  11977. fdd.DiseDate = s_tm
  11978. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11979. fdd.DiseName = item.CountryContentName
  11980. fdd.DiseCodg = item.CountryCode
  11981. fdds = append(fdds, &fdd)
  11982. }
  11983. }
  11984. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11985. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11986. fed.AdmDeptName = department.Name
  11987. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11988. fed.DscgDeptName = department.Name
  11989. fed.MedType = order.MedType
  11990. //处方医嘱信息
  11991. var orders []*models.FsiOrderDtos
  11992. //for _, item := range prescriptions {
  11993. // for _, subItem := range item.HisDoctorAdviceInfo {
  11994. // var order models.FsiOrderDtos
  11995. // order.RxID = strconv.FormatInt(item.ID, 10)
  11996. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11997. // order.LongDrordFlag = "0"
  11998. // order.HilistType = "1"
  11999. // order.ChrgType = "1"
  12000. // order.DrordBhvr = "-"
  12001. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12002. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12003. // order.HilistLv = "1"
  12004. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12005. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12006. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12007. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12008. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12009. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12010. // order.OwnpayAmt = ""
  12011. // order.SelfpayAmt = ""
  12012. // order.Spec = ""
  12013. // order.SpecUnt = ""
  12014. // order.DrordBegnDate = s_tm
  12015. // order.DrordStopDate = ""
  12016. // order.DrordDrCodg = "1"
  12017. // order.DrordDeptName = department.Name
  12018. // order.DrordDrCodg = "1"
  12019. // order.DrordDrName = doctor_info.UserName
  12020. // order.DrordDrProfttl = ""
  12021. // order.CurrDrordFlag = "1"
  12022. // orders = append(orders, &order)
  12023. // }
  12024. // for _, subItem := range item.HisPrescriptionProject {
  12025. // if subItem.Type == 2 {
  12026. // var order models.FsiOrderDtos
  12027. // order.RxID = strconv.FormatInt(item.ID, 10)
  12028. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12029. // order.LongDrordFlag = "0"
  12030. // order.HilistType = "1"
  12031. // order.ChrgType = "1"
  12032. // order.DrordBhvr = "-"
  12033. // order.HilistCode = subItem.HisProject.MedicalCode
  12034. // order.HosplistName = subItem.HisProject.ProjectName
  12035. // order.HilistLv = "1"
  12036. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12037. // order.HosplistCode = subItem.HisProject.MedicalCode
  12038. // order.HosplistName = subItem.HisProject.ProjectName
  12039. // order.Cnt = subItem.Count
  12040. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12041. //
  12042. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12043. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12044. // order.OwnpayAmt = ""
  12045. // order.SelfpayAmt = ""
  12046. // order.Spec = ""
  12047. // order.SpecUnt = ""
  12048. // order.DrordBegnDate = s_tm
  12049. // order.DrordStopDate = ""
  12050. // order.DrordDrCodg = "1"
  12051. // order.DrordDeptName = department.Name
  12052. // order.DrordDrCodg = "1"
  12053. // order.DrordDrName = doctor_info.UserName
  12054. // order.DrordDrProfttl = ""
  12055. // order.CurrDrordFlag = "1"
  12056. // orders = append(orders, &order)
  12057. //
  12058. // }
  12059. // if subItem.Type == 3 {
  12060. //
  12061. // var order models.FsiOrderDtos
  12062. // order.RxID = strconv.FormatInt(item.ID, 10)
  12063. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12064. // order.LongDrordFlag = "0"
  12065. // order.HilistType = "1"
  12066. // order.ChrgType = "1"
  12067. // order.DrordBhvr = "-"
  12068. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12069. // order.HosplistName = subItem.GoodInfo.GoodName
  12070. // order.HilistLv = "1"
  12071. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12072. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12073. // order.HosplistName = subItem.GoodInfo.GoodName
  12074. // order.Cnt = subItem.Count
  12075. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12076. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12077. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12078. // order.OwnpayAmt = ""
  12079. // order.SelfpayAmt = ""
  12080. // order.Spec = ""
  12081. // order.SpecUnt = ""
  12082. // order.DrordBegnDate = s_tm
  12083. // order.DrordStopDate = ""
  12084. // order.DrordDrCodg = "1"
  12085. // order.DrordDeptName = department.Name
  12086. // order.DrordDrCodg = "1"
  12087. // order.DrordDrName = doctor_info.UserName
  12088. // order.DrordDrProfttl = ""
  12089. // order.CurrDrordFlag = "1"
  12090. // orders = append(orders, &order)
  12091. //
  12092. // }
  12093. // }
  12094. //}
  12095. for _, item := range prescriptions {
  12096. for _, subItem := range item.HisDoctorAdviceInfo {
  12097. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12098. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12099. var order models.FsiOrderDtos
  12100. order.RxID = strconv.FormatInt(item.ID, 10)
  12101. order.Rxno = strconv.FormatInt(item.ID, 10)
  12102. order.LongDrordFlag = "0"
  12103. order.HilistType = "101"
  12104. order.ChrgType = "01"
  12105. order.DrordBhvr = "0"
  12106. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12107. order.HosplistName = subItem.BaseDrugLib.DrugName
  12108. order.HilistLv = "1"
  12109. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12110. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12111. order.HosplistName = subItem.BaseDrugLib.DrugName
  12112. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12113. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12114. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12115. order.OwnpayAmt = ""
  12116. order.SelfpayAmt = ""
  12117. order.Spec = spec
  12118. order.SpecUnt = subItem.PrescribingNumberUnit
  12119. order.DrordBegnDate = s_tm
  12120. order.DrordStopDate = ""
  12121. order.DrordDrCodg = doctor_info.DoctorNumber
  12122. order.DrordDeptName = department.Name
  12123. order.DrordDeptCodg = department.Number
  12124. order.DrordDrName = doctor_info.UserName
  12125. order.DrordDrProfttl = "234"
  12126. order.CurrDrordFlag = "1"
  12127. orders = append(orders, &order)
  12128. }
  12129. }
  12130. for _, subItem := range item.HisPrescriptionProject {
  12131. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12132. var order models.FsiOrderDtos
  12133. order.RxID = strconv.FormatInt(item.ID, 10)
  12134. order.Rxno = strconv.FormatInt(item.ID, 10)
  12135. order.LongDrordFlag = "0"
  12136. order.HilistType = "201"
  12137. order.ChrgType = "05"
  12138. order.DrordBhvr = "0"
  12139. order.HilistCode = subItem.HisProject.MedicalCode
  12140. order.HosplistName = subItem.HisProject.ProjectName
  12141. order.HilistLv = "1"
  12142. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12143. order.HosplistCode = subItem.HisProject.MedicalCode
  12144. order.HosplistName = subItem.HisProject.ProjectName
  12145. order.Cnt = subItem.Count
  12146. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12147. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12148. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12149. order.OwnpayAmt = ""
  12150. order.SelfpayAmt = ""
  12151. order.Spec = subItem.Unit
  12152. order.SpecUnt = subItem.Unit
  12153. order.DrordBegnDate = s_tm
  12154. order.DrordStopDate = ""
  12155. order.DrordDrCodg = doctor_info.DoctorNumber
  12156. order.DrordDeptName = department.Name
  12157. order.DrordDeptCodg = department.Number
  12158. order.DrordDrName = doctor_info.UserName
  12159. order.DrordDrProfttl = "234"
  12160. order.CurrDrordFlag = "1"
  12161. orders = append(orders, &order)
  12162. }
  12163. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12164. var order models.FsiOrderDtos
  12165. order.RxID = strconv.FormatInt(item.ID, 10)
  12166. order.Rxno = strconv.FormatInt(item.ID, 10)
  12167. order.LongDrordFlag = "0"
  12168. order.HilistType = "301"
  12169. order.ChrgType = "08"
  12170. order.DrordBhvr = "0"
  12171. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12172. order.HosplistName = subItem.GoodInfo.GoodName
  12173. order.HilistLv = "1"
  12174. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12175. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12176. order.HosplistName = subItem.GoodInfo.GoodName
  12177. order.Cnt = subItem.Count
  12178. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12179. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12180. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12181. order.OwnpayAmt = ""
  12182. order.SelfpayAmt = ""
  12183. order.Spec = subItem.GoodInfo.SpecificationName
  12184. order.SpecUnt = subItem.Unit
  12185. order.DrordBegnDate = s_tm
  12186. order.DrordStopDate = ""
  12187. order.DrordDrCodg = doctor_info.DoctorNumber
  12188. order.DrordDeptName = department.Name
  12189. order.DrordDeptCodg = department.Number
  12190. order.DrordDrName = doctor_info.UserName
  12191. order.DrordDrProfttl = "234"
  12192. order.CurrDrordFlag = "1"
  12193. orders = append(orders, &order)
  12194. }
  12195. }
  12196. }
  12197. //处方医嘱信息
  12198. fed.MatnStas = "0"
  12199. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12200. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12201. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12202. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12203. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12204. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12205. fed.SetlTotlnum = "1"
  12206. fed.Insutype = his.Insutype
  12207. fed.ReimFlag = "0"
  12208. fed.OutSetlFlag = "0"
  12209. var fopd []*models.FsiOperationDtosData
  12210. data := make(map[string]interface{})
  12211. data["fed"] = fed
  12212. data["fdd"] = fdds
  12213. data["fod"] = orders
  12214. data["pd"] = pd
  12215. data["pp"] = pp
  12216. data["fopd"] = fopd
  12217. data["trig_scen"] = trig_scen
  12218. client := &http.Client{}
  12219. bytesData, _ := json.Marshal(data)
  12220. var req *http.Request
  12221. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12222. if miConfig.MdtrtareaAdmvs == "320921" {
  12223. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12224. } else {
  12225. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12226. }
  12227. resp, _ := client.Do(req)
  12228. defer resp.Body.Close()
  12229. body, ioErr := ioutil.ReadAll(resp.Body)
  12230. if ioErr != nil {
  12231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12233. return res
  12234. }
  12235. var respJSON map[string]interface{}
  12236. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12239. return res
  12240. }
  12241. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12242. result, _ := json.Marshal(respJSON)
  12243. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12244. utils.ErrorLog("解析失败:%v", err)
  12245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12246. return res
  12247. }
  12248. return res
  12249. } else {
  12250. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12251. saveLog(output, input, "3102", "事中")
  12252. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12253. utils.ErrorLog("解析失败:%v", err)
  12254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12255. return
  12256. }
  12257. return res
  12258. }
  12259. return res
  12260. }
  12261. func (c *HisApiController) Check() {
  12262. psn_no := c.GetString("psn_no")
  12263. in := c.GetString("in")
  12264. mt := c.GetString("mt")
  12265. baseParams := models.BaseParams{
  12266. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12267. FixmedinsCode: "H15049901371",
  12268. InsuplcAdmdvs: "150499",
  12269. MdtrtareaAdmvs: "150499",
  12270. OrgName: "赤峰费森血液透析中心",
  12271. Doctor: "1111",
  12272. }
  12273. service.Gdyb2001(baseParams, psn_no, in, mt)
  12274. }
  12275. func (c *HisApiController) GetPsnNcdsInfo() {
  12276. admin_user_id, _ := c.GetInt64("admin_user_id")
  12277. patient_id, _ := c.GetInt64("patient_id")
  12278. //id, _ := c.GetInt64("id")
  12279. adminUser := c.GetAdminUserInfo()
  12280. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12281. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12282. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12283. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12284. //psn_record, _ := service.GetP(id)
  12285. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12286. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12287. //
  12288. //if psn_record.ID == 0 {
  12289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12290. // return
  12291. //}
  12292. var res Result5301
  12293. var res10265 Result5301For10265
  12294. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12295. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12296. var api string
  12297. if miConfig.MdtrtareaAdmvs == "320921" {
  12298. 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 +
  12299. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12300. } else {
  12301. 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 +
  12302. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12303. }
  12304. resp, requestErr := http.Get(api)
  12305. if requestErr != nil {
  12306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12307. return
  12308. }
  12309. body, ioErr := ioutil.ReadAll(resp.Body)
  12310. if ioErr != nil {
  12311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12313. return
  12314. }
  12315. var respJSON map[string]interface{}
  12316. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12319. return
  12320. }
  12321. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12322. result, _ := json.Marshal(respJSON)
  12323. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12324. utils.ErrorLog("解析失败:%v", err)
  12325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12326. return
  12327. }
  12328. res.ErrMsg = res10265.ErrMsg
  12329. res.Output = res10265.Output
  12330. res.InfRefmsgid = res10265.InfRefmsgid
  12331. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12332. res.Infcode = infocode
  12333. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12334. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12335. var api string
  12336. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12337. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12338. resp, requestErr := http.Get(api)
  12339. if requestErr != nil {
  12340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12341. return
  12342. }
  12343. body, ioErr := ioutil.ReadAll(resp.Body)
  12344. if ioErr != nil {
  12345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12347. return
  12348. }
  12349. var respJSON map[string]interface{}
  12350. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12353. return
  12354. }
  12355. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12356. if status == "0" {
  12357. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12358. c.ServeSuccessJSON(map[string]interface{}{
  12359. "failed_code": -10,
  12360. "msg": err_msg,
  12361. })
  12362. return
  12363. }
  12364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12365. result, _ := json.Marshal(respJSON)
  12366. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12367. utils.ErrorLog("解析失败:%v", err)
  12368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12369. return
  12370. }
  12371. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12372. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12373. var api string
  12374. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12375. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12376. resp, requestErr := http.Get(api)
  12377. if requestErr != nil {
  12378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12379. return
  12380. }
  12381. body, ioErr := ioutil.ReadAll(resp.Body)
  12382. if ioErr != nil {
  12383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12385. return
  12386. }
  12387. var respJSON map[string]interface{}
  12388. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12391. return
  12392. }
  12393. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12394. if status == "0" {
  12395. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12396. c.ServeSuccessJSON(map[string]interface{}{
  12397. "failed_code": -10,
  12398. "msg": err_msg,
  12399. })
  12400. return
  12401. }
  12402. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12403. result, _ := json.Marshal(respJSON)
  12404. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12405. utils.ErrorLog("解析失败:%v", err)
  12406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12407. return
  12408. }
  12409. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12410. p, _ := service.GetHisPatientById(patient_id)
  12411. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12412. var dat map[string]interface{}
  12413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12414. fmt.Println(dat)
  12415. } else {
  12416. fmt.Println(err)
  12417. }
  12418. userJSONBytes, _ := json.Marshal(dat)
  12419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12420. utils.ErrorLog("解析失败:%v", err)
  12421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12422. return
  12423. }
  12424. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12425. p, _ := service.GetHisPatientById(patient_id)
  12426. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12427. var dat map[string]interface{}
  12428. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12429. fmt.Println(dat)
  12430. } else {
  12431. fmt.Println(err)
  12432. }
  12433. userJSONBytes, _ := json.Marshal(dat)
  12434. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12435. utils.ErrorLog("解析失败:%v", err)
  12436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12437. return
  12438. }
  12439. } else if miConfig.MdtrtareaAdmvs == "360100" {
  12440. p, _ := service.GetHisPatientById(patient_id)
  12441. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12442. var dat map[string]interface{}
  12443. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12444. fmt.Println(dat)
  12445. } else {
  12446. fmt.Println(err)
  12447. }
  12448. userJSONBytes, _ := json.Marshal(dat)
  12449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12450. utils.ErrorLog("解析失败:%v", err)
  12451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12452. return
  12453. }
  12454. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12455. p, _ := service.GetHisPatientById(patient_id)
  12456. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12457. var dat map[string]interface{}
  12458. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12459. fmt.Println(dat)
  12460. } else {
  12461. fmt.Println(err)
  12462. }
  12463. userJSONBytes, _ := json.Marshal(dat)
  12464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12465. utils.ErrorLog("解析失败:%v", err)
  12466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12467. return
  12468. }
  12469. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12470. p, _ := service.GetHisPatientById(patient_id)
  12471. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12472. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12473. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12474. resp, requestErr := http.Get(api)
  12475. if requestErr != nil {
  12476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12477. return
  12478. }
  12479. body, ioErr := ioutil.ReadAll(resp.Body)
  12480. if ioErr != nil {
  12481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12483. return
  12484. }
  12485. var respJSON map[string]interface{}
  12486. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12489. return
  12490. }
  12491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12492. result, _ := json.Marshal(respJSON)
  12493. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12494. utils.ErrorLog("解析失败:%v", err)
  12495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12496. return
  12497. }
  12498. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12499. p, _ := service.GetHisPatientById(patient_id)
  12500. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12501. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12502. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12503. resp, requestErr := http.Get(api)
  12504. if requestErr != nil {
  12505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12506. return
  12507. }
  12508. body, ioErr := ioutil.ReadAll(resp.Body)
  12509. if ioErr != nil {
  12510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12512. return
  12513. }
  12514. var respJSON map[string]interface{}
  12515. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12518. return
  12519. }
  12520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12521. result, _ := json.Marshal(respJSON)
  12522. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12523. utils.ErrorLog("解析失败:%v", err)
  12524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12525. return
  12526. }
  12527. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12528. p, _ := service.GetHisPatientById(patient_id)
  12529. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12530. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12531. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12532. resp, requestErr := http.Get(api)
  12533. if requestErr != nil {
  12534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12535. return
  12536. }
  12537. body, ioErr := ioutil.ReadAll(resp.Body)
  12538. if ioErr != nil {
  12539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12541. return
  12542. }
  12543. var respJSON map[string]interface{}
  12544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12547. return
  12548. }
  12549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12550. result, _ := json.Marshal(respJSON)
  12551. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12552. utils.ErrorLog("解析失败:%v", err)
  12553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12554. return
  12555. }
  12556. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12557. p, _ := service.GetHisPatientById(patient_id)
  12558. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12559. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12560. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12561. resp, requestErr := http.Get(api)
  12562. if requestErr != nil {
  12563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12564. return
  12565. }
  12566. body, ioErr := ioutil.ReadAll(resp.Body)
  12567. if ioErr != nil {
  12568. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12570. return
  12571. }
  12572. var respJSON map[string]interface{}
  12573. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12576. return
  12577. }
  12578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12579. result, _ := json.Marshal(respJSON)
  12580. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12581. utils.ErrorLog("解析失败:%v", err)
  12582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12583. return
  12584. }
  12585. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12586. p, _ := service.GetHisPatientById(patient_id)
  12587. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12588. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12589. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12590. resp, requestErr := http.Get(api)
  12591. if requestErr != nil {
  12592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12593. return
  12594. }
  12595. body, ioErr := ioutil.ReadAll(resp.Body)
  12596. if ioErr != nil {
  12597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12599. return
  12600. }
  12601. var respJSON map[string]interface{}
  12602. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12605. return
  12606. }
  12607. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12608. result, _ := json.Marshal(respJSON)
  12609. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12610. utils.ErrorLog("解析失败:%v", err)
  12611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12612. return
  12613. }
  12614. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12615. p, _ := service.GetHisPatientById(patient_id)
  12616. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12617. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12618. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12619. resp, requestErr := http.Get(api)
  12620. if requestErr != nil {
  12621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12622. return
  12623. }
  12624. body, ioErr := ioutil.ReadAll(resp.Body)
  12625. if ioErr != nil {
  12626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12628. return
  12629. }
  12630. var respJSON map[string]interface{}
  12631. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12634. return
  12635. }
  12636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12637. result, _ := json.Marshal(respJSON)
  12638. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12639. utils.ErrorLog("解析失败:%v", err)
  12640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12641. return
  12642. }
  12643. } else {
  12644. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12645. var dat map[string]interface{}
  12646. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12647. fmt.Println(dat)
  12648. } else {
  12649. fmt.Println(err)
  12650. }
  12651. userJSONBytes, _ := json.Marshal(dat)
  12652. if miConfig.Code == "H15049901371" {
  12653. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12654. utils.ErrorLog("解析失败:%v", err)
  12655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12656. return
  12657. }
  12658. res.InfRefmsgid = res10265.InfRefmsgid
  12659. res.Output = res10265.Output
  12660. res.ErrMsg = res10265.ErrMsg
  12661. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12662. res.Infcode = infocode
  12663. } else {
  12664. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12665. utils.ErrorLog("解析失败:%v", err)
  12666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12667. return
  12668. }
  12669. }
  12670. }
  12671. if res.Infcode == 0 {
  12672. c.ServeSuccessJSON(map[string]interface{}{
  12673. "result": res.Output.Result,
  12674. })
  12675. }
  12676. }
  12677. func (c *HisApiController) CheckInsutype() {
  12678. his_patient_id, _ := c.GetInt64("his_patient_id")
  12679. admin_user_id, _ := c.GetInt64("admin_user_id")
  12680. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12681. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12682. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12683. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12684. var dat map[string]interface{}
  12685. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12686. fmt.Println(dat)
  12687. } else {
  12688. fmt.Println(err)
  12689. }
  12690. userJSONBytes, _ := json.Marshal(dat)
  12691. var res Result90100
  12692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12693. utils.ErrorLog("解析失败:%v", err)
  12694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12695. return
  12696. }
  12697. if res.Infcode != 0 {
  12698. c.ServeSuccessJSON(map[string]interface{}{
  12699. "failed_code": -10,
  12700. "msg": res.ErrMsg,
  12701. })
  12702. return
  12703. } else {
  12704. fmt.Println(res)
  12705. }
  12706. }
  12707. func (c *HisApiController) CheckCardPWD() {
  12708. card_pwd := c.GetString("card_pwd")
  12709. his_patient_id, _ := c.GetInt64("his_patient_id")
  12710. admin_user_id, _ := c.GetInt64("admin_user_id")
  12711. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12712. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12713. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12714. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12715. bas := strings.Split(psn.CardInfo, "|")
  12716. basNumber := bas[2]
  12717. if psn.InsuplcAdmdvs[:4] == "4403" {
  12718. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12719. var dat map[string]interface{}
  12720. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12721. fmt.Println(dat)
  12722. } else {
  12723. fmt.Println(err)
  12724. }
  12725. userJSONBytes, _ := json.Marshal(dat)
  12726. var res Result90991
  12727. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12728. utils.ErrorLog("解析失败:%v", err)
  12729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12730. return
  12731. }
  12732. if res.Infcode != 0 {
  12733. c.ServeSuccessJSON(map[string]interface{}{
  12734. "failed_code": -10,
  12735. "msg": res.ErrMsg,
  12736. })
  12737. return
  12738. } else {
  12739. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12740. var msg string
  12741. switch res.Output.Result.CardStat {
  12742. case "00":
  12743. msg = "未激活"
  12744. break
  12745. case "10":
  12746. msg = "激活"
  12747. break
  12748. case "20":
  12749. msg = "窗口挂失"
  12750. break
  12751. case "21":
  12752. msg = "电话挂失"
  12753. break
  12754. case "22":
  12755. msg = "单位网上申报挂失"
  12756. break
  12757. case "23":
  12758. msg = "保健办挂失"
  12759. break
  12760. case "24":
  12761. msg = "个人网上挂失"
  12762. break
  12763. case "25":
  12764. msg = "网上服务大厅挂失"
  12765. break
  12766. case "30":
  12767. msg = "注销"
  12768. break
  12769. case "40":
  12770. msg = "回收"
  12771. break
  12772. case "99":
  12773. msg = "制卡中(无效卡)"
  12774. break
  12775. }
  12776. c.ServeSuccessJSON(map[string]interface{}{
  12777. "failed_code": -10,
  12778. "msg": msg,
  12779. })
  12780. return
  12781. } else {
  12782. c.ServeSuccessJSON(map[string]interface{}{
  12783. "msg": "校验成功",
  12784. })
  12785. return
  12786. }
  12787. }
  12788. } else {
  12789. c.ServeSuccessJSON(map[string]interface{}{
  12790. "msg": "校验成功",
  12791. })
  12792. return
  12793. }
  12794. }
  12795. func (c *HisApiController) CheckCardPWDTwo() {
  12796. //card_pwd := c.GetString("card_pwd")
  12797. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12798. admin_user_id, _ := c.GetInt64("admin_user_id")
  12799. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12800. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12801. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12802. var dat map[string]interface{}
  12803. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12804. fmt.Println(dat)
  12805. } else {
  12806. fmt.Println(err)
  12807. }
  12808. userJSONBytes, _ := json.Marshal(dat)
  12809. var res Result90991
  12810. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12811. utils.ErrorLog("解析失败:%v", err)
  12812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12813. return
  12814. }
  12815. if res.Infcode != 0 {
  12816. c.ServeSuccessJSON(map[string]interface{}{
  12817. "failed_code": -10,
  12818. "msg": res.ErrMsg,
  12819. })
  12820. return
  12821. } else {
  12822. if res.Output.Result.SscnoCheckStat == "0" {
  12823. var msg string
  12824. switch res.Output.Result.CardStat {
  12825. case "00":
  12826. msg = "未激活"
  12827. break
  12828. case "10":
  12829. msg = "激活"
  12830. break
  12831. case "20":
  12832. msg = "窗口挂失"
  12833. break
  12834. case "21":
  12835. msg = "电话挂失"
  12836. break
  12837. case "22":
  12838. msg = "单位网上申报挂失"
  12839. break
  12840. case "23":
  12841. msg = "保健办挂失"
  12842. break
  12843. case "24":
  12844. msg = "个人网上挂失"
  12845. break
  12846. case "25":
  12847. msg = "网上服务大厅挂失"
  12848. break
  12849. case "30":
  12850. msg = "注销"
  12851. break
  12852. case "40":
  12853. msg = "回收"
  12854. break
  12855. case "99":
  12856. msg = "制卡中(无效卡)"
  12857. break
  12858. }
  12859. c.ServeSuccessJSON(map[string]interface{}{
  12860. "failed_code": -10,
  12861. "msg": msg,
  12862. })
  12863. return
  12864. } else {
  12865. c.ServeSuccessJSON(map[string]interface{}{
  12866. "msg": "校验成功",
  12867. })
  12868. return
  12869. }
  12870. }
  12871. }
  12872. type ELeCertData struct {
  12873. Data struct {
  12874. Extra string `json:"extra"`
  12875. IDNo string `json:"idNo"`
  12876. IDType string `json:"idType"`
  12877. EcToken string `json:"ecToken"`
  12878. InsuOrg string `json:"insuOrg"`
  12879. UserName string `json:"userName"`
  12880. EcIndexNo string `json:"ecIndexNo"`
  12881. Gender string `json:"gender"`
  12882. Birthday string `json:"birthday"`
  12883. Nationality string `json:"nationality"`
  12884. Email string `json:"email"`
  12885. } `json:"OutData"`
  12886. }
  12887. func (c *HisApiController) ReadCard() {
  12888. id_card_type, _ := c.GetInt64("id_card_type")
  12889. admin_user_id, _ := c.GetInt64("admin_user_id")
  12890. certificates, _ := c.GetInt64("certificates")
  12891. //
  12892. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12893. id_card_no := c.GetString("id_card_no")
  12894. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12895. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12896. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12897. switch id_card_type {
  12898. case 1:
  12899. if miConfig.MdtrtareaAdmvs == "421300" {
  12900. var res ResultTwo
  12901. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12902. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12903. "&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)
  12904. resp, requestErr := http.Get(api)
  12905. if requestErr != nil {
  12906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12907. return
  12908. }
  12909. body, ioErr := ioutil.ReadAll(resp.Body)
  12910. if ioErr != nil {
  12911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12913. return
  12914. }
  12915. var respJSON map[string]interface{}
  12916. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12919. return
  12920. }
  12921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12922. result, _ := json.Marshal(respJSON)
  12923. fmt.Println("log")
  12924. fmt.Println(string(result))
  12925. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12926. utils.ErrorLog("解析失败:%v", err)
  12927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12928. return
  12929. }
  12930. if res.Infcode == 0 {
  12931. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12932. if err == gorm.ErrRecordNotFound {
  12933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12934. return
  12935. } else if err != nil {
  12936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12937. return
  12938. } else {
  12939. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12940. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12941. infoStr := string(Iinfos)
  12942. idetinfoStr := string(Idetinfos)
  12943. var rf []*ResultFive
  12944. json.Unmarshal([]byte(infoStr), &rf)
  12945. var insutypes []*ResultFive
  12946. var insutype string
  12947. var is390 int = 0
  12948. var is310 int = 0
  12949. for _, item := range rf {
  12950. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12951. insutypes = append(insutypes, item)
  12952. }
  12953. }
  12954. if len(insutypes) == 1 {
  12955. insutype = insutypes[0].Insutype
  12956. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12957. } else {
  12958. for _, i := range insutypes {
  12959. if i.Insutype == "390" {
  12960. is390 = 1
  12961. }
  12962. if i.Insutype == "310" {
  12963. is310 = 1
  12964. }
  12965. }
  12966. }
  12967. if is390 == 1 {
  12968. insutype = "390"
  12969. }
  12970. if is310 == 1 {
  12971. insutype = "310"
  12972. }
  12973. if len(insutypes) == 0 {
  12974. insutype = "390"
  12975. }
  12976. var insuplc_admdvs string
  12977. for _, item := range rf {
  12978. if item.Insutype == insutype {
  12979. insuplc_admdvs = item.InsuplcAdmdvs
  12980. }
  12981. }
  12982. if strings.Contains(insuplc_admdvs, "4213") {
  12983. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12984. }
  12985. psn := &models.HisPsn{
  12986. PsnNo: res.Output.Baseinfo.PsnNo,
  12987. PatientId: patient.ID,
  12988. Certno: res.Output.Baseinfo.Certno,
  12989. Gend: res.Output.Baseinfo.Gend,
  12990. Naty: res.Output.Baseinfo.Naty,
  12991. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12992. PsnName: res.Output.Baseinfo.PsnName,
  12993. Idetinfo: idetinfoStr,
  12994. Insuinfo: infoStr,
  12995. InsuplcAdmdvs: insuplc_admdvs,
  12996. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12997. }
  12998. service.CreateHisPsn(psn)
  12999. c.ServeSuccessJSON(map[string]interface{}{
  13000. "patient": patient,
  13001. "number": res.Output.Baseinfo.Certno,
  13002. })
  13003. }
  13004. } else {
  13005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13006. return
  13007. }
  13008. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13009. var res ResultTwo
  13010. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13011. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13012. "&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)
  13013. resp, requestErr := http.Get(api)
  13014. if requestErr != nil {
  13015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13016. return
  13017. }
  13018. body, ioErr := ioutil.ReadAll(resp.Body)
  13019. if ioErr != nil {
  13020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13022. return
  13023. }
  13024. var respJSON map[string]interface{}
  13025. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13028. return
  13029. }
  13030. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13031. result, _ := json.Marshal(respJSON)
  13032. fmt.Println("log")
  13033. fmt.Println(string(result))
  13034. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13035. utils.ErrorLog("解析失败:%v", err)
  13036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13037. return
  13038. }
  13039. if res.Infcode == 0 {
  13040. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13041. if err == gorm.ErrRecordNotFound {
  13042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13043. return
  13044. } else if err != nil {
  13045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13046. return
  13047. } else {
  13048. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13049. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13050. infoStr := string(Iinfos)
  13051. idetinfoStr := string(Idetinfos)
  13052. psn := &models.HisPsn{
  13053. PsnNo: res.Output.Baseinfo.PsnNo,
  13054. PatientId: patient.ID,
  13055. Certno: res.Output.Baseinfo.Certno,
  13056. Gend: res.Output.Baseinfo.Gend,
  13057. Naty: res.Output.Baseinfo.Naty,
  13058. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13059. PsnName: res.Output.Baseinfo.PsnName,
  13060. Idetinfo: idetinfoStr,
  13061. Insuinfo: infoStr,
  13062. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13063. }
  13064. service.CreateHisPsn(psn)
  13065. var rf []*ResultFive
  13066. json.Unmarshal([]byte(infoStr), &rf)
  13067. var insutypes []*ResultFive
  13068. var insutype string
  13069. var is390 int = 0
  13070. var is310 int = 0
  13071. for _, item := range rf {
  13072. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13073. insutypes = append(insutypes, item)
  13074. }
  13075. }
  13076. if len(insutypes) == 1 {
  13077. insutype = insutypes[0].Insutype
  13078. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13079. } else {
  13080. for _, i := range insutypes {
  13081. if i.Insutype == "390" {
  13082. is390 = 1
  13083. }
  13084. if i.Insutype == "310" {
  13085. is310 = 1
  13086. }
  13087. }
  13088. }
  13089. if is390 == 1 {
  13090. insutype = "390"
  13091. }
  13092. if is310 == 1 {
  13093. insutype = "310"
  13094. }
  13095. if len(insutypes) == 0 {
  13096. insutype = "310"
  13097. }
  13098. c.ServeSuccessJSON(map[string]interface{}{
  13099. "patient": patient,
  13100. "number": res.Output.Baseinfo.Certno,
  13101. "insutype": insutype,
  13102. })
  13103. }
  13104. } else {
  13105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13106. return
  13107. }
  13108. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13109. var res ResultTwo
  13110. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13111. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13112. "&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)
  13113. resp, requestErr := http.Get(api)
  13114. if requestErr != nil {
  13115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13116. return
  13117. }
  13118. body, ioErr := ioutil.ReadAll(resp.Body)
  13119. if ioErr != nil {
  13120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13122. return
  13123. }
  13124. var respJSON map[string]interface{}
  13125. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13128. return
  13129. }
  13130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13131. result, _ := json.Marshal(respJSON)
  13132. fmt.Println("log")
  13133. fmt.Println(string(result))
  13134. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13135. utils.ErrorLog("解析失败:%v", err)
  13136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13137. return
  13138. }
  13139. if res.Infcode == 0 {
  13140. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13141. if err == gorm.ErrRecordNotFound {
  13142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13143. return
  13144. } else if err != nil {
  13145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13146. return
  13147. } else {
  13148. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13149. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13150. infoStr := string(Iinfos)
  13151. idetinfoStr := string(Idetinfos)
  13152. var rf []*ResultFive
  13153. json.Unmarshal([]byte(infoStr), &rf)
  13154. var insutypes []*ResultFive
  13155. var insutype string
  13156. var is390 int = 0
  13157. var is310 int = 0
  13158. for _, item := range rf {
  13159. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13160. insutypes = append(insutypes, item)
  13161. }
  13162. }
  13163. if len(insutypes) == 1 {
  13164. insutype = insutypes[0].Insutype
  13165. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13166. } else {
  13167. for _, i := range insutypes {
  13168. if i.Insutype == "390" {
  13169. is390 = 1
  13170. }
  13171. if i.Insutype == "310" {
  13172. is310 = 1
  13173. }
  13174. }
  13175. }
  13176. if is390 == 1 {
  13177. insutype = "390"
  13178. }
  13179. if is310 == 1 {
  13180. insutype = "310"
  13181. }
  13182. if len(insutypes) == 0 {
  13183. insutype = "390"
  13184. }
  13185. var insuplc_admdvs string
  13186. for _, item := range rf {
  13187. if item.Insutype == insutype {
  13188. insuplc_admdvs = item.InsuplcAdmdvs
  13189. }
  13190. }
  13191. psn := &models.HisPsn{
  13192. PsnNo: res.Output.Baseinfo.PsnNo,
  13193. PatientId: patient.ID,
  13194. Certno: res.Output.Baseinfo.Certno,
  13195. Gend: res.Output.Baseinfo.Gend,
  13196. Naty: res.Output.Baseinfo.Naty,
  13197. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13198. PsnName: res.Output.Baseinfo.PsnName,
  13199. Idetinfo: idetinfoStr,
  13200. Insuinfo: infoStr,
  13201. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13202. InsuplcAdmdvs: insuplc_admdvs,
  13203. }
  13204. service.CreateHisPsn(psn)
  13205. for _, item := range rf {
  13206. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13207. insutypes = append(insutypes, item)
  13208. }
  13209. }
  13210. if len(insutypes) == 1 {
  13211. insutype = insutypes[0].Insutype
  13212. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13213. } else {
  13214. for _, i := range insutypes {
  13215. if i.Insutype == "390" {
  13216. is390 = 1
  13217. }
  13218. if i.Insutype == "310" {
  13219. is310 = 1
  13220. }
  13221. }
  13222. }
  13223. if is390 == 1 {
  13224. insutype = "390"
  13225. }
  13226. if is310 == 1 {
  13227. insutype = "310"
  13228. }
  13229. if len(insutypes) == 0 {
  13230. insutype = "310"
  13231. }
  13232. c.ServeSuccessJSON(map[string]interface{}{
  13233. "patient": patient,
  13234. "number": res.Output.Baseinfo.Certno,
  13235. "insutype": insutype,
  13236. })
  13237. }
  13238. } else {
  13239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13240. return
  13241. }
  13242. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13243. var res ResultTwo
  13244. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13245. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13246. "&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)
  13247. resp, requestErr := http.Get(api)
  13248. if requestErr != nil {
  13249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13250. return
  13251. }
  13252. body, ioErr := ioutil.ReadAll(resp.Body)
  13253. if ioErr != nil {
  13254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13256. return
  13257. }
  13258. var respJSON map[string]interface{}
  13259. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13262. return
  13263. }
  13264. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13265. result, _ := json.Marshal(respJSON)
  13266. fmt.Println("log")
  13267. fmt.Println(string(result))
  13268. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13269. utils.ErrorLog("解析失败:%v", err)
  13270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13271. return
  13272. }
  13273. if res.Infcode == 0 {
  13274. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13275. if err == gorm.ErrRecordNotFound {
  13276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13277. return
  13278. } else if err != nil {
  13279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13280. return
  13281. } else {
  13282. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13283. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13284. infoStr := string(Iinfos)
  13285. idetinfoStr := string(Idetinfos)
  13286. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13287. psn := &models.HisPsn{
  13288. PsnNo: res.Output.Baseinfo.PsnNo,
  13289. PatientId: patient.ID,
  13290. Certno: res.Output.Baseinfo.Certno,
  13291. Brdy: b,
  13292. Age: float64(age),
  13293. Gend: res.Output.Baseinfo.Gend,
  13294. Naty: res.Output.Baseinfo.Naty,
  13295. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13296. PsnName: res.Output.Baseinfo.PsnName,
  13297. Idetinfo: idetinfoStr,
  13298. Insuinfo: infoStr,
  13299. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13300. }
  13301. service.CreateHisPsn(psn)
  13302. var rf []*ResultFive
  13303. json.Unmarshal([]byte(infoStr), &rf)
  13304. var insutypes []*ResultFive
  13305. var insutype string
  13306. var is390 int = 0
  13307. var is310 int = 0
  13308. for _, item := range rf {
  13309. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13310. insutypes = append(insutypes, item)
  13311. }
  13312. }
  13313. if len(insutypes) == 1 {
  13314. insutype = insutypes[0].Insutype
  13315. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13316. } else {
  13317. for _, i := range insutypes {
  13318. if i.Insutype == "390" {
  13319. is390 = 1
  13320. }
  13321. if i.Insutype == "310" {
  13322. is310 = 1
  13323. }
  13324. }
  13325. }
  13326. if is390 == 1 {
  13327. insutype = "390"
  13328. }
  13329. if is310 == 1 {
  13330. insutype = "310"
  13331. }
  13332. if len(insutypes) == 0 {
  13333. insutype = "310"
  13334. }
  13335. c.ServeSuccessJSON(map[string]interface{}{
  13336. "patient": patient,
  13337. "number": res.Output.Baseinfo.Certno,
  13338. "insutype": insutype,
  13339. })
  13340. }
  13341. } else {
  13342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13343. return
  13344. }
  13345. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13346. var api string
  13347. if miConfig.MdtrtareaAdmvs == "320921" {
  13348. 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 +
  13349. "&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
  13350. fmt.Println(api)
  13351. } else {
  13352. 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 +
  13353. "&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)
  13354. }
  13355. resp, requestErr := http.Get(api)
  13356. if requestErr != nil {
  13357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13358. return
  13359. }
  13360. body, ioErr := ioutil.ReadAll(resp.Body)
  13361. if ioErr != nil {
  13362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13364. return
  13365. }
  13366. var respJSON map[string]interface{}
  13367. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13370. return
  13371. }
  13372. var status string
  13373. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13374. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13375. //console.log()
  13376. fmt.Println("type===")
  13377. fmt.Println(card_type)
  13378. var token string
  13379. var res ResultTwo //1101结果
  13380. var res10265 ResultTwo10265 //1101结果
  13381. var card_info string //卡信息
  13382. var busi_card_info string
  13383. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13384. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13385. if status == "0" { //读卡成功
  13386. if card_type == "1" {
  13387. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13388. result, _ := json.Marshal(respJSON)
  13389. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13390. utils.ErrorLog("解析失败:%v", err)
  13391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13392. return
  13393. }
  13394. res.ErrMsg = res10265.ErrMsg
  13395. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13396. res.Infcode = infocode
  13397. res.Output = res10265.Output
  13398. res.InfRefmsgid = res10265.InfRefmsgid
  13399. } else {
  13400. //var card_info string //卡信息
  13401. //var busi_card_info string
  13402. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13403. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13404. //fmt.Println(card_info)
  13405. //fmt.Println(busi_card_info)
  13406. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13407. result, _ := json.Marshal(respJSON)
  13408. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13409. utils.ErrorLog("解析失败:%v", err)
  13410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13411. return
  13412. }
  13413. res.ErrMsg = res10265.ErrMsg
  13414. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13415. res.Infcode = infocode
  13416. res.Output = res10265.Output
  13417. res.InfRefmsgid = res10265.InfRefmsgid
  13418. }
  13419. if res.Infcode == 0 {
  13420. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13421. if err == gorm.ErrRecordNotFound {
  13422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13423. return
  13424. } else if err != nil {
  13425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13426. return
  13427. } else {
  13428. if card_type == "1" {
  13429. bas := strings.Split(card_info, "|")
  13430. basNumber := bas[2]
  13431. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13432. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13433. infoStr := string(Iinfos)
  13434. idetinfoStr := string(Idetinfos)
  13435. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13436. psn := &models.HisPsn{
  13437. PsnNo: res.Output.Baseinfo.PsnNo,
  13438. PatientId: patient.ID,
  13439. Certno: res.Output.Baseinfo.Certno,
  13440. Brdy: b,
  13441. Age: float64(age),
  13442. Gend: res.Output.Baseinfo.Gend,
  13443. Naty: res.Output.Baseinfo.Naty,
  13444. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13445. PsnName: res.Output.Baseinfo.PsnName,
  13446. Idetinfo: idetinfoStr,
  13447. Insuinfo: infoStr,
  13448. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13449. CardInfo: card_info,
  13450. VerifyNumber: busi_card_info,
  13451. }
  13452. service.CreateHisPsn(psn)
  13453. var rf []*ResultFive
  13454. json.Unmarshal([]byte(infoStr), &rf)
  13455. var insutypes []*ResultFive
  13456. var insutype string
  13457. var is390 int = 0
  13458. var is310 int = 0
  13459. for _, item := range rf {
  13460. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13461. insutypes = append(insutypes, item)
  13462. }
  13463. }
  13464. if len(insutypes) == 1 {
  13465. insutype = insutypes[0].Insutype
  13466. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13467. } else {
  13468. for _, i := range insutypes {
  13469. if i.Insutype == "390" {
  13470. is390 = 1
  13471. }
  13472. if i.Insutype == "310" {
  13473. is310 = 1
  13474. }
  13475. }
  13476. }
  13477. if is390 == 1 {
  13478. insutype = "390"
  13479. }
  13480. if is310 == 1 {
  13481. insutype = "310"
  13482. }
  13483. if len(insutypes) == 0 {
  13484. insutype = "310"
  13485. }
  13486. c.ServeSuccessJSON(map[string]interface{}{
  13487. "patient": patient,
  13488. "number": basNumber,
  13489. "insutype": insutype,
  13490. })
  13491. } else {
  13492. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13493. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13494. infoStr := string(Iinfos)
  13495. idetinfoStr := string(Idetinfos)
  13496. psn := &models.HisPsn{
  13497. PsnNo: res.Output.Baseinfo.PsnNo,
  13498. PatientId: patient.ID,
  13499. Certno: res.Output.Baseinfo.Certno,
  13500. Gend: res.Output.Baseinfo.Gend,
  13501. Naty: res.Output.Baseinfo.Naty,
  13502. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13503. PsnName: res.Output.Baseinfo.PsnName,
  13504. Idetinfo: idetinfoStr,
  13505. Insuinfo: infoStr,
  13506. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13507. CardInfo: card_info,
  13508. VerifyNumber: token,
  13509. }
  13510. service.CreateHisPsn(psn)
  13511. c.ServeSuccessJSON(map[string]interface{}{
  13512. "patient": patient,
  13513. "number": token,
  13514. })
  13515. }
  13516. }
  13517. } else {
  13518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13519. return
  13520. }
  13521. } else { //读卡失败
  13522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13523. return
  13524. }
  13525. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13526. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13527. cardnum = DeleteExtraSpaceTwo(cardnum)
  13528. cardCode = DeleteExtraSpaceTwo(cardCode)
  13529. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13530. name = DeleteExtraSpaceTwo(name)
  13531. errmsg = DeleteExtraSpaceTwo(errmsg)
  13532. cardnum = Remove0000(cardnum)
  13533. cardCode = Remove0000(cardCode)
  13534. id_card_no = Remove0000(id_card_no)
  13535. name = Remove0000(name)
  13536. errmsg = Remove0000(errmsg)
  13537. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13538. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13539. //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)
  13540. //fmt.Println(result2)
  13541. //fmt.Println(requestLog2)
  13542. //fmt.Println(errMsgLog2)
  13543. 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)
  13544. saveLog(result, requestLog, "1101", "获取人员信息")
  13545. fmt.Println(errMsgLog)
  13546. if len(errMsgLog) > 0 {
  13547. } else {
  13548. var dat map[string]interface{}
  13549. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13550. fmt.Println(dat)
  13551. } else {
  13552. fmt.Println(err)
  13553. }
  13554. userJSONBytes, _ := json.Marshal(dat)
  13555. var res ResultTwo
  13556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13557. utils.ErrorLog("解析失败:%v", err)
  13558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13559. return
  13560. }
  13561. res.ErrMsg = errMsgLog
  13562. if res.Infcode == 0 {
  13563. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13564. if err == gorm.ErrRecordNotFound {
  13565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13566. return
  13567. } else if err != nil {
  13568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13569. return
  13570. } else {
  13571. fmt.Println(res)
  13572. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13573. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13574. infoStr := string(Iinfos)
  13575. idetinfoStr := string(Idetinfos)
  13576. var rf []*ResultFive
  13577. json.Unmarshal([]byte(infoStr), &rf)
  13578. var insutypes []*ResultFive
  13579. var insutype string
  13580. var is390 int = 0
  13581. var is310 int = 0
  13582. for _, item := range rf {
  13583. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13584. insutypes = append(insutypes, item)
  13585. }
  13586. }
  13587. if len(insutypes) == 1 {
  13588. insutype = insutypes[0].Insutype
  13589. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13590. } else {
  13591. for _, i := range insutypes {
  13592. if i.Insutype == "390" {
  13593. is390 = 1
  13594. }
  13595. if i.Insutype == "310" {
  13596. is310 = 1
  13597. }
  13598. }
  13599. }
  13600. if is390 == 1 {
  13601. insutype = "390"
  13602. }
  13603. if is310 == 1 {
  13604. insutype = "310"
  13605. }
  13606. if len(insutypes) == 0 {
  13607. insutype = "390"
  13608. }
  13609. var insuplc_admdvs string
  13610. for _, item := range rf {
  13611. if item.Insutype == insutype {
  13612. insuplc_admdvs = item.InsuplcAdmdvs
  13613. }
  13614. }
  13615. psn := &models.HisPsn{
  13616. PsnNo: res.Output.Baseinfo.PsnNo,
  13617. PatientId: patient.ID,
  13618. Certno: res.Output.Baseinfo.Certno,
  13619. Gend: res.Output.Baseinfo.Gend,
  13620. Naty: res.Output.Baseinfo.Naty,
  13621. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13622. PsnName: res.Output.Baseinfo.PsnName,
  13623. Idetinfo: idetinfoStr,
  13624. Insuinfo: infoStr,
  13625. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13626. CardInfo: basStr,
  13627. VerifyNumber: "",
  13628. InsuplcAdmdvs: insuplc_admdvs,
  13629. }
  13630. service.CreateHisPsn(psn)
  13631. c.ServeSuccessJSON(map[string]interface{}{
  13632. "patient": patient,
  13633. "number": cardnum,
  13634. "insutype": insutype,
  13635. })
  13636. }
  13637. } else {
  13638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13639. return
  13640. }
  13641. }
  13642. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13643. fmt.Println(initFlag)
  13644. fmt.Println("initFlag")
  13645. if initFlag == 0 {
  13646. c.TestGetJiangXiBasBaseInit()
  13647. }
  13648. basStr := c.GetBasBaseInfo()
  13649. if len(basStr) == 0 {
  13650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13651. return
  13652. }
  13653. fmt.Println(basStr)
  13654. bas := strings.Split(basStr, "|")
  13655. basNumber := bas[1]
  13656. fmt.Println(basNumber)
  13657. card := bas[2]
  13658. card_sn := bas[3]
  13659. fmt.Println(card_sn)
  13660. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13661. result, _ := service.Jxyb11012(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,card)
  13662. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13663. var dat map[string]interface{}
  13664. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13665. fmt.Println(dat)
  13666. } else {
  13667. fmt.Println(err)
  13668. }
  13669. userJSONBytes, _ := json.Marshal(dat)
  13670. var res ResultTwo
  13671. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13672. utils.ErrorLog("解析失败:%v", err)
  13673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13674. return
  13675. }
  13676. if res.Infcode == 0 {
  13677. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13678. if err == gorm.ErrRecordNotFound {
  13679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13680. return
  13681. } else if err != nil {
  13682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13683. return
  13684. } else {
  13685. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13686. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13687. infoStr := string(Iinfos)
  13688. idetinfoStr := string(Idetinfos)
  13689. var rf []*ResultFive
  13690. json.Unmarshal([]byte(infoStr), &rf)
  13691. var insutypes []*ResultFive
  13692. var insutype string
  13693. var is390 int = 0
  13694. var is310 int = 0
  13695. var insuplc_admdvs string
  13696. for _, item := range rf {
  13697. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13698. insutypes = append(insutypes, item)
  13699. }
  13700. }
  13701. if len(insutypes) == 1 {
  13702. insutype = insutypes[0].Insutype
  13703. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13704. } else {
  13705. for _, i := range insutypes {
  13706. if i.Insutype == "390" {
  13707. is390 = 1
  13708. }
  13709. if i.Insutype == "310" {
  13710. is310 = 1
  13711. }
  13712. }
  13713. }
  13714. if is390 == 1 {
  13715. insutype = "390"
  13716. }
  13717. if is310 == 1 {
  13718. insutype = "310"
  13719. }
  13720. if len(insutypes) == 0 {
  13721. insutype = "310"
  13722. }
  13723. for _, item := range rf {
  13724. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13725. insuplc_admdvs = item.InsuplcAdmdvs
  13726. }
  13727. }
  13728. psn := &models.HisPsn{
  13729. PsnNo: res.Output.Baseinfo.PsnNo,
  13730. PatientId: patient.ID,
  13731. Certno: res.Output.Baseinfo.Certno,
  13732. Gend: res.Output.Baseinfo.Gend,
  13733. Naty: res.Output.Baseinfo.Naty,
  13734. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13735. PsnName: res.Output.Baseinfo.PsnName,
  13736. Idetinfo: idetinfoStr,
  13737. Insuinfo: infoStr,
  13738. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13739. CardInfo: basStr,
  13740. InsuplcAdmdvs: insuplc_admdvs,
  13741. VerifyNumber: "",
  13742. }
  13743. service.CreateHisPsn(psn)
  13744. c.ServeSuccessJSON(map[string]interface{}{
  13745. "patient": patient,
  13746. "number": basNumber,
  13747. "insutype": insutype,
  13748. })
  13749. }
  13750. } else {
  13751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13752. return
  13753. }
  13754. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13755. basStr := c.GetBasBaseInfo22222()
  13756. fmt.Println(basStr)
  13757. if len(basStr) == 0 {
  13758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13759. return
  13760. }
  13761. fmt.Println(basStr)
  13762. bas := strings.Split(basStr, "|")
  13763. basNumber := bas[2] //卡号
  13764. card_sn := bas[3] //
  13765. id_card_No := bas[1] //卡号
  13766. fmt.Println(basNumber)
  13767. fmt.Println(card_sn)
  13768. fmt.Println(id_card_No)
  13769. var patient service.Patients
  13770. if len(id_card_No) == 0 {
  13771. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13772. } else {
  13773. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13774. }
  13775. result, _ := service.Jxyb1101bycard(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, patient.IdCardNo)
  13776. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13777. var dat map[string]interface{}
  13778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13779. fmt.Println(dat)
  13780. } else {
  13781. fmt.Println(err)
  13782. }
  13783. userJSONBytes, _ := json.Marshal(dat)
  13784. var res ResultTwo
  13785. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13786. utils.ErrorLog("解析失败:%v", err)
  13787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13788. return
  13789. }
  13790. if res.Infcode == 0 {
  13791. var pateint2 service.Patients
  13792. var err error
  13793. if len(id_card_No) == 0 {
  13794. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13795. } else {
  13796. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13797. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13798. }
  13799. if err == gorm.ErrRecordNotFound {
  13800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13801. return
  13802. } else if err != nil {
  13803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13804. return
  13805. } else {
  13806. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13807. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13808. infoStr := string(Iinfos)
  13809. idetinfoStr := string(Idetinfos)
  13810. var rf []*ResultFive
  13811. json.Unmarshal([]byte(infoStr), &rf)
  13812. var insutypes []*ResultFive
  13813. var insutype string
  13814. var is390 int = 0
  13815. var is310 int = 0
  13816. var insuplc_admdvs string
  13817. for _, item := range rf {
  13818. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13819. insutypes = append(insutypes, item)
  13820. }
  13821. }
  13822. if len(insutypes) == 1 {
  13823. insutype = insutypes[0].Insutype
  13824. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13825. } else {
  13826. for _, i := range insutypes {
  13827. if i.Insutype == "390" {
  13828. is390 = 1
  13829. }
  13830. if i.Insutype == "310" {
  13831. is310 = 1
  13832. }
  13833. }
  13834. }
  13835. if is390 == 1 {
  13836. insutype = "390"
  13837. }
  13838. if is310 == 1 {
  13839. insutype = "310"
  13840. }
  13841. if len(insutypes) == 0 {
  13842. insutype = "310"
  13843. }
  13844. for _, item := range rf {
  13845. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13846. insuplc_admdvs = item.InsuplcAdmdvs
  13847. }
  13848. }
  13849. psn := &models.HisPsn{
  13850. PsnNo: res.Output.Baseinfo.PsnNo,
  13851. PatientId: pateint2.ID,
  13852. Certno: res.Output.Baseinfo.Certno,
  13853. Gend: res.Output.Baseinfo.Gend,
  13854. Naty: res.Output.Baseinfo.Naty,
  13855. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13856. PsnName: res.Output.Baseinfo.PsnName,
  13857. Idetinfo: idetinfoStr,
  13858. Insuinfo: infoStr,
  13859. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13860. CardInfo: basStr,
  13861. InsuplcAdmdvs: insuplc_admdvs,
  13862. VerifyNumber: "",
  13863. }
  13864. service.CreateHisPsn(psn)
  13865. c.ServeSuccessJSON(map[string]interface{}{
  13866. "patient": patient,
  13867. "number": basNumber,
  13868. "insutype": insutype,
  13869. })
  13870. }
  13871. } else {
  13872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13873. return
  13874. }
  13875. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13876. fmt.Println(initFlag)
  13877. fmt.Println("initFlag")
  13878. if initFlag == 0 {
  13879. c.TestGetJiangXiBasBaseInittwo()
  13880. }
  13881. basStr := c.GetBasBaseInfo()
  13882. if len(basStr) == 0 {
  13883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13884. return
  13885. }
  13886. fmt.Println(basStr)
  13887. bas := strings.Split(basStr, "|")
  13888. basNumber := bas[1]
  13889. fmt.Println(basNumber)
  13890. card_sn := bas[3]
  13891. fmt.Println(card_sn)
  13892. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13893. 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)
  13894. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13895. var dat map[string]interface{}
  13896. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13897. fmt.Println(dat)
  13898. } else {
  13899. fmt.Println(err)
  13900. }
  13901. userJSONBytes, _ := json.Marshal(dat)
  13902. var res ResultTwo
  13903. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13904. utils.ErrorLog("解析失败:%v", err)
  13905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13906. return
  13907. }
  13908. if res.Infcode == 0 {
  13909. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13910. if err == gorm.ErrRecordNotFound {
  13911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13912. return
  13913. } else if err != nil {
  13914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13915. return
  13916. } else {
  13917. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13918. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13919. infoStr := string(Iinfos)
  13920. idetinfoStr := string(Idetinfos)
  13921. var rf []*ResultFive
  13922. json.Unmarshal([]byte(infoStr), &rf)
  13923. var insutypes []*ResultFive
  13924. var insutype string
  13925. var is390 int = 0
  13926. var is310 int = 0
  13927. var insuplc_admdvs string
  13928. for _, item := range rf {
  13929. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13930. insutypes = append(insutypes, item)
  13931. }
  13932. }
  13933. if len(insutypes) == 1 {
  13934. insutype = insutypes[0].Insutype
  13935. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13936. } else {
  13937. for _, i := range insutypes {
  13938. if i.Insutype == "390" {
  13939. is390 = 1
  13940. }
  13941. if i.Insutype == "310" {
  13942. is310 = 1
  13943. }
  13944. }
  13945. }
  13946. if is390 == 1 {
  13947. insutype = "390"
  13948. }
  13949. if is310 == 1 {
  13950. insutype = "310"
  13951. }
  13952. if len(insutypes) == 0 {
  13953. insutype = "310"
  13954. }
  13955. for _, item := range rf {
  13956. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13957. insuplc_admdvs = item.InsuplcAdmdvs
  13958. }
  13959. }
  13960. psn := &models.HisPsn{
  13961. PsnNo: res.Output.Baseinfo.PsnNo,
  13962. PatientId: patient.ID,
  13963. Certno: res.Output.Baseinfo.Certno,
  13964. Gend: res.Output.Baseinfo.Gend,
  13965. Naty: res.Output.Baseinfo.Naty,
  13966. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13967. PsnName: res.Output.Baseinfo.PsnName,
  13968. Idetinfo: idetinfoStr,
  13969. Insuinfo: infoStr,
  13970. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13971. CardInfo: basStr,
  13972. InsuplcAdmdvs: insuplc_admdvs,
  13973. VerifyNumber: "",
  13974. }
  13975. service.CreateHisPsn(psn)
  13976. c.ServeSuccessJSON(map[string]interface{}{
  13977. "patient": patient,
  13978. "number": basNumber,
  13979. "insutype": insutype,
  13980. })
  13981. }
  13982. } else {
  13983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13984. return
  13985. }
  13986. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13987. fmt.Println(initFlag)
  13988. fmt.Println("initFlag")
  13989. if initFlag == 0 {
  13990. c.TestGetHnBasBaseInit()
  13991. }
  13992. basStr := c.GetBasBaseInfo()
  13993. if len(basStr) == 0 {
  13994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13995. return
  13996. }
  13997. fmt.Println(basStr)
  13998. bas := strings.Split(basStr, "|")
  13999. basNumber := bas[1]
  14000. fmt.Println(basNumber)
  14001. card_sn := bas[3]
  14002. card_no := bas[2]
  14003. fmt.Println(card_sn)
  14004. name := bas[4]
  14005. name = ConvertToString(name, "gbk", "utf-8")
  14006. 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)
  14007. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14008. var dat map[string]interface{}
  14009. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14010. fmt.Println(dat)
  14011. } else {
  14012. fmt.Println(err)
  14013. }
  14014. userJSONBytes, _ := json.Marshal(dat)
  14015. var res ResultTwo
  14016. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14017. utils.ErrorLog("解析失败:%v", err)
  14018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14019. return
  14020. }
  14021. if res.Infcode == 0 {
  14022. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14023. if err == gorm.ErrRecordNotFound {
  14024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14025. return
  14026. } else if err != nil {
  14027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14028. return
  14029. } else {
  14030. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14031. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14032. infoStr := string(Iinfos)
  14033. idetinfoStr := string(Idetinfos)
  14034. psn := &models.HisPsn{
  14035. PsnNo: res.Output.Baseinfo.PsnNo,
  14036. PatientId: patient.ID,
  14037. Certno: res.Output.Baseinfo.Certno,
  14038. Gend: res.Output.Baseinfo.Gend,
  14039. Naty: res.Output.Baseinfo.Naty,
  14040. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14041. PsnName: res.Output.Baseinfo.PsnName,
  14042. Idetinfo: idetinfoStr,
  14043. Insuinfo: infoStr,
  14044. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14045. CardInfo: basStr,
  14046. VerifyNumber: "",
  14047. }
  14048. service.CreateHisPsn(psn)
  14049. var rf []*ResultFive
  14050. json.Unmarshal([]byte(infoStr), &rf)
  14051. var insutypes []*ResultFive
  14052. var insutype string
  14053. var is390 int = 0
  14054. var is310 int = 0
  14055. for _, item := range rf {
  14056. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14057. insutypes = append(insutypes, item)
  14058. }
  14059. }
  14060. if len(insutypes) == 1 {
  14061. insutype = insutypes[0].Insutype
  14062. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14063. } else {
  14064. for _, i := range insutypes {
  14065. if i.Insutype == "390" {
  14066. is390 = 1
  14067. }
  14068. if i.Insutype == "310" {
  14069. is310 = 1
  14070. }
  14071. }
  14072. }
  14073. if is390 == 1 {
  14074. insutype = "390"
  14075. }
  14076. if is310 == 1 {
  14077. insutype = "310"
  14078. }
  14079. if len(insutypes) == 0 {
  14080. insutype = "310"
  14081. }
  14082. c.ServeSuccessJSON(map[string]interface{}{
  14083. "patient": patient,
  14084. "number": basNumber,
  14085. "insutype": insutype,
  14086. })
  14087. }
  14088. } else {
  14089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14090. return
  14091. }
  14092. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14093. var api string
  14094. 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 +
  14095. "&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
  14096. fmt.Println(api)
  14097. resp, requestErr := http.Get(api)
  14098. if requestErr != nil {
  14099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14100. return
  14101. }
  14102. body, ioErr := ioutil.ReadAll(resp.Body)
  14103. if ioErr != nil {
  14104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14106. return
  14107. }
  14108. var respJSON map[string]interface{}
  14109. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14112. return
  14113. }
  14114. var res ResultTwo //1101结果
  14115. var res10265 ResultTwo10265 //1101结果
  14116. var card_info string //卡信息
  14117. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14118. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14119. result, _ := json.Marshal(respJSON)
  14120. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14121. utils.ErrorLog("解析失败:%v", err)
  14122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14123. return
  14124. }
  14125. res.ErrMsg = res10265.ErrMsg
  14126. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14127. res.Infcode = infocode
  14128. res.Output = res10265.Output
  14129. res.InfRefmsgid = res10265.InfRefmsgid
  14130. if res.Infcode == 0 {
  14131. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14132. if err == gorm.ErrRecordNotFound {
  14133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14134. return
  14135. } else if err != nil {
  14136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14137. return
  14138. } else {
  14139. bas := strings.Split(card_info, "|")
  14140. basNumber := bas[2]
  14141. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14142. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14143. infoStr := string(Iinfos)
  14144. idetinfoStr := string(Idetinfos)
  14145. psn := &models.HisPsn{
  14146. PsnNo: res.Output.Baseinfo.PsnNo,
  14147. PatientId: patient.ID,
  14148. Certno: res.Output.Baseinfo.Certno,
  14149. Gend: res.Output.Baseinfo.Gend,
  14150. Naty: res.Output.Baseinfo.Naty,
  14151. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14152. PsnName: res.Output.Baseinfo.PsnName,
  14153. Idetinfo: idetinfoStr,
  14154. Insuinfo: infoStr,
  14155. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14156. CardInfo: card_info,
  14157. VerifyNumber: token,
  14158. }
  14159. service.CreateHisPsn(psn)
  14160. var rf []*ResultFive
  14161. json.Unmarshal([]byte(infoStr), &rf)
  14162. var insutypes []*ResultFive
  14163. var insutype string
  14164. var is390 int = 0
  14165. var is310 int = 0
  14166. for _, item := range rf {
  14167. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14168. insutypes = append(insutypes, item)
  14169. }
  14170. }
  14171. if len(insutypes) == 1 {
  14172. insutype = insutypes[0].Insutype
  14173. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14174. } else {
  14175. for _, i := range insutypes {
  14176. if i.Insutype == "390" {
  14177. is390 = 1
  14178. }
  14179. if i.Insutype == "310" {
  14180. is310 = 1
  14181. }
  14182. }
  14183. }
  14184. if is390 == 1 {
  14185. insutype = "390"
  14186. }
  14187. if is310 == 1 {
  14188. insutype = "310"
  14189. }
  14190. if len(insutypes) == 0 {
  14191. insutype = "310"
  14192. }
  14193. c.ServeSuccessJSON(map[string]interface{}{
  14194. "patient": patient,
  14195. "number": basNumber,
  14196. "insutype": insutype,
  14197. })
  14198. }
  14199. } else {
  14200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14201. return
  14202. }
  14203. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14204. res := c.GetoleInfo()
  14205. if res.Infcode == 0 {
  14206. var result string
  14207. if res.Output.MdtrtCertType == "01" {
  14208. 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)
  14209. } else if res.Output.MdtrtCertType == "02" {
  14210. 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)
  14211. } else if res.Output.MdtrtCertType == "03" {
  14212. 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)
  14213. }
  14214. var dat map[string]interface{}
  14215. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14216. fmt.Println(dat)
  14217. } else {
  14218. fmt.Println(err)
  14219. }
  14220. userJSONBytes, _ := json.Marshal(dat)
  14221. var res2 ResultTwo
  14222. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14223. utils.ErrorLog("解析失败:%v", err)
  14224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14225. return
  14226. }
  14227. if res2.Infcode == 0 {
  14228. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14229. if err == gorm.ErrRecordNotFound {
  14230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14231. return
  14232. } else if err != nil {
  14233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14234. return
  14235. } else {
  14236. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14237. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14238. infoStr := string(Iinfos)
  14239. idetinfoStr := string(Idetinfos)
  14240. var rf []*ResultFive
  14241. json.Unmarshal([]byte(infoStr), &rf)
  14242. var insutypes []*ResultFive
  14243. var insutype string
  14244. var is390 int = 0
  14245. var is310 int = 0
  14246. //var insuplc_admdvs string
  14247. for _, item := range rf {
  14248. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14249. insutypes = append(insutypes, item)
  14250. }
  14251. }
  14252. if len(insutypes) == 1 {
  14253. insutype = insutypes[0].Insutype
  14254. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14255. } else {
  14256. for _, i := range insutypes {
  14257. if i.Insutype == "390" {
  14258. is390 = 1
  14259. }
  14260. if i.Insutype == "310" {
  14261. is310 = 1
  14262. }
  14263. }
  14264. }
  14265. if is390 == 1 {
  14266. insutype = "390"
  14267. }
  14268. if is310 == 1 {
  14269. insutype = "310"
  14270. }
  14271. if len(insutypes) == 0 {
  14272. insutype = "310"
  14273. }
  14274. psn := &models.HisPsn{
  14275. PsnNo: res2.Output.Baseinfo.PsnNo,
  14276. PatientId: patient.ID,
  14277. Certno: res2.Output.Baseinfo.Certno,
  14278. Gend: res2.Output.Baseinfo.Gend,
  14279. Naty: res2.Output.Baseinfo.Naty,
  14280. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14281. PsnName: res2.Output.Baseinfo.PsnName,
  14282. Idetinfo: idetinfoStr,
  14283. Insuinfo: infoStr,
  14284. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14285. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14286. VerifyNumber: res.Output.EcToken,
  14287. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14288. }
  14289. if res.Output.MdtrtCertType == "01" {
  14290. psn.VerifyNumber = res.Output.EcToken
  14291. //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)
  14292. } else if res.Output.MdtrtCertType == "02" {
  14293. psn.VerifyNumber = res.Output.MdtrtCertNo
  14294. //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)
  14295. } else if res.Output.MdtrtCertType == "03" {
  14296. psn.VerifyNumber = res.Output.MdtrtCertNo
  14297. //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)
  14298. }
  14299. var balc float64
  14300. for _, item := range rf {
  14301. if item.Insutype == insutype {
  14302. balc = item.Balc
  14303. }
  14304. }
  14305. service.CreateHisPsn(psn)
  14306. c.ServeSuccessJSON(map[string]interface{}{
  14307. "patient": patient,
  14308. "number": res.Output.CardNo,
  14309. "insutype": insutype,
  14310. "blac": balc,
  14311. "desc": idetinfoStr,
  14312. })
  14313. }
  14314. } else {
  14315. c.ServeSuccessJSON(map[string]interface{}{
  14316. "failed_code": -10,
  14317. "msg": res2.ErrMsg,
  14318. })
  14319. }
  14320. } else {
  14321. c.ServeSuccessJSON(map[string]interface{}{
  14322. "failed_code": -10,
  14323. "msg": res.ErrMsg,
  14324. })
  14325. }
  14326. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14327. var api string
  14328. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14329. "&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
  14330. fmt.Println(api)
  14331. resp, requestErr := http.Get(api)
  14332. if requestErr != nil {
  14333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14334. return
  14335. }
  14336. body, ioErr := ioutil.ReadAll(resp.Body)
  14337. if ioErr != nil {
  14338. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14340. return
  14341. }
  14342. var respJSON map[string]interface{}
  14343. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14346. return
  14347. }
  14348. var status string
  14349. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14350. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14351. //console.log()
  14352. fmt.Println("type===")
  14353. fmt.Println(card_type)
  14354. var token string
  14355. var res ResultTwo //1101结果
  14356. //var res10265 ResultTwoesultTwo10265 //1101结果
  14357. var card_info string //卡信息
  14358. var busi_card_info string
  14359. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14360. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14361. if status == "0" { //读卡成功
  14362. if card_type == "1" {
  14363. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14364. result, _ := json.Marshal(respJSON)
  14365. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14366. utils.ErrorLog("解析失败:%v", err)
  14367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14368. return
  14369. }
  14370. } else {
  14371. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14372. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14373. result, _ := json.Marshal(respJSON)
  14374. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14375. utils.ErrorLog("解析失败:%v", err)
  14376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14377. return
  14378. }
  14379. }
  14380. if res.Infcode == 0 {
  14381. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14382. if err == gorm.ErrRecordNotFound {
  14383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14384. return
  14385. } else if err != nil {
  14386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14387. return
  14388. } else {
  14389. if card_type == "1" {
  14390. bas := strings.Split(card_info, "|")
  14391. basNumber := bas[2]
  14392. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14393. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14394. infoStr := string(Iinfos)
  14395. idetinfoStr := string(Idetinfos)
  14396. psn := &models.HisPsn{
  14397. PsnNo: res.Output.Baseinfo.PsnNo,
  14398. PatientId: patient.ID,
  14399. Certno: res.Output.Baseinfo.Certno,
  14400. Gend: res.Output.Baseinfo.Gend,
  14401. Naty: res.Output.Baseinfo.Naty,
  14402. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14403. PsnName: res.Output.Baseinfo.PsnName,
  14404. Idetinfo: idetinfoStr,
  14405. Insuinfo: infoStr,
  14406. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14407. CardInfo: card_info,
  14408. VerifyNumber: busi_card_info,
  14409. }
  14410. service.CreateHisPsn(psn)
  14411. var rf []*ResultFive
  14412. json.Unmarshal([]byte(infoStr), &rf)
  14413. var insutypes []*ResultFive
  14414. var insutype string
  14415. var is390 int = 0
  14416. var is310 int = 0
  14417. for _, item := range rf {
  14418. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14419. insutypes = append(insutypes, item)
  14420. }
  14421. }
  14422. if len(insutypes) == 1 {
  14423. insutype = insutypes[0].Insutype
  14424. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14425. } else {
  14426. for _, i := range insutypes {
  14427. if i.Insutype == "390" {
  14428. is390 = 1
  14429. }
  14430. if i.Insutype == "310" {
  14431. is310 = 1
  14432. }
  14433. }
  14434. }
  14435. if is390 == 1 {
  14436. insutype = "390"
  14437. }
  14438. if is310 == 1 {
  14439. insutype = "310"
  14440. }
  14441. if len(insutypes) == 0 {
  14442. insutype = "310"
  14443. }
  14444. c.ServeSuccessJSON(map[string]interface{}{
  14445. "patient": patient,
  14446. "number": basNumber,
  14447. "insutype": insutype,
  14448. })
  14449. } else {
  14450. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14451. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14452. infoStr := string(Iinfos)
  14453. idetinfoStr := string(Idetinfos)
  14454. psn := &models.HisPsn{
  14455. PsnNo: res.Output.Baseinfo.PsnNo,
  14456. PatientId: patient.ID,
  14457. Certno: res.Output.Baseinfo.Certno,
  14458. Gend: res.Output.Baseinfo.Gend,
  14459. Naty: res.Output.Baseinfo.Naty,
  14460. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14461. PsnName: res.Output.Baseinfo.PsnName,
  14462. Idetinfo: idetinfoStr,
  14463. Insuinfo: infoStr,
  14464. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14465. CardInfo: card_info,
  14466. VerifyNumber: token,
  14467. }
  14468. service.CreateHisPsn(psn)
  14469. c.ServeSuccessJSON(map[string]interface{}{
  14470. "patient": patient,
  14471. "number": token,
  14472. })
  14473. }
  14474. }
  14475. } else {
  14476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14477. return
  14478. }
  14479. } else { //读卡失败
  14480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14481. return
  14482. }
  14483. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14484. var api string
  14485. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14486. "&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
  14487. fmt.Println(api)
  14488. resp, requestErr := http.Get(api)
  14489. if requestErr != nil {
  14490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14491. return
  14492. }
  14493. body, ioErr := ioutil.ReadAll(resp.Body)
  14494. if ioErr != nil {
  14495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14497. return
  14498. }
  14499. var respJSON map[string]interface{}
  14500. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14503. return
  14504. }
  14505. var status string
  14506. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14507. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14508. //console.log()
  14509. fmt.Println("type===")
  14510. fmt.Println(card_type)
  14511. var token string
  14512. var res ResultTwo //1101结果
  14513. //var res10265 ResultTwoesultTwo10265 //1101结果
  14514. var card_info string //卡信息
  14515. //var busi_card_info string
  14516. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14517. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14518. if status == "0" { //读卡成功
  14519. if card_type == "1" {
  14520. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14521. result, _ := json.Marshal(respJSON)
  14522. fmt.Println(result)
  14523. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14524. utils.ErrorLog("解析失败:%v", err)
  14525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14526. return
  14527. }
  14528. fmt.Println(res)
  14529. } else {
  14530. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14531. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14532. result, _ := json.Marshal(respJSON)
  14533. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14534. utils.ErrorLog("解析失败:%v", err)
  14535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14536. return
  14537. }
  14538. }
  14539. if res.Infcode == 0 {
  14540. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14541. if err == gorm.ErrRecordNotFound {
  14542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14543. return
  14544. } else if err != nil {
  14545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14546. return
  14547. } else {
  14548. if card_type == "1" {
  14549. bas := strings.Split(card_info, "|")
  14550. basNumber := bas[2]
  14551. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14552. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14553. infoStr := string(Iinfos)
  14554. idetinfoStr := string(Idetinfos)
  14555. psn := &models.HisPsn{
  14556. PsnNo: res.Output.Baseinfo.PsnNo,
  14557. PatientId: patient.ID,
  14558. Certno: res.Output.Baseinfo.Certno,
  14559. Gend: res.Output.Baseinfo.Gend,
  14560. Naty: res.Output.Baseinfo.Naty,
  14561. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14562. PsnName: res.Output.Baseinfo.PsnName,
  14563. Idetinfo: idetinfoStr,
  14564. Insuinfo: infoStr,
  14565. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14566. CardInfo: card_info,
  14567. //VerifyNumber: busi_card_info,
  14568. }
  14569. service.CreateHisPsn(psn)
  14570. var rf []*ResultFive
  14571. json.Unmarshal([]byte(infoStr), &rf)
  14572. var insutypes []*ResultFive
  14573. var insutype string
  14574. var is390 int = 0
  14575. var is310 int = 0
  14576. for _, item := range rf {
  14577. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14578. insutypes = append(insutypes, item)
  14579. }
  14580. }
  14581. if len(insutypes) == 1 {
  14582. insutype = insutypes[0].Insutype
  14583. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14584. } else {
  14585. for _, i := range insutypes {
  14586. if i.Insutype == "390" {
  14587. is390 = 1
  14588. }
  14589. if i.Insutype == "310" {
  14590. is310 = 1
  14591. }
  14592. }
  14593. }
  14594. if is390 == 1 {
  14595. insutype = "390"
  14596. }
  14597. if is310 == 1 {
  14598. insutype = "310"
  14599. }
  14600. if len(insutypes) == 0 {
  14601. insutype = "310"
  14602. }
  14603. c.ServeSuccessJSON(map[string]interface{}{
  14604. "patient": patient,
  14605. "number": basNumber,
  14606. "insutype": insutype,
  14607. })
  14608. } else {
  14609. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14610. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14611. infoStr := string(Iinfos)
  14612. idetinfoStr := string(Idetinfos)
  14613. psn := &models.HisPsn{
  14614. PsnNo: res.Output.Baseinfo.PsnNo,
  14615. PatientId: patient.ID,
  14616. Certno: res.Output.Baseinfo.Certno,
  14617. Gend: res.Output.Baseinfo.Gend,
  14618. Naty: res.Output.Baseinfo.Naty,
  14619. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14620. PsnName: res.Output.Baseinfo.PsnName,
  14621. Idetinfo: idetinfoStr,
  14622. Insuinfo: infoStr,
  14623. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14624. CardInfo: card_info,
  14625. VerifyNumber: token,
  14626. }
  14627. service.CreateHisPsn(psn)
  14628. c.ServeSuccessJSON(map[string]interface{}{
  14629. "patient": patient,
  14630. "number": token,
  14631. })
  14632. }
  14633. }
  14634. } else {
  14635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14636. return
  14637. }
  14638. } else { //读卡失败
  14639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14640. return
  14641. }
  14642. } else {
  14643. if initFlag == 0 {
  14644. c.TestGetBasBaseInit()
  14645. }
  14646. basStr := c.GetBasBaseInfo()
  14647. if len(basStr) == 0 {
  14648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14649. return
  14650. }
  14651. fmt.Println(basStr)
  14652. bas := strings.Split(basStr, "|")
  14653. basNumber := bas[1]
  14654. fmt.Println(basNumber)
  14655. card_sn := bas[3]
  14656. fmt.Println(card_sn)
  14657. cardNumber := bas[2]
  14658. fmt.Println(cardNumber)
  14659. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14660. var result string
  14661. if bas[0][:2] == "44" {
  14662. 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)
  14663. } else {
  14664. 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)
  14665. }
  14666. var dat map[string]interface{}
  14667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14668. fmt.Println(dat)
  14669. } else {
  14670. fmt.Println(err)
  14671. }
  14672. userJSONBytes, _ := json.Marshal(dat)
  14673. var res ResultTwo
  14674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14675. utils.ErrorLog("解析失败:%v", err)
  14676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14677. return
  14678. }
  14679. if res.Infcode == 0 {
  14680. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14681. if err == gorm.ErrRecordNotFound {
  14682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14683. return
  14684. } else if err != nil {
  14685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14686. return
  14687. } else {
  14688. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14689. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14690. infoStr := string(Iinfos)
  14691. idetinfoStr := string(Idetinfos)
  14692. var rf []*ResultFive
  14693. json.Unmarshal([]byte(infoStr), &rf)
  14694. var insutypes []*ResultFive
  14695. var insutype string
  14696. var is390 int = 0
  14697. var is310 int = 0
  14698. var insuplc_admdvs string
  14699. for _, item := range rf {
  14700. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14701. insutypes = append(insutypes, item)
  14702. }
  14703. }
  14704. if len(insutypes) == 1 {
  14705. insutype = insutypes[0].Insutype
  14706. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14707. } else {
  14708. for _, i := range insutypes {
  14709. if i.Insutype == "390" {
  14710. is390 = 1
  14711. }
  14712. if i.Insutype == "310" {
  14713. is310 = 1
  14714. }
  14715. }
  14716. }
  14717. if is390 == 1 {
  14718. insutype = "390"
  14719. }
  14720. if is310 == 1 {
  14721. insutype = "310"
  14722. }
  14723. if len(insutypes) == 0 {
  14724. insutype = "310"
  14725. }
  14726. for _, item := range rf {
  14727. if item.Insutype == insutype {
  14728. insuplc_admdvs = item.InsuplcAdmdvs
  14729. }
  14730. }
  14731. psn := &models.HisPsn{
  14732. PsnNo: res.Output.Baseinfo.PsnNo,
  14733. PatientId: patient.ID,
  14734. Certno: res.Output.Baseinfo.Certno,
  14735. Gend: res.Output.Baseinfo.Gend,
  14736. Naty: res.Output.Baseinfo.Naty,
  14737. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14738. PsnName: res.Output.Baseinfo.PsnName,
  14739. Idetinfo: idetinfoStr,
  14740. Insuinfo: infoStr,
  14741. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14742. CardInfo: basStr,
  14743. VerifyNumber: "",
  14744. InsuplcAdmdvs: insuplc_admdvs,
  14745. }
  14746. service.CreateHisPsn(psn)
  14747. c.ServeSuccessJSON(map[string]interface{}{
  14748. "patient": patient,
  14749. "number": basNumber,
  14750. })
  14751. }
  14752. } else {
  14753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14754. return
  14755. }
  14756. break
  14757. }
  14758. case 2:
  14759. if miConfig.MdtrtareaAdmvs == "430800" {
  14760. if initFlag == 0 {
  14761. c.TestGetHnBasBaseInit()
  14762. }
  14763. SFZStr := c.GetSFZBaseInfo()
  14764. if len(SFZStr) == 0 {
  14765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14766. return
  14767. }
  14768. fmt.Println(SFZStr)
  14769. id_card_str := strings.Split(SFZStr, "^")
  14770. card_no := id_card_str[0]
  14771. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14772. //name := id_card_str[1]
  14773. //name = ConvertToString(name, "gbk", "utf-8")
  14774. 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)
  14775. var dat map[string]interface{}
  14776. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14777. fmt.Println(dat)
  14778. } else {
  14779. fmt.Println(err)
  14780. }
  14781. userJSONBytes, _ := json.Marshal(dat)
  14782. var res ResultTwo
  14783. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14784. utils.ErrorLog("解析失败:%v", err)
  14785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14786. return
  14787. }
  14788. if res.Infcode == 0 {
  14789. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14790. if err == gorm.ErrRecordNotFound {
  14791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14792. return
  14793. } else if err != nil {
  14794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14795. return
  14796. } else {
  14797. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14798. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14799. infoStr := string(Iinfos)
  14800. idetinfoStr := string(Idetinfos)
  14801. var rf []*ResultFive
  14802. json.Unmarshal([]byte(infoStr), &rf)
  14803. var insutypes []*ResultFive
  14804. var insutype string
  14805. var is390 int = 0
  14806. var is310 int = 0
  14807. for _, item := range rf {
  14808. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14809. insutypes = append(insutypes, item)
  14810. }
  14811. }
  14812. if len(insutypes) == 1 {
  14813. insutype = insutypes[0].Insutype
  14814. } else {
  14815. for _, i := range insutypes {
  14816. if i.Insutype == "390" {
  14817. is390 = 1
  14818. }
  14819. if i.Insutype == "310" {
  14820. is310 = 1
  14821. }
  14822. }
  14823. }
  14824. if is390 == 1 {
  14825. insutype = "390"
  14826. }
  14827. if is310 == 1 {
  14828. insutype = "310"
  14829. }
  14830. if len(insutypes) == 0 {
  14831. insutype = "310"
  14832. }
  14833. var InsuplcAdmdvs string
  14834. for _, item := range rf {
  14835. if item.Insutype == insutype {
  14836. InsuplcAdmdvs = item.InsuplcAdmdvs
  14837. }
  14838. }
  14839. psn := &models.HisPsn{
  14840. PsnNo: res.Output.Baseinfo.PsnNo,
  14841. PatientId: patient.ID,
  14842. Certno: res.Output.Baseinfo.Certno,
  14843. Gend: res.Output.Baseinfo.Gend,
  14844. Naty: res.Output.Baseinfo.Naty,
  14845. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14846. PsnName: res.Output.Baseinfo.PsnName,
  14847. Idetinfo: idetinfoStr,
  14848. Insuinfo: infoStr,
  14849. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14850. CardInfo: SFZStr,
  14851. VerifyNumber: "",
  14852. InsuplcAdmdvs: InsuplcAdmdvs,
  14853. }
  14854. service.CreateHisPsn(psn)
  14855. c.ServeSuccessJSON(map[string]interface{}{
  14856. "patient": patient,
  14857. "number": card_no,
  14858. "insutype": insutype,
  14859. })
  14860. }
  14861. } else {
  14862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14863. return
  14864. }
  14865. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14866. var res ResultTwo
  14867. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14868. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14869. "&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)
  14870. resp, requestErr := http.Get(api)
  14871. if requestErr != nil {
  14872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14873. return
  14874. }
  14875. body, ioErr := ioutil.ReadAll(resp.Body)
  14876. if ioErr != nil {
  14877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14879. return
  14880. }
  14881. var respJSON map[string]interface{}
  14882. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14885. return
  14886. }
  14887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14888. result, _ := json.Marshal(respJSON)
  14889. fmt.Println("log")
  14890. fmt.Println(string(result))
  14891. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14892. utils.ErrorLog("解析失败:%v", err)
  14893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14894. return
  14895. }
  14896. if res.Infcode == 0 {
  14897. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14898. if err == gorm.ErrRecordNotFound {
  14899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14900. return
  14901. } else if err != nil {
  14902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14903. return
  14904. } else {
  14905. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14906. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14907. infoStr := string(Iinfos)
  14908. idetinfoStr := string(Idetinfos)
  14909. psn := &models.HisPsn{
  14910. PsnNo: res.Output.Baseinfo.PsnNo,
  14911. PatientId: patient.ID,
  14912. Certno: res.Output.Baseinfo.Certno,
  14913. Gend: res.Output.Baseinfo.Gend,
  14914. Naty: res.Output.Baseinfo.Naty,
  14915. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14916. PsnName: res.Output.Baseinfo.PsnName,
  14917. Idetinfo: idetinfoStr,
  14918. Insuinfo: infoStr,
  14919. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14920. }
  14921. service.CreateHisPsn(psn)
  14922. c.ServeSuccessJSON(map[string]interface{}{
  14923. "patient": patient,
  14924. "number": res.Output.Baseinfo.Certno,
  14925. })
  14926. }
  14927. } else {
  14928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14929. return
  14930. }
  14931. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14932. var res ResultTwo
  14933. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14934. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14935. "&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)
  14936. resp, requestErr := http.Get(api)
  14937. if requestErr != nil {
  14938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14939. return
  14940. }
  14941. body, ioErr := ioutil.ReadAll(resp.Body)
  14942. if ioErr != nil {
  14943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14945. return
  14946. }
  14947. var respJSON map[string]interface{}
  14948. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14951. return
  14952. }
  14953. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14954. result, _ := json.Marshal(respJSON)
  14955. fmt.Println("log")
  14956. fmt.Println(string(result))
  14957. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14958. utils.ErrorLog("解析失败:%v", err)
  14959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14960. return
  14961. }
  14962. if res.Infcode == 0 {
  14963. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14964. if err == gorm.ErrRecordNotFound {
  14965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14966. return
  14967. } else if err != nil {
  14968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14969. return
  14970. } else {
  14971. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14972. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14973. infoStr := string(Iinfos)
  14974. idetinfoStr := string(Idetinfos)
  14975. psn := &models.HisPsn{
  14976. PsnNo: res.Output.Baseinfo.PsnNo,
  14977. PatientId: patient.ID,
  14978. Certno: res.Output.Baseinfo.Certno,
  14979. Gend: res.Output.Baseinfo.Gend,
  14980. Naty: res.Output.Baseinfo.Naty,
  14981. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14982. PsnName: res.Output.Baseinfo.PsnName,
  14983. Idetinfo: idetinfoStr,
  14984. Insuinfo: infoStr,
  14985. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14986. }
  14987. service.CreateHisPsn(psn)
  14988. c.ServeSuccessJSON(map[string]interface{}{
  14989. "patient": patient,
  14990. "number": res.Output.Baseinfo.Certno,
  14991. })
  14992. }
  14993. } else {
  14994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14995. return
  14996. }
  14997. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14998. var res ResultTwo
  14999. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15000. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15001. "&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)
  15002. resp, requestErr := http.Get(api)
  15003. if requestErr != nil {
  15004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15005. return
  15006. }
  15007. body, ioErr := ioutil.ReadAll(resp.Body)
  15008. if ioErr != nil {
  15009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15011. return
  15012. }
  15013. var respJSON map[string]interface{}
  15014. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15017. return
  15018. }
  15019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15020. result, _ := json.Marshal(respJSON)
  15021. fmt.Println("log")
  15022. fmt.Println(string(result))
  15023. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15024. utils.ErrorLog("解析失败:%v", err)
  15025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15026. return
  15027. }
  15028. if res.Infcode == 0 {
  15029. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15030. if err == gorm.ErrRecordNotFound {
  15031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15032. return
  15033. } else if err != nil {
  15034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15035. return
  15036. } else {
  15037. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15038. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15039. infoStr := string(Iinfos)
  15040. idetinfoStr := string(Idetinfos)
  15041. var rf []*ResultFive
  15042. json.Unmarshal([]byte(infoStr), &rf)
  15043. var insutypes []*ResultFive
  15044. var insutype string
  15045. var is390 int = 0
  15046. var is310 int = 0
  15047. for _, item := range rf {
  15048. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15049. insutypes = append(insutypes, item)
  15050. }
  15051. }
  15052. if len(insutypes) == 1 {
  15053. insutype = insutypes[0].Insutype
  15054. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15055. } else {
  15056. for _, i := range insutypes {
  15057. if i.Insutype == "390" {
  15058. is390 = 1
  15059. }
  15060. if i.Insutype == "310" {
  15061. is310 = 1
  15062. }
  15063. }
  15064. }
  15065. if is390 == 1 {
  15066. insutype = "390"
  15067. }
  15068. if is310 == 1 {
  15069. insutype = "310"
  15070. }
  15071. if len(insutypes) == 0 {
  15072. insutype = "390"
  15073. }
  15074. var insuplc_admdvs string
  15075. for _, item := range rf {
  15076. if item.Insutype == insutype {
  15077. insuplc_admdvs = item.InsuplcAdmdvs
  15078. }
  15079. }
  15080. psn := &models.HisPsn{
  15081. PsnNo: res.Output.Baseinfo.PsnNo,
  15082. PatientId: patient.ID,
  15083. Certno: res.Output.Baseinfo.Certno,
  15084. Gend: res.Output.Baseinfo.Gend,
  15085. Naty: res.Output.Baseinfo.Naty,
  15086. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15087. PsnName: res.Output.Baseinfo.PsnName,
  15088. Idetinfo: idetinfoStr,
  15089. Insuinfo: infoStr,
  15090. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15091. InsuplcAdmdvs: insuplc_admdvs,
  15092. }
  15093. service.CreateHisPsn(psn)
  15094. c.ServeSuccessJSON(map[string]interface{}{
  15095. "patient": patient,
  15096. "number": res.Output.Baseinfo.Certno,
  15097. })
  15098. }
  15099. } else {
  15100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15101. return
  15102. }
  15103. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15104. res := c.GetoleInfo()
  15105. if res.Infcode == 0 {
  15106. var result string
  15107. if res.Output.MdtrtCertType == "01" {
  15108. 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)
  15109. } else if res.Output.MdtrtCertType == "02" {
  15110. 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)
  15111. } else if res.Output.MdtrtCertType == "03" {
  15112. 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)
  15113. }
  15114. var dat map[string]interface{}
  15115. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15116. fmt.Println(dat)
  15117. } else {
  15118. fmt.Println(err)
  15119. }
  15120. userJSONBytes, _ := json.Marshal(dat)
  15121. var res2 ResultTwo
  15122. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15123. utils.ErrorLog("解析失败:%v", err)
  15124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15125. return
  15126. }
  15127. if res2.Infcode == 0 {
  15128. patient, err := service.GetPatientByNumber(res.Output.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(res2.Output.Iinfo)
  15137. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15138. infoStr := string(Iinfos)
  15139. idetinfoStr := string(Idetinfos)
  15140. var rf []*ResultFive
  15141. json.Unmarshal([]byte(infoStr), &rf)
  15142. var insutypes []*ResultFive
  15143. var insutype string
  15144. var is390 int = 0
  15145. var is310 int = 0
  15146. //var insuplc_admdvs string
  15147. for _, item := range rf {
  15148. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15149. insutypes = append(insutypes, item)
  15150. }
  15151. }
  15152. if len(insutypes) == 1 {
  15153. insutype = insutypes[0].Insutype
  15154. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15155. } else {
  15156. for _, i := range insutypes {
  15157. if i.Insutype == "390" {
  15158. is390 = 1
  15159. }
  15160. if i.Insutype == "310" {
  15161. is310 = 1
  15162. }
  15163. }
  15164. }
  15165. if is390 == 1 {
  15166. insutype = "390"
  15167. }
  15168. if is310 == 1 {
  15169. insutype = "310"
  15170. }
  15171. if len(insutypes) == 0 {
  15172. insutype = "310"
  15173. }
  15174. psn := &models.HisPsn{
  15175. PsnNo: res2.Output.Baseinfo.PsnNo,
  15176. PatientId: patient.ID,
  15177. //Brdy: res2.Output.Baseinfo.Brdy,
  15178. Certno: res2.Output.Baseinfo.Certno,
  15179. Gend: res2.Output.Baseinfo.Gend,
  15180. Naty: res2.Output.Baseinfo.Naty,
  15181. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15182. PsnName: res2.Output.Baseinfo.PsnName,
  15183. Idetinfo: idetinfoStr,
  15184. Insuinfo: infoStr,
  15185. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15186. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15187. VerifyNumber: res.Output.EcToken,
  15188. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15189. }
  15190. service.CreateHisPsn(psn)
  15191. var balc float64
  15192. for _, item := range rf {
  15193. if item.Insutype == insutype {
  15194. balc = item.Balc
  15195. }
  15196. }
  15197. c.ServeSuccessJSON(map[string]interface{}{
  15198. "patient": patient,
  15199. "number": res.Output.CardNo,
  15200. "insutype": insutype,
  15201. "blac": balc,
  15202. "desc": idetinfoStr,
  15203. })
  15204. }
  15205. } else {
  15206. c.ServeSuccessJSON(map[string]interface{}{
  15207. "failed_code": -10,
  15208. "msg": res2.ErrMsg,
  15209. })
  15210. }
  15211. } else {
  15212. c.ServeSuccessJSON(map[string]interface{}{
  15213. "failed_code": -10,
  15214. "msg": res.ErrMsg,
  15215. })
  15216. }
  15217. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15218. var insuplc_admdvs string
  15219. if len(patient.InsuplcAdmdvs) > 0 {
  15220. insuplc_admdvs = patient.InsuplcAdmdvs
  15221. } else {
  15222. if len(insuplc_admdvs_str) > 0 {
  15223. insuplc_admdvs = insuplc_admdvs_str
  15224. } else {
  15225. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15226. }
  15227. }
  15228. //请求内网数据
  15229. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15230. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15231. "&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 + "&token=" + ""
  15232. resp, requestErr := http.Get(api)
  15233. if requestErr != nil {
  15234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15235. return
  15236. }
  15237. body, ioErr := ioutil.ReadAll(resp.Body)
  15238. if ioErr != nil {
  15239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15241. return
  15242. }
  15243. var respJSON map[string]interface{}
  15244. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15247. return
  15248. }
  15249. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15250. if status == "0" {
  15251. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15252. c.ServeSuccessJSON(map[string]interface{}{
  15253. "failed_code": -10,
  15254. "msg": err_msg,
  15255. })
  15256. return
  15257. }
  15258. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15259. var res ResultTwo
  15260. result, _ := json.Marshal(respJSON)
  15261. fmt.Println("log")
  15262. fmt.Println(string(result))
  15263. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15264. utils.ErrorLog("解析失败:%v", err)
  15265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15266. return
  15267. }
  15268. if res.Infcode == 0 {
  15269. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15270. if err == gorm.ErrRecordNotFound {
  15271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15272. return
  15273. } else if err != nil {
  15274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15275. return
  15276. } else {
  15277. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15278. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15279. infoStr := string(Iinfos)
  15280. idetinfoStr := string(Idetinfos)
  15281. psn := &models.HisPsn{
  15282. PsnNo: res.Output.Baseinfo.PsnNo,
  15283. PatientId: patient.ID,
  15284. Certno: res.Output.Baseinfo.Certno,
  15285. Gend: res.Output.Baseinfo.Gend,
  15286. Naty: res.Output.Baseinfo.Naty,
  15287. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15288. PsnName: res.Output.Baseinfo.PsnName,
  15289. Idetinfo: idetinfoStr,
  15290. Insuinfo: infoStr,
  15291. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15292. }
  15293. service.CreateHisPsn(psn)
  15294. var rf []*ResultFive
  15295. json.Unmarshal([]byte(infoStr), &rf)
  15296. var insutypes []*ResultFive
  15297. var is390 int = 0
  15298. var is310 int = 0
  15299. var insutype string
  15300. for _, item := range rf {
  15301. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15302. insutypes = append(insutypes, item)
  15303. }
  15304. }
  15305. if len(insutypes) == 1 {
  15306. insutype = insutypes[0].Insutype
  15307. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15308. } else {
  15309. for _, i := range insutypes {
  15310. if i.Insutype == "390" {
  15311. is390 = 1
  15312. }
  15313. if i.Insutype == "310" {
  15314. is310 = 1
  15315. }
  15316. }
  15317. }
  15318. if is390 == 1 {
  15319. insutype = "390"
  15320. }
  15321. if is310 == 1 {
  15322. insutype = "310"
  15323. }
  15324. if len(insutypes) == 0 {
  15325. insutype = "390"
  15326. }
  15327. c.ServeSuccessJSON(map[string]interface{}{
  15328. "patient": patient,
  15329. "insutype": insutype,
  15330. "number": res.Output.Baseinfo.Certno,
  15331. "info": res,
  15332. })
  15333. }
  15334. } else {
  15335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15336. return
  15337. }
  15338. } else {
  15339. SFZStr := c.GetSFZBaseInfo()
  15340. id_card_str := strings.Split(SFZStr, "^")
  15341. id_card_number := id_card_str[0]
  15342. card_sn := ""
  15343. 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)
  15344. var dat map[string]interface{}
  15345. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15346. fmt.Println(dat)
  15347. } else {
  15348. fmt.Println(err)
  15349. }
  15350. userJSONBytes, _ := json.Marshal(dat)
  15351. var res ResultTwo
  15352. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15353. utils.ErrorLog("解析失败:%v", err)
  15354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15355. return
  15356. }
  15357. if res.Infcode == 0 {
  15358. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15359. if err == gorm.ErrRecordNotFound {
  15360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15361. return
  15362. } else if err != nil {
  15363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15364. return
  15365. } else {
  15366. c.ServeSuccessJSON(map[string]interface{}{
  15367. "patient": patient,
  15368. "number": id_card_number,
  15369. })
  15370. }
  15371. } else {
  15372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15373. return
  15374. }
  15375. }
  15376. break
  15377. case 3:
  15378. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15379. var api string
  15380. if miConfig.MdtrtareaAdmvs == "320921" {
  15381. 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 +
  15382. "&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
  15383. fmt.Println(api)
  15384. } else {
  15385. 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 +
  15386. "&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)
  15387. }
  15388. resp, requestErr := http.Get(api)
  15389. if requestErr != nil {
  15390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15391. return
  15392. }
  15393. body, ioErr := ioutil.ReadAll(resp.Body)
  15394. if ioErr != nil {
  15395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15397. return
  15398. }
  15399. var respJSON map[string]interface{}
  15400. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15403. return
  15404. }
  15405. var status string
  15406. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15407. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15408. var token string
  15409. var res ResultTwo //1101结果
  15410. var res10265 ResultTwo10265 //1101结果
  15411. var card_info string //卡信息
  15412. var busi_card_info string
  15413. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15414. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15415. if status == "0" { //读卡成功
  15416. if card_type == "1" {
  15417. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15418. result, _ := json.Marshal(respJSON)
  15419. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15420. utils.ErrorLog("解析失败:%v", err)
  15421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15422. return
  15423. }
  15424. res.ErrMsg = res10265.ErrMsg
  15425. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15426. res.Infcode = infocode
  15427. res.Output = res10265.Output
  15428. res.InfRefmsgid = res10265.InfRefmsgid
  15429. } else {
  15430. //var card_info string //卡信息
  15431. //var busi_card_info string
  15432. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15433. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15434. //fmt.Println(card_info)
  15435. //fmt.Println(busi_card_info)
  15436. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15437. result, _ := json.Marshal(respJSON)
  15438. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15439. utils.ErrorLog("解析失败:%v", err)
  15440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15441. return
  15442. }
  15443. res.ErrMsg = res10265.ErrMsg
  15444. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15445. res.Infcode = infocode
  15446. res.Output = res10265.Output
  15447. res.InfRefmsgid = res10265.InfRefmsgid
  15448. }
  15449. if res.Infcode == 0 {
  15450. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15451. if err == gorm.ErrRecordNotFound {
  15452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15453. return
  15454. } else if err != nil {
  15455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15456. return
  15457. } else {
  15458. if card_type == "1" {
  15459. bas := strings.Split(card_info, "|")
  15460. basNumber := bas[2]
  15461. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15462. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15463. infoStr := string(Iinfos)
  15464. idetinfoStr := string(Idetinfos)
  15465. psn := &models.HisPsn{
  15466. PsnNo: res.Output.Baseinfo.PsnNo,
  15467. PatientId: patient.ID,
  15468. Certno: res.Output.Baseinfo.Certno,
  15469. //Brdy: res.Output.Baseinfo.Brdy,
  15470. Gend: res.Output.Baseinfo.Gend,
  15471. Naty: res.Output.Baseinfo.Naty,
  15472. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15473. PsnName: res.Output.Baseinfo.PsnName,
  15474. Idetinfo: idetinfoStr,
  15475. Insuinfo: infoStr,
  15476. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15477. CardInfo: card_info,
  15478. VerifyNumber: busi_card_info,
  15479. }
  15480. service.CreateHisPsn(psn)
  15481. c.ServeSuccessJSON(map[string]interface{}{
  15482. "patient": patient,
  15483. "number": basNumber,
  15484. })
  15485. } else {
  15486. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15487. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15488. infoStr := string(Iinfos)
  15489. idetinfoStr := string(Idetinfos)
  15490. psn := &models.HisPsn{
  15491. PsnNo: res.Output.Baseinfo.PsnNo,
  15492. PatientId: patient.ID,
  15493. Certno: res.Output.Baseinfo.Certno,
  15494. Gend: res.Output.Baseinfo.Gend,
  15495. Naty: res.Output.Baseinfo.Naty,
  15496. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15497. PsnName: res.Output.Baseinfo.PsnName,
  15498. Idetinfo: idetinfoStr,
  15499. Insuinfo: infoStr,
  15500. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15501. CardInfo: card_info,
  15502. VerifyNumber: token,
  15503. }
  15504. service.CreateHisPsn(psn)
  15505. var rf []*ResultFive
  15506. json.Unmarshal([]byte(infoStr), &rf)
  15507. var insutypes []*ResultFive
  15508. var insutype string
  15509. var is390 int = 0
  15510. var is310 int = 0
  15511. for _, item := range rf {
  15512. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15513. insutypes = append(insutypes, item)
  15514. }
  15515. }
  15516. if len(insutypes) == 1 {
  15517. insutype = insutypes[0].Insutype
  15518. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15519. } else {
  15520. for _, i := range insutypes {
  15521. if i.Insutype == "390" {
  15522. is390 = 1
  15523. }
  15524. if i.Insutype == "310" {
  15525. is310 = 1
  15526. }
  15527. }
  15528. }
  15529. if is390 == 1 {
  15530. insutype = "390"
  15531. }
  15532. if is310 == 1 {
  15533. insutype = "310"
  15534. }
  15535. if len(insutypes) == 0 {
  15536. insutype = "310"
  15537. }
  15538. c.ServeSuccessJSON(map[string]interface{}{
  15539. "patient": patient,
  15540. "number": token,
  15541. "insutype": insutype,
  15542. })
  15543. }
  15544. }
  15545. } else {
  15546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15547. return
  15548. }
  15549. } else { //读卡失败
  15550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15551. return
  15552. }
  15553. }
  15554. break
  15555. case 4:
  15556. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15557. var api string
  15558. if miConfig.MdtrtareaAdmvs == "320921" {
  15559. 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 +
  15560. "&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
  15561. fmt.Println(api)
  15562. } else {
  15563. 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 +
  15564. "&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)
  15565. }
  15566. resp, requestErr := http.Get(api)
  15567. if requestErr != nil {
  15568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15569. return
  15570. }
  15571. body, ioErr := ioutil.ReadAll(resp.Body)
  15572. if ioErr != nil {
  15573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15575. return
  15576. }
  15577. var respJSON map[string]interface{}
  15578. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15581. return
  15582. }
  15583. var status string
  15584. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15585. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15586. var token string
  15587. var res ResultTwo //1101结果
  15588. var res10265 ResultTwo10265 //1101结果
  15589. if status == "0" { //读卡成功
  15590. var card_info string //卡信息
  15591. var busi_card_info string
  15592. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15593. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15594. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15595. fmt.Println(card_info)
  15596. fmt.Println(busi_card_info)
  15597. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15598. result, _ := json.Marshal(respJSON)
  15599. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15600. utils.ErrorLog("解析失败:%v", err)
  15601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15602. return
  15603. }
  15604. res.ErrMsg = res10265.ErrMsg
  15605. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15606. res.Infcode = infocode
  15607. res.Output = res10265.Output
  15608. res.InfRefmsgid = res10265.InfRefmsgid
  15609. if res.Infcode == 0 {
  15610. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15611. if err == gorm.ErrRecordNotFound {
  15612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15613. return
  15614. } else if err != nil {
  15615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15616. return
  15617. } else {
  15618. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15619. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15620. infoStr := string(Iinfos)
  15621. idetinfoStr := string(Idetinfos)
  15622. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15623. psn := &models.HisPsn{
  15624. PsnNo: res.Output.Baseinfo.PsnNo,
  15625. PatientId: patient.ID,
  15626. Certno: res.Output.Baseinfo.Certno,
  15627. Brdy: b,
  15628. Age: float64(age),
  15629. //Brdy: res.Output.Baseinfo.Brdy,
  15630. Gend: res.Output.Baseinfo.Gend,
  15631. Naty: res.Output.Baseinfo.Naty,
  15632. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15633. PsnName: res.Output.Baseinfo.PsnName,
  15634. Idetinfo: idetinfoStr,
  15635. Insuinfo: infoStr,
  15636. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15637. CardInfo: card_info,
  15638. VerifyNumber: token,
  15639. }
  15640. var rf []*ResultFive
  15641. json.Unmarshal([]byte(infoStr), &rf)
  15642. var insutypes []*ResultFive
  15643. var insutype string
  15644. var is390 int = 0
  15645. var is310 int = 0
  15646. for _, item := range rf {
  15647. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15648. insutypes = append(insutypes, item)
  15649. }
  15650. }
  15651. if len(insutypes) == 1 {
  15652. insutype = insutypes[0].Insutype
  15653. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15654. } else {
  15655. for _, i := range insutypes {
  15656. if i.Insutype == "390" {
  15657. is390 = 1
  15658. }
  15659. if i.Insutype == "310" {
  15660. is310 = 1
  15661. }
  15662. }
  15663. }
  15664. if is390 == 1 {
  15665. insutype = "390"
  15666. }
  15667. if is310 == 1 {
  15668. insutype = "310"
  15669. }
  15670. if len(insutypes) == 0 {
  15671. insutype = "310"
  15672. }
  15673. service.CreateHisPsn(psn)
  15674. c.ServeSuccessJSON(map[string]interface{}{
  15675. "patient": patient,
  15676. "number": token,
  15677. "insutype": insutype,
  15678. })
  15679. }
  15680. } else {
  15681. c.ServeSuccessJSON(map[string]interface{}{
  15682. "failed_code": -10,
  15683. "msg": res.ErrMsg,
  15684. })
  15685. }
  15686. } else { //读卡失败
  15687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15688. return
  15689. }
  15690. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15691. var api string
  15692. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15693. "&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
  15694. resp, requestErr := http.Get(api)
  15695. if requestErr != nil {
  15696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15697. return
  15698. }
  15699. body, ioErr := ioutil.ReadAll(resp.Body)
  15700. if ioErr != nil {
  15701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15703. return
  15704. }
  15705. var respJSON map[string]interface{}
  15706. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15709. return
  15710. }
  15711. var status string
  15712. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15713. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15714. var token string
  15715. var res ResultTwo //1101结果
  15716. if status == "1" { //读卡成功
  15717. var card_info string //卡信息
  15718. var busi_card_info string
  15719. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15720. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15721. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15722. fmt.Println(card_info)
  15723. fmt.Println(busi_card_info)
  15724. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15725. result, _ := json.Marshal(respJSON)
  15726. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15727. utils.ErrorLog("解析失败:%v", err)
  15728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15729. return
  15730. }
  15731. if res.Infcode == 0 {
  15732. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15733. if err == gorm.ErrRecordNotFound {
  15734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15735. return
  15736. } else if err != nil {
  15737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15738. return
  15739. } else {
  15740. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15741. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15742. infoStr := string(Iinfos)
  15743. idetinfoStr := string(Idetinfos)
  15744. psn := &models.HisPsn{
  15745. PsnNo: res.Output.Baseinfo.PsnNo,
  15746. PatientId: patient.ID,
  15747. Certno: res.Output.Baseinfo.Certno,
  15748. Gend: res.Output.Baseinfo.Gend,
  15749. Naty: res.Output.Baseinfo.Naty,
  15750. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15751. PsnName: res.Output.Baseinfo.PsnName,
  15752. Idetinfo: idetinfoStr,
  15753. Insuinfo: infoStr,
  15754. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15755. CardInfo: card_info,
  15756. VerifyNumber: token,
  15757. }
  15758. var rf []*ResultFive
  15759. json.Unmarshal([]byte(infoStr), &rf)
  15760. var insutypes []*ResultFive
  15761. var insutype string
  15762. var is390 int = 0
  15763. var is310 int = 0
  15764. for _, item := range rf {
  15765. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15766. insutypes = append(insutypes, item)
  15767. }
  15768. }
  15769. if len(insutypes) == 1 {
  15770. insutype = insutypes[0].Insutype
  15771. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15772. } else {
  15773. for _, i := range insutypes {
  15774. if i.Insutype == "390" {
  15775. is390 = 1
  15776. }
  15777. if i.Insutype == "310" {
  15778. is310 = 1
  15779. }
  15780. }
  15781. }
  15782. if is390 == 1 {
  15783. insutype = "390"
  15784. }
  15785. if is310 == 1 {
  15786. insutype = "310"
  15787. }
  15788. if len(insutypes) == 0 {
  15789. insutype = "310"
  15790. }
  15791. service.CreateHisPsn(psn)
  15792. c.ServeSuccessJSON(map[string]interface{}{
  15793. "patient": patient,
  15794. "number": token,
  15795. "insutype": insutype,
  15796. })
  15797. }
  15798. } else {
  15799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15800. return
  15801. }
  15802. } else { //读卡失败
  15803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15804. return
  15805. }
  15806. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15807. var api string
  15808. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15809. "&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
  15810. resp, requestErr := http.Get(api)
  15811. if requestErr != nil {
  15812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15813. return
  15814. }
  15815. body, ioErr := ioutil.ReadAll(resp.Body)
  15816. if ioErr != nil {
  15817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15819. return
  15820. }
  15821. var respJSON map[string]interface{}
  15822. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15825. return
  15826. }
  15827. var status string
  15828. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15829. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15830. var token string
  15831. var res ResultTwo //1101结果
  15832. if status == "1" { //读卡成功
  15833. var card_info string //卡信息
  15834. var busi_card_info string
  15835. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15836. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15837. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15838. fmt.Println(card_info)
  15839. fmt.Println(busi_card_info)
  15840. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15841. result, _ := json.Marshal(respJSON)
  15842. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15843. utils.ErrorLog("解析失败:%v", err)
  15844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15845. return
  15846. }
  15847. if res.Infcode == 0 {
  15848. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15849. if err == gorm.ErrRecordNotFound {
  15850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15851. return
  15852. } else if err != nil {
  15853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15854. return
  15855. } else {
  15856. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15857. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15858. infoStr := string(Iinfos)
  15859. idetinfoStr := string(Idetinfos)
  15860. psn := &models.HisPsn{
  15861. PsnNo: res.Output.Baseinfo.PsnNo,
  15862. PatientId: patient.ID,
  15863. Certno: res.Output.Baseinfo.Certno,
  15864. Gend: res.Output.Baseinfo.Gend,
  15865. Naty: res.Output.Baseinfo.Naty,
  15866. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15867. PsnName: res.Output.Baseinfo.PsnName,
  15868. Idetinfo: idetinfoStr,
  15869. Insuinfo: infoStr,
  15870. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15871. CardInfo: card_info,
  15872. VerifyNumber: token,
  15873. }
  15874. var rf []*ResultFive
  15875. json.Unmarshal([]byte(infoStr), &rf)
  15876. var insutypes []*ResultFive
  15877. var insutype string
  15878. var is390 int = 0
  15879. var is310 int = 0
  15880. for _, item := range rf {
  15881. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15882. insutypes = append(insutypes, item)
  15883. }
  15884. }
  15885. if len(insutypes) == 1 {
  15886. insutype = insutypes[0].Insutype
  15887. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15888. } else {
  15889. for _, i := range insutypes {
  15890. if i.Insutype == "390" {
  15891. is390 = 1
  15892. }
  15893. if i.Insutype == "310" {
  15894. is310 = 1
  15895. }
  15896. }
  15897. }
  15898. if is390 == 1 {
  15899. insutype = "390"
  15900. }
  15901. if is310 == 1 {
  15902. insutype = "310"
  15903. }
  15904. if len(insutypes) == 0 {
  15905. insutype = "310"
  15906. }
  15907. service.CreateHisPsn(psn)
  15908. c.ServeSuccessJSON(map[string]interface{}{
  15909. "patient": patient,
  15910. "number": token,
  15911. "insutype": insutype,
  15912. })
  15913. }
  15914. } else {
  15915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15916. return
  15917. }
  15918. } else { //读卡失败
  15919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15920. return
  15921. }
  15922. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15923. //idNo := c.GetString("idNo")
  15924. //userName := c.GetString("userName")
  15925. //ecToken := c.GetString("ecToken")
  15926. //insuOrg := c.GetString("insuOrg")
  15927. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15928. utils.ErrorLog("解析失败:%v", json_result)
  15929. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15930. type ELeData struct {
  15931. Data struct {
  15932. IdNo string `json:"idNo"`
  15933. IdType string `json:"idType"`
  15934. UserName string `json:"userName"`
  15935. EcToken string `json:"ecToken"`
  15936. InsuOrg string `json:"insuOrg"`
  15937. Gender string `json:"gender"`
  15938. Birthday string `json:"birthday"`
  15939. Nationality string `json:"nationality"`
  15940. Email string `json:"email"`
  15941. Extra string `json:"extra"`
  15942. } `json:"data"`
  15943. Code int `json:"code"`
  15944. Message string `json:"message"`
  15945. }
  15946. var ele ELeData
  15947. err := json.Unmarshal([]byte(json_result), &ele)
  15948. if err != nil {
  15949. utils.ErrorLog("解析失败:%v", err)
  15950. }
  15951. token := ele.Data.EcToken
  15952. token = Remove0000(token)
  15953. 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)
  15954. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15955. var res ResultTwo
  15956. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15957. utils.ErrorLog("解析失败:%v", err)
  15958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15959. return
  15960. }
  15961. if res.Infcode == 0 {
  15962. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15963. if err == gorm.ErrRecordNotFound {
  15964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15965. return
  15966. } else if err != nil {
  15967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15968. return
  15969. } else {
  15970. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15971. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15972. infoStr := string(Iinfos)
  15973. idetinfoStr := string(Idetinfos)
  15974. psn := &models.HisPsn{
  15975. PsnNo: res.Output.Baseinfo.PsnNo,
  15976. PatientId: patient.ID,
  15977. Certno: res.Output.Baseinfo.Certno,
  15978. Gend: res.Output.Baseinfo.Gend,
  15979. Naty: res.Output.Baseinfo.Naty,
  15980. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15981. PsnName: res.Output.Baseinfo.PsnName,
  15982. Idetinfo: idetinfoStr,
  15983. Insuinfo: infoStr,
  15984. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15985. CardInfo: "",
  15986. Stage: "1",
  15987. VerifyNumber: token,
  15988. InsuplcAdmdvs: ele.Data.InsuOrg,
  15989. }
  15990. service.CreateHisPsn(psn)
  15991. var rf []*ResultFive
  15992. json.Unmarshal([]byte(infoStr), &rf)
  15993. var insutypes []*ResultFive
  15994. var insutype string
  15995. var is390 int = 0
  15996. var is310 int = 0
  15997. for _, item := range rf {
  15998. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15999. insutypes = append(insutypes, item)
  16000. }
  16001. }
  16002. if len(insutypes) == 1 {
  16003. insutype = insutypes[0].Insutype
  16004. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16005. } else {
  16006. for _, i := range insutypes {
  16007. if i.Insutype == "390" {
  16008. is390 = 1
  16009. }
  16010. if i.Insutype == "310" {
  16011. is310 = 1
  16012. }
  16013. }
  16014. }
  16015. if is390 == 1 {
  16016. insutype = "390"
  16017. }
  16018. if is310 == 1 {
  16019. insutype = "310"
  16020. }
  16021. if len(insutypes) == 0 {
  16022. insutype = "310"
  16023. }
  16024. c.ServeSuccessJSON(map[string]interface{}{
  16025. "patient": patient,
  16026. "number": token,
  16027. "insutype": insutype,
  16028. })
  16029. }
  16030. } else {
  16031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16032. return
  16033. }
  16034. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16035. //if initFlag == 0 {
  16036. //c.TestGetJiangXiBasBaseInit()
  16037. //}
  16038. //if initEleFlag == 0 {
  16039. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16040. //}
  16041. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16042. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16043. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16044. type ELeData struct {
  16045. Data struct {
  16046. IdNo string `json:"idNo"`
  16047. IdType string `json:"idType"`
  16048. UserName string `json:"userName"`
  16049. EcToken string `json:"ecToken"`
  16050. InsuOrg string `json:"insuOrg"`
  16051. Gender string `json:"gender"`
  16052. Birthday string `json:"birthday"`
  16053. Nationality string `json:"nationality"`
  16054. Email string `json:"email"`
  16055. Extra string `json:"extra"`
  16056. } `json:"data"`
  16057. Code int `json:"code"`
  16058. Message string `json:"message"`
  16059. }
  16060. var ele ELeData
  16061. err := json.Unmarshal([]byte(result), &ele)
  16062. if err != nil {
  16063. utils.ErrorLog("解析失败:%v", err)
  16064. }
  16065. token := ele.Data.EcToken
  16066. token = Remove0000(token)
  16067. 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)
  16068. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16069. var res ResultTwo
  16070. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16071. utils.ErrorLog("解析失败:%v", err)
  16072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16073. return
  16074. }
  16075. if res.Infcode == 0 {
  16076. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16077. if err == gorm.ErrRecordNotFound {
  16078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16079. return
  16080. } else if err != nil {
  16081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16082. return
  16083. } else {
  16084. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16085. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16086. infoStr := string(Iinfos)
  16087. idetinfoStr := string(Idetinfos)
  16088. psn := &models.HisPsn{
  16089. PsnNo: res.Output.Baseinfo.PsnNo,
  16090. PatientId: patient.ID,
  16091. Certno: res.Output.Baseinfo.Certno,
  16092. Gend: res.Output.Baseinfo.Gend,
  16093. Naty: res.Output.Baseinfo.Naty,
  16094. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16095. PsnName: res.Output.Baseinfo.PsnName,
  16096. Idetinfo: idetinfoStr,
  16097. Insuinfo: infoStr,
  16098. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16099. CardInfo: "",
  16100. VerifyNumber: token,
  16101. InsuplcAdmdvs: ele.Data.InsuOrg,
  16102. }
  16103. service.CreateHisPsn(psn)
  16104. var rf []*ResultFive
  16105. json.Unmarshal([]byte(infoStr), &rf)
  16106. var insutypes []*ResultFive
  16107. var insutype string
  16108. var is390 int = 0
  16109. var is310 int = 0
  16110. for _, item := range rf {
  16111. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16112. insutypes = append(insutypes, item)
  16113. }
  16114. }
  16115. if len(insutypes) == 1 {
  16116. insutype = insutypes[0].Insutype
  16117. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16118. } else {
  16119. for _, i := range insutypes {
  16120. if i.Insutype == "390" {
  16121. is390 = 1
  16122. }
  16123. if i.Insutype == "310" {
  16124. is310 = 1
  16125. }
  16126. }
  16127. }
  16128. if is390 == 1 {
  16129. insutype = "390"
  16130. }
  16131. if is310 == 1 {
  16132. insutype = "310"
  16133. }
  16134. if len(insutypes) == 0 {
  16135. insutype = "310"
  16136. }
  16137. c.ServeSuccessJSON(map[string]interface{}{
  16138. "patient": patient,
  16139. "number": token,
  16140. "insutype": insutype,
  16141. })
  16142. }
  16143. } else {
  16144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16145. return
  16146. }
  16147. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16148. //if initFlag == 0 {
  16149. //c.TestGetJiangXiBasBaseInit()
  16150. //}
  16151. //if initEleFlag == 0 {
  16152. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16153. //}
  16154. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16155. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16156. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16157. type ELeData struct {
  16158. Data struct {
  16159. IdNo string `json:"idNo"`
  16160. IdType string `json:"idType"`
  16161. UserName string `json:"userName"`
  16162. EcToken string `json:"ecToken"`
  16163. InsuOrg string `json:"insuOrg"`
  16164. Gender string `json:"gender"`
  16165. Birthday string `json:"birthday"`
  16166. Nationality string `json:"nationality"`
  16167. Email string `json:"email"`
  16168. Extra string `json:"extra"`
  16169. } `json:"data"`
  16170. Code int `json:"code"`
  16171. Message string `json:"message"`
  16172. }
  16173. var ele ELeData
  16174. err := json.Unmarshal([]byte(result), &ele)
  16175. if err != nil {
  16176. utils.ErrorLog("解析失败:%v", err)
  16177. }
  16178. token := ele.Data.EcToken
  16179. token = Remove0000(token)
  16180. 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)
  16181. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16182. var res ResultTwo
  16183. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16184. utils.ErrorLog("解析失败:%v", err)
  16185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16186. return
  16187. }
  16188. if res.Infcode == 0 {
  16189. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16190. if err == gorm.ErrRecordNotFound {
  16191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16192. return
  16193. } else if err != nil {
  16194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16195. return
  16196. } else {
  16197. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16198. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16199. infoStr := string(Iinfos)
  16200. idetinfoStr := string(Idetinfos)
  16201. psn := &models.HisPsn{
  16202. PsnNo: res.Output.Baseinfo.PsnNo,
  16203. PatientId: patient.ID,
  16204. Certno: res.Output.Baseinfo.Certno,
  16205. Gend: res.Output.Baseinfo.Gend,
  16206. Naty: res.Output.Baseinfo.Naty,
  16207. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16208. PsnName: res.Output.Baseinfo.PsnName,
  16209. Idetinfo: idetinfoStr,
  16210. Insuinfo: infoStr,
  16211. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16212. CardInfo: "",
  16213. VerifyNumber: token,
  16214. InsuplcAdmdvs: ele.Data.InsuOrg,
  16215. }
  16216. service.CreateHisPsn(psn)
  16217. var rf []*ResultFive
  16218. json.Unmarshal([]byte(infoStr), &rf)
  16219. var insutypes []*ResultFive
  16220. var insutype string
  16221. var is390 int = 0
  16222. var is310 int = 0
  16223. for _, item := range rf {
  16224. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16225. insutypes = append(insutypes, item)
  16226. }
  16227. }
  16228. if len(insutypes) == 1 {
  16229. insutype = insutypes[0].Insutype
  16230. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16231. } else {
  16232. for _, i := range insutypes {
  16233. if i.Insutype == "390" {
  16234. is390 = 1
  16235. }
  16236. if i.Insutype == "310" {
  16237. is310 = 1
  16238. }
  16239. }
  16240. }
  16241. if is390 == 1 {
  16242. insutype = "390"
  16243. }
  16244. if is310 == 1 {
  16245. insutype = "310"
  16246. }
  16247. if len(insutypes) == 0 {
  16248. insutype = "310"
  16249. }
  16250. c.ServeSuccessJSON(map[string]interface{}{
  16251. "patient": patient,
  16252. "number": token,
  16253. "insutype": insutype,
  16254. })
  16255. }
  16256. } else {
  16257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16258. return
  16259. }
  16260. } else if miConfig.MdtrtareaAdmvs == "360100" {
  16261. //if initFlag == 0 {
  16262. //c.TestGetJiangXiBasBaseInit()
  16263. //}
  16264. //if initEleFlag == 0 {
  16265. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16266. //}
  16267. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16268. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16269. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16270. type ELeData struct {
  16271. Data struct {
  16272. IdNo string `json:"idNo"`
  16273. IdType string `json:"idType"`
  16274. UserName string `json:"userName"`
  16275. EcToken string `json:"ecToken"`
  16276. InsuOrg string `json:"insuOrg"`
  16277. Gender string `json:"gender"`
  16278. Birthday string `json:"birthday"`
  16279. Nationality string `json:"nationality"`
  16280. Email string `json:"email"`
  16281. Extra string `json:"extra"`
  16282. } `json:"data"`
  16283. Code int `json:"code"`
  16284. Message string `json:"message"`
  16285. }
  16286. var ele ELeData
  16287. err := json.Unmarshal([]byte(result), &ele)
  16288. if err != nil {
  16289. utils.ErrorLog("解析失败:%v", err)
  16290. }
  16291. token := ele.Data.EcToken
  16292. token = Remove0000(token)
  16293. 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)
  16294. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16295. var res ResultTwo
  16296. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16297. utils.ErrorLog("解析失败:%v", err)
  16298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16299. return
  16300. }
  16301. if res.Infcode == 0 {
  16302. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16303. if err == gorm.ErrRecordNotFound {
  16304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16305. return
  16306. } else if err != nil {
  16307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16308. return
  16309. } else {
  16310. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16311. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16312. infoStr := string(Iinfos)
  16313. idetinfoStr := string(Idetinfos)
  16314. psn := &models.HisPsn{
  16315. PsnNo: res.Output.Baseinfo.PsnNo,
  16316. PatientId: patient.ID,
  16317. Certno: res.Output.Baseinfo.Certno,
  16318. Gend: res.Output.Baseinfo.Gend,
  16319. Naty: res.Output.Baseinfo.Naty,
  16320. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16321. PsnName: res.Output.Baseinfo.PsnName,
  16322. Idetinfo: idetinfoStr,
  16323. Insuinfo: infoStr,
  16324. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16325. CardInfo: "",
  16326. VerifyNumber: token,
  16327. InsuplcAdmdvs: ele.Data.InsuOrg,
  16328. }
  16329. service.CreateHisPsn(psn)
  16330. var rf []*ResultFive
  16331. json.Unmarshal([]byte(infoStr), &rf)
  16332. var insutypes []*ResultFive
  16333. var insutype string
  16334. var is390 int = 0
  16335. var is310 int = 0
  16336. for _, item := range rf {
  16337. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16338. insutypes = append(insutypes, item)
  16339. }
  16340. }
  16341. if len(insutypes) == 1 {
  16342. insutype = insutypes[0].Insutype
  16343. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16344. } else {
  16345. for _, i := range insutypes {
  16346. if i.Insutype == "390" {
  16347. is390 = 1
  16348. }
  16349. if i.Insutype == "310" {
  16350. is310 = 1
  16351. }
  16352. }
  16353. }
  16354. if is390 == 1 {
  16355. insutype = "390"
  16356. }
  16357. if is310 == 1 {
  16358. insutype = "310"
  16359. }
  16360. if len(insutypes) == 0 {
  16361. insutype = "310"
  16362. }
  16363. c.ServeSuccessJSON(map[string]interface{}{
  16364. "patient": patient,
  16365. "number": token,
  16366. "insutype": insutype,
  16367. })
  16368. }
  16369. } else {
  16370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16371. return
  16372. }
  16373. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16374. //if initFlag == 0 {
  16375. c.TestGetJiangXiBasBaseInit()
  16376. //}
  16377. //if initEleFlag == 0 {
  16378. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16379. //}
  16380. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16381. type ELeData struct {
  16382. Data struct {
  16383. IdNo string `json:"idNo"`
  16384. IdType string `json:"idType"`
  16385. UserName string `json:"userName"`
  16386. EcToken string `json:"ecToken"`
  16387. InsuOrg string `json:"insuOrg"`
  16388. Gender string `json:"gender"`
  16389. Birthday string `json:"birthday"`
  16390. Nationality string `json:"nationality"`
  16391. Email string `json:"email"`
  16392. Extra string `json:"extra"`
  16393. } `json:"data"`
  16394. Code int `json:"code"`
  16395. Message string `json:"message"`
  16396. }
  16397. var ele ELeData
  16398. err := json.Unmarshal([]byte(json_result), &ele)
  16399. if err != nil {
  16400. utils.ErrorLog("解析失败:%v", err)
  16401. }
  16402. token := ele.Data.EcToken
  16403. token = Remove0000(token)
  16404. 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)
  16405. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16406. var res ResultTwo
  16407. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16408. utils.ErrorLog("解析失败:%v", err)
  16409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16410. return
  16411. }
  16412. if res.Infcode == 0 {
  16413. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16414. if err == gorm.ErrRecordNotFound {
  16415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16416. return
  16417. } else if err != nil {
  16418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16419. return
  16420. } else {
  16421. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16422. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16423. infoStr := string(Iinfos)
  16424. idetinfoStr := string(Idetinfos)
  16425. psn := &models.HisPsn{
  16426. PsnNo: res.Output.Baseinfo.PsnNo,
  16427. PatientId: patient.ID,
  16428. Certno: res.Output.Baseinfo.Certno,
  16429. Gend: res.Output.Baseinfo.Gend,
  16430. Naty: res.Output.Baseinfo.Naty,
  16431. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16432. PsnName: res.Output.Baseinfo.PsnName,
  16433. Idetinfo: idetinfoStr,
  16434. Insuinfo: infoStr,
  16435. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16436. CardInfo: "",
  16437. VerifyNumber: token,
  16438. }
  16439. service.CreateHisPsn(psn)
  16440. var rf []*ResultFive
  16441. json.Unmarshal([]byte(infoStr), &rf)
  16442. var insutypes []*ResultFive
  16443. var insutype string
  16444. var is390 int = 0
  16445. var is310 int = 0
  16446. for _, item := range rf {
  16447. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16448. insutypes = append(insutypes, item)
  16449. }
  16450. }
  16451. if len(insutypes) == 1 {
  16452. insutype = insutypes[0].Insutype
  16453. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16454. } else {
  16455. for _, i := range insutypes {
  16456. if i.Insutype == "390" {
  16457. is390 = 1
  16458. }
  16459. if i.Insutype == "310" {
  16460. is310 = 1
  16461. }
  16462. }
  16463. }
  16464. if is390 == 1 {
  16465. insutype = "390"
  16466. }
  16467. if is310 == 1 {
  16468. insutype = "310"
  16469. }
  16470. if len(insutypes) == 0 {
  16471. insutype = "310"
  16472. }
  16473. c.ServeSuccessJSON(map[string]interface{}{
  16474. "patient": patient,
  16475. "number": token,
  16476. "insutype": insutype,
  16477. })
  16478. }
  16479. } else {
  16480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16481. return
  16482. }
  16483. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16484. type ELeData struct {
  16485. Code string `json:"code"`
  16486. Data struct {
  16487. Aac002 string `json:"aac002"`
  16488. Aaz500 string `json:"aaz500"`
  16489. ActCardNo string `json:"actCardNo"`
  16490. Bab520 string `json:"bab520"`
  16491. Bkz543 string `json:"bkz543"`
  16492. BusinessType string `json:"businessType"`
  16493. CertfCodg string `json:"certfCodg"`
  16494. EcIndexNo string `json:"ecIndexNo"`
  16495. EcToken string `json:"ecToken"`
  16496. ID0000 string `json:"id0000"`
  16497. IDNo string `json:"idNo"`
  16498. IDType string `json:"idType"`
  16499. Idcode string `json:"idcode"`
  16500. IdentityToken string `json:"identity_token"`
  16501. InsuOrg string `json:"insuOrg"`
  16502. OfficeID string `json:"officeId"`
  16503. OfficeName string `json:"officeName"`
  16504. OperatorID string `json:"operatorId"`
  16505. OperatorName string `json:"operatorName"`
  16506. OrgID string `json:"orgId"`
  16507. UserName string `json:"userName"`
  16508. } `json:"data"`
  16509. Infno interface{} `json:"infno"`
  16510. Message string `json:"message"`
  16511. OrgID string `json:"orgId"`
  16512. TransType string `json:"transType"`
  16513. }
  16514. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16515. outPutInfo = Remove0000(outPutInfo)
  16516. if len(outPutInfo) > 0 {
  16517. var ele ELeData
  16518. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16519. if err != nil {
  16520. utils.ErrorLog("解析失败:%v", err)
  16521. }
  16522. token := ele.Data.EcToken
  16523. fmt.Println(inputInfo)
  16524. fmt.Println(outPutInfo)
  16525. 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)
  16526. saveLog(result, requestLog, "1101", "获取人员信息")
  16527. var dat map[string]interface{}
  16528. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16529. fmt.Println(dat)
  16530. } else {
  16531. fmt.Println(err)
  16532. }
  16533. userJSONBytes, _ := json.Marshal(dat)
  16534. var res ResultTwo
  16535. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16536. utils.ErrorLog("解析失败:%v", err)
  16537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16538. return
  16539. }
  16540. res.ErrMsg = errMsgLog
  16541. if res.Infcode == 0 {
  16542. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16543. if err == gorm.ErrRecordNotFound {
  16544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16545. return
  16546. } else if err != nil {
  16547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16548. return
  16549. } else {
  16550. fmt.Println(res)
  16551. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16552. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16553. infoStr := string(Iinfos)
  16554. idetinfoStr := string(Idetinfos)
  16555. psn := &models.HisPsn{
  16556. PsnNo: res.Output.Baseinfo.PsnNo,
  16557. PatientId: patient.ID,
  16558. Certno: res.Output.Baseinfo.Certno,
  16559. Gend: res.Output.Baseinfo.Gend,
  16560. Naty: res.Output.Baseinfo.Naty,
  16561. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16562. PsnName: res.Output.Baseinfo.PsnName,
  16563. Idetinfo: idetinfoStr,
  16564. Insuinfo: infoStr,
  16565. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16566. CardInfo: outPutInfo,
  16567. VerifyNumber: token,
  16568. InsuplcAdmdvs: ele.Data.InsuOrg,
  16569. }
  16570. service.CreateHisPsn(psn)
  16571. var rf []*ResultFive
  16572. json.Unmarshal([]byte(infoStr), &rf)
  16573. var insutypes []*ResultFive
  16574. var insutype string
  16575. var is390 int = 0
  16576. var is310 int = 0
  16577. for _, item := range rf {
  16578. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16579. insutypes = append(insutypes, item)
  16580. }
  16581. }
  16582. if len(insutypes) == 1 {
  16583. insutype = insutypes[0].Insutype
  16584. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16585. } else {
  16586. for _, i := range insutypes {
  16587. if i.Insutype == "390" {
  16588. is390 = 1
  16589. }
  16590. if i.Insutype == "310" {
  16591. is310 = 1
  16592. }
  16593. }
  16594. }
  16595. if is390 == 1 {
  16596. insutype = "390"
  16597. }
  16598. if is310 == 1 {
  16599. insutype = "310"
  16600. }
  16601. if len(insutypes) == 0 {
  16602. insutype = "310"
  16603. }
  16604. c.ServeSuccessJSON(map[string]interface{}{
  16605. "patient": patient,
  16606. "number": token,
  16607. "insutype": insutype,
  16608. })
  16609. }
  16610. } else {
  16611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16612. return
  16613. }
  16614. }
  16615. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16616. var api string
  16617. 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 +
  16618. "&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
  16619. resp, requestErr := http.Get(api)
  16620. if requestErr != nil {
  16621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16622. return
  16623. }
  16624. body, ioErr := ioutil.ReadAll(resp.Body)
  16625. if ioErr != nil {
  16626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16628. return
  16629. }
  16630. var respJSON map[string]interface{}
  16631. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16634. return
  16635. }
  16636. var status string
  16637. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16638. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16639. var token string
  16640. var res ResultTwo //1101结果
  16641. var res10265 ResultTwo10265 //1101结果
  16642. if status == "0" { //读卡成功
  16643. var card_info string //卡信息
  16644. var busi_card_info string
  16645. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16646. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16647. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16648. fmt.Println(card_info)
  16649. fmt.Println(busi_card_info)
  16650. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16651. result, _ := json.Marshal(respJSON)
  16652. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16653. utils.ErrorLog("解析失败:%v", err)
  16654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16655. return
  16656. }
  16657. res.ErrMsg = res10265.ErrMsg
  16658. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16659. res.Infcode = infocode
  16660. res.Output = res10265.Output
  16661. res.InfRefmsgid = res10265.InfRefmsgid
  16662. if res.Infcode == 0 {
  16663. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16664. if err == gorm.ErrRecordNotFound {
  16665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16666. return
  16667. } else if err != nil {
  16668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16669. return
  16670. } else {
  16671. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16672. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16673. infoStr := string(Iinfos)
  16674. idetinfoStr := string(Idetinfos)
  16675. psn := &models.HisPsn{
  16676. PsnNo: res.Output.Baseinfo.PsnNo,
  16677. PatientId: patient.ID,
  16678. Certno: res.Output.Baseinfo.Certno,
  16679. Gend: res.Output.Baseinfo.Gend,
  16680. Naty: res.Output.Baseinfo.Naty,
  16681. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16682. PsnName: res.Output.Baseinfo.PsnName,
  16683. Idetinfo: idetinfoStr,
  16684. Insuinfo: infoStr,
  16685. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16686. CardInfo: card_info,
  16687. VerifyNumber: token,
  16688. }
  16689. var rf []*ResultFive
  16690. json.Unmarshal([]byte(infoStr), &rf)
  16691. var insutypes []*ResultFive
  16692. var insutype string
  16693. var is390 int = 0
  16694. var is310 int = 0
  16695. for _, item := range rf {
  16696. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16697. insutypes = append(insutypes, item)
  16698. }
  16699. }
  16700. if len(insutypes) == 1 {
  16701. insutype = insutypes[0].Insutype
  16702. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16703. } else {
  16704. for _, i := range insutypes {
  16705. if i.Insutype == "390" {
  16706. is390 = 1
  16707. }
  16708. if i.Insutype == "310" {
  16709. is310 = 1
  16710. }
  16711. }
  16712. }
  16713. if is390 == 1 {
  16714. insutype = "390"
  16715. }
  16716. if is310 == 1 {
  16717. insutype = "310"
  16718. }
  16719. if len(insutypes) == 0 {
  16720. insutype = "310"
  16721. }
  16722. service.CreateHisPsn(psn)
  16723. c.ServeSuccessJSON(map[string]interface{}{
  16724. "patient": patient,
  16725. "number": token,
  16726. "insutype": insutype,
  16727. })
  16728. }
  16729. } else {
  16730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16731. return
  16732. }
  16733. } else { //读卡失败
  16734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16735. return
  16736. }
  16737. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16738. res := c.GetoleInfo()
  16739. if res.Infcode == 0 {
  16740. var result string
  16741. if res.Output.MdtrtCertType == "01" {
  16742. 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)
  16743. } else if res.Output.MdtrtCertType == "02" {
  16744. 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)
  16745. } else if res.Output.MdtrtCertType == "03" {
  16746. 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)
  16747. }
  16748. var dat map[string]interface{}
  16749. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16750. fmt.Println(dat)
  16751. } else {
  16752. fmt.Println(err)
  16753. }
  16754. userJSONBytes, _ := json.Marshal(dat)
  16755. var res2 ResultTwo
  16756. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16757. utils.ErrorLog("解析失败:%v", err)
  16758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16759. return
  16760. }
  16761. if res2.Infcode == 0 {
  16762. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16763. if err == gorm.ErrRecordNotFound {
  16764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16765. return
  16766. } else if err != nil {
  16767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16768. return
  16769. } else {
  16770. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16771. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16772. infoStr := string(Iinfos)
  16773. idetinfoStr := string(Idetinfos)
  16774. var rf []*ResultFive
  16775. json.Unmarshal([]byte(infoStr), &rf)
  16776. var insutypes []*ResultFive
  16777. var insutype string
  16778. var is390 int = 0
  16779. var is310 int = 0
  16780. //var insuplc_admdvs string
  16781. for _, item := range rf {
  16782. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16783. insutypes = append(insutypes, item)
  16784. }
  16785. }
  16786. if len(insutypes) == 1 {
  16787. insutype = insutypes[0].Insutype
  16788. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16789. } else {
  16790. for _, i := range insutypes {
  16791. if i.Insutype == "390" {
  16792. is390 = 1
  16793. }
  16794. if i.Insutype == "310" {
  16795. is310 = 1
  16796. }
  16797. }
  16798. }
  16799. if is390 == 1 {
  16800. insutype = "390"
  16801. }
  16802. if is310 == 1 {
  16803. insutype = "310"
  16804. }
  16805. if len(insutypes) == 0 {
  16806. insutype = "310"
  16807. }
  16808. psn := &models.HisPsn{
  16809. PsnNo: res2.Output.Baseinfo.PsnNo,
  16810. PatientId: patient.ID,
  16811. Certno: res2.Output.Baseinfo.Certno,
  16812. Gend: res2.Output.Baseinfo.Gend,
  16813. Naty: res2.Output.Baseinfo.Naty,
  16814. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16815. PsnName: res2.Output.Baseinfo.PsnName,
  16816. Idetinfo: idetinfoStr,
  16817. Insuinfo: infoStr,
  16818. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16819. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16820. VerifyNumber: res.Output.EcToken,
  16821. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16822. }
  16823. if res.Output.MdtrtCertType == "01" {
  16824. psn.VerifyNumber = res.Output.EcToken
  16825. //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)
  16826. } else if res.Output.MdtrtCertType == "02" {
  16827. psn.VerifyNumber = res.Output.CardNo
  16828. //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)
  16829. } else if res.Output.MdtrtCertType == "03" {
  16830. psn.VerifyNumber = res.Output.MdtrtCertNo
  16831. //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)
  16832. }
  16833. service.CreateHisPsn(psn)
  16834. var balc float64
  16835. for _, item := range rf {
  16836. if item.Insutype == insutype {
  16837. balc = item.Balc
  16838. }
  16839. }
  16840. c.ServeSuccessJSON(map[string]interface{}{
  16841. "patient": patient,
  16842. "number": res.Output.CardNo,
  16843. "insutype": insutype,
  16844. "blac": balc,
  16845. "desc": idetinfoStr,
  16846. })
  16847. }
  16848. } else {
  16849. c.ServeSuccessJSON(map[string]interface{}{
  16850. "failed_code": -10,
  16851. "msg": res2.ErrMsg,
  16852. })
  16853. }
  16854. } else {
  16855. c.ServeSuccessJSON(map[string]interface{}{
  16856. "failed_code": -10,
  16857. "msg": res.ErrMsg,
  16858. })
  16859. }
  16860. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16861. var res ResultTwo
  16862. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16863. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16864. "&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)
  16865. resp, requestErr := http.Get(api)
  16866. if requestErr != nil {
  16867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16868. return
  16869. }
  16870. body, ioErr := ioutil.ReadAll(resp.Body)
  16871. if ioErr != nil {
  16872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16874. return
  16875. }
  16876. var respJSON map[string]interface{}
  16877. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16880. return
  16881. }
  16882. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16883. result, _ := json.Marshal(respJSON)
  16884. fmt.Println("log")
  16885. fmt.Println(string(result))
  16886. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16887. utils.ErrorLog("解析失败:%v", err)
  16888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16889. return
  16890. }
  16891. if res.Infcode == 0 {
  16892. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16893. if err == gorm.ErrRecordNotFound {
  16894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16895. return
  16896. } else if err != nil {
  16897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16898. return
  16899. } else {
  16900. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16901. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16902. infoStr := string(Iinfos)
  16903. idetinfoStr := string(Idetinfos)
  16904. var rf []*ResultFive
  16905. json.Unmarshal([]byte(infoStr), &rf)
  16906. var insutypes []*ResultFive
  16907. var insutype string
  16908. var is390 int = 0
  16909. var is310 int = 0
  16910. for _, item := range rf {
  16911. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16912. insutypes = append(insutypes, item)
  16913. }
  16914. }
  16915. if len(insutypes) == 1 {
  16916. insutype = insutypes[0].Insutype
  16917. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16918. } else {
  16919. for _, i := range insutypes {
  16920. if i.Insutype == "390" {
  16921. is390 = 1
  16922. }
  16923. if i.Insutype == "310" {
  16924. is310 = 1
  16925. }
  16926. }
  16927. }
  16928. if is390 == 1 {
  16929. insutype = "390"
  16930. }
  16931. if is310 == 1 {
  16932. insutype = "310"
  16933. }
  16934. if len(insutypes) == 0 {
  16935. insutype = "390"
  16936. }
  16937. var insuplc_admdvs string
  16938. for _, item := range rf {
  16939. if item.Insutype == insutype {
  16940. insuplc_admdvs = item.InsuplcAdmdvs
  16941. }
  16942. }
  16943. psn := &models.HisPsn{
  16944. PsnNo: res.Output.Baseinfo.PsnNo,
  16945. PatientId: patient.ID,
  16946. Certno: res.Output.Baseinfo.Certno,
  16947. Gend: res.Output.Baseinfo.Gend,
  16948. Naty: res.Output.Baseinfo.Naty,
  16949. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16950. PsnName: res.Output.Baseinfo.PsnName,
  16951. Idetinfo: idetinfoStr,
  16952. Insuinfo: infoStr,
  16953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16954. InsuplcAdmdvs: insuplc_admdvs,
  16955. }
  16956. service.CreateHisPsn(psn)
  16957. c.ServeSuccessJSON(map[string]interface{}{
  16958. "patient": patient,
  16959. "number": res.Output.Baseinfo.Certno,
  16960. })
  16961. }
  16962. } else {
  16963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16964. return
  16965. }
  16966. } else {
  16967. type ELeData struct {
  16968. Code string `json:"code"`
  16969. Data struct {
  16970. Aac002 string `json:"aac002"`
  16971. Aaz500 string `json:"aaz500"`
  16972. ActCardNo string `json:"actCardNo"`
  16973. Bab520 string `json:"bab520"`
  16974. Bkz543 string `json:"bkz543"`
  16975. BusinessType string `json:"businessType"`
  16976. CertfCodg string `json:"certfCodg"`
  16977. EcIndexNo string `json:"ecIndexNo"`
  16978. EcToken string `json:"ecToken"`
  16979. ID0000 string `json:"id0000"`
  16980. IDNo string `json:"idNo"`
  16981. IDType string `json:"idType"`
  16982. Idcode string `json:"idcode"`
  16983. IdentityToken string `json:"identity_token"`
  16984. InsuOrg string `json:"insuOrg"`
  16985. OfficeID string `json:"officeId"`
  16986. OfficeName string `json:"officeName"`
  16987. OperatorID string `json:"operatorId"`
  16988. OperatorName string `json:"operatorName"`
  16989. OrgID string `json:"orgId"`
  16990. UserName string `json:"userName"`
  16991. } `json:"data"`
  16992. Infno interface{} `json:"infno"`
  16993. Message string `json:"message"`
  16994. OrgID string `json:"orgId"`
  16995. TransType string `json:"transType"`
  16996. }
  16997. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16998. fmt.Println(result)
  16999. outPutInfo := Remove0000(result)
  17000. fmt.Println(outPutInfo)
  17001. if len(outPutInfo) > 0 {
  17002. var ele ELeData
  17003. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17004. if err != nil {
  17005. utils.ErrorLog("解析失败:%v", err)
  17006. }
  17007. token := ele.Data.EcToken
  17008. fmt.Println(outPutInfo)
  17009. 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)
  17010. saveLog(result, requestLog, "1101", "获取人员信息")
  17011. var dat map[string]interface{}
  17012. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17013. fmt.Println(dat)
  17014. } else {
  17015. fmt.Println(err)
  17016. }
  17017. userJSONBytes, _ := json.Marshal(dat)
  17018. var res ResultTwo
  17019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17020. utils.ErrorLog("解析失败:%v", err)
  17021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17022. return
  17023. }
  17024. if res.Infcode == 0 {
  17025. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17026. if err == gorm.ErrRecordNotFound {
  17027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17028. return
  17029. } else if err != nil {
  17030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17031. return
  17032. } else {
  17033. fmt.Println(res)
  17034. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17035. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17036. infoStr := string(Iinfos)
  17037. idetinfoStr := string(Idetinfos)
  17038. psn := &models.HisPsn{
  17039. PsnNo: res.Output.Baseinfo.PsnNo,
  17040. PatientId: patient.ID,
  17041. Certno: res.Output.Baseinfo.Certno,
  17042. Gend: res.Output.Baseinfo.Gend,
  17043. Naty: res.Output.Baseinfo.Naty,
  17044. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17045. PsnName: res.Output.Baseinfo.PsnName,
  17046. Idetinfo: idetinfoStr,
  17047. Insuinfo: infoStr,
  17048. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17049. CardInfo: outPutInfo,
  17050. VerifyNumber: token,
  17051. InsuplcAdmdvs: ele.Data.InsuOrg,
  17052. }
  17053. service.CreateHisPsn(psn)
  17054. var rf []*ResultFive
  17055. json.Unmarshal([]byte(infoStr), &rf)
  17056. var insutypes []*ResultFive
  17057. var insutype string
  17058. var is390 int = 0
  17059. var is310 int = 0
  17060. for _, item := range rf {
  17061. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17062. insutypes = append(insutypes, item)
  17063. }
  17064. }
  17065. if len(insutypes) == 1 {
  17066. insutype = insutypes[0].Insutype
  17067. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17068. } else {
  17069. for _, i := range insutypes {
  17070. if i.Insutype == "390" {
  17071. is390 = 1
  17072. }
  17073. if i.Insutype == "310" {
  17074. is310 = 1
  17075. }
  17076. }
  17077. }
  17078. if is390 == 1 {
  17079. insutype = "390"
  17080. }
  17081. if is310 == 1 {
  17082. insutype = "310"
  17083. }
  17084. if len(insutypes) == 0 {
  17085. insutype = "310"
  17086. }
  17087. c.ServeSuccessJSON(map[string]interface{}{
  17088. "patient": patient,
  17089. "number": token,
  17090. "insutype": insutype,
  17091. })
  17092. }
  17093. } else {
  17094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17095. return
  17096. }
  17097. }
  17098. //fmt.Println(result)
  17099. //
  17100. //if initFlag == 0 {
  17101. // c.TestGetBasBaseInit()
  17102. //}
  17103. //token := c.GetEleBaseInfo()
  17104. //
  17105. //token = Remove0000(token)
  17106. //
  17107. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17108. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17109. ////
  17110. //var res ResultTwo
  17111. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17112. // utils.ErrorLog("解析失败:%v", err)
  17113. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17114. // return
  17115. //}
  17116. //
  17117. //if res.Infcode == 0 {
  17118. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17119. // if err == gorm.ErrRecordNotFound {
  17120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17121. // return
  17122. // } else if err != nil {
  17123. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17124. // return
  17125. //
  17126. // } else {
  17127. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17128. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17129. // infoStr := string(Iinfos)
  17130. // idetinfoStr := string(Idetinfos)
  17131. //
  17132. //
  17133. //
  17134. //
  17135. // var rf []*ResultFive
  17136. // json.Unmarshal([]byte(infoStr), &rf)
  17137. //
  17138. // var insutypes []*ResultFive
  17139. // var insutype string
  17140. // var is390 int = 0
  17141. // var is310 int = 0
  17142. // var insuplc_admdvs string
  17143. //
  17144. // for _, item := range rf {
  17145. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17146. // insutypes = append(insutypes, item)
  17147. // }
  17148. // }
  17149. //
  17150. // if len(insutypes) == 1 {
  17151. // insutype = insutypes[0].Insutype
  17152. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17153. // } else {
  17154. // for _, i := range insutypes {
  17155. // if i.Insutype == "390" {
  17156. // is390 = 1
  17157. // }
  17158. //
  17159. // if i.Insutype == "310" {
  17160. // is310 = 1
  17161. // }
  17162. // }
  17163. // }
  17164. // if is390 == 1 {
  17165. // insutype = "390"
  17166. // }
  17167. //
  17168. // if is310 == 1 {
  17169. // insutype = "310"
  17170. // }
  17171. // if len(insutypes) == 0 {
  17172. // insutype = "310"
  17173. // }
  17174. // for _, item := range rf {
  17175. // if item.Insutype == insutype {
  17176. // insuplc_admdvs = item.InsuplcAdmdvs
  17177. // }
  17178. // }
  17179. // psn := &models.HisPsn{
  17180. // PsnNo: res.Output.Baseinfo.PsnNo,
  17181. // Age: res.Output.Baseinfo.Age,
  17182. // PatientId: patient.ID,
  17183. // Certno: res.Output.Baseinfo.Certno,
  17184. // Brdy: res.Output.Baseinfo.Brdy,
  17185. // Gend: res.Output.Baseinfo.Gend,
  17186. // Naty: res.Output.Baseinfo.Naty,
  17187. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17188. // PsnName: res.Output.Baseinfo.PsnName,
  17189. // Idetinfo: idetinfoStr,
  17190. // Insuinfo: infoStr,
  17191. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17192. // CardInfo: "",
  17193. // VerifyNumber: token,
  17194. // InsuplcAdmdvs: insuplc_admdvs,
  17195. // }
  17196. // service.CreateHisPsn(psn)
  17197. //
  17198. // c.ServeSuccessJSON(map[string]interface{}{
  17199. // "patient": patient,
  17200. // "number": token,
  17201. // })
  17202. // }
  17203. //} else {
  17204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17205. // return
  17206. //}
  17207. }
  17208. break
  17209. case 5:
  17210. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17211. var api string
  17212. if miConfig.MdtrtareaAdmvs == "320921" {
  17213. 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 +
  17214. "&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
  17215. fmt.Println(api)
  17216. } else {
  17217. 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 +
  17218. "&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)
  17219. }
  17220. resp, requestErr := http.Get(api)
  17221. if requestErr != nil {
  17222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17223. return
  17224. }
  17225. body, ioErr := ioutil.ReadAll(resp.Body)
  17226. if ioErr != nil {
  17227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17229. return
  17230. }
  17231. var respJSON map[string]interface{}
  17232. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17235. return
  17236. }
  17237. var status string
  17238. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17239. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17240. var token string
  17241. var res ResultTwo //1101结果
  17242. var res10265 ResultTwo10265 //1101结果
  17243. if status == "0" { //读卡成功
  17244. var card_info string //卡信息
  17245. //var busi_card_info string
  17246. var auth_info string
  17247. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17248. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17249. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17250. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17251. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17252. result, _ := json.Marshal(respJSON)
  17253. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17254. utils.ErrorLog("解析失败:%v", err)
  17255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17256. return
  17257. }
  17258. res.ErrMsg = res10265.ErrMsg
  17259. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17260. res.Infcode = infocode
  17261. res.Output = res10265.Output
  17262. res.InfRefmsgid = res10265.InfRefmsgid
  17263. if res.Infcode == 0 {
  17264. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17265. if err == gorm.ErrRecordNotFound {
  17266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17267. return
  17268. } else if err != nil {
  17269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17270. return
  17271. } else {
  17272. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17273. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17274. infoStr := string(Iinfos)
  17275. idetinfoStr := string(Idetinfos)
  17276. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  17277. psn := &models.HisPsn{
  17278. PsnNo: res.Output.Baseinfo.PsnNo,
  17279. PatientId: patient.ID,
  17280. Certno: res.Output.Baseinfo.Certno,
  17281. Gend: res.Output.Baseinfo.Gend,
  17282. Brdy: b,
  17283. Age: float64(age),
  17284. Naty: res.Output.Baseinfo.Naty,
  17285. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17286. PsnName: res.Output.Baseinfo.PsnName,
  17287. Idetinfo: idetinfoStr,
  17288. Insuinfo: infoStr,
  17289. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17290. CardInfo: card_info,
  17291. VerifyNumber: token,
  17292. AuthInfo: auth_info,
  17293. }
  17294. var rf []*ResultFive
  17295. json.Unmarshal([]byte(infoStr), &rf)
  17296. var insutypes []*ResultFive
  17297. var insutype string
  17298. var is390 int = 0
  17299. var is310 int = 0
  17300. for _, item := range rf {
  17301. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17302. insutypes = append(insutypes, item)
  17303. }
  17304. }
  17305. if len(insutypes) == 1 {
  17306. insutype = insutypes[0].Insutype
  17307. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17308. } else {
  17309. for _, i := range insutypes {
  17310. if i.Insutype == "390" {
  17311. is390 = 1
  17312. }
  17313. if i.Insutype == "310" {
  17314. is310 = 1
  17315. }
  17316. }
  17317. }
  17318. if is390 == 1 {
  17319. insutype = "390"
  17320. }
  17321. if is310 == 1 {
  17322. insutype = "310"
  17323. }
  17324. if len(insutypes) == 0 {
  17325. insutype = "310"
  17326. }
  17327. service.CreateHisPsn(psn)
  17328. c.ServeSuccessJSON(map[string]interface{}{
  17329. "patient": patient,
  17330. "number": token,
  17331. "insutype": insutype,
  17332. })
  17333. }
  17334. } else {
  17335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17336. return
  17337. }
  17338. } else { //读卡失败
  17339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17340. return
  17341. }
  17342. }
  17343. break
  17344. }
  17345. }
  17346. var initFlag int64 = 0
  17347. var initEleFlag int64 = 0
  17348. func (c *HisApiController) TestGetBasBaseInit() {
  17349. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17350. Iinit := DllDef.MustFindProc("Init")
  17351. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17352. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  17353. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  17354. if ret != 0 {
  17355. fmt.Println("SSCard的报错原因:", err)
  17356. fmt.Println("SSCard的运算结果为:", ret)
  17357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17358. return
  17359. }
  17360. result := int(ret)
  17361. fmt.Println("SSCard的运算结果为1:", result)
  17362. initFlag = 1
  17363. return
  17364. }
  17365. func (c *HisApiController) HandleJiangXiReadCard() {
  17366. fmt.Println("~~~~~~")
  17367. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17368. admin_user_id, _ := c.GetInt64("admin_user_id")
  17369. id_card_type, _ := c.GetInt64("id_card_type")
  17370. //certificates, _ := c.GetInt64("certificates")
  17371. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17372. if initFlag == 0 {
  17373. c.TestGetJiangXiBasBaseInit()
  17374. }
  17375. basStr := c.GetBasBaseInfo()
  17376. if len(basStr) == 0 {
  17377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17378. return
  17379. }
  17380. fmt.Println(basStr)
  17381. bas := strings.Split(basStr, "|")
  17382. basNumber := bas[1]
  17383. fmt.Println(basNumber)
  17384. card_sn := bas[3]
  17385. fmt.Println(card_sn)
  17386. 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, "")
  17387. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  17388. var dat map[string]interface{}
  17389. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17390. fmt.Println(dat)
  17391. } else {
  17392. fmt.Println(err)
  17393. }
  17394. userJSONBytes, _ := json.Marshal(dat)
  17395. var res ResultTwo
  17396. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17397. utils.ErrorLog("解析失败:%v", err)
  17398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17399. return
  17400. }
  17401. if res.Infcode == 0 {
  17402. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  17403. if err == gorm.ErrRecordNotFound {
  17404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17405. return
  17406. } else if err != nil {
  17407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17408. return
  17409. } else {
  17410. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17411. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17412. infoStr := string(Iinfos)
  17413. idetinfoStr := string(Idetinfos)
  17414. psn := &models.HisPsn{
  17415. PsnNo: res.Output.Baseinfo.PsnNo,
  17416. PatientId: patient.ID,
  17417. Certno: res.Output.Baseinfo.Certno,
  17418. Gend: res.Output.Baseinfo.Gend,
  17419. Naty: res.Output.Baseinfo.Naty,
  17420. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17421. PsnName: res.Output.Baseinfo.PsnName,
  17422. Idetinfo: idetinfoStr,
  17423. Insuinfo: infoStr,
  17424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17425. CardInfo: basStr,
  17426. VerifyNumber: "",
  17427. }
  17428. service.CreateHisPsn(psn)
  17429. c.ServeSuccessJSON(map[string]interface{}{
  17430. "patient": patient,
  17431. "number": basNumber,
  17432. })
  17433. }
  17434. } else {
  17435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17436. return
  17437. }
  17438. }
  17439. func (c *HisApiController) TestGetHnBasBaseInit() {
  17440. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17441. Iinit := DllDef.MustFindProc("Init")
  17442. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17443. //http://10.77.211.236/CSB/hsa-fsi-1303
  17444. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17445. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17446. // 调用 Init 函数
  17447. 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"))))
  17448. //if ret != 0 {
  17449. fmt.Println("SSCard的报错原因:", err)
  17450. fmt.Println("SSCard的运算结果为:", ret)
  17451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17452. // return
  17453. //}
  17454. result := int(ret)
  17455. fmt.Println("SSCard的运算结果为1:", result)
  17456. initFlag = 1
  17457. return
  17458. }
  17459. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17460. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17461. Iinit := DllDef.MustFindProc("Init")
  17462. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17463. //http://10.77.211.236/CSB/hsa-fsi-1303
  17464. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  17465. if ret != 0 {
  17466. fmt.Println("SSCard的报错原因:", err)
  17467. fmt.Println("SSCard的运算结果为:", ret)
  17468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17469. return
  17470. }
  17471. result := int(ret)
  17472. fmt.Println("SSCard的运算结果为1:", result)
  17473. initFlag = 1
  17474. return
  17475. }
  17476. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17477. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17478. Iinit := DllDef.MustFindProc("Init")
  17479. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17480. //http://10.77.211.236/CSB/hsa-fsi-1303
  17481. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17482. if ret != 0 {
  17483. fmt.Println("SSCard的报错原因:", err)
  17484. fmt.Println("SSCard的运算结果为:", ret)
  17485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17486. return
  17487. }
  17488. result := int(ret)
  17489. fmt.Println("SSCard的运算结果为1:", result)
  17490. initFlag = 1
  17491. return
  17492. }
  17493. func (c *HisApiController) GetSFZBaseInfo() string {
  17494. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17495. readCard := DllDef.MustFindProc("ReadSFZ")
  17496. if readCard == nil {
  17497. fmt.Println("readcard is nil")
  17498. readCard = DllDef.MustFindProc("ReadSFZ")
  17499. }
  17500. str := make([]byte, 8096)
  17501. str1 := make([]byte, 8096)
  17502. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17503. fmt.Println(r)
  17504. return Remove0000(string(str))
  17505. }
  17506. func (c *HisApiController) GetEleBaseInfo() string {
  17507. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17508. readCard := DllDef.MustFindProc("GetQRBase")
  17509. fmt.Println(readCard)
  17510. if readCard == nil {
  17511. fmt.Println("readcard is nil")
  17512. readCard = DllDef.MustFindProc("GetQRBase")
  17513. }
  17514. str := make([]byte, 1024)
  17515. str1 := make([]byte, 1024)
  17516. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17517. fmt.Println(ret2)
  17518. fmt.Println(string(str1))
  17519. fmt.Println(string(str))
  17520. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17521. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17522. if ret2 != 0 {
  17523. return ""
  17524. }
  17525. return string(str)
  17526. }
  17527. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17528. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17529. readCard := DllDef.MustFindProc("NationEcTrans")
  17530. fmt.Println(readCard)
  17531. fmt.Println("!!!!!")
  17532. pBusiCardInfo := make([]byte, 2048)
  17533. input := make(map[string]interface{})
  17534. inputData := make(map[string]interface{})
  17535. inputData["orgId"] = code
  17536. inputData["businessType"] = "01101"
  17537. inputData["operatorId"] = "1"
  17538. inputData["operatorName"] = "admin"
  17539. inputData["officeId"] = "001"
  17540. inputData["officeName"] = "血透室"
  17541. inputData["deviceType"] = ""
  17542. input["data"] = inputData
  17543. input["orgId"] = code
  17544. input["transType"] = "ec.query"
  17545. bytesData, _ := json.Marshal(input)
  17546. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17547. fmt.Println(ret2)
  17548. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17549. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17550. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17551. }
  17552. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17553. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17554. readCard := DllDef.MustFindProc("NationEcTrans")
  17555. fmt.Println(readCard)
  17556. fmt.Println("!!!!!")
  17557. pBusiCardInfo := make([]byte, 2048)
  17558. input := make(map[string]interface{})
  17559. inputData := make(map[string]interface{})
  17560. inputData["orgId"] = code
  17561. inputData["businessType"] = "01101"
  17562. inputData["operatorId"] = "9"
  17563. inputData["operatorName"] = "admin"
  17564. inputData["officeId"] = "001"
  17565. inputData["officeName"] = "血透室"
  17566. inputData["deviceType"] = ""
  17567. input["data"] = inputData
  17568. input["orgId"] = code
  17569. input["transType"] = "ec.query"
  17570. bytesData, _ := json.Marshal(input)
  17571. 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])))
  17572. fmt.Println(ret2)
  17573. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17574. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17575. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17576. }
  17577. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17578. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17579. readCard := DllDef.MustFindProc("NationEcTrans")
  17580. fmt.Println(readCard)
  17581. fmt.Println("!!!!!")
  17582. pBusiCardInfo := make([]byte, 2048)
  17583. input := make(map[string]interface{})
  17584. inputData := make(map[string]interface{})
  17585. inputData["orgId"] = code
  17586. inputData["businessType"] = "01301"
  17587. inputData["operatorId"] = "9"
  17588. inputData["operatorName"] = "admin"
  17589. inputData["officeId"] = "001"
  17590. inputData["officeName"] = "血透室"
  17591. inputData["deviceType"] = ""
  17592. input["data"] = inputData
  17593. input["orgId"] = code
  17594. input["transType"] = "ec.query"
  17595. bytesData, _ := json.Marshal(input)
  17596. 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])))
  17597. fmt.Println(ret2)
  17598. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17599. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17600. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17601. }
  17602. func GetJxEleBaseInfo(org_id int64) string {
  17603. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17604. readCard := DllDef.MustFindProc("NationEcTrans")
  17605. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17606. if readCard == nil {
  17607. fmt.Println("readcard is nil")
  17608. readCard = DllDef.MustFindProc("NationEcTrans")
  17609. }
  17610. str1 := make([]byte, 1024)
  17611. data := make(map[string]interface{})
  17612. inputData := make(map[string]interface{})
  17613. inputData["orgId"] = miConfig.Code
  17614. inputData["businessType"] = "01101"
  17615. inputData["operatorId"] = "test001"
  17616. inputData["operatorName"] = "cn"
  17617. inputData["officeId"] = "32760"
  17618. inputData["officeName"] = "waike"
  17619. inputData["deviceType"] = ""
  17620. data["data"] = inputData
  17621. data["transType"] = "ec.query"
  17622. data["extra "] = ""
  17623. data["orgId"] = miConfig.Code
  17624. bytesData, _ := json.Marshal(data)
  17625. //bytesData, _ := json.Marshal(data)
  17626. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17627. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17628. fmt.Println(ret2)
  17629. fmt.Println(string(str1))
  17630. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17631. if ret2 != 0 {
  17632. return ""
  17633. }
  17634. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17635. }
  17636. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17637. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17638. // readCard := DllDef.MustFindProc("NationEcTrans")
  17639. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17640. //
  17641. // if readCard == nil {
  17642. // fmt.Println("readcard is nil")
  17643. // readCard = DllDef.MustFindProc("NationEcTrans")
  17644. // }
  17645. // str1 := make([]byte, 1024)
  17646. //
  17647. // data := make(map[string]interface{})
  17648. //
  17649. // inputData := make(map[string]interface{})
  17650. // inputData["orgId"] = miConfig.Code
  17651. // inputData["businessType"] = "01101"
  17652. // inputData["operatorId"] = "test001"
  17653. // inputData["operatorName"] = "cn"
  17654. // inputData["officeId"] = "32760"
  17655. // inputData["officeName"] = "waike"
  17656. // inputData["deviceType"] = ""
  17657. //
  17658. // data["data"] = inputData
  17659. // data["transType"] = "ec.query"
  17660. // data["extra "] = ""
  17661. // data["orgId"] = miConfig.Code
  17662. // bytesData, _ := json.Marshal(data)
  17663. // //bytesData, _ := json.Marshal(data)
  17664. //
  17665. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17666. //
  17667. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17668. // fmt.Println(ret2)
  17669. // fmt.Println(string(str1))
  17670. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17671. //
  17672. // if ret2 != 0 {
  17673. // return ""
  17674. // }
  17675. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17676. //}
  17677. func GetJxEleBaseInitInfo(org_id int64) string {
  17678. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17679. readCard := DllDef.MustFindProc("NationEcTrans")
  17680. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17681. if readCard == nil {
  17682. fmt.Println("readcard is nil")
  17683. readCard = DllDef.MustFindProc("NationEcTrans")
  17684. }
  17685. str1 := make([]byte, 2048)
  17686. data := make(map[string]interface{})
  17687. inputData := make(map[string]interface{})
  17688. inputData["orgId"] = miConfig.Code
  17689. inputData["businessType"] = "01101"
  17690. inputData["operatorId"] = "1"
  17691. inputData["operatorName"] = "huangchuang"
  17692. inputData["officeId"] = "101"
  17693. inputData["officeName"] = "xuetou"
  17694. inputData["deviceType"] = ""
  17695. data["data"] = inputData
  17696. data["transType"] = "ec.query"
  17697. data["orgId"] = miConfig.Code
  17698. bytesData, _ := json.Marshal(data)
  17699. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17700. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17701. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17702. fmt.Println(ret2)
  17703. fmt.Println(string(str1))
  17704. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17705. if ret2 != 0 {
  17706. return ""
  17707. }
  17708. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17709. initEleFlag = 1
  17710. }
  17711. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17712. }
  17713. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17714. // // 构建命令
  17715. // cmd := exec.Command("python", "b.py")
  17716. //
  17717. // // 执行命令并等待完成
  17718. // output, err := cmd.CombinedOutput()
  17719. // if err != nil {
  17720. // fmt.Println("Error executing Python script:", err)
  17721. // return
  17722. // }
  17723. //
  17724. // // 打印Python脚本的输出
  17725. // fmt.Println(string(output))
  17726. //}
  17727. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17728. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17729. readCard := DllDef.MustFindProc("gxyb_call")
  17730. if readCard == nil {
  17731. fmt.Println("readcard is nil")
  17732. readCard = DllDef.MustFindProc("gxyb_call")
  17733. }
  17734. str := make([]byte, 1024)
  17735. str1 := make([]byte, 1024)
  17736. //data := make(map[string]interface{})
  17737. currentTime := time.Now()
  17738. // 格式化时间为 "YYYYMMDDHH24MISS"
  17739. formattedTime := currentTime.Format("20060102150405")
  17740. inputData := make(map[string]interface{})
  17741. inputData2 := make(map[string]interface{})
  17742. inputData["transNo"] = "1401"
  17743. inputData["transType"] = "passwordCheck"
  17744. inputData["timestamp"] = formattedTime
  17745. inputData2["fixmedinsCode"] = code
  17746. inputData2["psnNo"] = ""
  17747. inputData["data"] = inputData2
  17748. jsonBytes, err := json.Marshal(inputData)
  17749. if err != nil {
  17750. fmt.Println("Error encoding map to JSON:", err)
  17751. }
  17752. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17753. fmt.Println(string(str1))
  17754. fmt.Println(string(str))
  17755. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17756. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17757. if ret2 != 0 {
  17758. return ""
  17759. }
  17760. return string(str)
  17761. }
  17762. func (c *HisApiController) GetoleInfo() Response {
  17763. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17764. defer ole.CoUninitialize()
  17765. // Replace with the ProgID or CLSID of your COM object
  17766. progID := "YinHai.XJ.Actual.Interface.New"
  17767. // Create COM object
  17768. unknown, err := oleutil.CreateObject(progID)
  17769. if err != nil {
  17770. fmt.Println("Unable to create COM object:", err)
  17771. }
  17772. defer unknown.Release()
  17773. // Query for the IDispatch interface
  17774. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17775. if err != nil {
  17776. fmt.Println("Unable to get IDispatch interface:", err)
  17777. }
  17778. defer dispatch.Release()
  17779. // Prepare parameters
  17780. transNo := "1401"
  17781. transType := "passwordCheck"
  17782. timestamp := time.Now().Unix()
  17783. fixmedinsCode := "H45072101171"
  17784. psnNo := ""
  17785. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17786. result2 := ""
  17787. // Call COM object's method using the IDispatch interface
  17788. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17789. fmt.Println(resulr)
  17790. fmt.Println(result2)
  17791. if err != nil {
  17792. fmt.Println("调用COM对象方法失败:", err)
  17793. }
  17794. var response Response
  17795. err2 := json.Unmarshal([]byte(result2), &response)
  17796. if err2 != nil {
  17797. fmt.Println("解析JSON失败:", err)
  17798. }
  17799. return response
  17800. }
  17801. func (c *HisApiController) GetBasBaseInfo() string {
  17802. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17803. readCard := DllDef.MustFindProc("ReadCardBas")
  17804. if readCard == nil {
  17805. fmt.Println("readcard is nil")
  17806. readCard = DllDef.MustFindProc("ReadCardBas")
  17807. }
  17808. str := make([]byte, 1024)
  17809. str1 := make([]byte, 1024)
  17810. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17811. fmt.Println(string(str1))
  17812. fmt.Println(string(str))
  17813. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17814. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17815. if ret2 != 0 {
  17816. return ""
  17817. }
  17818. return string(str)
  17819. }
  17820. type Program struct {
  17821. FunctionID string `xml:"function_id"`
  17822. CardInfo string `xml:"cardinfo"`
  17823. User string `xml:"user"`
  17824. }
  17825. func (c *HisApiController) GetBasBaseInfo1111() string {
  17826. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17827. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17828. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17829. if readCard == nil {
  17830. fmt.Println("readcard is nil")
  17831. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17832. }
  17833. if readCard2 == nil {
  17834. fmt.Println("readcard is nil")
  17835. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17836. }
  17837. str := make([]byte, 1024)
  17838. str1 := make([]byte, 1024)
  17839. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17840. str3 := make([]byte, 1024)
  17841. str4 := make([]byte, 1024)
  17842. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17843. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17844. //if err != nil {
  17845. // fmt.Println("Error opening file:", err)
  17846. //}
  17847. //defer file.Close()
  17848. //
  17849. //var lastProgram Program
  17850. //scanner := bufio.NewScanner(file)
  17851. //inProgram := false
  17852. //
  17853. //for scanner.Scan() {
  17854. // line := scanner.Text()
  17855. // if strings.Contains(line, "<program>") {
  17856. // inProgram = true
  17857. // programXML := "<program>"
  17858. // for scanner.Scan() {
  17859. // line = scanner.Text()
  17860. // programXML += line
  17861. // if strings.Contains(line, "</program>") {
  17862. // programXML += "</program>"
  17863. // break
  17864. // }
  17865. // }
  17866. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17867. // // 解析成功,更新最后的 Program
  17868. // }
  17869. // inProgram = false
  17870. // }
  17871. //}
  17872. //
  17873. // fmt.Println("Error reading file:", inProgram)
  17874. //
  17875. //if err := scanner.Err(); err != nil {
  17876. // fmt.Println("Error reading file:", err)
  17877. //}
  17878. // 输出最后一次的 Program
  17879. //fmt.Printf("最后一次的 <program>:\n")
  17880. //fmt.Printf("<program>\n")
  17881. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17882. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17883. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17884. //fmt.Printf("</program>\n")
  17885. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17886. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17887. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17888. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17889. return ConvertToString(string(str), "gbk", "utf-8")
  17890. }
  17891. func (c *HisApiController) GetBasBaseInfo22222() string {
  17892. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17893. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17894. if readCard == nil {
  17895. fmt.Println("readcard is nil")
  17896. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17897. }
  17898. str := make([]byte, 1024)
  17899. str1 := make([]byte, 1024)
  17900. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17901. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17902. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17903. //if err != nil {
  17904. // fmt.Println("Error opening file:", err)
  17905. //}
  17906. //defer file.Close()
  17907. //
  17908. //var lastProgram Program
  17909. //scanner := bufio.NewScanner(file)
  17910. //inProgram := false
  17911. //
  17912. //for scanner.Scan() {
  17913. // line := scanner.Text()
  17914. // if strings.Contains(line, "<program>") {
  17915. // inProgram = true
  17916. // programXML := "<program>"
  17917. // for scanner.Scan() {
  17918. // line = scanner.Text()
  17919. // programXML += line
  17920. // if strings.Contains(line, "</program>") {
  17921. // programXML += "</program>"
  17922. // break
  17923. // }
  17924. // }
  17925. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17926. // // 解析成功,更新最后的 Program
  17927. // }
  17928. // inProgram = false
  17929. // }
  17930. //}
  17931. //
  17932. // fmt.Println("Error reading file:", inProgram)
  17933. //
  17934. //if err := scanner.Err(); err != nil {
  17935. // fmt.Println("Error reading file:", err)
  17936. //}
  17937. // 输出最后一次的 Program
  17938. //fmt.Printf("最后一次的 <program>:\n")
  17939. //fmt.Printf("<program>\n")
  17940. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17941. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17942. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17943. //fmt.Printf("</program>\n")
  17944. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17945. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17946. return ConvertToString(string(str1), "gbk", "utf-8")
  17947. }
  17948. func (c *HisApiController) GetahBasBaseInfo() string {
  17949. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17950. readCard := DllDef.MustFindProc("iReadCardBas")
  17951. if readCard == nil {
  17952. fmt.Println("readcard is nil")
  17953. readCard = DllDef.MustFindProc("iReadCardBas")
  17954. }
  17955. //str := make([]byte, 1024)
  17956. str1 := make([]byte, 1024)
  17957. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17958. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17959. //if err != nil {
  17960. // fmt.Println("Error opening file:", err)
  17961. //}
  17962. //defer file.Close()
  17963. //
  17964. //var lastProgram Program
  17965. //scanner := bufio.NewScanner(file)
  17966. //inProgram := false
  17967. //
  17968. //for scanner.Scan() {
  17969. // line := scanner.Text()
  17970. // if strings.Contains(line, "<program>") {
  17971. // inProgram = true
  17972. // programXML := "<program>"
  17973. // for scanner.Scan() {
  17974. // line = scanner.Text()
  17975. // programXML += line
  17976. // if strings.Contains(line, "</program>") {
  17977. // programXML += "</program>"
  17978. // break
  17979. // }
  17980. // }
  17981. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17982. // // 解析成功,更新最后的 Program
  17983. // }
  17984. // inProgram = false
  17985. // }
  17986. //}
  17987. //
  17988. // fmt.Println("Error reading file:", inProgram)
  17989. //
  17990. //if err := scanner.Err(); err != nil {
  17991. // fmt.Println("Error reading file:", err)
  17992. //}
  17993. // 输出最后一次的 Program
  17994. //fmt.Printf("最后一次的 <program>:\n")
  17995. //fmt.Printf("<program>\n")
  17996. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17997. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17998. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17999. //fmt.Printf("</program>\n")
  18000. fmt.Println(string(str1))
  18001. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18002. if ret2 != 0 {
  18003. return ""
  18004. }
  18005. return string(str1)
  18006. }
  18007. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18008. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18009. readCard := DllDef.MustFindProc("read_cardinfo")
  18010. if readCard == nil {
  18011. fmt.Println("readcard is nil")
  18012. readCard = DllDef.MustFindProc("read_cardinfo")
  18013. }
  18014. str := make([]byte, 1024) //卡号
  18015. str1 := make([]byte, 1024) //卡识别码
  18016. str2 := make([]byte, 1024) //身份证号
  18017. str3 := make([]byte, 1024) //姓名
  18018. str4 := make([]byte, 1024) //错误信息
  18019. 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])))
  18020. fmt.Println(string(str1))
  18021. fmt.Println(string(str))
  18022. fmt.Println(string(str2))
  18023. fmt.Println(string(str3))
  18024. fmt.Println(string(str4))
  18025. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18026. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18027. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18028. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18029. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18030. if ret2 != 0 {
  18031. return "", "", "", "", ""
  18032. }
  18033. return string(str), string(str1), string(str2), string(str3), string(str4)
  18034. }
  18035. type CustomFundPay struct {
  18036. FundPayType string `json:"fund_pay_type"`
  18037. FundPayamt float64 `json:"fund_payamt"`
  18038. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18039. }
  18040. //func (c *HisApiController) GetBatchSettleList() {
  18041. // start_time_str := c.GetString("start_time")
  18042. // //end_time_str := c.GetString("end_time")
  18043. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18044. //
  18045. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18046. //
  18047. // for _, item := range orders {
  18048. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18049. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18050. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18051. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18052. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18053. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18054. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18055. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18056. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18057. //
  18058. // if order.ID == 0 {
  18059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18060. // return
  18061. // }
  18062. //
  18063. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18064. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18065. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18066. // //fmt.Println(count)
  18067. // //var zero string
  18068. // //number := count + 1
  18069. // //if number >= 1000 {
  18070. // // zero = "0000" + strconv.FormatInt(number, 10)
  18071. // //} else if number >= 10000 {
  18072. // // zero = "000" + strconv.FormatInt(number, 10)
  18073. // //} else if number >= 100000 {
  18074. // // zero = "00" + strconv.FormatInt(number, 10)
  18075. // //} else if number >= 1000000 {
  18076. // // zero = "0" + strconv.FormatInt(number, 10)
  18077. // //} else {
  18078. // // zero = strconv.FormatInt(number, 10)
  18079. // //}
  18080. // //fmt.Println(zero)
  18081. //
  18082. // struct4101 := service.Struct4101{
  18083. // PsnNo: order.PsnNo,
  18084. // MdtrtId: order.MdtrtId,
  18085. // SetlId: order.SetlId,
  18086. // PsnName: order.PsnName,
  18087. // Gend: order.Gend,
  18088. // Brdy: his.Brdy,
  18089. // Age: his.Age,
  18090. // Naty: order.Naty,
  18091. // PatnCertType: "01",
  18092. // Certno: order.Certno,
  18093. // Prfs: "90",
  18094. // ConerName: roles[0].UserName,
  18095. // PatnRlts: "99",
  18096. // ConerAddr: miConfig.OrgName,
  18097. // ConerTel: admin.Mobile,
  18098. // HiType: order.Insutype,
  18099. // Insuplc: miConfig.InsuplcAdmdvs,
  18100. // MaindiagFlag: "1",
  18101. // BillCode: order.SetlId,
  18102. // BillNo: order.SetlId,
  18103. // BizSn: order.Number,
  18104. // PsnSelfPay: order.PsnPartAmt,
  18105. // PsnOwnPay: order.PsnPartAmt,
  18106. // AcctPay: order.AcctPay,
  18107. // PsnCashpay: order.PsnCashPay,
  18108. // HiPaymtd: "1",
  18109. // Hsorg: miConfig.InsuplcAdmdvs,
  18110. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18111. // MedinsFillPsn: curRoles.UserName,
  18112. // MedinsFillDept: miConfig.OrgName,
  18113. // IptMedType: "2",
  18114. // }
  18115. // struct4101.SetlBegnDate = order.SetlTime
  18116. // struct4101.SetlEndDate = order.SetlTime
  18117. // time_arr := strings.Split(order.SetlTime, " ")
  18118. // struct4101.AdmTime = time_arr[0]
  18119. // struct4101.AdmEndTime = time_arr[0]
  18120. //
  18121. // var rf []CustomFundPay
  18122. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18123. //
  18124. // var tempFunPays []service.CustomStruct
  18125. // for _, item := range rf {
  18126. // var tempFunPay service.CustomStruct
  18127. // tempFunPay.FundPayamt = item.FundPayamt
  18128. // tempFunPay.FundPayType = item.FundPayType
  18129. // tempFunPays = append(tempFunPays, tempFunPay)
  18130. // }
  18131. // struct4101.CustomStruct = tempFunPays
  18132. //
  18133. // var tempDiaginfos []service.DiaginfoStructTwo
  18134. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18135. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18136. //
  18137. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18138. // var config []*models.HisXtDiagnoseConfig
  18139. // for _, item := range diagnosis_ids {
  18140. // id, _ := strconv.ParseInt(item, 10, 64)
  18141. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18142. // config = append(config, &diagnosisConfig)
  18143. // }
  18144. //
  18145. // for index, item := range config {
  18146. // if index == 0 {
  18147. // var tempDiaginfo service.DiaginfoStructTwo
  18148. // tempDiaginfo.DiagCode = item.CountryCode
  18149. // tempDiaginfo.DiagName = item.CountryContentName
  18150. // tempDiaginfo.DiagType = "1"
  18151. // tempDiaginfo.MaindiagFlag = "1"
  18152. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18153. // } else {
  18154. // var tempDiaginfo service.DiaginfoStructTwo
  18155. // tempDiaginfo.DiagCode = item.CountryCode
  18156. // tempDiaginfo.DiagName = item.CountryContentName
  18157. // tempDiaginfo.DiagType = "1"
  18158. // tempDiaginfo.MaindiagFlag = "0"
  18159. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18160. // }
  18161. // }
  18162. // struct4101.Diseinfo = tempDiaginfos
  18163. //
  18164. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18165. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18166. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18167. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18168. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18169. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18170. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18171. //
  18172. // var iteminfo service.IteminfoStruct
  18173. //
  18174. // var bedCostTotal float64 = 0 //床位总费
  18175. // var bedCostSelfTotal float64 = 0 //床位自费
  18176. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18177. //
  18178. // var operationCostTotal float64 = 0 //手术费
  18179. // var operationCostSelfTotal float64 = 0 //手术费
  18180. // var operationCostPartSelfTotal float64 = 0 //手术费
  18181. //
  18182. // var otherCostTotal float64 = 0 //其他费用
  18183. // var otherCostSelfTotal float64 = 0 //其他费用
  18184. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18185. //
  18186. // var materialCostTotal float64 = 0 //材料费
  18187. // var materialCostSelfTotal float64 = 0 //材料费
  18188. // var materialCostPartSelfTotal float64 = 0 //材料费
  18189. //
  18190. // var westernMedicineCostTotal float64 = 0 //西药费
  18191. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18192. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18193. //
  18194. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18195. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18196. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18197. //
  18198. // var checkCostTotal float64 = 0 //检查费
  18199. // var checkCostSelfTotal float64 = 0 //检查费
  18200. // var checkCostPartSelfTotal float64 = 0 //检查费
  18201. //
  18202. // var laboratoryCostTotal float64 = 0 //化验费
  18203. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18204. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18205. //
  18206. // var treatCostTotal float64 = 0 //治疗费用
  18207. // var treatCostSelfTotal float64 = 0 //治疗费用
  18208. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18209. //
  18210. // decimal.DivisionPrecision = 2
  18211. //
  18212. // var bed_fulamt_ownpay_amt float64 = 0
  18213. // var operation_fulamt_ownpay_amt float64 = 0
  18214. // var other_fulamt_ownpay_amt float64 = 0
  18215. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18216. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18217. // var check_fulamt_ownpay_amt float64 = 0
  18218. // var material_fulamt_ownpay_amt float64 = 0
  18219. // var laboratory_fulamt_ownpay_amt float64 = 0
  18220. // var treat_fulamt_ownpay_amt float64 = 0
  18221. //
  18222. // var bed_claa_sunmfee float64 = 0
  18223. // var bed_clab_amt float64 = 0
  18224. // var bed_other_amt float64 = 0
  18225. //
  18226. // var operation_claa_sunmfee float64 = 0
  18227. // var operation_clab_amt float64 = 0
  18228. // var operation_other_amt float64 = 0
  18229. //
  18230. // var other_claa_sunmfee float64 = 0
  18231. // var other_clab_amt float64 = 0
  18232. // var other_other_amt float64 = 0
  18233. //
  18234. // var westernMedicine_claa_sunmfee float64 = 0
  18235. // var westernMedicine_clab_amt float64 = 0
  18236. // var westernMedicine_other_amt float64 = 0
  18237. //
  18238. // var chineseTraditional_claa_sunmfee float64 = 0
  18239. // var chineseTraditional_clab_amt float64 = 0
  18240. // var chineseTraditional_other_amt float64 = 0
  18241. //
  18242. // var check_claa_sunmfee float64 = 0
  18243. // var check_clab_amt float64 = 0
  18244. // var check_other_amt float64 = 0
  18245. //
  18246. // var material_claa_sunmfee float64 = 0
  18247. // var material_clab_amt float64 = 0
  18248. // var material_other_amt float64 = 0
  18249. //
  18250. // var laboratory_claa_sunmfee float64 = 0
  18251. // var laboratory_clab_amt float64 = 0
  18252. // var laboratory_other_amt float64 = 0
  18253. //
  18254. // var treat_claa_sunmfee float64 = 0
  18255. // var treat_clab_amt float64 = 0
  18256. // var treat_other_amt float64 = 0
  18257. //
  18258. // for _, item := range order.HisOrderInfo {
  18259. // if item.MedChrgitmType == "01" { //床位费
  18260. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18261. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18262. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18263. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18264. // if item.ChrgitmLv == "1" {
  18265. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18266. // }
  18267. // if item.ChrgitmLv == "2" {
  18268. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18269. //
  18270. // }
  18271. // if item.ChrgitmLv == "3" {
  18272. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18273. // }
  18274. //
  18275. // }
  18276. //
  18277. // if item.MedChrgitmType == "03" { //检查费
  18278. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18279. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18280. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18281. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18282. // if item.ChrgitmLv == "1" {
  18283. //
  18284. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18285. //
  18286. // }
  18287. // if item.ChrgitmLv == "2" {
  18288. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18289. //
  18290. // }
  18291. // if item.ChrgitmLv == "3" {
  18292. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18293. // }
  18294. // }
  18295. //
  18296. // if item.MedChrgitmType == "04" { //化验费
  18297. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18298. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18299. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18300. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18301. // if item.ChrgitmLv == "1" {
  18302. //
  18303. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18304. //
  18305. // }
  18306. // if item.ChrgitmLv == "2" {
  18307. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18308. //
  18309. // }
  18310. // if item.ChrgitmLv == "3" {
  18311. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18312. // }
  18313. // }
  18314. //
  18315. // if item.MedChrgitmType == "05" { //治疗费
  18316. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18317. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18318. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18319. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18320. // if item.ChrgitmLv == "1" {
  18321. //
  18322. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18323. //
  18324. // }
  18325. // if item.ChrgitmLv == "2" {
  18326. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18327. //
  18328. // }
  18329. // if item.ChrgitmLv == "3" {
  18330. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18331. // }
  18332. // }
  18333. //
  18334. // if item.MedChrgitmType == "06" { //手术费
  18335. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18336. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18337. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18338. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18339. //
  18340. // if item.ChrgitmLv == "1" {
  18341. //
  18342. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18343. //
  18344. // }
  18345. // if item.ChrgitmLv == "2" {
  18346. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18347. //
  18348. // }
  18349. // if item.ChrgitmLv == "3" {
  18350. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18351. // }
  18352. // }
  18353. //
  18354. // if item.MedChrgitmType == "08" { //材料费
  18355. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18356. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18357. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18358. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18359. // if item.ChrgitmLv == "1" {
  18360. //
  18361. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18362. //
  18363. // }
  18364. // if item.ChrgitmLv == "2" {
  18365. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18366. //
  18367. // }
  18368. // if item.ChrgitmLv == "3" {
  18369. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18370. // }
  18371. // }
  18372. //
  18373. // if item.MedChrgitmType == "09" { //西药费
  18374. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18375. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18376. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18377. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18378. // if item.ChrgitmLv == "1" {
  18379. //
  18380. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18381. //
  18382. // }
  18383. // if item.ChrgitmLv == "2" {
  18384. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18385. //
  18386. // }
  18387. // if item.ChrgitmLv == "3" {
  18388. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18389. // }
  18390. // }
  18391. //
  18392. // if item.MedChrgitmType == "11" { //中成费
  18393. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18394. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18395. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18396. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18397. // if item.ChrgitmLv == "1" {
  18398. //
  18399. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18400. //
  18401. // }
  18402. // if item.ChrgitmLv == "2" {
  18403. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18404. //
  18405. // }
  18406. // if item.ChrgitmLv == "3" {
  18407. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18408. // }
  18409. // }
  18410. //
  18411. // if item.MedChrgitmType == "14" { //其他费
  18412. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18413. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18414. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18415. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18416. // if item.ChrgitmLv == "1" {
  18417. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18418. //
  18419. // }
  18420. // if item.ChrgitmLv == "2" {
  18421. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18422. //
  18423. // }
  18424. // if item.ChrgitmLv == "3" {
  18425. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18426. // }
  18427. // }
  18428. //
  18429. // }
  18430. //
  18431. // var iteminfoStructs []service.IteminfoStruct
  18432. //
  18433. // if bedCostTotal != 0 {
  18434. // iteminfo.MedChrgitm = "01"
  18435. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18436. // iteminfo.Amt = bedCostTotal
  18437. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18438. // iteminfo.ClabAmt = bed_clab_amt
  18439. // iteminfo.OthAmt = bed_other_amt
  18440. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18441. // }
  18442. //
  18443. // if checkCostTotal != 0 {
  18444. // iteminfo.MedChrgitm = "03"
  18445. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18446. // iteminfo.Amt = checkCostTotal
  18447. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18448. // iteminfo.ClabAmt = check_clab_amt
  18449. // iteminfo.OthAmt = check_other_amt
  18450. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18451. //
  18452. // }
  18453. //
  18454. // if laboratoryCostTotal != 0 {
  18455. // iteminfo.MedChrgitm = "04"
  18456. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18457. // iteminfo.Amt = laboratoryCostTotal
  18458. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18459. // iteminfo.ClabAmt = laboratory_clab_amt
  18460. // iteminfo.OthAmt = laboratory_other_amt
  18461. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18462. //
  18463. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18464. //
  18465. // }
  18466. //
  18467. // if treatCostTotal != 0 {
  18468. // iteminfo.MedChrgitm = "05"
  18469. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18470. // iteminfo.Amt = treatCostTotal
  18471. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18472. // iteminfo.ClabAmt = treat_clab_amt
  18473. // iteminfo.OthAmt = treat_other_amt
  18474. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18475. // //(struct4101.IteminfoStruct, iteminfo)
  18476. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18477. // }
  18478. //
  18479. // if operationCostTotal != 0 {
  18480. // iteminfo.MedChrgitm = "06"
  18481. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18482. // iteminfo.Amt = operationCostTotal
  18483. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18484. // iteminfo.ClabAmt = operation_clab_amt
  18485. // iteminfo.OthAmt = operation_other_amt
  18486. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18487. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18488. // }
  18489. //
  18490. // if materialCostTotal != 0 {
  18491. // iteminfo.MedChrgitm = "08"
  18492. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18493. // iteminfo.Amt = materialCostTotal
  18494. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18495. // iteminfo.ClabAmt = material_clab_amt
  18496. // iteminfo.OthAmt = material_other_amt
  18497. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18498. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18499. // }
  18500. //
  18501. // if westernMedicineCostTotal != 0 {
  18502. // iteminfo.MedChrgitm = "09"
  18503. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18504. // iteminfo.Amt = westernMedicineCostTotal
  18505. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18506. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18507. // iteminfo.OthAmt = westernMedicine_other_amt
  18508. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18509. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18510. //
  18511. // }
  18512. // if chineseTraditionalMedicineCostTotal != 0 {
  18513. // iteminfo.MedChrgitm = "11"
  18514. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18515. // iteminfo.Amt = westernMedicineCostTotal
  18516. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18517. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18518. // iteminfo.OthAmt = westernMedicine_other_amt
  18519. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18520. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18521. //
  18522. // }
  18523. // if otherCostTotal != 0 {
  18524. // iteminfo.MedChrgitm = "14"
  18525. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18526. // iteminfo.Amt = otherCostTotal
  18527. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18528. // iteminfo.ClabAmt = other_clab_amt
  18529. // iteminfo.OthAmt = other_other_amt
  18530. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18531. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18532. //
  18533. // }
  18534. // struct4101.IteminfoStruct = iteminfoStructs
  18535. // struct4101.Ntly = "中国"
  18536. // struct4101.AdmCaty = "A03.06"
  18537. //
  18538. // struct4101.DoctorName = doctor.UserName
  18539. // struct4101.DoctorCode = doctor.DoctorNumber
  18540. //
  18541. // var res ResultSeventeen
  18542. //
  18543. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18544. // struct4101.BillCode = order.Number
  18545. // struct4101.BillNo = order.SetlId
  18546. // var resOther ResultSeventeenOther
  18547. // var pp models.PublicParams
  18548. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18549. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18550. // pp.FixmedinsName = miConfig.OrgName
  18551. // pp.FixmedinsCode = miConfig.Code
  18552. // pp.RequestUrl = miConfig.Url
  18553. // pp.Cainfo = miConfig.Cainfo
  18554. // pp.SecretKey = miConfig.SecretKey
  18555. // pp.AccessKey = miConfig.AccessKey
  18556. // pp.OpterName = curRoles.UserName
  18557. //
  18558. // client := &http.Client{}
  18559. // var req *http.Request
  18560. // data := make(map[string]interface{})
  18561. // data["struct4101"] = struct4101
  18562. // data["pp"] = pp
  18563. // bytesData, _ := json.Marshal(data)
  18564. // if miConfig.MdtrtareaAdmvs == "320921" {
  18565. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18566. // } else {
  18567. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18568. // }
  18569. // resp, _ := client.Do(req)
  18570. // defer resp.Body.Close()
  18571. // body, ioErr := ioutil.ReadAll(resp.Body)
  18572. // if ioErr != nil {
  18573. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18575. // return
  18576. // }
  18577. // var respJSON map[string]interface{}
  18578. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18579. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18581. // return
  18582. // }
  18583. //
  18584. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18585. // userJSONBytes, _ := json.Marshal(respJSON)
  18586. // fmt.Println("log")
  18587. // fmt.Println(string(userJSONBytes))
  18588. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18589. // utils.ErrorLog("解析失败:%v", err)
  18590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18591. // return
  18592. // }
  18593. // res.InfRefmsgid = resOther.InfRefmsgid
  18594. // res.Output = resOther.Output
  18595. // res.ErrMsg = resOther.ErrMsg
  18596. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18597. // res.Infcode = infocode
  18598. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18599. //
  18600. // var pp models.PublicParams
  18601. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18602. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18603. // pp.FixmedinsName = miConfig.OrgName
  18604. // pp.FixmedinsCode = miConfig.Code
  18605. // pp.RequestUrl = miConfig.Url
  18606. // pp.Cainfo = miConfig.Cainfo
  18607. // pp.SecretKey = miConfig.SecretKey
  18608. // pp.AccessKey = miConfig.AccessKey
  18609. // pp.OpterName = curRoles.UserName
  18610. // result, _ := service.Jxyb4101(struct4101, pp)
  18611. // var dat map[string]interface{}
  18612. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18613. // fmt.Println(dat)
  18614. // } else {
  18615. // fmt.Println(err)
  18616. // }
  18617. // userJSONBytes, _ := json.Marshal(dat)
  18618. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18619. // utils.ErrorLog("解析失败:%v", err)
  18620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18621. // return
  18622. // }
  18623. //
  18624. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18625. // var pp models.PublicParams
  18626. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18627. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18628. // pp.FixmedinsName = miConfig.OrgName
  18629. // pp.FixmedinsCode = miConfig.Code
  18630. // pp.RequestUrl = miConfig.Url
  18631. // pp.Cainfo = miConfig.Cainfo
  18632. // pp.SecretKey = miConfig.SecretKey
  18633. // pp.AccessKey = miConfig.AccessKey
  18634. // pp.OpterName = curRoles.UserName
  18635. // result, _ := service.Hnyb4101(struct4101, pp)
  18636. // var dat map[string]interface{}
  18637. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18638. // fmt.Println(dat)
  18639. // } else {
  18640. // fmt.Println(err)
  18641. // }
  18642. // userJSONBytes, _ := json.Marshal(dat)
  18643. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18644. // utils.ErrorLog("解析失败:%v", err)
  18645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18646. // return
  18647. // }
  18648. //
  18649. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18650. // var resOther ResultSeventeenOther
  18651. //
  18652. // var pp models.PublicParams
  18653. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18654. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18655. // pp.FixmedinsName = miConfig.OrgName
  18656. // pp.FixmedinsCode = miConfig.Code
  18657. // pp.RequestUrl = miConfig.Url
  18658. // pp.Cainfo = miConfig.Cainfo
  18659. // pp.SecretKey = miConfig.SecretKey
  18660. // pp.AccessKey = miConfig.AccessKey
  18661. // pp.OpterName = curRoles.UserName
  18662. // client := &http.Client{}
  18663. // var req *http.Request
  18664. // data := make(map[string]interface{})
  18665. // data["struct4101"] = struct4101
  18666. // data["pp"] = pp
  18667. // bytesData, _ := json.Marshal(data)
  18668. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18669. // resp, _ := client.Do(req)
  18670. // defer resp.Body.Close()
  18671. // body, ioErr := ioutil.ReadAll(resp.Body)
  18672. // if ioErr != nil {
  18673. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18674. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18675. // return
  18676. // }
  18677. // var respJSON map[string]interface{}
  18678. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18679. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18681. // return
  18682. // }
  18683. //
  18684. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18685. // userJSONBytes, _ := json.Marshal(respJSON)
  18686. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18687. // utils.ErrorLog("解析失败:%v", err)
  18688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18689. // return
  18690. // }
  18691. // res.InfRefmsgid = resOther.InfRefmsgid
  18692. // res.Output = resOther.Output
  18693. // res.ErrMsg = resOther.ErrMsg
  18694. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18695. // res.Infcode = infocode
  18696. //
  18697. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18698. // var pp models.PublicParams
  18699. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18700. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18701. // pp.FixmedinsName = miConfig.OrgName
  18702. // pp.FixmedinsCode = miConfig.Code
  18703. // pp.RequestUrl = miConfig.Url
  18704. // pp.Cainfo = miConfig.Cainfo
  18705. // pp.SecretKey = miConfig.SecretKey
  18706. // pp.AccessKey = miConfig.AccessKey
  18707. // pp.OpterName = curRoles.UserName
  18708. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18709. // fmt.Println(requestLog)
  18710. // fmt.Println(errMsgLog)
  18711. //
  18712. // saveLog(result, requestLog, "4101a", "上传清单")
  18713. //
  18714. // var dat map[string]interface{}
  18715. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18716. // fmt.Println(dat)
  18717. // } else {
  18718. // fmt.Println(err)
  18719. // }
  18720. // userJSONBytes, _ := json.Marshal(dat)
  18721. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18722. // utils.ErrorLog("解析失败:%v", err)
  18723. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18724. // return
  18725. // }
  18726. //
  18727. // } else {
  18728. //
  18729. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18730. // var dat map[string]interface{}
  18731. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18732. // fmt.Println(dat)
  18733. // } else {
  18734. // fmt.Println(err)
  18735. // }
  18736. // userJSONBytes, _ := json.Marshal(dat)
  18737. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18738. // utils.ErrorLog("解析失败:%v", err)
  18739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18740. // return
  18741. // }
  18742. // }
  18743. //
  18744. // if res.Infcode != 0 {
  18745. // adminUser := c.GetAdminUserInfo()
  18746. // errlog := &models.HisOrderError{
  18747. // UserOrgId: adminUser.CurrentOrgId,
  18748. // Ctime: time.Now().Unix(),
  18749. // Mtime: time.Now().Unix(),
  18750. // ErrMsg: res.ErrMsg,
  18751. // Status: 1,
  18752. // PatientId: order.ID,
  18753. // Stage: 10265,
  18754. // }
  18755. // service.CreateErrMsgLog(errlog)
  18756. // continue
  18757. // } else {
  18758. // //order.FaPiaoNumber = zero
  18759. // //order.FaPiaoCode = last_order.FaPiaoCode
  18760. // //service.UpdateOrder(order)
  18761. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18762. // Number: res.Output.SetlListId,
  18763. // Status: 1,
  18764. // Ctime: time.Now().Unix(),
  18765. // Mtime: time.Now().Unix(),
  18766. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18767. // IsUpload: 1,
  18768. // OrderId: order.ID,
  18769. // }
  18770. // service.CreateUploadRecord(hisFundSettleListResult)
  18771. // c.ServeSuccessJSON(map[string]interface{}{
  18772. // "msg": "上传成功",
  18773. // "result": hisFundSettleListResult,
  18774. // })
  18775. // continue
  18776. // }
  18777. // }
  18778. //}
  18779. func (c *HisApiController) GetbatchSettleList() {
  18780. //order_id, _ := c.GetInt64("order_id")
  18781. admin_user_id, _ := c.GetInt64("admin_user_id")
  18782. orders, _ := service.GetAllHisOrderTwo10485()
  18783. for _, item := range orders {
  18784. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18785. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18786. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18787. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18788. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18789. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18790. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18791. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18792. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18793. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18794. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18795. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18796. //fmt.Println(count)
  18797. //var zero string
  18798. //number := count + 1
  18799. //if number >= 1000 {
  18800. // zero = "0000" + strconv.FormatInt(number, 10)
  18801. //} else if number >= 10000 {
  18802. // zero = "000" + strconv.FormatInt(number, 10)
  18803. //} else if number >= 100000 {
  18804. // zero = "00" + strconv.FormatInt(number, 10)
  18805. //} else if number >= 1000000 {
  18806. // zero = "0" + strconv.FormatInt(number, 10)
  18807. //} else {
  18808. // zero = strconv.FormatInt(number, 10)
  18809. //}
  18810. //fmt.Println(zero)
  18811. struct4101 := service.Struct4101{
  18812. PsnNo: order.PsnNo,
  18813. MdtrtId: order.MdtrtId,
  18814. SetlId: order.SetlId,
  18815. PsnName: order.PsnName,
  18816. Gend: order.Gend,
  18817. Brdy: his.Brdy,
  18818. Age: his.Age,
  18819. Naty: order.Naty,
  18820. PatnCertType: "01",
  18821. Certno: order.Certno,
  18822. Prfs: "90",
  18823. ConerName: roles[0].UserName,
  18824. PatnRlts: "99",
  18825. ConerAddr: miConfig.OrgName,
  18826. ConerTel: admin.Mobile,
  18827. HiType: order.Insutype,
  18828. Insuplc: miConfig.InsuplcAdmdvs,
  18829. MaindiagFlag: "1",
  18830. BillCode: order.SetlId,
  18831. BillNo: order.SetlId,
  18832. BizSn: order.Number,
  18833. PsnSelfPay: order.PsnPartAmt,
  18834. PsnOwnPay: order.PsnPartAmt,
  18835. AcctPay: order.AcctPay,
  18836. PsnCashpay: order.PsnCashPay,
  18837. HiPaymtd: "1",
  18838. Hsorg: miConfig.InsuplcAdmdvs,
  18839. HsorgOpter: miConfig.InsuplcAdmdvs,
  18840. MedinsFillPsn: curRoles.UserName,
  18841. MedinsFillDept: miConfig.OrgName,
  18842. IptMedType: "2",
  18843. }
  18844. struct4101.SetlBegnDate = order.SetlTime
  18845. struct4101.SetlEndDate = order.SetlTime
  18846. time_arr := strings.Split(order.SetlTime, " ")
  18847. struct4101.AdmTime = time_arr[0]
  18848. struct4101.AdmEndTime = time_arr[0]
  18849. //var rf []CustomFundPay
  18850. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18851. //
  18852. //var tempFunPays []service.CustomStruct
  18853. //for _, item := range rf {
  18854. // var tempFunPay service.CustomStruct
  18855. // tempFunPay.FundPayamt = item.FundPayamt
  18856. // tempFunPay.FundPayType = item.FundPayType
  18857. // tempFunPays = append(tempFunPays, tempFunPay)
  18858. //}
  18859. //struct4101.CustomStruct = tempFunPays
  18860. var tempDiaginfos []service.DiaginfoStructTwo
  18861. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18862. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18863. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18864. var config []*models.HisXtDiagnoseConfig
  18865. for _, item := range diagnosis_ids {
  18866. id, _ := strconv.ParseInt(item, 10, 64)
  18867. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18868. config = append(config, &diagnosisConfig)
  18869. }
  18870. for index, item := range config {
  18871. if index == 0 {
  18872. var tempDiaginfo service.DiaginfoStructTwo
  18873. tempDiaginfo.DiagCode = item.CountryCode
  18874. tempDiaginfo.DiagName = item.CountryContentName
  18875. tempDiaginfo.DiagType = "1"
  18876. tempDiaginfo.MaindiagFlag = "1"
  18877. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18878. } else {
  18879. var tempDiaginfo service.DiaginfoStructTwo
  18880. tempDiaginfo.DiagCode = item.CountryCode
  18881. tempDiaginfo.DiagName = item.CountryContentName
  18882. tempDiaginfo.DiagType = "1"
  18883. tempDiaginfo.MaindiagFlag = "0"
  18884. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18885. }
  18886. }
  18887. struct4101.Diseinfo = tempDiaginfos
  18888. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18889. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18890. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18891. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18892. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18893. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18894. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18895. var iteminfo service.IteminfoStruct
  18896. var bedCostTotal float64 = 0 //床位总费
  18897. var bedCostSelfTotal float64 = 0 //床位自费
  18898. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18899. var operationCostTotal float64 = 0 //手术费
  18900. var operationCostSelfTotal float64 = 0 //手术费
  18901. var operationCostPartSelfTotal float64 = 0 //手术费
  18902. var otherCostTotal float64 = 0 //其他费用
  18903. var otherCostSelfTotal float64 = 0 //其他费用
  18904. var otherCostPartSelfTotal float64 = 0 //其他费用
  18905. var materialCostTotal float64 = 0 //材料费
  18906. var materialCostSelfTotal float64 = 0 //材料费
  18907. var materialCostPartSelfTotal float64 = 0 //材料费
  18908. var westernMedicineCostTotal float64 = 0 //西药费
  18909. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18910. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18911. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18912. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18913. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18914. var checkCostTotal float64 = 0 //检查费
  18915. var checkCostSelfTotal float64 = 0 //检查费
  18916. var checkCostPartSelfTotal float64 = 0 //检查费
  18917. var laboratoryCostTotal float64 = 0 //化验费
  18918. var laboratoryCostSelfTotal float64 = 0 //化验费
  18919. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18920. var treatCostTotal float64 = 0 //治疗费用
  18921. var treatCostSelfTotal float64 = 0 //治疗费用
  18922. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18923. decimal.DivisionPrecision = 2
  18924. var bed_fulamt_ownpay_amt float64 = 0
  18925. var operation_fulamt_ownpay_amt float64 = 0
  18926. var other_fulamt_ownpay_amt float64 = 0
  18927. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18928. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18929. var check_fulamt_ownpay_amt float64 = 0
  18930. var material_fulamt_ownpay_amt float64 = 0
  18931. var laboratory_fulamt_ownpay_amt float64 = 0
  18932. var treat_fulamt_ownpay_amt float64 = 0
  18933. var bed_claa_sunmfee float64 = 0
  18934. var bed_clab_amt float64 = 0
  18935. var bed_other_amt float64 = 0
  18936. var operation_claa_sunmfee float64 = 0
  18937. var operation_clab_amt float64 = 0
  18938. var operation_other_amt float64 = 0
  18939. var other_claa_sunmfee float64 = 0
  18940. var other_clab_amt float64 = 0
  18941. var other_other_amt float64 = 0
  18942. var westernMedicine_claa_sunmfee float64 = 0
  18943. var westernMedicine_clab_amt float64 = 0
  18944. var westernMedicine_other_amt float64 = 0
  18945. var chineseTraditional_claa_sunmfee float64 = 0
  18946. var chineseTraditional_clab_amt float64 = 0
  18947. var chineseTraditional_other_amt float64 = 0
  18948. var check_claa_sunmfee float64 = 0
  18949. var check_clab_amt float64 = 0
  18950. var check_other_amt float64 = 0
  18951. var material_claa_sunmfee float64 = 0
  18952. var material_clab_amt float64 = 0
  18953. var material_other_amt float64 = 0
  18954. var laboratory_claa_sunmfee float64 = 0
  18955. var laboratory_clab_amt float64 = 0
  18956. var laboratory_other_amt float64 = 0
  18957. var treat_claa_sunmfee float64 = 0
  18958. var treat_clab_amt float64 = 0
  18959. var treat_other_amt float64 = 0
  18960. for _, item := range order.HisOrderInfo {
  18961. if item.MedChrgitmType == "01" { //床位费
  18962. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18963. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18964. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18965. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18966. if item.ChrgitmLv == "1" {
  18967. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18968. }
  18969. if item.ChrgitmLv == "2" {
  18970. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18971. }
  18972. if item.ChrgitmLv == "3" {
  18973. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18974. }
  18975. }
  18976. if item.MedChrgitmType == "03" { //检查费
  18977. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18978. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18979. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18980. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18981. if item.ChrgitmLv == "1" {
  18982. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18983. }
  18984. if item.ChrgitmLv == "2" {
  18985. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18986. }
  18987. if item.ChrgitmLv == "3" {
  18988. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18989. }
  18990. }
  18991. if item.MedChrgitmType == "04" { //化验费
  18992. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18993. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18994. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18995. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18996. if item.ChrgitmLv == "1" {
  18997. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18998. }
  18999. if item.ChrgitmLv == "2" {
  19000. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19001. }
  19002. if item.ChrgitmLv == "3" {
  19003. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19004. }
  19005. }
  19006. if item.MedChrgitmType == "05" { //治疗费
  19007. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19008. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19009. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19010. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19011. if item.ChrgitmLv == "1" {
  19012. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19013. }
  19014. if item.ChrgitmLv == "2" {
  19015. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19016. }
  19017. if item.ChrgitmLv == "3" {
  19018. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19019. }
  19020. }
  19021. if item.MedChrgitmType == "06" { //手术费
  19022. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19023. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19024. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19025. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19026. if item.ChrgitmLv == "1" {
  19027. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19028. }
  19029. if item.ChrgitmLv == "2" {
  19030. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19031. }
  19032. if item.ChrgitmLv == "3" {
  19033. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19034. }
  19035. }
  19036. if item.MedChrgitmType == "08" { //材料费
  19037. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19038. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19039. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19040. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19041. if item.ChrgitmLv == "1" {
  19042. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19043. }
  19044. if item.ChrgitmLv == "2" {
  19045. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19046. }
  19047. if item.ChrgitmLv == "3" {
  19048. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19049. }
  19050. }
  19051. if item.MedChrgitmType == "09" { //西药费
  19052. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19053. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19054. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19055. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19056. if item.ChrgitmLv == "1" {
  19057. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19058. }
  19059. if item.ChrgitmLv == "2" {
  19060. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19061. }
  19062. if item.ChrgitmLv == "3" {
  19063. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19064. }
  19065. }
  19066. if item.MedChrgitmType == "11" { //中成费
  19067. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19068. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19069. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19070. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19071. if item.ChrgitmLv == "1" {
  19072. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19073. }
  19074. if item.ChrgitmLv == "2" {
  19075. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19076. }
  19077. if item.ChrgitmLv == "3" {
  19078. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19079. }
  19080. }
  19081. if item.MedChrgitmType == "14" { //其他费
  19082. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19083. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19084. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19085. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19086. if item.ChrgitmLv == "1" {
  19087. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19088. }
  19089. if item.ChrgitmLv == "2" {
  19090. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19091. }
  19092. if item.ChrgitmLv == "3" {
  19093. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19094. }
  19095. }
  19096. }
  19097. var iteminfoStructs []service.IteminfoStruct
  19098. if bedCostTotal != 0 {
  19099. iteminfo.MedChrgitm = "01"
  19100. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19101. iteminfo.Amt = bedCostTotal
  19102. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19103. iteminfo.ClabAmt = bed_clab_amt
  19104. iteminfo.OthAmt = bed_other_amt
  19105. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19106. }
  19107. if checkCostTotal != 0 {
  19108. iteminfo.MedChrgitm = "03"
  19109. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19110. iteminfo.Amt = checkCostTotal
  19111. iteminfo.ClaaSumfee = check_claa_sunmfee
  19112. iteminfo.ClabAmt = check_clab_amt
  19113. iteminfo.OthAmt = check_other_amt
  19114. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19115. }
  19116. if laboratoryCostTotal != 0 {
  19117. iteminfo.MedChrgitm = "04"
  19118. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19119. iteminfo.Amt = laboratoryCostTotal
  19120. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19121. iteminfo.ClabAmt = laboratory_clab_amt
  19122. iteminfo.OthAmt = laboratory_other_amt
  19123. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19124. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19125. }
  19126. if treatCostTotal != 0 {
  19127. iteminfo.MedChrgitm = "05"
  19128. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19129. iteminfo.Amt = treatCostTotal
  19130. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19131. iteminfo.ClabAmt = treat_clab_amt
  19132. iteminfo.OthAmt = treat_other_amt
  19133. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19134. //(struct4101.IteminfoStruct, iteminfo)
  19135. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19136. }
  19137. if operationCostTotal != 0 {
  19138. iteminfo.MedChrgitm = "06"
  19139. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19140. iteminfo.Amt = operationCostTotal
  19141. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19142. iteminfo.ClabAmt = operation_clab_amt
  19143. iteminfo.OthAmt = operation_other_amt
  19144. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19145. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19146. }
  19147. if materialCostTotal != 0 {
  19148. iteminfo.MedChrgitm = "08"
  19149. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19150. iteminfo.Amt = materialCostTotal
  19151. iteminfo.ClaaSumfee = material_claa_sunmfee
  19152. iteminfo.ClabAmt = material_clab_amt
  19153. iteminfo.OthAmt = material_other_amt
  19154. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19155. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19156. }
  19157. if westernMedicineCostTotal != 0 {
  19158. iteminfo.MedChrgitm = "09"
  19159. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19160. iteminfo.Amt = westernMedicineCostTotal
  19161. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19162. iteminfo.ClabAmt = westernMedicine_clab_amt
  19163. iteminfo.OthAmt = westernMedicine_other_amt
  19164. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19165. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19166. }
  19167. if chineseTraditionalMedicineCostTotal != 0 {
  19168. iteminfo.MedChrgitm = "11"
  19169. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19170. iteminfo.Amt = westernMedicineCostTotal
  19171. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19172. iteminfo.ClabAmt = westernMedicine_clab_amt
  19173. iteminfo.OthAmt = westernMedicine_other_amt
  19174. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19175. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19176. }
  19177. if otherCostTotal != 0 {
  19178. iteminfo.MedChrgitm = "14"
  19179. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19180. iteminfo.Amt = otherCostTotal
  19181. iteminfo.ClaaSumfee = other_claa_sunmfee
  19182. iteminfo.ClabAmt = other_clab_amt
  19183. iteminfo.OthAmt = other_other_amt
  19184. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19185. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19186. }
  19187. struct4101.IteminfoStruct = iteminfoStructs
  19188. struct4101.Ntly = "中国"
  19189. struct4101.AdmCaty = "A03.06"
  19190. struct4101.DoctorName = doctor.UserName
  19191. struct4101.DoctorCode = doctor.DoctorNumber
  19192. var res ResultSeventeen
  19193. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19194. struct4101.BillCode = order.Number
  19195. struct4101.BillNo = order.SetlId
  19196. var resOther ResultSeventeenOther
  19197. var pp models.PublicParams
  19198. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19199. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19200. pp.FixmedinsName = miConfig.OrgName
  19201. pp.FixmedinsCode = miConfig.Code
  19202. pp.RequestUrl = miConfig.Url
  19203. pp.Cainfo = miConfig.Cainfo
  19204. pp.SecretKey = miConfig.SecretKey
  19205. pp.AccessKey = miConfig.AccessKey
  19206. pp.OpterName = curRoles.UserName
  19207. client := &http.Client{}
  19208. var req *http.Request
  19209. data := make(map[string]interface{})
  19210. data["struct4101"] = struct4101
  19211. data["pp"] = pp
  19212. bytesData, _ := json.Marshal(data)
  19213. if miConfig.MdtrtareaAdmvs == "320921" {
  19214. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19215. } else {
  19216. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19217. }
  19218. resp, _ := client.Do(req)
  19219. defer resp.Body.Close()
  19220. body, ioErr := ioutil.ReadAll(resp.Body)
  19221. if ioErr != nil {
  19222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19224. return
  19225. }
  19226. var respJSON map[string]interface{}
  19227. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19230. return
  19231. }
  19232. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19233. userJSONBytes, _ := json.Marshal(respJSON)
  19234. fmt.Println("log")
  19235. fmt.Println(string(userJSONBytes))
  19236. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19237. utils.ErrorLog("解析失败:%v", err)
  19238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19239. return
  19240. }
  19241. res.InfRefmsgid = resOther.InfRefmsgid
  19242. res.Output = resOther.Output
  19243. res.ErrMsg = resOther.ErrMsg
  19244. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19245. res.Infcode = infocode
  19246. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19247. var pp models.PublicParams
  19248. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19249. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19250. pp.FixmedinsName = miConfig.OrgName
  19251. pp.FixmedinsCode = miConfig.Code
  19252. pp.RequestUrl = miConfig.Url
  19253. pp.Cainfo = miConfig.Cainfo
  19254. pp.SecretKey = miConfig.SecretKey
  19255. pp.AccessKey = miConfig.AccessKey
  19256. pp.OpterName = curRoles.UserName
  19257. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19258. result, _ := service.Jxyb4101(struct4101, pp)
  19259. var dat map[string]interface{}
  19260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19261. fmt.Println(dat)
  19262. } else {
  19263. fmt.Println(err)
  19264. }
  19265. userJSONBytes, _ := json.Marshal(dat)
  19266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19267. utils.ErrorLog("解析失败:%v", err)
  19268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19269. return
  19270. }
  19271. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19272. var pp models.PublicParams
  19273. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19274. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19275. pp.FixmedinsName = miConfig.OrgName
  19276. pp.FixmedinsCode = miConfig.Code
  19277. pp.RequestUrl = miConfig.Url
  19278. pp.Cainfo = miConfig.Cainfo
  19279. pp.SecretKey = miConfig.SecretKey
  19280. pp.AccessKey = miConfig.AccessKey
  19281. pp.OpterName = curRoles.UserName
  19282. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19283. result, _ := service.Jxyb4101(struct4101, pp)
  19284. var dat map[string]interface{}
  19285. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19286. fmt.Println(dat)
  19287. } else {
  19288. fmt.Println(err)
  19289. }
  19290. userJSONBytes, _ := json.Marshal(dat)
  19291. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19292. utils.ErrorLog("解析失败:%v", err)
  19293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19294. return
  19295. }
  19296. } else if miConfig.MdtrtareaAdmvs == "360100" {
  19297. var pp models.PublicParams
  19298. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19299. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19300. pp.FixmedinsName = miConfig.OrgName
  19301. pp.FixmedinsCode = miConfig.Code
  19302. pp.RequestUrl = miConfig.Url
  19303. pp.Cainfo = miConfig.Cainfo
  19304. pp.SecretKey = miConfig.SecretKey
  19305. pp.AccessKey = miConfig.AccessKey
  19306. pp.OpterName = curRoles.UserName
  19307. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19308. result, _ := service.Jxyb4101(struct4101, pp)
  19309. var dat map[string]interface{}
  19310. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19311. fmt.Println(dat)
  19312. } else {
  19313. fmt.Println(err)
  19314. }
  19315. userJSONBytes, _ := json.Marshal(dat)
  19316. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19317. utils.ErrorLog("解析失败:%v", err)
  19318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19319. return
  19320. }
  19321. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19322. var pp models.PublicParams
  19323. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19324. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19325. pp.FixmedinsName = miConfig.OrgName
  19326. pp.FixmedinsCode = miConfig.Code
  19327. pp.RequestUrl = miConfig.Url
  19328. pp.Cainfo = miConfig.Cainfo
  19329. pp.SecretKey = miConfig.SecretKey
  19330. pp.AccessKey = miConfig.AccessKey
  19331. pp.OpterName = curRoles.UserName
  19332. result, _ := service.Hnyb4101(struct4101, pp)
  19333. var dat map[string]interface{}
  19334. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19335. fmt.Println(dat)
  19336. } else {
  19337. fmt.Println(err)
  19338. }
  19339. userJSONBytes, _ := json.Marshal(dat)
  19340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19341. utils.ErrorLog("解析失败:%v", err)
  19342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19343. return
  19344. }
  19345. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19346. var resOther ResultSeventeenOther
  19347. var pp models.PublicParams
  19348. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19349. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19350. pp.FixmedinsName = miConfig.OrgName
  19351. pp.FixmedinsCode = miConfig.Code
  19352. pp.RequestUrl = miConfig.Url
  19353. pp.Cainfo = miConfig.Cainfo
  19354. pp.SecretKey = miConfig.SecretKey
  19355. pp.AccessKey = miConfig.AccessKey
  19356. pp.OpterName = curRoles.UserName
  19357. client := &http.Client{}
  19358. var req *http.Request
  19359. data := make(map[string]interface{})
  19360. data["struct4101"] = struct4101
  19361. data["pp"] = pp
  19362. bytesData, _ := json.Marshal(data)
  19363. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19364. resp, _ := client.Do(req)
  19365. defer resp.Body.Close()
  19366. body, ioErr := ioutil.ReadAll(resp.Body)
  19367. if ioErr != nil {
  19368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19370. return
  19371. }
  19372. var respJSON map[string]interface{}
  19373. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19376. return
  19377. }
  19378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19379. userJSONBytes, _ := json.Marshal(respJSON)
  19380. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19381. utils.ErrorLog("解析失败:%v", err)
  19382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19383. return
  19384. }
  19385. res.InfRefmsgid = resOther.InfRefmsgid
  19386. res.Output = resOther.Output
  19387. res.ErrMsg = resOther.ErrMsg
  19388. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19389. res.Infcode = infocode
  19390. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19391. var pp models.PublicParams
  19392. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19393. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19394. pp.FixmedinsName = miConfig.OrgName
  19395. pp.FixmedinsCode = miConfig.Code
  19396. pp.RequestUrl = miConfig.Url
  19397. pp.Cainfo = miConfig.Cainfo
  19398. pp.SecretKey = miConfig.SecretKey
  19399. pp.AccessKey = miConfig.AccessKey
  19400. pp.OpterName = curRoles.UserName
  19401. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19402. fmt.Println(requestLog)
  19403. fmt.Println(errMsgLog)
  19404. saveLog(result, requestLog, "4101a", "上传清单")
  19405. var dat map[string]interface{}
  19406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19407. fmt.Println(dat)
  19408. } else {
  19409. fmt.Println(err)
  19410. }
  19411. userJSONBytes, _ := json.Marshal(dat)
  19412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19413. utils.ErrorLog("解析失败:%v", err)
  19414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19415. return
  19416. }
  19417. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19418. var pp models.PublicParams
  19419. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19420. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19421. pp.FixmedinsName = miConfig.OrgName
  19422. pp.FixmedinsCode = miConfig.Code
  19423. pp.RequestUrl = miConfig.Url
  19424. pp.Cainfo = miConfig.Cainfo
  19425. pp.SecretKey = miConfig.SecretKey
  19426. pp.AccessKey = miConfig.AccessKey
  19427. pp.OpterName = curRoles.UserName
  19428. client := &http.Client{}
  19429. var req *http.Request
  19430. data := make(map[string]interface{})
  19431. data["struct4101"] = struct4101
  19432. data["pp"] = pp
  19433. bytesData, _ := json.Marshal(data)
  19434. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19435. resp, _ := client.Do(req)
  19436. defer resp.Body.Close()
  19437. body, ioErr := ioutil.ReadAll(resp.Body)
  19438. if ioErr != nil {
  19439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19441. return
  19442. }
  19443. var respJSON map[string]interface{}
  19444. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19447. return
  19448. }
  19449. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19450. userJSONBytes, _ := json.Marshal(respJSON)
  19451. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19452. utils.ErrorLog("解析失败:%v", err)
  19453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19454. return
  19455. }
  19456. } else {
  19457. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19458. var dat map[string]interface{}
  19459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19460. fmt.Println(dat)
  19461. } else {
  19462. fmt.Println(err)
  19463. }
  19464. userJSONBytes, _ := json.Marshal(dat)
  19465. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19466. utils.ErrorLog("解析失败:%v", err)
  19467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19468. return
  19469. }
  19470. }
  19471. if res.Infcode != 0 {
  19472. errlog := &models.HisOrderError{
  19473. UserOrgId: order.UserOrgId,
  19474. Ctime: time.Now().Unix(),
  19475. Mtime: time.Now().Unix(),
  19476. ErrMsg: res.ErrMsg + "解析失败",
  19477. Status: 1,
  19478. PatientId: order.ID,
  19479. Stage: 10485,
  19480. }
  19481. service.CreateErrMsgLog(errlog)
  19482. continue
  19483. //c.ServeSuccessJSON(map[string]interface{}{
  19484. // "failed_code": -10,
  19485. // "msg": res.ErrMsg,
  19486. //})
  19487. } else {
  19488. //order.FaPiaoNumber = zero
  19489. //order.FaPiaoCode = last_order.FaPiaoCode
  19490. //service.UpdateOrder(order)
  19491. hisFundSettleListResult := &models.HisFundSettleListResult{
  19492. Number: res.Output.SetlListId,
  19493. Status: 1,
  19494. Ctime: time.Now().Unix(),
  19495. Mtime: time.Now().Unix(),
  19496. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19497. IsUpload: 1,
  19498. OrderId: order.ID,
  19499. }
  19500. service.CreateUploadRecord(hisFundSettleListResult)
  19501. continue
  19502. }
  19503. }
  19504. }
  19505. func (c *HisApiController) GetSettleList() {
  19506. order_id, _ := c.GetInt64("order_id")
  19507. admin_user_id, _ := c.GetInt64("admin_user_id")
  19508. order, _ := service.GetHisOrderByIDTwo(order_id)
  19509. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19510. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19511. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19512. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19513. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19514. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19515. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19516. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19517. if order.ID == 0 {
  19518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19519. return
  19520. }
  19521. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19522. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19523. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19524. //fmt.Println(count)
  19525. //var zero string
  19526. //number := count + 1
  19527. //if number >= 1000 {
  19528. // zero = "0000" + strconv.FormatInt(number, 10)
  19529. //} else if number >= 10000 {
  19530. // zero = "000" + strconv.FormatInt(number, 10)
  19531. //} else if number >= 100000 {
  19532. // zero = "00" + strconv.FormatInt(number, 10)
  19533. //} else if number >= 1000000 {
  19534. // zero = "0" + strconv.FormatInt(number, 10)
  19535. //} else {
  19536. // zero = strconv.FormatInt(number, 10)
  19537. //}
  19538. //fmt.Println(zero)
  19539. struct4101 := service.Struct4101{
  19540. PsnNo: order.PsnNo,
  19541. MdtrtId: order.MdtrtId,
  19542. SetlId: order.SetlId,
  19543. PsnName: order.PsnName,
  19544. Gend: order.Gend,
  19545. Brdy: his.Brdy,
  19546. Age: his.Age,
  19547. Naty: order.Naty,
  19548. PatnCertType: "01",
  19549. Certno: order.Certno,
  19550. Prfs: "90",
  19551. ConerName: roles[0].UserName,
  19552. PatnRlts: "99",
  19553. ConerAddr: miConfig.OrgName,
  19554. ConerTel: admin.Mobile,
  19555. HiType: order.Insutype,
  19556. Insuplc: miConfig.InsuplcAdmdvs,
  19557. MaindiagFlag: "1",
  19558. BillCode: order.SetlId,
  19559. BillNo: order.SetlId,
  19560. BizSn: order.Number,
  19561. PsnSelfPay: order.PsnPartAmt,
  19562. PsnOwnPay: order.PsnPartAmt,
  19563. AcctPay: order.AcctPay,
  19564. PsnCashpay: order.PsnCashPay,
  19565. HiPaymtd: "1",
  19566. Hsorg: miConfig.InsuplcAdmdvs,
  19567. HsorgOpter: miConfig.InsuplcAdmdvs,
  19568. MedinsFillPsn: curRoles.UserName,
  19569. MedinsFillDept: miConfig.OrgName,
  19570. IptMedType: "2",
  19571. }
  19572. struct4101.SetlBegnDate = order.SetlTime
  19573. struct4101.SetlEndDate = order.SetlTime
  19574. time_arr := strings.Split(order.SetlTime, " ")
  19575. struct4101.AdmTime = time_arr[0]
  19576. struct4101.AdmEndTime = time_arr[0]
  19577. //
  19578. //var rf []CustomFundPay
  19579. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19580. //
  19581. //var tempFunPays []service.CustomStruct
  19582. //for _, item := range rf {
  19583. // var tempFunPay service.CustomStruct
  19584. // tempFunPay.FundPayamt = item.FundPayamt
  19585. // tempFunPay.FundPayType = item.FundPayType
  19586. // tempFunPays = append(tempFunPays, tempFunPay)
  19587. //}
  19588. //struct4101.CustomStruct = tempFunPays
  19589. var tempDiaginfos []service.DiaginfoStructTwo
  19590. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19591. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19592. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19593. var config []*models.HisXtDiagnoseConfig
  19594. for _, item := range diagnosis_ids {
  19595. id, _ := strconv.ParseInt(item, 10, 64)
  19596. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19597. config = append(config, &diagnosisConfig)
  19598. }
  19599. if miConfig.Code == "H15049901371" {
  19600. //for _, item := range config {
  19601. // if item.ID == 138 {
  19602. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19603. var tempDiaginfo service.DiaginfoStructTwo
  19604. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19605. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19606. tempDiaginfo.DiagType = "1"
  19607. tempDiaginfo.MaindiagFlag = "1"
  19608. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19609. //}
  19610. //}
  19611. for _, item := range config {
  19612. if item.ID != 138 {
  19613. var tempDiaginfo service.DiaginfoStructTwo
  19614. tempDiaginfo.DiagCode = item.CountryCode
  19615. tempDiaginfo.DiagName = item.CountryContentName
  19616. tempDiaginfo.DiagType = "1"
  19617. tempDiaginfo.MaindiagFlag = "0"
  19618. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19619. }
  19620. }
  19621. } else {
  19622. for index, item := range config {
  19623. if index == 0 {
  19624. var tempDiaginfo service.DiaginfoStructTwo
  19625. tempDiaginfo.DiagCode = item.CountryCode
  19626. tempDiaginfo.DiagName = item.CountryContentName
  19627. tempDiaginfo.DiagType = "1"
  19628. tempDiaginfo.MaindiagFlag = "1"
  19629. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19630. } else {
  19631. var tempDiaginfo service.DiaginfoStructTwo
  19632. tempDiaginfo.DiagCode = item.CountryCode
  19633. tempDiaginfo.DiagName = item.CountryContentName
  19634. tempDiaginfo.DiagType = "1"
  19635. tempDiaginfo.MaindiagFlag = "0"
  19636. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19637. }
  19638. }
  19639. }
  19640. struct4101.Diseinfo = tempDiaginfos
  19641. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19642. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19643. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19644. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19645. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19646. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19647. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19648. var iteminfo service.IteminfoStruct
  19649. var bedCostTotal float64 = 0 //床位总费
  19650. var bedCostSelfTotal float64 = 0 //床位自费
  19651. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19652. var operationCostTotal float64 = 0 //手术费
  19653. var operationCostSelfTotal float64 = 0 //手术费
  19654. var operationCostPartSelfTotal float64 = 0 //手术费
  19655. var otherCostTotal float64 = 0 //其他费用
  19656. var otherCostSelfTotal float64 = 0 //其他费用
  19657. var otherCostPartSelfTotal float64 = 0 //其他费用
  19658. var materialCostTotal float64 = 0 //材料费
  19659. var materialCostSelfTotal float64 = 0 //材料费
  19660. var materialCostPartSelfTotal float64 = 0 //材料费
  19661. var westernMedicineCostTotal float64 = 0 //西药费
  19662. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19663. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19664. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19665. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19666. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19667. var checkCostTotal float64 = 0 //检查费
  19668. var checkCostSelfTotal float64 = 0 //检查费
  19669. var checkCostPartSelfTotal float64 = 0 //检查费
  19670. var laboratoryCostTotal float64 = 0 //化验费
  19671. var laboratoryCostSelfTotal float64 = 0 //化验费
  19672. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19673. var treatCostTotal float64 = 0 //治疗费用
  19674. var treatCostSelfTotal float64 = 0 //治疗费用
  19675. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19676. decimal.DivisionPrecision = 2
  19677. var bed_fulamt_ownpay_amt float64 = 0
  19678. var operation_fulamt_ownpay_amt float64 = 0
  19679. var other_fulamt_ownpay_amt float64 = 0
  19680. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19681. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19682. var check_fulamt_ownpay_amt float64 = 0
  19683. var material_fulamt_ownpay_amt float64 = 0
  19684. var laboratory_fulamt_ownpay_amt float64 = 0
  19685. var treat_fulamt_ownpay_amt float64 = 0
  19686. var bed_claa_sunmfee float64 = 0
  19687. var bed_clab_amt float64 = 0
  19688. var bed_other_amt float64 = 0
  19689. var operation_claa_sunmfee float64 = 0
  19690. var operation_clab_amt float64 = 0
  19691. var operation_other_amt float64 = 0
  19692. var other_claa_sunmfee float64 = 0
  19693. var other_clab_amt float64 = 0
  19694. var other_other_amt float64 = 0
  19695. var westernMedicine_claa_sunmfee float64 = 0
  19696. var westernMedicine_clab_amt float64 = 0
  19697. var westernMedicine_other_amt float64 = 0
  19698. var chineseTraditional_claa_sunmfee float64 = 0
  19699. var chineseTraditional_clab_amt float64 = 0
  19700. var chineseTraditional_other_amt float64 = 0
  19701. var check_claa_sunmfee float64 = 0
  19702. var check_clab_amt float64 = 0
  19703. var check_other_amt float64 = 0
  19704. var material_claa_sunmfee float64 = 0
  19705. var material_clab_amt float64 = 0
  19706. var material_other_amt float64 = 0
  19707. var laboratory_claa_sunmfee float64 = 0
  19708. var laboratory_clab_amt float64 = 0
  19709. var laboratory_other_amt float64 = 0
  19710. var treat_claa_sunmfee float64 = 0
  19711. var treat_clab_amt float64 = 0
  19712. var treat_other_amt float64 = 0
  19713. for _, item := range order.HisOrderInfo {
  19714. if item.MedChrgitmType == "01" { //床位费
  19715. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19716. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19717. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19718. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19719. if item.ChrgitmLv == "1" {
  19720. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19721. }
  19722. if item.ChrgitmLv == "2" {
  19723. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19724. }
  19725. if item.ChrgitmLv == "3" {
  19726. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19727. }
  19728. }
  19729. if item.MedChrgitmType == "03" { //检查费
  19730. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19731. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19732. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19733. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19734. if item.ChrgitmLv == "1" {
  19735. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19736. }
  19737. if item.ChrgitmLv == "2" {
  19738. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19739. }
  19740. if item.ChrgitmLv == "3" {
  19741. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19742. }
  19743. }
  19744. if item.MedChrgitmType == "04" { //化验费
  19745. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19746. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19747. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19748. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19749. if item.ChrgitmLv == "1" {
  19750. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19751. }
  19752. if item.ChrgitmLv == "2" {
  19753. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19754. }
  19755. if item.ChrgitmLv == "3" {
  19756. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19757. }
  19758. }
  19759. if item.MedChrgitmType == "05" { //治疗费
  19760. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19761. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19762. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19763. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19764. if item.ChrgitmLv == "1" {
  19765. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19766. }
  19767. if item.ChrgitmLv == "2" {
  19768. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19769. }
  19770. if item.ChrgitmLv == "3" {
  19771. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19772. }
  19773. }
  19774. if item.MedChrgitmType == "06" { //手术费
  19775. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19776. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19777. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19778. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19779. if item.ChrgitmLv == "1" {
  19780. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19781. }
  19782. if item.ChrgitmLv == "2" {
  19783. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19784. }
  19785. if item.ChrgitmLv == "3" {
  19786. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19787. }
  19788. }
  19789. if item.MedChrgitmType == "08" { //材料费
  19790. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19791. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19792. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19793. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19794. if item.ChrgitmLv == "1" {
  19795. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19796. }
  19797. if item.ChrgitmLv == "2" {
  19798. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19799. }
  19800. if item.ChrgitmLv == "3" {
  19801. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19802. }
  19803. }
  19804. if item.MedChrgitmType == "09" { //西药费
  19805. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19806. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19807. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19808. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19809. if item.ChrgitmLv == "1" {
  19810. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19811. }
  19812. if item.ChrgitmLv == "2" {
  19813. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19814. }
  19815. if item.ChrgitmLv == "3" {
  19816. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19817. }
  19818. }
  19819. if item.MedChrgitmType == "11" { //中成费
  19820. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19821. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19822. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19823. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19824. if item.ChrgitmLv == "1" {
  19825. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19826. }
  19827. if item.ChrgitmLv == "2" {
  19828. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19829. }
  19830. if item.ChrgitmLv == "3" {
  19831. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19832. }
  19833. }
  19834. if item.MedChrgitmType == "14" { //其他费
  19835. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19836. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19837. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19838. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19839. if item.ChrgitmLv == "1" {
  19840. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19841. }
  19842. if item.ChrgitmLv == "2" {
  19843. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19844. }
  19845. if item.ChrgitmLv == "3" {
  19846. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19847. }
  19848. }
  19849. }
  19850. var iteminfoStructs []service.IteminfoStruct
  19851. if bedCostTotal != 0 {
  19852. iteminfo.MedChrgitm = "01"
  19853. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19854. iteminfo.Amt = bedCostTotal
  19855. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19856. iteminfo.ClabAmt = bed_clab_amt
  19857. iteminfo.OthAmt = bed_other_amt
  19858. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19859. }
  19860. if checkCostTotal != 0 {
  19861. iteminfo.MedChrgitm = "03"
  19862. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19863. iteminfo.Amt = checkCostTotal
  19864. iteminfo.ClaaSumfee = check_claa_sunmfee
  19865. iteminfo.ClabAmt = check_clab_amt
  19866. iteminfo.OthAmt = check_other_amt
  19867. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19868. }
  19869. if laboratoryCostTotal != 0 {
  19870. iteminfo.MedChrgitm = "04"
  19871. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19872. iteminfo.Amt = laboratoryCostTotal
  19873. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19874. iteminfo.ClabAmt = laboratory_clab_amt
  19875. iteminfo.OthAmt = laboratory_other_amt
  19876. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19877. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19878. }
  19879. if treatCostTotal != 0 {
  19880. iteminfo.MedChrgitm = "05"
  19881. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19882. iteminfo.Amt = treatCostTotal
  19883. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19884. iteminfo.ClabAmt = treat_clab_amt
  19885. iteminfo.OthAmt = treat_other_amt
  19886. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19887. //(struct4101.IteminfoStruct, iteminfo)
  19888. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19889. }
  19890. if operationCostTotal != 0 {
  19891. iteminfo.MedChrgitm = "06"
  19892. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19893. iteminfo.Amt = operationCostTotal
  19894. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19895. iteminfo.ClabAmt = operation_clab_amt
  19896. iteminfo.OthAmt = operation_other_amt
  19897. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19898. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19899. }
  19900. if materialCostTotal != 0 {
  19901. iteminfo.MedChrgitm = "08"
  19902. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19903. iteminfo.Amt = materialCostTotal
  19904. iteminfo.ClaaSumfee = material_claa_sunmfee
  19905. iteminfo.ClabAmt = material_clab_amt
  19906. iteminfo.OthAmt = material_other_amt
  19907. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19908. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19909. }
  19910. if westernMedicineCostTotal != 0 {
  19911. iteminfo.MedChrgitm = "09"
  19912. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19913. iteminfo.Amt = westernMedicineCostTotal
  19914. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19915. iteminfo.ClabAmt = westernMedicine_clab_amt
  19916. iteminfo.OthAmt = westernMedicine_other_amt
  19917. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19918. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19919. }
  19920. if chineseTraditionalMedicineCostTotal != 0 {
  19921. iteminfo.MedChrgitm = "11"
  19922. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19923. iteminfo.Amt = westernMedicineCostTotal
  19924. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19925. iteminfo.ClabAmt = westernMedicine_clab_amt
  19926. iteminfo.OthAmt = westernMedicine_other_amt
  19927. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19928. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19929. }
  19930. if otherCostTotal != 0 {
  19931. iteminfo.MedChrgitm = "14"
  19932. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19933. iteminfo.Amt = otherCostTotal
  19934. iteminfo.ClaaSumfee = other_claa_sunmfee
  19935. iteminfo.ClabAmt = other_clab_amt
  19936. iteminfo.OthAmt = other_other_amt
  19937. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19938. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19939. }
  19940. struct4101.IteminfoStruct = iteminfoStructs
  19941. struct4101.Ntly = "中国"
  19942. struct4101.AdmCaty = "A03.06"
  19943. struct4101.DoctorName = doctor.UserName
  19944. struct4101.DoctorCode = doctor.DoctorNumber
  19945. var res ResultSeventeen
  19946. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19947. struct4101.BillCode = order.Number
  19948. struct4101.BillNo = order.SetlId
  19949. var resOther ResultSeventeenOther
  19950. var pp models.PublicParams
  19951. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19952. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19953. pp.FixmedinsName = miConfig.OrgName
  19954. pp.FixmedinsCode = miConfig.Code
  19955. pp.RequestUrl = miConfig.Url
  19956. pp.Cainfo = miConfig.Cainfo
  19957. pp.SecretKey = miConfig.SecretKey
  19958. pp.AccessKey = miConfig.AccessKey
  19959. pp.OpterName = curRoles.UserName
  19960. client := &http.Client{}
  19961. var req *http.Request
  19962. data := make(map[string]interface{})
  19963. data["struct4101"] = struct4101
  19964. data["pp"] = pp
  19965. bytesData, _ := json.Marshal(data)
  19966. if miConfig.MdtrtareaAdmvs == "320921" {
  19967. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19968. } else {
  19969. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19970. }
  19971. resp, _ := client.Do(req)
  19972. defer resp.Body.Close()
  19973. body, ioErr := ioutil.ReadAll(resp.Body)
  19974. if ioErr != nil {
  19975. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19977. return
  19978. }
  19979. var respJSON map[string]interface{}
  19980. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19983. return
  19984. }
  19985. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19986. userJSONBytes, _ := json.Marshal(respJSON)
  19987. fmt.Println("log")
  19988. fmt.Println(string(userJSONBytes))
  19989. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19990. utils.ErrorLog("解析失败:%v", err)
  19991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19992. return
  19993. }
  19994. res.InfRefmsgid = resOther.InfRefmsgid
  19995. res.Output = resOther.Output
  19996. res.ErrMsg = resOther.ErrMsg
  19997. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19998. res.Infcode = infocode
  19999. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20000. var pp models.PublicParams
  20001. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20002. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20003. pp.FixmedinsName = miConfig.OrgName
  20004. pp.FixmedinsCode = miConfig.Code
  20005. pp.RequestUrl = miConfig.Url
  20006. pp.Cainfo = miConfig.Cainfo
  20007. pp.SecretKey = miConfig.SecretKey
  20008. pp.AccessKey = miConfig.AccessKey
  20009. pp.OpterName = curRoles.UserName
  20010. result, _ := service.Jxyb4101(struct4101, pp)
  20011. var dat map[string]interface{}
  20012. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20013. fmt.Println(dat)
  20014. } else {
  20015. fmt.Println(err)
  20016. }
  20017. userJSONBytes, _ := json.Marshal(dat)
  20018. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20019. utils.ErrorLog("解析失败:%v", err)
  20020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20021. return
  20022. }
  20023. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20024. var pp models.PublicParams
  20025. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20026. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20027. pp.FixmedinsName = miConfig.OrgName
  20028. pp.FixmedinsCode = miConfig.Code
  20029. pp.RequestUrl = miConfig.Url
  20030. pp.Cainfo = miConfig.Cainfo
  20031. pp.SecretKey = miConfig.SecretKey
  20032. pp.AccessKey = miConfig.AccessKey
  20033. pp.OpterName = curRoles.UserName
  20034. result, _ := service.Jxyb4101(struct4101, pp)
  20035. var dat map[string]interface{}
  20036. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20037. fmt.Println(dat)
  20038. } else {
  20039. fmt.Println(err)
  20040. }
  20041. userJSONBytes, _ := json.Marshal(dat)
  20042. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20043. utils.ErrorLog("解析失败:%v", err)
  20044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20045. return
  20046. }
  20047. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20048. var pp models.PublicParams
  20049. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20050. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20051. pp.FixmedinsName = miConfig.OrgName
  20052. pp.FixmedinsCode = miConfig.Code
  20053. pp.RequestUrl = miConfig.Url
  20054. pp.Cainfo = miConfig.Cainfo
  20055. pp.SecretKey = miConfig.SecretKey
  20056. pp.AccessKey = miConfig.AccessKey
  20057. pp.OpterName = curRoles.UserName
  20058. result, _ := service.Jxyb4101(struct4101, pp)
  20059. var dat map[string]interface{}
  20060. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20061. fmt.Println(dat)
  20062. } else {
  20063. fmt.Println(err)
  20064. }
  20065. userJSONBytes, _ := json.Marshal(dat)
  20066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20067. utils.ErrorLog("解析失败:%v", err)
  20068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20069. return
  20070. }
  20071. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20072. var pp models.PublicParams
  20073. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20074. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20075. pp.FixmedinsName = miConfig.OrgName
  20076. pp.FixmedinsCode = miConfig.Code
  20077. pp.RequestUrl = miConfig.Url
  20078. pp.Cainfo = miConfig.Cainfo
  20079. pp.SecretKey = miConfig.SecretKey
  20080. pp.AccessKey = miConfig.AccessKey
  20081. pp.OpterName = curRoles.UserName
  20082. result, _ := service.Hnyb4101(struct4101, pp)
  20083. var dat map[string]interface{}
  20084. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20085. fmt.Println(dat)
  20086. } else {
  20087. fmt.Println(err)
  20088. }
  20089. userJSONBytes, _ := json.Marshal(dat)
  20090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20091. utils.ErrorLog("解析失败:%v", err)
  20092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20093. return
  20094. }
  20095. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20096. var resOther ResultSeventeenOther
  20097. var pp models.PublicParams
  20098. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20099. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20100. pp.FixmedinsName = miConfig.OrgName
  20101. pp.FixmedinsCode = miConfig.Code
  20102. pp.RequestUrl = miConfig.Url
  20103. pp.Cainfo = miConfig.Cainfo
  20104. pp.SecretKey = miConfig.SecretKey
  20105. pp.AccessKey = miConfig.AccessKey
  20106. pp.OpterName = curRoles.UserName
  20107. client := &http.Client{}
  20108. var req *http.Request
  20109. data := make(map[string]interface{})
  20110. data["struct4101"] = struct4101
  20111. data["pp"] = pp
  20112. bytesData, _ := json.Marshal(data)
  20113. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20114. resp, _ := client.Do(req)
  20115. defer resp.Body.Close()
  20116. body, ioErr := ioutil.ReadAll(resp.Body)
  20117. if ioErr != nil {
  20118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20120. return
  20121. }
  20122. var respJSON map[string]interface{}
  20123. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20126. return
  20127. }
  20128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20129. userJSONBytes, _ := json.Marshal(respJSON)
  20130. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20131. utils.ErrorLog("解析失败:%v", err)
  20132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20133. return
  20134. }
  20135. res.InfRefmsgid = resOther.InfRefmsgid
  20136. res.Output = resOther.Output
  20137. res.ErrMsg = resOther.ErrMsg
  20138. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20139. res.Infcode = infocode
  20140. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20141. var pp models.PublicParams
  20142. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20143. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20144. pp.FixmedinsName = miConfig.OrgName
  20145. pp.FixmedinsCode = miConfig.Code
  20146. pp.RequestUrl = miConfig.Url
  20147. pp.Cainfo = miConfig.Cainfo
  20148. pp.SecretKey = miConfig.SecretKey
  20149. pp.AccessKey = miConfig.AccessKey
  20150. pp.OpterName = curRoles.UserName
  20151. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20152. fmt.Println(requestLog)
  20153. fmt.Println(errMsgLog)
  20154. saveLog(result, requestLog, "4101a", "上传清单")
  20155. var dat map[string]interface{}
  20156. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20157. fmt.Println(dat)
  20158. } else {
  20159. fmt.Println(err)
  20160. }
  20161. userJSONBytes, _ := json.Marshal(dat)
  20162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20163. utils.ErrorLog("解析失败:%v", err)
  20164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20165. return
  20166. }
  20167. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20168. var pp models.PublicParams
  20169. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20170. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20171. pp.FixmedinsName = miConfig.OrgName
  20172. pp.FixmedinsCode = miConfig.Code
  20173. pp.RequestUrl = miConfig.Url
  20174. pp.Cainfo = miConfig.Cainfo
  20175. pp.SecretKey = miConfig.SecretKey
  20176. pp.AccessKey = miConfig.AccessKey
  20177. pp.OpterName = curRoles.UserName
  20178. client := &http.Client{}
  20179. var req *http.Request
  20180. data := make(map[string]interface{})
  20181. data["struct4101"] = struct4101
  20182. data["pp"] = pp
  20183. bytesData, _ := json.Marshal(data)
  20184. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20185. resp, _ := client.Do(req)
  20186. defer resp.Body.Close()
  20187. body, ioErr := ioutil.ReadAll(resp.Body)
  20188. if ioErr != nil {
  20189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20191. return
  20192. }
  20193. var respJSON map[string]interface{}
  20194. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20197. return
  20198. }
  20199. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20200. userJSONBytes, _ := json.Marshal(respJSON)
  20201. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20202. utils.ErrorLog("解析失败:%v", err)
  20203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20204. return
  20205. }
  20206. } else {
  20207. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20208. var dat map[string]interface{}
  20209. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20210. fmt.Println(dat)
  20211. } else {
  20212. fmt.Println(err)
  20213. }
  20214. userJSONBytes, _ := json.Marshal(dat)
  20215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20216. utils.ErrorLog("解析失败:%v", err)
  20217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20218. return
  20219. }
  20220. }
  20221. if res.Infcode != 0 {
  20222. c.ServeSuccessJSON(map[string]interface{}{
  20223. "failed_code": -10,
  20224. "msg": res.ErrMsg,
  20225. })
  20226. return
  20227. } else {
  20228. //order.FaPiaoNumber = zero
  20229. //order.FaPiaoCode = last_order.FaPiaoCode
  20230. //service.UpdateOrder(order)
  20231. hisFundSettleListResult := &models.HisFundSettleListResult{
  20232. Number: res.Output.SetlListId,
  20233. Status: 1,
  20234. Ctime: time.Now().Unix(),
  20235. Mtime: time.Now().Unix(),
  20236. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20237. IsUpload: 1,
  20238. OrderId: order_id,
  20239. }
  20240. service.CreateUploadRecord(hisFundSettleListResult)
  20241. c.ServeSuccessJSON(map[string]interface{}{
  20242. "msg": "上传成功",
  20243. "result": hisFundSettleListResult,
  20244. })
  20245. return
  20246. }
  20247. }
  20248. func (c *HisApiController) GetSettleListHospital() {
  20249. order_id, _ := c.GetInt64("order_id")
  20250. admin_user_id, _ := c.GetInt64("admin_user_id")
  20251. order, _ := service.GetHisOrderByIDTwo(order_id)
  20252. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20253. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  20254. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20255. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20256. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20257. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20258. if order.ID == 0 {
  20259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20260. return
  20261. }
  20262. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20263. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20264. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20265. fmt.Println(count)
  20266. var zero string
  20267. number := count + 1
  20268. if number >= 1000 {
  20269. zero = "0000" + strconv.FormatInt(number, 10)
  20270. } else if number >= 10000 {
  20271. zero = "000" + strconv.FormatInt(number, 10)
  20272. } else if number >= 100000 {
  20273. zero = "00" + strconv.FormatInt(number, 10)
  20274. } else if number >= 1000000 {
  20275. zero = "0" + strconv.FormatInt(number, 10)
  20276. } else {
  20277. zero = strconv.FormatInt(number, 10)
  20278. }
  20279. fmt.Println(zero)
  20280. struct4101 := service.Struct4101{
  20281. PsnNo: order.PsnNo,
  20282. MdtrtId: order.MdtrtId,
  20283. SetlId: order.SetlId,
  20284. PsnName: order.PsnName,
  20285. Gend: order.Gend,
  20286. Brdy: his.Brdy,
  20287. Age: int64(order.Age),
  20288. Naty: order.Naty,
  20289. PatnCertType: "01",
  20290. Certno: order.Certno,
  20291. Prfs: "90",
  20292. ConerName: roles[0].UserName,
  20293. PatnRlts: "99",
  20294. ConerAddr: miConfig.OrgName,
  20295. ConerTel: admin.Mobile,
  20296. HiType: order.Insutype,
  20297. Insuplc: miConfig.InsuplcAdmdvs,
  20298. MaindiagFlag: "1",
  20299. BillCode: order.SetlId,
  20300. BillNo: order.SetlId,
  20301. BizSn: order.Number,
  20302. PsnSelfPay: order.PsnPartAmt,
  20303. PsnOwnPay: order.PsnPartAmt,
  20304. AcctPay: order.AcctPay,
  20305. PsnCashpay: order.PsnCashPay,
  20306. HiPaymtd: "1",
  20307. Hsorg: miConfig.InsuplcAdmdvs,
  20308. HsorgOpter: miConfig.InsuplcAdmdvs,
  20309. MedinsFillPsn: curRoles.UserName,
  20310. MedinsFillDept: depart.Name,
  20311. IptMedType: "2",
  20312. AdmTime: his.InHosptialTime,
  20313. AdmEndTime: his.OutHosptialTime,
  20314. }
  20315. struct4101.SetlBegnDate = order.SetlTime
  20316. struct4101.SetlEndDate = order.SetlTime
  20317. //var rf []CustomFundPay
  20318. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20319. //
  20320. //var tempFunPays []service.CustomStruct
  20321. //for _, item := range rf {
  20322. // var tempFunPay service.CustomStruct
  20323. // tempFunPay.FundPayamt = item.FundPayamt
  20324. // tempFunPay.FundPayType = item.FundPayType
  20325. // tempFunPays = append(tempFunPays, tempFunPay)
  20326. //}
  20327. //struct4101.CustomStruct = tempFunPays
  20328. var tempDiaginfos []service.DiaginfoStructTwo
  20329. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20330. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20331. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  20332. //for _, item := range infos {
  20333. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  20334. //}
  20335. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  20336. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  20337. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20338. fmt.Println(diagnosis_ids_arr)
  20339. if order.UserOrgId == 10210 {
  20340. var diagnosis_ids_arr_two []int64
  20341. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  20342. var config []*models.HisXtDiagnoseConfig
  20343. for _, id := range diagnosis_ids_arr_two {
  20344. //id, _ := strconv.ParseInt(item, 10, 64)
  20345. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20346. if diagnosisConfig.ID > 0 {
  20347. config = append(config, &diagnosisConfig)
  20348. }
  20349. }
  20350. for index, item := range config {
  20351. if item.ID > 0 {
  20352. if index == 0 {
  20353. var tempDiaginfo service.DiaginfoStructTwo
  20354. tempDiaginfo.DiagCode = item.CountryCode
  20355. tempDiaginfo.DiagName = item.CountryContentName
  20356. tempDiaginfo.DiagType = "1"
  20357. tempDiaginfo.MaindiagFlag = "1"
  20358. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20359. } else {
  20360. var tempDiaginfo service.DiaginfoStructTwo
  20361. tempDiaginfo.DiagCode = item.CountryCode
  20362. tempDiaginfo.DiagName = item.CountryContentName
  20363. tempDiaginfo.DiagType = "1"
  20364. tempDiaginfo.MaindiagFlag = "0"
  20365. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20366. }
  20367. }
  20368. }
  20369. struct4101.Diseinfo = tempDiaginfos
  20370. } else {
  20371. var config []*models.HisXtDiagnoseConfig
  20372. for _, item := range diagnosis_ids_arr {
  20373. id, _ := strconv.ParseInt(item, 10, 64)
  20374. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20375. if diagnosisConfig.ID > 0 {
  20376. config = append(config, &diagnosisConfig)
  20377. }
  20378. }
  20379. for index, item := range config {
  20380. if item.ID > 0 {
  20381. if index == 0 {
  20382. var tempDiaginfo service.DiaginfoStructTwo
  20383. tempDiaginfo.DiagCode = item.CountryCode
  20384. tempDiaginfo.DiagName = item.CountryContentName
  20385. tempDiaginfo.DiagType = "1"
  20386. tempDiaginfo.MaindiagFlag = "1"
  20387. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20388. } else {
  20389. var tempDiaginfo service.DiaginfoStructTwo
  20390. tempDiaginfo.DiagCode = item.CountryCode
  20391. tempDiaginfo.DiagName = item.CountryContentName
  20392. tempDiaginfo.DiagType = "1"
  20393. tempDiaginfo.MaindiagFlag = "0"
  20394. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20395. }
  20396. }
  20397. }
  20398. struct4101.Diseinfo = tempDiaginfos
  20399. }
  20400. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20401. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20402. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20403. tempOpspdiseinfo2.OprnOprtCode = ""
  20404. tempOpspdiseinfo2.OprnOprtName = ""
  20405. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20406. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20407. var iteminfo service.IteminfoStruct
  20408. var bedCostTotal float64 = 0 //床位总费
  20409. var bedCostSelfTotal float64 = 0 //床位自费
  20410. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20411. var operationCostTotal float64 = 0 //手术费
  20412. var operationCostSelfTotal float64 = 0 //手术费
  20413. var operationCostPartSelfTotal float64 = 0 //手术费
  20414. var otherCostTotal float64 = 0 //其他费用
  20415. var otherCostSelfTotal float64 = 0 //其他费用
  20416. var otherCostPartSelfTotal float64 = 0 //其他费用
  20417. var materialCostTotal float64 = 0 //材料费
  20418. var materialCostSelfTotal float64 = 0 //材料费
  20419. var materialCostPartSelfTotal float64 = 0 //材料费
  20420. var westernMedicineCostTotal float64 = 0 //西药费
  20421. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20422. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20423. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20424. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20425. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20426. var checkCostTotal float64 = 0 //检查费
  20427. var checkCostSelfTotal float64 = 0 //检查费
  20428. var checkCostPartSelfTotal float64 = 0 //检查费
  20429. var laboratoryCostTotal float64 = 0 //化验费
  20430. var laboratoryCostSelfTotal float64 = 0 //化验费
  20431. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20432. var treatCostTotal float64 = 0 //治疗费用
  20433. var treatCostSelfTotal float64 = 0 //治疗费用
  20434. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20435. decimal.DivisionPrecision = 2
  20436. var bed_fulamt_ownpay_amt float64 = 0
  20437. var operation_fulamt_ownpay_amt float64 = 0
  20438. var other_fulamt_ownpay_amt float64 = 0
  20439. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20440. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20441. var check_fulamt_ownpay_amt float64 = 0
  20442. var material_fulamt_ownpay_amt float64 = 0
  20443. var laboratory_fulamt_ownpay_amt float64 = 0
  20444. var treat_fulamt_ownpay_amt float64 = 0
  20445. var bed_claa_sunmfee float64 = 0
  20446. var bed_clab_amt float64 = 0
  20447. var bed_other_amt float64 = 0
  20448. var operation_claa_sunmfee float64 = 0
  20449. var operation_clab_amt float64 = 0
  20450. var operation_other_amt float64 = 0
  20451. var other_claa_sunmfee float64 = 0
  20452. var other_clab_amt float64 = 0
  20453. var other_other_amt float64 = 0
  20454. var westernMedicine_claa_sunmfee float64 = 0
  20455. var westernMedicine_clab_amt float64 = 0
  20456. var westernMedicine_other_amt float64 = 0
  20457. var chineseTraditional_claa_sunmfee float64 = 0
  20458. var chineseTraditional_clab_amt float64 = 0
  20459. var chineseTraditional_other_amt float64 = 0
  20460. var check_claa_sunmfee float64 = 0
  20461. var check_clab_amt float64 = 0
  20462. var check_other_amt float64 = 0
  20463. var material_claa_sunmfee float64 = 0
  20464. var material_clab_amt float64 = 0
  20465. var material_other_amt float64 = 0
  20466. var laboratory_claa_sunmfee float64 = 0
  20467. var laboratory_clab_amt float64 = 0
  20468. var laboratory_other_amt float64 = 0
  20469. var treat_claa_sunmfee float64 = 0
  20470. var treat_clab_amt float64 = 0
  20471. var treat_other_amt float64 = 0
  20472. for _, item := range order.HisOrderInfo {
  20473. if item.MedChrgitmType == "01" { //床位费
  20474. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20475. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20476. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20477. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20478. if item.ChrgitmLv == "1" {
  20479. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20480. }
  20481. if item.ChrgitmLv == "2" {
  20482. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20483. }
  20484. if item.ChrgitmLv == "3" {
  20485. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20486. }
  20487. }
  20488. if item.MedChrgitmType == "03" { //检查费
  20489. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20490. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20491. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20492. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20493. if item.ChrgitmLv == "1" {
  20494. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20495. }
  20496. if item.ChrgitmLv == "2" {
  20497. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20498. }
  20499. if item.ChrgitmLv == "3" {
  20500. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20501. }
  20502. }
  20503. if item.MedChrgitmType == "04" { //化验费
  20504. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20505. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20506. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20507. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20508. if item.ChrgitmLv == "1" {
  20509. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20510. }
  20511. if item.ChrgitmLv == "2" {
  20512. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20513. }
  20514. if item.ChrgitmLv == "3" {
  20515. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20516. }
  20517. }
  20518. if item.MedChrgitmType == "05" { //治疗费
  20519. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20520. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20521. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20522. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20523. if item.ChrgitmLv == "1" {
  20524. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20525. }
  20526. if item.ChrgitmLv == "2" {
  20527. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20528. }
  20529. if item.ChrgitmLv == "3" {
  20530. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20531. }
  20532. }
  20533. if item.MedChrgitmType == "06" { //手术费
  20534. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20535. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20536. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20537. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20538. if item.ChrgitmLv == "1" {
  20539. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20540. }
  20541. if item.ChrgitmLv == "2" {
  20542. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20543. }
  20544. if item.ChrgitmLv == "3" {
  20545. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20546. }
  20547. }
  20548. if item.MedChrgitmType == "08" { //材料费
  20549. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20550. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20551. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20552. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20553. if item.ChrgitmLv == "1" {
  20554. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20555. }
  20556. if item.ChrgitmLv == "2" {
  20557. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20558. }
  20559. if item.ChrgitmLv == "3" {
  20560. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20561. }
  20562. }
  20563. if item.MedChrgitmType == "09" { //西药费
  20564. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20565. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20566. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20567. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20568. if item.ChrgitmLv == "1" {
  20569. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20570. }
  20571. if item.ChrgitmLv == "2" {
  20572. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20573. }
  20574. if item.ChrgitmLv == "3" {
  20575. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20576. }
  20577. }
  20578. if item.MedChrgitmType == "11" { //中成费
  20579. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20580. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20581. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20582. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20583. if item.ChrgitmLv == "1" {
  20584. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20585. }
  20586. if item.ChrgitmLv == "2" {
  20587. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20588. }
  20589. if item.ChrgitmLv == "3" {
  20590. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20591. }
  20592. }
  20593. if item.MedChrgitmType == "14" { //其他费
  20594. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20595. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20596. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20597. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20598. if item.ChrgitmLv == "1" {
  20599. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20600. }
  20601. if item.ChrgitmLv == "2" {
  20602. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20603. }
  20604. if item.ChrgitmLv == "3" {
  20605. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20606. }
  20607. }
  20608. }
  20609. var iteminfoStructs []service.IteminfoStruct
  20610. if bedCostTotal != 0 {
  20611. iteminfo.MedChrgitm = "01"
  20612. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20613. iteminfo.Amt = bedCostTotal
  20614. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20615. iteminfo.ClabAmt = bed_clab_amt
  20616. iteminfo.OthAmt = bed_other_amt
  20617. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20618. }
  20619. if checkCostTotal != 0 {
  20620. iteminfo.MedChrgitm = "03"
  20621. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20622. iteminfo.Amt = checkCostTotal
  20623. iteminfo.ClaaSumfee = check_claa_sunmfee
  20624. iteminfo.ClabAmt = check_clab_amt
  20625. iteminfo.OthAmt = check_other_amt
  20626. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20627. }
  20628. if laboratoryCostTotal != 0 {
  20629. iteminfo.MedChrgitm = "04"
  20630. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20631. iteminfo.Amt = laboratoryCostTotal
  20632. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20633. iteminfo.ClabAmt = laboratory_clab_amt
  20634. iteminfo.OthAmt = laboratory_other_amt
  20635. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20636. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20637. }
  20638. if treatCostTotal != 0 {
  20639. iteminfo.MedChrgitm = "05"
  20640. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20641. iteminfo.Amt = treatCostTotal
  20642. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20643. iteminfo.ClabAmt = treat_clab_amt
  20644. iteminfo.OthAmt = treat_other_amt
  20645. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20646. //(struct4101.IteminfoStruct, iteminfo)
  20647. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20648. }
  20649. if operationCostTotal != 0 {
  20650. iteminfo.MedChrgitm = "06"
  20651. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20652. iteminfo.Amt = operationCostTotal
  20653. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20654. iteminfo.ClabAmt = operation_clab_amt
  20655. iteminfo.OthAmt = operation_other_amt
  20656. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20657. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20658. }
  20659. if materialCostTotal != 0 {
  20660. iteminfo.MedChrgitm = "08"
  20661. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20662. iteminfo.Amt = materialCostTotal
  20663. iteminfo.ClaaSumfee = material_claa_sunmfee
  20664. iteminfo.ClabAmt = material_clab_amt
  20665. iteminfo.OthAmt = material_other_amt
  20666. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20667. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20668. }
  20669. if westernMedicineCostTotal != 0 {
  20670. iteminfo.MedChrgitm = "09"
  20671. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20672. iteminfo.Amt = westernMedicineCostTotal
  20673. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20674. iteminfo.ClabAmt = westernMedicine_clab_amt
  20675. iteminfo.OthAmt = westernMedicine_other_amt
  20676. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20677. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20678. }
  20679. if chineseTraditionalMedicineCostTotal != 0 {
  20680. iteminfo.MedChrgitm = "11"
  20681. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20682. iteminfo.Amt = westernMedicineCostTotal
  20683. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20684. iteminfo.ClabAmt = westernMedicine_clab_amt
  20685. iteminfo.OthAmt = westernMedicine_other_amt
  20686. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20687. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20688. }
  20689. if otherCostTotal != 0 {
  20690. iteminfo.MedChrgitm = "14"
  20691. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20692. iteminfo.Amt = otherCostTotal
  20693. iteminfo.ClaaSumfee = other_claa_sunmfee
  20694. iteminfo.ClabAmt = other_clab_amt
  20695. iteminfo.OthAmt = other_other_amt
  20696. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20697. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20698. }
  20699. struct4101.IteminfoStruct = iteminfoStructs
  20700. struct4101.Ntly = "中国"
  20701. struct4101.AdmCaty = "A03.06"
  20702. var resOther ResultSeventeenOther
  20703. var res ResultSeventeen
  20704. if miConfig.MdtrtareaAdmvs == "150499" {
  20705. var pp models.PublicParams
  20706. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20707. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20708. pp.FixmedinsName = miConfig.OrgName
  20709. pp.FixmedinsCode = miConfig.Code
  20710. pp.RequestUrl = miConfig.Url
  20711. pp.Cainfo = miConfig.Cainfo
  20712. pp.SecretKey = miConfig.SecretKey
  20713. pp.AccessKey = miConfig.AccessKey
  20714. pp.OpterName = curRoles.UserName
  20715. client := &http.Client{}
  20716. var req *http.Request
  20717. data := make(map[string]interface{})
  20718. data["struct4101"] = struct4101
  20719. data["pp"] = pp
  20720. bytesData, _ := json.Marshal(data)
  20721. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20722. resp, _ := client.Do(req)
  20723. defer resp.Body.Close()
  20724. body, ioErr := ioutil.ReadAll(resp.Body)
  20725. if ioErr != nil {
  20726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20728. return
  20729. }
  20730. var respJSON map[string]interface{}
  20731. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20734. return
  20735. }
  20736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20737. userJSONBytes, _ := json.Marshal(respJSON)
  20738. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20739. utils.ErrorLog("解析失败:%v", err)
  20740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20741. return
  20742. }
  20743. res.InfRefmsgid = resOther.InfRefmsgid
  20744. res.Output = resOther.Output
  20745. res.ErrMsg = resOther.ErrMsg
  20746. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20747. res.Infcode = infocode
  20748. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20749. var pp models.PublicParams
  20750. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20751. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20752. pp.FixmedinsName = miConfig.OrgName
  20753. pp.FixmedinsCode = miConfig.Code
  20754. pp.RequestUrl = miConfig.Url
  20755. pp.Cainfo = miConfig.Cainfo
  20756. pp.SecretKey = miConfig.SecretKey
  20757. pp.AccessKey = miConfig.AccessKey
  20758. pp.OpterName = curRoles.UserName
  20759. result, _ := service.Jxyb4101(struct4101, pp)
  20760. var dat map[string]interface{}
  20761. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20762. fmt.Println(dat)
  20763. } else {
  20764. fmt.Println(err)
  20765. }
  20766. userJSONBytes, _ := json.Marshal(dat)
  20767. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20768. utils.ErrorLog("解析失败:%v", err)
  20769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20770. return
  20771. }
  20772. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20773. var pp models.PublicParams
  20774. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20775. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20776. pp.FixmedinsName = miConfig.OrgName
  20777. pp.FixmedinsCode = miConfig.Code
  20778. pp.RequestUrl = miConfig.Url
  20779. pp.Cainfo = miConfig.Cainfo
  20780. pp.SecretKey = miConfig.SecretKey
  20781. pp.AccessKey = miConfig.AccessKey
  20782. pp.OpterName = curRoles.UserName
  20783. result, _ := service.Jxyb4101(struct4101, pp)
  20784. var dat map[string]interface{}
  20785. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20786. fmt.Println(dat)
  20787. } else {
  20788. fmt.Println(err)
  20789. }
  20790. userJSONBytes, _ := json.Marshal(dat)
  20791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20792. utils.ErrorLog("解析失败:%v", err)
  20793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20794. return
  20795. }
  20796. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20797. var pp models.PublicParams
  20798. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20799. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20800. pp.FixmedinsName = miConfig.OrgName
  20801. pp.FixmedinsCode = miConfig.Code
  20802. pp.RequestUrl = miConfig.Url
  20803. pp.Cainfo = miConfig.Cainfo
  20804. pp.SecretKey = miConfig.SecretKey
  20805. pp.AccessKey = miConfig.AccessKey
  20806. pp.OpterName = curRoles.UserName
  20807. result, _ := service.Jxyb4101(struct4101, pp)
  20808. var dat map[string]interface{}
  20809. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20810. fmt.Println(dat)
  20811. } else {
  20812. fmt.Println(err)
  20813. }
  20814. userJSONBytes, _ := json.Marshal(dat)
  20815. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20816. utils.ErrorLog("解析失败:%v", err)
  20817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20818. return
  20819. }
  20820. } else {
  20821. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20822. var dat map[string]interface{}
  20823. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20824. fmt.Println(dat)
  20825. } else {
  20826. fmt.Println(err)
  20827. }
  20828. userJSONBytes, _ := json.Marshal(dat)
  20829. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20830. utils.ErrorLog("解析失败:%v", err)
  20831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20832. return
  20833. }
  20834. }
  20835. if res.Infcode != 0 {
  20836. c.ServeSuccessJSON(map[string]interface{}{
  20837. "failed_code": -10,
  20838. "msg": res.ErrMsg,
  20839. })
  20840. return
  20841. } else {
  20842. if miConfig.MdtrtareaAdmvs != "150499" {
  20843. order.FaPiaoNumber = zero
  20844. order.FaPiaoCode = last_order.FaPiaoCode
  20845. service.UpdateOrder(order)
  20846. }
  20847. hisFundSettleListResult := &models.HisFundSettleListResult{
  20848. Number: res.Output.SetlListId,
  20849. Status: 1,
  20850. Ctime: time.Now().Unix(),
  20851. Mtime: time.Now().Unix(),
  20852. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20853. IsUpload: 1,
  20854. OrderId: order_id,
  20855. }
  20856. service.CreateUploadRecord(hisFundSettleListResult)
  20857. c.ServeSuccessJSON(map[string]interface{}{
  20858. "msg": "上传成功",
  20859. "result": hisFundSettleListResult,
  20860. })
  20861. return
  20862. }
  20863. }
  20864. //func (c *HisApiController) GetBatchSettleList() {
  20865. // orders, _ := service.GetAllHisOrder(10106)
  20866. // for _, item := range orders {
  20867. // order_id := item.ID
  20868. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20869. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20870. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20871. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20872. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20873. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20874. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20875. //
  20876. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20877. //
  20878. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20879. //
  20880. // if order.ID == 0 {
  20881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20882. // return
  20883. // }
  20884. // if his.BalanceAccountsType == 2 {
  20885. // continue
  20886. // }
  20887. // struct4101 := service.Struct4101{
  20888. // PsnNo: order.PsnNo,
  20889. // MdtrtId: order.MdtrtId,
  20890. // SetlId: order.SetlId,
  20891. // PsnName: order.PsnName,
  20892. // Gend: order.Gend,
  20893. // Brdy: his.Brdy,
  20894. // Age: his.Age,
  20895. // Naty: order.Naty,
  20896. // PatnCertType: "01",
  20897. // Certno: order.Certno,
  20898. // Prfs: "90",
  20899. // ConerName: roles[0].UserName,
  20900. // PatnRlts: "99",
  20901. // ConerAddr: miConfig.OrgName,
  20902. // ConerTel: admin.Mobile,
  20903. // HiType: order.Insutype,
  20904. // Insuplc: his.InsuplcAdmdvs,
  20905. // MaindiagFlag: "1",
  20906. // BillCode: order.SetlId,
  20907. // BillNo: order.SetlId,
  20908. // BizSn: order.Number,
  20909. // PsnSelfPay: order.PsnPartAmt,
  20910. // PsnOwnPay: order.PsnPartAmt,
  20911. // AcctPay: order.AcctPay,
  20912. // PsnCashpay: order.PsnCashPay,
  20913. // HiPaymtd: "1",
  20914. // Hsorg: his.InsuplcAdmdvs,
  20915. // HsorgOpter: his.InsuplcAdmdvs,
  20916. // MedinsFillPsn: curRoles.UserName,
  20917. // MedinsFillDept: depart.Name,
  20918. // IptMedType: "2",
  20919. // }
  20920. // struct4101.SetlBegnDate = order.SetlTime
  20921. // struct4101.SetlEndDate = order.SetlTime
  20922. // //if order.SettleType == 1 {
  20923. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20924. // // dateStr := t.Format("2006-01-02")
  20925. // // struct4101.SetlBegnDate = dateStr
  20926. // // struct4101.SetlEndDate = dateStr
  20927. // //} else {
  20928. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20929. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20930. // // dateStartStr := t.Format("2006-01-02")
  20931. // // dateEndStr := t2.Format("2006-01-02")
  20932. // // struct4101.SetlBegnDate = dateStartStr
  20933. // // struct4101.SetlEndDate = dateEndStr
  20934. // //}
  20935. //
  20936. // var rf []CustomFundPay
  20937. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20938. //
  20939. // var tempFunPays []service.CustomStruct
  20940. // var tempFunPay610100 service.CustomStruct
  20941. //
  20942. // for _, item := range rf {
  20943. // if item.FundPayType == "610100" {
  20944. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20945. // tempFunPay610100.FundPayType = item.FundPayType
  20946. // } else {
  20947. // var tempFunPay service.CustomStruct
  20948. // tempFunPay.FundPayamt = item.FundPayamt
  20949. // tempFunPay.FundPayType = item.FundPayType
  20950. // tempFunPays = append(tempFunPays, tempFunPay)
  20951. // }
  20952. // }
  20953. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20954. // struct4101.CustomStruct = tempFunPays
  20955. //
  20956. // var tempDiaginfos []service.DiaginfoStructTwo
  20957. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20958. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20959. //
  20960. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20961. // var config []*models.HisXtDiagnoseConfig
  20962. // for _, item := range diagnosis_ids {
  20963. // id, _ := strconv.ParseInt(item, 10, 64)
  20964. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20965. // config = append(config, &diagnosisConfig)
  20966. // }
  20967. //
  20968. // for index, item := range config {
  20969. // if index == 0 {
  20970. // var tempDiaginfo service.DiaginfoStructTwo
  20971. // tempDiaginfo.DiagCode = item.CountryCode
  20972. // tempDiaginfo.DiagName = item.CountryContentName
  20973. // tempDiaginfo.DiagType = "1"
  20974. // tempDiaginfo.MaindiagFlag = "1"
  20975. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20976. // } else {
  20977. //
  20978. // var tempDiaginfo service.DiaginfoStructTwo
  20979. // tempDiaginfo.DiagCode = item.CountryCode
  20980. // tempDiaginfo.DiagName = item.CountryContentName
  20981. // tempDiaginfo.DiagType = "2"
  20982. // tempDiaginfo.MaindiagFlag = "0"
  20983. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20984. // }
  20985. // }
  20986. // struct4101.Diseinfo = tempDiaginfos
  20987. //
  20988. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20989. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20990. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20991. // tempOpspdiseinfo2.OprnOprtCode = ""
  20992. // tempOpspdiseinfo2.OprnOprtName = ""
  20993. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20994. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20995. //
  20996. // var iteminfo service.IteminfoStruct
  20997. //
  20998. // var bedCostTotal float64 = 0 //床位总费
  20999. // var bedCostSelfTotal float64 = 0 //床位自费
  21000. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21001. //
  21002. // var examineCostTotal float64 = 0 //诊查总费
  21003. // var examineCostSelfTotal float64 = 0 //诊查自费
  21004. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21005. //
  21006. // var nursingCostTotal float64 = 0 //护理总费
  21007. // var nursingCostSelfTotal float64 = 0 //护理自费
  21008. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21009. //
  21010. // var chineseMedicineCostTotal float64 = 0 //中成药
  21011. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21012. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21013. //
  21014. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21015. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21016. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21017. //
  21018. // var registerCostTotal float64 = 0 //一般诊疗费
  21019. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21020. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21021. //
  21022. // var operationCostTotal float64 = 0 //手术费
  21023. // var operationCostSelfTotal float64 = 0 //手术费
  21024. // var operationCostPartSelfTotal float64 = 0 //手术费
  21025. //
  21026. // var otherCostTotal float64 = 0 //其他费用
  21027. // var otherCostSelfTotal float64 = 0 //其他费用
  21028. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21029. //
  21030. // var materialCostTotal float64 = 0 //材料费
  21031. // var materialCostSelfTotal float64 = 0 //材料费
  21032. // var materialCostPartSelfTotal float64 = 0 //材料费
  21033. //
  21034. // var westernMedicineCostTotal float64 = 0 //西药费
  21035. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21036. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21037. //
  21038. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21039. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21040. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21041. //
  21042. // var checkCostTotal float64 = 0 //检查费
  21043. // var checkCostSelfTotal float64 = 0 //检查费
  21044. // var checkCostPartSelfTotal float64 = 0 //检查费
  21045. //
  21046. // var laboratoryCostTotal float64 = 0 //化验费
  21047. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21048. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21049. //
  21050. // var treatCostTotal float64 = 0 //治疗费用
  21051. // var treatCostSelfTotal float64 = 0 //治疗费用
  21052. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21053. //
  21054. // decimal.DivisionPrecision = 2
  21055. //
  21056. // var bed_fulamt_ownpay_amt float64 = 0
  21057. //
  21058. // var examine_fulamt_ownpay_amt float64 = 0
  21059. //
  21060. // var nursing_fulamt_ownpay_amt float64 = 0
  21061. //
  21062. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21063. //
  21064. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21065. //
  21066. // var register_fulamt_ownpay_amt float64 = 0
  21067. //
  21068. // var operation_fulamt_ownpay_amt float64 = 0
  21069. // var other_fulamt_ownpay_amt float64 = 0
  21070. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21071. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21072. // var check_fulamt_ownpay_amt float64 = 0
  21073. // var material_fulamt_ownpay_amt float64 = 0
  21074. // var laboratory_fulamt_ownpay_amt float64 = 0
  21075. // var treat_fulamt_ownpay_amt float64 = 0
  21076. //
  21077. // var bed_claa_sunmfee float64 = 0
  21078. // var bed_clab_amt float64 = 0
  21079. // var bed_other_amt float64 = 0
  21080. //
  21081. // var examine_claa_sunmfee float64 = 0
  21082. // var examine_clab_amt float64 = 0
  21083. // var examine_other_amt float64 = 0
  21084. //
  21085. // var nursing_claa_sunmfee float64 = 0
  21086. // var nursing_clab_amt float64 = 0
  21087. // var nursing_other_amt float64 = 0
  21088. //
  21089. // var chinese_medicine_claa_sunmfee float64 = 0
  21090. // var chinese_medicine_clab_amt float64 = 0
  21091. // var chinese_medicine_other_amt float64 = 0
  21092. //
  21093. // var commonly_treatment_claa_sunmfee float64 = 0
  21094. // var commonly_treatment_clab_amt float64 = 0
  21095. // var commonly_treatment_other_amt float64 = 0
  21096. //
  21097. // var operation_claa_sunmfee float64 = 0
  21098. // var operation_clab_amt float64 = 0
  21099. // var operation_other_amt float64 = 0
  21100. //
  21101. // var other_claa_sunmfee float64 = 0
  21102. // var other_clab_amt float64 = 0
  21103. // var other_other_amt float64 = 0
  21104. //
  21105. // var westernMedicine_claa_sunmfee float64 = 0
  21106. // var westernMedicine_clab_amt float64 = 0
  21107. // var westernMedicine_other_amt float64 = 0
  21108. //
  21109. // var chineseTraditional_claa_sunmfee float64 = 0
  21110. // var chineseTraditional_clab_amt float64 = 0
  21111. // var chineseTraditional_other_amt float64 = 0
  21112. //
  21113. // var check_claa_sunmfee float64 = 0
  21114. // var check_clab_amt float64 = 0
  21115. // var check_other_amt float64 = 0
  21116. //
  21117. // var material_claa_sunmfee float64 = 0
  21118. // var material_clab_amt float64 = 0
  21119. // var material_other_amt float64 = 0
  21120. //
  21121. // var laboratory_claa_sunmfee float64 = 0
  21122. // var laboratory_clab_amt float64 = 0
  21123. // var laboratory_other_amt float64 = 0
  21124. //
  21125. // var treat_claa_sunmfee float64 = 0
  21126. // var treat_clab_amt float64 = 0
  21127. // var treat_other_amt float64 = 0
  21128. //
  21129. // var register_claa_sunmfee float64 = 0
  21130. // var register_clab_amt float64 = 0
  21131. // var register_other_amt float64 = 0
  21132. //
  21133. // for _, item := range order.HisOrderInfo {
  21134. // if item.MedChrgitmType == "01" { //床位费
  21135. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21136. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21137. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21138. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21139. // if item.ChrgitmLv == "1" {
  21140. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21141. // }
  21142. // if item.ChrgitmLv == "2" {
  21143. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21144. //
  21145. // }
  21146. // if item.ChrgitmLv == "3" {
  21147. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21148. // }
  21149. //
  21150. // }
  21151. //
  21152. // if item.MedChrgitmType == "02" { //诊查
  21153. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21154. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21155. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21156. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21157. // if item.ChrgitmLv == "1" {
  21158. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21159. // }
  21160. // if item.ChrgitmLv == "2" {
  21161. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21162. //
  21163. // }
  21164. // if item.ChrgitmLv == "3" {
  21165. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21166. // }
  21167. //
  21168. // }
  21169. //
  21170. // if item.MedChrgitmType == "03" { //检查费
  21171. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21172. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21173. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21174. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21175. // if item.ChrgitmLv == "1" {
  21176. //
  21177. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21178. //
  21179. // }
  21180. // if item.ChrgitmLv == "2" {
  21181. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21182. //
  21183. // }
  21184. // if item.ChrgitmLv == "3" {
  21185. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21186. // }
  21187. // }
  21188. //
  21189. // if item.MedChrgitmType == "04" { //化验费
  21190. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21191. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21192. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21193. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21194. // if item.ChrgitmLv == "1" {
  21195. //
  21196. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21197. //
  21198. // }
  21199. // if item.ChrgitmLv == "2" {
  21200. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21201. //
  21202. // }
  21203. // if item.ChrgitmLv == "3" {
  21204. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21205. // }
  21206. // }
  21207. //
  21208. // if item.MedChrgitmType == "05" { //治疗费
  21209. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21210. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21211. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21212. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21213. // if item.ChrgitmLv == "1" {
  21214. //
  21215. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21216. //
  21217. // }
  21218. // if item.ChrgitmLv == "2" {
  21219. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21220. //
  21221. // }
  21222. // if item.ChrgitmLv == "3" {
  21223. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21224. // }
  21225. // }
  21226. //
  21227. // if item.MedChrgitmType == "06" { //手术费
  21228. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21229. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21230. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21231. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21232. //
  21233. // if item.ChrgitmLv == "1" {
  21234. //
  21235. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21236. //
  21237. // }
  21238. // if item.ChrgitmLv == "2" {
  21239. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21240. //
  21241. // }
  21242. // if item.ChrgitmLv == "3" {
  21243. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21244. // }
  21245. // }
  21246. //
  21247. // if item.MedChrgitmType == "07" { //手术费
  21248. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21249. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21250. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21251. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21252. //
  21253. // if item.ChrgitmLv == "1" {
  21254. //
  21255. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21256. //
  21257. // }
  21258. // if item.ChrgitmLv == "2" {
  21259. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21260. //
  21261. // }
  21262. // if item.ChrgitmLv == "3" {
  21263. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21264. // }
  21265. // }
  21266. //
  21267. // if item.MedChrgitmType == "08" { //材料费
  21268. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21269. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21270. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21271. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21272. // if item.ChrgitmLv == "1" {
  21273. //
  21274. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21275. //
  21276. // }
  21277. // if item.ChrgitmLv == "2" {
  21278. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21279. //
  21280. // }
  21281. // if item.ChrgitmLv == "3" {
  21282. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21283. // }
  21284. // }
  21285. // if item.MedChrgitmType == "09" { //西药费
  21286. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21287. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21288. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21289. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21290. // if item.ChrgitmLv == "1" {
  21291. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21292. // }
  21293. // if item.ChrgitmLv == "2" {
  21294. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21295. // }
  21296. // if item.ChrgitmLv == "3" {
  21297. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21298. // }
  21299. // }
  21300. // if item.MedChrgitmType == "10" { //中药饮片
  21301. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21302. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21303. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21304. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21305. // if item.ChrgitmLv == "1" {
  21306. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21307. // }
  21308. // if item.ChrgitmLv == "2" {
  21309. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21310. // }
  21311. // if item.ChrgitmLv == "3" {
  21312. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21313. // }
  21314. // }
  21315. //
  21316. // if item.MedChrgitmType == "11" { //中成费
  21317. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21318. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21319. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21320. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21321. // if item.ChrgitmLv == "1" {
  21322. //
  21323. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21324. //
  21325. // }
  21326. // if item.ChrgitmLv == "2" {
  21327. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21328. //
  21329. // }
  21330. // if item.ChrgitmLv == "3" {
  21331. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21332. // }
  21333. // }
  21334. //
  21335. // if item.MedChrgitmType == "12" { //中成费
  21336. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21337. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21338. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21339. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21340. // if item.ChrgitmLv == "1" {
  21341. //
  21342. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21343. //
  21344. // }
  21345. // if item.ChrgitmLv == "2" {
  21346. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21347. //
  21348. // }
  21349. // if item.ChrgitmLv == "3" {
  21350. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21351. // }
  21352. // }
  21353. //
  21354. // if item.MedChrgitmType == "13" { //中成费
  21355. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21356. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21357. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21358. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21359. // if item.ChrgitmLv == "1" {
  21360. //
  21361. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21362. //
  21363. // }
  21364. // if item.ChrgitmLv == "2" {
  21365. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21366. //
  21367. // }
  21368. // if item.ChrgitmLv == "3" {
  21369. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21370. // }
  21371. // }
  21372. //
  21373. // if item.MedChrgitmType == "14" { //其他费
  21374. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21375. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21376. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21377. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21378. // if item.ChrgitmLv == "1" {
  21379. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21380. //
  21381. // }
  21382. // if item.ChrgitmLv == "2" {
  21383. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21384. //
  21385. // }
  21386. // if item.ChrgitmLv == "3" {
  21387. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21388. // }
  21389. // }
  21390. //
  21391. // }
  21392. //
  21393. // var iteminfoStructs []service.IteminfoStruct
  21394. //
  21395. // if bedCostTotal != 0 {
  21396. // iteminfo.MedChrgitm = "01"
  21397. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21398. // iteminfo.Amt = bedCostTotal
  21399. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  21400. // iteminfo.ClabAmt = bed_clab_amt
  21401. // iteminfo.OthAmt = bed_other_amt
  21402. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21403. // }
  21404. //
  21405. // if examineCostTotal != 0 {
  21406. // iteminfo.MedChrgitm = "02"
  21407. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  21408. // iteminfo.Amt = examineCostTotal
  21409. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  21410. // iteminfo.ClabAmt = examine_clab_amt
  21411. // iteminfo.OthAmt = examine_other_amt
  21412. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21413. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21414. // }
  21415. //
  21416. // if checkCostTotal != 0 {
  21417. // iteminfo.MedChrgitm = "03"
  21418. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21419. // iteminfo.Amt = checkCostTotal
  21420. // iteminfo.ClaaSumfee = check_claa_sunmfee
  21421. // iteminfo.ClabAmt = check_clab_amt
  21422. // iteminfo.OthAmt = check_other_amt
  21423. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21424. //
  21425. // }
  21426. //
  21427. // if laboratoryCostTotal != 0 {
  21428. // iteminfo.MedChrgitm = "04"
  21429. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21430. // iteminfo.Amt = laboratoryCostTotal
  21431. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21432. // iteminfo.ClabAmt = laboratory_clab_amt
  21433. // iteminfo.OthAmt = laboratory_other_amt
  21434. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21435. //
  21436. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21437. //
  21438. // }
  21439. //
  21440. // if treatCostTotal != 0 {
  21441. // iteminfo.MedChrgitm = "05"
  21442. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21443. // iteminfo.Amt = treatCostTotal
  21444. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  21445. // iteminfo.ClabAmt = treat_clab_amt
  21446. // iteminfo.OthAmt = treat_other_amt
  21447. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21448. // //(struct4101.IteminfoStruct, iteminfo)
  21449. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21450. // }
  21451. //
  21452. // if operationCostTotal != 0 {
  21453. // iteminfo.MedChrgitm = "06"
  21454. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21455. // iteminfo.Amt = operationCostTotal
  21456. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  21457. // iteminfo.ClabAmt = operation_clab_amt
  21458. // iteminfo.OthAmt = operation_other_amt
  21459. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21460. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21461. // }
  21462. //
  21463. // if nursingCostTotal != 0 {
  21464. // iteminfo.MedChrgitm = "07"
  21465. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  21466. // iteminfo.Amt = nursingCostTotal
  21467. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  21468. // iteminfo.ClabAmt = nursing_clab_amt
  21469. // iteminfo.OthAmt = nursing_other_amt
  21470. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21471. // }
  21472. //
  21473. // if materialCostTotal != 0 {
  21474. // iteminfo.MedChrgitm = "08"
  21475. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21476. // iteminfo.Amt = materialCostTotal
  21477. // iteminfo.ClaaSumfee = material_claa_sunmfee
  21478. // iteminfo.ClabAmt = material_clab_amt
  21479. // iteminfo.OthAmt = material_other_amt
  21480. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21481. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21482. // }
  21483. //
  21484. // if westernMedicineCostTotal != 0 {
  21485. // iteminfo.MedChrgitm = "09"
  21486. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21487. // iteminfo.Amt = westernMedicineCostTotal
  21488. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21489. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21490. // iteminfo.OthAmt = westernMedicine_other_amt
  21491. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21492. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21493. //
  21494. // }
  21495. //
  21496. // if chineseMedicineCostTotal != 0 {
  21497. // iteminfo.MedChrgitm = "10"
  21498. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  21499. // iteminfo.Amt = chineseMedicineCostTotal
  21500. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  21501. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  21502. // iteminfo.OthAmt = chinese_medicine_other_amt
  21503. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21504. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21505. //
  21506. // }
  21507. //
  21508. // if chineseTraditionalMedicineCostTotal != 0 {
  21509. // iteminfo.MedChrgitm = "11"
  21510. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21511. // iteminfo.Amt = westernMedicineCostTotal
  21512. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21513. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21514. // iteminfo.OthAmt = westernMedicine_other_amt
  21515. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21516. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21517. //
  21518. // }
  21519. //
  21520. // if commonlyTreatmentCostTotal != 0 {
  21521. // iteminfo.MedChrgitm = "12"
  21522. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21523. // iteminfo.Amt = commonlyTreatmentCostTotal
  21524. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21525. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21526. // iteminfo.OthAmt = commonly_treatment_other_amt
  21527. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21528. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21529. //
  21530. // }
  21531. //
  21532. // if registerCostTotal != 0 {
  21533. // iteminfo.MedChrgitm = "13"
  21534. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21535. // iteminfo.Amt = registerCostTotal
  21536. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21537. // iteminfo.ClabAmt = register_clab_amt
  21538. // iteminfo.OthAmt = register_other_amt
  21539. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21540. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21541. //
  21542. // }
  21543. //
  21544. // if otherCostTotal != 0 {
  21545. // iteminfo.MedChrgitm = "14"
  21546. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21547. // iteminfo.Amt = otherCostTotal
  21548. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21549. // iteminfo.ClabAmt = other_clab_amt
  21550. // iteminfo.OthAmt = other_other_amt
  21551. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21552. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21553. //
  21554. // }
  21555. // struct4101.IteminfoStruct = iteminfoStructs
  21556. // time_arr := strings.Split(order.SetlTime, " ")
  21557. // struct4101.AdmTime = time_arr[0]
  21558. // struct4101.AdmEndTime = time_arr[0]
  21559. //
  21560. // struct4101.DoctorName = doctor.UserName
  21561. // struct4101.DoctorCode = doctor.DoctorNumber
  21562. //
  21563. // struct4101.Ntly = "中国"
  21564. // struct4101.AdmCaty = "A03.06"
  21565. // var res ResultSeventeen
  21566. // if miConfig.MdtrtareaAdmvs == "421300" {
  21567. // data := make(map[string]interface{})
  21568. // data["struct4101"] = struct4101
  21569. // data["secret_key"] = miConfig.SecretKey
  21570. // data["org_name"] = miConfig.OrgName
  21571. // data["opera"] = curRoles.UserName
  21572. // data["code"] = miConfig.Code
  21573. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21574. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21575. //
  21576. // client := &http.Client{}
  21577. // bytesData, _ := json.Marshal(data)
  21578. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21579. // resp, _ := client.Do(req)
  21580. // defer resp.Body.Close()
  21581. // body, ioErr := ioutil.ReadAll(resp.Body)
  21582. // if ioErr != nil {
  21583. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21585. // return
  21586. // }
  21587. // var respJSON map[string]interface{}
  21588. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21589. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21591. // return
  21592. // }
  21593. //
  21594. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21595. // userJSONBytes, _ := json.Marshal(respJSON)
  21596. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21597. // utils.ErrorLog("解析失败:%v", err)
  21598. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21599. // adminUser := c.GetAdminUserInfo()
  21600. // errlog := &models.HisOrderError{
  21601. // UserOrgId: adminUser.CurrentOrgId,
  21602. // Ctime: time.Now().Unix(),
  21603. // Mtime: time.Now().Unix(),
  21604. // ErrMsg: res.ErrMsg + "解析失败",
  21605. // Status: 1,
  21606. // PatientId: order_id,
  21607. // Stage: 10088,
  21608. // }
  21609. // service.CreateErrMsgLog(errlog)
  21610. // continue
  21611. // }
  21612. //
  21613. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21614. // data := make(map[string]interface{})
  21615. // data["struct4101"] = struct4101
  21616. // data["secret_key"] = miConfig.SecretKey
  21617. // data["org_name"] = miConfig.OrgName
  21618. // data["opera"] = curRoles.UserName
  21619. // data["code"] = miConfig.Code
  21620. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21621. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21622. //
  21623. // client := &http.Client{}
  21624. // bytesData, _ := json.Marshal(data)
  21625. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21626. // resp, _ := client.Do(req)
  21627. // defer resp.Body.Close()
  21628. // body, ioErr := ioutil.ReadAll(resp.Body)
  21629. // if ioErr != nil {
  21630. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21631. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21632. // return
  21633. // }
  21634. // var respJSON map[string]interface{}
  21635. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21636. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21638. // return
  21639. // }
  21640. //
  21641. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21642. // userJSONBytes, _ := json.Marshal(respJSON)
  21643. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21644. // utils.ErrorLog("解析失败:%v", err)
  21645. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21646. // adminUser := c.GetAdminUserInfo()
  21647. // errlog := &models.HisOrderError{
  21648. // UserOrgId: adminUser.CurrentOrgId,
  21649. // Ctime: time.Now().Unix(),
  21650. // Mtime: time.Now().Unix(),
  21651. // ErrMsg: res.ErrMsg + "解析失败",
  21652. // Status: 1,
  21653. // PatientId: order_id,
  21654. // Stage: 10088,
  21655. // }
  21656. // service.CreateErrMsgLog(errlog)
  21657. // continue
  21658. // }
  21659. //
  21660. // } else {
  21661. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21662. // fmt.Println(result)
  21663. //
  21664. // var dat map[string]interface{}
  21665. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21666. // fmt.Println(dat)
  21667. // } else {
  21668. // fmt.Println(err)
  21669. // }
  21670. // userJSONBytes, _ := json.Marshal(dat)
  21671. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21672. // utils.ErrorLog("解析失败:%v", err)
  21673. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21674. // adminUser := c.GetAdminUserInfo()
  21675. // errlog := &models.HisOrderError{
  21676. // UserOrgId: adminUser.CurrentOrgId,
  21677. // Ctime: time.Now().Unix(),
  21678. // Mtime: time.Now().Unix(),
  21679. // ErrMsg: res.ErrMsg + "解析失败",
  21680. // Status: 1,
  21681. // PatientId: order_id,
  21682. // Stage: 10106,
  21683. // }
  21684. // service.CreateErrMsgLog(errlog)
  21685. // continue
  21686. // }
  21687. // }
  21688. //
  21689. // if res.Infcode != 0 {
  21690. // adminUser := c.GetAdminUserInfo()
  21691. // errlog := &models.HisOrderError{
  21692. // UserOrgId: adminUser.CurrentOrgId,
  21693. // Ctime: time.Now().Unix(),
  21694. // Mtime: time.Now().Unix(),
  21695. // ErrMsg: res.ErrMsg,
  21696. // Status: 1,
  21697. // PatientId: order_id,
  21698. // Stage: 10106,
  21699. // }
  21700. // service.CreateErrMsgLog(errlog)
  21701. // continue
  21702. // } else {
  21703. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21704. // Number: res.Output.SetlListId,
  21705. // Status: 1,
  21706. // Ctime: time.Now().Unix(),
  21707. // Mtime: time.Now().Unix(),
  21708. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21709. // IsUpload: 1,
  21710. // OrderId: order_id,
  21711. // }
  21712. // service.CreateUploadRecord(hisFundSettleListResult)
  21713. // continue
  21714. // }
  21715. // }
  21716. //}
  21717. func (c *HisApiController) GetOrgInfo() {
  21718. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21719. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21720. }
  21721. func (c *HisApiController) GetHisPatientInfo() {
  21722. medical_insurance_card := c.GetString("medical_insurance_card")
  21723. id_card_type, _ := c.GetInt64("id_card_type")
  21724. id_card := c.GetString("id_card")
  21725. adminInfo := c.GetAdminUserInfo()
  21726. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21727. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21728. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21729. IdCardNo := ""
  21730. if id_card_type == 1 {
  21731. IdCardNo = medical_insurance_card
  21732. } else if id_card_type == 2 {
  21733. IdCardNo = id_card
  21734. }
  21735. if config.IsOpen == 1 {
  21736. 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
  21737. resp, requestErr := http.Get(api)
  21738. if requestErr != nil {
  21739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21740. return
  21741. }
  21742. defer resp.Body.Close()
  21743. body, ioErr := ioutil.ReadAll(resp.Body)
  21744. if ioErr != nil {
  21745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21747. return
  21748. }
  21749. var respJSON map[string]interface{}
  21750. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21753. return
  21754. }
  21755. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21756. userJSONBytes, _ := json.Marshal(userJSON)
  21757. var res ResultTwo
  21758. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21759. utils.ErrorLog("解析失败:%v", err)
  21760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21761. return
  21762. }
  21763. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21764. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21765. infoStr := string(Iinfos)
  21766. idetinfoStr := string(Idetinfos)
  21767. if res.Infcode == 0 {
  21768. his := models.VMHisPatient{
  21769. Status: 1,
  21770. Ctime: time.Now().Unix(),
  21771. Mtime: time.Now().Unix(),
  21772. PsnNo: res.Output.Baseinfo.PsnNo,
  21773. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21774. Certno: res.Output.Baseinfo.Certno,
  21775. PsnName: res.Output.Baseinfo.PsnName,
  21776. Gend: res.Output.Baseinfo.Gend,
  21777. Naty: res.Output.Baseinfo.Naty,
  21778. Iinfo: infoStr,
  21779. Idetinfo: idetinfoStr,
  21780. UserOrgId: adminInfo.CurrentOrgId,
  21781. IsReturn: 1,
  21782. IdCardType: id_card_type,
  21783. }
  21784. c.ServeSuccessJSON(map[string]interface{}{
  21785. "info": his,
  21786. })
  21787. } else {
  21788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21789. return
  21790. }
  21791. }
  21792. }
  21793. //func GetBasBaseInfo() (jsonStr string, err error) {
  21794. //
  21795. // handle := syscall.NewLazyDLL("SSCard.dll")
  21796. // add := handle.NewProc("ReadCardBas")
  21797. // str := make([]byte, 1024)
  21798. // str1 := make([]byte, 1024)
  21799. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21800. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21801. //
  21802. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21803. //
  21804. // fmt.Println("> Add(4,5)的结果为:", ret)
  21805. // handle.Release()
  21806. //
  21807. // return "", nil
  21808. //
  21809. //}
  21810. //func GetQRBaseInfo() (jsonStr string, err error) {
  21811. // handle := syscall.LoadDLL("SSCard.dll")
  21812. // ReadCardBas := handle.FindProc("GetQRBase")
  21813. //
  21814. // str := make([]byte, 256)
  21815. // str1 := make([]byte, 256)
  21816. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21817. //
  21818. // fmt.Println(string(str))
  21819. // fmt.Println(r)
  21820. // return string(str), nil
  21821. //}
  21822. //func CardInit() int {
  21823. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21824. // add := DllTestDef.MustFindProc("Init")
  21825. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21826. // if err != nil {
  21827. // fmt.Println("SSCard的运算结果为:", ret)
  21828. // }
  21829. // result := int(ret)
  21830. // return result
  21831. //}
  21832. //func CardInit() int {
  21833. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21834. // if err != nil {
  21835. // fmt.Println("SSCard的运算结果为:", ret)
  21836. // }
  21837. // fmt.Println(err)
  21838. // result := int(ret)
  21839. // return result
  21840. //}
  21841. func IntPtr(n int) uintptr {
  21842. return uintptr(n)
  21843. }
  21844. func StrPtr(s string) uintptr {
  21845. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21846. }
  21847. type Result2001 struct {
  21848. Cainfo interface{} `json:"cainfo"`
  21849. ErrMsg string `json:"err_msg"`
  21850. InfRefmsgid string `json:"inf_refmsgid"`
  21851. Infcode int64 `json:"infcode"`
  21852. Output struct {
  21853. Trtinfo struct {
  21854. PsnNo string `json:"psn_no"`
  21855. TrtChkType string `json:"trt_chk_type"`
  21856. FundPayType string `json:"fund_pay_type"`
  21857. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21858. Begndate string `json:"begndate"`
  21859. Enddate string `json:"enddate"`
  21860. TrtChkRslt string `json:"trt_chk_rslt"`
  21861. } `json:"trtinfo"`
  21862. } `json:"output"`
  21863. RefmsgTime string `json:"refmsg_time"`
  21864. RespondTime string `json:"respond_time"`
  21865. Signtype interface{} `json:"signtype"`
  21866. WarnMsg interface{} `json:"warn_msg"`
  21867. }
  21868. type Result2001Org10265 struct {
  21869. Cainfo interface{} `json:"cainfo"`
  21870. ErrMsg string `json:"err_msg"`
  21871. InfRefmsgid string `json:"inf_refmsgid"`
  21872. Infcode string `json:"infcode"`
  21873. Output struct {
  21874. Trtinfo struct {
  21875. PsnNo string `json:"psn_no"`
  21876. TrtChkType string `json:"trt_chk_type"`
  21877. FundPayType string `json:"fund_pay_type"`
  21878. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21879. Begndate string `json:"begndate"`
  21880. Enddate string `json:"enddate"`
  21881. TrtChkRslt string `json:"trt_chk_rslt"`
  21882. } `json:"trtinfo"`
  21883. } `json:"output"`
  21884. RefmsgTime string `json:"refmsg_time"`
  21885. RespondTime string `json:"respond_time"`
  21886. Signtype interface{} `json:"signtype"`
  21887. WarnMsg interface{} `json:"warn_msg"`
  21888. }
  21889. type ResultTwo struct {
  21890. ErrMsg string `json:"err_msg"`
  21891. InfRefmsgid string `json:"inf_refmsgid"`
  21892. Infcode int64 `json:"infcode"`
  21893. Output struct {
  21894. Baseinfo struct {
  21895. //Brdy string `json:"brdy"`
  21896. Certno string `json:"certno"`
  21897. Gend string `json:"gend"`
  21898. Naty string `json:"naty"`
  21899. PsnCertType string `json:"psn_cert_type"`
  21900. PsnName string `json:"psn_name"`
  21901. PsnNo string `json:"psn_no"`
  21902. } `json:"baseinfo"`
  21903. Idetinfo []interface{} `json:"idetinfo"`
  21904. Iinfo []struct {
  21905. Balc float64 `json:"balc"`
  21906. CvlservFlag string `json:"cvlserv_flag"`
  21907. EmpName string `json:"emp_name"`
  21908. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21909. Insutype string `json:"insutype"`
  21910. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21911. //PausInsuDate string `json:"paus_insu_date"`
  21912. //PsnInsuDate string `json:"psn_insu_date"`
  21913. PsnInsuStas string `json:"psn_insu_stas"`
  21914. PsnType string `json:"psn_type"`
  21915. } `json:"insuinfo"`
  21916. } `json:"output"`
  21917. RefmsgTime string `json:"refmsg_time"`
  21918. RespondTime string `json:"respond_time"`
  21919. Signtype interface{} `json:"signtype"`
  21920. WarnInfo interface{} `json:"warn_info"`
  21921. }
  21922. type ResultTwo10265 struct {
  21923. ErrMsg string `json:"err_msg"`
  21924. InfRefmsgid string `json:"inf_refmsgid"`
  21925. Infcode string `json:"infcode"`
  21926. Output struct {
  21927. Baseinfo struct {
  21928. //Brdy string `json:"brdy"`
  21929. Certno string `json:"certno"`
  21930. Gend string `json:"gend"`
  21931. Naty string `json:"naty"`
  21932. PsnCertType string `json:"psn_cert_type"`
  21933. PsnName string `json:"psn_name"`
  21934. PsnNo string `json:"psn_no"`
  21935. } `json:"baseinfo"`
  21936. Idetinfo []interface{} `json:"idetinfo"`
  21937. Iinfo []struct {
  21938. Balc float64 `json:"balc"`
  21939. CvlservFlag string `json:"cvlserv_flag"`
  21940. EmpName string `json:"emp_name"`
  21941. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21942. Insutype string `json:"insutype"`
  21943. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21944. PsnInsuStas string `json:"psn_insu_stas"`
  21945. PsnType string `json:"psn_type"`
  21946. } `json:"insuinfo"`
  21947. } `json:"output"`
  21948. RefmsgTime string `json:"refmsg_time"`
  21949. RespondTime string `json:"respond_time"`
  21950. Signtype interface{} `json:"signtype"`
  21951. WarnInfo interface{} `json:"warn_info"`
  21952. }
  21953. type ResultThree struct {
  21954. Cainfo interface{} `json:"cainfo"`
  21955. ErrMsg string `json:"err_msg"`
  21956. InfRefmsgid string `json:"inf_refmsgid"`
  21957. Infcode int64 `json:"infcode"`
  21958. Output struct {
  21959. Data struct {
  21960. IptOtpNo string `json:"ipt_otp_no"`
  21961. MdtrtID string `json:"mdtrt_id"`
  21962. PsnNo string `json:"psn_no"`
  21963. } `json:"data"`
  21964. } `json:"output"`
  21965. RefmsgTime string `json:"refmsg_time"`
  21966. RespondTime string `json:"respond_time"`
  21967. Signtype interface{} `json:"signtype"`
  21968. WarnMsg interface{} `json:"warn_msg"`
  21969. }
  21970. type ResultThree10265 struct {
  21971. Cainfo interface{} `json:"cainfo"`
  21972. ErrMsg string `json:"err_msg"`
  21973. InfRefmsgid string `json:"inf_refmsgid"`
  21974. Infcode string `json:"infcode"`
  21975. Output struct {
  21976. Data struct {
  21977. IptOtpNo string `json:"ipt_otp_no"`
  21978. MdtrtID string `json:"mdtrt_id"`
  21979. PsnNo string `json:"psn_no"`
  21980. } `json:"data"`
  21981. } `json:"output"`
  21982. RefmsgTime string `json:"refmsg_time"`
  21983. RespondTime string `json:"respond_time"`
  21984. Signtype interface{} `json:"signtype"`
  21985. WarnMsg interface{} `json:"warn_msg"`
  21986. }
  21987. type ResultFour struct {
  21988. Cainfo string `json:"cainfo"`
  21989. ErrMsg string `json:"err_msg"`
  21990. InfRefmsgid string `json:"inf_refmsgid"`
  21991. Infcode int64 `json:"infcode"`
  21992. Output struct {
  21993. Result []struct {
  21994. BasMednFlag string `json:"bas_medn_flag"`
  21995. ChldMedcFlag string `json:"chld_medc_flag"`
  21996. ChrgitmLv string `json:"chrgitm_lv"`
  21997. Cnt float64 `json:"cnt"`
  21998. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21999. DrtReimFlag string `json:"drt_reim_flag"`
  22000. FeedetlSn string `json:"feedetl_sn"`
  22001. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22002. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22003. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22004. ListSpItemFlag string `json:"list_sp_item_flag"`
  22005. LmtUsedFlag string `json:"lmt_used_flag"`
  22006. MedChrgitmType string `json:"med_chrgitm_type"`
  22007. Memo string `json:"memo"`
  22008. OverlmtAmt float64 `json:"overlmt_amt"`
  22009. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22010. Pric float64 `json:"pric"`
  22011. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22012. SelfpayProp float64 `json:"selfpay_prop"`
  22013. } `json:"result"`
  22014. } `json:"output"`
  22015. RefmsgTime string `json:"refmsg_time"`
  22016. RespondTime string `json:"respond_time"`
  22017. Signtype string `json:"signtype"`
  22018. WarnMsg string `json:"warn_msg"`
  22019. }
  22020. type ResultFour10265 struct {
  22021. Cainfo string `json:"cainfo"`
  22022. ErrMsg string `json:"err_msg"`
  22023. InfRefmsgid string `json:"inf_refmsgid"`
  22024. Infcode string `json:"infcode"`
  22025. Output struct {
  22026. Result []struct {
  22027. BasMednFlag string `json:"bas_medn_flag"`
  22028. ChldMedcFlag string `json:"chld_medc_flag"`
  22029. ChrgitmLv string `json:"chrgitm_lv"`
  22030. Cnt float64 `json:"cnt"`
  22031. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22032. DrtReimFlag string `json:"drt_reim_flag"`
  22033. FeedetlSn string `json:"feedetl_sn"`
  22034. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22035. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22036. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22037. ListSpItemFlag string `json:"list_sp_item_flag"`
  22038. LmtUsedFlag string `json:"lmt_used_flag"`
  22039. MedChrgitmType string `json:"med_chrgitm_type"`
  22040. Memo string `json:"memo"`
  22041. OverlmtAmt float64 `json:"overlmt_amt"`
  22042. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22043. Pric float64 `json:"pric"`
  22044. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22045. SelfpayProp float64 `json:"selfpay_prop"`
  22046. } `json:"result"`
  22047. } `json:"output"`
  22048. RefmsgTime string `json:"refmsg_time"`
  22049. RespondTime string `json:"respond_time"`
  22050. Signtype string `json:"signtype"`
  22051. WarnMsg string `json:"warn_msg"`
  22052. }
  22053. type ResultMemo struct {
  22054. InsuAdmdvs string `json:"insuAdmdvs"`
  22055. }
  22056. // [{"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}]
  22057. type ResultIDInfo struct {
  22058. Begntime string `json:"begntime"`
  22059. Endtime string `json:"endtime"`
  22060. Memo string `json:"memo"`
  22061. }
  22062. type ResultFive struct {
  22063. Balc float64 `json:"balc"`
  22064. CvlservFlag string `json:"cvlserv_flag"`
  22065. EmpName string `json:"emp_name"`
  22066. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22067. Insutype string `json:"insutype"`
  22068. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22069. PausInsuDate string `json:"paus_insu_date"`
  22070. PsnInsuDate string `json:"psn_insu_date"`
  22071. PsnInsuStas string `json:"psn_insu_stas"`
  22072. PsnType string `json:"psn_type"`
  22073. }
  22074. type ResultSix struct {
  22075. Cainfo interface{} `json:"cainfo"`
  22076. ErrMsg string `json:"err_msg"`
  22077. InfRefmsgid string `json:"inf_refmsgid"`
  22078. Infcode int64 `json:"infcode"`
  22079. Output struct {
  22080. } `json:"output"`
  22081. RefmsgTime string `json:"refmsg_time"`
  22082. RespondTime string `json:"respond_time"`
  22083. Signtype interface{} `json:"signtype"`
  22084. WarnMsg interface{} `json:"warn_msg"`
  22085. }
  22086. type ResultSix3103 struct {
  22087. Cainfo interface{} `json:"cainfo"`
  22088. ErrMsg string `json:"err_msg"`
  22089. InfRefmsgid string `json:"inf_refmsgid"`
  22090. Infcode int64 `json:"infcode"`
  22091. RefmsgTime string `json:"refmsg_time"`
  22092. RespondTime string `json:"respond_time"`
  22093. Signtype interface{} `json:"signtype"`
  22094. WarnMsg interface{} `json:"warn_msg"`
  22095. }
  22096. type FJ3507Result struct {
  22097. Cainfo interface{} `json:"cainfo"`
  22098. ErrMsg string `json:"err_msg"`
  22099. InfRefmsgid string `json:"inf_refmsgid"`
  22100. Infcode int64 `json:"infcode"`
  22101. Output struct {
  22102. retRslt string `json:"retRslt"`
  22103. msgRslt string `json:"msgRslt"`
  22104. } `json:"output"`
  22105. RefmsgTime string `json:"refmsg_time"`
  22106. RespondTime string `json:"respond_time"`
  22107. Signtype interface{} `json:"signtype"`
  22108. WarnMsg interface{} `json:"warn_msg"`
  22109. }
  22110. type FJ3507ResultFor10188 struct {
  22111. Cainfo interface{} `json:"cainfo"`
  22112. ErrMsg string `json:"err_msg"`
  22113. InfRefmsgid string `json:"inf_refmsgid"`
  22114. Infcode string `json:"infcode"`
  22115. RefmsgTime string `json:"refmsg_time"`
  22116. RespondTime string `json:"respond_time"`
  22117. Signtype interface{} `json:"signtype"`
  22118. WarnMsg interface{} `json:"warn_msg"`
  22119. }
  22120. type Result2406 struct {
  22121. Cainfo interface{} `json:"cainfo"`
  22122. ErrMsg string `json:"err_msg"`
  22123. InfRefmsgid string `json:"inf_refmsgid"`
  22124. Infcode int64 `json:"infcode"`
  22125. Output struct {
  22126. Result struct {
  22127. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22128. } `json:"result"`
  22129. } `json:"output"`
  22130. RefmsgTime string `json:"refmsg_time"`
  22131. RespondTime string `json:"respond_time"`
  22132. Signtype interface{} `json:"signtype"`
  22133. WarnMsg interface{} `json:"warn_msg"`
  22134. }
  22135. type GZResultSix struct {
  22136. Cainfo interface{} `json:"cainfo"`
  22137. ErrMsg string `json:"err_msg"`
  22138. InfRefmsgid string `json:"inf_refmsgid"`
  22139. Infcode int64 `json:"infcode"`
  22140. Output string `json:"output"`
  22141. RefmsgTime string `json:"refmsg_time"`
  22142. RespondTime string `json:"respond_time"`
  22143. Signtype interface{} `json:"signtype"`
  22144. WarnMsg interface{} `json:"warn_msg"`
  22145. }
  22146. type ResultSix10265 struct {
  22147. Cainfo interface{} `json:"cainfo"`
  22148. ErrMsg string `json:"err_msg"`
  22149. InfRefmsgid string `json:"inf_refmsgid"`
  22150. Infcode string `json:"infcode"`
  22151. Output struct {
  22152. } `json:"output"`
  22153. RefmsgTime string `json:"refmsg_time"`
  22154. RespondTime string `json:"respond_time"`
  22155. Signtype interface{} `json:"signtype"`
  22156. WarnMsg interface{} `json:"warn_msg"`
  22157. }
  22158. type ResultSeven struct {
  22159. Cainfo string `json:"cainfo"`
  22160. ErrMsg string `json:"err_msg"`
  22161. InfRefmsgid string `json:"inf_refmsgid"`
  22162. Infcode int64 `json:"infcode"`
  22163. Output struct {
  22164. Setlinfo struct {
  22165. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22166. AcctPay float64 `json:"acct_pay"`
  22167. ActPayDedc float64 `json:"act_pay_dedc"`
  22168. Age float64 `json:"age"`
  22169. Balc float64 `json:"balc"`
  22170. Certno string `json:"certno"`
  22171. ClrOptins string `json:"clr_optins"`
  22172. ClrType string `json:"clr_type"`
  22173. ClrWay string `json:"clr_way"`
  22174. CvlservFlag string `json:"cvlserv_flag"`
  22175. CvlservPay float64 `json:"cvlserv_pay"`
  22176. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22177. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22178. Gend string `json:"gend"`
  22179. HifesPay float64 `json:"hifes_pay"`
  22180. HifmiPay float64 `json:"hifmi_pay"`
  22181. HifpPay float64 `json:"hifp_pay"`
  22182. HospPartAmt float64 `json:"hosp_part_amt"`
  22183. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22184. Insutype string `json:"insutype"`
  22185. MafPay float64 `json:"maf_pay"`
  22186. MdtrtCertType string `json:"mdtrt_cert_type"`
  22187. HifobPay float64 `json:"hifob_pay"`
  22188. MdtrtID string `json:"mdtrt_id"`
  22189. MedType string `json:"med_type"`
  22190. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22191. MedinsSetlID string `json:"medins_setl_id"`
  22192. Naty string `json:"naty"`
  22193. OthPay float64 `json:"oth_pay"`
  22194. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22195. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22196. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22197. PsnCashPay float64 `json:"psn_cash_pay"`
  22198. PsnCertType string `json:"psn_cert_type"`
  22199. PsnName string `json:"psn_name"`
  22200. PsnNo string `json:"psn_no"`
  22201. PsnPartAmt float64 `json:"psn_part_amt"`
  22202. PsnType string `json:"psn_type"`
  22203. SetlID string `json:"setl_id"`
  22204. SetlTime string `json:"setl_time"`
  22205. } `json:"setlinfo"`
  22206. Setldetail interface{} `json:"setldetail"`
  22207. } `json:"output"`
  22208. RefmsgTime string `json:"refmsg_time"`
  22209. RespondTime string `json:"respond_time"`
  22210. Signtype interface{} `json:"signtype"`
  22211. WarnMsg interface{} `json:"warn_msg"`
  22212. }
  22213. type ResultSevenAH struct {
  22214. Cainfo string `json:"cainfo"`
  22215. ErrMsg string `json:"err_msg"`
  22216. InfRefmsgid string `json:"inf_refmsgid"`
  22217. Infcode int64 `json:"infcode"`
  22218. Output struct {
  22219. Setlinfo struct {
  22220. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22221. AcctPay float64 `json:"acct_pay"`
  22222. ActPayDedc float64 `json:"act_pay_dedc"`
  22223. Age float64 `json:"age"`
  22224. Balc float64 `json:"balc"`
  22225. Certno string `json:"certno"`
  22226. ClrOptins string `json:"clr_optins"`
  22227. ClrType string `json:"clr_type"`
  22228. ClrWay string `json:"clr_way"`
  22229. CvlservFlag string `json:"cvlserv_flag"`
  22230. CvlservPay float64 `json:"cvlserv_pay"`
  22231. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22232. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22233. Gend string `json:"gend"`
  22234. HifesPay float64 `json:"hifes_pay"`
  22235. HifmiPay float64 `json:"hifmi_pay"`
  22236. HifpPay float64 `json:"hifp_pay"`
  22237. HospPartAmt float64 `json:"hosp_part_amt"`
  22238. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22239. Insutype string `json:"insutype"`
  22240. MafPay float64 `json:"maf_pay"`
  22241. MdtrtCertType string `json:"mdtrt_cert_type"`
  22242. HifobPay float64 `json:"hifob_pay"`
  22243. MdtrtID string `json:"mdtrt_id"`
  22244. MedType string `json:"med_type"`
  22245. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22246. MedinsSetlID string `json:"medins_setl_id"`
  22247. Naty string `json:"naty"`
  22248. OthPay float64 `json:"oth_pay"`
  22249. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22250. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22251. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22252. PsnCashPay float64 `json:"psn_cash_pay"`
  22253. PsnCertType string `json:"psn_cert_type"`
  22254. PsnName string `json:"psn_name"`
  22255. PsnNo string `json:"psn_no"`
  22256. PsnPartAmt float64 `json:"psn_part_amt"`
  22257. PsnType string `json:"psn_type"`
  22258. SetlID string `json:"setl_id"`
  22259. SetlTime int64 `json:"setl_time"`
  22260. } `json:"setlinfo"`
  22261. Setldetail interface{} `json:"setldetail"`
  22262. } `json:"output"`
  22263. RefmsgTime string `json:"refmsg_time"`
  22264. RespondTime string `json:"respond_time"`
  22265. Signtype interface{} `json:"signtype"`
  22266. WarnMsg interface{} `json:"warn_msg"`
  22267. }
  22268. type ResultSeven10265 struct {
  22269. Cainfo string `json:"cainfo"`
  22270. ErrMsg string `json:"err_msg"`
  22271. InfRefmsgid string `json:"inf_refmsgid"`
  22272. Infcode string `json:"infcode"`
  22273. Output struct {
  22274. Setlinfo struct {
  22275. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22276. AcctPay float64 `json:"acct_pay"`
  22277. ActPayDedc float64 `json:"act_pay_dedc"`
  22278. Age float64 `json:"age"`
  22279. Balc float64 `json:"balc"`
  22280. Certno string `json:"certno"`
  22281. ClrOptins string `json:"clr_optins"`
  22282. ClrType string `json:"clr_type"`
  22283. ClrWay string `json:"clr_way"`
  22284. CvlservFlag string `json:"cvlserv_flag"`
  22285. CvlservPay float64 `json:"cvlserv_pay"`
  22286. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22287. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22288. Gend string `json:"gend"`
  22289. HifesPay float64 `json:"hifes_pay"`
  22290. HifmiPay float64 `json:"hifmi_pay"`
  22291. HifpPay float64 `json:"hifp_pay"`
  22292. HospPartAmt float64 `json:"hosp_part_amt"`
  22293. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22294. Insutype string `json:"insutype"`
  22295. MafPay float64 `json:"maf_pay"`
  22296. MdtrtCertType string `json:"mdtrt_cert_type"`
  22297. HifobPay float64 `json:"hifob_pay"`
  22298. MdtrtID string `json:"mdtrt_id"`
  22299. MedType string `json:"med_type"`
  22300. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22301. MedinsSetlID string `json:"medins_setl_id"`
  22302. Naty string `json:"naty"`
  22303. OthPay float64 `json:"oth_pay"`
  22304. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22305. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22306. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22307. PsnCashPay float64 `json:"psn_cash_pay"`
  22308. PsnCertType string `json:"psn_cert_type"`
  22309. PsnName string `json:"psn_name"`
  22310. PsnNo string `json:"psn_no"`
  22311. PsnPartAmt float64 `json:"psn_part_amt"`
  22312. PsnType string `json:"psn_type"`
  22313. SetlID string `json:"setl_id"`
  22314. SetlTime string `json:"setl_time"`
  22315. } `json:"setlinfo"`
  22316. Setldetail interface{} `json:"setldetail"`
  22317. } `json:"output"`
  22318. RefmsgTime string `json:"refmsg_time"`
  22319. RespondTime string `json:"respond_time"`
  22320. Signtype interface{} `json:"signtype"`
  22321. WarnMsg interface{} `json:"warn_msg"`
  22322. }
  22323. type ResultSeven10265Two struct {
  22324. Cainfo string `json:"cainfo"`
  22325. ErrMsg string `json:"err_msg"`
  22326. InfRefmsgid string `json:"inf_refmsgid"`
  22327. Infcode string `json:"infcode"`
  22328. Output struct {
  22329. Setlinfo struct {
  22330. AcctMulaidPay string `json:"acct_mulaid_pay"`
  22331. AcctPay float64 `json:"acct_pay"`
  22332. ActPayDedc float64 `json:"act_pay_dedc"`
  22333. Age float64 `json:"age"`
  22334. Balc float64 `json:"balc"`
  22335. Certno string `json:"certno"`
  22336. ClrOptins string `json:"clr_optins"`
  22337. ClrType string `json:"clr_type"`
  22338. ClrWay string `json:"clr_way"`
  22339. CvlservFlag string `json:"cvlserv_flag"`
  22340. CvlservPay float64 `json:"cvlserv_pay"`
  22341. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22342. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22343. Gend string `json:"gend"`
  22344. HifesPay float64 `json:"hifes_pay"`
  22345. HifmiPay float64 `json:"hifmi_pay"`
  22346. HifpPay float64 `json:"hifp_pay"`
  22347. HospPartAmt string `json:"hosp_part_amt"`
  22348. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22349. Insutype string `json:"insutype"`
  22350. MafPay float64 `json:"maf_pay"`
  22351. MdtrtCertType string `json:"mdtrt_cert_type"`
  22352. HifobPay float64 `json:"hifob_pay"`
  22353. MdtrtID string `json:"mdtrt_id"`
  22354. MedType string `json:"med_type"`
  22355. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22356. MedinsSetlID string `json:"medins_setl_id"`
  22357. Naty string `json:"naty"`
  22358. OthPay float64 `json:"oth_pay"`
  22359. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22360. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22361. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22362. PsnCashPay float64 `json:"psn_cash_pay"`
  22363. PsnCertType string `json:"psn_cert_type"`
  22364. PsnName string `json:"psn_name"`
  22365. PsnNo string `json:"psn_no"`
  22366. PsnPartAmt float64 `json:"psn_part_amt"`
  22367. PsnType string `json:"psn_type"`
  22368. SetlID string `json:"setl_id"`
  22369. SetlTime string `json:"setl_time"`
  22370. } `json:"setlinfo"`
  22371. Setldetail interface{} `json:"setldetail"`
  22372. } `json:"output"`
  22373. RefmsgTime string `json:"refmsg_time"`
  22374. RespondTime string `json:"respond_time"`
  22375. Signtype interface{} `json:"signtype"`
  22376. WarnMsg interface{} `json:"warn_msg"`
  22377. }
  22378. type GZResultSeven10265Two struct {
  22379. Cainfo string `json:"cainfo"`
  22380. ErrMsg string `json:"err_msg"`
  22381. InfRefmsgid string `json:"inf_refmsgid"`
  22382. Infcode int64 `json:"infcode"`
  22383. Output struct {
  22384. Setlinfo struct {
  22385. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22386. AcctPay float64 `json:"acct_pay"`
  22387. ActPayDedc float64 `json:"act_pay_dedc"`
  22388. Age float64 `json:"age"`
  22389. Balc float64 `json:"balc"`
  22390. Certno string `json:"certno"`
  22391. ClrOptins string `json:"clr_optins"`
  22392. ClrType string `json:"clr_type"`
  22393. ClrWay string `json:"clr_way"`
  22394. CvlservFlag string `json:"cvlserv_flag"`
  22395. CvlservPay float64 `json:"cvlserv_pay"`
  22396. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22397. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22398. Gend string `json:"gend"`
  22399. HifesPay float64 `json:"hifes_pay"`
  22400. HifmiPay float64 `json:"hifmi_pay"`
  22401. HifpPay float64 `json:"hifp_pay"`
  22402. HospPartAmt float64 `json:"hosp_part_amt"`
  22403. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22404. Insutype string `json:"insutype"`
  22405. MafPay float64 `json:"maf_pay"`
  22406. MdtrtCertType string `json:"mdtrt_cert_type"`
  22407. HifobPay float64 `json:"hifob_pay"`
  22408. MdtrtID string `json:"mdtrt_id"`
  22409. MedType string `json:"med_type"`
  22410. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22411. MedinsSetlID string `json:"medins_setl_id"`
  22412. Naty string `json:"naty"`
  22413. OthPay float64 `json:"oth_pay"`
  22414. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22415. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22416. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22417. PsnCashPay float64 `json:"psn_cash_pay"`
  22418. PsnCertType string `json:"psn_cert_type"`
  22419. PsnName string `json:"psn_name"`
  22420. PsnNo string `json:"psn_no"`
  22421. PsnPartAmt float64 `json:"psn_part_amt"`
  22422. PsnType string `json:"psn_type"`
  22423. SetlID string `json:"setl_id"`
  22424. SetlTime string `json:"setl_time"`
  22425. } `json:"setlinfo"`
  22426. Setldetail interface{} `json:"setldetail"`
  22427. } `json:"output"`
  22428. RefmsgTime string `json:"refmsg_time"`
  22429. RespondTime string `json:"respond_time"`
  22430. Signtype interface{} `json:"signtype"`
  22431. WarnMsg interface{} `json:"warn_msg"`
  22432. }
  22433. type ResultEight struct {
  22434. Cainfo string `json:"cainfo"`
  22435. ErrMsg string `json:"err_msg"`
  22436. InfRefmsgid string `json:"inf_refmsgid"`
  22437. Infcode int64 `json:"infcode"`
  22438. Output struct {
  22439. Stmtinfo struct {
  22440. SetlOptins string `json:"setl_optins"`
  22441. StmtRslt string `json:"stmt_rslt"`
  22442. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22443. } `json:"stmtinfo"`
  22444. } `json:"output"`
  22445. RefmsgTime string `json:"refmsg_time"`
  22446. RespondTime string `json:"respond_time"`
  22447. Signtype interface{} `json:"signtype"`
  22448. WarnMsg interface{} `json:"warn_msg"`
  22449. }
  22450. type ResultEightFor10188 struct {
  22451. Cainfo string `json:"cainfo"`
  22452. ErrMsg string `json:"err_msg"`
  22453. InfRefmsgid string `json:"inf_refmsgid"`
  22454. Infcode string `json:"infcode"`
  22455. Output struct {
  22456. Stmtinfo struct {
  22457. SetlOptins string `json:"setl_optins"`
  22458. StmtRslt string `json:"stmt_rslt"`
  22459. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22460. } `json:"stmtinfo"`
  22461. } `json:"output"`
  22462. RefmsgTime string `json:"refmsg_time"`
  22463. RespondTime string `json:"respond_time"`
  22464. Signtype interface{} `json:"signtype"`
  22465. WarnMsg interface{} `json:"warn_msg"`
  22466. }
  22467. type ResultNine struct {
  22468. Cainfo string `json:"cainfo"`
  22469. ErrMsg string `json:"err_msg"`
  22470. InfRefmsgid string `json:"inf_refmsgid"`
  22471. Infcode int64 `json:"infcode"`
  22472. Output struct {
  22473. FileQuryNo string `json:"file_qury_no"`
  22474. } `json:"output"`
  22475. RefmsgTime string `json:"refmsg_time"`
  22476. RespondTime string `json:"respond_time"`
  22477. Signtype interface{} `json:"signtype"`
  22478. WarnMsg interface{} `json:"warn_msg"`
  22479. }
  22480. type ResultTen struct {
  22481. Cainfo string `json:"cainfo"`
  22482. ErrMsg string `json:"err_msg"`
  22483. InfRefmsgid string `json:"inf_refmsgid"`
  22484. Infcode int64 `json:"infcode"`
  22485. Output struct {
  22486. Fileinfo struct {
  22487. DldEndtime string `json:"dld_endtime"`
  22488. FileQuryNo string `json:"file_qury_no"`
  22489. Filename string `json:"filename"`
  22490. } `json:"fileinfo"`
  22491. } `json:"output"`
  22492. RefmsgTime string `json:"refmsg_time"`
  22493. RespondTime string `json:"respond_time"`
  22494. Signtype interface{} `json:"signtype"`
  22495. WarnMsg interface{} `json:"warn_msg"`
  22496. }
  22497. type Result5262 struct {
  22498. ErrMsg string `json:"err_msg"`
  22499. InfRefmsgid string `json:"inf_refmsgid"`
  22500. Infcode int64 `json:"infcode"`
  22501. Output struct {
  22502. PageInfo struct {
  22503. Size int `json:"size"`
  22504. RecordCounts int `json:"record_counts"`
  22505. } `json:"page_info"`
  22506. Idetinfo []interface{} `json:"idetinfo"`
  22507. Result []struct {
  22508. SetlID string `json:"setl_id"`
  22509. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22510. MdtrtID string `json:"mdtrt_id"`
  22511. InitSetlID string `json:"init_setl_id,omitempty"`
  22512. PsnNo string `json:"psn_no"`
  22513. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22514. PsnName string `json:"psn_name"`
  22515. PsnCertType string `json:"psn_cert_type"`
  22516. Certno string `json:"certno"`
  22517. Gend string `json:"gend,omitempty"`
  22518. Naty string `json:"naty,omitempty"`
  22519. Brdy string `json:"brdy,omitempty"`
  22520. Age float64 `json:"age,omitempty"`
  22521. Insutype string `json:"insutype,omitempty"`
  22522. PsnType string `json:"psn_type"`
  22523. CvlservFlag string `json:"cvlserv_flag"`
  22524. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22525. SpPsnType string `json:"sp_psn_type,omitempty"`
  22526. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22527. ClctGrde string `json:"clct_grde,omitempty"`
  22528. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22529. NwbFlag string `json:"nwb_flag,omitempty"`
  22530. InsuAdmdvs string `json:"insu_admdvs"`
  22531. EmpNo string `json:"emp_no,omitempty"`
  22532. EmpName string `json:"emp_name,omitempty"`
  22533. EmpType string `json:"emp_type,omitempty"`
  22534. EconType string `json:"econ_type,omitempty"`
  22535. AfilIndu string `json:"afil_indu,omitempty"`
  22536. AfilRlts string `json:"afil_rlts,omitempty"`
  22537. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22538. PayLoc string `json:"pay_loc,omitempty"`
  22539. FixmedinsCode string `json:"fixmedins_code"`
  22540. FixmedinsName string `json:"fixmedins_name"`
  22541. HospLv string `json:"hosp_lv,omitempty"`
  22542. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22543. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22544. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22545. Begndate string `json:"begndate"`
  22546. Enddate string `json:"enddate"`
  22547. SetlTime string `json:"setl_time"`
  22548. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22549. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22550. MedType string `json:"med_type"`
  22551. SetlType string `json:"setl_type,omitempty"`
  22552. ClrType string `json:"clr_type,omitempty"`
  22553. ClrWay string `json:"clr_way,omitempty"`
  22554. PsnSetlway string `json:"psn_setlway,omitempty"`
  22555. ClrOptins string `json:"clr_optins,omitempty"`
  22556. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22557. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22558. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22559. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22560. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22561. DedcStd float64 `json:"dedc_std,omitempty"`
  22562. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22563. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22564. HifpPay float64 `json:"hifp_pay,omitempty"`
  22565. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22566. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22567. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22568. HifesPay float64 `json:"hifes_pay,omitempty"`
  22569. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22570. HifobPay float64 `json:"hifob_pay,omitempty"`
  22571. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22572. MafPay float64 `json:"maf_pay,omitempty"`
  22573. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22574. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22575. PsnPay float64 `json:"psn_pay,omitempty"`
  22576. AcctPay float64 `json:"acct_pay,omitempty"`
  22577. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22578. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22579. Balc float64 `json:"balc,omitempty"`
  22580. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22581. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22582. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22583. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22584. Year string `json:"year,omitempty"`
  22585. DiseNo string `json:"dise_no,omitempty"`
  22586. DiseName string `json:"dise_name,omitempty"`
  22587. Invono string `json:"invono,omitempty"`
  22588. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22589. ValiFlag string `json:"vali_flag,omitempty"`
  22590. Memo string `json:"memo,omitempty"`
  22591. Rid string `json:"rid"`
  22592. UpdtTime string `json:"updt_time,omitempty"`
  22593. CrterID string `json:"crter_id,omitempty"`
  22594. CrterName string `json:"crter_name,omitempty"`
  22595. CrteTime string `json:"crte_time,omitempty"`
  22596. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22597. OpterID string `json:"opter_id,omitempty"`
  22598. OpterName string `json:"opter_name,omitempty"`
  22599. OptTime string `json:"opt_time,omitempty"`
  22600. OptinsNo string `json:"optins_no,omitempty"`
  22601. PoolareaNo string `json:"poolarea_no,omitempty"`
  22602. } `json:"result"`
  22603. } `json:"output"`
  22604. RefmsgTime string `json:"refmsg_time"`
  22605. RespondTime string `json:"respond_time"`
  22606. Signtype interface{} `json:"signtype"`
  22607. WarnInfo interface{} `json:"warn_info"`
  22608. }
  22609. type Result5267 struct {
  22610. ErrMsg string `json:"err_msg"`
  22611. InfRefmsgid string `json:"inf_refmsgid"`
  22612. Infcode int64 `json:"infcode"`
  22613. Output struct {
  22614. PageInfo struct {
  22615. Size int `json:"size"`
  22616. RecordCounts int `json:"record_counts"`
  22617. } `json:"pageinfo"`
  22618. Result []struct {
  22619. SetlID string `json:"setl_id"`
  22620. ClrOptins string `json:"clr_optins"`
  22621. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22622. MdtrtID string `json:"mdtrt_id"`
  22623. InitSetlID string `json:"init_setl_id,omitempty"`
  22624. PsnNo string `json:"psn_no"`
  22625. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22626. PsnName string `json:"psn_name"`
  22627. PsnCertType string `json:"psn_cert_type"`
  22628. Certno string `json:"certno"`
  22629. Gend string `json:"gend,omitempty"`
  22630. Naty string `json:"naty,omitempty"`
  22631. Brdy string `json:"brdy,omitempty"`
  22632. Age float64 `json:"age,omitempty"`
  22633. Insutype string `json:"insutype,omitempty"`
  22634. PsnType string `json:"psn_type"`
  22635. CvlservFlag string `json:"cvlserv_flag"`
  22636. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22637. SpPsnType string `json:"sp_psn_type,omitempty"`
  22638. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22639. ClctGrde string `json:"clct_grde,omitempty"`
  22640. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22641. NwbFlag string `json:"nwb_flag,omitempty"`
  22642. InsuAdmdvs string `json:"insu_admdvs"`
  22643. EmpNo string `json:"emp_no,omitempty"`
  22644. EmpName string `json:"emp_name,omitempty"`
  22645. EmpType string `json:"emp_type,omitempty"`
  22646. EconType string `json:"econ_type,omitempty"`
  22647. AfilIndu string `json:"afil_indu,omitempty"`
  22648. AfilRlts string `json:"afil_rlts,omitempty"`
  22649. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22650. PayLoc string `json:"pay_loc,omitempty"`
  22651. FixmedinsCode string `json:"fixmedins_code"`
  22652. FixmedinsName string `json:"fixmedins_name"`
  22653. HospLv string `json:"hosp_lv,omitempty"`
  22654. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22655. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22656. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22657. Begndate string `json:"begndate,omitempty"`
  22658. Enddate string `json:"enddate,omitempty"`
  22659. SetlTime string `json:"setl_time,omitempty"`
  22660. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22661. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22662. MedType string `json:"med_type"`
  22663. SetlType string `json:"setl_type,omitempty"`
  22664. ClrType string `json:"clr_type,omitempty"`
  22665. ClrWay string `json:"clr_way,omitempty"`
  22666. PsnSetlway string `json:"psn_setlway,omitempty"`
  22667. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22668. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22669. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22670. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22671. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22672. DedcStd float64 `json:"dedc_std,omitempty"`
  22673. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22674. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22675. HifpPay float64 `json:"hifp_pay,omitempty"`
  22676. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22677. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22678. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22679. HifesPay float64 `json:"hifes_pay,omitempty"`
  22680. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22681. HifobPay float64 `json:"hifob_pay,omitempty"`
  22682. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22683. MafPay float64 `json:"maf_pay,omitempty"`
  22684. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22685. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22686. PsnPay float64 `json:"psn_pay,omitempty"`
  22687. AcctPay float64 `json:"acct_pay,omitempty"`
  22688. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22689. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22690. Balc float64 `json:"balc,omitempty"`
  22691. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22692. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22693. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22694. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22695. Year string `json:"year,omitempty"`
  22696. DiseNo string `json:"dise_no,omitempty"`
  22697. DiseName string `json:"dise_name,omitempty"`
  22698. Invono string `json:"invono,omitempty"`
  22699. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22700. Memo string `json:"memo,omitempty"`
  22701. UpdtTime string `json:"updt_time,omitempty"`
  22702. OpterID string `json:"opter_id,omitempty"`
  22703. OpterName string `json:"opter_name,omitempty"`
  22704. OptTime string `json:"opt_time,omitempty"`
  22705. OptinsNo string `json:"optins_no,omitempty"`
  22706. PoolareaNo string `json:"poolarea_no,omitempty"`
  22707. } `json:"result"`
  22708. } `json:"output"`
  22709. RefmsgTime string `json:"refmsg_time"`
  22710. RespondTime string `json:"respond_time"`
  22711. Signtype interface{} `json:"signtype"`
  22712. WarnInfo interface{} `json:"warn_info"`
  22713. }
  22714. // type Autogenerated struct {
  22715. // Output struct {
  22716. // Setlinfo struct {
  22717. // SetlTime string `json:"setl_time"`
  22718. // CvlservPay float64 `json:"cvlserv_pay"`
  22719. // Year string `json:"year"`
  22720. // MedType string `json:"med_type"`
  22721. // PsnPay float64 `json:"psn_pay"`
  22722. // OpterID string `json:"opter_id"`
  22723. // Begndate string `json:"begndate"`
  22724. // FlxempeFlag string `json:"flxempe_flag"`
  22725. // HifmiPay float64 `json:"hifmi_pay"`
  22726. // PsnNo string `json:"psn_no"`
  22727. // ActPayDedc float64 `json:"act_pay_dedc"`
  22728. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22729. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22730. // ClrWay string `json:"clr_way"`
  22731. // OthPay float64 `json:"oth_pay"`
  22732. // Gend string `json:"gend"`
  22733. // MdtrtID string `json:"mdtrt_id"`
  22734. // AcctPay float64 `json:"acct_pay"`
  22735. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22736. // Insutype string `json:"insutype"`
  22737. // Invono interface{} `json:"invono"`
  22738. // Enddate string `json:"enddate"`
  22739. // CashPayamt float64 `json:"cash_payamt"`
  22740. // PsnType string `json:"psn_type"`
  22741. // FixmedinsName string `json:"fixmedins_name"`
  22742. // HifpPay float64 `json:"hifp_pay"`
  22743. // NewFlag interface{} `json:"new_flag"`
  22744. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22745. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22746. // PayLoc string `json:"pay_loc"`
  22747. // ClrType string `json:"clr_type"`
  22748. // RefdSetlFlag string `json:"refd_setl_flag"`
  22749. // CvlservFlag string `json:"cvlserv_flag"`
  22750. // EmpName string `json:"emp_name"`
  22751. // Brdy string `json:"brdy"`
  22752. // Naty string `json:"naty"`
  22753. // Certno string `json:"certno"`
  22754. // DiseCode string `json:"dise_code"`
  22755. // FixmedinsCode string `json:"fixmedins_code"`
  22756. // DedcHospLv string `json:"dedc_hosp_lv"`
  22757. // OpterName string `json:"opter_name"`
  22758. // Balc float64 `json:"balc"`
  22759. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22760. // PsnCertType string `json:"psn_cert_type"`
  22761. // HifobPay float64 `json:"hifob_pay"`
  22762. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22763. // HifesPay float64 `json:"hifes_pay"`
  22764. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22765. // OptTime string `json:"opt_time"`
  22766. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22767. // SetlID string `json:"setl_id"`
  22768. // MafPay float64 `json:"maf_pay"`
  22769. // PsnName string `json:"psn_name"`
  22770. // InsuOptins interface{} `json:"insu_optins"`
  22771. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22772. // ClrOptins string `json:"clr_optins"`
  22773. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22774. // DiseName string `json:"dise_name"`
  22775. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22776. // Age float64 `json:"age"`
  22777. // DtrtCertType string `json:"dtrt_cert_type"`
  22778. // HospLv string `json:"hosp_lv"`
  22779. // } `json:"setlinfo"`
  22780. // Setldetail []struct {
  22781. // FundPayType string `json:"fund_pay_type"`
  22782. // FundPayamt float64 `json:"fund_payamt"`
  22783. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22784. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22785. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22786. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22787. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22788. // } `json:"setldetail"`
  22789. // } `json:"output"`
  22790. // Infcode int `json:"infcode"`
  22791. // WarnMsg interface{} `json:"warn_msg"`
  22792. // Cainfo interface{} `json:"cainfo"`
  22793. // ErrMsg interface{} `json:"err_msg"`
  22794. // RefmsgTime string `json:"refmsg_time"`
  22795. // Signtype interface{} `json:"signtype"`
  22796. // RespondTime string `json:"respond_time"`
  22797. // InfRefmsgid string `json:"inf_refmsgid"`
  22798. // }
  22799. type Result002 struct {
  22800. Cainfo interface{} `json:"cainfo"`
  22801. ErrMsg string `json:"err_msg"`
  22802. InfRefmsgid string `json:"inf_refmsgid"`
  22803. Infcode int64 `json:"infcode"`
  22804. Output struct {
  22805. RxFile string `json:"rx_file"`
  22806. SignDigest string `json:"sign_digest"`
  22807. SignCertSn string `json:"sign_cert_sn"`
  22808. SignCertDn string `json:"sign_cert_dn"`
  22809. } `json:"output"`
  22810. RefmsgTime string `json:"refmsg_time"`
  22811. RespondTime string `json:"respond_time"`
  22812. Signtype interface{} `json:"signtype"`
  22813. WarnMsg interface{} `json:"warn_msg"`
  22814. }
  22815. type Result003 struct {
  22816. Cainfo interface{} `json:"cainfo"`
  22817. ErrMsg string `json:"err_msg"`
  22818. InfRefmsgid string `json:"inf_refmsgid"`
  22819. Infcode int64 `json:"infcode"`
  22820. Output struct {
  22821. HiRxno string `json:"hi_rxno"`
  22822. RxStasCodg string `json:"rx_stas_codg"`
  22823. RxStasName string `json:"rx_stas_name"`
  22824. } `json:"output"`
  22825. RefmsgTime string `json:"refmsg_time"`
  22826. RespondTime string `json:"respond_time"`
  22827. Signtype interface{} `json:"signtype"`
  22828. WarnMsg interface{} `json:"warn_msg"`
  22829. }
  22830. type ResultEleven struct {
  22831. Cainfo string `json:"cainfo"`
  22832. ErrMsg string `json:"err_msg"`
  22833. InfRefmsgid string `json:"inf_refmsgid"`
  22834. Infcode int64 `json:"infcode"`
  22835. Output struct {
  22836. Setlinfo struct {
  22837. SetlTime string `json:"setl_time"`
  22838. CvlservPay float64 `json:"cvlserv_pay"`
  22839. Year string `json:"year"`
  22840. MedType string `json:"med_type"`
  22841. PsnPay float64 `json:"psn_pay"`
  22842. OpterID string `json:"opter_id"`
  22843. Begndate string `json:"begndate"`
  22844. FlxempeFlag string `json:"flxempe_flag"`
  22845. HifmiPay float64 `json:"hifmi_pay"`
  22846. PsnNo string `json:"psn_no"`
  22847. ActPayDedc float64 `json:"act_pay_dedc"`
  22848. MedinsSetlID interface{} `json:"medins_setl_id"`
  22849. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22850. ClrWay string `json:"clr_way"`
  22851. OthPay float64 `json:"oth_pay"`
  22852. Gend string `json:"gend"`
  22853. MdtrtID string `json:"mdtrt_id"`
  22854. AcctPay float64 `json:"acct_pay"`
  22855. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22856. Insutype string `json:"insutype"`
  22857. Invono interface{} `json:"invono"`
  22858. Enddate string `json:"enddate"`
  22859. CashPayamt float64 `json:"cash_payamt"`
  22860. PsnType string `json:"psn_type"`
  22861. FixmedinsName string `json:"fixmedins_name"`
  22862. HifpPay float64 `json:"hifp_pay"`
  22863. NewFlag interface{} `json:"new_flag"`
  22864. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22865. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22866. PayLoc string `json:"pay_loc"`
  22867. ClrType string `json:"clr_type"`
  22868. RefdSetlFlag string `json:"refd_setl_flag"`
  22869. CvlservFlag string `json:"cvlserv_flag"`
  22870. EmpName string `json:"emp_name"`
  22871. Brdy string `json:"brdy"`
  22872. Naty string `json:"naty"`
  22873. Certno string `json:"certno"`
  22874. DiseCode string `json:"dise_code"`
  22875. FixmedinsCode string `json:"fixmedins_code"`
  22876. DedcHospLv string `json:"dedc_hosp_lv"`
  22877. OpterName string `json:"opter_name"`
  22878. Balc float64 `json:"balc"`
  22879. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22880. PsnCertType string `json:"psn_cert_type"`
  22881. HifobPay float64 `json:"hifob_pay"`
  22882. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22883. HifesPay float64 `json:"hifes_pay"`
  22884. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22885. OptTime string `json:"opt_time"`
  22886. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22887. SetlID string `json:"setl_id"`
  22888. MafPay float64 `json:"maf_pay"`
  22889. PsnName string `json:"psn_name"`
  22890. InsuOptins interface{} `json:"insu_optins"`
  22891. PrefFundPay interface{} `json:"pref_fund_pay"`
  22892. ClrOptins string `json:"clr_optins"`
  22893. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22894. DiseName string `json:"dise_name"`
  22895. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22896. Age float64 `json:"age"`
  22897. DtrtCertType string `json:"dtrt_cert_type"`
  22898. HospLv string `json:"hosp_lv"`
  22899. PsnCashPay float64 `json:"psn_cash_pay"`
  22900. } `json:"setlinfo"`
  22901. } `json:"output"`
  22902. RefmsgTime string `json:"refmsg_time"`
  22903. RespondTime string `json:"respond_time"`
  22904. Signtype interface{} `json:"signtype"`
  22905. WarnMsg interface{} `json:"warn_msg"`
  22906. }
  22907. type ResultElevenah struct {
  22908. Cainfo string `json:"cainfo"`
  22909. ErrMsg string `json:"err_msg"`
  22910. InfRefmsgid string `json:"inf_refmsgid"`
  22911. Infcode int64 `json:"infcode"`
  22912. Output struct {
  22913. Setlinfo struct {
  22914. SetlTime int64 `json:"setl_time"`
  22915. CvlservPay float64 `json:"cvlserv_pay"`
  22916. Year string `json:"year"`
  22917. MedType string `json:"med_type"`
  22918. PsnPay float64 `json:"psn_pay"`
  22919. OpterID string `json:"opter_id"`
  22920. Begndate int64 `json:"begndate"`
  22921. FlxempeFlag string `json:"flxempe_flag"`
  22922. HifmiPay float64 `json:"hifmi_pay"`
  22923. PsnNo string `json:"psn_no"`
  22924. ActPayDedc float64 `json:"act_pay_dedc"`
  22925. MedinsSetlID interface{} `json:"medins_setl_id"`
  22926. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22927. ClrWay string `json:"clr_way"`
  22928. OthPay float64 `json:"oth_pay"`
  22929. Gend string `json:"gend"`
  22930. MdtrtID string `json:"mdtrt_id"`
  22931. AcctPay float64 `json:"acct_pay"`
  22932. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22933. Insutype string `json:"insutype"`
  22934. Invono interface{} `json:"invono"`
  22935. Enddate int64 `json:"enddate"`
  22936. CashPayamt float64 `json:"cash_payamt"`
  22937. PsnType string `json:"psn_type"`
  22938. FixmedinsName string `json:"fixmedins_name"`
  22939. HifpPay float64 `json:"hifp_pay"`
  22940. NewFlag interface{} `json:"new_flag"`
  22941. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22942. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22943. PayLoc string `json:"pay_loc"`
  22944. ClrType string `json:"clr_type"`
  22945. RefdSetlFlag string `json:"refd_setl_flag"`
  22946. CvlservFlag string `json:"cvlserv_flag"`
  22947. EmpName string `json:"emp_name"`
  22948. Brdy int64 `json:"brdy"`
  22949. Naty string `json:"naty"`
  22950. Certno string `json:"certno"`
  22951. DiseCode string `json:"dise_code"`
  22952. FixmedinsCode string `json:"fixmedins_code"`
  22953. DedcHospLv string `json:"dedc_hosp_lv"`
  22954. OpterName string `json:"opter_name"`
  22955. Balc float64 `json:"balc"`
  22956. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22957. PsnCertType string `json:"psn_cert_type"`
  22958. HifobPay float64 `json:"hifob_pay"`
  22959. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22960. HifesPay float64 `json:"hifes_pay"`
  22961. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22962. OptTime int64 `json:"opt_time"`
  22963. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22964. SetlID string `json:"setl_id"`
  22965. MafPay float64 `json:"maf_pay"`
  22966. PsnName string `json:"psn_name"`
  22967. InsuOptins interface{} `json:"insu_optins"`
  22968. PrefFundPay interface{} `json:"pref_fund_pay"`
  22969. ClrOptins string `json:"clr_optins"`
  22970. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22971. DiseName string `json:"dise_name"`
  22972. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22973. Age float64 `json:"age"`
  22974. DtrtCertType string `json:"dtrt_cert_type"`
  22975. HospLv string `json:"hosp_lv"`
  22976. PsnCashPay float64 `json:"psn_cash_pay"`
  22977. } `json:"setlinfo"`
  22978. } `json:"output"`
  22979. RefmsgTime string `json:"refmsg_time"`
  22980. RespondTime string `json:"respond_time"`
  22981. Signtype interface{} `json:"signtype"`
  22982. WarnMsg interface{} `json:"warn_msg"`
  22983. }
  22984. type ResultEleven10265 struct {
  22985. Cainfo string `json:"cainfo"`
  22986. ErrMsg string `json:"err_msg"`
  22987. InfRefmsgid string `json:"inf_refmsgid"`
  22988. Infcode string `json:"infcode"`
  22989. Output struct {
  22990. Setlinfo struct {
  22991. SetlTime string `json:"setl_time"`
  22992. CvlservPay float64 `json:"cvlserv_pay"`
  22993. Year string `json:"year"`
  22994. MedType string `json:"med_type"`
  22995. PsnPay float64 `json:"psn_pay"`
  22996. OpterID string `json:"opter_id"`
  22997. Begndate string `json:"begndate"`
  22998. FlxempeFlag string `json:"flxempe_flag"`
  22999. HifmiPay float64 `json:"hifmi_pay"`
  23000. PsnNo string `json:"psn_no"`
  23001. ActPayDedc float64 `json:"act_pay_dedc"`
  23002. MedinsSetlID interface{} `json:"medins_setl_id"`
  23003. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23004. ClrWay string `json:"clr_way"`
  23005. OthPay float64 `json:"oth_pay"`
  23006. Gend string `json:"gend"`
  23007. MdtrtID string `json:"mdtrt_id"`
  23008. AcctPay float64 `json:"acct_pay"`
  23009. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23010. Insutype string `json:"insutype"`
  23011. Invono interface{} `json:"invono"`
  23012. Enddate string `json:"enddate"`
  23013. CashPayamt float64 `json:"cash_payamt"`
  23014. PsnType string `json:"psn_type"`
  23015. FixmedinsName string `json:"fixmedins_name"`
  23016. HifpPay float64 `json:"hifp_pay"`
  23017. NewFlag interface{} `json:"new_flag"`
  23018. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23019. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23020. PayLoc string `json:"pay_loc"`
  23021. ClrType string `json:"clr_type"`
  23022. RefdSetlFlag string `json:"refd_setl_flag"`
  23023. CvlservFlag string `json:"cvlserv_flag"`
  23024. EmpName string `json:"emp_name"`
  23025. Brdy string `json:"brdy"`
  23026. Naty string `json:"naty"`
  23027. Certno string `json:"certno"`
  23028. DiseCode string `json:"dise_code"`
  23029. FixmedinsCode string `json:"fixmedins_code"`
  23030. DedcHospLv string `json:"dedc_hosp_lv"`
  23031. OpterName string `json:"opter_name"`
  23032. Balc float64 `json:"balc"`
  23033. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23034. PsnCertType string `json:"psn_cert_type"`
  23035. HifobPay float64 `json:"hifob_pay"`
  23036. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23037. HifesPay float64 `json:"hifes_pay"`
  23038. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23039. OptTime string `json:"opt_time"`
  23040. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23041. SetlID string `json:"setl_id"`
  23042. MafPay float64 `json:"maf_pay"`
  23043. PsnName string `json:"psn_name"`
  23044. InsuOptins interface{} `json:"insu_optins"`
  23045. PrefFundPay interface{} `json:"pref_fund_pay"`
  23046. ClrOptins string `json:"clr_optins"`
  23047. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23048. DiseName string `json:"dise_name"`
  23049. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23050. Age float64 `json:"age"`
  23051. DtrtCertType string `json:"dtrt_cert_type"`
  23052. HospLv string `json:"hosp_lv"`
  23053. PsnCashPay float64 `json:"psn_cash_pay"`
  23054. } `json:"setlinfo"`
  23055. } `json:"output"`
  23056. RefmsgTime string `json:"refmsg_time"`
  23057. RespondTime string `json:"respond_time"`
  23058. Signtype interface{} `json:"signtype"`
  23059. WarnMsg interface{} `json:"warn_msg"`
  23060. }
  23061. type ResultTwelve struct {
  23062. Cainfo string `json:"cainfo"`
  23063. ErrMsg string `json:"err_msg"`
  23064. InfRefmsgid string `json:"inf_refmsgid"`
  23065. Infcode int64 `json:"infcode"`
  23066. Output struct {
  23067. MdtrtId string `json:"mdtrt_id"`
  23068. ChrgBchno string `json:"chrg_bchno"`
  23069. PsnNo string `json:"psn_no"`
  23070. } `json:"output"`
  23071. RefmsgTime string `json:"refmsg_time"`
  23072. RespondTime string `json:"respond_time"`
  23073. Signtype interface{} `json:"signtype"`
  23074. WarnMsg interface{} `json:"warn_msg"`
  23075. }
  23076. type ResultThirteen struct {
  23077. ErrMsg string `json:"err_msg"`
  23078. InfRefmsgid string `json:"inf_refmsgid"`
  23079. Infcode int64 `json:"infcode"`
  23080. Output struct {
  23081. Result struct {
  23082. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23083. } `json:"result"`
  23084. } `json:"output"`
  23085. RefmsgTime string `json:"refmsg_time"`
  23086. RespondTime string `json:"respond_time"`
  23087. Signtype interface{} `json:"signtype"`
  23088. WarnInfo interface{} `json:"warn_info"`
  23089. }
  23090. type ResultThirteen10265 struct {
  23091. ErrMsg string `json:"err_msg"`
  23092. InfRefmsgid string `json:"inf_refmsgid"`
  23093. Infcode string `json:"infcode"`
  23094. Output struct {
  23095. Result struct {
  23096. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23097. } `json:"result"`
  23098. } `json:"output"`
  23099. RefmsgTime string `json:"refmsg_time"`
  23100. RespondTime string `json:"respond_time"`
  23101. Signtype interface{} `json:"signtype"`
  23102. WarnInfo interface{} `json:"warn_info"`
  23103. }
  23104. type ResultFourteen struct {
  23105. ErrMsg string `json:"err_msg"`
  23106. InfRefmsgid string `json:"inf_refmsgid"`
  23107. Infcode int64 `json:"infcode"`
  23108. Output struct {
  23109. } `json:"output"`
  23110. RefmsgTime string `json:"refmsg_time"`
  23111. RespondTime string `json:"respond_time"`
  23112. Signtype interface{} `json:"signtype"`
  23113. WarnInfo interface{} `json:"warn_info"`
  23114. }
  23115. type ResultCFYLJG001 struct {
  23116. ErrMsg string `json:"err_msg"`
  23117. InfRefmsgid string `json:"inf_refmsgid"`
  23118. Infcode int64 `json:"infcode"`
  23119. Output struct {
  23120. RxTraceCode string `json:"rx_trace_code"`
  23121. HiRxno string `json:"hi_rxno"`
  23122. } `json:"output"`
  23123. RefmsgTime string `json:"refmsg_time"`
  23124. RespondTime string `json:"respond_time"`
  23125. Signtype interface{} `json:"signtype"`
  23126. WarnInfo interface{} `json:"warn_info"`
  23127. }
  23128. type ResultCFYLJG007 struct {
  23129. ErrMsg string `json:"err_msg"`
  23130. InfRefmsgid string `json:"inf_refmsgid"`
  23131. Infcode int64 `json:"infcode"`
  23132. Output struct {
  23133. HiRxno string `json:"hi_rxno"`
  23134. RxStasName string `json:"rx_stas_name"`
  23135. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  23136. Seltdelts []interface{} `json:"seltdelts"`
  23137. RxUsedStasName string `json:"rx_used_stas_name"`
  23138. RxStasCodg string `json:"rx_stas_codg"`
  23139. } `json:"output"`
  23140. RefmsgTime string `json:"refmsg_time"`
  23141. RespondTime string `json:"respond_time"`
  23142. Signtype interface{} `json:"signtype"`
  23143. WarnInfo interface{} `json:"warn_info"`
  23144. }
  23145. type ResultCFYLJG002 struct {
  23146. ErrMsg string `json:"err_msg"`
  23147. InfRefmsgid string `json:"inf_refmsgid"`
  23148. Infcode int64 `json:"infcode"`
  23149. Output struct {
  23150. RxFile string `json:"rx_file"`
  23151. SignDigest string `json:"sign_digest"`
  23152. SignCertSn string `json:"sign_cert_sn"`
  23153. SignCertDn string `json:"sign_cert_dn"`
  23154. } `json:"output"`
  23155. RefmsgTime string `json:"refmsg_time"`
  23156. RespondTime string `json:"respond_time"`
  23157. Signtype interface{} `json:"signtype"`
  23158. WarnInfo interface{} `json:"warn_info"`
  23159. }
  23160. type ResultCFYLJG003 struct {
  23161. ErrMsg string `json:"err_msg"`
  23162. InfRefmsgid string `json:"inf_refmsgid"`
  23163. Infcode int64 `json:"infcode"`
  23164. Output struct {
  23165. HiRxno string `json:"hi_rxno"`
  23166. RxStasCodg string `json:"rx_stas_codg"`
  23167. RxStasName string `json:"rx_stas_name"`
  23168. } `json:"output"`
  23169. RefmsgTime string `json:"refmsg_time"`
  23170. RespondTime string `json:"respond_time"`
  23171. Signtype interface{} `json:"signtype"`
  23172. WarnInfo interface{} `json:"warn_info"`
  23173. }
  23174. type ResultCFYLJG004 struct {
  23175. ErrMsg string `json:"err_msg"`
  23176. InfRefmsgid string `json:"inf_refmsgid"`
  23177. Infcode int64 `json:"infcode"`
  23178. Output struct {
  23179. HiRxno string `json:"hi_rxno"`
  23180. RxStasCodg string `json:"rx_stas_codg"`
  23181. RxStasName string `json:"rx_stas_name"`
  23182. } `json:"output"`
  23183. RefmsgTime string `json:"refmsg_time"`
  23184. RespondTime string `json:"respond_time"`
  23185. Signtype interface{} `json:"signtype"`
  23186. WarnInfo interface{} `json:"warn_info"`
  23187. }
  23188. type ResultCFYLJG008 struct {
  23189. ErrMsg string `json:"err_msg"`
  23190. InfRefmsgid string `json:"inf_refmsgid"`
  23191. Infcode int64 `json:"infcode"`
  23192. Output struct {
  23193. PoolareaNo string `json:"poolareaNo"`
  23194. AdmdvsName string `json:"admdvsName"`
  23195. Count string `json:"count"`
  23196. } `json:"output"`
  23197. RefmsgTime string `json:"refmsg_time"`
  23198. RespondTime string `json:"respond_time"`
  23199. Signtype interface{} `json:"signtype"`
  23200. WarnInfo interface{} `json:"warn_info"`
  23201. }
  23202. type ResultCFYLJG005 struct {
  23203. ErrMsg string `json:"err_msg"`
  23204. InfRefmsgid string `json:"inf_refmsgid"`
  23205. Infcode int64 `json:"infcode"`
  23206. Output struct {
  23207. HiRxNo string `json:"hi_rxno"`
  23208. FixMedinsCode string `json:"fixmedins_code"`
  23209. FixMedinsName string `json:"fixmedins_name"`
  23210. RxStasCodg string `json:"rx_stas_codg"`
  23211. RxStasName string `json:"rx_stas_name"`
  23212. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  23213. RxUserdStasName string `json:"rx_userd_stas_name"`
  23214. PrscTime string `json:"prsc_time"`
  23215. RxDrugCnt float64 `json:"rx_drug_cnt"`
  23216. RxUsedWayCodg string `json:"rx_used_way_codg"`
  23217. RxUsedWayName string `json:"rx_used_way_name"`
  23218. RxFrquCodg string `json:"rx_frqu_codg"`
  23219. RxFrquName string `json:"rx_frqu_name"`
  23220. RxDosunt string `json:"rx_dosunt"`
  23221. RxDoscnt float64 `json:"rx_doscnt"`
  23222. RxDrordDscr string `json:"rx_drord_dscr"`
  23223. ValiDays int64 `json:"vali_days"`
  23224. ValiEndTime string `json:"vali_end_time"`
  23225. ReptFlag string `json:"rept_flag"`
  23226. MaxReptCnt int64 `json:"max_rept_cnt"`
  23227. ReptdCnt int64 `json:"reptd_cnt"`
  23228. MinInrvDays int64 `json:"min_inrv_days"`
  23229. RxTypeCode string `json:"rx_type_code"`
  23230. RxTypeName string `json:"rx_type_name"`
  23231. LongRxFlag string `json:"long_rx_flag"`
  23232. RxDetlList []struct {
  23233. MedListCodg string `json:"med_list_codg"`
  23234. MedinsListCodg string `json:"medins_list_codg"`
  23235. HospPrepFlag string `json:"hosp_prep_flag"`
  23236. RxItemTypeCode string `json:"rx_item_type_code"`
  23237. RxItemTypeName string `json:"rx_item_type_name"`
  23238. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  23239. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  23240. TcmHerbFoote string `json:"tcmherb_foote"`
  23241. MednTypeCode string `json:"medn_type_code"`
  23242. MednTypeName string `json:"medn_type_name"`
  23243. MainMedcFlag string `json:"main_medc_flag"`
  23244. UrgtFlag string `json:"urgt_flag"`
  23245. BasMednFlag string `json:"bas_medn_flag"`
  23246. ImpDrugFlag string `json:"imp_drug_flag"`
  23247. ProdBarc string `json:"prod_barc"`
  23248. DrugProdname string `json:"drug_prodname"`
  23249. GennameCodg string `json:"genname_codg"`
  23250. DrugGenname string `json:"drug_genname"`
  23251. DrugDosform string `json:"drug_dosform"`
  23252. DrugSpec string `json:"drug_spec"`
  23253. PrdrName string `json:"prdr_name"`
  23254. MedcWayCodg string `json:"medc_way_codg"`
  23255. MedcWayDscr string `json:"medc_way_dscr"`
  23256. MedcBegntime string `json:"medc_begntime"`
  23257. MedcEndtime string `json:"medc_endtime"`
  23258. MedcDays float64 `json:"medc_days"`
  23259. DrugPric float64 `json:"drug_pric"`
  23260. DrugSumamt float64 `json:"drug_sumamt"`
  23261. DrugCnt float64 `json:"drug_cnt"`
  23262. DrugDosunt string `json:"drug_dosunt"`
  23263. SinDoscnt float64 `json:"sin_doscnt"`
  23264. SinDosunt string `json:"sin_dosunt"`
  23265. UsedFrquCodg string `json:"used_frqu_codg"`
  23266. UsedFrquName string `json:"used_frqu_name"`
  23267. DrugTotlcnt string `json:"drug_totlcnt"`
  23268. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  23269. DiseCodg string `json:"dise_codg"`
  23270. HospApprFlag string `json:"hosp_appr_flag"`
  23271. } `json:"rx_detl_list"`
  23272. RxOtpinfo struct {
  23273. MedType string `json:"med_type"`
  23274. IptOtpNo string `json:"ipt_otp_no"`
  23275. OtpIptFlag string `json:"otp_ipt_flag"`
  23276. PatnName string `json:"patn_name"`
  23277. PatnAge float64 `json:"patn_age"`
  23278. PatnHgt float64 `json:"patn_hgt"`
  23279. PatnWt float64 `json:"patn_wt"`
  23280. Gend string `json:"gend"`
  23281. GesoVal float64 `json:"geso_val"`
  23282. NwbFlag string `json:"nwb_flag"`
  23283. NwbAge string `json:"nwb_age"`
  23284. SuckPrdFlag string `json:"suck_prd_flag"`
  23285. AlgsHis string `json:"algs_his"`
  23286. Insutype string `json:"insutype"`
  23287. PrscDeptName string `json:"prsc_dept_name"`
  23288. PrscDrName string `json:"prsc_dr_name"`
  23289. PharName string `json:"phar_name"`
  23290. PharChkTime string `json:"phar_chk_time"`
  23291. MdtrtTime string `json:"mdtrt_time"`
  23292. DiseCodg string `json:"dise_codg"`
  23293. DiseName string `json:"dise_name"`
  23294. SpDiseFlag string `json:"sp_dise_flag"`
  23295. MaindiagCode string `json:"maindiag_code"`
  23296. MaindiagName string `json:"maindiag_name"`
  23297. DiseCondDscr string `json:"dise_cond_dscr"`
  23298. FstdiagFlag string `json:"fstdiag_flag"`
  23299. } `json:"rx_otpinfo"`
  23300. RxDiseList []struct {
  23301. DiagType string `json:"diag_type"`
  23302. MaindiagFlag string `json:"maindiag_flag"`
  23303. DiagSrtNo string `json:"diag_srt_no"`
  23304. DiagCode string `json:"diag_code"`
  23305. DiagName string `json:"diag_name"`
  23306. DiagDept string `json:"diag_dept"`
  23307. DiagDrNo string `json:"diag_dr_no"`
  23308. DiagDrName string `json:"diag_dr_name"`
  23309. DiagTime string `json:"diag_time"`
  23310. TcmDiseCode string `json:"tcm_dise_code"`
  23311. TcmDiseName string `json:"tcm_dise_name"`
  23312. TcmSympCode string `json:"tcmsymp_code"`
  23313. TcmSymp string `json:"tcmsymp"`
  23314. } `json:"rx_dise_list"`
  23315. } `json:"output"`
  23316. RefmsgTime string `json:"refmsg_time"`
  23317. RespondTime string `json:"respond_time"`
  23318. Signtype interface{} `json:"signtype"`
  23319. WarnInfo interface{} `json:"warn_info"`
  23320. }
  23321. type ResultCFYLJG006 struct {
  23322. ErrMsg string `json:"err_msg"`
  23323. InfRefmsgid string `json:"inf_refmsgid"`
  23324. Infcode int64 `json:"infcode"`
  23325. Output struct {
  23326. HiRxNo string `json:"hi_rxno"`
  23327. PharCode string `json:"phar_code"`
  23328. PharName string `json:"phar_name"`
  23329. RxChkOpnn string `json:"rx_chk_opnn"`
  23330. RxChkTime string `json:"rx_chk_time"`
  23331. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  23332. RxChkStasName string `json:"rx_chk_stas_name"`
  23333. RxStasCodg string `json:"rx_stas_codg"`
  23334. RxStasName string `json:"rx_stas_name"`
  23335. } `json:"output"`
  23336. RefmsgTime string `json:"refmsg_time"`
  23337. RespondTime string `json:"respond_time"`
  23338. Signtype interface{} `json:"signtype"`
  23339. WarnInfo interface{} `json:"warn_info"`
  23340. }
  23341. type ResultFourteen10265 struct {
  23342. ErrMsg string `json:"err_msg"`
  23343. InfRefmsgid string `json:"inf_refmsgid"`
  23344. Infcode string `json:"infcode"`
  23345. Output struct {
  23346. } `json:"output"`
  23347. RefmsgTime string `json:"refmsg_time"`
  23348. RespondTime string `json:"respond_time"`
  23349. Signtype interface{} `json:"signtype"`
  23350. WarnInfo interface{} `json:"warn_info"`
  23351. }
  23352. type ResultSixteen struct {
  23353. Cainfo string `json:"cainfo"`
  23354. ErrMsg string `json:"err_msg"`
  23355. InfRefmsgid string `json:"inf_refmsgid"`
  23356. Infcode int64 `json:"infcode"`
  23357. Output struct {
  23358. Setlinfo struct {
  23359. MdtrtID string `json:"mdtrt_id"`
  23360. SetlID string `json:"setl_id"`
  23361. ClrOptins string `json:"clr_optins"`
  23362. SetlTime string `json:"setl_time"`
  23363. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23364. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23365. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23366. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23367. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23368. ActPayDedc float64 `json:"act_pay_dedc"`
  23369. HifpPay float64 `json:"hifp_pay"`
  23370. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23371. Lfpay float64 `json:"selfpay"`
  23372. CvlservPay float64 `json:"cvlserv_pay"`
  23373. HifesPay float64 `json:"hifes_pay"`
  23374. HifmiPay float64 `json:"hifmi_pay"`
  23375. HifobPay float64 `json:"hifob_pay"`
  23376. MafPay float64 `json:"maf_pay"`
  23377. OthPay float64 `json:"oth_pay"`
  23378. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23379. PsnPartAmt float64 `json:"psn_part_amt"`
  23380. AcctPay float64 `json:"acct_pay"`
  23381. Balc float64 `json:"balc"`
  23382. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23383. HospPartAmt float64 `json:"hosp_part_amt"`
  23384. MedinsSetlID string `json:"medins_setl_id"`
  23385. PdnCashPay string `json:"pdn_cash_pay"`
  23386. } `json:"setlinfo"`
  23387. } `json:"output"`
  23388. RefmsgTime string `json:"refmsg_time"`
  23389. RespondTime string `json:"respond_time"`
  23390. Signtype interface{} `json:"signtype"`
  23391. WarnMsg interface{} `json:"warn_msg"`
  23392. }
  23393. type ResultSixteen10265 struct {
  23394. Cainfo string `json:"cainfo"`
  23395. ErrMsg string `json:"err_msg"`
  23396. InfRefmsgid string `json:"inf_refmsgid"`
  23397. Infcode string `json:"infcode"`
  23398. Output struct {
  23399. Setlinfo struct {
  23400. MdtrtID string `json:"mdtrt_id"`
  23401. SetlID string `json:"setl_id"`
  23402. ClrOptins string `json:"clr_optins"`
  23403. SetlTime string `json:"setl_time"`
  23404. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23405. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23406. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23407. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23408. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23409. ActPayDedc float64 `json:"act_pay_dedc"`
  23410. HifpPay float64 `json:"hifp_pay"`
  23411. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23412. Lfpay float64 `json:"selfpay"`
  23413. CvlservPay float64 `json:"cvlserv_pay"`
  23414. HifesPay float64 `json:"hifes_pay"`
  23415. HifmiPay float64 `json:"hifmi_pay"`
  23416. HifobPay float64 `json:"hifob_pay"`
  23417. MafPay float64 `json:"maf_pay"`
  23418. OthPay float64 `json:"oth_pay"`
  23419. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23420. PsnPartAmt float64 `json:"psn_part_amt"`
  23421. AcctPay float64 `json:"acct_pay"`
  23422. Balc float64 `json:"balc"`
  23423. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23424. HospPartAmt float64 `json:"hosp_part_amt"`
  23425. MedinsSetlID string `json:"medins_setl_id"`
  23426. PdnCashPay string `json:"pdn_cash_pay"`
  23427. } `json:"setlinfo"`
  23428. } `json:"output"`
  23429. RefmsgTime string `json:"refmsg_time"`
  23430. RespondTime string `json:"respond_time"`
  23431. Signtype interface{} `json:"signtype"`
  23432. WarnMsg interface{} `json:"warn_msg"`
  23433. }
  23434. type ResultSixteen10265Two struct {
  23435. Cainfo string `json:"cainfo"`
  23436. ErrMsg string `json:"err_msg"`
  23437. InfRefmsgid string `json:"inf_refmsgid"`
  23438. Infcode string `json:"infcode"`
  23439. Output struct {
  23440. Setlinfo interface{} `json:"setlinfo"`
  23441. } `json:"output"`
  23442. RefmsgTime string `json:"refmsg_time"`
  23443. RespondTime string `json:"respond_time"`
  23444. Signtype interface{} `json:"signtype"`
  23445. WarnMsg interface{} `json:"warn_msg"`
  23446. }
  23447. type ResultgzSixteen10265Two struct {
  23448. Cainfo string `json:"cainfo"`
  23449. ErrMsg string `json:"err_msg"`
  23450. InfRefmsgid string `json:"inf_refmsgid"`
  23451. Infcode int64 `json:"infcode"`
  23452. Output struct {
  23453. Setlinfo interface{} `json:"setlinfo"`
  23454. } `json:"output"`
  23455. RefmsgTime string `json:"refmsg_time"`
  23456. RespondTime string `json:"respond_time"`
  23457. Signtype interface{} `json:"signtype"`
  23458. WarnMsg interface{} `json:"warn_msg"`
  23459. }
  23460. type ResultSeventeen struct {
  23461. ErrMsg string `json:"err_msg"`
  23462. InfRefmsgid string `json:"inf_refmsgid"`
  23463. Infcode int64 `json:"infcode"`
  23464. Output struct {
  23465. SetlListId string `json:"setl_list_id"`
  23466. } `json:"output"`
  23467. RefmsgTime string `json:"refmsg_time"`
  23468. RespondTime string `json:"respond_time"`
  23469. Signtype string `json:"signtype"`
  23470. WarnInfo string `json:"warn_info"`
  23471. }
  23472. type ResultSeventeenOther struct {
  23473. ErrMsg string `json:"err_msg"`
  23474. InfRefmsgid string `json:"inf_refmsgid"`
  23475. Infcode string `json:"infcode"`
  23476. Output struct {
  23477. SetlListId string `json:"setl_list_id"`
  23478. } `json:"output"`
  23479. RefmsgTime string `json:"refmsg_time"`
  23480. RespondTime string `json:"respond_time"`
  23481. Signtype string `json:"signtype"`
  23482. WarnInfo string `json:"warn_info"`
  23483. }
  23484. type Result90991 struct {
  23485. ErrMsg string `json:"err_msg"`
  23486. InfRefmsgid string `json:"inf_refmsgid"`
  23487. Infcode int64 `json:"infcode"`
  23488. Output struct {
  23489. Result struct {
  23490. PsnNo string `json:"psn_no"`
  23491. CardStat string `json:"card_stat"`
  23492. Certno string `json:"certno"`
  23493. PsnName string `json:"psn_name"`
  23494. CheckStat string `json:"check_stat"`
  23495. SscnoCheckStat string `json:"sscno_check_stat"`
  23496. } `json:"result"`
  23497. } `json:"output"`
  23498. RefmsgTime string `json:"refmsg_time"`
  23499. RespondTime string `json:"respond_time"`
  23500. Signtype interface{} `json:"signtype"`
  23501. WarnInfo interface{} `json:"warn_info"`
  23502. }
  23503. type Result90100 struct {
  23504. ErrMsg string `json:"err_msg"`
  23505. InfRefmsgid string `json:"inf_refmsgid"`
  23506. Infcode int64 `json:"infcode"`
  23507. Output struct {
  23508. PoolareaNo string `json:"poolarea_no"`
  23509. PoolareaNoName string `json:"poolarea_no_name"`
  23510. Insutype string `json:"insutype"`
  23511. InsutypeName string `json:"insutype_name"`
  23512. ClctType string `json:"clct_type"`
  23513. ClctTypeName string `json:"clct_type_name"`
  23514. ClctFlag string `json:"clct_flag"`
  23515. ClctFlagName string `json:"clct_flag_name"`
  23516. AccrymBegn string `json:"accrym_begn"`
  23517. AccrymEnd string `json:"accrym_end"`
  23518. ClctTime string `json:"clct_time"`
  23519. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23520. } `json:"output"`
  23521. RefmsgTime string `json:"refmsg_time"`
  23522. RespondTime string `json:"respond_time"`
  23523. Signtype interface{} `json:"signtype"`
  23524. WarnInfo interface{} `json:"warn_info"`
  23525. }
  23526. type Custom struct {
  23527. DetItemFeeSumamt string
  23528. Cut string
  23529. FeedetlSn string
  23530. Price string
  23531. MedListCodg string
  23532. Type int64
  23533. AdviceId int64
  23534. ProjectId int64
  23535. ItemId int64
  23536. }
  23537. type Result5301 struct {
  23538. ErrMsg string `json:"err_msg"`
  23539. InfRefmsgid string `json:"inf_refmsgid"`
  23540. Infcode int64 `json:"infcode"`
  23541. Output struct {
  23542. Result []struct {
  23543. OpspDiseCode string `json:"opsp_dise_code"`
  23544. OpspDiseName string `json:"opsp_dise_name"`
  23545. Begndate string `json:"begndate"`
  23546. Enddate string `json:"enddate"`
  23547. } `json:"feedetail"`
  23548. } `json:"output"`
  23549. RefmsgTime string `json:"refmsg_time"`
  23550. RespondTime string `json:"respond_time"`
  23551. Signtype interface{} `json:"signtype"`
  23552. WarnInfo interface{} `json:"warn_info"`
  23553. }
  23554. type Result5301For10265 struct {
  23555. ErrMsg string `json:"err_msg"`
  23556. InfRefmsgid string `json:"inf_refmsgid"`
  23557. Infcode string `json:"infcode"`
  23558. Output struct {
  23559. Result []struct {
  23560. OpspDiseCode string `json:"opsp_dise_code"`
  23561. OpspDiseName string `json:"opsp_dise_name"`
  23562. Begndate string `json:"begndate"`
  23563. Enddate string `json:"enddate"`
  23564. } `json:"feedetail"`
  23565. } `json:"output"`
  23566. RefmsgTime string `json:"refmsg_time"`
  23567. RespondTime string `json:"respond_time"`
  23568. Signtype interface{} `json:"signtype"`
  23569. WarnInfo interface{} `json:"warn_info"`
  23570. }
  23571. //获取个人信息----挂号-----上传就诊信息
  23572. func (c *HisApiController) GetRegisterInfo() {
  23573. id, _ := c.GetInt64("id")
  23574. record_time := c.GetString("record_time")
  23575. settlementValue, _ := c.GetInt64("settlement_value")
  23576. medical_insurance_card := c.GetString("medical_insurance_card")
  23577. name := c.GetString("name")
  23578. id_card_type, _ := c.GetInt64("id_card_type")
  23579. certificates, _ := c.GetInt64("certificates")
  23580. medical_care, _ := c.GetInt64("medical_care")
  23581. birthday := c.GetString("birthday")
  23582. id_card := c.GetString("id_card")
  23583. register_type, _ := c.GetInt64("register")
  23584. doctor, _ := c.GetInt64("doctor")
  23585. department, _ := c.GetInt64("department")
  23586. gender, _ := c.GetInt64("sex")
  23587. registration_fee, _ := c.GetFloat("registration_fee")
  23588. medical_expenses, _ := c.GetFloat("medical_expenses")
  23589. social_type, _ := c.GetInt64("social_type")
  23590. admin_user_id, _ := c.GetInt64("admin_user_id")
  23591. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23592. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  23593. mdtrt_type := c.GetString("mdtrt_type")
  23594. if id_card_type == 5 {
  23595. id_card_type = 4
  23596. }
  23597. timeLayout := "2006-01-02"
  23598. loc, _ := time.LoadLocation("Local")
  23599. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23600. birthUnix := birthdays.Unix()
  23601. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23602. if err != nil {
  23603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23604. return
  23605. }
  23606. recordDateTime := theTime.Unix()
  23607. adminInfo := c.GetAdminUserInfo()
  23608. var patient service.Patients
  23609. if id == 0 {
  23610. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23611. } else {
  23612. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23613. }
  23614. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23615. if patientPrescription.ID == 0 {
  23616. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23617. }
  23618. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23619. if patient.ID == 0 {
  23620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23621. return
  23622. }
  23623. if len(patient.IdCardNo) == 0 {
  23624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23625. return
  23626. }
  23627. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23628. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23629. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23630. //就诊结算未完成,不能进行二次挂号
  23631. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23632. if len(his) >= 1 {
  23633. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23634. if len(his) >= 1 && order.ID == 0 {
  23635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23636. return
  23637. }
  23638. }
  23639. //var register_log string
  23640. if config.IsOpen == 1 {
  23641. var res ResultTwo
  23642. var res10265 ResultTwo10265
  23643. var PsnNo string
  23644. var PsnCertType string
  23645. var Certno string
  23646. var PsnName string
  23647. var Gend string
  23648. var Naty string
  23649. var Brdy string
  23650. var Age float64
  23651. var infoStr string
  23652. var idetinfoStr string
  23653. var infocode int64
  23654. var verify_number string
  23655. fmt.Println(verify_number)
  23656. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23657. psn_info, _ := service.GetPsnByPatientId(id)
  23658. PsnNo = psn_info.PsnNo
  23659. PsnCertType = psn_info.PsnCertType
  23660. Certno = psn_info.Certno
  23661. PsnName = psn_info.PsnName
  23662. Gend = psn_info.Gend
  23663. Naty = psn_info.Naty
  23664. Brdy = psn_info.Brdy
  23665. Age = psn_info.Age
  23666. infoStr = psn_info.Insuinfo
  23667. idetinfoStr = psn_info.Idetinfo
  23668. infocode = 0
  23669. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23670. psn_info, _ := service.GetPsnByPatientId(id)
  23671. PsnNo = psn_info.PsnNo
  23672. PsnCertType = psn_info.PsnCertType
  23673. Certno = psn_info.Certno
  23674. PsnName = psn_info.PsnName
  23675. Gend = psn_info.Gend
  23676. Naty = psn_info.Naty
  23677. Brdy = psn_info.Brdy
  23678. Age = psn_info.Age
  23679. infoStr = psn_info.Insuinfo
  23680. idetinfoStr = psn_info.Idetinfo
  23681. infocode = 0
  23682. verify_number = psn_info.VerifyNumber
  23683. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23684. if id_card_type == 2 {
  23685. //请求内网数据
  23686. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23687. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23688. "&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
  23689. resp, requestErr := http.Get(api)
  23690. if requestErr != nil {
  23691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23692. return
  23693. }
  23694. body, ioErr := ioutil.ReadAll(resp.Body)
  23695. if ioErr != nil {
  23696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23698. return
  23699. }
  23700. var respJSON map[string]interface{}
  23701. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23704. return
  23705. }
  23706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23707. result_byte, _ := json.Marshal(respJSON)
  23708. result := string(result_byte)
  23709. var dat map[string]interface{}
  23710. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23711. fmt.Println(dat)
  23712. } else {
  23713. fmt.Println(err)
  23714. }
  23715. userJSONBytes, _ := json.Marshal(dat)
  23716. var res ResultTwo
  23717. var resTwo10265 ResultTwo10265
  23718. if miConfig.Code == "H15049901371" {
  23719. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23720. utils.ErrorLog("解析失败:%v", err)
  23721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23722. return
  23723. }
  23724. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23725. res.Infcode = Infcode
  23726. res.ErrMsg = resTwo10265.ErrMsg
  23727. res.Output = resTwo10265.Output
  23728. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23729. res.RespondTime = resTwo10265.RespondTime
  23730. res.WarnInfo = resTwo10265.WarnInfo
  23731. } else {
  23732. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23733. utils.ErrorLog("解析失败:%v", err)
  23734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23735. return
  23736. }
  23737. }
  23738. //var insutypes []string
  23739. //var insutype string
  23740. //var is390 int = 0
  23741. //var is310 int = 0
  23742. //for _, item := range res.Output.Iinfo {
  23743. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23744. // insutypes = append(insutypes, item.Insutype)
  23745. // }
  23746. //}
  23747. //if len(insutypes) == 1 {
  23748. // insutype = insutypes[0]
  23749. //} else {
  23750. // for _, i := range insutypes {
  23751. // if i == "390" {
  23752. // is390 = 1
  23753. // }
  23754. //
  23755. // if i == "310" {
  23756. // is310 = 1
  23757. // }
  23758. // }
  23759. //}
  23760. //if is390 == 1 {
  23761. // insutype = "390"
  23762. //}
  23763. //if is310 == 1 {
  23764. // insutype = "310"
  23765. //}
  23766. //if len(insutypes) == 0 {
  23767. // insutype = "310"
  23768. //}
  23769. PsnNo = res.Output.Baseinfo.PsnNo
  23770. PsnCertType = res.Output.Baseinfo.PsnCertType
  23771. Certno = res.Output.Baseinfo.Certno
  23772. PsnName = res.Output.Baseinfo.PsnName
  23773. Gend = res.Output.Baseinfo.Gend
  23774. Naty = res.Output.Baseinfo.Naty
  23775. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23776. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23777. infoStr = string(Iinfos)
  23778. idetinfoStr = string(Idetinfos)
  23779. infocode = res.Infcode
  23780. //infocode = 0
  23781. //verify_number = psn_info.VerifyNumber
  23782. } else {
  23783. psn_info, _ := service.GetPsnByPatientId(id)
  23784. PsnNo = psn_info.PsnNo
  23785. PsnCertType = psn_info.PsnCertType
  23786. Certno = psn_info.Certno
  23787. PsnName = psn_info.PsnName
  23788. Gend = psn_info.Gend
  23789. Naty = psn_info.Naty
  23790. Brdy = psn_info.Brdy
  23791. Age = psn_info.Age
  23792. infoStr = psn_info.Insuinfo
  23793. idetinfoStr = psn_info.Idetinfo
  23794. infocode = 0
  23795. verify_number = psn_info.VerifyNumber
  23796. }
  23797. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23798. if id_card_type == 1 {
  23799. psn_info, _ := service.GetPsnByPatientId(id)
  23800. PsnNo = psn_info.PsnNo
  23801. PsnCertType = psn_info.PsnCertType
  23802. Certno = psn_info.Certno
  23803. PsnName = psn_info.PsnName
  23804. Gend = psn_info.Gend
  23805. Naty = psn_info.Naty
  23806. Brdy = psn_info.Brdy
  23807. Age = psn_info.Age
  23808. infoStr = psn_info.Insuinfo
  23809. idetinfoStr = psn_info.Idetinfo
  23810. infocode = 0
  23811. verify_number = psn_info.VerifyNumber
  23812. } else if id_card_type == 2 {
  23813. 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)
  23814. fmt.Println(errMsgLog)
  23815. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23816. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23817. utils.ErrorLog("解析失败:%v", err)
  23818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23819. return
  23820. }
  23821. PsnNo = res.Output.Baseinfo.PsnNo
  23822. PsnCertType = res.Output.Baseinfo.PsnCertType
  23823. Certno = res.Output.Baseinfo.Certno
  23824. PsnName = res.Output.Baseinfo.PsnName
  23825. Gend = res.Output.Baseinfo.Gend
  23826. Naty = res.Output.Baseinfo.Naty
  23827. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23828. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23829. infoStr = string(Iinfos)
  23830. idetinfoStr = string(Idetinfos)
  23831. infocode = res.Infcode
  23832. }
  23833. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23834. if id_card_type == 1 {
  23835. psn_info, _ := service.GetPsnByPatientId(id)
  23836. PsnNo = psn_info.PsnNo
  23837. PsnCertType = psn_info.PsnCertType
  23838. Certno = psn_info.Certno
  23839. PsnName = psn_info.PsnName
  23840. Gend = psn_info.Gend
  23841. Naty = psn_info.Naty
  23842. Brdy = psn_info.Brdy
  23843. Age = psn_info.Age
  23844. infoStr = psn_info.Insuinfo
  23845. idetinfoStr = psn_info.Idetinfo
  23846. infocode = 0
  23847. verify_number = psn_info.VerifyNumber
  23848. } else if id_card_type == 2 {
  23849. 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, "")
  23850. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23851. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23852. utils.ErrorLog("解析失败:%v", err)
  23853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23854. return
  23855. }
  23856. PsnNo = res.Output.Baseinfo.PsnNo
  23857. PsnCertType = res.Output.Baseinfo.PsnCertType
  23858. Certno = res.Output.Baseinfo.Certno
  23859. PsnName = res.Output.Baseinfo.PsnName
  23860. Gend = res.Output.Baseinfo.Gend
  23861. Naty = res.Output.Baseinfo.Naty
  23862. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23863. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23864. infoStr = string(Iinfos)
  23865. idetinfoStr = string(Idetinfos)
  23866. infocode = res.Infcode
  23867. } else {
  23868. psn_info, _ := service.GetPsnByPatientId(id)
  23869. PsnNo = psn_info.PsnNo
  23870. PsnCertType = psn_info.PsnCertType
  23871. Certno = psn_info.Certno
  23872. PsnName = psn_info.PsnName
  23873. Gend = psn_info.Gend
  23874. Naty = psn_info.Naty
  23875. Brdy = psn_info.Brdy
  23876. Age = psn_info.Age
  23877. infoStr = psn_info.Insuinfo
  23878. idetinfoStr = psn_info.Idetinfo
  23879. infocode = 0
  23880. verify_number = psn_info.VerifyNumber
  23881. }
  23882. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23883. if id_card_type == 1 {
  23884. psn_info, _ := service.GetPsnByPatientId(id)
  23885. PsnNo = psn_info.PsnNo
  23886. PsnCertType = psn_info.PsnCertType
  23887. Certno = psn_info.Certno
  23888. PsnName = psn_info.PsnName
  23889. Gend = psn_info.Gend
  23890. Naty = psn_info.Naty
  23891. Brdy = psn_info.Brdy
  23892. Age = psn_info.Age
  23893. infoStr = psn_info.Insuinfo
  23894. idetinfoStr = psn_info.Idetinfo
  23895. infocode = 0
  23896. verify_number = psn_info.VerifyNumber
  23897. } else if id_card_type == 2 {
  23898. psn_info, _ := service.GetPsnByPatientId(id)
  23899. PsnNo = psn_info.PsnNo
  23900. PsnCertType = psn_info.PsnCertType
  23901. Certno = psn_info.Certno
  23902. PsnName = psn_info.PsnName
  23903. Gend = psn_info.Gend
  23904. Naty = psn_info.Naty
  23905. Brdy = psn_info.Brdy
  23906. Age = psn_info.Age
  23907. infoStr = psn_info.Insuinfo
  23908. idetinfoStr = psn_info.Idetinfo
  23909. infocode = 0
  23910. verify_number = psn_info.VerifyNumber
  23911. } else {
  23912. psn_info, _ := service.GetPsnByPatientId(id)
  23913. PsnNo = psn_info.PsnNo
  23914. PsnCertType = psn_info.PsnCertType
  23915. Certno = psn_info.Certno
  23916. PsnName = psn_info.PsnName
  23917. Gend = psn_info.Gend
  23918. Naty = psn_info.Naty
  23919. Brdy = psn_info.Brdy
  23920. Age = psn_info.Age
  23921. infoStr = psn_info.Insuinfo
  23922. idetinfoStr = psn_info.Idetinfo
  23923. infocode = 0
  23924. verify_number = psn_info.VerifyNumber
  23925. }
  23926. } else if miConfig.MdtrtareaAdmvs == "360100" {
  23927. if id_card_type == 1 {
  23928. psn_info, _ := service.GetPsnByPatientId(id)
  23929. PsnNo = psn_info.PsnNo
  23930. PsnCertType = psn_info.PsnCertType
  23931. Certno = psn_info.Certno
  23932. PsnName = psn_info.PsnName
  23933. Gend = psn_info.Gend
  23934. Naty = psn_info.Naty
  23935. Brdy = psn_info.Brdy
  23936. Age = psn_info.Age
  23937. infoStr = psn_info.Insuinfo
  23938. idetinfoStr = psn_info.Idetinfo
  23939. infocode = 0
  23940. verify_number = psn_info.VerifyNumber
  23941. } else if id_card_type == 2 {
  23942. psn_info, _ := service.GetPsnByPatientId(id)
  23943. PsnNo = psn_info.PsnNo
  23944. PsnCertType = psn_info.PsnCertType
  23945. Certno = psn_info.Certno
  23946. PsnName = psn_info.PsnName
  23947. Gend = psn_info.Gend
  23948. Naty = psn_info.Naty
  23949. Brdy = psn_info.Brdy
  23950. Age = psn_info.Age
  23951. infoStr = psn_info.Insuinfo
  23952. idetinfoStr = psn_info.Idetinfo
  23953. infocode = 0
  23954. verify_number = psn_info.VerifyNumber
  23955. } else {
  23956. psn_info, _ := service.GetPsnByPatientId(id)
  23957. PsnNo = psn_info.PsnNo
  23958. PsnCertType = psn_info.PsnCertType
  23959. Certno = psn_info.Certno
  23960. PsnName = psn_info.PsnName
  23961. Gend = psn_info.Gend
  23962. Naty = psn_info.Naty
  23963. Brdy = psn_info.Brdy
  23964. Age = psn_info.Age
  23965. infoStr = psn_info.Insuinfo
  23966. idetinfoStr = psn_info.Idetinfo
  23967. infocode = 0
  23968. verify_number = psn_info.VerifyNumber
  23969. }
  23970. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23971. psn_info, _ := service.GetPsnByPatientId(id)
  23972. PsnNo = psn_info.PsnNo
  23973. PsnCertType = psn_info.PsnCertType
  23974. Certno = psn_info.Certno
  23975. PsnName = psn_info.PsnName
  23976. Gend = psn_info.Gend
  23977. Naty = psn_info.Naty
  23978. Brdy = psn_info.Brdy
  23979. Age = psn_info.Age
  23980. infoStr = psn_info.Insuinfo
  23981. idetinfoStr = psn_info.Idetinfo
  23982. infocode = 0
  23983. verify_number = psn_info.VerifyNumber
  23984. idetinfoStr = psn_info.Idetinfo
  23985. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23986. if id_card_type == 1 {
  23987. psn_info, _ := service.GetPsnByPatientId(id)
  23988. PsnNo = psn_info.PsnNo
  23989. PsnCertType = psn_info.PsnCertType
  23990. Certno = psn_info.Certno
  23991. PsnName = psn_info.PsnName
  23992. Gend = psn_info.Gend
  23993. Naty = psn_info.Naty
  23994. Brdy = psn_info.Brdy
  23995. Age = psn_info.Age
  23996. infoStr = psn_info.Insuinfo
  23997. idetinfoStr = psn_info.Idetinfo
  23998. infocode = 0
  23999. verify_number = psn_info.VerifyNumber
  24000. } else if id_card_type == 2 {
  24001. 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)
  24002. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24003. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24004. utils.ErrorLog("解析失败:%v", err)
  24005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24006. return
  24007. }
  24008. PsnNo = res.Output.Baseinfo.PsnNo
  24009. PsnCertType = res.Output.Baseinfo.PsnCertType
  24010. Certno = res.Output.Baseinfo.Certno
  24011. PsnName = res.Output.Baseinfo.PsnName
  24012. Gend = res.Output.Baseinfo.Gend
  24013. Naty = res.Output.Baseinfo.Naty
  24014. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24015. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24016. infoStr = string(Iinfos)
  24017. idetinfoStr = string(Idetinfos)
  24018. infocode = res.Infcode
  24019. } else if id_card_type == 4 {
  24020. psn_info, _ := service.GetPsnByPatientId(id)
  24021. PsnNo = psn_info.PsnNo
  24022. PsnCertType = psn_info.PsnCertType
  24023. Certno = psn_info.Certno
  24024. PsnName = psn_info.PsnName
  24025. Gend = psn_info.Gend
  24026. Naty = psn_info.Naty
  24027. Brdy = psn_info.Brdy
  24028. Age = psn_info.Age
  24029. infoStr = psn_info.Insuinfo
  24030. idetinfoStr = psn_info.Idetinfo
  24031. infocode = 0
  24032. verify_number = psn_info.VerifyNumber
  24033. }
  24034. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24035. var result string
  24036. var requestLog string
  24037. 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), "")
  24038. if id_card_type == 4 {
  24039. psn_info, _ := service.GetPsnByPatientId(id)
  24040. PsnNo = psn_info.PsnNo
  24041. PsnCertType = psn_info.PsnCertType
  24042. Certno = psn_info.Certno
  24043. PsnName = psn_info.PsnName
  24044. Gend = psn_info.Gend
  24045. Naty = psn_info.Naty
  24046. Brdy = psn_info.Brdy
  24047. Age = psn_info.Age
  24048. infoStr = psn_info.Insuinfo
  24049. idetinfoStr = psn_info.Idetinfo
  24050. infocode = 0
  24051. verify_number = psn_info.VerifyNumber
  24052. } else {
  24053. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24054. if miConfig.Code == "H15049901371" {
  24055. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24056. utils.ErrorLog("解析失败:%v", err)
  24057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24058. return
  24059. }
  24060. res.ErrMsg = res10265.ErrMsg
  24061. res.Output = res10265.Output
  24062. res.InfRefmsgid = res10265.InfRefmsgid
  24063. } else {
  24064. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24065. utils.ErrorLog("解析失败:%v", err)
  24066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24067. return
  24068. }
  24069. }
  24070. PsnNo = res.Output.Baseinfo.PsnNo
  24071. PsnCertType = res.Output.Baseinfo.PsnCertType
  24072. Certno = res.Output.Baseinfo.Certno
  24073. PsnName = res.Output.Baseinfo.PsnName
  24074. Gend = res.Output.Baseinfo.Gend
  24075. Naty = res.Output.Baseinfo.Naty
  24076. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24077. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24078. infoStr = string(Iinfos)
  24079. idetinfoStr = string(Idetinfos)
  24080. if miConfig.Code == "H15049901371" {
  24081. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24082. } else {
  24083. infocode = res.Infcode
  24084. }
  24085. }
  24086. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24087. psn_info, _ := service.GetPsnByPatientId(id)
  24088. PsnNo = psn_info.PsnNo
  24089. PsnCertType = psn_info.PsnCertType
  24090. Certno = psn_info.Certno
  24091. PsnName = psn_info.PsnName
  24092. Gend = psn_info.Gend
  24093. Naty = psn_info.Naty
  24094. Brdy = psn_info.Brdy
  24095. Age = psn_info.Age
  24096. infoStr = psn_info.Insuinfo
  24097. idetinfoStr = psn_info.Idetinfo
  24098. infocode = 0
  24099. verify_number = psn_info.VerifyNumber
  24100. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24101. psn_info, _ := service.GetPsnByPatientId(id)
  24102. PsnNo = psn_info.PsnNo
  24103. PsnCertType = psn_info.PsnCertType
  24104. Certno = psn_info.Certno
  24105. PsnName = psn_info.PsnName
  24106. Gend = psn_info.Gend
  24107. Naty = psn_info.Naty
  24108. Brdy = psn_info.Brdy
  24109. Age = psn_info.Age
  24110. infoStr = psn_info.Insuinfo
  24111. idetinfoStr = psn_info.Idetinfo
  24112. infocode = 0
  24113. verify_number = psn_info.VerifyNumber
  24114. } else {
  24115. var result string
  24116. var requestLog string
  24117. //if miConfig.UserOrgId == 10138 {
  24118. if id_card_type != 4 || id_card_type != 1 {
  24119. var insa string
  24120. if len(patient.InsuplcAdmdvs) > 0 {
  24121. insa = patient.InsuplcAdmdvs
  24122. } else {
  24123. insa = miConfig.InsuplcAdmdvs
  24124. }
  24125. //psn_info, _ := service.GetPsnByPatientId(id)
  24126. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  24127. 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)
  24128. }
  24129. //}
  24130. //else {
  24131. // var insa string
  24132. // if len(patient.InsuplcAdmdvs) > 0 {
  24133. // insa = patient.InsuplcAdmdvs
  24134. // } else {
  24135. // insa = miConfig.InsuplcAdmdvs
  24136. // }
  24137. // 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)
  24138. //}
  24139. if id_card_type == 4 || id_card_type == 1 {
  24140. psn_info, _ := service.GetPsnByPatientId(id)
  24141. PsnNo = psn_info.PsnNo
  24142. PsnCertType = psn_info.PsnCertType
  24143. Certno = psn_info.Certno
  24144. PsnName = psn_info.PsnName
  24145. Gend = psn_info.Gend
  24146. Naty = psn_info.Naty
  24147. Brdy = psn_info.Brdy
  24148. Age = psn_info.Age
  24149. infoStr = psn_info.Insuinfo
  24150. idetinfoStr = psn_info.Idetinfo
  24151. infocode = 0
  24152. verify_number = psn_info.VerifyNumber
  24153. } else {
  24154. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24155. if miConfig.Code == "H15049901371" {
  24156. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24157. utils.ErrorLog("解析失败:%v", err)
  24158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24159. return
  24160. }
  24161. res.ErrMsg = res10265.ErrMsg
  24162. res.Output = res10265.Output
  24163. res.InfRefmsgid = res10265.InfRefmsgid
  24164. } else {
  24165. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24166. utils.ErrorLog("解析失败:%v", err)
  24167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24168. return
  24169. }
  24170. }
  24171. PsnNo = res.Output.Baseinfo.PsnNo
  24172. PsnCertType = res.Output.Baseinfo.PsnCertType
  24173. Certno = res.Output.Baseinfo.Certno
  24174. PsnName = res.Output.Baseinfo.PsnName
  24175. Gend = res.Output.Baseinfo.Gend
  24176. Naty = res.Output.Baseinfo.Naty
  24177. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24178. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24179. infoStr = string(Iinfos)
  24180. idetinfoStr = string(Idetinfos)
  24181. if miConfig.Code == "H15049901371" {
  24182. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24183. } else {
  24184. infocode = res.Infcode
  24185. }
  24186. }
  24187. }
  24188. if infocode == 0 {
  24189. his := models.VMHisPatient{
  24190. Name: name,
  24191. Gender: gender,
  24192. Birthday: birthUnix,
  24193. MedicalTreatmentType: medical_care,
  24194. IdType: certificates,
  24195. IdCardNo: id_card,
  24196. BalanceAccountsType: settlementValue,
  24197. SocialType: social_type,
  24198. MedicalInsuranceNumber: medical_insurance_card,
  24199. RegisterType: register_type,
  24200. RegisterCost: registration_fee,
  24201. TreatmentCost: medical_expenses,
  24202. Status: 1,
  24203. Ctime: time.Now().Unix(),
  24204. Mtime: time.Now().Unix(),
  24205. PsnNo: PsnNo,
  24206. PsnCertType: PsnCertType,
  24207. Certno: Certno,
  24208. PsnName: PsnName,
  24209. Gend: Gend,
  24210. Naty: Naty,
  24211. Brdy: Brdy,
  24212. Age: Age,
  24213. Iinfo: infoStr,
  24214. Idetinfo: idetinfoStr,
  24215. PatientId: patient.ID,
  24216. RecordDate: theTime.Unix(),
  24217. UserOrgId: adminInfo.CurrentOrgId,
  24218. AdminUserId: admin_user_id,
  24219. IsReturn: 1,
  24220. IdCardType: id_card_type,
  24221. Doctor: doctor,
  24222. Departments: department,
  24223. MdtrtGrpType: mdtrt_type,
  24224. }
  24225. timestamp := time.Now().Unix()
  24226. tempTime := time.Unix(timestamp, 0)
  24227. timeFormat := tempTime.Format("20060102150405")
  24228. chrgBchno := rand.Intn(100000) + 10000
  24229. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  24230. his.Number = ipt_otp_no
  24231. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  24232. department, _ := service.GetDepartMentDetail(department)
  24233. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  24234. IdCardNo := ""
  24235. if id_card_type == 1 {
  24236. // IdCardNo = medical_insurance_card
  24237. IdCardNo = patient.IdCardNo
  24238. } else {
  24239. IdCardNo = patient.IdCardNo
  24240. }
  24241. var rf []*ResultFive
  24242. json.Unmarshal([]byte(his.Iinfo), &rf)
  24243. var insutypes []*ResultFive
  24244. var insutype string
  24245. var insuplc_admdvs_temp string
  24246. var is390 int = 0
  24247. var is310 int = 0
  24248. for _, item := range rf {
  24249. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24250. insutypes = append(insutypes, item)
  24251. }
  24252. }
  24253. if len(insutypes) == 1 {
  24254. insutype = insutypes[0].Insutype
  24255. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24256. if insutype == "390" {
  24257. is390 = 1
  24258. }
  24259. if insutype == "310" {
  24260. is310 = 1
  24261. }
  24262. } else {
  24263. for _, i := range insutypes {
  24264. if i.Insutype == "390" {
  24265. is390 = 1
  24266. }
  24267. if i.Insutype == "310" {
  24268. is310 = 1
  24269. }
  24270. }
  24271. }
  24272. if is390 == 1 {
  24273. insutype = "390"
  24274. }
  24275. if is310 == 1 {
  24276. insutype = "310"
  24277. }
  24278. fmt.Println(social_type)
  24279. if social_type > 0 {
  24280. insutype = strconv.FormatInt(social_type, 10)
  24281. }
  24282. var infocode int64
  24283. var resThree ResultThree
  24284. var resThree10265 ResultThree10265
  24285. if len(insuplc_admdvs) == 0 {
  24286. psn_info, _ := service.GetPsnByPatientId(id)
  24287. //if len(psn_info.InsuplcAdmdvs) > 0 {
  24288. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24289. //}
  24290. } else {
  24291. insuplc_admdvs_temp = insuplc_admdvs
  24292. }
  24293. if miConfig.MdtrtareaAdmvs == "421300" {
  24294. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24295. psn_info, _ := service.GetPsnByPatientId(id)
  24296. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24297. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24298. "&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
  24299. resp, requestErr := http.Get(api)
  24300. if requestErr != nil {
  24301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24302. return
  24303. }
  24304. body, ioErr := ioutil.ReadAll(resp.Body)
  24305. if ioErr != nil {
  24306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24308. return
  24309. }
  24310. var respJSON map[string]interface{}
  24311. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24314. return
  24315. }
  24316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24317. result, _ := json.Marshal(respJSON)
  24318. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24319. utils.ErrorLog("解析失败:%v", err)
  24320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24321. return
  24322. }
  24323. infocode = resThree.Infcode
  24324. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24325. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24326. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24327. // insuplc_admdvs_temp =
  24328. //}
  24329. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24330. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24331. //}
  24332. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24333. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24334. "&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
  24335. resp, requestErr := http.Get(api)
  24336. if requestErr != nil {
  24337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24338. return
  24339. }
  24340. body, ioErr := ioutil.ReadAll(resp.Body)
  24341. if ioErr != nil {
  24342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24344. return
  24345. }
  24346. var respJSON map[string]interface{}
  24347. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24350. return
  24351. }
  24352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24353. result, _ := json.Marshal(respJSON)
  24354. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24355. utils.ErrorLog("解析失败:%v", err)
  24356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24357. return
  24358. }
  24359. infocode = resThree.Infcode
  24360. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24361. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24362. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24363. // insuplc_admdvs_temp =
  24364. //}
  24365. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24366. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24367. //}
  24368. utils.ErrorLog("解析失败:%v", insutype)
  24369. utils.ErrorLog("解析失败:%v", PsnNo)
  24370. utils.ErrorLog("解析失败:%v", Certno)
  24371. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  24372. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  24373. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  24374. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  24375. utils.ErrorLog("解析失败:%v", PsnNo)
  24376. utils.ErrorLog("解析失败:%v", department.Number)
  24377. utils.ErrorLog("解析失败:%v", department.Name)
  24378. utils.ErrorLog("解析失败:%v", roles.UserName)
  24379. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24380. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24381. "&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
  24382. resp, requestErr := http.Get(api)
  24383. if requestErr != nil {
  24384. utils.ErrorLog("解析失败:%v", requestErr)
  24385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24386. return
  24387. }
  24388. body, ioErr := ioutil.ReadAll(resp.Body)
  24389. if ioErr != nil {
  24390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24392. return
  24393. }
  24394. var respJSON map[string]interface{}
  24395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24398. return
  24399. }
  24400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24401. result, _ := json.Marshal(respJSON)
  24402. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24403. utils.ErrorLog("解析失败:%v", err)
  24404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24405. return
  24406. }
  24407. infocode = resThree.Infcode
  24408. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24409. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24410. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24411. // insuplc_admdvs_temp =
  24412. //}
  24413. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24414. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24415. //}
  24416. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24417. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24418. "&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
  24419. resp, requestErr := http.Get(api)
  24420. if requestErr != nil {
  24421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24422. return
  24423. }
  24424. body, ioErr := ioutil.ReadAll(resp.Body)
  24425. if ioErr != nil {
  24426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24428. return
  24429. }
  24430. var respJSON map[string]interface{}
  24431. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24434. return
  24435. }
  24436. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24437. result, _ := json.Marshal(respJSON)
  24438. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24439. utils.ErrorLog("解析失败:%v", err)
  24440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24441. return
  24442. }
  24443. infocode = resThree.Infcode
  24444. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24445. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24446. psn_info, _ := service.GetPsnByPatientId(id)
  24447. var verify_number string
  24448. if id_card_type == 4 {
  24449. verify_number = psn_info.VerifyNumber
  24450. } else if id_card_type == 1 {
  24451. bas := strings.Split(psn_info.CardInfo, "|")
  24452. cardNumber := bas[2]
  24453. verify_number = cardNumber
  24454. }
  24455. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24456. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24457. "&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
  24458. resp, requestErr := http.Get(api)
  24459. if requestErr != nil {
  24460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24461. return
  24462. }
  24463. body, ioErr := ioutil.ReadAll(resp.Body)
  24464. if ioErr != nil {
  24465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24467. return
  24468. }
  24469. var respJSON map[string]interface{}
  24470. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24473. return
  24474. }
  24475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24476. result, _ := json.Marshal(respJSON)
  24477. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24478. // utils.ErrorLog("解析失败:%v", err)
  24479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24480. // return
  24481. //}
  24482. //infocode = resThree.Infcode
  24483. //result, _ := json.Marshal(respJSON)
  24484. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24485. utils.ErrorLog("解析失败:%v", err)
  24486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24487. return
  24488. }
  24489. resThree.ErrMsg = resThree10265.ErrMsg
  24490. resThree.Output = resThree10265.Output
  24491. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24492. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24493. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24494. psn_info, _ := service.GetPsnByPatientId(id)
  24495. his.PsnNo = psn_info.PsnNo
  24496. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24497. var cert_no string
  24498. if id_card_type == 3 {
  24499. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  24500. cert_no = IdCardNo
  24501. } else if id_card_type == 4 {
  24502. cert_no = IdCardNo
  24503. psn_info.VerifyNumber = psn_info.VerifyNumber
  24504. } else {
  24505. bas := strings.Split(psn_info.CardInfo, "|")
  24506. cert_no = bas[2]
  24507. }
  24508. var hisPrescription []*models.HisPrescription
  24509. for _, item := range rf {
  24510. if item.Insutype == insutype {
  24511. //insuplc_admdvs = item.InsuplcAdmdvs
  24512. his.InsuplcAdmdvs = insuplc_admdvs
  24513. }
  24514. }
  24515. his.Insutype = insutype
  24516. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24517. fmt.Println(res3101)
  24518. fmt.Println(res3101.Infcode)
  24519. if res3101.Infcode == "0" {
  24520. fmt.Println("33333333")
  24521. if len(res3101.Output.Result) > 0 {
  24522. fmt.Println("222222")
  24523. for _, item := range res3101.Output.Result {
  24524. if len(res3101.ErrMsg) == 0 {
  24525. res3101.ErrMsg = item.VolaCont
  24526. } else {
  24527. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24528. }
  24529. }
  24530. c.ServeSuccessJSON(map[string]interface{}{
  24531. "failed_code": -10,
  24532. "msg": res3101.ErrMsg,
  24533. })
  24534. return
  24535. } else {
  24536. fmt.Println("11111")
  24537. var api string
  24538. if miConfig.MdtrtareaAdmvs == "320921" {
  24539. ipt_otp_no = timeFormat
  24540. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24541. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24542. "&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
  24543. } else {
  24544. ipt_otp_no = timeFormat
  24545. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24546. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24547. "&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
  24548. }
  24549. resp, requestErr := http.Get(api)
  24550. if requestErr != nil {
  24551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24552. return
  24553. }
  24554. body, ioErr := ioutil.ReadAll(resp.Body)
  24555. if ioErr != nil {
  24556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24558. return
  24559. }
  24560. var respJSON map[string]interface{}
  24561. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24564. return
  24565. }
  24566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24567. result, _ := json.Marshal(respJSON)
  24568. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24569. utils.ErrorLog("解析失败:%v", err)
  24570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24571. return
  24572. }
  24573. resThree.ErrMsg = resThree10265.ErrMsg
  24574. resThree.Output = resThree10265.Output
  24575. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24576. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24577. }
  24578. } else if res3101.Infcode != "0" {
  24579. c.ServeSuccessJSON(map[string]interface{}{
  24580. "failed_code": -10,
  24581. "msg": res3101.ErrMsg,
  24582. })
  24583. return
  24584. }
  24585. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24586. psn_info, _ := service.GetPsnByPatientId(id)
  24587. var cert_no string
  24588. if id_card_type == 1 {
  24589. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24590. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24591. } else if id_card_type == 4 {
  24592. cert_no = psn_info.VerifyNumber
  24593. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24594. } else {
  24595. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24596. cert_no = psn_info.VerifyNumber
  24597. }
  24598. 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)
  24599. saveLog(result, requestLog, "2201", "挂号")
  24600. if miConfig.Code == "H15049901371" {
  24601. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24602. utils.ErrorLog("解析失败:%v", err)
  24603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24604. return
  24605. }
  24606. resThree.ErrMsg = resThree10265.ErrMsg
  24607. resThree.Output = resThree10265.Output
  24608. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24609. } else {
  24610. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24611. utils.ErrorLog("解析失败:%v", err)
  24612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24613. return
  24614. }
  24615. }
  24616. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24617. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24618. psn_info, _ := service.GetPsnByPatientId(id)
  24619. var result string
  24620. var requestLog string
  24621. if id_card_type == 1 {
  24622. bas := strings.Split(psn_info.CardInfo, "|")
  24623. basNumber := bas[2]
  24624. card_sn := bas[3]
  24625. 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)
  24626. saveLog(result, requestLog, "2201A", "挂号")
  24627. } else if id_card_type == 2 {
  24628. 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, "", "", "", "", "", "")
  24629. saveLog(result, requestLog, "2201A", "挂号")
  24630. } else {
  24631. 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)
  24632. saveLog(result, requestLog, "2201A", "挂号")
  24633. }
  24634. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24635. utils.ErrorLog("解析失败:%v", err)
  24636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24637. return
  24638. }
  24639. infocode = resThree.Infcode
  24640. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24641. psn_info, _ := service.GetPsnByPatientId(id)
  24642. var result string
  24643. var requestLog string
  24644. if id_card_type == 1 {
  24645. bas := strings.Split(psn_info.CardInfo, "|")
  24646. basNumber := bas[2]
  24647. card_sn := ""
  24648. 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)
  24649. saveLog(result, requestLog, "2201A", "挂号")
  24650. } else if id_card_type == 2 {
  24651. 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, "", "", "", "", "", "")
  24652. saveLog(result, requestLog, "2201A", "挂号")
  24653. } else {
  24654. 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)
  24655. saveLog(result, requestLog, "2201A", "挂号")
  24656. }
  24657. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24658. utils.ErrorLog("解析失败:%v", err)
  24659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24660. return
  24661. }
  24662. infocode = resThree.Infcode
  24663. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  24664. psn_info, _ := service.GetPsnByPatientId(id)
  24665. var result string
  24666. var requestLog string
  24667. if id_card_type == 1 {
  24668. bas := strings.Split(psn_info.CardInfo, "|")
  24669. basNumber := bas[2]
  24670. card_sn := ""
  24671. 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)
  24672. saveLog(result, requestLog, "2201A", "挂号")
  24673. } else if id_card_type == 2 {
  24674. 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, "", "", "", "", "", "")
  24675. saveLog(result, requestLog, "2201A", "挂号")
  24676. } else {
  24677. 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)
  24678. saveLog(result, requestLog, "2201A", "挂号")
  24679. }
  24680. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24681. utils.ErrorLog("解析失败:%v", err)
  24682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24683. return
  24684. }
  24685. infocode = resThree.Infcode
  24686. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24687. psn_info, _ := service.GetPsnByPatientId(id)
  24688. his.PsnNo = psn_info.PsnNo
  24689. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24690. var cert_no string
  24691. if id_card_type == 1 {
  24692. bas := strings.Split(psn_info.CardInfo, "|")
  24693. cert_no = bas[2]
  24694. } else if id_card_type == 4 {
  24695. cert_no = psn_info.VerifyNumber
  24696. psn_info.VerifyNumber = psn_info.VerifyNumber
  24697. IdCardNo = psn_info.VerifyNumber
  24698. } else {
  24699. cert_no = IdCardNo
  24700. psn_info.VerifyNumber = cert_no
  24701. }
  24702. for _, item := range rf {
  24703. if item.Insutype == insutype {
  24704. his.InsuplcAdmdvs = insuplc_admdvs
  24705. }
  24706. }
  24707. his.Insutype = insutype
  24708. var api string
  24709. ipt_otp_no = timeFormat
  24710. api = miConfig.SecretKey + "ahyb/2201?verify_number=" + cert_no + "&cert_no=" + IdCardNo + "&psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24711. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24712. "&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
  24713. resp, requestErr := http.Get(api)
  24714. if requestErr != nil {
  24715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24716. return
  24717. }
  24718. body, ioErr := ioutil.ReadAll(resp.Body)
  24719. if ioErr != nil {
  24720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24722. return
  24723. }
  24724. var respJSON map[string]interface{}
  24725. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24728. return
  24729. }
  24730. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24731. if status == "0" {
  24732. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24733. c.ServeSuccessJSON(map[string]interface{}{
  24734. "failed_code": -10,
  24735. "msg": err_msg,
  24736. })
  24737. return
  24738. }
  24739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24740. result, _ := json.Marshal(respJSON)
  24741. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24742. utils.ErrorLog("解析失败:%v", err)
  24743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24744. return
  24745. }
  24746. infocode = resThree.Infcode
  24747. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24748. psn_info, _ := service.GetPsnByPatientId(id)
  24749. his.PsnNo = psn_info.PsnNo
  24750. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24751. var cert_no string
  24752. if id_card_type == 1 {
  24753. bas := strings.Split(psn_info.CardInfo, "|")
  24754. cert_no = bas[2]
  24755. } else if id_card_type == 4 {
  24756. cert_no = psn_info.VerifyNumber
  24757. psn_info.VerifyNumber = psn_info.VerifyNumber
  24758. IdCardNo = psn_info.VerifyNumber
  24759. } else {
  24760. cert_no = IdCardNo
  24761. psn_info.VerifyNumber = cert_no
  24762. }
  24763. for _, item := range rf {
  24764. if item.Insutype == insutype {
  24765. his.InsuplcAdmdvs = insuplc_admdvs
  24766. patient.InsuplcAdmdvs = insuplc_admdvs
  24767. }
  24768. }
  24769. his.Insutype = insutype
  24770. var api string
  24771. ipt_otp_no = timeFormat
  24772. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&verify_number=" + cert_no + "&cert_no=" + IdCardNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24773. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24774. "&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
  24775. resp, requestErr := http.Get(api)
  24776. if requestErr != nil {
  24777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24778. return
  24779. }
  24780. body, ioErr := ioutil.ReadAll(resp.Body)
  24781. if ioErr != nil {
  24782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24784. return
  24785. }
  24786. var respJSON map[string]interface{}
  24787. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24790. return
  24791. }
  24792. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24793. if status == "0" {
  24794. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24795. c.ServeSuccessJSON(map[string]interface{}{
  24796. "failed_code": -10,
  24797. "msg": err_msg,
  24798. })
  24799. return
  24800. }
  24801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24802. result, _ := json.Marshal(respJSON)
  24803. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24804. utils.ErrorLog("解析失败:%v", err)
  24805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24806. return
  24807. }
  24808. infocode = resThree.Infcode
  24809. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24810. psn_info, _ := service.GetPsnByPatientId(id)
  24811. var result string
  24812. var requestLog string
  24813. if id_card_type == 1 {
  24814. bas := strings.Split(psn_info.CardInfo, "|")
  24815. basNumber := bas[2]
  24816. card_sn := bas[3]
  24817. 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)
  24818. saveLog(result, requestLog, "2201A", "挂号")
  24819. } else if id_card_type == 2 {
  24820. 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, "", "")
  24821. saveLog(result, requestLog, "2201A", "挂号")
  24822. } else {
  24823. 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, "", "")
  24824. saveLog(result, requestLog, "2201A", "挂号")
  24825. }
  24826. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24827. utils.ErrorLog("解析失败:%v", err)
  24828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24829. return
  24830. }
  24831. infocode = resThree.Infcode
  24832. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24833. psn_info, _ := service.GetPsnByPatientId(id)
  24834. 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)
  24835. saveLog(result, requestLog, "2201A", "挂号")
  24836. if miConfig.Code == "H15049901371" {
  24837. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24838. utils.ErrorLog("解析失败:%v", err)
  24839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24840. return
  24841. }
  24842. resThree.ErrMsg = resThree10265.ErrMsg
  24843. resThree.Output = resThree10265.Output
  24844. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24845. } else {
  24846. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24847. utils.ErrorLog("解析失败:%v", err)
  24848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24849. return
  24850. }
  24851. }
  24852. if miConfig.Code == "H15049901371" {
  24853. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24854. } else {
  24855. infocode = resThree.Infcode
  24856. }
  24857. } else {
  24858. psn_info, _ := service.GetPsnByPatientId(id)
  24859. if id_card_type == 4 || id_card_type == 1 {
  24860. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24861. }
  24862. var rf []*ResultFive
  24863. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24864. var insutypes []*ResultFive
  24865. var insutype string
  24866. var is390 int = 0
  24867. var is310 int = 0
  24868. for _, item := range rf {
  24869. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24870. insutypes = append(insutypes, item)
  24871. }
  24872. }
  24873. if len(insutypes) == 1 {
  24874. insutype = insutypes[0].Insutype
  24875. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24876. } else {
  24877. for _, i := range insutypes {
  24878. if i.Insutype == "390" {
  24879. is390 = 1
  24880. }
  24881. if i.Insutype == "310" {
  24882. is310 = 1
  24883. }
  24884. }
  24885. }
  24886. if is390 == 1 {
  24887. insutype = "390"
  24888. }
  24889. if is310 == 1 {
  24890. insutype = "310"
  24891. }
  24892. fmt.Println(len(insutypes))
  24893. if len(insutypes) == 0 {
  24894. for index, item := range rf {
  24895. if index == 0 {
  24896. insutype = item.Insutype
  24897. insuplc_admdvs = item.InsuplcAdmdvs
  24898. }
  24899. }
  24900. fmt.Println(insutype)
  24901. fmt.Println(insuplc_admdvs)
  24902. }
  24903. if social_type > 0 {
  24904. insutype = strconv.FormatInt(social_type, 10)
  24905. }
  24906. fmt.Println("--------")
  24907. fmt.Println(psn_info)
  24908. fmt.Println(psn_info.PsnNo)
  24909. if miConfig.MdtrtareaAdmvs == "441202" {
  24910. var hisPrescription []*models.HisPrescription
  24911. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24912. if res3101.Infcode == 0 {
  24913. fmt.Println("33333333")
  24914. if len(res3101.Output.Result) > 0 {
  24915. fmt.Println("222222")
  24916. for _, item := range res3101.Output.Result {
  24917. if len(res3101.ErrMsg) == 0 {
  24918. res3101.ErrMsg = item.VolaCont
  24919. } else {
  24920. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24921. }
  24922. }
  24923. c.ServeSuccessJSON(map[string]interface{}{
  24924. "failed_code": -10,
  24925. "msg": res3101.ErrMsg,
  24926. })
  24927. return
  24928. } else {
  24929. hour := time.Now().Format("15")
  24930. min := time.Now().Format("04")
  24931. sec := time.Now().Format("05")
  24932. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24933. fmt.Println(record_time_two)
  24934. 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)
  24935. saveLog(result, requestLog, "2201A", "挂号")
  24936. if miConfig.Code == "H15049901371" {
  24937. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24938. utils.ErrorLog("解析失败:%v", err)
  24939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24940. return
  24941. }
  24942. resThree.ErrMsg = resThree10265.ErrMsg
  24943. resThree.Output = resThree10265.Output
  24944. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24945. } else {
  24946. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24947. utils.ErrorLog("解析失败:%v", err)
  24948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24949. return
  24950. }
  24951. }
  24952. if miConfig.Code == "H15049901371" {
  24953. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24954. } else {
  24955. infocode = resThree.Infcode
  24956. }
  24957. }
  24958. } else if res3101.Infcode != 0 {
  24959. c.ServeSuccessJSON(map[string]interface{}{
  24960. "failed_code": -10,
  24961. "msg": res3101.ErrMsg,
  24962. })
  24963. return
  24964. }
  24965. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24966. var hisPrescription []*models.HisPrescription
  24967. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24968. if res3101.Infcode == 0 {
  24969. fmt.Println("33333333")
  24970. if len(res3101.Output.Result) > 0 {
  24971. fmt.Println("222222")
  24972. for _, item := range res3101.Output.Result {
  24973. if len(res3101.ErrMsg) == 0 {
  24974. res3101.ErrMsg = item.VolaCont
  24975. } else {
  24976. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24977. }
  24978. }
  24979. c.ServeSuccessJSON(map[string]interface{}{
  24980. "failed_code": -10,
  24981. "msg": res3101.ErrMsg,
  24982. })
  24983. return
  24984. } else {
  24985. hour := time.Now().Format("15")
  24986. min := time.Now().Format("04")
  24987. sec := time.Now().Format("05")
  24988. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24989. fmt.Println(record_time_two)
  24990. 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)
  24991. saveLog(result, requestLog, "2201A", "挂号")
  24992. if miConfig.Code == "H15049901371" {
  24993. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24994. utils.ErrorLog("解析失败:%v", err)
  24995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24996. return
  24997. }
  24998. resThree.ErrMsg = resThree10265.ErrMsg
  24999. resThree.Output = resThree10265.Output
  25000. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25001. } else {
  25002. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25003. utils.ErrorLog("解析失败:%v", err)
  25004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25005. return
  25006. }
  25007. }
  25008. if miConfig.Code == "H15049901371" {
  25009. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25010. } else {
  25011. infocode = resThree.Infcode
  25012. }
  25013. }
  25014. } else if res3101.Infcode != 0 {
  25015. c.ServeSuccessJSON(map[string]interface{}{
  25016. "failed_code": -10,
  25017. "msg": res3101.ErrMsg,
  25018. })
  25019. return
  25020. }
  25021. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25022. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25023. psn_info, _ := service.GetPsnByPatientId(id)
  25024. var verify_number string
  25025. if id_card_type == 4 {
  25026. verify_number = psn_info.VerifyNumber
  25027. } else if id_card_type == 1 {
  25028. bas := strings.Split(psn_info.CardInfo, "|")
  25029. cardNumber := bas[2]
  25030. verify_number = cardNumber
  25031. } else {
  25032. verify_number = psn_info.Certno
  25033. }
  25034. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25035. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25036. "&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
  25037. resp, requestErr := http.Get(api)
  25038. if requestErr != nil {
  25039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25040. return
  25041. }
  25042. body, ioErr := ioutil.ReadAll(resp.Body)
  25043. if ioErr != nil {
  25044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25046. return
  25047. }
  25048. var respJSON map[string]interface{}
  25049. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25052. return
  25053. }
  25054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25055. result, _ := json.Marshal(respJSON)
  25056. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25057. utils.ErrorLog("解析失败:%v", err)
  25058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25059. return
  25060. }
  25061. infocode = resThree.Infcode
  25062. } else {
  25063. hour := time.Now().Format("15")
  25064. min := time.Now().Format("04")
  25065. sec := time.Now().Format("05")
  25066. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25067. if id_card_type == 1 {
  25068. for _, item := range rf {
  25069. if item.Insutype == strconv.FormatInt(social_type, 10) {
  25070. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  25071. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25072. } else if strconv.FormatInt(social_type, 10) == "390" {
  25073. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25074. } else {
  25075. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25076. }
  25077. }
  25078. }
  25079. }
  25080. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  25081. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25082. }
  25083. if id_card_type == 1 {
  25084. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  25085. bas := strings.Split(psn_info.CardInfo, "|")
  25086. basNumber := bas[1]
  25087. IdCardNo = basNumber
  25088. }
  25089. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  25090. IdCardNo = psn_info.VerifyNumber
  25091. }
  25092. if len(insuplc_admdvs_temp) == 0 {
  25093. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25094. }
  25095. var result string
  25096. var requestLog string
  25097. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" {
  25098. var hisPrescription []*models.HisPrescription
  25099. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25100. if res3101.Infcode == 0 {
  25101. if len(res3101.Output.Result) > 0 {
  25102. if len(res3101.Output.Result) > 0 {
  25103. c.ServeSuccessJSON(map[string]interface{}{
  25104. "failed_code": -10,
  25105. "failed_type": 100,
  25106. "warm_type": 1,
  25107. "msg": res3101,
  25108. })
  25109. return
  25110. } else {
  25111. c.ServeSuccessJSON(map[string]interface{}{
  25112. "failed_code": -10,
  25113. "msg": res3101.ErrMsg,
  25114. })
  25115. return
  25116. }
  25117. } else {
  25118. hour := time.Now().Format("15")
  25119. min := time.Now().Format("04")
  25120. sec := time.Now().Format("05")
  25121. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25122. fmt.Println(record_time_two)
  25123. if his.IdCardType == 2 {
  25124. IdCardNo = psn_info.Certno
  25125. psn_info.VerifyNumber = psn_info.Certno
  25126. } else if his.IdCardType == 4 {
  25127. IdCardNo = psn_info.Certno
  25128. } else {
  25129. bas := strings.Split(psn_info.CardInfo, "|")
  25130. IdCardNo = bas[2]
  25131. }
  25132. 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)
  25133. saveLog(result, requestLog, "2201A", "挂号")
  25134. if miConfig.Code == "H15049901371" {
  25135. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25136. utils.ErrorLog("解析失败:%v", err)
  25137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25138. return
  25139. }
  25140. resThree.ErrMsg = resThree10265.ErrMsg
  25141. resThree.Output = resThree10265.Output
  25142. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25143. } else {
  25144. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25145. utils.ErrorLog("解析失败:%v", err)
  25146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25147. return
  25148. }
  25149. }
  25150. if miConfig.Code == "H15049901371" {
  25151. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25152. } else {
  25153. infocode = resThree.Infcode
  25154. }
  25155. }
  25156. } else if res3101.Infcode != 0 {
  25157. c.ServeSuccessJSON(map[string]interface{}{
  25158. "failed_code": -10,
  25159. "msg": res3101.ErrMsg,
  25160. })
  25161. return
  25162. }
  25163. } else {
  25164. psn_info, _ := service.GetPsnByPatientId(id)
  25165. var rf []*ResultFive
  25166. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25167. //var insutypes []*ResultFive
  25168. var insutype string
  25169. var insutypes []*ResultFive
  25170. var is390 int = 0
  25171. var is310 int = 0
  25172. for _, item := range rf {
  25173. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25174. insutypes = append(insutypes, item)
  25175. }
  25176. }
  25177. if len(insutypes) == 1 {
  25178. insutype = insutypes[0].Insutype
  25179. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25180. } else {
  25181. for _, i := range insutypes {
  25182. if i.Insutype == "390" {
  25183. is390 = 1
  25184. }
  25185. if i.Insutype == "310" {
  25186. is310 = 1
  25187. }
  25188. }
  25189. }
  25190. if is390 == 1 {
  25191. insutype = "390"
  25192. }
  25193. if is310 == 1 {
  25194. insutype = "310"
  25195. }
  25196. if len(insutypes) == 0 {
  25197. insutype = "310"
  25198. }
  25199. if social_type > 0 {
  25200. insutype = strconv.FormatInt(social_type, 10)
  25201. }
  25202. for _, item := range rf {
  25203. if item.Insutype == insutype {
  25204. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25205. }
  25206. }
  25207. if len(insuplc_admdvs_tt) > 0{
  25208. insuplc_admdvs_temp = insuplc_admdvs_tt
  25209. }
  25210. 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)
  25211. saveLog(result, requestLog, "2201A", "挂号")
  25212. }
  25213. if miConfig.Code == "H15049901371" {
  25214. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25215. utils.ErrorLog("解析失败:%v", err)
  25216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25217. return
  25218. }
  25219. resThree.ErrMsg = resThree10265.ErrMsg
  25220. resThree.Output = resThree10265.Output
  25221. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25222. } else {
  25223. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25224. utils.ErrorLog("解析失败:%v", err)
  25225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25226. return
  25227. }
  25228. }
  25229. if miConfig.Code == "H15049901371" {
  25230. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25231. } else {
  25232. infocode = resThree.Infcode
  25233. }
  25234. }
  25235. }
  25236. if infocode == -1 {
  25237. adminUser := c.GetAdminUserInfo()
  25238. errlog := &models.HisOrderError{
  25239. UserOrgId: adminUser.CurrentOrgId,
  25240. Ctime: time.Now().Unix(),
  25241. Mtime: time.Now().Unix(),
  25242. ErrMsg: resThree.ErrMsg,
  25243. Status: 1,
  25244. PatientId: id,
  25245. RecordTime: recordDateTime,
  25246. Stage: 2,
  25247. }
  25248. service.CreateErrMsgLog(errlog)
  25249. c.ServeSuccessJSON(map[string]interface{}{
  25250. "failed_code": -10,
  25251. "msg": resThree.ErrMsg,
  25252. })
  25253. return
  25254. }
  25255. his.Number = resThree.Output.Data.MdtrtID
  25256. his.PsnNo = resThree.Output.Data.PsnNo
  25257. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  25258. his.IdCardNo = patient.IdCardNo
  25259. his.PhoneNumber = patient.Phone
  25260. his.UserOrgId = adminInfo.CurrentOrgId
  25261. his.Insutype = insutype
  25262. his.Ctime = time.Now().Unix()
  25263. his.Mtime = time.Now().Unix()
  25264. his.InsuplcAdmdvs = insuplc_admdvs_temp
  25265. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  25266. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25267. }
  25268. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  25269. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25270. }
  25271. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  25272. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25273. }
  25274. his.Status = 1
  25275. his.MdtrtGrpType = mdtrt_type
  25276. service.UpdateHisPatientStatus(&his)
  25277. service.UpdateHisPatient123(&patient)
  25278. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  25279. c.ServeSuccessJSON(map[string]interface{}{
  25280. "his_info": his,
  25281. })
  25282. } else {
  25283. adminUser := c.GetAdminUserInfo()
  25284. errlog := &models.HisOrderError{
  25285. UserOrgId: adminUser.CurrentOrgId,
  25286. Ctime: time.Now().Unix(),
  25287. Mtime: time.Now().Unix(),
  25288. ErrMsg: res.ErrMsg,
  25289. Status: 1,
  25290. PatientId: id,
  25291. RecordTime: recordDateTime,
  25292. Stage: 1,
  25293. }
  25294. service.CreateErrMsgLog(errlog)
  25295. c.ServeSuccessJSON(map[string]interface{}{
  25296. "failed_code": -10,
  25297. "msg": res.ErrMsg,
  25298. })
  25299. return
  25300. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  25301. }
  25302. }
  25303. }
  25304. func (c *HisApiController) GetUploadInfo() {
  25305. id, _ := c.GetInt64("id")
  25306. record_time := c.GetString("record_time")
  25307. his_patient_id, _ := c.GetInt64("his_patient_id")
  25308. order_id, _ := c.GetInt64("order_id")
  25309. pay_way, _ := c.GetInt64("pay_way")
  25310. pay_ways := c.GetString("pay_ways")
  25311. oth_desc := c.GetString("oth_desc")
  25312. pay_price, _ := c.GetFloat("pay_price")
  25313. pay_card_no := c.GetString("pay_card_no")
  25314. discount_price, _ := c.GetFloat("discount_price")
  25315. preferential_price, _ := c.GetFloat("preferential_price")
  25316. reality_price, _ := c.GetFloat("reality_price")
  25317. found_price, _ := c.GetFloat("found_price")
  25318. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  25319. private_price, _ := c.GetFloat("private_price")
  25320. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  25321. admin_user_id, _ := c.GetInt64("admin_user_id")
  25322. fapiao_code := c.GetString("fapiao_code")
  25323. fapiao_number := c.GetString("fapiao_number")
  25324. diagnosis_id := c.GetString("diagnosis")
  25325. sick_type, _ := c.GetInt64("sick_type")
  25326. reg_type, _ := c.GetInt64("p_type")
  25327. begin_time := c.GetString("begin_time")
  25328. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  25329. cash_pay := c.GetString("cash_pay")
  25330. band_card_pay := c.GetString("band_card_pay")
  25331. wechat_pay := c.GetString("wechat_pay")
  25332. ali_pay := c.GetString("ali_pay")
  25333. jifen_pay := c.GetString("jifen_pay")
  25334. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  25335. fmt.Println(acct_used_flag)
  25336. id_str := c.GetString("ids")
  25337. ids_arr := strings.Split(id_str, ",")
  25338. timeLayout := "2006-01-02"
  25339. loc, _ := time.LoadLocation("Local")
  25340. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25341. if err != nil {
  25342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25343. return
  25344. }
  25345. recordDateTime := theTime.Unix()
  25346. adminUser := c.GetAdminUserInfo()
  25347. var tempOrder models.HisOrder
  25348. tempOrder, _ = service.GetHisOrderByID(order_id)
  25349. var prescriptions []*models.HisPrescription
  25350. var start_time int64
  25351. var end_time int64
  25352. //押金模块
  25353. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  25354. tmp_decimal := c.GetString("tmp_decimal")
  25355. var decimal float64 //本次使用的押金
  25356. var errmsg error
  25357. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  25358. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  25359. return
  25360. }
  25361. if len(tmp_decimal) > 0 {
  25362. if tmp_decimal[0] == 45 {
  25363. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  25364. return
  25365. }
  25366. }
  25367. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  25368. fmt.Println(errs)
  25369. decimal = tt
  25370. //if adminUser.CurrentOrgId == 10106{
  25371. // if len(fapiao_code) == 0{
  25372. // fapiao_code = "144072080589"
  25373. // }
  25374. // if len(fapiao_number) == 0{
  25375. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  25376. // if order.ID == 0{
  25377. // fapiao_number = "00001520"
  25378. // }else{
  25379. // //fapiao_code = "00001520"
  25380. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  25381. // var zero string
  25382. // if fpNumber >= 1000{
  25383. // zero = "0000" + strconv.Itoa(fpNumber)
  25384. // }else if fpNumber >= 10000{
  25385. // zero = "000" + strconv.Itoa(fpNumber)
  25386. // } else if fpNumber >= 100000{
  25387. // zero = "00" + strconv.Itoa(fpNumber)
  25388. // } else if fpNumber >= 1000000{
  25389. // zero = "0" + strconv.Itoa(fpNumber)
  25390. // }else {
  25391. // zero = strconv.Itoa(fpNumber)
  25392. // }
  25393. // fapiao_number = zero
  25394. // }
  25395. // }
  25396. //}
  25397. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25398. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25399. var patientPrescription models.HisPrescriptionInfo
  25400. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25401. if patientPrescription.ID == 0 {
  25402. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  25403. }
  25404. //if patientPrescription.Do
  25405. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25406. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25407. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25408. diagnosis_ids := strings.Split(diagnosis_id, ",")
  25409. var config []*models.HisXtDiagnoseConfig
  25410. for _, item := range diagnosis_ids {
  25411. id, _ := strconv.ParseInt(item, 10, 64)
  25412. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25413. config = append(config, &diagnosisConfig)
  25414. }
  25415. sickConfig, _ := service.FindSickById(sick_type)
  25416. //if tempOrder.ID == 0 {
  25417. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  25418. //}
  25419. if tempOrder.ID == 0 {
  25420. var result string
  25421. var requestLog string
  25422. var res2 ResultSix
  25423. var res3 GZResultSix
  25424. var ressix10265 ResultSix10265
  25425. if miConfig.MdtrtareaAdmvs == "421300" {
  25426. data := make(map[string]interface{})
  25427. client := &http.Client{}
  25428. data["psn_no"] = his.PsnNo
  25429. data["mdtrt_id"] = his.Number
  25430. data["opter"] = roles.UserName
  25431. data["org_name"] = miConfig.OrgName
  25432. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25433. data["doctor_id"] = doctor_info.DoctorNumber
  25434. data["doctor_name"] = doctor_info.UserName
  25435. data["department"] = department.Name
  25436. data["fixmedins_code"] = miConfig.Code
  25437. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25438. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25439. data["secret_key"] = miConfig.SecretKey
  25440. data["sick_code"] = sickConfig.CountryCode
  25441. data["sick_name"] = sickConfig.ClassName
  25442. data["dept"] = strconv.FormatInt(department.ID, 10)
  25443. data["config"] = config
  25444. data["begin_time"] = begin_time
  25445. bytesData, _ := json.Marshal(data)
  25446. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25447. resp, _ := client.Do(req)
  25448. defer resp.Body.Close()
  25449. body, ioErr := ioutil.ReadAll(resp.Body)
  25450. if ioErr != nil {
  25451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25453. return
  25454. }
  25455. var respJSON map[string]interface{}
  25456. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25459. return
  25460. }
  25461. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25462. userJSONBytes, _ := json.Marshal(respJSON)
  25463. fmt.Println("log")
  25464. fmt.Println(string(userJSONBytes))
  25465. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25466. utils.ErrorLog("解析失败:%v", err)
  25467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25468. return
  25469. }
  25470. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25471. data := make(map[string]interface{})
  25472. client := &http.Client{}
  25473. data["psn_no"] = his.PsnNo
  25474. data["mdtrt_id"] = his.Number
  25475. data["opter"] = roles.UserName
  25476. data["org_name"] = miConfig.OrgName
  25477. if reg_type == 11 && his.Insutype == "390" {
  25478. data["med_type"] = "110104"
  25479. } else {
  25480. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25481. }
  25482. data["doctor_id"] = doctor_info.DoctorNumber
  25483. data["doctor_name"] = doctor_info.UserName
  25484. data["department"] = department.Name
  25485. data["fixmedins_code"] = miConfig.Code
  25486. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25487. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25488. data["secret_key"] = miConfig.SecretKey
  25489. data["sick_code"] = sickConfig.CountryCode
  25490. data["sick_name"] = sickConfig.ClassName
  25491. data["dept"] = strconv.FormatInt(department.ID, 10)
  25492. data["config"] = config
  25493. data["begin_time"] = begin_time
  25494. bytesData, _ := json.Marshal(data)
  25495. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25496. resp, _ := client.Do(req)
  25497. defer resp.Body.Close()
  25498. body, ioErr := ioutil.ReadAll(resp.Body)
  25499. if ioErr != nil {
  25500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25502. return
  25503. }
  25504. var respJSON map[string]interface{}
  25505. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25508. return
  25509. }
  25510. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25511. userJSONBytes, _ := json.Marshal(respJSON)
  25512. fmt.Println("log")
  25513. fmt.Println(string(userJSONBytes))
  25514. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25515. utils.ErrorLog("解析失败:%v", err)
  25516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25517. return
  25518. }
  25519. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25520. data := make(map[string]interface{})
  25521. client := &http.Client{}
  25522. data["psn_no"] = his.PsnNo
  25523. data["mdtrt_id"] = his.Number
  25524. data["opter"] = roles.UserName
  25525. data["org_name"] = miConfig.OrgName
  25526. if reg_type == 11 && his.Insutype == "390" {
  25527. data["med_type"] = "110104"
  25528. } else {
  25529. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25530. }
  25531. data["doctor_id"] = doctor_info.DoctorNumber
  25532. data["doctor_name"] = doctor_info.UserName
  25533. data["department"] = department.Name
  25534. data["fixmedins_code"] = miConfig.Code
  25535. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25536. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25537. data["secret_key"] = miConfig.SecretKey
  25538. data["sick_code"] = sickConfig.CountryCode
  25539. data["sick_name"] = sickConfig.ClassName
  25540. data["dept"] = strconv.FormatInt(department.ID, 10)
  25541. data["config"] = config
  25542. data["begin_time"] = begin_time
  25543. bytesData, _ := json.Marshal(data)
  25544. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25545. resp, _ := client.Do(req)
  25546. defer resp.Body.Close()
  25547. body, ioErr := ioutil.ReadAll(resp.Body)
  25548. if ioErr != nil {
  25549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25551. return
  25552. }
  25553. var respJSON map[string]interface{}
  25554. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25557. return
  25558. }
  25559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25560. userJSONBytes, _ := json.Marshal(respJSON)
  25561. fmt.Println("log")
  25562. fmt.Println(string(userJSONBytes))
  25563. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25564. utils.ErrorLog("解析失败:%v", err)
  25565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25566. return
  25567. }
  25568. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25569. data := make(map[string]interface{})
  25570. client := &http.Client{}
  25571. data["psn_no"] = his.PsnNo
  25572. data["mdtrt_id"] = his.Number
  25573. data["opter"] = roles.UserName
  25574. data["org_name"] = miConfig.OrgName
  25575. if reg_type == 11 && his.Insutype == "390" {
  25576. data["med_type"] = "110104"
  25577. } else {
  25578. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25579. }
  25580. data["doctor_id"] = doctor_info.DoctorNumber
  25581. data["doctor_name"] = doctor_info.UserName
  25582. data["department"] = department.Name
  25583. data["fixmedins_code"] = miConfig.Code
  25584. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25585. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25586. data["secret_key"] = miConfig.SecretKey
  25587. data["sick_code"] = sickConfig.CountryCode
  25588. data["sick_name"] = sickConfig.ClassName
  25589. data["dept"] = strconv.FormatInt(department.ID, 10)
  25590. data["config"] = config
  25591. data["begin_time"] = begin_time
  25592. bytesData, _ := json.Marshal(data)
  25593. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25594. resp, _ := client.Do(req)
  25595. defer resp.Body.Close()
  25596. body, ioErr := ioutil.ReadAll(resp.Body)
  25597. if ioErr != nil {
  25598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25600. return
  25601. }
  25602. var respJSON map[string]interface{}
  25603. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25606. return
  25607. }
  25608. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25609. userJSONBytes, _ := json.Marshal(respJSON)
  25610. fmt.Println("log")
  25611. fmt.Println(string(userJSONBytes))
  25612. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25613. utils.ErrorLog("解析失败:%v", err)
  25614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25615. return
  25616. }
  25617. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25618. data := make(map[string]interface{})
  25619. client := &http.Client{}
  25620. data["psn_no"] = his.PsnNo
  25621. data["mdtrt_id"] = his.Number
  25622. data["doctor"] = roles.UserName
  25623. data["department"] = department.Name
  25624. data["org_name"] = miConfig.OrgName
  25625. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25626. data["doctor_id"] = doctor_info.DoctorNumber
  25627. data["new_doctor_name"] = doctor_info.UserName
  25628. data["fixmedins_code"] = miConfig.Code
  25629. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25630. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25631. data["secret_key"] = miConfig.SecretKey
  25632. data["sick_code"] = sickConfig.CountryCode
  25633. data["sick_name"] = sickConfig.ClassName
  25634. data["url"] = miConfig.Url
  25635. data["ak"] = miConfig.AccessKey
  25636. data["begin_time"] = begin_time
  25637. data["cainfo"] = miConfig.Cainfo
  25638. data["dept"] = strconv.FormatInt(department.ID, 10)
  25639. data["config"] = config
  25640. bytesData, _ := json.Marshal(data)
  25641. var req *http.Request
  25642. if miConfig.MdtrtareaAdmvs == "320921" {
  25643. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25644. //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 +
  25645. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25646. } else {
  25647. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25648. }
  25649. resp, _ := client.Do(req)
  25650. defer resp.Body.Close()
  25651. body, ioErr := ioutil.ReadAll(resp.Body)
  25652. if ioErr != nil {
  25653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25655. return
  25656. }
  25657. var respJSON map[string]interface{}
  25658. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25661. return
  25662. }
  25663. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25664. userJSONBytes, _ := json.Marshal(respJSON)
  25665. fmt.Println("log")
  25666. fmt.Println(string(userJSONBytes))
  25667. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25668. utils.ErrorLog("解析失败:%v", err)
  25669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25670. return
  25671. }
  25672. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25673. res2.Output = ressix10265.Output
  25674. res2.ErrMsg = ressix10265.ErrMsg
  25675. res2.Cainfo = ressix10265.Cainfo
  25676. res2.WarnMsg = ressix10265.WarnMsg
  25677. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25678. res2.Infcode = infocode
  25679. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25680. data := make(map[string]interface{})
  25681. client := &http.Client{}
  25682. data["psn_no"] = his.PsnNo
  25683. data["mdtrt_id"] = his.Number
  25684. data["doctor"] = roles.UserName
  25685. data["department"] = department.Name
  25686. data["org_name"] = miConfig.OrgName
  25687. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25688. data["doctor_id"] = doctor_info.DoctorNumber
  25689. data["new_doctor_name"] = doctor_info.UserName
  25690. data["fixmedins_code"] = miConfig.Code
  25691. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25692. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25693. data["secret_key"] = miConfig.SecretKey
  25694. data["sick_code"] = sickConfig.CountryCode
  25695. data["sick_name"] = sickConfig.ClassName
  25696. data["url"] = miConfig.Url
  25697. data["ak"] = miConfig.AccessKey
  25698. data["begin_time"] = begin_time
  25699. data["cainfo"] = miConfig.Cainfo
  25700. data["dept"] = strconv.FormatInt(department.ID, 10)
  25701. data["config"] = config
  25702. bytesData, _ := json.Marshal(data)
  25703. var req *http.Request
  25704. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25705. resp, _ := client.Do(req)
  25706. defer resp.Body.Close()
  25707. body, ioErr := ioutil.ReadAll(resp.Body)
  25708. if ioErr != nil {
  25709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25711. return
  25712. }
  25713. var respJSON map[string]interface{}
  25714. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25717. return
  25718. }
  25719. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25720. userJSONBytes, _ := json.Marshal(respJSON)
  25721. fmt.Println("log")
  25722. fmt.Println(string(userJSONBytes))
  25723. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25724. utils.ErrorLog("解析失败:%v", err)
  25725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25726. return
  25727. }
  25728. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25729. res2.Output = ressix10265.Output
  25730. res2.ErrMsg = ressix10265.ErrMsg
  25731. res2.Cainfo = ressix10265.Cainfo
  25732. res2.WarnMsg = ressix10265.WarnMsg
  25733. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25734. res2.Infcode = infocode
  25735. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25736. 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)
  25737. saveLog(result, requestLog, "2203", "上传就诊信息")
  25738. var respJSON2 map[string]interface{}
  25739. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25742. return
  25743. }
  25744. userJSONBytes2, _ := json.Marshal(respJSON2)
  25745. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25746. utils.ErrorLog("解析失败:%v", err)
  25747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25748. return
  25749. }
  25750. 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)
  25751. fmt.Println(result2)
  25752. fmt.Println(src_request)
  25753. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25754. data := make(map[string]interface{})
  25755. client := &http.Client{}
  25756. data["psn_no"] = his.PsnNo
  25757. data["mdtrt_id"] = his.Number
  25758. data["doctor"] = roles.UserName
  25759. data["department"] = department.Name
  25760. data["org_name"] = miConfig.OrgName
  25761. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25762. data["doctor_id"] = doctor_info.DoctorNumber
  25763. data["new_doctor_name"] = doctor_info.UserName
  25764. data["fixmedins_code"] = miConfig.Code
  25765. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25766. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25767. data["secret_key"] = miConfig.SecretKey
  25768. data["sick_code"] = sickConfig.CountryCode
  25769. data["sick_name"] = sickConfig.ClassName
  25770. data["url"] = miConfig.Url
  25771. data["ak"] = miConfig.AccessKey
  25772. data["begin_time"] = begin_time
  25773. data["cainfo"] = miConfig.Cainfo
  25774. data["dept"] = strconv.FormatInt(department.ID, 10)
  25775. data["config"] = config
  25776. bytesData, _ := json.Marshal(data)
  25777. var req *http.Request
  25778. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25779. resp, _ := client.Do(req)
  25780. defer resp.Body.Close()
  25781. body, ioErr := ioutil.ReadAll(resp.Body)
  25782. if ioErr != nil {
  25783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25785. return
  25786. }
  25787. var respJSON map[string]interface{}
  25788. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25791. return
  25792. }
  25793. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25794. userJSONBytes, _ := json.Marshal(respJSON)
  25795. fmt.Println("log")
  25796. fmt.Println(string(userJSONBytes))
  25797. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25798. utils.ErrorLog("解析失败:%v", err)
  25799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25800. return
  25801. }
  25802. } else {
  25803. if miConfig.MdtrtareaAdmvs == "440781" { //
  25804. 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)
  25805. } else {
  25806. if miConfig.Code == "H15049901371" {
  25807. //赤峰地区国家医保医疗类别
  25808. //职工透析:医疗类别选特殊情况门诊990502
  25809. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25810. var med_type string
  25811. if his.Insutype == "390" {
  25812. if reg_type == 14 {
  25813. med_type = "9933"
  25814. } else if reg_type == 11 {
  25815. med_type = "11"
  25816. }
  25817. } else if his.Insutype == "310" {
  25818. if reg_type == 14 {
  25819. med_type = "990502"
  25820. } else if reg_type == 11 {
  25821. med_type = "11"
  25822. }
  25823. }
  25824. 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)
  25825. } else {
  25826. 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)
  25827. }
  25828. }
  25829. saveLog(result, requestLog, "2203", "上传就诊信息")
  25830. var respJSON2 map[string]interface{}
  25831. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25834. return
  25835. }
  25836. userJSONBytes2, _ := json.Marshal(respJSON2)
  25837. if miConfig.Code == "H15049901371" {
  25838. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25839. utils.ErrorLog("解析失败:%v", err)
  25840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25841. return
  25842. }
  25843. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25844. res2.Output = ressix10265.Output
  25845. res2.ErrMsg = ressix10265.ErrMsg
  25846. res2.Cainfo = ressix10265.Cainfo
  25847. res2.WarnMsg = ressix10265.WarnMsg
  25848. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25849. res2.Infcode = infocode
  25850. } else {
  25851. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25852. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25853. utils.ErrorLog("解析失败:%v", err)
  25854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25855. return
  25856. }
  25857. res2.Infcode = res3.Infcode
  25858. } else {
  25859. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25860. utils.ErrorLog("解析失败:%v", err)
  25861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25862. return
  25863. }
  25864. }
  25865. }
  25866. }
  25867. if res2.Infcode == -1 {
  25868. adminUser := c.GetAdminUserInfo()
  25869. errlog := &models.HisOrderError{
  25870. UserOrgId: adminUser.CurrentOrgId,
  25871. Ctime: time.Now().Unix(),
  25872. Mtime: time.Now().Unix(),
  25873. ErrMsg: res2.ErrMsg,
  25874. Status: 1,
  25875. PatientId: id,
  25876. RecordTime: recordDateTime,
  25877. Stage: 3,
  25878. }
  25879. service.CreateErrMsgLog(errlog)
  25880. c.ServeSuccessJSON(map[string]interface{}{
  25881. "failed_code": -10,
  25882. "msg": res2.ErrMsg,
  25883. })
  25884. return
  25885. } else {
  25886. his.Diagnosis = diagnosis_id
  25887. his.SickType = sickConfig.ID
  25888. //var p_type int64
  25889. //if reg_type == 1111 || reg_type == 1112 {
  25890. // p_type = 11
  25891. //
  25892. //}
  25893. his.PType = fmt.Sprintf("%d", reg_type)
  25894. service.UpdateHisPatientThree(&his)
  25895. data := make(map[string]interface{})
  25896. if settle_accounts_type == 1 { //日结
  25897. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25898. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25899. } else {
  25900. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25901. }
  25902. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25903. data["pre"] = prescriptions
  25904. } else { //月结
  25905. start_time_str := c.GetString("start_time")
  25906. end_time_str := c.GetString("end_time")
  25907. timeLayout := "2006-01-02"
  25908. loc, _ := time.LoadLocation("Local")
  25909. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25910. if err != nil {
  25911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25912. return
  25913. }
  25914. recordStartTime := theStartTime.Unix()
  25915. start_time = recordStartTime
  25916. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25917. if err != nil {
  25918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25919. return
  25920. }
  25921. recordEndTime := theEndTime.Unix()
  25922. end_time = recordEndTime
  25923. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25924. data["pre"] = prescriptions
  25925. }
  25926. timestamp := time.Now().Unix()
  25927. tempTime := time.Unix(timestamp, 0)
  25928. timeFormat := tempTime.Format("20060102150405")
  25929. chrgBchno := rand.Intn(100000) + 10000
  25930. new_chrg_bchno := ""
  25931. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25932. new_chrg_bchno = chrg_bchno
  25933. strconv.FormatInt(his.PatientId, 10)
  25934. client := &http.Client{}
  25935. if adminUser.CurrentOrgId == 10265 {
  25936. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25937. new_chrg_bchno = "0000"
  25938. }
  25939. }
  25940. data["psn_no"] = his.PsnNo
  25941. data["mdtrt_id"] = his.Number
  25942. data["chrg_bchno"] = new_chrg_bchno
  25943. data["org_name"] = miConfig.OrgName
  25944. data["doctor"] = doctor_info.UserName
  25945. data["doctor_id"] = doctor_info.DoctorNumber
  25946. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25947. data["fixmedins_code"] = miConfig.Code
  25948. data["dept_code"] = department.Number
  25949. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25950. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25951. data["secret_key"] = miConfig.SecretKey
  25952. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25953. data["url"] = miConfig.Url
  25954. data["ak"] = miConfig.AccessKey
  25955. data["new_doctor_name"] = patientPrescription.Doctor
  25956. data["diag_code"] = sickConfig.CountryCode
  25957. data["cainfo"] = miConfig.Cainfo
  25958. data["opter"] = roles.UserName
  25959. var ids []int64
  25960. for _, item := range prescriptions {
  25961. ids = append(ids, item.ID)
  25962. }
  25963. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25964. if config.IsOpen == 1 { //对接了医保,走医保流程
  25965. var res ResultFour
  25966. var resFour10265 ResultFour10265
  25967. if miConfig.MdtrtareaAdmvs == "421300" {
  25968. bytesData, _ := json.Marshal(data)
  25969. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25970. resp, _ := client.Do(req)
  25971. defer resp.Body.Close()
  25972. body, ioErr := ioutil.ReadAll(resp.Body)
  25973. if ioErr != nil {
  25974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25976. return
  25977. }
  25978. var respJSON map[string]interface{}
  25979. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25982. return
  25983. }
  25984. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25985. userJSONBytes, _ := json.Marshal(respJSON)
  25986. fmt.Println("log")
  25987. fmt.Println(string(userJSONBytes))
  25988. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25989. utils.ErrorLog("解析失败:%v", err)
  25990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25991. return
  25992. }
  25993. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25994. bytesData, _ := json.Marshal(data)
  25995. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25996. resp, _ := client.Do(req)
  25997. defer resp.Body.Close()
  25998. body, ioErr := ioutil.ReadAll(resp.Body)
  25999. if ioErr != nil {
  26000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26002. return
  26003. }
  26004. var respJSON map[string]interface{}
  26005. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26008. return
  26009. }
  26010. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26011. userJSONBytes, _ := json.Marshal(respJSON)
  26012. fmt.Println("log")
  26013. fmt.Println(string(userJSONBytes))
  26014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26015. utils.ErrorLog("解析失败:%v", err)
  26016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26017. return
  26018. }
  26019. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26020. bytesData, _ := json.Marshal(data)
  26021. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26022. resp, _ := client.Do(req)
  26023. defer resp.Body.Close()
  26024. body, ioErr := ioutil.ReadAll(resp.Body)
  26025. if ioErr != nil {
  26026. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26028. return
  26029. }
  26030. var respJSON map[string]interface{}
  26031. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26034. return
  26035. }
  26036. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26037. userJSONBytes, _ := json.Marshal(respJSON)
  26038. fmt.Println("log")
  26039. fmt.Println(string(userJSONBytes))
  26040. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26041. utils.ErrorLog("解析失败:%v", err)
  26042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26043. return
  26044. }
  26045. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26046. bytesData, _ := json.Marshal(data)
  26047. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26048. resp, _ := client.Do(req)
  26049. defer resp.Body.Close()
  26050. body, ioErr := ioutil.ReadAll(resp.Body)
  26051. if ioErr != nil {
  26052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26054. return
  26055. }
  26056. var respJSON map[string]interface{}
  26057. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26060. return
  26061. }
  26062. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26063. userJSONBytes, _ := json.Marshal(respJSON)
  26064. fmt.Println("log")
  26065. fmt.Println(string(userJSONBytes))
  26066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26067. utils.ErrorLog("解析失败:%v", err)
  26068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26069. return
  26070. }
  26071. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26072. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26073. if result3101.Infcode == "0" {
  26074. if len(result3101.Output.Result) > 0 {
  26075. var errMsgs []string
  26076. for _, item := range result3101.Output.Result {
  26077. errMsgs = append(errMsgs, item.VolaCont)
  26078. }
  26079. c.ServeSuccessJSON(map[string]interface{}{
  26080. "failed_code": -10,
  26081. "msg": errMsgs,
  26082. })
  26083. return
  26084. }
  26085. }
  26086. bytesData, _ := json.Marshal(data)
  26087. var req *http.Request
  26088. if miConfig.MdtrtareaAdmvs == "320921" {
  26089. data["diag_code"] = sickConfig.CountryCode
  26090. fmt.Println(data)
  26091. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26092. } else {
  26093. data["diag_code"] = sickConfig.CountryCode
  26094. fmt.Println(data)
  26095. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26096. }
  26097. resp, _ := client.Do(req)
  26098. defer resp.Body.Close()
  26099. body, ioErr := ioutil.ReadAll(resp.Body)
  26100. if ioErr != nil {
  26101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26103. return
  26104. }
  26105. var respJSON map[string]interface{}
  26106. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26109. return
  26110. }
  26111. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26112. userJSONBytes, _ := json.Marshal(respJSON)
  26113. fmt.Println("log")
  26114. fmt.Println(string(userJSONBytes))
  26115. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26116. utils.ErrorLog("解析失败:%v", err)
  26117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26118. return
  26119. }
  26120. res.InfRefmsgid = resFour10265.InfRefmsgid
  26121. res.Output = resFour10265.Output
  26122. res.ErrMsg = resFour10265.ErrMsg
  26123. res.Cainfo = resFour10265.Cainfo
  26124. res.WarnMsg = resFour10265.WarnMsg
  26125. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26126. res.Infcode = infocode
  26127. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26128. var pagesize int = 2
  26129. var start int = 1
  26130. var stop int
  26131. var pagecount int
  26132. var curpage int
  26133. var isSuccess bool = true
  26134. data["doctor_id"] = doctor_info.DoctorNumber
  26135. //总页数,向上取整,注意除之前要先转换类型为float64
  26136. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  26137. for curpage = 1; curpage <= pagecount; curpage++ {
  26138. if curpage == 1 {
  26139. start = 1
  26140. } else {
  26141. start = (curpage-1)*pagesize + 1
  26142. }
  26143. stop = curpage * pagesize
  26144. if stop > len(prescriptions) {
  26145. stop = len(prescriptions)
  26146. }
  26147. //var requestLog string
  26148. data["pre"] = prescriptions[start-1 : stop]
  26149. fmt.Println(data["pre"])
  26150. bytesData, _ := json.Marshal(data)
  26151. var req *http.Request
  26152. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  26153. resp, _ := client.Do(req)
  26154. defer resp.Body.Close()
  26155. body, ioErr := ioutil.ReadAll(resp.Body)
  26156. if ioErr != nil {
  26157. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26159. return
  26160. }
  26161. var respJSON map[string]interface{}
  26162. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26165. return
  26166. }
  26167. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26168. userJSONBytes, _ := json.Marshal(respJSON)
  26169. fmt.Println("log")
  26170. fmt.Println(string(userJSONBytes))
  26171. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26172. utils.ErrorLog("解析失败:%v", err)
  26173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26174. return
  26175. }
  26176. res.InfRefmsgid = resFour10265.InfRefmsgid
  26177. res.Output = resFour10265.Output
  26178. res.ErrMsg = resFour10265.ErrMsg
  26179. res.Cainfo = resFour10265.Cainfo
  26180. res.WarnMsg = resFour10265.WarnMsg
  26181. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26182. res.Infcode = infocode
  26183. if infocode == 0 {
  26184. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  26185. } else {
  26186. isSuccess = false
  26187. errlog := &models.HisOrderError{
  26188. UserOrgId: adminUser.CurrentOrgId,
  26189. Ctime: time.Now().Unix(),
  26190. Mtime: time.Now().Unix(),
  26191. Number: chrg_bchno,
  26192. ErrMsg: "",
  26193. Status: 1,
  26194. PatientId: id,
  26195. RecordTime: recordDateTime,
  26196. Stage: 4,
  26197. }
  26198. service.CreateErrMsgLog(errlog)
  26199. c.ServeSuccessJSON(map[string]interface{}{
  26200. "failed_code": -10,
  26201. "msg": res.ErrMsg,
  26202. })
  26203. return
  26204. }
  26205. }
  26206. if isSuccess {
  26207. res.Infcode = 0
  26208. }
  26209. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26210. 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)
  26211. var dat map[string]interface{}
  26212. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26213. fmt.Println(dat)
  26214. } else {
  26215. fmt.Println(err)
  26216. }
  26217. saveLog(result, request_log, "2204", "上传费用明细")
  26218. userJSONBytes, _ := json.Marshal(dat)
  26219. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26220. utils.ErrorLog("解析失败:%v", err)
  26221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26222. return
  26223. }
  26224. res.InfRefmsgid = resFour10265.InfRefmsgid
  26225. res.Output = resFour10265.Output
  26226. res.ErrMsg = resFour10265.ErrMsg
  26227. res.Cainfo = resFour10265.Cainfo
  26228. res.WarnMsg = resFour10265.WarnMsg
  26229. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26230. res.Infcode = infocode
  26231. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26232. bytesData, _ := json.Marshal(data)
  26233. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  26234. resp, _ := client.Do(req)
  26235. defer resp.Body.Close()
  26236. body, ioErr := ioutil.ReadAll(resp.Body)
  26237. if ioErr != nil {
  26238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26240. return
  26241. }
  26242. var respJSON map[string]interface{}
  26243. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26246. return
  26247. }
  26248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26249. userJSONBytes, _ := json.Marshal(respJSON)
  26250. fmt.Println("log")
  26251. fmt.Println(string(userJSONBytes))
  26252. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26253. utils.ErrorLog("解析失败:%v", err)
  26254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26255. return
  26256. }
  26257. } else {
  26258. if miConfig.Code == "H15049901371" {
  26259. 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)
  26260. var dat map[string]interface{}
  26261. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26262. fmt.Println(dat)
  26263. } else {
  26264. fmt.Println(err)
  26265. }
  26266. saveLog(result, request_log, "2204", "上传费用明细")
  26267. userJSONBytes, _ := json.Marshal(dat)
  26268. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26269. utils.ErrorLog("解析失败:%v", err)
  26270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26271. return
  26272. }
  26273. res.InfRefmsgid = resFour10265.InfRefmsgid
  26274. res.Output = resFour10265.Output
  26275. res.ErrMsg = resFour10265.ErrMsg
  26276. res.Cainfo = resFour10265.Cainfo
  26277. res.WarnMsg = resFour10265.WarnMsg
  26278. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26279. res.Infcode = infocode
  26280. } else {
  26281. 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)
  26282. var dat map[string]interface{}
  26283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26284. fmt.Println(dat)
  26285. } else {
  26286. fmt.Println(err)
  26287. }
  26288. saveLog(result, request_log, "2204", "上传费用明细")
  26289. userJSONBytes, _ := json.Marshal(dat)
  26290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26291. utils.ErrorLog("解析失败:%v", err)
  26292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26293. return
  26294. }
  26295. }
  26296. }
  26297. if res.Infcode == 0 {
  26298. order := &models.HisOrder{
  26299. UserOrgId: adminUser.CurrentOrgId,
  26300. HisPatientId: his.ID,
  26301. PatientId: his.PatientId,
  26302. SettleAccountsDate: recordDateTime,
  26303. MdtrtId: his.Number,
  26304. PsnNo: his.PsnNo,
  26305. MedType: strconv.FormatInt(reg_type, 10),
  26306. Ctime: time.Now().Unix(),
  26307. Mtime: time.Now().Unix(),
  26308. Status: 1,
  26309. Number: chrg_bchno,
  26310. Infcode: res.Infcode,
  26311. WarnMsg: res.WarnMsg,
  26312. Cainfo: res.Cainfo,
  26313. ErrMsg: res.ErrMsg,
  26314. RespondTime: res.RefmsgTime,
  26315. InfRefmsgid: res.InfRefmsgid,
  26316. OrderStatus: 1,
  26317. PayWay: pay_way,
  26318. PayWays: pay_ways,
  26319. OthDesc: oth_desc,
  26320. PayPrice: pay_price,
  26321. PayCardNo: pay_card_no,
  26322. DiscountPrice: discount_price,
  26323. PreferentialPrice: preferential_price,
  26324. RealityPrice: reality_price,
  26325. FoundPrice: found_price,
  26326. MedicalInsurancePrice: medical_insurance_price,
  26327. PrivatePrice: private_price,
  26328. IsMedicineInsurance: 1,
  26329. SettleType: settle_accounts_type,
  26330. SettleStartTime: start_time,
  26331. SettleEndTime: end_time,
  26332. Creator: roles.AdminUserId,
  26333. Modify: roles.AdminUserId,
  26334. FaPiaoNumber: fapiao_number,
  26335. FaPiaoCode: fapiao_code,
  26336. PType: 2,
  26337. Diagnosis: diagnosis_id,
  26338. CashPay: cash_pay,
  26339. WechatPay: wechat_pay,
  26340. AliPay: ali_pay,
  26341. JifenPay: jifen_pay,
  26342. BandCardPay: band_card_pay,
  26343. }
  26344. err = service.CreateOrder(order)
  26345. if err != nil {
  26346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  26347. return
  26348. }
  26349. for _, item := range res.Output.Result {
  26350. temp := strings.Split(item.FeedetlSn, "-")
  26351. var advice_id int64 = 0
  26352. var project_id int64 = 0
  26353. var types int64 = 0
  26354. id, _ := strconv.ParseInt(temp[2], 10, 64)
  26355. types, _ = strconv.ParseInt(temp[1], 10, 64)
  26356. if temp[1] == "1" {
  26357. advice_id = id
  26358. project_id = 0
  26359. } else if temp[1] == "2" {
  26360. advice_id = 0
  26361. project_id = id
  26362. }
  26363. if item.MedChrgitmType == "9" {
  26364. item.MedChrgitmType = "09"
  26365. }
  26366. info := &models.HisOrderInfo{
  26367. OrderNumber: order.Number,
  26368. FeedetlSn: item.FeedetlSn,
  26369. UploadDate: time.Now().Unix(),
  26370. AdviceId: advice_id,
  26371. DetItemFeeSumamt: item.DetItemFeeSumamt,
  26372. Cnt: item.Cnt,
  26373. Pric: float64(item.Pric),
  26374. PatientId: his.PatientId,
  26375. PricUplmtAmt: item.PricUplmtAmt,
  26376. SelfpayProp: item.SelfpayProp,
  26377. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  26378. OverlmtAmt: item.OverlmtAmt,
  26379. PreselfpayAmt: item.PreselfpayAmt,
  26380. BasMednFlag: item.BasMednFlag,
  26381. MedChrgitmType: item.MedChrgitmType,
  26382. HiNegoDrugFlag: item.HiNegoDrugFlag,
  26383. Status: 1,
  26384. Memo: item.Memo,
  26385. Mtime: time.Now().Unix(),
  26386. InscpScpAmt: item.InscpScpAmt,
  26387. DrtReimFlag: item.DrtReimFlag,
  26388. Ctime: time.Now().Unix(),
  26389. ListSpItemFlag: item.ListSpItemFlag,
  26390. ChldMedcFlag: item.ChldMedcFlag,
  26391. LmtUsedFlag: item.LmtUsedFlag,
  26392. ChrgitmLv: item.ChrgitmLv,
  26393. UserOrgId: adminUser.CurrentOrgId,
  26394. HisPatientId: his.ID,
  26395. OrderId: order.ID,
  26396. ProjectId: project_id,
  26397. Type: types,
  26398. }
  26399. service.CreateOrderInfo(info)
  26400. }
  26401. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  26402. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  26403. var total float64
  26404. for _, item := range prescriptions {
  26405. if item.Type == 1 { //药品
  26406. for _, subItem := range item.HisDoctorAdviceInfo {
  26407. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26408. total_one := price * subItem.PrescribingNumber
  26409. total = total + total_one
  26410. }
  26411. }
  26412. if item.Type == 2 { //项目
  26413. for _, subItem := range item.HisPrescriptionProject {
  26414. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  26415. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26416. total_one := price * cnt
  26417. total = total + total_one
  26418. }
  26419. }
  26420. }
  26421. allTotal := fmt.Sprintf("%.2f", total)
  26422. //if adminUser.CurrentOrgId == 9919 {
  26423. //
  26424. // allTotal = fmt.Sprintf("%.2f", total)
  26425. //
  26426. //} else {
  26427. //
  26428. // allTotal = fmt.Sprintf("%.2f", total)
  26429. //
  26430. //}
  26431. if res.Infcode == 0 {
  26432. var rf []*ResultFive
  26433. json.Unmarshal([]byte(his.Iinfo), &rf)
  26434. chrg_bchno := chrg_bchno
  26435. cert_no := his.Certno
  26436. var insutypes []string
  26437. var insutype string
  26438. var is390 int = 0
  26439. var is310 int = 0
  26440. for _, item := range rf {
  26441. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26442. insutypes = append(insutypes, item.Insutype)
  26443. }
  26444. }
  26445. if len(insutypes) == 1 {
  26446. insutype = insutypes[0]
  26447. } else {
  26448. for _, i := range insutypes {
  26449. if i == "390" {
  26450. is390 = 1
  26451. }
  26452. if i == "310" {
  26453. is310 = 1
  26454. }
  26455. }
  26456. }
  26457. if is390 == 1 {
  26458. insutype = "390"
  26459. }
  26460. if is310 == 1 {
  26461. insutype = "310"
  26462. }
  26463. if len(insutypes) == 0 {
  26464. insutype = "310"
  26465. }
  26466. if len(insutypes) == 2 {
  26467. insutype = strconv.FormatInt(his.SocialType, 10)
  26468. }
  26469. insutype = strconv.FormatInt(his.SocialType, 10)
  26470. //insutype = "390"
  26471. if his.IdCardType == 1 {
  26472. // cert_no = his.MedicalInsuranceNumber
  26473. cert_no = his.Certno
  26474. } else {
  26475. cert_no = his.Certno
  26476. }
  26477. var res ResultSeven
  26478. var resSeven10265 ResultSeven10265
  26479. var gzresSeven10265Two GZResultSeven10265Two
  26480. var src_resquest string
  26481. var result2 string
  26482. if miConfig.MdtrtareaAdmvs == "421300" {
  26483. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26484. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26485. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26486. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26487. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26488. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26489. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26490. resp, requestErr := http.Get(api)
  26491. if requestErr != nil {
  26492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26493. return
  26494. }
  26495. body, ioErr := ioutil.ReadAll(resp.Body)
  26496. if ioErr != nil {
  26497. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26499. return
  26500. }
  26501. var respJSON map[string]interface{}
  26502. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26505. return
  26506. }
  26507. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26508. result, _ := json.Marshal(respJSON)
  26509. if miConfig.Code == "H15049901371" {
  26510. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26511. utils.ErrorLog("解析失败:%v", err)
  26512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26513. return
  26514. }
  26515. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26516. res.Output = resSeven10265.Output
  26517. res.ErrMsg = resSeven10265.ErrMsg
  26518. res.Cainfo = resSeven10265.Cainfo
  26519. res.WarnMsg = resSeven10265.WarnMsg
  26520. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26521. res.Infcode = infocode
  26522. } else {
  26523. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26524. utils.ErrorLog("解析失败:%v", err)
  26525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26526. return
  26527. }
  26528. }
  26529. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26530. if reg_type == 11 && his.Insutype == "390" {
  26531. reg_type = 110104
  26532. }
  26533. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26534. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26535. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26536. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26537. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26538. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26539. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26540. resp, requestErr := http.Get(api)
  26541. if requestErr != nil {
  26542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26543. return
  26544. }
  26545. body, ioErr := ioutil.ReadAll(resp.Body)
  26546. if ioErr != nil {
  26547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26549. return
  26550. }
  26551. var respJSON map[string]interface{}
  26552. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26555. return
  26556. }
  26557. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26558. result, _ := json.Marshal(respJSON)
  26559. if miConfig.Code == "H15049901371" {
  26560. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26561. utils.ErrorLog("解析失败:%v", err)
  26562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26563. return
  26564. }
  26565. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26566. res.Output = resSeven10265.Output
  26567. res.ErrMsg = resSeven10265.ErrMsg
  26568. res.Cainfo = resSeven10265.Cainfo
  26569. res.WarnMsg = resSeven10265.WarnMsg
  26570. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26571. res.Infcode = infocode
  26572. } else {
  26573. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26574. utils.ErrorLog("解析失败:%v", err)
  26575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26576. return
  26577. }
  26578. }
  26579. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26580. if reg_type == 11 && his.Insutype == "390" {
  26581. reg_type = 110104
  26582. }
  26583. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26584. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26585. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26586. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26587. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26588. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26589. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26590. resp, requestErr := http.Get(api)
  26591. if requestErr != nil {
  26592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26593. return
  26594. }
  26595. body, ioErr := ioutil.ReadAll(resp.Body)
  26596. if ioErr != nil {
  26597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26599. return
  26600. }
  26601. var respJSON map[string]interface{}
  26602. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26605. return
  26606. }
  26607. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26608. result, _ := json.Marshal(respJSON)
  26609. if miConfig.Code == "H15049901371" {
  26610. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26611. utils.ErrorLog("解析失败:%v", err)
  26612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26613. return
  26614. }
  26615. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26616. res.Output = resSeven10265.Output
  26617. res.ErrMsg = resSeven10265.ErrMsg
  26618. res.Cainfo = resSeven10265.Cainfo
  26619. res.WarnMsg = resSeven10265.WarnMsg
  26620. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26621. res.Infcode = infocode
  26622. } else {
  26623. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26624. utils.ErrorLog("解析失败:%v", err)
  26625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26626. return
  26627. }
  26628. }
  26629. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26630. if reg_type == 11 && his.Insutype == "390" {
  26631. reg_type = 110104
  26632. }
  26633. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26634. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26635. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26636. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26637. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26638. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26639. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26640. resp, requestErr := http.Get(api)
  26641. if requestErr != nil {
  26642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26643. return
  26644. }
  26645. body, ioErr := ioutil.ReadAll(resp.Body)
  26646. if ioErr != nil {
  26647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26649. return
  26650. }
  26651. var respJSON map[string]interface{}
  26652. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26655. return
  26656. }
  26657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26658. result, _ := json.Marshal(respJSON)
  26659. if miConfig.Code == "H15049901371" {
  26660. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26661. utils.ErrorLog("解析失败:%v", err)
  26662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26663. return
  26664. }
  26665. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26666. res.Output = resSeven10265.Output
  26667. res.ErrMsg = resSeven10265.ErrMsg
  26668. res.Cainfo = resSeven10265.Cainfo
  26669. res.WarnMsg = resSeven10265.WarnMsg
  26670. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26671. res.Infcode = infocode
  26672. } else {
  26673. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26674. utils.ErrorLog("解析失败:%v", err)
  26675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26676. return
  26677. }
  26678. }
  26679. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26680. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26681. if result3101.Infcode == "0" {
  26682. if len(result3101.Output.Result) > 0 {
  26683. var errMsgs []string
  26684. for _, item := range result3101.Output.Result {
  26685. errMsgs = append(errMsgs, item.VolaCont)
  26686. }
  26687. c.ServeSuccessJSON(map[string]interface{}{
  26688. "failed_code": -10,
  26689. "msg": errMsgs,
  26690. })
  26691. return
  26692. } else {
  26693. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26694. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26695. bas := strings.Split(psn_info.CardInfo, "|")
  26696. if his.IdCardType == 1 {
  26697. cert_no = bas[2]
  26698. } else if his.IdCardType == 3 {
  26699. cert_no = his.Certno
  26700. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26701. } else if his.IdCardType == 4 {
  26702. cert_no = his.Certno
  26703. psn_info.VerifyNumber = psn_info.VerifyNumber
  26704. }
  26705. var api string
  26706. if miConfig.MdtrtareaAdmvs == "320921" {
  26707. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26708. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26709. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26710. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26711. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26712. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26713. "&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
  26714. } else {
  26715. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26716. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26717. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26718. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26719. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26720. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26721. "&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
  26722. }
  26723. resp, requestErr := http.Get(api)
  26724. if requestErr != nil {
  26725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26726. return
  26727. }
  26728. body, ioErr := ioutil.ReadAll(resp.Body)
  26729. if ioErr != nil {
  26730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26732. return
  26733. }
  26734. var respJSON map[string]interface{}
  26735. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26738. return
  26739. }
  26740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26741. result, _ := json.Marshal(respJSON)
  26742. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26743. utils.ErrorLog("解析失败:%v", err)
  26744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26745. return
  26746. }
  26747. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26748. res.Output = resSeven10265.Output
  26749. res.ErrMsg = resSeven10265.ErrMsg
  26750. res.Cainfo = resSeven10265.Cainfo
  26751. res.WarnMsg = resSeven10265.WarnMsg
  26752. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26753. res.Infcode = infocode
  26754. }
  26755. }
  26756. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26757. psn_info, _ := service.GetPsnByPatientId(id)
  26758. var verify_number string
  26759. if psn_info.IdCardType == 4 {
  26760. verify_number = psn_info.VerifyNumber
  26761. } else if psn_info.IdCardType == 1 {
  26762. bas := strings.Split(psn_info.CardInfo, "|")
  26763. cardNumber := bas[2]
  26764. verify_number = cardNumber
  26765. } else {
  26766. psn_info.IdCardType = 2
  26767. verify_number = psn_info.Certno
  26768. }
  26769. var api string
  26770. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26771. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26772. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26773. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26774. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26775. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26776. "&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
  26777. resp, requestErr := http.Get(api)
  26778. if requestErr != nil {
  26779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26780. return
  26781. }
  26782. body, ioErr := ioutil.ReadAll(resp.Body)
  26783. if ioErr != nil {
  26784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26786. return
  26787. }
  26788. var respJSON map[string]interface{}
  26789. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26792. return
  26793. }
  26794. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26795. result, _ := json.Marshal(respJSON)
  26796. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26797. utils.ErrorLog("解析失败:%v", err)
  26798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26799. return
  26800. }
  26801. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26802. res.Output = resSeven10265.Output
  26803. res.ErrMsg = resSeven10265.ErrMsg
  26804. res.Cainfo = resSeven10265.Cainfo
  26805. res.WarnMsg = resSeven10265.WarnMsg
  26806. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26807. res.Infcode = infocode
  26808. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26809. var cert_no string
  26810. if his.IdCardType == 4 {
  26811. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26812. cert_no = psn_info.VerifyNumber
  26813. 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)
  26814. } else if his.IdCardType == 1 {
  26815. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26816. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26817. 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)
  26818. }
  26819. //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)
  26820. var dat map[string]interface{}
  26821. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26822. fmt.Println(dat)
  26823. } else {
  26824. fmt.Println(err)
  26825. }
  26826. saveLog(result2, src_resquest, "2207", "结算")
  26827. userJSONBytes, _ := json.Marshal(dat)
  26828. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26829. utils.ErrorLog("解析失败:%v", err)
  26830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26831. return
  26832. }
  26833. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26834. res.Output = resSeven10265.Output
  26835. res.ErrMsg = resSeven10265.ErrMsg
  26836. res.Cainfo = resSeven10265.Cainfo
  26837. res.WarnMsg = resSeven10265.WarnMsg
  26838. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26839. res.Infcode = infocode
  26840. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26841. res2 := c.GetoleInfo()
  26842. if res2.Infcode == 0 {
  26843. var result string
  26844. var request_log string
  26845. var result_log string
  26846. if res2.Output.MdtrtCertType == "02" {
  26847. 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)
  26848. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26849. } else if res2.Output.MdtrtCertType == "01" {
  26850. 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)
  26851. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26852. } else {
  26853. 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)
  26854. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26855. }
  26856. var dat map[string]interface{}
  26857. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26858. fmt.Println(dat)
  26859. } else {
  26860. fmt.Println(err)
  26861. }
  26862. userJSONBytes, _ := json.Marshal(dat)
  26863. var res5 ResultTwo
  26864. //var resTwo10265 ResultTwo10265
  26865. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26866. utils.ErrorLog("解析失败:%v", err)
  26867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26868. return
  26869. }
  26870. if res5.Infcode == -1 {
  26871. c.ServeSuccessJSON(map[string]interface{}{
  26872. "failed_code": -10,
  26873. "msg": res5.ErrMsg,
  26874. })
  26875. return
  26876. }
  26877. var insutypes []string
  26878. var insutype string
  26879. var is390 int = 0
  26880. var is310 int = 0
  26881. for _, item := range res5.Output.Iinfo {
  26882. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26883. insutypes = append(insutypes, item.Insutype)
  26884. }
  26885. }
  26886. if len(insutypes) == 1 {
  26887. insutype = insutypes[0]
  26888. } else {
  26889. for _, i := range insutypes {
  26890. if i == "390" {
  26891. is390 = 1
  26892. }
  26893. if i == "310" {
  26894. is310 = 1
  26895. }
  26896. }
  26897. }
  26898. if is390 == 1 {
  26899. insutype = "390"
  26900. }
  26901. if is310 == 1 {
  26902. insutype = "310"
  26903. }
  26904. if len(insutypes) == 0 {
  26905. insutype = "310"
  26906. }
  26907. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26908. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26909. infoStr := string(Iinfos)
  26910. idetinfoStr := string(Idetinfos)
  26911. psn := &models.HisPsn{
  26912. PsnNo: res5.Output.Baseinfo.PsnNo,
  26913. PatientId: id,
  26914. Certno: res5.Output.Baseinfo.Certno,
  26915. Gend: res5.Output.Baseinfo.Gend,
  26916. Naty: res5.Output.Baseinfo.Naty,
  26917. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26918. PsnName: res5.Output.Baseinfo.PsnName,
  26919. Idetinfo: idetinfoStr,
  26920. Insuinfo: infoStr,
  26921. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26922. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26923. VerifyNumber: res2.Output.EcToken,
  26924. }
  26925. if res2.Output.MdtrtCertType == "01" {
  26926. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26927. psn.VerifyNumber = res2.Output.EcToken
  26928. } else if res2.Output.MdtrtCertType == "02" {
  26929. psn.VerifyNumber = res2.Output.CardNo
  26930. } else {
  26931. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26932. }
  26933. service.CreateHisPsn(psn)
  26934. if res2.Output.MdtrtCertType == "01" {
  26935. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26936. token := res2.Output.EcToken
  26937. 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)
  26938. } else if res2.Output.MdtrtCertType == "02" {
  26939. 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)
  26940. } else {
  26941. 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)
  26942. }
  26943. var dat2 map[string]interface{}
  26944. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26945. fmt.Println(dat2)
  26946. } else {
  26947. fmt.Println(err)
  26948. }
  26949. userJSONBytes3, _ := json.Marshal(dat2)
  26950. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26951. utils.ErrorLog("解析失败:%v", err)
  26952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26953. return
  26954. }
  26955. saveLog(result2, src_resquest, "2207", "结算")
  26956. } else {
  26957. c.ServeSuccessJSON(map[string]interface{}{
  26958. "failed_code": -10,
  26959. "msg": res2.ErrMsg,
  26960. })
  26961. return
  26962. }
  26963. } else {
  26964. if miConfig.Code == "H15049901371" {
  26965. //赤峰地区国家医保医疗类别
  26966. //职工透析:医疗类别选特殊情况门诊990502
  26967. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26968. var med_type string
  26969. if his.Insutype == "390" {
  26970. if reg_type == 14 {
  26971. med_type = "9933"
  26972. } else if reg_type == 11 {
  26973. med_type = "11"
  26974. }
  26975. } else if his.Insutype == "310" {
  26976. if reg_type == 14 {
  26977. med_type = "990502"
  26978. } else if reg_type == 11 {
  26979. med_type = "11"
  26980. }
  26981. }
  26982. 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)
  26983. } else {
  26984. if his.IdCardType == 4 {
  26985. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26986. var token string
  26987. token = psn_info.VerifyNumber
  26988. 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)
  26989. } else {
  26990. if his.IdCardType == 1 {
  26991. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26992. bas := strings.Split(psn_info.CardInfo, "|")
  26993. basNumber := bas[2]
  26994. cert_no = basNumber
  26995. }
  26996. 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)
  26997. }
  26998. }
  26999. //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)
  27000. var dat map[string]interface{}
  27001. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27002. fmt.Println(dat)
  27003. } else {
  27004. fmt.Println(err)
  27005. }
  27006. saveLog(result2, src_resquest, "2207", "结算")
  27007. userJSONBytes, _ := json.Marshal(dat)
  27008. if miConfig.Code == "H15049901371" {
  27009. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27010. utils.ErrorLog("解析失败:%v", err)
  27011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27012. return
  27013. }
  27014. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27015. res.Output = resSeven10265.Output
  27016. res.ErrMsg = resSeven10265.ErrMsg
  27017. res.Cainfo = resSeven10265.Cainfo
  27018. res.WarnMsg = resSeven10265.WarnMsg
  27019. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27020. res.Infcode = infocode
  27021. } else {
  27022. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27023. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27024. utils.ErrorLog("解析失败:%v", err)
  27025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27026. return
  27027. }
  27028. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27029. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27030. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27031. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27032. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27033. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27034. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27035. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27036. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27037. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27038. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27039. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27040. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27041. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27042. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27043. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27044. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27045. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27046. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27047. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27048. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27049. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27050. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27051. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27052. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27053. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27054. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27055. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27056. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27057. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27058. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27059. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27060. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27061. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27062. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27063. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27064. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27065. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27066. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27067. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27068. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27069. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27070. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27071. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27072. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27073. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27074. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27075. res.Cainfo = gzresSeven10265Two.Cainfo
  27076. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27077. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27078. //res.Infcode = infocode
  27079. } else {
  27080. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27081. utils.ErrorLog("解析失败:%v", err)
  27082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27083. return
  27084. }
  27085. }
  27086. }
  27087. }
  27088. if res.Infcode == -1 {
  27089. errlog := &models.HisOrderError{
  27090. UserOrgId: adminUser.CurrentOrgId,
  27091. Ctime: time.Now().Unix(),
  27092. Mtime: time.Now().Unix(),
  27093. Number: chrg_bchno,
  27094. ErrMsg: res.ErrMsg,
  27095. Status: 1,
  27096. PatientId: id,
  27097. RecordTime: recordDateTime,
  27098. Stage: 6,
  27099. }
  27100. service.CreateErrMsgLog(errlog)
  27101. c.ServeSuccessJSON(map[string]interface{}{
  27102. "failed_code": -10,
  27103. "msg": res.ErrMsg,
  27104. })
  27105. return
  27106. } else {
  27107. sickConfig, _ := service.FindSickById(his.SickType)
  27108. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27109. order.OrderStatus = 2
  27110. order.Status = 1
  27111. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27112. order.SetlId = res.Output.Setlinfo.SetlID
  27113. order.PsnNo = res.Output.Setlinfo.PsnNo
  27114. order.PsnName = res.Output.Setlinfo.PsnName
  27115. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27116. order.Certno = res.Output.Setlinfo.Certno
  27117. order.Gend = res.Output.Setlinfo.Gend
  27118. order.Naty = res.Output.Setlinfo.Naty
  27119. order.Age = res.Output.Setlinfo.Age
  27120. order.Insutype = res.Output.Setlinfo.Insutype
  27121. order.PsnType = res.Output.Setlinfo.PsnType
  27122. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27123. order.SetlTime = res.Output.Setlinfo.SetlTime
  27124. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27125. if res.Output.Setlinfo.MedType == "140101" {
  27126. order.MedType = "14"
  27127. } else {
  27128. if res.Output.Setlinfo.MedType == "110104" {
  27129. order.MedType = "11"
  27130. } else {
  27131. order.MedType = res.Output.Setlinfo.MedType
  27132. }
  27133. }
  27134. if reg_type == 1112 {
  27135. order.MedType = "1112"
  27136. }
  27137. if reg_type == 1111 {
  27138. order.MedType = "1111"
  27139. }
  27140. order.ClrType = res.Output.Setlinfo.ClrType
  27141. if adminUser.CurrentOrgId == 10480 {
  27142. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27143. order.ClrType = "11"
  27144. } else {
  27145. order.ClrType = "9903"
  27146. }
  27147. }
  27148. if adminUser.CurrentOrgId == 10721 {
  27149. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27150. order.ClrType = "11"
  27151. } else {
  27152. order.ClrType = "9903"
  27153. }
  27154. }
  27155. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27156. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27157. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27158. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27159. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27160. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27161. order.HifpPay = res.Output.Setlinfo.HifpPay
  27162. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27163. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27164. order.HifesPay = res.Output.Setlinfo.HifesPay
  27165. order.HifobPay = res.Output.Setlinfo.HifobPay
  27166. order.MafPay = res.Output.Setlinfo.MafPay
  27167. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27168. order.OthPay = res.Output.Setlinfo.OthPay
  27169. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27170. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27171. order.AcctPay = res.Output.Setlinfo.AcctPay
  27172. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27173. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27174. order.Balc = res.Output.Setlinfo.Balc
  27175. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27176. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27177. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27178. //order.ClrType = res.Output.Setlinfo.ClrType
  27179. order.ClrWay = res.Output.Setlinfo.ClrWay
  27180. order.Creator = order.Creator
  27181. order.Modify = roles.AdminUserId
  27182. order.RequestLog = src_resquest
  27183. order.FaPiaoNumber = fapiao_number
  27184. order.FaPiaoCode = fapiao_code
  27185. order.SickName = sickConfig.ClassName
  27186. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27187. //detailStr := string(setlDetail)
  27188. //order.SetlDetail = detailStr
  27189. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27190. err = service.UpDateOrder(order)
  27191. if err == nil {
  27192. //判断是否使用了押金
  27193. if dec_way == "true" {
  27194. tmpstring := strconv.FormatInt(order.ID, 10)
  27195. order.Decimal = decimal
  27196. service.UpDateOrder(order)
  27197. //扣押金
  27198. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27199. if errmsg != nil {
  27200. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27201. return
  27202. }
  27203. }
  27204. c.ServeSuccessJSON(map[string]interface{}{
  27205. "msg": "结算成功",
  27206. })
  27207. } else {
  27208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27209. return
  27210. }
  27211. }
  27212. } else {
  27213. adminUser := c.GetAdminUserInfo()
  27214. errlog := &models.HisOrderError{
  27215. UserOrgId: adminUser.CurrentOrgId,
  27216. Ctime: time.Now().Unix(),
  27217. Mtime: time.Now().Unix(),
  27218. ErrMsg: res.ErrMsg,
  27219. Status: 1,
  27220. PatientId: id,
  27221. RecordTime: recordDateTime,
  27222. Stage: 4,
  27223. }
  27224. service.CreateErrMsgLog(errlog)
  27225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  27226. return
  27227. }
  27228. } else {
  27229. adminUser := c.GetAdminUserInfo()
  27230. errlog := &models.HisOrderError{
  27231. UserOrgId: adminUser.CurrentOrgId,
  27232. Ctime: time.Now().Unix(),
  27233. Mtime: time.Now().Unix(),
  27234. ErrMsg: res.ErrMsg,
  27235. Status: 1,
  27236. PatientId: id,
  27237. RecordTime: recordDateTime,
  27238. Stage: 4,
  27239. }
  27240. service.CreateErrMsgLog(errlog)
  27241. c.ServeSuccessJSON(map[string]interface{}{
  27242. "failed_code": -10,
  27243. "msg": res.ErrMsg,
  27244. })
  27245. return
  27246. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  27247. //return
  27248. }
  27249. }
  27250. }
  27251. } else if tempOrder.ID > 0 {
  27252. if tempOrder.IsPre == 1 {
  27253. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  27254. var rf []*ResultFive
  27255. json.Unmarshal([]byte(his.Iinfo), &rf)
  27256. chrg_bchno := tempOrder.Number
  27257. cert_no := his.Certno
  27258. var insutypes []string
  27259. var insutype string
  27260. var is390 int = 0
  27261. var is310 int = 0
  27262. for _, item := range rf {
  27263. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27264. insutypes = append(insutypes, item.Insutype)
  27265. }
  27266. }
  27267. if len(insutypes) == 1 {
  27268. insutype = insutypes[0]
  27269. } else {
  27270. for _, i := range insutypes {
  27271. if i == "390" {
  27272. is390 = 1
  27273. }
  27274. if i == "310" {
  27275. is310 = 1
  27276. }
  27277. }
  27278. }
  27279. if is390 == 1 {
  27280. insutype = "390"
  27281. }
  27282. if is310 == 1 {
  27283. insutype = "310"
  27284. }
  27285. if len(insutypes) == 0 {
  27286. insutype = "310"
  27287. }
  27288. if len(insutypes) == 2 {
  27289. insutype = strconv.FormatInt(his.SocialType, 10)
  27290. }
  27291. //insutype = "390"
  27292. if his.IdCardType == 1 {
  27293. // cert_no = his.MedicalInsuranceNumber
  27294. cert_no = his.Certno
  27295. } else {
  27296. cert_no = his.Certno
  27297. }
  27298. var res ResultSeven
  27299. var ahres ResultSevenAH
  27300. var resSeven10265 ResultSeven10265
  27301. var gzresSeven10265Two GZResultSeven10265Two
  27302. var src_resquest string
  27303. var result2 string
  27304. if miConfig.MdtrtareaAdmvs == "450721" {
  27305. res2 := c.GetoleInfo()
  27306. if res2.Infcode == 0 {
  27307. var result string
  27308. var request_log string
  27309. var result_log string
  27310. if res2.Output.MdtrtCertType == "02" {
  27311. 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)
  27312. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27313. } else if res2.Output.MdtrtCertType == "01" {
  27314. 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)
  27315. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27316. } else {
  27317. 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)
  27318. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27319. }
  27320. var dat map[string]interface{}
  27321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27322. fmt.Println(dat)
  27323. } else {
  27324. fmt.Println(err)
  27325. }
  27326. userJSONBytes, _ := json.Marshal(dat)
  27327. var res5 ResultTwo
  27328. //var resTwo10265 ResultTwo10265
  27329. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27330. utils.ErrorLog("解析失败:%v", err)
  27331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27332. return
  27333. }
  27334. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  27335. if res5.Infcode == -1 {
  27336. c.ServeSuccessJSON(map[string]interface{}{
  27337. "failed_code": -10,
  27338. "msg": res5.ErrMsg,
  27339. })
  27340. return
  27341. }
  27342. var insutypes []string
  27343. var insutype string
  27344. var is390 int = 0
  27345. var is310 int = 0
  27346. for _, item := range res5.Output.Iinfo {
  27347. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27348. insutypes = append(insutypes, item.Insutype)
  27349. }
  27350. }
  27351. if len(insutypes) == 1 {
  27352. insutype = insutypes[0]
  27353. } else {
  27354. for _, i := range insutypes {
  27355. if i == "390" {
  27356. is390 = 1
  27357. }
  27358. if i == "310" {
  27359. is310 = 1
  27360. }
  27361. }
  27362. }
  27363. if is390 == 1 {
  27364. insutype = "390"
  27365. }
  27366. if is310 == 1 {
  27367. insutype = "310"
  27368. }
  27369. if len(insutypes) == 0 {
  27370. insutype = "310"
  27371. }
  27372. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27373. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27374. infoStr := string(Iinfos)
  27375. idetinfoStr := string(Idetinfos)
  27376. psn := &models.HisPsn{
  27377. PsnNo: res5.Output.Baseinfo.PsnNo,
  27378. PatientId: id,
  27379. Certno: res5.Output.Baseinfo.Certno,
  27380. Gend: res5.Output.Baseinfo.Gend,
  27381. Naty: res5.Output.Baseinfo.Naty,
  27382. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27383. PsnName: res5.Output.Baseinfo.PsnName,
  27384. Idetinfo: idetinfoStr,
  27385. Insuinfo: infoStr,
  27386. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27387. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27388. VerifyNumber: res2.Output.EcToken,
  27389. }
  27390. service.CreateHisPsn(psn)
  27391. if res2.Output.MdtrtCertType == "01" {
  27392. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27393. token := res2.Output.EcToken
  27394. 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)
  27395. } else if res2.Output.MdtrtCertType == "02" {
  27396. 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)
  27397. } else {
  27398. 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)
  27399. }
  27400. var dat2 map[string]interface{}
  27401. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27402. fmt.Println(dat2)
  27403. } else {
  27404. fmt.Println(err)
  27405. }
  27406. userJSONBytes3, _ := json.Marshal(dat2)
  27407. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27408. utils.ErrorLog("解析失败:%v", err)
  27409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27410. return
  27411. }
  27412. saveLog(result2, src_resquest, "2207", "结算")
  27413. } else {
  27414. c.ServeSuccessJSON(map[string]interface{}{
  27415. "failed_code": -10,
  27416. "msg": res2.ErrMsg,
  27417. })
  27418. return
  27419. }
  27420. } else if miConfig.MdtrtareaAdmvs == "421300" {
  27421. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27422. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27423. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27424. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27425. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27426. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27427. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27428. resp, requestErr := http.Get(api)
  27429. if requestErr != nil {
  27430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27431. return
  27432. }
  27433. body, ioErr := ioutil.ReadAll(resp.Body)
  27434. if ioErr != nil {
  27435. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27437. return
  27438. }
  27439. var respJSON map[string]interface{}
  27440. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27441. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27443. return
  27444. }
  27445. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27446. result, _ := json.Marshal(respJSON)
  27447. fmt.Println("log")
  27448. fmt.Println(string(result))
  27449. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27450. utils.ErrorLog("解析失败:%v", err)
  27451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27452. return
  27453. }
  27454. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27455. if reg_type == 11 && his.Insutype == "390" {
  27456. reg_type = 110104
  27457. }
  27458. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27459. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27460. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27461. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27462. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27463. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27464. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27465. resp, requestErr := http.Get(api)
  27466. if requestErr != nil {
  27467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27468. return
  27469. }
  27470. body, ioErr := ioutil.ReadAll(resp.Body)
  27471. if ioErr != nil {
  27472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27474. return
  27475. }
  27476. var respJSON map[string]interface{}
  27477. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27480. return
  27481. }
  27482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27483. result, _ := json.Marshal(respJSON)
  27484. fmt.Println("log")
  27485. fmt.Println(string(result))
  27486. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27487. utils.ErrorLog("解析失败:%v", err)
  27488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27489. return
  27490. }
  27491. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27492. if reg_type == 11 && his.Insutype == "390" {
  27493. reg_type = 110104
  27494. }
  27495. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27496. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27497. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27498. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27499. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27500. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27501. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27502. resp, requestErr := http.Get(api)
  27503. if requestErr != nil {
  27504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27505. return
  27506. }
  27507. body, ioErr := ioutil.ReadAll(resp.Body)
  27508. if ioErr != nil {
  27509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27511. return
  27512. }
  27513. var respJSON map[string]interface{}
  27514. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27517. return
  27518. }
  27519. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27520. result, _ := json.Marshal(respJSON)
  27521. fmt.Println("log")
  27522. fmt.Println(string(result))
  27523. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27524. utils.ErrorLog("解析失败:%v", err)
  27525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27526. return
  27527. }
  27528. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27529. if reg_type == 11 && his.Insutype == "390" {
  27530. reg_type = 110104
  27531. }
  27532. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27533. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27534. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27535. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27536. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27537. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27538. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27539. resp, requestErr := http.Get(api)
  27540. if requestErr != nil {
  27541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27542. return
  27543. }
  27544. body, ioErr := ioutil.ReadAll(resp.Body)
  27545. if ioErr != nil {
  27546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27548. return
  27549. }
  27550. var respJSON map[string]interface{}
  27551. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27554. return
  27555. }
  27556. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27557. result, _ := json.Marshal(respJSON)
  27558. fmt.Println("log")
  27559. fmt.Println(string(result))
  27560. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27561. utils.ErrorLog("解析失败:%v", err)
  27562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27563. return
  27564. }
  27565. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27566. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27567. if result3101.Infcode == "0" {
  27568. if len(result3101.Output.Result) > 0 {
  27569. var errMsgs []string
  27570. for _, item := range result3101.Output.Result {
  27571. errMsgs = append(errMsgs, item.VolaCont)
  27572. }
  27573. c.ServeSuccessJSON(map[string]interface{}{
  27574. "failed_code": -10,
  27575. "msg": errMsgs,
  27576. })
  27577. return
  27578. } else {
  27579. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27580. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27581. bas := strings.Split(psn_info.CardInfo, "|")
  27582. if his.IdCardType == 1 {
  27583. cert_no = bas[2]
  27584. } else if his.IdCardType == 3 {
  27585. cert_no = his.Certno
  27586. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27587. } else if his.IdCardType == 4 {
  27588. cert_no = his.Certno
  27589. psn_info.VerifyNumber = psn_info.VerifyNumber
  27590. }
  27591. //江苏地区国家医保医疗类别
  27592. //职工透析:医疗类别选特殊情况门诊9933
  27593. //居民血透门慢: 医疗类别选门诊慢病1402
  27594. //var med_type string
  27595. //if his.Insutype == "310" {
  27596. // if reg_type == 14 {
  27597. // med_type = "9933"
  27598. // } else if reg_type == 11 {
  27599. // med_type = "11"
  27600. //
  27601. // }
  27602. //} else if his.Insutype == "390" {
  27603. // if reg_type == 14 {
  27604. // med_type = "1402"
  27605. // } else if reg_type == 11 {
  27606. // med_type = "11"
  27607. // }
  27608. //}
  27609. var api string
  27610. if miConfig.MdtrtareaAdmvs == "320921" {
  27611. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27612. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27613. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27614. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27615. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27616. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27617. "&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
  27618. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27619. } else {
  27620. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27621. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27622. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27623. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27624. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27625. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27626. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27627. "&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
  27628. }
  27629. resp, requestErr := http.Get(api)
  27630. if requestErr != nil {
  27631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27632. return
  27633. }
  27634. body, ioErr := ioutil.ReadAll(resp.Body)
  27635. if ioErr != nil {
  27636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27638. return
  27639. }
  27640. var respJSON map[string]interface{}
  27641. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27644. return
  27645. }
  27646. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27647. result, _ := json.Marshal(respJSON)
  27648. fmt.Println("log")
  27649. fmt.Println(string(result))
  27650. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27651. utils.ErrorLog("解析失败:%v", err)
  27652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27653. return
  27654. }
  27655. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27656. res.Output = resSeven10265.Output
  27657. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27658. res.ErrMsg = resSeven10265.ErrMsg
  27659. res.Cainfo = resSeven10265.Cainfo
  27660. res.WarnMsg = resSeven10265.WarnMsg
  27661. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27662. res.Infcode = infocode
  27663. }
  27664. }
  27665. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27666. psn_info, _ := service.GetPsnByPatientId(id)
  27667. var verify_number string
  27668. if psn_info.IdCardType == 4 {
  27669. verify_number = psn_info.VerifyNumber
  27670. } else if psn_info.IdCardType == 1 {
  27671. bas := strings.Split(psn_info.CardInfo, "|")
  27672. cardNumber := bas[2]
  27673. verify_number = cardNumber
  27674. } else {
  27675. verify_number = psn_info.Certno
  27676. psn_info.IdCardType = 2
  27677. }
  27678. var api string
  27679. new_chrg_bchno := chrg_bchno
  27680. if adminUser.CurrentOrgId == 10265 {
  27681. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27682. new_chrg_bchno = "0000"
  27683. }
  27684. }
  27685. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27686. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27687. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27688. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27689. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27690. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27691. "&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
  27692. resp, requestErr := http.Get(api)
  27693. if requestErr != nil {
  27694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27695. return
  27696. }
  27697. body, ioErr := ioutil.ReadAll(resp.Body)
  27698. if ioErr != nil {
  27699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27701. return
  27702. }
  27703. var respJSON map[string]interface{}
  27704. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27707. return
  27708. }
  27709. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27710. result, _ := json.Marshal(respJSON)
  27711. fmt.Println("log")
  27712. fmt.Println(string(result))
  27713. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27714. utils.ErrorLog("解析失败:%v", err)
  27715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27716. return
  27717. }
  27718. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27719. res.Output = resSeven10265.Output
  27720. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27721. res.ErrMsg = resSeven10265.ErrMsg
  27722. res.Cainfo = resSeven10265.Cainfo
  27723. res.WarnMsg = resSeven10265.WarnMsg
  27724. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27725. res.Infcode = infocode
  27726. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27727. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27728. var cert_no string
  27729. if his.IdCardType == 1 {
  27730. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27731. } else {
  27732. cert_no = psn_info.VerifyNumber
  27733. }
  27734. 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)
  27735. var dat map[string]interface{}
  27736. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27737. fmt.Println(dat)
  27738. } else {
  27739. fmt.Println(err)
  27740. }
  27741. saveLog(result2, src_resquest, "2207", "结算")
  27742. userJSONBytes, _ := json.Marshal(dat)
  27743. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27744. utils.ErrorLog("解析失败:%v", err)
  27745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27746. return
  27747. }
  27748. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27749. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27750. var cert_no string
  27751. var card_sn string
  27752. if his.IdCardType == 1 {
  27753. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27754. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27755. bas := strings.Split(psn_info.CardInfo, "|")
  27756. card_sn = bas[3]
  27757. } else if his.IdCardType == 2 {
  27758. cert_no = his.IdCardNo
  27759. } else {
  27760. cert_no = psn_info.VerifyNumber
  27761. }
  27762. var rf []*ResultFive
  27763. json.Unmarshal([]byte(his.Iinfo), &rf)
  27764. var psn_type string
  27765. for _, item := range rf {
  27766. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27767. psn_type = item.PsnType
  27768. }
  27769. }
  27770. 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)
  27771. var dat map[string]interface{}
  27772. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27773. fmt.Println(dat)
  27774. } else {
  27775. fmt.Println(err)
  27776. }
  27777. saveLog(result2, src_resquest, "2207", "结算")
  27778. userJSONBytes, _ := json.Marshal(dat)
  27779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27780. utils.ErrorLog("解析失败:%v", err)
  27781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27782. return
  27783. }
  27784. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27785. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27786. var cert_no string
  27787. var card_sn string
  27788. if his.IdCardType == 1 {
  27789. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27790. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27791. //bas := strings.Split(psn_info.CardInfo, "|")
  27792. card_sn = ""
  27793. } else if his.IdCardType == 2 {
  27794. cert_no = his.IdCardNo
  27795. } else {
  27796. cert_no = psn_info.VerifyNumber
  27797. }
  27798. var rf []*ResultFive
  27799. json.Unmarshal([]byte(his.Iinfo), &rf)
  27800. var psn_type string
  27801. for _, item := range rf {
  27802. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27803. psn_type = item.PsnType
  27804. }
  27805. }
  27806. 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)
  27807. var dat map[string]interface{}
  27808. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27809. fmt.Println(dat)
  27810. } else {
  27811. fmt.Println(err)
  27812. }
  27813. saveLog(result2, src_resquest, "2207", "结算")
  27814. userJSONBytes, _ := json.Marshal(dat)
  27815. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27816. utils.ErrorLog("解析失败:%v", err)
  27817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27818. return
  27819. }
  27820. } else if miConfig.MdtrtareaAdmvs == "360100" {
  27821. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27822. var cert_no string
  27823. var card_sn string
  27824. if his.IdCardType == 1 {
  27825. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27826. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27827. //bas := strings.Split(psn_info.CardInfo, "|")
  27828. card_sn = ""
  27829. } else if his.IdCardType == 2 {
  27830. cert_no = his.IdCardNo
  27831. } else {
  27832. cert_no = psn_info.VerifyNumber
  27833. }
  27834. var rf []*ResultFive
  27835. json.Unmarshal([]byte(his.Iinfo), &rf)
  27836. var psn_type string
  27837. for _, item := range rf {
  27838. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27839. psn_type = item.PsnType
  27840. }
  27841. }
  27842. 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)
  27843. var dat map[string]interface{}
  27844. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27845. fmt.Println(dat)
  27846. } else {
  27847. fmt.Println(err)
  27848. }
  27849. saveLog(result2, src_resquest, "2207", "结算")
  27850. userJSONBytes, _ := json.Marshal(dat)
  27851. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27852. utils.ErrorLog("解析失败:%v", err)
  27853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27854. return
  27855. }
  27856. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27857. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27858. if his.IdCardType == 1 {
  27859. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27860. bas := strings.Split(psn_info.CardInfo, "|")
  27861. cert_no = bas[2]
  27862. } else if his.IdCardType == 3 {
  27863. cert_no = his.Certno
  27864. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27865. } else if his.IdCardType == 4 {
  27866. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27867. cert_no = psn_info.VerifyNumber
  27868. psn_info.VerifyNumber = psn_info.VerifyNumber
  27869. } else {
  27870. cert_no = his.Certno
  27871. psn_info.VerifyNumber = his.Certno
  27872. }
  27873. var api string
  27874. var med_type string
  27875. if his.Insutype == "390" {
  27876. if reg_type == 992102 {
  27877. med_type = "992102"
  27878. }
  27879. if reg_type == 140104 {
  27880. med_type = "140104"
  27881. }
  27882. if reg_type == 140201 {
  27883. med_type = "140201"
  27884. }
  27885. if reg_type == 14 {
  27886. med_type = "14"
  27887. }
  27888. } else if his.Insutype == "310" {
  27889. if reg_type == 992102 {
  27890. med_type = "992102"
  27891. }
  27892. if reg_type == 140104 {
  27893. med_type = "140104"
  27894. }
  27895. if reg_type == 140201 {
  27896. med_type = "140201"
  27897. }
  27898. if reg_type == 14 {
  27899. med_type = "14"
  27900. }
  27901. }
  27902. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27903. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27904. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27905. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27906. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27907. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27908. "&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
  27909. resp, requestErr := http.Get(api)
  27910. if requestErr != nil {
  27911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27912. return
  27913. }
  27914. body, ioErr := ioutil.ReadAll(resp.Body)
  27915. if ioErr != nil {
  27916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27918. return
  27919. }
  27920. var respJSON map[string]interface{}
  27921. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27924. return
  27925. }
  27926. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27927. if status == "0" {
  27928. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27929. c.ServeSuccessJSON(map[string]interface{}{
  27930. "failed_code": -10,
  27931. "msg": err_msg,
  27932. })
  27933. return
  27934. }
  27935. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27936. result, _ := json.Marshal(respJSON)
  27937. fmt.Println("log")
  27938. fmt.Println(string(result))
  27939. if err := json.Unmarshal(result, &ahres); err != nil {
  27940. utils.ErrorLog("解析失败:%v", err)
  27941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27942. return
  27943. }
  27944. res.InfRefmsgid = ahres.InfRefmsgid
  27945. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27946. // 创建对应的Time类型
  27947. t := time.UnixMilli(timestamp)
  27948. // 格式化成指定的日期字符串
  27949. str := t.Format("2006-01-02 15:04:05")
  27950. res.Output.Setlinfo.SetlTime = str
  27951. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27952. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27953. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27954. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27955. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27956. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27957. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27958. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27959. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27960. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27961. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27962. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27963. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27964. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27965. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27966. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27967. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27968. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27969. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27970. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27971. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27972. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27973. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27974. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27975. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27976. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27977. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27978. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27979. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27980. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27981. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27982. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27983. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27984. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27985. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27986. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27987. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27988. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27989. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27990. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27991. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27992. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27993. res.Output.Setldetail = ahres.Output.Setldetail
  27994. res.ErrMsg = ahres.ErrMsg
  27995. res.Cainfo = ahres.Cainfo
  27996. res.WarnMsg = ahres.WarnMsg
  27997. res.Infcode = ahres.Infcode
  27998. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27999. res.Output.Setlinfo.ClrType = "11"
  28000. } else {
  28001. res.Output.Setlinfo.ClrType = "9903"
  28002. }
  28003. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28004. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28005. if his.IdCardType == 1 {
  28006. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28007. bas := strings.Split(psn_info.CardInfo, "|")
  28008. cert_no = bas[2]
  28009. } else if his.IdCardType == 3 {
  28010. cert_no = his.Certno
  28011. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28012. } else if his.IdCardType == 4 {
  28013. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28014. cert_no = his.Certno
  28015. psn_info.VerifyNumber = psn_info.VerifyNumber
  28016. } else {
  28017. cert_no = his.Certno
  28018. psn_info.VerifyNumber = his.Certno
  28019. }
  28020. var api string
  28021. var med_type string
  28022. if his.Insutype == "390" {
  28023. if reg_type == 992102 {
  28024. med_type = "992102"
  28025. }
  28026. if reg_type == 140104 {
  28027. med_type = "140104"
  28028. }
  28029. if reg_type == 14 {
  28030. med_type = "14"
  28031. }
  28032. if reg_type == 140201 {
  28033. med_type = "140201"
  28034. }
  28035. } else if his.Insutype == "310" {
  28036. if reg_type == 992102 {
  28037. med_type = "992102"
  28038. }
  28039. if reg_type == 14 {
  28040. med_type = "14"
  28041. }
  28042. if reg_type == 140104 {
  28043. med_type = "140104"
  28044. }
  28045. if reg_type == 140201 {
  28046. med_type = "140201"
  28047. }
  28048. }
  28049. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28050. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28051. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28052. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28053. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28054. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28055. "&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
  28056. resp, requestErr := http.Get(api)
  28057. if requestErr != nil {
  28058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28059. return
  28060. }
  28061. body, ioErr := ioutil.ReadAll(resp.Body)
  28062. if ioErr != nil {
  28063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28065. return
  28066. }
  28067. var respJSON map[string]interface{}
  28068. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28071. return
  28072. }
  28073. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28074. if status == "0" {
  28075. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28076. c.ServeSuccessJSON(map[string]interface{}{
  28077. "failed_code": -10,
  28078. "msg": err_msg,
  28079. })
  28080. return
  28081. }
  28082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28083. result, _ := json.Marshal(respJSON)
  28084. fmt.Println("log")
  28085. fmt.Println(string(result))
  28086. if err := json.Unmarshal(result, &ahres); err != nil {
  28087. utils.ErrorLog("解析失败:%v", err)
  28088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28089. return
  28090. }
  28091. res.InfRefmsgid = ahres.InfRefmsgid
  28092. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28093. // 创建对应的Time类型
  28094. t := time.UnixMilli(timestamp)
  28095. // 格式化成指定的日期字符串
  28096. str := t.Format("2006-01-02 15:04:05")
  28097. res.Output.Setlinfo.SetlTime = str
  28098. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28099. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28100. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28101. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28102. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28103. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28104. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28105. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28106. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28107. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28108. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28109. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28110. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28111. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28112. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28113. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28114. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28115. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28116. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28117. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28118. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28119. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28120. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28121. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28122. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28123. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28124. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28125. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28126. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28127. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28128. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28129. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28130. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28131. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28132. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28133. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28134. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28135. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28136. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28137. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28138. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28139. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28140. res.Output.Setldetail = ahres.Output.Setldetail
  28141. res.ErrMsg = ahres.ErrMsg
  28142. res.Cainfo = ahres.Cainfo
  28143. res.WarnMsg = ahres.WarnMsg
  28144. res.Infcode = ahres.Infcode
  28145. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28146. res.Output.Setlinfo.ClrType = "11"
  28147. } else {
  28148. res.Output.Setlinfo.ClrType = "9903"
  28149. }
  28150. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28151. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28152. var cert_no string
  28153. if his.IdCardType == 1 {
  28154. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28155. } else if his.IdCardType == 2 {
  28156. cert_no = his.IdCardNo
  28157. } else {
  28158. cert_no = psn_info.VerifyNumber
  28159. }
  28160. 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, "")
  28161. var dat map[string]interface{}
  28162. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28163. fmt.Println(dat)
  28164. } else {
  28165. fmt.Println(err)
  28166. }
  28167. saveLog(result2, src_resquest, "2207", "结算")
  28168. userJSONBytes, _ := json.Marshal(dat)
  28169. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28170. utils.ErrorLog("解析失败:%v", err)
  28171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28172. return
  28173. }
  28174. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28175. psn_info, _ := service.GetPsnByPatientId(id)
  28176. var verify_number string
  28177. if psn_info.IdCardType == 4 {
  28178. verify_number = psn_info.VerifyNumber
  28179. } else if psn_info.IdCardType == 1 {
  28180. bas := strings.Split(psn_info.CardInfo, "|")
  28181. cardNumber := bas[2]
  28182. verify_number = cardNumber
  28183. } else {
  28184. verify_number = psn_info.Certno
  28185. psn_info.IdCardType = 2
  28186. }
  28187. var api string
  28188. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28189. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28190. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28191. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28192. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28193. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28194. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  28195. resp, requestErr := http.Get(api)
  28196. if requestErr != nil {
  28197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28198. return
  28199. }
  28200. body, ioErr := ioutil.ReadAll(resp.Body)
  28201. if ioErr != nil {
  28202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28204. return
  28205. }
  28206. var respJSON map[string]interface{}
  28207. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28210. return
  28211. }
  28212. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28213. result, _ := json.Marshal(respJSON)
  28214. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28215. utils.ErrorLog("解析失败:%v", err)
  28216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28217. return
  28218. }
  28219. } else {
  28220. var src_resquest string
  28221. if miConfig.Code == "H15049901371" {
  28222. //赤峰地区国家医保医疗类别
  28223. //职工透析:医疗类别选特殊情况门诊990502
  28224. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28225. var med_type string
  28226. if his.Insutype == "390" {
  28227. if reg_type == 14 {
  28228. med_type = "9933"
  28229. } else if reg_type == 11 {
  28230. med_type = "11"
  28231. }
  28232. } else if his.Insutype == "310" {
  28233. if reg_type == 14 {
  28234. med_type = "990502"
  28235. } else if reg_type == 11 {
  28236. med_type = "11"
  28237. }
  28238. }
  28239. 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)
  28240. } else {
  28241. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" {
  28242. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28243. if result3101.Infcode == 0 {
  28244. if len(result3101.Output.Result) > 0 {
  28245. c.ServeSuccessJSON(map[string]interface{}{
  28246. "failed_code": -10,
  28247. "failed_type": 100,
  28248. "warm_type": 2,
  28249. "msg": result3101,
  28250. })
  28251. return
  28252. }
  28253. } else {
  28254. c.ServeSuccessJSON(map[string]interface{}{
  28255. "failed_code": -10,
  28256. "msg": result3101.ErrMsg,
  28257. })
  28258. return
  28259. }
  28260. }
  28261. if his.IdCardType == 4 {
  28262. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28263. token := psn_info.VerifyNumber
  28264. 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)
  28265. } else {
  28266. 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)
  28267. }
  28268. }
  28269. var dat map[string]interface{}
  28270. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28271. fmt.Println(dat)
  28272. } else {
  28273. fmt.Println(err)
  28274. }
  28275. saveLog(result2, src_resquest, "2207", "结算")
  28276. userJSONBytes, _ := json.Marshal(dat)
  28277. if miConfig.Code == "H15049901371" {
  28278. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28279. utils.ErrorLog("解析失败:%v", err)
  28280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28281. return
  28282. }
  28283. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28284. res.Output = resSeven10265.Output
  28285. res.ErrMsg = resSeven10265.ErrMsg
  28286. res.Cainfo = resSeven10265.Cainfo
  28287. res.WarnMsg = resSeven10265.WarnMsg
  28288. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28289. res.Infcode = infocode
  28290. } else {
  28291. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28292. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  28293. utils.ErrorLog("解析失败:%v", err)
  28294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28295. return
  28296. }
  28297. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  28298. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  28299. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  28300. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28301. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  28302. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  28303. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  28304. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28305. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  28306. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28307. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28308. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28309. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28310. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28311. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  28312. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  28313. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  28314. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  28315. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  28316. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  28317. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28318. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  28319. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  28320. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  28321. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  28322. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  28323. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  28324. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  28325. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  28326. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  28327. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  28328. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  28329. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  28330. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  28331. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28332. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  28333. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  28334. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  28335. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28336. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  28337. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  28338. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  28339. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  28340. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  28341. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  28342. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  28343. res.ErrMsg = gzresSeven10265Two.ErrMsg
  28344. res.Cainfo = gzresSeven10265Two.Cainfo
  28345. res.WarnMsg = gzresSeven10265Two.WarnMsg
  28346. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  28347. //res.Infcode = infocode
  28348. } else {
  28349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28350. utils.ErrorLog("解析失败:%v", err)
  28351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28352. return
  28353. }
  28354. }
  28355. }
  28356. }
  28357. if res.Infcode == -1 {
  28358. errlog := &models.HisOrderError{
  28359. UserOrgId: adminUser.CurrentOrgId,
  28360. Ctime: time.Now().Unix(),
  28361. Mtime: time.Now().Unix(),
  28362. Number: chrg_bchno,
  28363. ErrMsg: res.ErrMsg,
  28364. Status: 1,
  28365. PatientId: id,
  28366. RecordTime: recordDateTime,
  28367. Stage: 6,
  28368. }
  28369. service.CreateErrMsgLog(errlog)
  28370. c.ServeSuccessJSON(map[string]interface{}{
  28371. "failed_code": -10,
  28372. "msg": res.ErrMsg,
  28373. })
  28374. return
  28375. } else {
  28376. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  28377. order.OrderStatus = 2
  28378. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  28379. order.SetlId = res.Output.Setlinfo.SetlID
  28380. order.PsnNo = res.Output.Setlinfo.PsnNo
  28381. order.PsnName = res.Output.Setlinfo.PsnName
  28382. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  28383. order.Certno = res.Output.Setlinfo.Certno
  28384. order.Gend = res.Output.Setlinfo.Gend
  28385. order.Naty = res.Output.Setlinfo.Naty
  28386. order.Age = res.Output.Setlinfo.Age
  28387. order.Insutype = res.Output.Setlinfo.Insutype
  28388. order.PsnType = res.Output.Setlinfo.PsnType
  28389. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28390. order.SetlTime = res.Output.Setlinfo.SetlTime
  28391. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28392. order.PayWays = pay_ways
  28393. order.AcctUsedFlag = acct_used_flag
  28394. order.WechatPay = wechat_pay
  28395. order.AliPay = ali_pay
  28396. order.JifenPay = jifen_pay
  28397. order.BandCardPay = band_card_pay
  28398. order.CashPay = cash_pay
  28399. order.OthDesc = oth_desc
  28400. //order.MedType = res.Output.Setlinfo.MedType
  28401. if reg_type == 1112 {
  28402. order.MedType = "1112"
  28403. }
  28404. if reg_type == 1111 {
  28405. order.MedType = "1111"
  28406. }
  28407. order.ClrType = res.Output.Setlinfo.ClrType
  28408. if adminUser.CurrentOrgId == 10480 {
  28409. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28410. order.ClrType = "11"
  28411. } else {
  28412. order.ClrType = "9903"
  28413. }
  28414. }
  28415. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28416. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28417. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28418. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28419. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28420. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28421. order.HifpPay = res.Output.Setlinfo.HifpPay
  28422. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28423. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28424. order.HifesPay = res.Output.Setlinfo.HifesPay
  28425. order.HifobPay = res.Output.Setlinfo.HifobPay
  28426. order.MafPay = res.Output.Setlinfo.MafPay
  28427. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28428. order.OthPay = res.Output.Setlinfo.OthPay
  28429. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28430. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28431. order.AcctPay = res.Output.Setlinfo.AcctPay
  28432. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28433. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28434. order.Balc = res.Output.Setlinfo.Balc
  28435. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28436. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28437. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28438. order.ClrWay = res.Output.Setlinfo.ClrWay
  28439. order.Creator = order.Creator
  28440. order.Modify = roles.AdminUserId
  28441. order.RequestLog = src_resquest
  28442. order.Diagnosis = diagnosis_id
  28443. order.FaPiaoNumber = fapiao_number
  28444. order.FaPiaoCode = fapiao_code
  28445. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28446. detailStr := string(setlDetail)
  28447. order.SetlDetail = detailStr
  28448. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28449. err = service.UpDateOrder(order)
  28450. if err == nil {
  28451. //判断是否使用了押金
  28452. if dec_way == "true" {
  28453. tmpstring := strconv.FormatInt(order.ID, 10)
  28454. //扣押金
  28455. order.Decimal = decimal
  28456. service.UpDateOrder(order)
  28457. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28458. if errmsg != nil {
  28459. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28460. return
  28461. }
  28462. }
  28463. c.ServeSuccessJSON(map[string]interface{}{
  28464. "msg": "结算成功",
  28465. })
  28466. } else {
  28467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28468. return
  28469. }
  28470. }
  28471. }
  28472. }
  28473. }
  28474. // 上传明细-预结算-
  28475. func (c *HisApiController) GetPreUploadInfo() {
  28476. id, _ := c.GetInt64("id")
  28477. record_time := c.GetString("record_time")
  28478. his_patient_id, _ := c.GetInt64("his_patient_id")
  28479. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  28480. admin_user_id, _ := c.GetInt64("admin_user_id")
  28481. diagnosis_id := c.GetString("diagnosis")
  28482. sick_type, _ := c.GetInt64("sick_type")
  28483. reg_type, _ := c.GetInt64("p_type")
  28484. begin_time := c.GetString("begin_time")
  28485. acct_used_flag := c.GetString("acct_used_flag")
  28486. id_str := c.GetString("ids")
  28487. ids_arr := strings.Split(id_str, ",")
  28488. timeLayout := "2006-01-02"
  28489. loc, _ := time.LoadLocation("Local")
  28490. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28491. if err != nil {
  28492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28493. return
  28494. }
  28495. recordDateTime := theTime.Unix()
  28496. adminUser := c.GetAdminUserInfo()
  28497. diagnosis_ids := strings.Split(diagnosis_id, ",")
  28498. var config []*models.HisXtDiagnoseConfig
  28499. for _, item := range diagnosis_ids {
  28500. id, _ := strconv.ParseInt(item, 10, 64)
  28501. if id > 0 {
  28502. diagnosisConfig, _ := service.FindDiagnoseById(id)
  28503. config = append(config, &diagnosisConfig)
  28504. }
  28505. }
  28506. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  28507. sickConfig, _ := service.FindSickById(sick_type)
  28508. var prescriptions []*models.HisPrescription
  28509. var start_time int64
  28510. var end_time int64
  28511. var isSuccess bool = true
  28512. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28513. fmt.Println(his_patient_id)
  28514. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28515. timestamp := time.Now().Unix()
  28516. tempTime := time.Unix(timestamp, 0)
  28517. timeFormat := tempTime.Format("20060102150405")
  28518. chrgBchno := rand.Intn(100000) + 10000
  28519. new_chrg_bchno := ""
  28520. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  28521. new_chrg_bchno = chrg_bchno
  28522. if adminUser.CurrentOrgId == 10265 {
  28523. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28524. new_chrg_bchno = "0000"
  28525. }
  28526. }
  28527. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28528. var patientPrescription models.HisPrescriptionInfo
  28529. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28530. if patientPrescription.ID == 0 {
  28531. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  28532. }
  28533. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28534. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28535. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  28536. strconv.FormatInt(his.PatientId, 10)
  28537. var res2406 Result2406
  28538. //安徽单病种处理
  28539. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  28540. data := make(map[string]interface{})
  28541. client := &http.Client{}
  28542. data["psn_no"] = his.PsnNo
  28543. data["mdtrt_id"] = his.Number
  28544. data["operator"] = roles.UserName
  28545. data["cert_no"] = his.IdCardNo
  28546. data["org_name"] = miConfig.OrgName
  28547. data["psn_name"] = his.Name
  28548. data["ipt_otp_no"] = his.IptOtpNo
  28549. data["ipt_psn_sp_flag_type"] = "0901"
  28550. data["ipt_psn_sp_flag"] = "1"
  28551. data["fixmedins_code"] = miConfig.Code
  28552. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28553. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28554. data["url"] = miConfig.Url
  28555. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28556. bytesData, _ := json.Marshal(data)
  28557. var req *http.Request
  28558. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28559. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28560. resp, _ := client.Do(req)
  28561. defer resp.Body.Close()
  28562. body, ioErr := ioutil.ReadAll(resp.Body)
  28563. if ioErr != nil {
  28564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28566. return
  28567. }
  28568. var respJSON map[string]interface{}
  28569. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28572. return
  28573. }
  28574. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28575. if status == "0" {
  28576. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28577. c.ServeSuccessJSON(map[string]interface{}{
  28578. "failed_code": -10,
  28579. "msg": err_msg,
  28580. })
  28581. return
  28582. }
  28583. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28584. userJSONBytes, _ := json.Marshal(respJSON)
  28585. fmt.Println("log")
  28586. fmt.Println(string(userJSONBytes))
  28587. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28588. utils.ErrorLog("解析失败:%v", err)
  28589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28590. return
  28591. }
  28592. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  28593. data := make(map[string]interface{})
  28594. client := &http.Client{}
  28595. data["psn_no"] = his.PsnNo
  28596. data["mdtrt_id"] = his.Number
  28597. data["operator"] = roles.UserName
  28598. data["cert_no"] = his.IdCardNo
  28599. data["org_name"] = miConfig.OrgName
  28600. data["psn_name"] = his.Name
  28601. data["ipt_otp_no"] = his.IptOtpNo
  28602. data["ipt_psn_sp_flag_type"] = "0901"
  28603. data["ipt_psn_sp_flag"] = "1"
  28604. data["fixmedins_code"] = miConfig.Code
  28605. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28606. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28607. data["url"] = miConfig.Url
  28608. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28609. bytesData, _ := json.Marshal(data)
  28610. var req *http.Request
  28611. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28612. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28613. resp, _ := client.Do(req)
  28614. defer resp.Body.Close()
  28615. body, ioErr := ioutil.ReadAll(resp.Body)
  28616. if ioErr != nil {
  28617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28619. return
  28620. }
  28621. var respJSON map[string]interface{}
  28622. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28625. return
  28626. }
  28627. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28628. if status == "0" {
  28629. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28630. c.ServeSuccessJSON(map[string]interface{}{
  28631. "failed_code": -10,
  28632. "msg": err_msg,
  28633. })
  28634. return
  28635. }
  28636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28637. userJSONBytes, _ := json.Marshal(respJSON)
  28638. fmt.Println("log")
  28639. fmt.Println(string(userJSONBytes))
  28640. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28641. utils.ErrorLog("解析失败:%v", err)
  28642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28643. return
  28644. }
  28645. }
  28646. if res2406.Infcode != 0 {
  28647. adminUser := c.GetAdminUserInfo()
  28648. errlog := &models.HisOrderError{
  28649. UserOrgId: adminUser.CurrentOrgId,
  28650. Ctime: time.Now().Unix(),
  28651. Mtime: time.Now().Unix(),
  28652. ErrMsg: res2406.ErrMsg,
  28653. Status: 1,
  28654. PatientId: id,
  28655. RecordTime: recordDateTime,
  28656. Stage: 3,
  28657. }
  28658. service.CreateErrMsgLog(errlog)
  28659. c.ServeSuccessJSON(map[string]interface{}{
  28660. "failed_code": -10,
  28661. "msg": res2406.ErrMsg,
  28662. })
  28663. return
  28664. }
  28665. var res2 ResultSix
  28666. var res3 GZResultSix
  28667. var resSix10265 ResultSix10265
  28668. //var time_stamp string
  28669. if miConfig.MdtrtareaAdmvs == "421300" {
  28670. data := make(map[string]interface{})
  28671. client := &http.Client{}
  28672. data["psn_no"] = his.PsnNo
  28673. data["mdtrt_id"] = his.Number
  28674. data["department"] = department.Name
  28675. data["org_name"] = miConfig.OrgName
  28676. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28677. data["doctor_id"] = doctor_info.DoctorNumber
  28678. data["doctor_name"] = roles.UserName
  28679. data["fixmedins_code"] = miConfig.Code
  28680. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28681. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28682. data["secret_key"] = miConfig.SecretKey
  28683. data["sick_code"] = sickConfig.CountryCode
  28684. data["sick_name"] = sickConfig.ClassName
  28685. data["begin_time"] = begin_time
  28686. data["dept"] = strconv.FormatInt(department.ID, 10)
  28687. data["config"] = config
  28688. data["opter"] = roles.UserName
  28689. fmt.Println(data)
  28690. bytesData, _ := json.Marshal(data)
  28691. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28692. resp, _ := client.Do(req)
  28693. defer resp.Body.Close()
  28694. body, ioErr := ioutil.ReadAll(resp.Body)
  28695. if ioErr != nil {
  28696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28698. return
  28699. }
  28700. var respJSON map[string]interface{}
  28701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28704. return
  28705. }
  28706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28707. userJSONBytes, _ := json.Marshal(respJSON)
  28708. fmt.Println("log")
  28709. fmt.Println(string(userJSONBytes))
  28710. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28711. utils.ErrorLog("解析失败:%v", err)
  28712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28713. return
  28714. }
  28715. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28716. data := make(map[string]interface{})
  28717. client := &http.Client{}
  28718. data["psn_no"] = his.PsnNo
  28719. data["mdtrt_id"] = his.Number
  28720. data["department"] = department.Name
  28721. data["org_name"] = miConfig.OrgName
  28722. if reg_type == 11 && his.Insutype == "390" {
  28723. data["med_type"] = "110104"
  28724. } else {
  28725. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28726. }
  28727. data["doctor_id"] = doctor_info.DoctorNumber
  28728. data["doctor_name"] = roles.UserName
  28729. data["fixmedins_code"] = miConfig.Code
  28730. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28731. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28732. data["secret_key"] = miConfig.SecretKey
  28733. data["sick_code"] = sickConfig.CountryCode
  28734. data["sick_name"] = sickConfig.ClassName
  28735. data["begin_time"] = begin_time
  28736. data["dept"] = strconv.FormatInt(department.ID, 10)
  28737. data["config"] = config
  28738. data["opter"] = roles.UserName
  28739. fmt.Println(data)
  28740. bytesData, _ := json.Marshal(data)
  28741. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28742. resp, _ := client.Do(req)
  28743. defer resp.Body.Close()
  28744. body, ioErr := ioutil.ReadAll(resp.Body)
  28745. if ioErr != nil {
  28746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28748. return
  28749. }
  28750. var respJSON map[string]interface{}
  28751. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28754. return
  28755. }
  28756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28757. userJSONBytes, _ := json.Marshal(respJSON)
  28758. fmt.Println("log")
  28759. fmt.Println(string(userJSONBytes))
  28760. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28761. utils.ErrorLog("解析失败:%v", err)
  28762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28763. return
  28764. }
  28765. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28766. data := make(map[string]interface{})
  28767. client := &http.Client{}
  28768. data["psn_no"] = his.PsnNo
  28769. data["mdtrt_id"] = his.Number
  28770. data["department"] = department.Name
  28771. data["org_name"] = miConfig.OrgName
  28772. if reg_type == 11 && his.Insutype == "390" {
  28773. data["med_type"] = "110104"
  28774. } else {
  28775. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28776. }
  28777. data["doctor_id"] = doctor_info.DoctorNumber
  28778. data["doctor_name"] = roles.UserName
  28779. data["fixmedins_code"] = miConfig.Code
  28780. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28781. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28782. data["secret_key"] = miConfig.SecretKey
  28783. data["sick_code"] = sickConfig.CountryCode
  28784. data["sick_name"] = sickConfig.ClassName
  28785. data["begin_time"] = begin_time
  28786. data["dept"] = strconv.FormatInt(department.ID, 10)
  28787. data["config"] = config
  28788. data["opter"] = roles.UserName
  28789. fmt.Println(data)
  28790. bytesData, _ := json.Marshal(data)
  28791. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28792. resp, _ := client.Do(req)
  28793. defer resp.Body.Close()
  28794. body, ioErr := ioutil.ReadAll(resp.Body)
  28795. if ioErr != nil {
  28796. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28798. return
  28799. }
  28800. var respJSON map[string]interface{}
  28801. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28804. return
  28805. }
  28806. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28807. userJSONBytes, _ := json.Marshal(respJSON)
  28808. fmt.Println("log")
  28809. fmt.Println(string(userJSONBytes))
  28810. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28811. utils.ErrorLog("解析失败:%v", err)
  28812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28813. return
  28814. }
  28815. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28816. data := make(map[string]interface{})
  28817. client := &http.Client{}
  28818. data["psn_no"] = his.PsnNo
  28819. data["mdtrt_id"] = his.Number
  28820. data["department"] = department.Name
  28821. data["org_name"] = miConfig.OrgName
  28822. if reg_type == 11 && his.Insutype == "390" {
  28823. data["med_type"] = "110104"
  28824. } else {
  28825. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28826. }
  28827. data["doctor_id"] = doctor_info.DoctorNumber
  28828. data["doctor_name"] = roles.UserName
  28829. data["fixmedins_code"] = miConfig.Code
  28830. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28831. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28832. data["secret_key"] = miConfig.SecretKey
  28833. data["sick_code"] = sickConfig.CountryCode
  28834. data["sick_name"] = sickConfig.ClassName
  28835. data["begin_time"] = begin_time
  28836. data["dept"] = strconv.FormatInt(department.ID, 10)
  28837. data["config"] = config
  28838. data["opter"] = roles.UserName
  28839. fmt.Println(data)
  28840. bytesData, _ := json.Marshal(data)
  28841. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28842. resp, _ := client.Do(req)
  28843. defer resp.Body.Close()
  28844. body, ioErr := ioutil.ReadAll(resp.Body)
  28845. if ioErr != nil {
  28846. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28848. return
  28849. }
  28850. var respJSON map[string]interface{}
  28851. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28854. return
  28855. }
  28856. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28857. userJSONBytes, _ := json.Marshal(respJSON)
  28858. fmt.Println("log")
  28859. fmt.Println(string(userJSONBytes))
  28860. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28861. utils.ErrorLog("解析失败:%v", err)
  28862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28863. return
  28864. }
  28865. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28866. data := make(map[string]interface{})
  28867. client := &http.Client{}
  28868. data["psn_no"] = his.PsnNo
  28869. data["mdtrt_id"] = his.Number
  28870. data["doctor"] = roles.UserName
  28871. data["department"] = department.Name
  28872. data["org_name"] = miConfig.OrgName
  28873. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28874. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28875. data["fixmedins_code"] = miConfig.Code
  28876. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28877. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28878. data["secret_key"] = miConfig.SecretKey
  28879. data["sick_code"] = sickConfig.CountryCode
  28880. data["sick_name"] = sickConfig.ClassName
  28881. data["begin_time"] = begin_time
  28882. data["dept"] = strconv.FormatInt(department.ID, 10)
  28883. data["config"] = config
  28884. data["url"] = miConfig.Url
  28885. data["ak"] = miConfig.AccessKey
  28886. data["cainfo"] = miConfig.Cainfo
  28887. bytesData, _ := json.Marshal(data)
  28888. var req *http.Request
  28889. if miConfig.MdtrtareaAdmvs == "320921" {
  28890. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28891. } else {
  28892. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28893. }
  28894. resp, _ := client.Do(req)
  28895. defer resp.Body.Close()
  28896. body, ioErr := ioutil.ReadAll(resp.Body)
  28897. if ioErr != nil {
  28898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28900. return
  28901. }
  28902. var respJSON map[string]interface{}
  28903. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28906. return
  28907. }
  28908. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28909. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28910. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28912. userJSONBytes, _ := json.Marshal(respJSON)
  28913. fmt.Println("log")
  28914. fmt.Println(string(userJSONBytes))
  28915. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28916. utils.ErrorLog("解析失败:%v", err)
  28917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28918. return
  28919. }
  28920. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28921. res2.Output = resSix10265.Output
  28922. res2.ErrMsg = resSix10265.ErrMsg
  28923. res2.Cainfo = resSix10265.Cainfo
  28924. res2.WarnMsg = resSix10265.WarnMsg
  28925. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28926. res2.Infcode = infocode
  28927. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28928. data := make(map[string]interface{})
  28929. client := &http.Client{}
  28930. data["psn_no"] = his.PsnNo
  28931. data["mdtrt_id"] = his.Number
  28932. data["doctor"] = roles.UserName
  28933. data["department"] = department.Name
  28934. data["org_name"] = miConfig.OrgName
  28935. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28936. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28937. data["fixmedins_code"] = miConfig.Code
  28938. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28939. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28940. data["secret_key"] = miConfig.SecretKey
  28941. data["sick_code"] = sickConfig.CountryCode
  28942. data["sick_name"] = sickConfig.ClassName
  28943. data["begin_time"] = begin_time
  28944. data["dept"] = strconv.FormatInt(department.ID, 10)
  28945. data["config"] = config
  28946. //data["url"] = miConfig.Url
  28947. //data["ak"] = miConfig.AccessKey
  28948. data["cainfo"] = miConfig.Cainfo
  28949. fmt.Println(data)
  28950. bytesData, _ := json.Marshal(data)
  28951. var req *http.Request
  28952. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28953. resp, _ := client.Do(req)
  28954. defer resp.Body.Close()
  28955. body, ioErr := ioutil.ReadAll(resp.Body)
  28956. if ioErr != nil {
  28957. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28959. return
  28960. }
  28961. var respJSON map[string]interface{}
  28962. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28965. return
  28966. }
  28967. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28968. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28969. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28970. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28971. userJSONBytes, _ := json.Marshal(respJSON)
  28972. fmt.Println("log")
  28973. fmt.Println(string(userJSONBytes))
  28974. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28975. utils.ErrorLog("解析失败:%v", err)
  28976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28977. return
  28978. }
  28979. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28980. res2.Output = resSix10265.Output
  28981. res2.ErrMsg = resSix10265.ErrMsg
  28982. res2.Cainfo = resSix10265.Cainfo
  28983. res2.WarnMsg = resSix10265.WarnMsg
  28984. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28985. res2.Infcode = infocode
  28986. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28987. 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)
  28988. saveLog(result, requestLog, "2203", "上传就诊信息")
  28989. var respJSON2 map[string]interface{}
  28990. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28993. return
  28994. }
  28995. userJSONBytes2, _ := json.Marshal(respJSON2)
  28996. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28997. utils.ErrorLog("解析失败:%v", err)
  28998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28999. return
  29000. }
  29001. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29002. var result string
  29003. var requestLog string
  29004. 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, "")
  29005. saveLog(result, requestLog, "2203", "上传就诊信息")
  29006. var respJSON2 map[string]interface{}
  29007. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29010. return
  29011. }
  29012. userJSONBytes2, _ := json.Marshal(respJSON2)
  29013. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29014. utils.ErrorLog("解析失败:%v", err)
  29015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29016. return
  29017. }
  29018. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29019. var result string
  29020. var requestLog string
  29021. 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, "")
  29022. saveLog(result, requestLog, "2203", "上传就诊信息")
  29023. var respJSON2 map[string]interface{}
  29024. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29027. return
  29028. }
  29029. userJSONBytes2, _ := json.Marshal(respJSON2)
  29030. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29031. utils.ErrorLog("解析失败:%v", err)
  29032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29033. return
  29034. }
  29035. } else if miConfig.MdtrtareaAdmvs == "360100" {
  29036. var result string
  29037. var requestLog string
  29038. 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, "")
  29039. saveLog(result, requestLog, "2203", "上传就诊信息")
  29040. var respJSON2 map[string]interface{}
  29041. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29044. return
  29045. }
  29046. userJSONBytes2, _ := json.Marshal(respJSON2)
  29047. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29048. utils.ErrorLog("解析失败:%v", err)
  29049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29050. return
  29051. }
  29052. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29053. data := make(map[string]interface{})
  29054. client := &http.Client{}
  29055. data["psn_no"] = his.PsnNo
  29056. data["mdtrt_id"] = his.Number
  29057. data["operator"] = roles.UserName
  29058. data["department"] = department.Name
  29059. data["org_name"] = miConfig.OrgName
  29060. var med_type string
  29061. if his.Insutype == "390" {
  29062. if reg_type == 992102 {
  29063. med_type = "992102"
  29064. data["sick_code"] = "ZDZ940"
  29065. data["sick_name"] = "慢性肾衰竭"
  29066. }
  29067. if reg_type == 140104 {
  29068. med_type = "140104"
  29069. data["sick_code"] = sickConfig.CountryCode
  29070. data["sick_name"] = sickConfig.ClassName
  29071. }
  29072. if reg_type == 14 {
  29073. med_type = "140104"
  29074. data["sick_code"] = sickConfig.CountryCode
  29075. data["sick_name"] = sickConfig.ClassName
  29076. }
  29077. } else if his.Insutype == "310" {
  29078. if reg_type == 992102 {
  29079. med_type = "992102"
  29080. data["sick_code"] = "ZDZ940"
  29081. data["sick_name"] = "慢性肾衰竭"
  29082. }
  29083. if reg_type == 140104 {
  29084. med_type = "140104"
  29085. data["sick_code"] = sickConfig.CountryCode
  29086. data["sick_name"] = sickConfig.ClassName
  29087. }
  29088. if reg_type == 14 {
  29089. med_type = "14"
  29090. data["sick_code"] = sickConfig.CountryCode
  29091. data["sick_name"] = sickConfig.ClassName
  29092. }
  29093. }
  29094. data["med_type"] = med_type
  29095. data["doctor_number"] = doctor_info.DoctorNumber
  29096. data["doctor_name"] = doctor_info.UserName
  29097. data["fixmedins_code"] = miConfig.Code
  29098. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29099. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29100. data["secret_key"] = miConfig.SecretKey
  29101. data["begin_time"] = begin_time
  29102. data["dept"] = strconv.FormatInt(department.ID, 10)
  29103. data["config"] = config
  29104. data["url"] = miConfig.Url
  29105. data["ak"] = miConfig.AccessKey
  29106. data["cainfo"] = miConfig.Cainfo
  29107. bytesData, _ := json.Marshal(data)
  29108. var req *http.Request
  29109. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  29110. resp, _ := client.Do(req)
  29111. defer resp.Body.Close()
  29112. body, ioErr := ioutil.ReadAll(resp.Body)
  29113. if ioErr != nil {
  29114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29116. return
  29117. }
  29118. var respJSON map[string]interface{}
  29119. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29122. return
  29123. }
  29124. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29125. if status == "0" {
  29126. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29127. c.ServeSuccessJSON(map[string]interface{}{
  29128. "failed_code": -10,
  29129. "msg": err_msg,
  29130. })
  29131. return
  29132. }
  29133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29134. userJSONBytes, _ := json.Marshal(respJSON)
  29135. fmt.Println("log")
  29136. fmt.Println(string(userJSONBytes))
  29137. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29138. utils.ErrorLog("解析失败:%v", err)
  29139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29140. return
  29141. }
  29142. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29143. data := make(map[string]interface{})
  29144. client := &http.Client{}
  29145. data["psn_no"] = his.PsnNo
  29146. data["mdtrt_id"] = his.Number
  29147. data["operator"] = roles.UserName
  29148. data["department"] = department.Name
  29149. data["org_name"] = miConfig.OrgName
  29150. var med_type string
  29151. if his.Insutype == "390" {
  29152. if reg_type == 992102 {
  29153. med_type = "992102"
  29154. data["sick_code"] = sickConfig.CountryCode
  29155. data["sick_name"] = sickConfig.ClassName
  29156. }
  29157. if reg_type == 140104 {
  29158. med_type = "140104"
  29159. data["sick_code"] = sickConfig.CountryCode
  29160. data["sick_name"] = sickConfig.ClassName
  29161. }
  29162. if reg_type == 140201 {
  29163. med_type = "140201"
  29164. data["sick_code"] = sickConfig.CountryCode
  29165. data["sick_name"] = sickConfig.ClassName
  29166. }
  29167. if reg_type == 14 {
  29168. med_type = "14"
  29169. data["sick_code"] = sickConfig.CountryCode
  29170. data["sick_name"] = sickConfig.ClassName
  29171. }
  29172. } else if his.Insutype == "310" {
  29173. if reg_type == 992102 {
  29174. med_type = "992102"
  29175. data["sick_code"] = sickConfig.CountryCode
  29176. data["sick_name"] = sickConfig.ClassName
  29177. }
  29178. if reg_type == 140104 {
  29179. med_type = "140104"
  29180. data["sick_code"] = sickConfig.CountryCode
  29181. data["sick_name"] = sickConfig.ClassName
  29182. }
  29183. if reg_type == 140201 {
  29184. med_type = "140201"
  29185. data["sick_code"] = sickConfig.CountryCode
  29186. data["sick_name"] = sickConfig.ClassName
  29187. }
  29188. if reg_type == 14 {
  29189. med_type = "14"
  29190. data["sick_code"] = sickConfig.CountryCode
  29191. data["sick_name"] = sickConfig.ClassName
  29192. }
  29193. }
  29194. data["med_type"] = med_type
  29195. data["doctor_number"] = doctor_info.DoctorNumber
  29196. data["doctor_name"] = doctor_info.UserName
  29197. data["fixmedins_code"] = miConfig.Code
  29198. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29199. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29200. data["secret_key"] = miConfig.SecretKey
  29201. data["begin_time"] = begin_time
  29202. data["dept"] = strconv.FormatInt(department.ID, 10)
  29203. data["config"] = config
  29204. data["url"] = miConfig.Url
  29205. data["ak"] = miConfig.AccessKey
  29206. data["cainfo"] = miConfig.Cainfo
  29207. bytesData, _ := json.Marshal(data)
  29208. var req *http.Request
  29209. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  29210. resp, _ := client.Do(req)
  29211. defer resp.Body.Close()
  29212. body, ioErr := ioutil.ReadAll(resp.Body)
  29213. if ioErr != nil {
  29214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29216. return
  29217. }
  29218. var respJSON map[string]interface{}
  29219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29222. return
  29223. }
  29224. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29225. if status == "0" {
  29226. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29227. c.ServeSuccessJSON(map[string]interface{}{
  29228. "failed_code": -10,
  29229. "msg": err_msg,
  29230. })
  29231. return
  29232. }
  29233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29234. userJSONBytes, _ := json.Marshal(respJSON)
  29235. fmt.Println("log")
  29236. fmt.Println(string(userJSONBytes))
  29237. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29238. utils.ErrorLog("解析失败:%v", err)
  29239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29240. return
  29241. }
  29242. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29243. var result string
  29244. var requestLog string
  29245. 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, "")
  29246. saveLog(result, requestLog, "2203", "上传就诊信息")
  29247. var respJSON2 map[string]interface{}
  29248. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29251. return
  29252. }
  29253. userJSONBytes2, _ := json.Marshal(respJSON2)
  29254. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29255. utils.ErrorLog("解析失败:%v", err)
  29256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29257. return
  29258. }
  29259. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29260. data := make(map[string]interface{})
  29261. client := &http.Client{}
  29262. data["psn_no"] = his.PsnNo
  29263. data["mdtrt_id"] = his.Number
  29264. data["doctor"] = roles.UserName
  29265. data["department"] = department.Name
  29266. data["org_name"] = miConfig.OrgName
  29267. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29268. data["doctor_id"] = doctor_info.DoctorNumber
  29269. data["fixmedins_code"] = miConfig.Code
  29270. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29271. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29272. data["secret_key"] = miConfig.SecretKey
  29273. data["sick_code"] = sickConfig.CountryCode
  29274. data["sick_name"] = sickConfig.ClassName
  29275. data["begin_time"] = begin_time
  29276. data["new_doctor_name"] = doctor_info.UserName
  29277. data["dept"] = strconv.FormatInt(department.ID, 10)
  29278. data["config"] = config
  29279. bytesData, _ := json.Marshal(data)
  29280. var req *http.Request
  29281. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  29282. resp, _ := client.Do(req)
  29283. defer resp.Body.Close()
  29284. body, ioErr := ioutil.ReadAll(resp.Body)
  29285. if ioErr != nil {
  29286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29288. return
  29289. }
  29290. var respJSON map[string]interface{}
  29291. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29294. return
  29295. }
  29296. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29297. userJSONBytes, _ := json.Marshal(respJSON)
  29298. fmt.Println("log")
  29299. fmt.Println(string(userJSONBytes))
  29300. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29301. utils.ErrorLog("解析失败:%v", err)
  29302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29303. return
  29304. }
  29305. } else {
  29306. var result string
  29307. var requestLog string
  29308. if miConfig.MdtrtareaAdmvs == "440781" { //
  29309. 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)
  29310. } else {
  29311. if miConfig.Code == "H15049901371" {
  29312. //赤峰地区国家医保医疗类别
  29313. //职工透析:医疗类别选特殊情况门诊990502
  29314. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29315. var med_type string
  29316. if his.Insutype == "390" {
  29317. if reg_type == 14 {
  29318. med_type = "9933"
  29319. } else if reg_type == 11 {
  29320. med_type = "11"
  29321. }
  29322. } else if his.Insutype == "310" {
  29323. if reg_type == 14 {
  29324. med_type = "990502"
  29325. } else if reg_type == 11 {
  29326. med_type = "11"
  29327. }
  29328. }
  29329. 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)
  29330. } else {
  29331. 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)
  29332. }
  29333. saveLog(result, requestLog, "2203", "上传就诊信息")
  29334. var respJSON2 map[string]interface{}
  29335. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29338. return
  29339. }
  29340. userJSONBytes2, _ := json.Marshal(respJSON2)
  29341. if miConfig.Code == "H15049901371" {
  29342. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  29343. utils.ErrorLog("解析失败:%v", err)
  29344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29345. return
  29346. }
  29347. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29348. res2.Output = resSix10265.Output
  29349. res2.ErrMsg = resSix10265.ErrMsg
  29350. res2.Cainfo = resSix10265.Cainfo
  29351. res2.WarnMsg = resSix10265.WarnMsg
  29352. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29353. res2.Infcode = infocode
  29354. } else {
  29355. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29356. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  29357. utils.ErrorLog("解析失败:%v", err)
  29358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29359. return
  29360. }
  29361. res2.Infcode = res3.Infcode
  29362. } else {
  29363. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29364. utils.ErrorLog("解析失败:%v", err)
  29365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29366. return
  29367. }
  29368. }
  29369. }
  29370. }
  29371. }
  29372. if res2.Infcode == -1 {
  29373. adminUser := c.GetAdminUserInfo()
  29374. errlog := &models.HisOrderError{
  29375. UserOrgId: adminUser.CurrentOrgId,
  29376. Ctime: time.Now().Unix(),
  29377. Mtime: time.Now().Unix(),
  29378. ErrMsg: res2.ErrMsg,
  29379. Status: 1,
  29380. PatientId: id,
  29381. RecordTime: recordDateTime,
  29382. Stage: 3,
  29383. }
  29384. service.CreateErrMsgLog(errlog)
  29385. c.ServeSuccessJSON(map[string]interface{}{
  29386. "failed_code": -10,
  29387. "msg": res2.ErrMsg,
  29388. })
  29389. return
  29390. }
  29391. if res2.Infcode != 0 {
  29392. adminUser := c.GetAdminUserInfo()
  29393. errlog := &models.HisOrderError{
  29394. UserOrgId: adminUser.CurrentOrgId,
  29395. Ctime: time.Now().Unix(),
  29396. Mtime: time.Now().Unix(),
  29397. ErrMsg: res2.ErrMsg,
  29398. Status: 1,
  29399. PatientId: id,
  29400. RecordTime: recordDateTime,
  29401. Stage: 3,
  29402. }
  29403. service.CreateErrMsgLog(errlog)
  29404. c.ServeSuccessJSON(map[string]interface{}{
  29405. "failed_code": -10,
  29406. "msg": res2.ErrMsg,
  29407. })
  29408. return
  29409. } else {
  29410. his.Diagnosis = diagnosis_id
  29411. his.SickType = sickConfig.ID
  29412. his.PType = fmt.Sprintf("%d", reg_type)
  29413. service.UpdateHisPatientThree(&his)
  29414. data := make(map[string]interface{})
  29415. if settle_accounts_type == 1 { //日结
  29416. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  29417. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  29418. } else {
  29419. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  29420. }
  29421. data["pre"] = prescriptions
  29422. } else { //月结
  29423. start_time_str := c.GetString("start_time")
  29424. end_time_str := c.GetString("end_time")
  29425. timeLayout := "2006-01-02"
  29426. loc, _ := time.LoadLocation("Local")
  29427. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  29428. if err != nil {
  29429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29430. return
  29431. }
  29432. recordStartTime := theStartTime.Unix()
  29433. start_time = recordStartTime
  29434. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  29435. if err != nil {
  29436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29437. return
  29438. }
  29439. recordEndTime := theEndTime.Unix()
  29440. end_time = recordEndTime
  29441. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  29442. data["pre"] = prescriptions
  29443. }
  29444. client := &http.Client{}
  29445. data["psn_no"] = his.PsnNo
  29446. data["mdtrt_id"] = his.Number
  29447. data["chrg_bchno"] = new_chrg_bchno
  29448. data["org_name"] = miConfig.OrgName
  29449. data["doctor"] = doctor_info.UserName
  29450. data["doctor_id"] = doctor_info.DoctorNumber
  29451. data["dept"] = department.Name
  29452. data["fixmedins_code"] = miConfig.Code
  29453. data["opter"] = roles.UserName
  29454. data["dept_code"] = department.Number
  29455. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29456. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29457. data["secret_key"] = miConfig.SecretKey
  29458. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  29459. data["url"] = miConfig.Url
  29460. data["ak"] = miConfig.AccessKey
  29461. data["new_doctor_name"] = patientPrescription.Doctor
  29462. if his.Insutype == "390" {
  29463. if reg_type == 992102 {
  29464. data["diag_code"] = "ZDZ940"
  29465. }
  29466. if reg_type == 140104 {
  29467. data["diag_code"] = sickConfig.CountryCode
  29468. }
  29469. if reg_type == 140201 {
  29470. data["diag_code"] = sickConfig.CountryCode
  29471. }
  29472. if reg_type == 14 {
  29473. data["diag_code"] = sickConfig.CountryCode
  29474. }
  29475. } else if his.Insutype == "310" {
  29476. if miConfig.MdtrtareaAdmvs == "341203" {
  29477. if reg_type == 992102 {
  29478. data["diag_code"] = "ZDZ940"
  29479. }
  29480. if reg_type != 992102 {
  29481. data["diag_code"] = sickConfig.CountryCode
  29482. }
  29483. } else {
  29484. data["diag_code"] = sickConfig.CountryCode
  29485. }
  29486. }
  29487. data["cainfo"] = miConfig.Cainfo
  29488. data["opter"] = roles.UserName
  29489. var ids []int64
  29490. for _, item := range prescriptions {
  29491. ids = append(ids, item.ID)
  29492. }
  29493. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29494. if config.IsOpen == 1 { //对接了医保,走医保流程
  29495. var res ResultFour
  29496. var resFour10265 ResultFour10265
  29497. if miConfig.MdtrtareaAdmvs == "421300" {
  29498. bytesData, _ := json.Marshal(data)
  29499. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  29500. resp, _ := client.Do(req)
  29501. defer resp.Body.Close()
  29502. body, ioErr := ioutil.ReadAll(resp.Body)
  29503. if ioErr != nil {
  29504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29506. return
  29507. }
  29508. var respJSON map[string]interface{}
  29509. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29512. return
  29513. }
  29514. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29515. userJSONBytes, _ := json.Marshal(respJSON)
  29516. fmt.Println("log")
  29517. fmt.Println(string(userJSONBytes))
  29518. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29519. utils.ErrorLog("解析失败:%v", err)
  29520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29521. return
  29522. }
  29523. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29524. bytesData, _ := json.Marshal(data)
  29525. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  29526. resp, _ := client.Do(req)
  29527. defer resp.Body.Close()
  29528. body, ioErr := ioutil.ReadAll(resp.Body)
  29529. if ioErr != nil {
  29530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29532. return
  29533. }
  29534. var respJSON map[string]interface{}
  29535. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29538. return
  29539. }
  29540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29541. userJSONBytes, _ := json.Marshal(respJSON)
  29542. fmt.Println("log")
  29543. fmt.Println(string(userJSONBytes))
  29544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29545. utils.ErrorLog("解析失败:%v", err)
  29546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29547. return
  29548. }
  29549. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29550. bytesData, _ := json.Marshal(data)
  29551. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29552. resp, _ := client.Do(req)
  29553. defer resp.Body.Close()
  29554. body, ioErr := ioutil.ReadAll(resp.Body)
  29555. if ioErr != nil {
  29556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29558. return
  29559. }
  29560. var respJSON map[string]interface{}
  29561. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29564. return
  29565. }
  29566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29567. userJSONBytes, _ := json.Marshal(respJSON)
  29568. fmt.Println("log")
  29569. fmt.Println(string(userJSONBytes))
  29570. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29571. utils.ErrorLog("解析失败:%v", err)
  29572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29573. return
  29574. }
  29575. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29576. bytesData, _ := json.Marshal(data)
  29577. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29578. resp, _ := client.Do(req)
  29579. defer resp.Body.Close()
  29580. body, ioErr := ioutil.ReadAll(resp.Body)
  29581. if ioErr != nil {
  29582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29584. return
  29585. }
  29586. var respJSON map[string]interface{}
  29587. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29590. return
  29591. }
  29592. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29593. userJSONBytes, _ := json.Marshal(respJSON)
  29594. fmt.Println("log")
  29595. fmt.Println(string(userJSONBytes))
  29596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29597. utils.ErrorLog("解析失败:%v", err)
  29598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29599. return
  29600. }
  29601. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29602. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29603. if result3101.Infcode == "0" {
  29604. if len(result3101.Output.Result) > 0 {
  29605. var errMsgs []string
  29606. for _, item := range result3101.Output.Result {
  29607. errMsgs = append(errMsgs, item.VolaCont)
  29608. }
  29609. c.ServeSuccessJSON(map[string]interface{}{
  29610. "failed_code": -10,
  29611. "msg": errMsgs,
  29612. })
  29613. return
  29614. } else {
  29615. if miConfig.MdtrtareaAdmvs == "320921" {
  29616. data["doctor_id"] = "D320923012139"
  29617. } else {
  29618. data["doctor_id"] = "D371621008686"
  29619. }
  29620. bytesData, _ := json.Marshal(data)
  29621. var req *http.Request
  29622. if miConfig.MdtrtareaAdmvs == "320921" {
  29623. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29624. } else {
  29625. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29626. }
  29627. resp, _ := client.Do(req)
  29628. defer resp.Body.Close()
  29629. body, ioErr := ioutil.ReadAll(resp.Body)
  29630. if ioErr != nil {
  29631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29633. return
  29634. }
  29635. var respJSON map[string]interface{}
  29636. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29639. return
  29640. }
  29641. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29642. userJSONBytes, _ := json.Marshal(respJSON)
  29643. fmt.Println("log")
  29644. fmt.Println(string(userJSONBytes))
  29645. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29646. utils.ErrorLog("解析失败:%v", err)
  29647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29648. return
  29649. }
  29650. res.InfRefmsgid = resFour10265.InfRefmsgid
  29651. res.Output = resFour10265.Output
  29652. res.ErrMsg = resFour10265.ErrMsg
  29653. res.Cainfo = resFour10265.Cainfo
  29654. res.WarnMsg = resFour10265.WarnMsg
  29655. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29656. res.Infcode = infocode
  29657. }
  29658. }
  29659. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29660. var pagesize int = 5
  29661. var start int = 1
  29662. var stop int
  29663. var pagecount int
  29664. var curpage int
  29665. data["doctor_id"] = doctor_info.DoctorNumber
  29666. var res2 ResultFour
  29667. //var result res.
  29668. //总页数,向上取整,注意除之前要先转换类型为float64
  29669. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29670. for curpage = 1; curpage <= pagecount; curpage++ {
  29671. if curpage == 1 {
  29672. start = 1
  29673. } else {
  29674. start = (curpage-1)*pagesize + 1
  29675. }
  29676. stop = curpage * pagesize
  29677. if stop > len(prescriptions) {
  29678. stop = len(prescriptions)
  29679. }
  29680. //var requestLog string
  29681. data["pre"] = prescriptions[start-1 : stop]
  29682. fmt.Println(data["pre"])
  29683. bytesData, _ := json.Marshal(data)
  29684. var req *http.Request
  29685. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29686. resp, _ := client.Do(req)
  29687. defer resp.Body.Close()
  29688. body, ioErr := ioutil.ReadAll(resp.Body)
  29689. if ioErr != nil {
  29690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29692. return
  29693. }
  29694. var respJSON map[string]interface{}
  29695. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29698. return
  29699. }
  29700. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29701. userJSONBytes, _ := json.Marshal(respJSON)
  29702. fmt.Println("log")
  29703. fmt.Println(string(userJSONBytes))
  29704. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29705. utils.ErrorLog("解析失败:%v", err)
  29706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29707. return
  29708. }
  29709. res.InfRefmsgid = resFour10265.InfRefmsgid
  29710. res.Output = resFour10265.Output
  29711. res.ErrMsg = resFour10265.ErrMsg
  29712. res.Cainfo = resFour10265.Cainfo
  29713. res.WarnMsg = resFour10265.WarnMsg
  29714. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29715. res.Infcode = infocode
  29716. if infocode == 0 {
  29717. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29718. } else {
  29719. isSuccess = false
  29720. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29721. res.Infcode = -1
  29722. res.ErrMsg = resFour10265.ErrMsg
  29723. errlog := &models.HisOrderError{
  29724. UserOrgId: adminUser.CurrentOrgId,
  29725. Ctime: time.Now().Unix(),
  29726. Mtime: time.Now().Unix(),
  29727. Number: chrg_bchno,
  29728. ErrMsg: "",
  29729. Status: 1,
  29730. PatientId: id,
  29731. RecordTime: recordDateTime,
  29732. Stage: 4,
  29733. }
  29734. service.CreateErrMsgLog(errlog)
  29735. }
  29736. }
  29737. if isSuccess {
  29738. res.Infcode = 0
  29739. res.Output.Result = res2.Output.Result
  29740. } else {
  29741. order := &models.HisOrder{
  29742. UserOrgId: adminUser.CurrentOrgId,
  29743. HisPatientId: his.ID,
  29744. PatientId: his.PatientId,
  29745. SettleAccountsDate: recordDateTime,
  29746. Ctime: time.Now().Unix(),
  29747. Mtime: time.Now().Unix(),
  29748. MdtrtId: his.Number,
  29749. PsnNo: his.PsnNo,
  29750. MedType: strconv.FormatInt(reg_type, 10),
  29751. Status: 1,
  29752. Number: chrg_bchno,
  29753. Infcode: res.Infcode,
  29754. WarnMsg: res.WarnMsg,
  29755. Cainfo: res.Cainfo,
  29756. ErrMsg: res.ErrMsg,
  29757. RespondTime: res.RefmsgTime,
  29758. InfRefmsgid: res.InfRefmsgid,
  29759. OrderStatus: 1,
  29760. IsMedicineInsurance: 1,
  29761. SettleType: settle_accounts_type,
  29762. SettleStartTime: start_time,
  29763. SettleEndTime: end_time,
  29764. Creator: roles.AdminUserId,
  29765. Modify: roles.AdminUserId,
  29766. PType: 2,
  29767. Diagnosis: diagnosis_id,
  29768. }
  29769. err = service.CreateOrder(order)
  29770. if err != nil {
  29771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29772. return
  29773. }
  29774. c.ServeSuccessJSON(map[string]interface{}{
  29775. "failed_code": -10,
  29776. "msg": res2.ErrMsg,
  29777. })
  29778. return
  29779. }
  29780. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29781. 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)
  29782. var dat map[string]interface{}
  29783. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29784. fmt.Println(dat)
  29785. } else {
  29786. fmt.Println(err)
  29787. }
  29788. saveLog(result, request_log, "2204", "上传费用明细")
  29789. userJSONBytes, _ := json.Marshal(dat)
  29790. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29791. utils.ErrorLog("解析失败:%v", err)
  29792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29793. return
  29794. }
  29795. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29796. 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, "", "")
  29797. var dat map[string]interface{}
  29798. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29799. fmt.Println(dat)
  29800. } else {
  29801. fmt.Println(err)
  29802. }
  29803. saveLog(result, request_log, "2204", "上传费用明细")
  29804. userJSONBytes, _ := json.Marshal(dat)
  29805. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29806. utils.ErrorLog("解析失败:%v", err)
  29807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29808. return
  29809. }
  29810. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29811. 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, "", "")
  29812. var dat map[string]interface{}
  29813. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29814. fmt.Println(dat)
  29815. } else {
  29816. fmt.Println(err)
  29817. }
  29818. saveLog(result, request_log, "2204", "上传费用明细")
  29819. userJSONBytes, _ := json.Marshal(dat)
  29820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29821. utils.ErrorLog("解析失败:%v", err)
  29822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29823. return
  29824. }
  29825. } else if miConfig.MdtrtareaAdmvs == "360100" {
  29826. 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, "", "")
  29827. var dat map[string]interface{}
  29828. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29829. fmt.Println(dat)
  29830. } else {
  29831. fmt.Println(err)
  29832. }
  29833. saveLog(result, request_log, "2204", "上传费用明细")
  29834. userJSONBytes, _ := json.Marshal(dat)
  29835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29836. utils.ErrorLog("解析失败:%v", err)
  29837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29838. return
  29839. }
  29840. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29841. bytesData, _ := json.Marshal(data)
  29842. var req *http.Request
  29843. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29844. resp, _ := client.Do(req)
  29845. defer resp.Body.Close()
  29846. body, ioErr := ioutil.ReadAll(resp.Body)
  29847. if ioErr != nil {
  29848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29850. return
  29851. }
  29852. var respJSON map[string]interface{}
  29853. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29856. return
  29857. }
  29858. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29859. if status == "0" {
  29860. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29861. c.ServeSuccessJSON(map[string]interface{}{
  29862. "failed_code": -10,
  29863. "msg": err_msg,
  29864. })
  29865. return
  29866. }
  29867. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29868. userJSONBytes, _ := json.Marshal(respJSON)
  29869. fmt.Println("log")
  29870. fmt.Println(string(userJSONBytes))
  29871. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29872. utils.ErrorLog("解析失败:%v", err)
  29873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29874. return
  29875. }
  29876. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29877. bytesData, _ := json.Marshal(data)
  29878. var req *http.Request
  29879. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29880. resp, _ := client.Do(req)
  29881. defer resp.Body.Close()
  29882. body, ioErr := ioutil.ReadAll(resp.Body)
  29883. if ioErr != nil {
  29884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29886. return
  29887. }
  29888. var respJSON map[string]interface{}
  29889. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29892. return
  29893. }
  29894. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29895. if status == "0" {
  29896. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29897. c.ServeSuccessJSON(map[string]interface{}{
  29898. "failed_code": -10,
  29899. "msg": err_msg,
  29900. })
  29901. return
  29902. }
  29903. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29904. userJSONBytes, _ := json.Marshal(respJSON)
  29905. fmt.Println("log")
  29906. fmt.Println(string(userJSONBytes))
  29907. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29908. utils.ErrorLog("解析失败:%v", err)
  29909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29910. return
  29911. }
  29912. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29913. 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, "", "")
  29914. var dat map[string]interface{}
  29915. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29916. fmt.Println(dat)
  29917. } else {
  29918. fmt.Println(err)
  29919. }
  29920. saveLog(result, request_log, "2204", "上传费用明细")
  29921. userJSONBytes, _ := json.Marshal(dat)
  29922. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29923. utils.ErrorLog("解析失败:%v", err)
  29924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29925. return
  29926. }
  29927. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29928. bytesData, _ := json.Marshal(data)
  29929. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29930. resp, _ := client.Do(req)
  29931. defer resp.Body.Close()
  29932. body, ioErr := ioutil.ReadAll(resp.Body)
  29933. if ioErr != nil {
  29934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29936. return
  29937. }
  29938. var respJSON map[string]interface{}
  29939. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29942. return
  29943. }
  29944. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29945. userJSONBytes, _ := json.Marshal(respJSON)
  29946. fmt.Println("log")
  29947. fmt.Println(string(userJSONBytes))
  29948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29949. utils.ErrorLog("解析失败:%v", err)
  29950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29951. return
  29952. }
  29953. } else {
  29954. if miConfig.MdtrtareaAdmvs == "441202" {
  29955. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29956. if result3101.Infcode == 0 {
  29957. if len(result3101.Output.Result) > 0 {
  29958. var errMsgs []string
  29959. for _, item := range result3101.Output.Result {
  29960. errMsgs = append(errMsgs, item.VolaCont)
  29961. }
  29962. c.ServeSuccessJSON(map[string]interface{}{
  29963. "failed_code": -10,
  29964. "msg": errMsgs,
  29965. })
  29966. return
  29967. } else {
  29968. 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)
  29969. var dat map[string]interface{}
  29970. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29971. fmt.Println(dat)
  29972. } else {
  29973. fmt.Println(err)
  29974. }
  29975. saveLog(result, request_log, "2204", "上传费用明细")
  29976. userJSONBytes, _ := json.Marshal(dat)
  29977. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29978. utils.ErrorLog("解析失败:%v", err)
  29979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29980. return
  29981. }
  29982. }
  29983. } else {
  29984. c.ServeSuccessJSON(map[string]interface{}{
  29985. "failed_code": -10,
  29986. "msg": result3101.ErrMsg,
  29987. })
  29988. return
  29989. }
  29990. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29991. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29992. if result3101.Infcode == 0 {
  29993. if len(result3101.Output.Result) > 0 {
  29994. var errMsgs []string
  29995. for _, item := range result3101.Output.Result {
  29996. errMsgs = append(errMsgs, item.VolaCont)
  29997. }
  29998. c.ServeSuccessJSON(map[string]interface{}{
  29999. "failed_code": -10,
  30000. "msg": errMsgs,
  30001. })
  30002. return
  30003. } else {
  30004. 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)
  30005. var dat map[string]interface{}
  30006. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30007. fmt.Println(dat)
  30008. } else {
  30009. fmt.Println(err)
  30010. }
  30011. saveLog(result, request_log, "2204", "上传费用明细")
  30012. userJSONBytes, _ := json.Marshal(dat)
  30013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30014. utils.ErrorLog("解析失败:%v", err)
  30015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30016. return
  30017. }
  30018. }
  30019. } else {
  30020. c.ServeSuccessJSON(map[string]interface{}{
  30021. "failed_code": -10,
  30022. "msg": result3101.ErrMsg,
  30023. })
  30024. return
  30025. }
  30026. } else {
  30027. if miConfig.Code == "H15049901371" {
  30028. 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)
  30029. var dat map[string]interface{}
  30030. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30031. fmt.Println(dat)
  30032. } else {
  30033. fmt.Println(err)
  30034. }
  30035. saveLog(result, request_log, "2204", "上传费用明细")
  30036. userJSONBytes, _ := json.Marshal(dat)
  30037. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30038. utils.ErrorLog("解析失败:%v", err)
  30039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30040. return
  30041. }
  30042. res.InfRefmsgid = resFour10265.InfRefmsgid
  30043. res.Output = resFour10265.Output
  30044. res.ErrMsg = resFour10265.ErrMsg
  30045. res.Cainfo = resFour10265.Cainfo
  30046. res.WarnMsg = resFour10265.WarnMsg
  30047. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30048. res.Infcode = infocode
  30049. } else {
  30050. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483"{
  30051. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30052. if result3101.Infcode == 0 {
  30053. if len(result3101.Output.Result) > 0 {
  30054. c.ServeSuccessJSON(map[string]interface{}{
  30055. "failed_code": -10,
  30056. "failed_type": 100,
  30057. "warm_type": 1,
  30058. "msg": result3101,
  30059. })
  30060. return
  30061. } else {
  30062. 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)
  30063. var dat map[string]interface{}
  30064. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30065. fmt.Println(dat)
  30066. } else {
  30067. fmt.Println(err)
  30068. }
  30069. saveLog(result, request_log, "2204", "上传费用明细")
  30070. userJSONBytes, _ := json.Marshal(dat)
  30071. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30072. utils.ErrorLog("解析失败:%v", err)
  30073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30074. return
  30075. }
  30076. }
  30077. } else {
  30078. c.ServeSuccessJSON(map[string]interface{}{
  30079. "failed_code": -10,
  30080. "msg": result3101.ErrMsg,
  30081. })
  30082. return
  30083. }
  30084. } else {
  30085. 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)
  30086. var dat map[string]interface{}
  30087. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30088. fmt.Println(dat)
  30089. } else {
  30090. fmt.Println(err)
  30091. }
  30092. saveLog(result, request_log, "2204", "上传费用明细")
  30093. userJSONBytes, _ := json.Marshal(dat)
  30094. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30095. utils.ErrorLog("解析失败:%v", err)
  30096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30097. return
  30098. }
  30099. }
  30100. }
  30101. }
  30102. }
  30103. var total_two float64
  30104. if res.Infcode == -1 {
  30105. errlog := &models.HisOrderError{
  30106. UserOrgId: adminUser.CurrentOrgId,
  30107. Ctime: time.Now().Unix(),
  30108. Mtime: time.Now().Unix(),
  30109. Number: chrg_bchno,
  30110. ErrMsg: res.ErrMsg,
  30111. Status: 1,
  30112. PatientId: id,
  30113. RecordTime: recordDateTime,
  30114. Stage: 4,
  30115. }
  30116. service.CreateErrMsgLog(errlog)
  30117. c.ServeSuccessJSON(map[string]interface{}{
  30118. "failed_code": -10,
  30119. "msg": res.ErrMsg,
  30120. })
  30121. return
  30122. }
  30123. if res.Infcode == 0 {
  30124. order := &models.HisOrder{
  30125. UserOrgId: adminUser.CurrentOrgId,
  30126. HisPatientId: his.ID,
  30127. PatientId: his.PatientId,
  30128. SettleAccountsDate: recordDateTime,
  30129. Ctime: time.Now().Unix(),
  30130. Mtime: time.Now().Unix(),
  30131. MdtrtId: his.Number,
  30132. PsnNo: his.PsnNo,
  30133. MedType: strconv.FormatInt(reg_type, 10),
  30134. Status: 1,
  30135. Number: chrg_bchno,
  30136. Infcode: res.Infcode,
  30137. WarnMsg: res.WarnMsg,
  30138. Cainfo: res.Cainfo,
  30139. ErrMsg: res.ErrMsg,
  30140. RespondTime: res.RefmsgTime,
  30141. InfRefmsgid: res.InfRefmsgid,
  30142. OrderStatus: 1,
  30143. IsMedicineInsurance: 1,
  30144. SettleType: settle_accounts_type,
  30145. SettleStartTime: start_time,
  30146. SettleEndTime: end_time,
  30147. Creator: roles.AdminUserId,
  30148. Modify: roles.AdminUserId,
  30149. PType: 2,
  30150. Diagnosis: diagnosis_id,
  30151. }
  30152. err = service.CreateOrder(order)
  30153. if err != nil {
  30154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30155. return
  30156. }
  30157. for _, item := range res.Output.Result {
  30158. temp := strings.Split(item.FeedetlSn, "-")
  30159. var advice_id int64 = 0
  30160. var project_id int64 = 0
  30161. var types int64 = 0
  30162. id, _ := strconv.ParseInt(temp[2], 10, 64)
  30163. types, _ = strconv.ParseInt(temp[1], 10, 64)
  30164. if temp[1] == "1" {
  30165. advice_id = id
  30166. project_id = 0
  30167. } else if temp[1] == "2" {
  30168. advice_id = 0
  30169. project_id = id
  30170. }
  30171. total_two = total_two + item.DetItemFeeSumamt
  30172. info := &models.HisOrderInfo{
  30173. OrderNumber: order.Number,
  30174. FeedetlSn: item.FeedetlSn,
  30175. UploadDate: time.Now().Unix(),
  30176. AdviceId: advice_id,
  30177. DetItemFeeSumamt: item.DetItemFeeSumamt,
  30178. Cnt: item.Cnt,
  30179. Pric: float64(item.Pric),
  30180. PatientId: his.PatientId,
  30181. PricUplmtAmt: item.PricUplmtAmt,
  30182. SelfpayProp: item.SelfpayProp,
  30183. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  30184. OverlmtAmt: item.OverlmtAmt,
  30185. PreselfpayAmt: item.PreselfpayAmt,
  30186. BasMednFlag: item.BasMednFlag,
  30187. MedChrgitmType: item.MedChrgitmType,
  30188. HiNegoDrugFlag: item.HiNegoDrugFlag,
  30189. Status: 1,
  30190. Memo: item.Memo,
  30191. Mtime: time.Now().Unix(),
  30192. InscpScpAmt: item.InscpScpAmt,
  30193. DrtReimFlag: item.DrtReimFlag,
  30194. Ctime: time.Now().Unix(),
  30195. ListSpItemFlag: item.ListSpItemFlag,
  30196. ChldMedcFlag: item.ChldMedcFlag,
  30197. LmtUsedFlag: item.LmtUsedFlag,
  30198. ChrgitmLv: item.ChrgitmLv,
  30199. UserOrgId: adminUser.CurrentOrgId,
  30200. HisPatientId: his.ID,
  30201. OrderId: order.ID,
  30202. ProjectId: project_id,
  30203. Type: types,
  30204. }
  30205. service.CreateOrderInfo(info)
  30206. }
  30207. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  30208. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  30209. var total float64
  30210. for _, item := range prescriptions {
  30211. if item.Type == 1 { //药品
  30212. for _, subItem := range item.HisDoctorAdviceInfo {
  30213. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  30214. total_one := price * subItem.PrescribingNumber
  30215. fmt.Println("subItem")
  30216. fmt.Println(subItem.Price)
  30217. fmt.Println("price")
  30218. fmt.Println(price)
  30219. fmt.Println("total_one")
  30220. fmt.Println(total_one)
  30221. total = total + total_one
  30222. fmt.Println(total)
  30223. }
  30224. }
  30225. if item.Type == 2 { //项目
  30226. for _, subItem := range item.HisPrescriptionProject {
  30227. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  30228. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  30229. total_one := price * cnt
  30230. total = total + total_one
  30231. }
  30232. }
  30233. }
  30234. allTotal := fmt.Sprintf("%.2f", total)
  30235. if res.Infcode == 0 {
  30236. var rf []*ResultFive
  30237. json.Unmarshal([]byte(his.Iinfo), &rf)
  30238. chrg_bchno := chrg_bchno
  30239. cert_no := his.Certno
  30240. var insutypes []string
  30241. var insutype string
  30242. var is390 int = 0
  30243. var is310 int = 0
  30244. for _, item := range rf {
  30245. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  30246. insutypes = append(insutypes, item.Insutype)
  30247. }
  30248. }
  30249. if len(insutypes) == 1 {
  30250. insutype = insutypes[0]
  30251. } else {
  30252. for _, i := range insutypes {
  30253. if i == "390" {
  30254. is390 = 1
  30255. }
  30256. if i == "310" {
  30257. is310 = 1
  30258. }
  30259. }
  30260. }
  30261. if is390 == 1 {
  30262. insutype = "390"
  30263. }
  30264. if is310 == 1 {
  30265. insutype = "310"
  30266. }
  30267. if len(insutypes) == 0 {
  30268. insutype = "390"
  30269. }
  30270. if len(insutypes) == 2 {
  30271. insutype = strconv.FormatInt(his.SocialType, 10)
  30272. }
  30273. //insutype = "390"
  30274. if his.IdCardType == 1 {
  30275. cert_no = his.MedicalInsuranceNumber
  30276. } else {
  30277. cert_no = his.Certno
  30278. }
  30279. var res ResultSeven
  30280. var ahres ResultSevenAH
  30281. var resSeven10265 ResultSeven10265
  30282. var resSeven10265Two ResultSeven10265Two
  30283. var gzresSeven10265Two GZResultSeven10265Two
  30284. if miConfig.MdtrtareaAdmvs == "421300" {
  30285. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  30286. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30287. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30288. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30289. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30290. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30291. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30292. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30293. resp, requestErr := http.Get(api)
  30294. if requestErr != nil {
  30295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30296. return
  30297. }
  30298. body, ioErr := ioutil.ReadAll(resp.Body)
  30299. if ioErr != nil {
  30300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30302. return
  30303. }
  30304. var respJSON map[string]interface{}
  30305. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30308. return
  30309. }
  30310. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30311. result, _ := json.Marshal(respJSON)
  30312. fmt.Println("log")
  30313. fmt.Println(string(result))
  30314. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30315. utils.ErrorLog("解析失败:%v", err)
  30316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30317. return
  30318. }
  30319. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30320. if reg_type == 11 && his.Insutype == "390" {
  30321. reg_type = 110104
  30322. }
  30323. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30324. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30325. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30326. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30327. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30328. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30329. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30330. resp, requestErr := http.Get(api)
  30331. if requestErr != nil {
  30332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30333. return
  30334. }
  30335. body, ioErr := ioutil.ReadAll(resp.Body)
  30336. if ioErr != nil {
  30337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30339. return
  30340. }
  30341. var respJSON map[string]interface{}
  30342. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30345. return
  30346. }
  30347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30348. result, _ := json.Marshal(respJSON)
  30349. fmt.Println("log")
  30350. fmt.Println(string(result))
  30351. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30352. utils.ErrorLog("解析失败:%v", err)
  30353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30354. return
  30355. }
  30356. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30357. if reg_type == 11 && his.Insutype == "390" {
  30358. reg_type = 110104
  30359. }
  30360. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30361. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30362. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30363. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30364. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30365. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30366. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30367. resp, requestErr := http.Get(api)
  30368. if requestErr != nil {
  30369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30370. return
  30371. }
  30372. body, ioErr := ioutil.ReadAll(resp.Body)
  30373. if ioErr != nil {
  30374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30376. return
  30377. }
  30378. var respJSON map[string]interface{}
  30379. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30382. return
  30383. }
  30384. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30385. result, _ := json.Marshal(respJSON)
  30386. fmt.Println("log")
  30387. fmt.Println(string(result))
  30388. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30389. utils.ErrorLog("解析失败:%v", err)
  30390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30391. return
  30392. }
  30393. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30394. if reg_type == 11 && his.Insutype == "390" {
  30395. reg_type = 110104
  30396. }
  30397. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30398. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30399. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30400. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30401. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30402. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30403. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30404. resp, requestErr := http.Get(api)
  30405. if requestErr != nil {
  30406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30407. return
  30408. }
  30409. body, ioErr := ioutil.ReadAll(resp.Body)
  30410. if ioErr != nil {
  30411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30413. return
  30414. }
  30415. var respJSON map[string]interface{}
  30416. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30419. return
  30420. }
  30421. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30422. result, _ := json.Marshal(respJSON)
  30423. fmt.Println("log")
  30424. fmt.Println(string(result))
  30425. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30426. utils.ErrorLog("解析失败:%v", err)
  30427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30428. return
  30429. }
  30430. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30431. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30432. if result3101.Infcode == "0" {
  30433. if len(result3101.Output.Result) > 0 {
  30434. var errMsgs []string
  30435. for _, item := range result3101.Output.Result {
  30436. errMsgs = append(errMsgs, item.VolaCont)
  30437. }
  30438. c.ServeSuccessJSON(map[string]interface{}{
  30439. "failed_code": -10,
  30440. "msg": errMsgs,
  30441. })
  30442. return
  30443. } else {
  30444. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30445. if his.IdCardType != 4 {
  30446. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30447. bas := strings.Split(psn_info.CardInfo, "|")
  30448. if his.IdCardType == 1 {
  30449. cert_no = bas[2]
  30450. } else {
  30451. cert_no = bas[1]
  30452. }
  30453. } else {
  30454. cert_no = his.Certno
  30455. }
  30456. //江苏地区国家医保医疗类别
  30457. //职工透析:医疗类别选特殊情况门诊9933
  30458. //居民血透门慢: 医疗类别选门诊慢病1402
  30459. //var med_type string
  30460. //if his.Insutype == "310" {
  30461. // if reg_type == 14 {
  30462. // med_type = "9933"
  30463. // } else if reg_type == 11 {
  30464. // med_type = "11"
  30465. //
  30466. // }
  30467. //} else if his.Insutype == "390" {
  30468. // if reg_type == 14 {
  30469. // med_type = "1402"
  30470. // } else if reg_type == 11 {
  30471. // med_type = "11"
  30472. // }
  30473. //}
  30474. var api string
  30475. if miConfig.MdtrtareaAdmvs == "320921" {
  30476. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30477. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30478. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30479. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30480. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30481. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30482. "&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
  30483. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30484. } else {
  30485. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30486. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30487. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30488. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30489. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30490. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30491. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30492. "&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
  30493. }
  30494. resp, requestErr := http.Get(api)
  30495. if requestErr != nil {
  30496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30497. return
  30498. }
  30499. body, ioErr := ioutil.ReadAll(resp.Body)
  30500. if ioErr != nil {
  30501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30503. return
  30504. }
  30505. var respJSON map[string]interface{}
  30506. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30509. return
  30510. }
  30511. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30512. result, _ := json.Marshal(respJSON)
  30513. fmt.Println("log")
  30514. fmt.Println(string(result))
  30515. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  30516. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30517. utils.ErrorLog("解析失败:%v", err)
  30518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30519. return
  30520. }
  30521. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30522. res.Output = resSeven10265.Output
  30523. res.ErrMsg = resSeven10265.ErrMsg
  30524. res.Cainfo = resSeven10265.Cainfo
  30525. res.WarnMsg = resSeven10265.WarnMsg
  30526. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30527. res.Infcode = infocode
  30528. } else {
  30529. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  30530. utils.ErrorLog("解析失败:%v", err)
  30531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30532. return
  30533. }
  30534. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  30535. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  30536. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  30537. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  30538. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30539. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  30540. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  30541. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  30542. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  30543. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  30544. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  30545. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30546. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  30547. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  30548. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30549. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30550. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  30551. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  30552. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  30553. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  30554. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  30555. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30556. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  30557. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  30558. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  30559. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  30560. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  30561. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  30562. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  30563. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  30564. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30565. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  30566. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  30567. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  30568. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30569. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30570. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30571. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30572. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  30573. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30574. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  30575. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  30576. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  30577. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  30578. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  30579. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  30580. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  30581. res.ErrMsg = resSeven10265Two.ErrMsg
  30582. res.Cainfo = resSeven10265Two.Cainfo
  30583. res.WarnMsg = resSeven10265Two.WarnMsg
  30584. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30585. res.Infcode = infocode
  30586. }
  30587. }
  30588. }
  30589. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30590. psn_info, _ := service.GetPsnByPatientId(id)
  30591. var verify_number string
  30592. if psn_info.IdCardType == 4 {
  30593. verify_number = psn_info.VerifyNumber
  30594. } else if psn_info.IdCardType == 1 {
  30595. bas := strings.Split(psn_info.CardInfo, "|")
  30596. cardNumber := bas[2]
  30597. verify_number = cardNumber
  30598. } else {
  30599. psn_info.IdCardType = 2
  30600. verify_number = psn_info.Certno
  30601. }
  30602. var api string
  30603. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30604. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  30605. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30606. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30607. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  30608. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30609. "&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
  30610. resp, requestErr := http.Get(api)
  30611. if requestErr != nil {
  30612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30613. return
  30614. }
  30615. body, ioErr := ioutil.ReadAll(resp.Body)
  30616. if ioErr != nil {
  30617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30619. return
  30620. }
  30621. var respJSON map[string]interface{}
  30622. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30625. return
  30626. }
  30627. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30628. result, _ := json.Marshal(respJSON)
  30629. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30630. utils.ErrorLog("解析失败:%v", err)
  30631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30632. return
  30633. }
  30634. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30635. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  30636. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  30637. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30638. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  30639. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  30640. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  30641. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  30642. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  30643. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  30644. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  30645. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  30646. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  30647. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30648. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  30649. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  30650. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  30651. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  30652. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  30653. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  30654. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30655. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  30656. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  30657. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  30658. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  30659. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  30660. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  30661. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  30662. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  30663. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  30664. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  30665. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  30666. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  30667. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  30668. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30669. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  30670. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  30671. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  30672. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  30673. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  30674. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  30675. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30676. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30677. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30678. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30679. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30680. res.ErrMsg = resSeven10265.ErrMsg
  30681. res.Cainfo = resSeven10265.Cainfo
  30682. res.WarnMsg = resSeven10265.WarnMsg
  30683. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30684. res.Infcode = infocode
  30685. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30686. acct_used_flag := "1"
  30687. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30688. var result string
  30689. var request_log string
  30690. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30691. 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)
  30692. } else {
  30693. 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)
  30694. }
  30695. var dat map[string]interface{}
  30696. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30697. fmt.Println(dat)
  30698. } else {
  30699. fmt.Println(err)
  30700. }
  30701. saveLog(result, request_log, "2206", "预结算")
  30702. userJSONBytes, _ := json.Marshal(dat)
  30703. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30704. utils.ErrorLog("解析失败:%v", err)
  30705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30706. return
  30707. }
  30708. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30709. var result string
  30710. var request_log string
  30711. if his.IdCardType == 2 {
  30712. insutype = strconv.FormatInt(his.SocialType, 10)
  30713. 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, "")
  30714. } else if his.IdCardType == 1 {
  30715. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30716. bas := strings.Split(psn_info.CardInfo, "|")
  30717. basNumber := bas[2]
  30718. card_sn := bas[3]
  30719. var rf []*ResultFive
  30720. json.Unmarshal([]byte(his.Iinfo), &rf)
  30721. var psn_type string
  30722. for _, item := range rf {
  30723. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30724. psn_type = item.PsnType
  30725. }
  30726. }
  30727. insutype = strconv.FormatInt(his.SocialType, 10)
  30728. 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)
  30729. } else {
  30730. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30731. //bas := strings.Split(psn_info.CardInfo, "|")
  30732. //basNumber := bas[2]
  30733. //card_sn := bas[3]
  30734. var rf []*ResultFive
  30735. json.Unmarshal([]byte(his.Iinfo), &rf)
  30736. var psn_type string
  30737. for _, item := range rf {
  30738. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30739. psn_type = item.PsnType
  30740. }
  30741. }
  30742. insutype = strconv.FormatInt(his.SocialType, 10)
  30743. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30744. 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)
  30745. }
  30746. var dat map[string]interface{}
  30747. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30748. fmt.Println(dat)
  30749. } else {
  30750. fmt.Println(err)
  30751. }
  30752. saveLog(result, request_log, "2206", "预结算")
  30753. userJSONBytes, _ := json.Marshal(dat)
  30754. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30755. utils.ErrorLog("解析失败:%v", err)
  30756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30757. return
  30758. }
  30759. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30760. var result string
  30761. var request_log string
  30762. if his.IdCardType == 2 {
  30763. insutype = strconv.FormatInt(his.SocialType, 10)
  30764. 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, "")
  30765. } else if his.IdCardType == 1 {
  30766. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30767. bas := strings.Split(psn_info.CardInfo, "|")
  30768. basNumber := bas[0]
  30769. card_sn := ""
  30770. var rf []*ResultFive
  30771. json.Unmarshal([]byte(his.Iinfo), &rf)
  30772. var psn_type string
  30773. for _, item := range rf {
  30774. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30775. psn_type = item.PsnType
  30776. }
  30777. }
  30778. insutype = strconv.FormatInt(his.SocialType, 10)
  30779. 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)
  30780. } else {
  30781. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30782. //bas := strings.Split(psn_info.CardInfo, "|")
  30783. //basNumber := bas[2]
  30784. //card_sn := bas[3]
  30785. var rf []*ResultFive
  30786. json.Unmarshal([]byte(his.Iinfo), &rf)
  30787. var psn_type string
  30788. for _, item := range rf {
  30789. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30790. psn_type = item.PsnType
  30791. }
  30792. }
  30793. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30794. 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)
  30795. }
  30796. var dat map[string]interface{}
  30797. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30798. fmt.Println(dat)
  30799. } else {
  30800. fmt.Println(err)
  30801. }
  30802. saveLog(result, request_log, "2206", "预结算")
  30803. userJSONBytes, _ := json.Marshal(dat)
  30804. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30805. utils.ErrorLog("解析失败:%v", err)
  30806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30807. return
  30808. }
  30809. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30810. var result string
  30811. var request_log string
  30812. if his.IdCardType == 2 {
  30813. insutype = strconv.FormatInt(his.SocialType, 10)
  30814. 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, "")
  30815. } else if his.IdCardType == 1 {
  30816. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30817. bas := strings.Split(psn_info.CardInfo, "|")
  30818. basNumber := bas[0]
  30819. card_sn := ""
  30820. var rf []*ResultFive
  30821. json.Unmarshal([]byte(his.Iinfo), &rf)
  30822. var psn_type string
  30823. for _, item := range rf {
  30824. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30825. psn_type = item.PsnType
  30826. }
  30827. }
  30828. insutype = strconv.FormatInt(his.SocialType, 10)
  30829. 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)
  30830. } else {
  30831. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30832. //bas := strings.Split(psn_info.CardInfo, "|")
  30833. //basNumber := bas[2]
  30834. //card_sn := bas[3]
  30835. var rf []*ResultFive
  30836. json.Unmarshal([]byte(his.Iinfo), &rf)
  30837. var psn_type string
  30838. for _, item := range rf {
  30839. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30840. psn_type = item.PsnType
  30841. }
  30842. }
  30843. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30844. 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)
  30845. }
  30846. var dat map[string]interface{}
  30847. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30848. fmt.Println(dat)
  30849. } else {
  30850. fmt.Println(err)
  30851. }
  30852. saveLog(result, request_log, "2206", "预结算")
  30853. userJSONBytes, _ := json.Marshal(dat)
  30854. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30855. utils.ErrorLog("解析失败:%v", err)
  30856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30857. return
  30858. }
  30859. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30860. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30861. if his.IdCardType == 4 {
  30862. psn_info.VerifyNumber = psn_info.VerifyNumber
  30863. cert_no = psn_info.VerifyNumber
  30864. } else if his.IdCardType == 2 {
  30865. cert_no = psn_info.Certno
  30866. psn_info.VerifyNumber = psn_info.Certno
  30867. } else {
  30868. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30869. bas := strings.Split(psn_info.CardInfo, "|")
  30870. if his.IdCardType == 1 {
  30871. cert_no = bas[2]
  30872. } else {
  30873. cert_no = bas[1]
  30874. }
  30875. }
  30876. var api string
  30877. var med_type string
  30878. if his.Insutype == "390" {
  30879. if reg_type == 992102 {
  30880. med_type = "992102"
  30881. }
  30882. if reg_type == 140104 {
  30883. med_type = "140104"
  30884. }
  30885. if reg_type == 140201 {
  30886. med_type = "140201"
  30887. }
  30888. if reg_type == 14 {
  30889. med_type = "140104"
  30890. }
  30891. } else if his.Insutype == "310" {
  30892. if reg_type == 992102 {
  30893. med_type = "992102"
  30894. }
  30895. if reg_type == 140104 {
  30896. med_type = "140104"
  30897. }
  30898. if reg_type == 140201 {
  30899. med_type = "140201"
  30900. }
  30901. if reg_type == 14 {
  30902. med_type = "140104"
  30903. }
  30904. }
  30905. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30906. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30907. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30908. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30909. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30910. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30911. "&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
  30912. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30913. resp, requestErr := http.Get(api)
  30914. if requestErr != nil {
  30915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30916. return
  30917. }
  30918. body, ioErr := ioutil.ReadAll(resp.Body)
  30919. if ioErr != nil {
  30920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30922. return
  30923. }
  30924. var respJSON map[string]interface{}
  30925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30928. return
  30929. }
  30930. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30931. if status == "0" {
  30932. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30933. c.ServeSuccessJSON(map[string]interface{}{
  30934. "failed_code": -10,
  30935. "msg": err_msg,
  30936. })
  30937. return
  30938. }
  30939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30940. result, _ := json.Marshal(respJSON)
  30941. fmt.Println("log")
  30942. fmt.Println(string(result))
  30943. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30944. utils.ErrorLog("解析失败:%v", err)
  30945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30946. return
  30947. }
  30948. res.InfRefmsgid = ahres.InfRefmsgid
  30949. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30950. // 创建对应的Time类型
  30951. t := time.UnixMilli(timestamp)
  30952. // 格式化成指定的日期字符串
  30953. str := t.Format("2006-01-02 15:04:05")
  30954. res.Output.Setlinfo.SetlTime = str
  30955. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30956. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30957. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30958. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30959. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30960. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30961. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30962. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30963. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30964. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30965. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30966. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30967. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30968. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30969. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30970. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30971. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30972. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30973. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30974. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30975. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30976. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30977. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30978. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30979. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30980. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30981. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30982. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30983. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30984. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30985. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30986. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30987. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30988. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30989. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30990. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30991. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30992. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30993. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30994. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30995. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30996. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30997. //res.Output.Setldetail = ahres.Output.Setldetail
  30998. res.ErrMsg = ahres.ErrMsg
  30999. res.Cainfo = ahres.Cainfo
  31000. res.WarnMsg = ahres.WarnMsg
  31001. res.Infcode = ahres.Infcode
  31002. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31003. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31004. if his.IdCardType == 4 {
  31005. psn_info.VerifyNumber = psn_info.VerifyNumber
  31006. cert_no = psn_info.Certno
  31007. } else if his.IdCardType == 2 {
  31008. cert_no = psn_info.Certno
  31009. psn_info.VerifyNumber = psn_info.Certno
  31010. } else {
  31011. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31012. bas := strings.Split(psn_info.CardInfo, "|")
  31013. if his.IdCardType == 1 {
  31014. cert_no = bas[2]
  31015. } else {
  31016. cert_no = bas[1]
  31017. }
  31018. }
  31019. var api string
  31020. var med_type string
  31021. if his.Insutype == "390" {
  31022. if reg_type == 992102 {
  31023. med_type = "992102"
  31024. }
  31025. if reg_type == 140104 {
  31026. med_type = "140104"
  31027. }
  31028. if reg_type == 140201 {
  31029. med_type = "140201"
  31030. }
  31031. if reg_type == 14 {
  31032. med_type = "14"
  31033. }
  31034. } else if his.Insutype == "310" {
  31035. if reg_type == 992102 {
  31036. med_type = "992102"
  31037. }
  31038. if reg_type == 140104 {
  31039. med_type = "140104"
  31040. }
  31041. if reg_type == 140201 {
  31042. med_type = "140201"
  31043. }
  31044. if reg_type == 14 {
  31045. med_type = "14"
  31046. }
  31047. }
  31048. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31049. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31050. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31051. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31052. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31053. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31054. "&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
  31055. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31056. resp, requestErr := http.Get(api)
  31057. if requestErr != nil {
  31058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31059. return
  31060. }
  31061. body, ioErr := ioutil.ReadAll(resp.Body)
  31062. if ioErr != nil {
  31063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31065. return
  31066. }
  31067. var respJSON map[string]interface{}
  31068. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31071. return
  31072. }
  31073. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31074. if status == "0" {
  31075. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31076. c.ServeSuccessJSON(map[string]interface{}{
  31077. "failed_code": -10,
  31078. "msg": err_msg,
  31079. })
  31080. return
  31081. }
  31082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31083. result, _ := json.Marshal(respJSON)
  31084. fmt.Println("log")
  31085. fmt.Println(string(result))
  31086. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  31087. utils.ErrorLog("解析失败:%v", err)
  31088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31089. return
  31090. }
  31091. res.InfRefmsgid = ahres.InfRefmsgid
  31092. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31093. // 创建对应的Time类型
  31094. t := time.UnixMilli(timestamp)
  31095. // 格式化成指定的日期字符串
  31096. str := t.Format("2006-01-02 15:04:05")
  31097. res.Output.Setlinfo.SetlTime = str
  31098. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31099. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31100. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31101. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31102. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31103. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31104. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31105. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31106. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31107. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31108. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31109. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31110. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31111. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31112. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31113. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31114. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31115. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31116. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31117. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31118. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31119. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31120. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31121. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31122. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31123. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31124. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31125. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31126. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31127. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31128. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31129. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31130. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31131. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  31132. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31133. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  31134. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  31135. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  31136. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  31137. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31138. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  31139. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31140. //res.Output.Setldetail = ahres.Output.Setldetail
  31141. res.ErrMsg = ahres.ErrMsg
  31142. res.Cainfo = ahres.Cainfo
  31143. res.WarnMsg = ahres.WarnMsg
  31144. res.Infcode = ahres.Infcode
  31145. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31146. var result string
  31147. var request_log string
  31148. if his.IdCardType == 2 {
  31149. 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")
  31150. } else if his.IdCardType == 1 {
  31151. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31152. bas := strings.Split(psn_info.CardInfo, "|")
  31153. basNumber := bas[2]
  31154. card_sn := bas[3]
  31155. 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")
  31156. } else {
  31157. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31158. 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")
  31159. }
  31160. var dat map[string]interface{}
  31161. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31162. fmt.Println(dat)
  31163. } else {
  31164. fmt.Println(err)
  31165. }
  31166. saveLog(result, request_log, "2206", "预结算")
  31167. userJSONBytes, _ := json.Marshal(dat)
  31168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31169. utils.ErrorLog("解析失败:%v", err)
  31170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31171. return
  31172. }
  31173. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31174. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31175. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31176. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31177. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31178. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31179. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31180. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31181. resp, requestErr := http.Get(api)
  31182. if requestErr != nil {
  31183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31184. return
  31185. }
  31186. body, ioErr := ioutil.ReadAll(resp.Body)
  31187. if ioErr != nil {
  31188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31190. return
  31191. }
  31192. var respJSON map[string]interface{}
  31193. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31196. return
  31197. }
  31198. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31199. result, _ := json.Marshal(respJSON)
  31200. fmt.Println("log")
  31201. fmt.Println(string(result))
  31202. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31203. utils.ErrorLog("解析失败:%v", err)
  31204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31205. return
  31206. }
  31207. } else {
  31208. if miConfig.MdtrtareaAdmvs == "441202" {
  31209. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31210. if result3101.Infcode == 0 {
  31211. if len(result3101.Output.Result) > 0 {
  31212. c.ServeSuccessJSON(map[string]interface{}{
  31213. "failed_code": -10,
  31214. "failed_type": 100,
  31215. "msg": result3101.Output.Result,
  31216. })
  31217. return
  31218. } else {
  31219. var result string
  31220. var request_log string
  31221. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31222. allTotal = fmt.Sprintf("%.2f", total_two)
  31223. if his.IdCardType == 4 {
  31224. 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)
  31225. } else {
  31226. 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)
  31227. }
  31228. var dat map[string]interface{}
  31229. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31230. fmt.Println(dat)
  31231. } else {
  31232. fmt.Println(err)
  31233. }
  31234. saveLog(result, request_log, "2206", "预结算")
  31235. //userJSONBytes, _ := json.Marshal(dat)
  31236. //
  31237. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31238. // utils.ErrorLog("解析失败:%v", err)
  31239. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31240. // return
  31241. //}
  31242. userJSONBytes, _ := json.Marshal(dat)
  31243. if miConfig.Code == "H15049901371" {
  31244. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  31245. utils.ErrorLog("解析失败:%v", err)
  31246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31247. return
  31248. }
  31249. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31250. res.Output = resSeven10265.Output
  31251. res.ErrMsg = resSeven10265.ErrMsg
  31252. res.Cainfo = resSeven10265.Cainfo
  31253. res.WarnMsg = resSeven10265.WarnMsg
  31254. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31255. res.Infcode = infocode
  31256. } else {
  31257. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31258. utils.ErrorLog("解析失败:%v", err)
  31259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31260. return
  31261. }
  31262. }
  31263. }
  31264. } else {
  31265. c.ServeSuccessJSON(map[string]interface{}{
  31266. "failed_code": -10,
  31267. "msg": result3101.ErrMsg,
  31268. })
  31269. return
  31270. }
  31271. } else if miConfig.MdtrtareaAdmvs == "440205" {
  31272. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31273. if result3101.Infcode == 0 {
  31274. if len(result3101.Output.Result) > 0 {
  31275. var errMsgs []string
  31276. for _, item := range result3101.Output.Result {
  31277. errMsgs = append(errMsgs, item.VolaCont)
  31278. }
  31279. c.ServeSuccessJSON(map[string]interface{}{
  31280. "failed_code": -10,
  31281. "msg": errMsgs,
  31282. })
  31283. return
  31284. } else {
  31285. var result string
  31286. var request_log string
  31287. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31288. allTotal = fmt.Sprintf("%.2f", total_two)
  31289. if his.IdCardType == 4 {
  31290. 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)
  31291. } else {
  31292. 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)
  31293. }
  31294. var dat map[string]interface{}
  31295. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31296. fmt.Println(dat)
  31297. } else {
  31298. fmt.Println(err)
  31299. }
  31300. saveLog(result, request_log, "2206", "预结算")
  31301. //userJSONBytes, _ := json.Marshal(dat)
  31302. //
  31303. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31304. // utils.ErrorLog("解析失败:%v", err)
  31305. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31306. // return
  31307. //}
  31308. userJSONBytes, _ := json.Marshal(dat)
  31309. if miConfig.Code == "H15049901371" {
  31310. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  31311. utils.ErrorLog("解析失败:%v", err)
  31312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31313. return
  31314. }
  31315. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31316. res.Output = resSeven10265.Output
  31317. res.ErrMsg = resSeven10265.ErrMsg
  31318. res.Cainfo = resSeven10265.Cainfo
  31319. res.WarnMsg = resSeven10265.WarnMsg
  31320. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31321. res.Infcode = infocode
  31322. } else {
  31323. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31324. utils.ErrorLog("解析失败:%v", err)
  31325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31326. return
  31327. }
  31328. }
  31329. }
  31330. } else {
  31331. c.ServeSuccessJSON(map[string]interface{}{
  31332. "failed_code": -10,
  31333. "msg": result3101.ErrMsg,
  31334. })
  31335. return
  31336. }
  31337. } else {
  31338. var result string
  31339. var request_log string
  31340. var dat map[string]interface{}
  31341. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31342. allTotal = fmt.Sprintf("%.2f", total_two)
  31343. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" {
  31344. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31345. if result3101.Infcode == 0 {
  31346. if len(result3101.Output.Result) > 0 {
  31347. c.ServeSuccessJSON(map[string]interface{}{
  31348. "failed_code": -10,
  31349. "failed_type": 100,
  31350. "warm_type": 2,
  31351. "msg": result3101,
  31352. })
  31353. return
  31354. } else {
  31355. var result string
  31356. var request_log string
  31357. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31358. allTotal = fmt.Sprintf("%.2f", total_two)
  31359. if his.IdCardType == 4 {
  31360. 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)
  31361. } else {
  31362. if his.IdCardType == 2 {
  31363. cert_no = psn_info.Certno
  31364. psn_info.VerifyNumber = psn_info.Certno
  31365. } else {
  31366. bas := strings.Split(psn_info.CardInfo, "|")
  31367. cert_no = bas[2]
  31368. }
  31369. 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)
  31370. }
  31371. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31372. fmt.Println(dat)
  31373. } else {
  31374. fmt.Println(err)
  31375. }
  31376. saveLog(result, request_log, "2206", "预结算")
  31377. }
  31378. } else {
  31379. c.ServeSuccessJSON(map[string]interface{}{
  31380. "failed_code": -10,
  31381. "msg": result3101.ErrMsg,
  31382. })
  31383. return
  31384. }
  31385. } else {
  31386. if his.IdCardType == 4 {
  31387. 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)
  31388. } else {
  31389. if his.IdCardType == 2 {
  31390. cert_no = psn_info.Certno
  31391. psn_info.VerifyNumber = psn_info.Certno
  31392. } else {
  31393. bas := strings.Split(psn_info.CardInfo, "|")
  31394. cert_no = bas[2]
  31395. }
  31396. 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)
  31397. }
  31398. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31399. fmt.Println(dat)
  31400. } else {
  31401. fmt.Println(err)
  31402. }
  31403. saveLog(result, request_log, "2206", "预结算")
  31404. }
  31405. //userJSONBytes, _ := json.Marshal(dat)
  31406. //
  31407. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31408. // utils.ErrorLog("解析失败:%v", err)
  31409. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31410. // return
  31411. //}
  31412. userJSONBytes, _ := json.Marshal(dat)
  31413. if miConfig.Code == "H15049901371" {
  31414. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  31415. utils.ErrorLog("解析失败:%v", err)
  31416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31417. return
  31418. }
  31419. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31420. res.Output = resSeven10265.Output
  31421. res.ErrMsg = resSeven10265.ErrMsg
  31422. res.Cainfo = resSeven10265.Cainfo
  31423. res.WarnMsg = resSeven10265.WarnMsg
  31424. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31425. res.Infcode = infocode
  31426. } else {
  31427. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31428. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  31429. utils.ErrorLog("解析失败:%v", err)
  31430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31431. return
  31432. }
  31433. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  31434. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  31435. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  31436. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  31437. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  31438. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  31439. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  31440. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31441. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  31442. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31443. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31444. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31445. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31446. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  31447. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31448. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  31449. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  31450. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  31451. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  31452. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  31453. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31454. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  31455. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  31456. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  31457. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  31458. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  31459. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  31460. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  31461. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  31462. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31463. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  31464. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  31465. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  31466. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31467. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31468. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31469. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31470. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  31471. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31472. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  31473. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  31474. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  31475. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  31476. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  31477. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  31478. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  31479. res.ErrMsg = gzresSeven10265Two.ErrMsg
  31480. res.Cainfo = gzresSeven10265Two.Cainfo
  31481. res.WarnMsg = gzresSeven10265Two.WarnMsg
  31482. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31483. //res.Infcode = infocode
  31484. } else {
  31485. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31486. utils.ErrorLog("解析失败:%v", err)
  31487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31488. return
  31489. }
  31490. }
  31491. }
  31492. }
  31493. }
  31494. utils.ErrorLog("解析失败:%v", res.Infcode)
  31495. if res.Infcode == -1 {
  31496. errlog := &models.HisOrderError{
  31497. UserOrgId: adminUser.CurrentOrgId,
  31498. Ctime: time.Now().Unix(),
  31499. Mtime: time.Now().Unix(),
  31500. Number: chrg_bchno,
  31501. ErrMsg: res.ErrMsg,
  31502. Status: 1,
  31503. PatientId: id,
  31504. RecordTime: recordDateTime,
  31505. Stage: 20,
  31506. }
  31507. service.CreateErrMsgLog(errlog)
  31508. c.ServeSuccessJSON(map[string]interface{}{
  31509. "failed_code": -10,
  31510. "msg": res.ErrMsg,
  31511. })
  31512. return
  31513. }
  31514. if res.Infcode != 0 {
  31515. errlog := &models.HisOrderError{
  31516. UserOrgId: adminUser.CurrentOrgId,
  31517. Ctime: time.Now().Unix(),
  31518. Mtime: time.Now().Unix(),
  31519. Number: chrg_bchno,
  31520. ErrMsg: res.ErrMsg,
  31521. Status: 1,
  31522. PatientId: id,
  31523. RecordTime: recordDateTime,
  31524. Stage: 20,
  31525. }
  31526. service.CreateErrMsgLog(errlog)
  31527. c.ServeSuccessJSON(map[string]interface{}{
  31528. "failed_code": -10,
  31529. "msg": res.ErrMsg,
  31530. })
  31531. return
  31532. } else {
  31533. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  31534. order.OrderStatus = 1
  31535. order.IsPre = 1
  31536. order.Status = 1
  31537. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  31538. order.SetlId = res.Output.Setlinfo.SetlID
  31539. order.PsnNo = res.Output.Setlinfo.PsnNo
  31540. order.PsnName = res.Output.Setlinfo.PsnName
  31541. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  31542. order.Certno = res.Output.Setlinfo.Certno
  31543. order.Gend = res.Output.Setlinfo.Gend
  31544. order.Naty = res.Output.Setlinfo.Naty
  31545. order.Age = res.Output.Setlinfo.Age
  31546. order.Insutype = res.Output.Setlinfo.Insutype
  31547. order.PsnType = res.Output.Setlinfo.PsnType
  31548. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  31549. order.SetlTime = res.Output.Setlinfo.SetlTime
  31550. order.AcctUsedFlag = acct_used_flag
  31551. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  31552. if res.Output.Setlinfo.MedType == "140101" {
  31553. order.MedType = "14"
  31554. } else {
  31555. if res.Output.Setlinfo.MedType == "110104" {
  31556. order.MedType = "11"
  31557. } else {
  31558. order.MedType = res.Output.Setlinfo.MedType
  31559. }
  31560. }
  31561. if res.Output.Setlinfo.MedType == "992102" {
  31562. order.MedType = "992102"
  31563. }
  31564. if res.Output.Setlinfo.MedType == "140104" {
  31565. order.MedType = "140104"
  31566. }
  31567. if res.Output.Setlinfo.MedType == "140201" {
  31568. order.MedType = "140201"
  31569. }
  31570. if res.Output.Setlinfo.MedType == "14" {
  31571. order.MedType = "14"
  31572. }
  31573. if reg_type == 1112 {
  31574. order.MedType = "1112"
  31575. }
  31576. if reg_type == 1111 {
  31577. order.MedType = "1111"
  31578. }
  31579. order.ClrType = res.Output.Setlinfo.ClrType
  31580. if adminUser.CurrentOrgId == 10480 {
  31581. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  31582. order.ClrType = "11"
  31583. } else {
  31584. order.ClrType = "9903"
  31585. }
  31586. }
  31587. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  31588. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  31589. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  31590. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  31591. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  31592. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  31593. order.HifpPay = res.Output.Setlinfo.HifpPay
  31594. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  31595. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  31596. order.HifesPay = res.Output.Setlinfo.HifesPay
  31597. order.HifobPay = res.Output.Setlinfo.HifobPay
  31598. order.MafPay = res.Output.Setlinfo.MafPay
  31599. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  31600. order.OthPay = res.Output.Setlinfo.OthPay
  31601. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  31602. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  31603. order.AcctPay = res.Output.Setlinfo.AcctPay
  31604. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  31605. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  31606. order.Balc = res.Output.Setlinfo.Balc
  31607. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  31608. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  31609. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  31610. order.ClrWay = res.Output.Setlinfo.ClrWay
  31611. order.Creator = order.Creator
  31612. order.Modify = roles.AdminUserId
  31613. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  31614. //detailStr := string(setlDetail)
  31615. //order.SetlDetail = detailStr
  31616. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  31617. err = service.UpDateOrder(order)
  31618. if err == nil {
  31619. c.ServeSuccessJSON(map[string]interface{}{
  31620. "msg": "预结算成功",
  31621. })
  31622. } else {
  31623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  31624. return
  31625. }
  31626. }
  31627. } else {
  31628. adminUser := c.GetAdminUserInfo()
  31629. errlog := &models.HisOrderError{
  31630. UserOrgId: adminUser.CurrentOrgId,
  31631. Ctime: time.Now().Unix(),
  31632. Mtime: time.Now().Unix(),
  31633. ErrMsg: res.ErrMsg,
  31634. Status: 1,
  31635. PatientId: id,
  31636. RecordTime: recordDateTime,
  31637. Stage: 4,
  31638. }
  31639. service.CreateErrMsgLog(errlog)
  31640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  31641. return
  31642. }
  31643. } else {
  31644. if miConfig.MdtrtareaAdmvs == "150499" {
  31645. order := &models.HisOrder{
  31646. UserOrgId: adminUser.CurrentOrgId,
  31647. HisPatientId: his.ID,
  31648. PatientId: his.PatientId,
  31649. SettleAccountsDate: recordDateTime,
  31650. Ctime: time.Now().Unix(),
  31651. Mtime: time.Now().Unix(),
  31652. MdtrtId: his.Number,
  31653. PsnNo: his.PsnNo,
  31654. MedType: strconv.FormatInt(reg_type, 10),
  31655. Status: 1,
  31656. Number: chrg_bchno,
  31657. Infcode: res.Infcode,
  31658. WarnMsg: res.WarnMsg,
  31659. Cainfo: res.Cainfo,
  31660. ErrMsg: res.ErrMsg,
  31661. RespondTime: res.RefmsgTime,
  31662. InfRefmsgid: res.InfRefmsgid,
  31663. OrderStatus: 1,
  31664. IsMedicineInsurance: 1,
  31665. SettleType: settle_accounts_type,
  31666. SettleStartTime: start_time,
  31667. SettleEndTime: end_time,
  31668. Creator: roles.AdminUserId,
  31669. Modify: roles.AdminUserId,
  31670. PType: 2,
  31671. Diagnosis: diagnosis_id,
  31672. }
  31673. err = service.CreateOrder(order)
  31674. if err != nil {
  31675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31676. return
  31677. }
  31678. }
  31679. adminUser := c.GetAdminUserInfo()
  31680. errlog := &models.HisOrderError{
  31681. UserOrgId: adminUser.CurrentOrgId,
  31682. Ctime: time.Now().Unix(),
  31683. Mtime: time.Now().Unix(),
  31684. ErrMsg: res.ErrMsg,
  31685. Status: 1,
  31686. PatientId: id,
  31687. RecordTime: recordDateTime,
  31688. Stage: 4,
  31689. }
  31690. service.CreateErrMsgLog(errlog)
  31691. c.ServeSuccessJSON(map[string]interface{}{
  31692. "failed_code": -10,
  31693. "msg": res.ErrMsg,
  31694. })
  31695. return
  31696. }
  31697. }
  31698. }
  31699. }
  31700. // 退款
  31701. func (c *HisApiController) Refund() {
  31702. order_id, _ := c.GetInt64("order_id")
  31703. admin_user_id, _ := c.GetInt64("admin_user_id")
  31704. adminUser := c.GetAdminUserInfo()
  31705. var order models.HisOrder
  31706. order, _ = service.GetHisOrderByID(order_id)
  31707. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  31708. if fapiao.ID > 0 {
  31709. c.ServeSuccessJSON(map[string]interface{}{
  31710. "failed_code": -10,
  31711. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  31712. })
  31713. return
  31714. }
  31715. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31716. if order.ID == 0 {
  31717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31718. return
  31719. }
  31720. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31721. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31722. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31723. if config.IsOpen == 1 { //对接了医保,走医保流程
  31724. var res ResultSixteen
  31725. var ahres ResultSevenAH
  31726. var resSixteen10265 ResultSixteen10265
  31727. var resSixteen10265Two ResultSixteen10265Two
  31728. var gz ResultgzSixteen10265Two
  31729. var src_resquest string
  31730. var result string
  31731. if miConfig.MdtrtareaAdmvs == "421300" {
  31732. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31733. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31734. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31735. resp3, requestErr3 := http.Get(api3)
  31736. if requestErr3 != nil {
  31737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31738. return
  31739. }
  31740. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31741. if ioErr3 != nil {
  31742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31744. return
  31745. }
  31746. var respJSON3 map[string]interface{}
  31747. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31750. return
  31751. }
  31752. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31753. userJSONBytes3, _ := json.Marshal(respJSON3)
  31754. fmt.Println("log")
  31755. fmt.Println(string(userJSONBytes3))
  31756. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31757. utils.ErrorLog("解析失败:%v", err)
  31758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31759. return
  31760. }
  31761. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31762. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31763. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31764. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31765. resp3, requestErr3 := http.Get(api3)
  31766. if requestErr3 != nil {
  31767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31768. return
  31769. }
  31770. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31771. if ioErr3 != nil {
  31772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31774. return
  31775. }
  31776. var respJSON3 map[string]interface{}
  31777. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31780. return
  31781. }
  31782. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31783. userJSONBytes3, _ := json.Marshal(respJSON3)
  31784. fmt.Println("log")
  31785. fmt.Println(string(userJSONBytes3))
  31786. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31787. utils.ErrorLog("解析失败:%v", err)
  31788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31789. return
  31790. }
  31791. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31792. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31793. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31794. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31795. resp3, requestErr3 := http.Get(api3)
  31796. if requestErr3 != nil {
  31797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31798. return
  31799. }
  31800. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31801. if ioErr3 != nil {
  31802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31804. return
  31805. }
  31806. var respJSON3 map[string]interface{}
  31807. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31810. return
  31811. }
  31812. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31813. userJSONBytes3, _ := json.Marshal(respJSON3)
  31814. fmt.Println("log")
  31815. fmt.Println(string(userJSONBytes3))
  31816. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31817. utils.ErrorLog("解析失败:%v", err)
  31818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31819. return
  31820. }
  31821. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31822. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31823. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31824. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31825. resp3, requestErr3 := http.Get(api3)
  31826. if requestErr3 != nil {
  31827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31828. return
  31829. }
  31830. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31831. if ioErr3 != nil {
  31832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31834. return
  31835. }
  31836. var respJSON3 map[string]interface{}
  31837. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31840. return
  31841. }
  31842. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31843. userJSONBytes3, _ := json.Marshal(respJSON3)
  31844. fmt.Println("log")
  31845. fmt.Println(string(userJSONBytes3))
  31846. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31847. utils.ErrorLog("解析失败:%v", err)
  31848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31849. return
  31850. }
  31851. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31852. var api3 string
  31853. if miConfig.MdtrtareaAdmvs == "320921" {
  31854. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31855. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31856. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31857. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31858. } else {
  31859. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31860. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31861. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31862. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31863. }
  31864. resp3, requestErr3 := http.Get(api3)
  31865. if requestErr3 != nil {
  31866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31867. return
  31868. }
  31869. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31870. if ioErr3 != nil {
  31871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31873. return
  31874. }
  31875. var respJSON3 map[string]interface{}
  31876. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31879. return
  31880. }
  31881. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31882. userJSONBytes3, _ := json.Marshal(respJSON3)
  31883. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31884. utils.ErrorLog("解析失败:%v", err)
  31885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31886. return
  31887. }
  31888. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31889. res.Output = resSixteen10265.Output
  31890. res.ErrMsg = resSixteen10265.ErrMsg
  31891. res.Cainfo = resSixteen10265.Cainfo
  31892. res.WarnMsg = resSixteen10265.WarnMsg
  31893. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31894. res.Infcode = infocode
  31895. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31896. var api3 string
  31897. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31898. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31899. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31900. resp3, requestErr3 := http.Get(api3)
  31901. if requestErr3 != nil {
  31902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31903. return
  31904. }
  31905. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31906. if ioErr3 != nil {
  31907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31909. return
  31910. }
  31911. var respJSON3 map[string]interface{}
  31912. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31915. return
  31916. }
  31917. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31918. userJSONBytes3, _ := json.Marshal(respJSON3)
  31919. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31920. utils.ErrorLog("解析失败:%v", err)
  31921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31922. return
  31923. }
  31924. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31925. res.Output = resSixteen10265.Output
  31926. res.ErrMsg = resSixteen10265.ErrMsg
  31927. res.Cainfo = resSixteen10265.Cainfo
  31928. res.WarnMsg = resSixteen10265.WarnMsg
  31929. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31930. res.Infcode = infocode
  31931. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31932. 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)
  31933. var dat map[string]interface{}
  31934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31935. fmt.Println(dat)
  31936. } else {
  31937. fmt.Println(err)
  31938. }
  31939. saveLog(result, src_resquest, "2208", "退费")
  31940. userJSONBytes, _ := json.Marshal(dat)
  31941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31942. utils.ErrorLog("解析失败:%v", err)
  31943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31944. return
  31945. }
  31946. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31947. 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, "")
  31948. var dat map[string]interface{}
  31949. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31950. fmt.Println(dat)
  31951. } else {
  31952. fmt.Println(err)
  31953. }
  31954. saveLog(result, src_resquest, "2208", "退费")
  31955. userJSONBytes, _ := json.Marshal(dat)
  31956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31957. utils.ErrorLog("解析失败:%v", err)
  31958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31959. return
  31960. }
  31961. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31962. 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, "")
  31963. var dat map[string]interface{}
  31964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31965. fmt.Println(dat)
  31966. } else {
  31967. fmt.Println(err)
  31968. }
  31969. saveLog(result, src_resquest, "2208", "退费")
  31970. userJSONBytes, _ := json.Marshal(dat)
  31971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31972. utils.ErrorLog("解析失败:%v", err)
  31973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31974. return
  31975. }
  31976. } else if miConfig.MdtrtareaAdmvs == "360100" {
  31977. 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, "")
  31978. var dat map[string]interface{}
  31979. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31980. fmt.Println(dat)
  31981. } else {
  31982. fmt.Println(err)
  31983. }
  31984. saveLog(result, src_resquest, "2208", "退费")
  31985. userJSONBytes, _ := json.Marshal(dat)
  31986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31987. utils.ErrorLog("解析失败:%v", err)
  31988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31989. return
  31990. }
  31991. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31992. var api3 string
  31993. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31994. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31995. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31996. resp3, requestErr3 := http.Get(api3)
  31997. if requestErr3 != nil {
  31998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31999. return
  32000. }
  32001. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32002. if ioErr3 != nil {
  32003. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32005. return
  32006. }
  32007. var respJSON3 map[string]interface{}
  32008. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32011. return
  32012. }
  32013. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32014. if status == "0" {
  32015. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32016. c.ServeSuccessJSON(map[string]interface{}{
  32017. "failed_code": -10,
  32018. "msg": err_msg,
  32019. })
  32020. return
  32021. }
  32022. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32023. userJSONBytes3, _ := json.Marshal(respJSON3)
  32024. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32025. // utils.ErrorLog("解析失败:%v", err)
  32026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32027. // return
  32028. //}
  32029. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  32030. utils.ErrorLog("解析失败:%v", err)
  32031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32032. return
  32033. }
  32034. res.InfRefmsgid = ahres.InfRefmsgid
  32035. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32036. // 创建对应的Time类型
  32037. t := time.UnixMilli(timestamp)
  32038. // 格式化成指定的日期字符串
  32039. str := t.Format("2006-01-02 15:04:05")
  32040. res.Output.Setlinfo.SetlTime = str
  32041. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32042. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32043. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32044. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32045. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32046. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32047. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32048. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32049. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32050. //
  32051. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32052. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32053. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32054. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32055. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32056. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32057. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32058. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32059. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32060. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32061. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32062. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32063. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32064. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32065. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32066. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32067. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32068. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32069. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32070. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32071. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32072. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32073. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32074. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32075. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32076. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32077. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32078. //res.Output.Setldetail = ahres.Output.Setldetail
  32079. res.ErrMsg = ahres.ErrMsg
  32080. res.Cainfo = ahres.Cainfo
  32081. res.WarnMsg = ahres.WarnMsg
  32082. res.Infcode = ahres.Infcode
  32083. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32084. var api3 string
  32085. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  32086. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32087. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32088. resp3, requestErr3 := http.Get(api3)
  32089. if requestErr3 != nil {
  32090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32091. return
  32092. }
  32093. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32094. if ioErr3 != nil {
  32095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32097. return
  32098. }
  32099. var respJSON3 map[string]interface{}
  32100. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32103. return
  32104. }
  32105. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32106. if status == "0" {
  32107. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32108. c.ServeSuccessJSON(map[string]interface{}{
  32109. "failed_code": -10,
  32110. "msg": err_msg,
  32111. })
  32112. return
  32113. }
  32114. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32115. userJSONBytes3, _ := json.Marshal(respJSON3)
  32116. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32117. // utils.ErrorLog("解析失败:%v", err)
  32118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32119. // return
  32120. //}
  32121. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  32122. utils.ErrorLog("解析失败:%v", err)
  32123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32124. return
  32125. }
  32126. res.InfRefmsgid = ahres.InfRefmsgid
  32127. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32128. // 创建对应的Time类型
  32129. t := time.UnixMilli(timestamp)
  32130. // 格式化成指定的日期字符串
  32131. str := t.Format("2006-01-02 15:04:05")
  32132. res.Output.Setlinfo.SetlTime = str
  32133. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32134. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32135. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32136. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32137. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32138. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32139. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32140. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32141. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32142. //
  32143. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32144. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32145. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32146. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32147. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32148. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32149. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32150. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32151. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32152. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32153. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32154. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32155. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32156. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32157. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32158. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32159. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32160. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32161. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32162. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32163. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32164. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32165. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32166. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32167. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32168. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32169. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32170. //res.Output.Setldetail = ahres.Output.Setldetail
  32171. res.ErrMsg = ahres.ErrMsg
  32172. res.Cainfo = ahres.Cainfo
  32173. res.WarnMsg = ahres.WarnMsg
  32174. res.Infcode = ahres.Infcode
  32175. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32176. 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, "")
  32177. var dat map[string]interface{}
  32178. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32179. fmt.Println(dat)
  32180. } else {
  32181. fmt.Println(err)
  32182. }
  32183. saveLog(result, src_resquest, "2208", "退费")
  32184. userJSONBytes, _ := json.Marshal(dat)
  32185. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32186. utils.ErrorLog("解析失败:%v", err)
  32187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32188. return
  32189. }
  32190. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32191. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  32192. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32193. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32194. resp3, requestErr3 := http.Get(api3)
  32195. if requestErr3 != nil {
  32196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32197. return
  32198. }
  32199. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32200. if ioErr3 != nil {
  32201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32203. return
  32204. }
  32205. var respJSON3 map[string]interface{}
  32206. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32209. return
  32210. }
  32211. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32212. userJSONBytes3, _ := json.Marshal(respJSON3)
  32213. fmt.Println("log")
  32214. fmt.Println(string(userJSONBytes3))
  32215. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32216. utils.ErrorLog("解析失败:%v", err)
  32217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32218. return
  32219. }
  32220. } else {
  32221. if miConfig.Code == "H15049901371" {
  32222. 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)
  32223. var dat map[string]interface{}
  32224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32225. fmt.Println(dat)
  32226. } else {
  32227. fmt.Println(err)
  32228. }
  32229. saveLog(result, src_resquest, "2208", "退费")
  32230. if strings.Contains(result, "Post") {
  32231. res.Infcode = -1
  32232. res.ErrMsg = result
  32233. }
  32234. userJSONBytes, _ := json.Marshal(dat)
  32235. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  32236. utils.ErrorLog("解析失败:%v", err)
  32237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32238. return
  32239. }
  32240. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  32241. res.Output = resSixteen10265.Output
  32242. res.ErrMsg = resSixteen10265.ErrMsg
  32243. res.Cainfo = resSixteen10265.Cainfo
  32244. res.WarnMsg = resSixteen10265.WarnMsg
  32245. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  32246. res.Infcode = infocode
  32247. } else {
  32248. 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)
  32249. var dat map[string]interface{}
  32250. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32251. fmt.Println(dat)
  32252. } else {
  32253. fmt.Println(err)
  32254. }
  32255. saveLog(result, src_resquest, "2208", "退费")
  32256. userJSONBytes, _ := json.Marshal(dat)
  32257. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32258. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  32259. utils.ErrorLog("解析失败:%v", err)
  32260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32261. return
  32262. }
  32263. res.Infcode = gz.Infcode
  32264. } else {
  32265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32266. utils.ErrorLog("解析失败:%v", err)
  32267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32268. return
  32269. }
  32270. }
  32271. if strings.Contains(result, "Post") {
  32272. res.Infcode = -1
  32273. res.ErrMsg = result
  32274. }
  32275. }
  32276. }
  32277. if res.Infcode == -1 {
  32278. c.ServeSuccessJSON(map[string]interface{}{
  32279. "failed_code": -10,
  32280. "msg": res.ErrMsg,
  32281. })
  32282. return
  32283. }
  32284. if res.Infcode != -1 {
  32285. var res2 ResultSix
  32286. var resSix10265 ResultSix10265
  32287. if miConfig.MdtrtareaAdmvs == "421300" {
  32288. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32289. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32290. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32291. resp3, requestErr3 := http.Get(api3)
  32292. if requestErr3 != nil {
  32293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32294. return
  32295. }
  32296. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32297. if ioErr3 != nil {
  32298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32300. return
  32301. }
  32302. var respJSON3 map[string]interface{}
  32303. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32306. return
  32307. }
  32308. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32309. userJSONBytes3, _ := json.Marshal(respJSON3)
  32310. fmt.Println("log")
  32311. fmt.Println(string(userJSONBytes3))
  32312. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32313. utils.ErrorLog("解析失败:%v", err)
  32314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32315. return
  32316. }
  32317. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32318. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32319. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32320. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32321. resp3, requestErr3 := http.Get(api3)
  32322. if requestErr3 != nil {
  32323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32324. return
  32325. }
  32326. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32327. if ioErr3 != nil {
  32328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32330. return
  32331. }
  32332. var respJSON3 map[string]interface{}
  32333. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32336. return
  32337. }
  32338. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32339. userJSONBytes3, _ := json.Marshal(respJSON3)
  32340. fmt.Println("log")
  32341. fmt.Println(string(userJSONBytes3))
  32342. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32343. utils.ErrorLog("解析失败:%v", err)
  32344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32345. return
  32346. }
  32347. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32348. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32349. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32350. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32351. resp3, requestErr3 := http.Get(api3)
  32352. if requestErr3 != nil {
  32353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32354. return
  32355. }
  32356. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32357. if ioErr3 != nil {
  32358. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32360. return
  32361. }
  32362. var respJSON3 map[string]interface{}
  32363. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32364. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32366. return
  32367. }
  32368. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32369. userJSONBytes3, _ := json.Marshal(respJSON3)
  32370. fmt.Println("log")
  32371. fmt.Println(string(userJSONBytes3))
  32372. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32373. utils.ErrorLog("解析失败:%v", err)
  32374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32375. return
  32376. }
  32377. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32378. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32379. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32380. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32381. resp3, requestErr3 := http.Get(api3)
  32382. if requestErr3 != nil {
  32383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32384. return
  32385. }
  32386. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32387. if ioErr3 != nil {
  32388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32390. return
  32391. }
  32392. var respJSON3 map[string]interface{}
  32393. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32396. return
  32397. }
  32398. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32399. userJSONBytes3, _ := json.Marshal(respJSON3)
  32400. fmt.Println("log")
  32401. fmt.Println(string(userJSONBytes3))
  32402. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32403. utils.ErrorLog("解析失败:%v", err)
  32404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32405. return
  32406. }
  32407. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32408. var api3 string
  32409. if miConfig.MdtrtareaAdmvs == "320921" {
  32410. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32411. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32412. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32413. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32414. } else {
  32415. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32416. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32417. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32418. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32419. }
  32420. resp3, requestErr3 := http.Get(api3)
  32421. if requestErr3 != nil {
  32422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32423. return
  32424. }
  32425. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32426. if ioErr3 != nil {
  32427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32429. return
  32430. }
  32431. var respJSON3 map[string]interface{}
  32432. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32435. return
  32436. }
  32437. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32438. userJSONBytes3, _ := json.Marshal(respJSON3)
  32439. fmt.Println("log")
  32440. fmt.Println(string(userJSONBytes3))
  32441. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32442. utils.ErrorLog("解析失败:%v", err)
  32443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32444. return
  32445. }
  32446. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32447. res2.Output = resSix10265.Output
  32448. res2.ErrMsg = resSix10265.ErrMsg
  32449. res2.Cainfo = resSix10265.Cainfo
  32450. res2.WarnMsg = resSix10265.WarnMsg
  32451. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32452. res2.Infcode = infocode
  32453. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32454. var api3 string
  32455. new_chrg_bchno := order.Number
  32456. if adminUser.CurrentOrgId == 10265 {
  32457. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32458. new_chrg_bchno = "0000"
  32459. }
  32460. }
  32461. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32462. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32463. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32464. resp3, requestErr3 := http.Get(api3)
  32465. if requestErr3 != nil {
  32466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32467. return
  32468. }
  32469. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32470. if ioErr3 != nil {
  32471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32473. return
  32474. }
  32475. var respJSON3 map[string]interface{}
  32476. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32479. return
  32480. }
  32481. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32482. userJSONBytes3, _ := json.Marshal(respJSON3)
  32483. fmt.Println("log")
  32484. fmt.Println(string(userJSONBytes3))
  32485. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32486. utils.ErrorLog("解析失败:%v", err)
  32487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32488. return
  32489. }
  32490. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32491. res2.Output = resSix10265.Output
  32492. res2.ErrMsg = resSix10265.ErrMsg
  32493. res2.Cainfo = resSix10265.Cainfo
  32494. res2.WarnMsg = resSix10265.WarnMsg
  32495. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32496. res2.Infcode = infocode
  32497. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32498. 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)
  32499. var dat map[string]interface{}
  32500. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32501. fmt.Println(dat)
  32502. } else {
  32503. fmt.Println(err)
  32504. }
  32505. saveLog(result2, src_request, "2205", "撤销明细")
  32506. userJSONBytes, _ := json.Marshal(dat)
  32507. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32508. utils.ErrorLog("解析失败:%v", err)
  32509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32510. return
  32511. }
  32512. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32513. 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, "")
  32514. var dat map[string]interface{}
  32515. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32516. fmt.Println(dat)
  32517. } else {
  32518. fmt.Println(err)
  32519. }
  32520. saveLog(result2, src_request, "2205", "撤销明细")
  32521. userJSONBytes, _ := json.Marshal(dat)
  32522. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32523. utils.ErrorLog("解析失败:%v", err)
  32524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32525. return
  32526. }
  32527. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32528. 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, "")
  32529. var dat map[string]interface{}
  32530. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32531. fmt.Println(dat)
  32532. } else {
  32533. fmt.Println(err)
  32534. }
  32535. saveLog(result2, src_request, "2205", "撤销明细")
  32536. userJSONBytes, _ := json.Marshal(dat)
  32537. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32538. utils.ErrorLog("解析失败:%v", err)
  32539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32540. return
  32541. }
  32542. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32543. 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, "")
  32544. var dat map[string]interface{}
  32545. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32546. fmt.Println(dat)
  32547. } else {
  32548. fmt.Println(err)
  32549. }
  32550. saveLog(result2, src_request, "2205", "撤销明细")
  32551. userJSONBytes, _ := json.Marshal(dat)
  32552. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32553. utils.ErrorLog("解析失败:%v", err)
  32554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32555. return
  32556. }
  32557. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32558. var api3 string
  32559. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32560. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32561. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32562. resp3, requestErr3 := http.Get(api3)
  32563. if requestErr3 != nil {
  32564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32565. return
  32566. }
  32567. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32568. if ioErr3 != nil {
  32569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32571. return
  32572. }
  32573. var respJSON3 map[string]interface{}
  32574. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32577. return
  32578. }
  32579. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32580. if status == "0" {
  32581. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32582. c.ServeSuccessJSON(map[string]interface{}{
  32583. "failed_code": -10,
  32584. "msg": err_msg,
  32585. })
  32586. return
  32587. }
  32588. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32589. userJSONBytes3, _ := json.Marshal(respJSON3)
  32590. fmt.Println("log")
  32591. fmt.Println(string(userJSONBytes3))
  32592. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32593. utils.ErrorLog("解析失败:%v", err)
  32594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32595. return
  32596. }
  32597. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32598. 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, "")
  32599. var dat map[string]interface{}
  32600. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32601. fmt.Println(dat)
  32602. } else {
  32603. fmt.Println(err)
  32604. }
  32605. saveLog(result2, src_request, "2205", "撤销明细")
  32606. userJSONBytes, _ := json.Marshal(dat)
  32607. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32608. utils.ErrorLog("解析失败:%v", err)
  32609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32610. return
  32611. }
  32612. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32613. 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, "")
  32614. var dat map[string]interface{}
  32615. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32616. fmt.Println(dat)
  32617. } else {
  32618. fmt.Println(err)
  32619. }
  32620. saveLog(result2, src_request, "2205", "撤销明细")
  32621. userJSONBytes, _ := json.Marshal(dat)
  32622. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32623. utils.ErrorLog("解析失败:%v", err)
  32624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32625. return
  32626. }
  32627. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32628. 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, "")
  32629. var dat map[string]interface{}
  32630. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32631. fmt.Println(dat)
  32632. } else {
  32633. fmt.Println(err)
  32634. }
  32635. saveLog(result2, src_request, "2205", "撤销明细")
  32636. userJSONBytes, _ := json.Marshal(dat)
  32637. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32638. utils.ErrorLog("解析失败:%v", err)
  32639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32640. return
  32641. }
  32642. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32643. var api3 string
  32644. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32645. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32646. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32647. resp3, requestErr3 := http.Get(api3)
  32648. if requestErr3 != nil {
  32649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32650. return
  32651. }
  32652. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32653. if ioErr3 != nil {
  32654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32656. return
  32657. }
  32658. var respJSON3 map[string]interface{}
  32659. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32662. return
  32663. }
  32664. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32665. if status == "0" {
  32666. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32667. c.ServeSuccessJSON(map[string]interface{}{
  32668. "failed_code": -10,
  32669. "msg": err_msg,
  32670. })
  32671. return
  32672. }
  32673. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32674. userJSONBytes3, _ := json.Marshal(respJSON3)
  32675. fmt.Println("log")
  32676. fmt.Println(string(userJSONBytes3))
  32677. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32678. utils.ErrorLog("解析失败:%v", err)
  32679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32680. return
  32681. }
  32682. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32683. 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, "")
  32684. var dat map[string]interface{}
  32685. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32686. fmt.Println(dat)
  32687. } else {
  32688. fmt.Println(err)
  32689. }
  32690. saveLog(result2, src_request, "2205", "撤销明细")
  32691. userJSONBytes, _ := json.Marshal(dat)
  32692. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32693. utils.ErrorLog("解析失败:%v", err)
  32694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32695. return
  32696. }
  32697. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32698. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  32699. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32700. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32701. resp3, requestErr3 := http.Get(api3)
  32702. if requestErr3 != nil {
  32703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32704. return
  32705. }
  32706. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32707. if ioErr3 != nil {
  32708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32710. return
  32711. }
  32712. var respJSON3 map[string]interface{}
  32713. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32716. return
  32717. }
  32718. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32719. userJSONBytes3, _ := json.Marshal(respJSON3)
  32720. fmt.Println("log")
  32721. fmt.Println(string(userJSONBytes3))
  32722. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32723. utils.ErrorLog("解析失败:%v", err)
  32724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32725. return
  32726. }
  32727. } else {
  32728. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32729. res2.Infcode = 0
  32730. } else {
  32731. 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)
  32732. var dat map[string]interface{}
  32733. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32734. fmt.Println(dat)
  32735. } else {
  32736. fmt.Println(err)
  32737. }
  32738. saveLog(result2, src_request, "2205", "撤销明细")
  32739. userJSONBytes, _ := json.Marshal(dat)
  32740. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32741. utils.ErrorLog("解析失败:%v", err)
  32742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32743. return
  32744. }
  32745. }
  32746. }
  32747. if res2.Infcode == -1 {
  32748. c.ServeSuccessJSON(map[string]interface{}{
  32749. "failed_code": -10,
  32750. "msg": res2.ErrMsg,
  32751. })
  32752. return
  32753. }
  32754. if res2.Infcode == 0 {
  32755. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  32756. if err == nil {
  32757. //当押金不为零时产生退费记录
  32758. if order.Decimal != 0 {
  32759. tmp := strconv.FormatInt(order.ID, 10)
  32760. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  32761. if err != nil {
  32762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32763. return
  32764. }
  32765. }
  32766. c.ServeSuccessJSON(map[string]interface{}{
  32767. "msg": "退费成功",
  32768. })
  32769. } else {
  32770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32771. return
  32772. }
  32773. } else {
  32774. c.ServeSuccessJSON(map[string]interface{}{
  32775. "failed_code": -10,
  32776. "msg": res2.ErrMsg,
  32777. })
  32778. }
  32779. } else {
  32780. c.ServeSuccessJSON(map[string]interface{}{
  32781. "failed_code": -10,
  32782. "msg": res.ErrMsg,
  32783. })
  32784. }
  32785. }
  32786. }
  32787. func (c *HisApiController) RefundNumber() {
  32788. record_time := c.GetString("record_time")
  32789. //patient_id, _ := c.GetInt64("patient_id")
  32790. admin_user_id, _ := c.GetInt64("admin_user_id")
  32791. his_patient_id, _ := c.GetInt64("id")
  32792. timeLayout := "2006-01-02"
  32793. loc, _ := time.LoadLocation("Local")
  32794. adminUser := c.GetAdminUserInfo()
  32795. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32796. fmt.Println(err)
  32797. if err != nil {
  32798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32799. return
  32800. }
  32801. recordDateTime := theTime.Unix()
  32802. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32803. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32804. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32805. //order, _ := service.GetHisOrderByID(order_id)
  32806. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32807. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32808. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32809. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32810. if count > 0 {
  32811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32812. return
  32813. }
  32814. if config.IsOpen == 1 { //对接了医保,走医保流程
  32815. var res2 ResultSix
  32816. var res3 GZResultSix
  32817. var resSix10265 ResultSix10265
  32818. if miConfig.MdtrtareaAdmvs == "421300" {
  32819. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32820. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32821. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32822. resp3, requestErr3 := http.Get(api3)
  32823. if requestErr3 != nil {
  32824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32825. return
  32826. }
  32827. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32828. if ioErr3 != nil {
  32829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32831. return
  32832. }
  32833. var respJSON3 map[string]interface{}
  32834. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32837. return
  32838. }
  32839. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32840. userJSONBytes3, _ := json.Marshal(respJSON3)
  32841. fmt.Println("log")
  32842. fmt.Println(string(userJSONBytes3))
  32843. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32844. utils.ErrorLog("解析失败:%v", err)
  32845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32846. return
  32847. }
  32848. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32849. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32850. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32851. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32852. resp3, requestErr3 := http.Get(api3)
  32853. if requestErr3 != nil {
  32854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32855. return
  32856. }
  32857. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32858. if ioErr3 != nil {
  32859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32861. return
  32862. }
  32863. var respJSON3 map[string]interface{}
  32864. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32867. return
  32868. }
  32869. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32870. userJSONBytes3, _ := json.Marshal(respJSON3)
  32871. fmt.Println("log")
  32872. fmt.Println(string(userJSONBytes3))
  32873. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32874. utils.ErrorLog("解析失败:%v", err)
  32875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32876. return
  32877. }
  32878. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32879. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32880. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32881. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32882. resp3, requestErr3 := http.Get(api3)
  32883. if requestErr3 != nil {
  32884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32885. return
  32886. }
  32887. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32888. if ioErr3 != nil {
  32889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32891. return
  32892. }
  32893. var respJSON3 map[string]interface{}
  32894. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32897. return
  32898. }
  32899. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32900. userJSONBytes3, _ := json.Marshal(respJSON3)
  32901. fmt.Println("log")
  32902. fmt.Println(string(userJSONBytes3))
  32903. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32904. utils.ErrorLog("解析失败:%v", err)
  32905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32906. return
  32907. }
  32908. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32909. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32910. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32911. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32912. resp3, requestErr3 := http.Get(api3)
  32913. if requestErr3 != nil {
  32914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32915. return
  32916. }
  32917. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32918. if ioErr3 != nil {
  32919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32921. return
  32922. }
  32923. var respJSON3 map[string]interface{}
  32924. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32927. return
  32928. }
  32929. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32930. userJSONBytes3, _ := json.Marshal(respJSON3)
  32931. fmt.Println("log")
  32932. fmt.Println(string(userJSONBytes3))
  32933. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32934. utils.ErrorLog("解析失败:%v", err)
  32935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32936. return
  32937. }
  32938. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32939. var api3 string
  32940. if miConfig.MdtrtareaAdmvs == "320921" {
  32941. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32942. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32943. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32944. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32945. } else {
  32946. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32947. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32948. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32949. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32950. }
  32951. resp3, requestErr3 := http.Get(api3)
  32952. if requestErr3 != nil {
  32953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32954. return
  32955. }
  32956. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32957. if ioErr3 != nil {
  32958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32960. return
  32961. }
  32962. var respJSON3 map[string]interface{}
  32963. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32966. return
  32967. }
  32968. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32969. userJSONBytes3, _ := json.Marshal(respJSON3)
  32970. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32971. utils.ErrorLog("解析失败:%v", err)
  32972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32973. return
  32974. }
  32975. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32976. res2.Output = resSix10265.Output
  32977. res2.ErrMsg = resSix10265.ErrMsg
  32978. res2.Cainfo = resSix10265.Cainfo
  32979. res2.WarnMsg = resSix10265.WarnMsg
  32980. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32981. res2.Infcode = infocode
  32982. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32983. var api3 string
  32984. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32985. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32986. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32987. resp3, requestErr3 := http.Get(api3)
  32988. if requestErr3 != nil {
  32989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32990. return
  32991. }
  32992. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32993. if ioErr3 != nil {
  32994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32996. return
  32997. }
  32998. var respJSON3 map[string]interface{}
  32999. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33002. return
  33003. }
  33004. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33005. userJSONBytes3, _ := json.Marshal(respJSON3)
  33006. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33007. utils.ErrorLog("解析失败:%v", err)
  33008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33009. return
  33010. }
  33011. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33012. res2.Output = resSix10265.Output
  33013. res2.ErrMsg = resSix10265.ErrMsg
  33014. res2.Cainfo = resSix10265.Cainfo
  33015. res2.WarnMsg = resSix10265.WarnMsg
  33016. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33017. res2.Infcode = infocode
  33018. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33019. 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)
  33020. var dat map[string]interface{}
  33021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33022. fmt.Println(dat)
  33023. } else {
  33024. fmt.Println(err)
  33025. }
  33026. saveLog(result, request, "2202", "退号")
  33027. userJSONBytes, _ := json.Marshal(dat)
  33028. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33029. utils.ErrorLog("解析失败:%v", err)
  33030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33031. return
  33032. }
  33033. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33034. 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, "")
  33035. var dat map[string]interface{}
  33036. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33037. fmt.Println(dat)
  33038. } else {
  33039. fmt.Println(err)
  33040. }
  33041. saveLog(result, request, "2202", "退号")
  33042. userJSONBytes, _ := json.Marshal(dat)
  33043. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33044. utils.ErrorLog("解析失败:%v", err)
  33045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33046. return
  33047. }
  33048. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33049. 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, "")
  33050. var dat map[string]interface{}
  33051. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33052. fmt.Println(dat)
  33053. } else {
  33054. fmt.Println(err)
  33055. }
  33056. saveLog(result, request, "2202", "退号")
  33057. userJSONBytes, _ := json.Marshal(dat)
  33058. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33059. utils.ErrorLog("解析失败:%v", err)
  33060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33061. return
  33062. }
  33063. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33064. 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, "")
  33065. var dat map[string]interface{}
  33066. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33067. fmt.Println(dat)
  33068. } else {
  33069. fmt.Println(err)
  33070. }
  33071. saveLog(result, request, "2202", "退号")
  33072. userJSONBytes, _ := json.Marshal(dat)
  33073. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33074. utils.ErrorLog("解析失败:%v", err)
  33075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33076. return
  33077. }
  33078. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33079. var api3 string
  33080. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  33081. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33082. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33083. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33084. resp3, requestErr3 := http.Get(api3)
  33085. if requestErr3 != nil {
  33086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33087. return
  33088. }
  33089. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33090. if ioErr3 != nil {
  33091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33093. return
  33094. }
  33095. var respJSON3 map[string]interface{}
  33096. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33099. return
  33100. }
  33101. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33102. if status == "0" {
  33103. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33104. c.ServeSuccessJSON(map[string]interface{}{
  33105. "failed_code": -10,
  33106. "msg": err_msg,
  33107. })
  33108. return
  33109. }
  33110. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33111. userJSONBytes3, _ := json.Marshal(respJSON3)
  33112. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33113. utils.ErrorLog("解析失败:%v", err)
  33114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33115. return
  33116. }
  33117. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  33118. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33119. var api3 string
  33120. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  33121. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33122. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33123. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33124. resp3, requestErr3 := http.Get(api3)
  33125. if requestErr3 != nil {
  33126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33127. return
  33128. }
  33129. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33130. if ioErr3 != nil {
  33131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33133. return
  33134. }
  33135. var respJSON3 map[string]interface{}
  33136. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33139. return
  33140. }
  33141. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33142. if status == "0" {
  33143. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33144. c.ServeSuccessJSON(map[string]interface{}{
  33145. "failed_code": -10,
  33146. "msg": err_msg,
  33147. })
  33148. return
  33149. }
  33150. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33151. userJSONBytes3, _ := json.Marshal(respJSON3)
  33152. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33153. utils.ErrorLog("解析失败:%v", err)
  33154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33155. return
  33156. }
  33157. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  33158. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33159. 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, "")
  33160. var dat map[string]interface{}
  33161. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33162. fmt.Println(dat)
  33163. } else {
  33164. fmt.Println(err)
  33165. }
  33166. saveLog(result, request, "2202", "退号")
  33167. userJSONBytes, _ := json.Marshal(dat)
  33168. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33169. utils.ErrorLog("解析失败:%v", err)
  33170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33171. return
  33172. }
  33173. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33174. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  33175. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33176. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33177. resp3, requestErr3 := http.Get(api3)
  33178. if requestErr3 != nil {
  33179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33180. return
  33181. }
  33182. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33183. if ioErr3 != nil {
  33184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33186. return
  33187. }
  33188. var respJSON3 map[string]interface{}
  33189. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33192. return
  33193. }
  33194. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33195. userJSONBytes3, _ := json.Marshal(respJSON3)
  33196. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33197. utils.ErrorLog("解析失败:%v", err)
  33198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33199. return
  33200. }
  33201. } else {
  33202. var api3 string
  33203. if miConfig.Code == "H15049901371" {
  33204. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  33205. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33206. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33207. } else {
  33208. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  33209. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33210. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33211. }
  33212. resp3, requestErr3 := http.Get(api3)
  33213. if requestErr3 != nil {
  33214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33215. return
  33216. }
  33217. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33218. if ioErr3 != nil {
  33219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33221. return
  33222. }
  33223. var respJSON3 map[string]interface{}
  33224. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33227. return
  33228. }
  33229. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33230. userJSONBytes3, _ := json.Marshal(respJSON3)
  33231. if miConfig.Code == "H15049901371" {
  33232. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33233. utils.ErrorLog("解析失败:%v", err)
  33234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33235. return
  33236. }
  33237. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33238. res2.Output = resSix10265.Output
  33239. res2.ErrMsg = resSix10265.ErrMsg
  33240. res2.Cainfo = resSix10265.Cainfo
  33241. res2.WarnMsg = resSix10265.WarnMsg
  33242. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33243. res2.Infcode = infocode
  33244. } else {
  33245. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33246. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  33247. utils.ErrorLog("解析失败:%v", err)
  33248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33249. return
  33250. }
  33251. res2.Infcode = res3.Infcode
  33252. } else {
  33253. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33254. utils.ErrorLog("解析失败:%v", err)
  33255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33256. return
  33257. }
  33258. }
  33259. }
  33260. }
  33261. if res2.Infcode == -1 {
  33262. c.ServeSuccessJSON(map[string]interface{}{
  33263. "failed_code": -10,
  33264. "msg": res2.ErrMsg,
  33265. })
  33266. return
  33267. }
  33268. if res2.Infcode == 0 {
  33269. if err == nil {
  33270. c.ServeSuccessJSON(map[string]interface{}{
  33271. "msg": "退号成功",
  33272. })
  33273. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  33274. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  33275. } else {
  33276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33277. return
  33278. }
  33279. }
  33280. } else {
  33281. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  33282. //if err == nil {
  33283. // c.ServeSuccessJSON(map[string]interface{}{
  33284. // "msg": "退费成功",
  33285. // })
  33286. //} else {
  33287. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33288. // return
  33289. //}
  33290. }
  33291. }
  33292. func (c *HisApiController) RefundDetail() {
  33293. order_id, _ := c.GetInt64("order_id")
  33294. admin_user_id, _ := c.GetInt64("admin_user_id")
  33295. //his_patient_id, _ := c.GetInt64("his_patient_id")
  33296. number := c.GetString("number")
  33297. record_time := c.GetString("record_time")
  33298. patient_id, _ := c.GetInt64("patient_id")
  33299. //med_type, _ := c.GetInt64("med_type")
  33300. timeLayout := "2006-01-02"
  33301. loc, _ := time.LoadLocation("Local")
  33302. adminUser := c.GetAdminUserInfo()
  33303. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33304. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33305. fmt.Println(err)
  33306. if err != nil {
  33307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33308. return
  33309. }
  33310. recordDateTime := theTime.Unix()
  33311. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  33312. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33313. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33314. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33315. var order models.HisOrder
  33316. order, _ = service.GetHisOrderByID(order_id)
  33317. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33318. if config.IsOpen == 1 { //对接了医保,走医保流程
  33319. var res2 ResultSix
  33320. if miConfig.MdtrtareaAdmvs == "421300" {
  33321. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33322. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33323. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33324. resp3, requestErr3 := http.Get(api3)
  33325. if requestErr3 != nil {
  33326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33327. return
  33328. }
  33329. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33330. if ioErr3 != nil {
  33331. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33333. return
  33334. }
  33335. var respJSON3 map[string]interface{}
  33336. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33339. return
  33340. }
  33341. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33342. userJSONBytes3, _ := json.Marshal(respJSON3)
  33343. fmt.Println("log")
  33344. fmt.Println(string(userJSONBytes3))
  33345. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33346. utils.ErrorLog("解析失败:%v", err)
  33347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33348. return
  33349. }
  33350. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33351. if err == nil {
  33352. c.ServeSuccessJSON(map[string]interface{}{
  33353. "msg": "撤销明细成功",
  33354. })
  33355. return
  33356. } else {
  33357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33358. return
  33359. }
  33360. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33361. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33362. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33363. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33364. resp3, requestErr3 := http.Get(api3)
  33365. if requestErr3 != nil {
  33366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33367. return
  33368. }
  33369. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33370. if ioErr3 != nil {
  33371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33373. return
  33374. }
  33375. var respJSON3 map[string]interface{}
  33376. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33379. return
  33380. }
  33381. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33382. userJSONBytes3, _ := json.Marshal(respJSON3)
  33383. fmt.Println("log")
  33384. fmt.Println(string(userJSONBytes3))
  33385. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33386. utils.ErrorLog("解析失败:%v", err)
  33387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33388. return
  33389. }
  33390. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33391. if err == nil {
  33392. c.ServeSuccessJSON(map[string]interface{}{
  33393. "msg": "撤销明细成功",
  33394. })
  33395. return
  33396. } else {
  33397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33398. return
  33399. }
  33400. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33401. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33402. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33403. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33404. resp3, requestErr3 := http.Get(api3)
  33405. if requestErr3 != nil {
  33406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33407. return
  33408. }
  33409. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33410. if ioErr3 != nil {
  33411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33413. return
  33414. }
  33415. var respJSON3 map[string]interface{}
  33416. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33419. return
  33420. }
  33421. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33422. userJSONBytes3, _ := json.Marshal(respJSON3)
  33423. fmt.Println("log")
  33424. fmt.Println(string(userJSONBytes3))
  33425. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33426. utils.ErrorLog("解析失败:%v", err)
  33427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33428. return
  33429. }
  33430. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33431. if err == nil {
  33432. c.ServeSuccessJSON(map[string]interface{}{
  33433. "msg": "撤销明细成功",
  33434. })
  33435. return
  33436. } else {
  33437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33438. return
  33439. }
  33440. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33441. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33442. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33443. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33444. resp3, requestErr3 := http.Get(api3)
  33445. if requestErr3 != nil {
  33446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33447. return
  33448. }
  33449. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33450. if ioErr3 != nil {
  33451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33453. return
  33454. }
  33455. var respJSON3 map[string]interface{}
  33456. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33459. return
  33460. }
  33461. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33462. userJSONBytes3, _ := json.Marshal(respJSON3)
  33463. fmt.Println("log")
  33464. fmt.Println(string(userJSONBytes3))
  33465. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33466. utils.ErrorLog("解析失败:%v", err)
  33467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33468. return
  33469. }
  33470. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33471. if err == nil {
  33472. c.ServeSuccessJSON(map[string]interface{}{
  33473. "msg": "撤销明细成功",
  33474. })
  33475. return
  33476. } else {
  33477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33478. return
  33479. }
  33480. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33481. var resSix10265 ResultSix10265
  33482. var api3 string
  33483. if miConfig.MdtrtareaAdmvs == "320921" {
  33484. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33485. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33486. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33487. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33488. } else {
  33489. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33490. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33491. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33492. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33493. }
  33494. resp3, requestErr3 := http.Get(api3)
  33495. utils.ErrorLog("接口: %v", requestErr3)
  33496. if requestErr3 != nil {
  33497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33498. return
  33499. }
  33500. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33501. if ioErr3 != nil {
  33502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33504. return
  33505. }
  33506. var respJSON3 map[string]interface{}
  33507. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33510. return
  33511. }
  33512. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33513. userJSONBytes3, _ := json.Marshal(respJSON3)
  33514. fmt.Println("log")
  33515. fmt.Println(string(userJSONBytes3))
  33516. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33517. utils.ErrorLog("解析失败:%v", err)
  33518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33519. return
  33520. }
  33521. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33522. res2.Output = resSix10265.Output
  33523. res2.ErrMsg = resSix10265.ErrMsg
  33524. res2.Cainfo = resSix10265.Cainfo
  33525. res2.WarnMsg = resSix10265.WarnMsg
  33526. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33527. res2.Infcode = infocode
  33528. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33529. if err == nil {
  33530. c.ServeSuccessJSON(map[string]interface{}{
  33531. "msg": "撤销明细成功",
  33532. })
  33533. return
  33534. } else {
  33535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33536. return
  33537. }
  33538. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33539. var api3 string
  33540. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33541. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33542. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33543. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33544. resp3, requestErr3 := http.Get(api3)
  33545. utils.ErrorLog("接口: %v", requestErr3)
  33546. if requestErr3 != nil {
  33547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33548. return
  33549. }
  33550. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33551. if ioErr3 != nil {
  33552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33554. return
  33555. }
  33556. var respJSON3 map[string]interface{}
  33557. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33560. return
  33561. }
  33562. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33563. if status == "0" {
  33564. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33565. c.ServeSuccessJSON(map[string]interface{}{
  33566. "failed_code": -10,
  33567. "msg": err_msg,
  33568. })
  33569. return
  33570. }
  33571. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33572. userJSONBytes3, _ := json.Marshal(respJSON3)
  33573. fmt.Println("log")
  33574. fmt.Println(string(userJSONBytes3))
  33575. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33576. utils.ErrorLog("解析失败:%v", err)
  33577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33578. return
  33579. }
  33580. fmt.Println(res2.Infcode)
  33581. if res2.Infcode == -1 {
  33582. c.ServeSuccessJSON(map[string]interface{}{
  33583. "failed_code": -10,
  33584. "msg": res2.ErrMsg,
  33585. })
  33586. return
  33587. }
  33588. if res2.Infcode == 0 {
  33589. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33590. if err == nil {
  33591. c.ServeSuccessJSON(map[string]interface{}{
  33592. "msg": "撤销明细成功",
  33593. })
  33594. return
  33595. } else {
  33596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33597. return
  33598. }
  33599. } else {
  33600. c.ServeSuccessJSON(map[string]interface{}{
  33601. "failed_code": -10,
  33602. "msg": res2.ErrMsg,
  33603. })
  33604. }
  33605. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33606. if err == nil {
  33607. c.ServeSuccessJSON(map[string]interface{}{
  33608. "msg": "撤销明细成功",
  33609. })
  33610. return
  33611. } else {
  33612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33613. return
  33614. }
  33615. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33616. var api3 string
  33617. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33618. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33619. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33620. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33621. resp3, requestErr3 := http.Get(api3)
  33622. utils.ErrorLog("接口: %v", requestErr3)
  33623. if requestErr3 != nil {
  33624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33625. return
  33626. }
  33627. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33628. if ioErr3 != nil {
  33629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33631. return
  33632. }
  33633. var respJSON3 map[string]interface{}
  33634. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33637. return
  33638. }
  33639. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33640. if status == "0" {
  33641. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33642. c.ServeSuccessJSON(map[string]interface{}{
  33643. "failed_code": -10,
  33644. "msg": err_msg,
  33645. })
  33646. return
  33647. }
  33648. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33649. userJSONBytes3, _ := json.Marshal(respJSON3)
  33650. fmt.Println("log")
  33651. fmt.Println(string(userJSONBytes3))
  33652. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33653. utils.ErrorLog("解析失败:%v", err)
  33654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33655. return
  33656. }
  33657. fmt.Println(res2.Infcode)
  33658. if res2.Infcode == -1 {
  33659. c.ServeSuccessJSON(map[string]interface{}{
  33660. "failed_code": -10,
  33661. "msg": res2.ErrMsg,
  33662. })
  33663. return
  33664. }
  33665. if res2.Infcode == 0 {
  33666. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33667. if err == nil {
  33668. c.ServeSuccessJSON(map[string]interface{}{
  33669. "msg": "撤销明细成功",
  33670. })
  33671. return
  33672. } else {
  33673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33674. return
  33675. }
  33676. } else {
  33677. c.ServeSuccessJSON(map[string]interface{}{
  33678. "failed_code": -10,
  33679. "msg": res2.ErrMsg,
  33680. })
  33681. }
  33682. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33683. if err == nil {
  33684. c.ServeSuccessJSON(map[string]interface{}{
  33685. "msg": "撤销明细成功",
  33686. })
  33687. return
  33688. } else {
  33689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33690. return
  33691. }
  33692. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33693. var resSix10265 ResultSix10265
  33694. new_chrg_bchno := order.Number
  33695. if adminUser.CurrentOrgId == 10265 {
  33696. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33697. new_chrg_bchno = "0000"
  33698. }
  33699. }
  33700. var api3 string
  33701. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33702. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33703. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33704. resp3, requestErr3 := http.Get(api3)
  33705. if requestErr3 != nil {
  33706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33707. return
  33708. }
  33709. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33710. if ioErr3 != nil {
  33711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33713. return
  33714. }
  33715. var respJSON3 map[string]interface{}
  33716. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33719. return
  33720. }
  33721. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33722. userJSONBytes3, _ := json.Marshal(respJSON3)
  33723. fmt.Println("log")
  33724. fmt.Println(string(userJSONBytes3))
  33725. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33726. utils.ErrorLog("解析失败:%v", err)
  33727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33728. return
  33729. }
  33730. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33731. res2.Output = resSix10265.Output
  33732. res2.ErrMsg = resSix10265.ErrMsg
  33733. res2.Cainfo = resSix10265.Cainfo
  33734. res2.WarnMsg = resSix10265.WarnMsg
  33735. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33736. res2.Infcode = infocode
  33737. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33738. if err == nil {
  33739. c.ServeSuccessJSON(map[string]interface{}{
  33740. "msg": "撤销明细成功",
  33741. })
  33742. return
  33743. } else {
  33744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33745. return
  33746. }
  33747. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33748. 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)
  33749. var dat map[string]interface{}
  33750. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33751. fmt.Println(dat)
  33752. } else {
  33753. fmt.Println(err)
  33754. }
  33755. saveLog(result2, src_request, "2205", "撤销明细")
  33756. userJSONBytes, _ := json.Marshal(dat)
  33757. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33758. utils.ErrorLog("解析失败:%v", err)
  33759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33760. return
  33761. }
  33762. if res2.Infcode == 0 {
  33763. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33764. if err == nil {
  33765. c.ServeSuccessJSON(map[string]interface{}{
  33766. "msg": "撤销明细成功",
  33767. })
  33768. return
  33769. } else {
  33770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33771. return
  33772. }
  33773. } else {
  33774. c.ServeSuccessJSON(map[string]interface{}{
  33775. "failed_code": -10,
  33776. "msg": res2.ErrMsg,
  33777. })
  33778. }
  33779. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33780. 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, "")
  33781. var dat map[string]interface{}
  33782. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33783. fmt.Println(dat)
  33784. } else {
  33785. fmt.Println(err)
  33786. }
  33787. saveLog(result2, src_request, "2205", "撤销明细")
  33788. userJSONBytes, _ := json.Marshal(dat)
  33789. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33790. utils.ErrorLog("解析失败:%v", err)
  33791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33792. return
  33793. }
  33794. if res2.Infcode == 0 {
  33795. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33796. if err == nil {
  33797. c.ServeSuccessJSON(map[string]interface{}{
  33798. "msg": "撤销明细成功",
  33799. })
  33800. return
  33801. } else {
  33802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33803. return
  33804. }
  33805. } else {
  33806. c.ServeSuccessJSON(map[string]interface{}{
  33807. "failed_code": -10,
  33808. "msg": res2.ErrMsg,
  33809. })
  33810. }
  33811. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33812. 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, "")
  33813. var dat map[string]interface{}
  33814. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33815. fmt.Println(dat)
  33816. } else {
  33817. fmt.Println(err)
  33818. }
  33819. saveLog(result2, src_request, "2205", "撤销明细")
  33820. userJSONBytes, _ := json.Marshal(dat)
  33821. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33822. utils.ErrorLog("解析失败:%v", err)
  33823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33824. return
  33825. }
  33826. if res2.Infcode == 0 {
  33827. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33828. if err == nil {
  33829. c.ServeSuccessJSON(map[string]interface{}{
  33830. "msg": "撤销明细成功",
  33831. })
  33832. return
  33833. } else {
  33834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33835. return
  33836. }
  33837. } else {
  33838. c.ServeSuccessJSON(map[string]interface{}{
  33839. "failed_code": -10,
  33840. "msg": res2.ErrMsg,
  33841. })
  33842. }
  33843. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33844. 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, "")
  33845. var dat map[string]interface{}
  33846. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33847. fmt.Println(dat)
  33848. } else {
  33849. fmt.Println(err)
  33850. }
  33851. saveLog(result2, src_request, "2205", "撤销明细")
  33852. userJSONBytes, _ := json.Marshal(dat)
  33853. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33854. utils.ErrorLog("解析失败:%v", err)
  33855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33856. return
  33857. }
  33858. if res2.Infcode == 0 {
  33859. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33860. if err == nil {
  33861. c.ServeSuccessJSON(map[string]interface{}{
  33862. "msg": "撤销明细成功",
  33863. })
  33864. return
  33865. } else {
  33866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33867. return
  33868. }
  33869. } else {
  33870. c.ServeSuccessJSON(map[string]interface{}{
  33871. "failed_code": -10,
  33872. "msg": res2.ErrMsg,
  33873. })
  33874. }
  33875. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33876. 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, "")
  33877. var dat map[string]interface{}
  33878. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33879. fmt.Println(dat)
  33880. } else {
  33881. fmt.Println(err)
  33882. }
  33883. saveLog(result2, src_request, "2205", "撤销明细")
  33884. userJSONBytes, _ := json.Marshal(dat)
  33885. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33886. utils.ErrorLog("解析失败:%v", err)
  33887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33888. return
  33889. }
  33890. if res2.Infcode == 0 {
  33891. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33892. if err == nil {
  33893. c.ServeSuccessJSON(map[string]interface{}{
  33894. "msg": "撤销明细成功",
  33895. })
  33896. return
  33897. } else {
  33898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33899. return
  33900. }
  33901. } else {
  33902. c.ServeSuccessJSON(map[string]interface{}{
  33903. "failed_code": -10,
  33904. "msg": res2.ErrMsg,
  33905. })
  33906. }
  33907. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33908. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33909. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33910. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33911. resp2, requestErr2 := http.Get(api2)
  33912. if requestErr2 != nil {
  33913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33914. return
  33915. }
  33916. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33917. if ioErr2 != nil {
  33918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33920. return
  33921. }
  33922. var respJSON2 map[string]interface{}
  33923. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33926. return
  33927. }
  33928. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33929. userJSONBytes3, _ := json.Marshal(respJSON2)
  33930. fmt.Println("log")
  33931. fmt.Println(string(userJSONBytes3))
  33932. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33933. utils.ErrorLog("解析失败:%v", err)
  33934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33935. return
  33936. }
  33937. if res2.Infcode == 0 {
  33938. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33939. if err == nil {
  33940. c.ServeSuccessJSON(map[string]interface{}{
  33941. "msg": "撤销明细成功",
  33942. })
  33943. return
  33944. } else {
  33945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33946. return
  33947. }
  33948. } else {
  33949. c.ServeSuccessJSON(map[string]interface{}{
  33950. "failed_code": -10,
  33951. "msg": res2.ErrMsg,
  33952. })
  33953. }
  33954. } else {
  33955. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33956. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33957. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33958. resp2, requestErr2 := http.Get(api2)
  33959. if requestErr2 != nil {
  33960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33961. return
  33962. }
  33963. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33964. if ioErr2 != nil {
  33965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33967. return
  33968. }
  33969. var respJSON2 map[string]interface{}
  33970. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33973. return
  33974. }
  33975. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33976. userJSONBytes3, _ := json.Marshal(respJSON2)
  33977. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33978. utils.ErrorLog("解析失败:%v", err)
  33979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33980. return
  33981. }
  33982. if res2.Infcode == -1 {
  33983. c.ServeSuccessJSON(map[string]interface{}{
  33984. "failed_code": -10,
  33985. "msg": res2.ErrMsg,
  33986. })
  33987. return
  33988. } else {
  33989. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33990. if err == nil {
  33991. c.ServeSuccessJSON(map[string]interface{}{
  33992. "msg": "撤销明细成功",
  33993. })
  33994. return
  33995. } else {
  33996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33997. return
  33998. }
  33999. }
  34000. }
  34001. } else {
  34002. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34003. if err == nil {
  34004. c.ServeSuccessJSON(map[string]interface{}{
  34005. "msg": "退费成功",
  34006. })
  34007. } else {
  34008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34009. return
  34010. }
  34011. }
  34012. }
  34013. // 对账
  34014. func (c *HisApiController) GetCheckAccount() {
  34015. start_time := c.GetString("start_time")
  34016. end_time := c.GetString("end_time")
  34017. insutype := c.GetString("insutype")
  34018. clr_type := c.GetString("clr_type")
  34019. clr_org := c.GetString("clr_optins")
  34020. admin_user_id, _ := c.GetInt64("admin_user_id")
  34021. adminUser := c.GetAdminUserInfo()
  34022. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34023. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34024. if len(clr_org) == 0 {
  34025. clr_org = miConfig.InsuplcAdmdvs
  34026. }
  34027. timeLayout := "2006-01-02"
  34028. loc, _ := time.LoadLocation("Local")
  34029. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34030. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34031. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34032. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34033. fixmedins_setl_cnt := int64(len(orders))
  34034. var medfee_sumamt float64
  34035. var acct_pay float64
  34036. var fund_pay_sumamt float64
  34037. for _, item := range orders {
  34038. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34039. acct_pay = acct_pay + item.AcctPay
  34040. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  34041. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  34042. } else {
  34043. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34044. }
  34045. }
  34046. var user_name string
  34047. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34048. if role.ID == 0 {
  34049. user_name = "xxx"
  34050. } else {
  34051. user_name = role.UserName
  34052. }
  34053. var res ResultEight
  34054. var res10188 ResultEightFor10188
  34055. if config.IsOpen == 1 {
  34056. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34057. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  34058. "insutype=" + insutype +
  34059. "&clr_type=" + clr_type +
  34060. "&setl_optins=" + clr_org +
  34061. "&stmt_begndate=" + start_time +
  34062. "&stm_enddate=" + end_time +
  34063. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34064. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34065. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34066. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34067. "&fixmedins_code=" + miConfig.Code +
  34068. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34069. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34070. "&secret_key=" + miConfig.SecretKey +
  34071. "&org_name=" + miConfig.OrgName +
  34072. "&doctor=" + user_name +
  34073. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34074. fmt.Println(api)
  34075. resp, requestErr := http.Get(api)
  34076. if requestErr != nil {
  34077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34078. return
  34079. }
  34080. body, ioErr := ioutil.ReadAll(resp.Body)
  34081. fmt.Println(body)
  34082. if ioErr != nil {
  34083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34085. return
  34086. }
  34087. var respJSON map[string]interface{}
  34088. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34091. return
  34092. }
  34093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34094. userJSONBytes, _ := json.Marshal(respJSON)
  34095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34096. utils.ErrorLog("解析失败:%v", err)
  34097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34098. return
  34099. }
  34100. res.InfRefmsgid = res10188.InfRefmsgid
  34101. res.Output = res10188.Output
  34102. res.ErrMsg = res10188.ErrMsg
  34103. res.Cainfo = res10188.Cainfo
  34104. res.WarnMsg = res10188.WarnMsg
  34105. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  34106. res.Infcode = infocode
  34107. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34108. if clr_type != "9903" {
  34109. clr_type = "99" // 就诊 ID(来自2201接口返回)
  34110. }
  34111. if clr_type == "9903" {
  34112. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  34113. }
  34114. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  34115. "insutype=" + insutype +
  34116. "&clr_type=" + clr_type +
  34117. "&setl_optins=" + clr_org +
  34118. "&stmt_begndate=" + start_time +
  34119. "&stm_enddate=" + end_time +
  34120. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34121. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34122. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34123. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34124. "&fixmedins_code=" + miConfig.Code +
  34125. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34126. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34127. "&secret_key=" + miConfig.SecretKey +
  34128. "&org_name=" + miConfig.OrgName +
  34129. "&doctor=" + user_name
  34130. resp, requestErr := http.Get(api)
  34131. if requestErr != nil {
  34132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34133. return
  34134. }
  34135. body, ioErr := ioutil.ReadAll(resp.Body)
  34136. if ioErr != nil {
  34137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34139. return
  34140. }
  34141. var respJSON map[string]interface{}
  34142. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34145. return
  34146. }
  34147. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34148. result, _ := json.Marshal(respJSON)
  34149. fmt.Println("log")
  34150. fmt.Println(string(result))
  34151. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  34152. utils.ErrorLog("解析失败:%v", err)
  34153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34154. return
  34155. }
  34156. res.InfRefmsgid = res10188.InfRefmsgid
  34157. res.Output = res10188.Output
  34158. res.ErrMsg = res10188.ErrMsg
  34159. res.Cainfo = res10188.Cainfo
  34160. res.WarnMsg = res10188.WarnMsg
  34161. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  34162. res.Infcode = infocode
  34163. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34164. var baseParams models.BaseParams
  34165. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34166. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34167. baseParams.SecretKey = miConfig.SecretKey
  34168. baseParams.OrgName = miConfig.OrgName
  34169. baseParams.FixmedinsCode = miConfig.Code
  34170. baseParams.EncKey = miConfig.EncKey
  34171. baseParams.AppSecret = miConfig.AppSecret
  34172. baseParams.SignKey = miConfig.SignKey
  34173. baseParams.AppID = miConfig.Code
  34174. baseParams.Doctor = role.UserName
  34175. baseParams.RequestUrl = miConfig.Url
  34176. businessParams := models.BusinessParams{
  34177. Insutype: insutype,
  34178. ClrType: clr_type,
  34179. SetlOptins: clr_org,
  34180. StmtBegndate: start_time,
  34181. StmtEnddate: end_time,
  34182. MedfeeSumamt: medfee_sumamt,
  34183. FundPaySumamt: fund_pay_sumamt,
  34184. AcctPay: acct_pay,
  34185. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34186. }
  34187. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  34188. fmt.Println(requestLog)
  34189. fmt.Println(result)
  34190. fmt.Println(err_msg)
  34191. var dat map[string]interface{}
  34192. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34193. fmt.Println(dat)
  34194. } else {
  34195. fmt.Println(err)
  34196. }
  34197. userJSONBytes, _ := json.Marshal(dat)
  34198. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34199. utils.ErrorLog("解析失败:%v", err)
  34200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34201. return
  34202. }
  34203. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34204. var baseParams models.BaseParams
  34205. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34206. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34207. baseParams.SecretKey = miConfig.SecretKey
  34208. baseParams.OrgName = miConfig.OrgName
  34209. baseParams.FixmedinsCode = miConfig.Code
  34210. baseParams.EncKey = miConfig.EncKey
  34211. baseParams.AppSecret = miConfig.AppSecret
  34212. baseParams.SignKey = miConfig.SignKey
  34213. baseParams.AppID = miConfig.Code
  34214. baseParams.Doctor = role.UserName
  34215. baseParams.RequestUrl = miConfig.Url
  34216. baseParams.AccessKey = miConfig.AccessKey
  34217. businessParams := models.BusinessParams{
  34218. Insutype: insutype,
  34219. ClrType: clr_type,
  34220. SetlOptins: "430822",
  34221. StmtBegndate: start_time,
  34222. StmtEnddate: end_time,
  34223. MedfeeSumamt: medfee_sumamt,
  34224. FundPaySumamt: fund_pay_sumamt,
  34225. AcctPay: acct_pay,
  34226. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34227. }
  34228. 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)
  34229. fmt.Println(requestLog)
  34230. fmt.Println(result)
  34231. var dat map[string]interface{}
  34232. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34233. fmt.Println(dat)
  34234. } else {
  34235. fmt.Println(err)
  34236. }
  34237. userJSONBytes, _ := json.Marshal(dat)
  34238. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34239. utils.ErrorLog("解析失败:%v", err)
  34240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34241. return
  34242. }
  34243. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34244. var baseParams models.BaseParams
  34245. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34246. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34247. baseParams.SecretKey = miConfig.SecretKey
  34248. baseParams.OrgName = miConfig.OrgName
  34249. baseParams.FixmedinsCode = miConfig.Code
  34250. baseParams.EncKey = miConfig.EncKey
  34251. baseParams.AppSecret = miConfig.AppSecret
  34252. baseParams.SignKey = miConfig.SignKey
  34253. baseParams.AppID = miConfig.Code
  34254. baseParams.Doctor = role.UserName
  34255. baseParams.RequestUrl = miConfig.Url
  34256. businessParams := models.BusinessParams{
  34257. Insutype: insutype,
  34258. ClrType: clr_type,
  34259. SetlOptins: clr_org,
  34260. StmtBegndate: start_time,
  34261. StmtEnddate: end_time,
  34262. MedfeeSumamt: medfee_sumamt,
  34263. FundPaySumamt: fund_pay_sumamt,
  34264. AcctPay: acct_pay,
  34265. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34266. }
  34267. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  34268. fmt.Println(requestLog)
  34269. fmt.Println(result)
  34270. fmt.Println(err_msg)
  34271. var dat map[string]interface{}
  34272. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34273. fmt.Println(dat)
  34274. } else {
  34275. fmt.Println(err)
  34276. }
  34277. userJSONBytes, _ := json.Marshal(dat)
  34278. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34279. utils.ErrorLog("解析失败:%v", err)
  34280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34281. return
  34282. }
  34283. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34284. if len(clr_type) == 0 {
  34285. clr_type = "11"
  34286. }
  34287. api := miConfig.Url + "gdyb/ten?" +
  34288. "insutype=" + insutype +
  34289. "&clr_type=" + clr_type +
  34290. "&setl_optins=" + clr_org +
  34291. "&stmt_begndate=" + start_time +
  34292. "&stm_enddate=" + end_time +
  34293. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34294. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34295. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34296. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34297. "&fixmedins_code=" + miConfig.Code +
  34298. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34299. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34300. "&secret_key=" + miConfig.SecretKey +
  34301. "&org_name=" + miConfig.OrgName +
  34302. "&doctor=" + user_name
  34303. fmt.Println(api)
  34304. resp, requestErr := http.Get(api)
  34305. if requestErr != nil {
  34306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34307. return
  34308. }
  34309. body, ioErr := ioutil.ReadAll(resp.Body)
  34310. fmt.Println(body)
  34311. if ioErr != nil {
  34312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34314. return
  34315. }
  34316. var respJSON map[string]interface{}
  34317. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34320. return
  34321. }
  34322. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34323. userJSONBytes, _ := json.Marshal(respJSON)
  34324. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34325. utils.ErrorLog("解析失败:%v", err)
  34326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34327. return
  34328. }
  34329. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34330. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34331. //fixmedins_setl_cnt := int64(len(orders_two))
  34332. //var medfee_sumamt float64
  34333. //var acct_pay float64
  34334. //var fund_pay_sumamt float64
  34335. //for _, item := range orders_two {
  34336. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34337. // acct_pay = acct_pay + item.AcctPay
  34338. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34339. //}
  34340. var baseParams models.BaseParams
  34341. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34342. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34343. baseParams.SecretKey = miConfig.SecretKey
  34344. baseParams.OrgName = miConfig.OrgName
  34345. baseParams.FixmedinsCode = miConfig.Code
  34346. baseParams.EncKey = miConfig.EncKey
  34347. baseParams.AppSecret = miConfig.AppSecret
  34348. baseParams.SignKey = miConfig.SignKey
  34349. baseParams.AppID = miConfig.Code
  34350. baseParams.Doctor = role.UserName
  34351. baseParams.RequestUrl = miConfig.Url
  34352. if clr_type == "9903" {
  34353. clr_type = "9901"
  34354. }
  34355. businessParams := models.BusinessParams{
  34356. Insutype: insutype,
  34357. ClrType: clr_type,
  34358. SetlOptins: "360302",
  34359. StmtBegndate: start_time,
  34360. StmtEnddate: end_time,
  34361. MedfeeSumamt: 0,
  34362. FundPaySumamt: 0,
  34363. AcctPay: 0,
  34364. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34365. }
  34366. 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))
  34367. fmt.Println(requestLog)
  34368. fmt.Println(result)
  34369. var dat map[string]interface{}
  34370. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34371. fmt.Println(dat)
  34372. } else {
  34373. fmt.Println(err)
  34374. }
  34375. userJSONBytes, _ := json.Marshal(dat)
  34376. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34377. utils.ErrorLog("解析失败:%v", err)
  34378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34379. return
  34380. }
  34381. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34382. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34383. //fixmedins_setl_cnt := int64(len(orders_two))
  34384. //var medfee_sumamt float64
  34385. //var acct_pay float64
  34386. //var fund_pay_sumamt float64
  34387. //for _, item := range orders_two {
  34388. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34389. // acct_pay = acct_pay + item.AcctPay
  34390. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34391. //}
  34392. var baseParams models.BaseParams
  34393. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34394. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34395. baseParams.SecretKey = miConfig.SecretKey
  34396. baseParams.OrgName = miConfig.OrgName
  34397. baseParams.FixmedinsCode = miConfig.Code
  34398. baseParams.EncKey = miConfig.EncKey
  34399. baseParams.AppSecret = miConfig.AppSecret
  34400. baseParams.SignKey = miConfig.SignKey
  34401. baseParams.AppID = miConfig.Code
  34402. baseParams.Doctor = role.UserName
  34403. baseParams.RequestUrl = miConfig.Url
  34404. if clr_type == "9903" {
  34405. clr_type = "9994"
  34406. }
  34407. businessParams := models.BusinessParams{
  34408. Insutype: insutype,
  34409. ClrType: clr_type,
  34410. SetlOptins: "361025",
  34411. StmtBegndate: start_time,
  34412. StmtEnddate: end_time,
  34413. MedfeeSumamt: 0,
  34414. FundPaySumamt: 0,
  34415. AcctPay: 0,
  34416. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34417. }
  34418. result, requestLog := service.Jxyb32012(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))
  34419. fmt.Println(requestLog)
  34420. fmt.Println(result)
  34421. var dat map[string]interface{}
  34422. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34423. fmt.Println(dat)
  34424. } else {
  34425. fmt.Println(err)
  34426. }
  34427. userJSONBytes, _ := json.Marshal(dat)
  34428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34429. utils.ErrorLog("解析失败:%v", err)
  34430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34431. return
  34432. }
  34433. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34434. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34435. //fixmedins_setl_cnt := int64(len(orders_two))
  34436. //var medfee_sumamt float64
  34437. //var acct_pay float64
  34438. //var fund_pay_sumamt float64
  34439. //for _, item := range orders_two {
  34440. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34441. // acct_pay = acct_pay + item.AcctPay
  34442. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34443. //}
  34444. var baseParams models.BaseParams
  34445. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34446. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34447. baseParams.SecretKey = miConfig.SecretKey
  34448. baseParams.OrgName = miConfig.OrgName
  34449. baseParams.FixmedinsCode = miConfig.Code
  34450. baseParams.EncKey = miConfig.EncKey
  34451. baseParams.AppSecret = miConfig.AppSecret
  34452. baseParams.SignKey = miConfig.SignKey
  34453. baseParams.AppID = miConfig.Code
  34454. baseParams.Doctor = role.UserName
  34455. baseParams.RequestUrl = miConfig.Url
  34456. if clr_type == "9903" {
  34457. clr_type = "9994"
  34458. }
  34459. businessParams := models.BusinessParams{
  34460. Insutype: insutype,
  34461. ClrType: clr_type,
  34462. SetlOptins: "360100",
  34463. StmtBegndate: start_time,
  34464. StmtEnddate: end_time,
  34465. MedfeeSumamt: 0,
  34466. FundPaySumamt: 0,
  34467. AcctPay: 0,
  34468. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34469. }
  34470. result, requestLog := service.Jxyb32012(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))
  34471. fmt.Println(requestLog)
  34472. fmt.Println(result)
  34473. var dat map[string]interface{}
  34474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34475. fmt.Println(dat)
  34476. } else {
  34477. fmt.Println(err)
  34478. }
  34479. userJSONBytes, _ := json.Marshal(dat)
  34480. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34481. utils.ErrorLog("解析失败:%v", err)
  34482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34483. return
  34484. }
  34485. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34486. var api string
  34487. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  34488. "&clr_type=" + clr_type +
  34489. "&setl_optins=" + clr_org +
  34490. "&stmt_begndate=" + start_time +
  34491. "&stm_enddate=" + end_time +
  34492. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34493. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34494. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34495. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34496. "&fixmedins_code=" + miConfig.Code +
  34497. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34498. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34499. "&secret_key=" + miConfig.SecretKey +
  34500. "&org_name=" + miConfig.OrgName +
  34501. "&doctor=" + user_name + "&url=" + miConfig.Url
  34502. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34503. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34504. resp, requestErr := http.Get(api)
  34505. if requestErr != nil {
  34506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34507. return
  34508. }
  34509. body, ioErr := ioutil.ReadAll(resp.Body)
  34510. if ioErr != nil {
  34511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34513. return
  34514. }
  34515. var respJSON map[string]interface{}
  34516. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34519. return
  34520. }
  34521. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34522. if status == "0" {
  34523. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34524. c.ServeSuccessJSON(map[string]interface{}{
  34525. "failed_code": -10,
  34526. "msg": err_msg,
  34527. })
  34528. return
  34529. }
  34530. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34531. userJSONBytes, _ := json.Marshal(respJSON)
  34532. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34533. utils.ErrorLog("解析失败:%v", err)
  34534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34535. return
  34536. }
  34537. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34538. var api string
  34539. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  34540. "&clr_type=" + clr_type +
  34541. "&setl_optins=" + clr_org +
  34542. "&stmt_begndate=" + start_time +
  34543. "&stm_enddate=" + end_time +
  34544. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34545. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34546. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34547. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34548. "&fixmedins_code=" + miConfig.Code +
  34549. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34550. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34551. "&secret_key=" + miConfig.SecretKey +
  34552. "&org_name=" + miConfig.OrgName +
  34553. "&doctor=" + user_name + "&url=" + miConfig.Url
  34554. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34555. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34556. resp, requestErr := http.Get(api)
  34557. if requestErr != nil {
  34558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34559. return
  34560. }
  34561. body, ioErr := ioutil.ReadAll(resp.Body)
  34562. if ioErr != nil {
  34563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34565. return
  34566. }
  34567. var respJSON map[string]interface{}
  34568. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34571. return
  34572. }
  34573. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34574. if status == "0" {
  34575. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34576. c.ServeSuccessJSON(map[string]interface{}{
  34577. "failed_code": -10,
  34578. "msg": err_msg,
  34579. })
  34580. return
  34581. }
  34582. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34583. userJSONBytes, _ := json.Marshal(respJSON)
  34584. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34585. utils.ErrorLog("解析失败:%v", err)
  34586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34587. return
  34588. }
  34589. } else {
  34590. if len(clr_type) == 0 {
  34591. clr_type = "11"
  34592. }
  34593. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34594. "insutype=" + insutype +
  34595. "&clr_type=" + clr_type +
  34596. "&setl_optins=" + clr_org +
  34597. "&stmt_begndate=" + start_time +
  34598. "&stm_enddate=" + end_time +
  34599. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34600. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34601. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34602. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34603. "&fixmedins_code=" + miConfig.Code +
  34604. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34605. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34606. "&secret_key=" + miConfig.SecretKey +
  34607. "&org_name=" + miConfig.OrgName +
  34608. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34609. fmt.Println(api)
  34610. resp, requestErr := http.Get(api)
  34611. if requestErr != nil {
  34612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34613. return
  34614. }
  34615. body, ioErr := ioutil.ReadAll(resp.Body)
  34616. fmt.Println(body)
  34617. if ioErr != nil {
  34618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34620. return
  34621. }
  34622. var respJSON map[string]interface{}
  34623. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34626. return
  34627. }
  34628. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34629. userJSONBytes, _ := json.Marshal(respJSON)
  34630. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34631. utils.ErrorLog("解析失败:%v", err)
  34632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34633. return
  34634. }
  34635. }
  34636. if res.Infcode == 0 {
  34637. if res.Output.Stmtinfo.StmtRslt == "0" {
  34638. micc := &models.MedicalInsuranceCostCompare{
  34639. StartTime: startime.Unix(),
  34640. EndTime: endtime.Unix(),
  34641. Insutype: insutype,
  34642. CheckType: 1,
  34643. Num: fixmedins_setl_cnt,
  34644. Mtime: time.Now().Unix(),
  34645. Status: 1,
  34646. UserOrgId: adminUser.CurrentOrgId,
  34647. CostTotal: medfee_sumamt,
  34648. FuncTotal: fund_pay_sumamt,
  34649. PsnPay: acct_pay,
  34650. Creator: admin_user_id,
  34651. Ctime: time.Now().Unix(),
  34652. ClrType: clr_type,
  34653. }
  34654. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  34655. if err == nil {
  34656. c.ServeSuccessJSON(map[string]interface{}{
  34657. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  34658. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  34659. })
  34660. } else {
  34661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34662. }
  34663. } else {
  34664. c.ServeSuccessJSON(map[string]interface{}{
  34665. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  34666. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  34667. })
  34668. }
  34669. } else {
  34670. c.ServeSuccessJSON(map[string]interface{}{
  34671. "failed_code": -10,
  34672. "msg": res.ErrMsg,
  34673. })
  34674. }
  34675. }
  34676. }
  34677. func (c *HisApiController) Check310() {
  34678. adminUser := c.GetAdminUserInfo()
  34679. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34680. var user_name string
  34681. user_name = "高慧裕"
  34682. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34683. "insutype=" + "310" +
  34684. "&clr_type=" + "" +
  34685. "&setl_optins=" + "441202" +
  34686. "&stmt_begndate=" + "2022-03-01" +
  34687. "&stm_enddate=" + "2022-03-31" +
  34688. "&medfee_sumamt=" + "194930.12" +
  34689. "&fund_pay_sumamt=" + "188741.46" +
  34690. "&acct_pay=" + "0" +
  34691. "&fixmedins_setl_cnt=" + "452" +
  34692. "&fixmedins_code=" + miConfig.Code +
  34693. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34694. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34695. "&secret_key=" + miConfig.SecretKey +
  34696. "&org_name=" + miConfig.OrgName +
  34697. "&doctor=" + user_name
  34698. fmt.Println(api)
  34699. resp, requestErr := http.Get(api)
  34700. if requestErr != nil {
  34701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34702. return
  34703. }
  34704. body, ioErr := ioutil.ReadAll(resp.Body)
  34705. fmt.Println(body)
  34706. if ioErr != nil {
  34707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34709. return
  34710. }
  34711. var respJSON map[string]interface{}
  34712. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34715. return
  34716. }
  34717. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34718. userJSONBytes, _ := json.Marshal(respJSON)
  34719. var res ResultEight
  34720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34721. utils.ErrorLog("解析失败:%v", err)
  34722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34723. return
  34724. }
  34725. }
  34726. func (c *HisApiController) Check390() {
  34727. adminUser := c.GetAdminUserInfo()
  34728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34729. var user_name string
  34730. user_name = "高慧裕"
  34731. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34732. "insutype=" + "390" +
  34733. "&clr_type=" + "" +
  34734. "&setl_optins=" + "441202" +
  34735. "&stmt_begndate=" + "2022-03-01" +
  34736. "&stm_enddate=" + "2022-03-31" +
  34737. "&medfee_sumamt=" + "1068448.89" +
  34738. "&fund_pay_sumamt=" + "1014677.62" +
  34739. "&acct_pay=" + "0" +
  34740. "&fixmedins_setl_cnt=" + "1950" +
  34741. "&fixmedins_code=" + miConfig.Code +
  34742. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34743. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34744. "&secret_key=" + miConfig.SecretKey +
  34745. "&org_name=" + miConfig.OrgName +
  34746. "&doctor=" + user_name
  34747. fmt.Println(api)
  34748. resp, requestErr := http.Get(api)
  34749. if requestErr != nil {
  34750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34751. return
  34752. }
  34753. body, ioErr := ioutil.ReadAll(resp.Body)
  34754. fmt.Println(body)
  34755. if ioErr != nil {
  34756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34758. return
  34759. }
  34760. var respJSON map[string]interface{}
  34761. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34764. return
  34765. }
  34766. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34767. userJSONBytes, _ := json.Marshal(respJSON)
  34768. var res ResultEight
  34769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34770. utils.ErrorLog("解析失败:%v", err)
  34771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34772. return
  34773. }
  34774. }
  34775. // 对账明细
  34776. func (c *HisApiController) GetCheckDetailAccount() {
  34777. start_time := c.GetString("start_time")
  34778. end_time := c.GetString("end_time")
  34779. admin_user_id, _ := c.GetInt64("admin_user_id")
  34780. adminUser := c.GetAdminUserInfo()
  34781. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34782. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34783. timeLayout := "2006-01-02"
  34784. loc, _ := time.LoadLocation("Local")
  34785. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34786. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34787. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34788. rand.Seed(time.Now().UnixNano())
  34789. num := rand.Intn(30000)
  34790. Mkdir(miConfig.OrgName)
  34791. file := strconv.FormatInt(int64(num), 10)
  34792. file_name := file + ".txt"
  34793. zip_name := file + ".zip"
  34794. zip_path := miConfig.OrgName + "/" + zip_name
  34795. file_path := miConfig.OrgName + "/" + file_name
  34796. decimal.DivisionPrecision = 2
  34797. var medfee_sumamt float64
  34798. var psn_cash_pay float64
  34799. var fund_pay_sumamt float64
  34800. fixmedins_setl_cnt := int64(len(orders))
  34801. for _, item := range orders {
  34802. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34803. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  34804. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34805. }
  34806. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  34807. defer f.Close()
  34808. if err != nil {
  34809. fmt.Println(err.Error())
  34810. } else {
  34811. for _, item := range orders {
  34812. var refd_setl_flag string
  34813. if item.OrderStatus == 2 {
  34814. refd_setl_flag = "0"
  34815. var str string
  34816. str = item.SetlId + " " +
  34817. item.MdtrtId + " " +
  34818. item.PsnNo + " " +
  34819. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34820. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34821. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  34822. _, err = f.Write([]byte(str))
  34823. }
  34824. if item.OrderStatus == 3 {
  34825. var str string
  34826. str = item.SetlId + " " +
  34827. item.MdtrtId + " " +
  34828. item.PsnNo + " " +
  34829. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34830. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34831. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  34832. _, err = f.Write([]byte(str))
  34833. var str2 string
  34834. str2 = item.SetlId + " " +
  34835. item.MdtrtId + " " +
  34836. item.PsnNo + " " +
  34837. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  34838. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  34839. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  34840. _, err = f.Write([]byte(str2))
  34841. }
  34842. }
  34843. }
  34844. Zip(file_path, zip_path)
  34845. fmt.Println(ReadFile(zip_path))
  34846. fmt.Println(string(ReadFile(zip_path)))
  34847. if config.IsOpen == 1 {
  34848. var user_name string
  34849. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34850. if role.ID == 0 {
  34851. user_name = "管理员"
  34852. } else {
  34853. user_name = role.UserName
  34854. }
  34855. baseParams := models.BaseParams{
  34856. SecretKey: miConfig.SecretKey,
  34857. FixmedinsCode: miConfig.Code,
  34858. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34859. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34860. OrgName: miConfig.OrgName,
  34861. Doctor: user_name,
  34862. }
  34863. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  34864. var dat map[string]interface{}
  34865. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34866. fmt.Println(dat)
  34867. } else {
  34868. fmt.Println(err)
  34869. }
  34870. userJSONBytes, _ := json.Marshal(dat)
  34871. var res ResultNine
  34872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34873. utils.ErrorLog("解析失败:%v", err)
  34874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34875. return
  34876. }
  34877. if res.Infcode == 0 {
  34878. fileNo := res.Output.FileQuryNo
  34879. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34880. "file_qury_no=" + fileNo +
  34881. "&setl_optins=" + "定点医保中心" +
  34882. "&stmt_begndate=" + start_time +
  34883. "&stm_enddate=" + end_time +
  34884. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34885. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34886. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34887. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34888. "&fixmedins_code=" + miConfig.Code +
  34889. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34890. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34891. "&secret_key=" + miConfig.SecretKey +
  34892. "&org_name=" + miConfig.OrgName +
  34893. "&doctor=" + user_name
  34894. resp, requestErr := http.Get(api)
  34895. if requestErr != nil {
  34896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34897. return
  34898. }
  34899. body, ioErr := ioutil.ReadAll(resp.Body)
  34900. if ioErr != nil {
  34901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34903. return
  34904. }
  34905. var respJSON map[string]interface{}
  34906. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34909. return
  34910. }
  34911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34912. userJSONBytes, _ := json.Marshal(respJSON)
  34913. var res ResultTen
  34914. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34915. utils.ErrorLog("解析失败:%v", err)
  34916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34917. return
  34918. }
  34919. if res.Infcode == 0 {
  34920. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34921. micc := &models.MedicalInsuranceCostCompare{
  34922. StartTime: startime.Unix(),
  34923. EndTime: endtime.Unix(),
  34924. Insutype: "0",
  34925. CheckType: 2,
  34926. Num: fixmedins_setl_cnt,
  34927. Mtime: time.Now().Unix(),
  34928. Status: 1,
  34929. UserOrgId: adminUser.CurrentOrgId,
  34930. CostTotal: medfee_sumamt,
  34931. FuncTotal: fund_pay_sumamt,
  34932. PsnPay: psn_cash_pay,
  34933. Creator: admin_user_id,
  34934. Ctime: time.Now().Unix(),
  34935. }
  34936. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34937. c.ServeSuccessJSON(map[string]interface{}{
  34938. "msg": "明细对账成功",
  34939. })
  34940. }
  34941. } else {
  34942. }
  34943. }
  34944. }
  34945. type CustomOrderInfo struct {
  34946. Name string
  34947. Spec string
  34948. Unit string
  34949. Count float64
  34950. Price float64
  34951. Total float64
  34952. }
  34953. func (c *HisApiController) GetBatchSettleAccounts() {
  34954. admin_user_id, _ := c.GetInt64("admin_user_id")
  34955. order_ids := c.GetString("order_ids")
  34956. order_ids_arr := strings.Split(order_ids, ",")
  34957. data3 := []map[string]interface{}{}
  34958. for _, item := range order_ids_arr {
  34959. id, _ := strconv.ParseInt(item, 10, 64)
  34960. order_id := id
  34961. adminUser := c.GetAdminUserInfo()
  34962. order, _ := service.GetHisOrderByID(order_id)
  34963. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34964. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34965. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34966. orderInfos = append(orderInfos, orderInfos_two...)
  34967. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34968. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34969. var diagnosis_ids []string
  34970. if his.ID > 0 {
  34971. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34972. } else {
  34973. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34974. }
  34975. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34976. var dia_config []*models.HisXtDiagnoseConfig
  34977. var name string
  34978. for _, item := range diagnosis_ids {
  34979. id, _ := strconv.ParseInt(item, 10, 64)
  34980. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34981. dia_config = append(dia_config, &diagnosisConfig)
  34982. if len(name) == 0 {
  34983. name = diagnosisConfig.ClassName
  34984. }
  34985. //} else {
  34986. // name = name + "," + diagnosisConfig.ClassName
  34987. //}
  34988. }
  34989. var bedCostTotal float64 = 0 //床位总费
  34990. var bedCostSelfTotal float64 = 0 //床位自费
  34991. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34992. var bedSelfTotal float64 = 0 //床位部分项目自费
  34993. var bedInscpTotal float64 = 0 //床位部分项目自费
  34994. var operationCostTotal float64 = 0 //手术费
  34995. var operationCostSelfTotal float64 = 0 //手术费
  34996. var operationCostPartSelfTotal float64 = 0 //手术费
  34997. var operationSelfTotal float64 = 0 //床位部分项目自费
  34998. var operationInscpTotal float64 = 0 //床位部分项目自费
  34999. var otherCostTotal float64 = 0 //其他费用
  35000. var otherCostSelfTotal float64 = 0 //其他费用
  35001. var otherCostPartSelfTotal float64 = 0 //其他费用
  35002. var otherSelfTotal float64 = 0 //床位部分项目自费
  35003. var otherInscpTotal float64 = 0 //床位部分项目自费
  35004. var materialCostTotal float64 = 0 //材料费
  35005. var materialCostSelfTotal float64 = 0 //材料费
  35006. var materialCostPartSelfTotal float64 = 0 //材料费
  35007. var materialSelfTotal float64 = 0 //床位部分项目自费
  35008. var materialInscpTotal float64 = 0 //床位部分项目自费
  35009. var westernMedicineCostTotal float64 = 0 //西药费
  35010. var westernMedicineCostSelfTotal float64 = 0 //西药费
  35011. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  35012. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  35013. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  35014. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  35015. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  35016. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  35017. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  35018. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  35019. var checkCostTotal float64 = 0 //检查费
  35020. var checkCostSelfTotal float64 = 0 //检查费
  35021. var checkCostPartSelfTotal float64 = 0 //检查费
  35022. var checkSelfTotal float64 = 0 //床位部分项目自费
  35023. var checkInscpTotal float64 = 0 //床位部分项目自费
  35024. var laboratoryCostTotal float64 = 0 //化验费
  35025. var laboratoryCostSelfTotal float64 = 0 //化验费
  35026. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  35027. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  35028. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  35029. var treatCostTotal float64 = 0 //治疗费用
  35030. var treatCostSelfTotal float64 = 0 //治疗费用
  35031. var treatCostPartSelfTotal float64 = 0 //治疗费用
  35032. var treatSelfTotal float64 = 0 //床位部分项目自费
  35033. var treatInscpTotal float64 = 0 //床位部分项目自费
  35034. decimal.DivisionPrecision = 2
  35035. for _, item := range orderInfos {
  35036. if item.MedChrgitmType == "01" { //床位费
  35037. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35038. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35039. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35040. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35041. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35042. }
  35043. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  35044. if item.MedChrgitmType == "03" { //检查费
  35045. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35046. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35047. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35048. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35049. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35050. }
  35051. } else {
  35052. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  35053. fmt.Println("------------")
  35054. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35055. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35056. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35057. }
  35058. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  35059. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35060. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35061. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35062. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35063. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35064. }
  35065. }
  35066. if item.MedChrgitmType == "04" { //化验费
  35067. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35068. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35069. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35070. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35071. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35072. }
  35073. if item.MedChrgitmType == "05" { //治疗费
  35074. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35075. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35076. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35077. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35078. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35079. }
  35080. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  35081. fmt.Println("------------")
  35082. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35083. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35084. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35085. }
  35086. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  35087. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35088. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35089. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35090. }
  35091. //if item.MedChrgitmType == "06" { //手术费
  35092. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35093. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35094. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35095. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35096. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35097. //
  35098. //}
  35099. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  35100. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35101. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35102. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35103. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35104. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35105. }
  35106. if item.MedChrgitmType == "09" { //西药费
  35107. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35108. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35109. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35110. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35111. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35112. }
  35113. if item.MedChrgitmType == "11" { //中成费
  35114. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35115. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35116. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35117. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35118. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35119. }
  35120. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  35121. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35122. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35123. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35124. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35125. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35126. }
  35127. }
  35128. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35129. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35130. var user_name string
  35131. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35132. if role.ID == 0 {
  35133. user_name = "管理员"
  35134. } else {
  35135. user_name = role.UserName
  35136. }
  35137. baseParams := models.BaseParams{
  35138. SecretKey: miConfig.SecretKey,
  35139. FixmedinsCode: miConfig.Code,
  35140. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35141. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35142. OrgName: miConfig.OrgName,
  35143. Doctor: user_name,
  35144. RequestUrl: miConfig.Url,
  35145. AccessKey: miConfig.AccessKey,
  35146. }
  35147. businessParams := models.BusinessParams{
  35148. PsnNo: order.PsnNo,
  35149. MdtrtId: order.MdtrtId,
  35150. SetlId: order.SetlId,
  35151. }
  35152. var res ResultEleven
  35153. var resEleven10265 ResultEleven10265
  35154. if config.IsOpen == 1 {
  35155. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35156. result := service.Gdyb5203(baseParams, businessParams)
  35157. service.Gdyb5204(baseParams, businessParams)
  35158. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35159. var dat map[string]interface{}
  35160. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35161. fmt.Println(dat)
  35162. } else {
  35163. fmt.Println(err)
  35164. }
  35165. userJSONBytes, _ := json.Marshal(dat)
  35166. if miConfig.Code == "H15049901371" {
  35167. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35168. utils.ErrorLog("解析失败:%v", err)
  35169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35170. return
  35171. }
  35172. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35173. res.Output = resEleven10265.Output
  35174. res.ErrMsg = resEleven10265.ErrMsg
  35175. res.Cainfo = resEleven10265.Cainfo
  35176. res.WarnMsg = resEleven10265.WarnMsg
  35177. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35178. res.Infcode = infocode
  35179. } else {
  35180. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35181. utils.ErrorLog("解析失败:%v", err)
  35182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35183. return
  35184. }
  35185. }
  35186. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35187. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35188. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35189. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35190. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35191. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35192. var doctor_name string
  35193. if roles.ID == 0 {
  35194. doctor_name = "管理员"
  35195. } else {
  35196. doctor_name = roles.UserName
  35197. }
  35198. yiliao_leibie := ""
  35199. switch order.MedType {
  35200. case "11":
  35201. yiliao_leibie = "普通门诊"
  35202. break
  35203. case "12":
  35204. yiliao_leibie = "门诊挂号"
  35205. break
  35206. case "13":
  35207. yiliao_leibie = "急诊"
  35208. break
  35209. case "14":
  35210. yiliao_leibie = "门诊特殊病"
  35211. break
  35212. case "15":
  35213. yiliao_leibie = "门诊统筹"
  35214. break
  35215. case "16":
  35216. yiliao_leibie = "门诊慢性病"
  35217. break
  35218. case "21":
  35219. yiliao_leibie = "普通住院"
  35220. break
  35221. }
  35222. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35223. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  35224. if res.Infcode == 0 {
  35225. data2 := map[string]interface{}{
  35226. "diagnosis": name,
  35227. "order_infos": orderInfos,
  35228. "number": order.MdtrtId,
  35229. "date": order.SettleAccountsDate,
  35230. "charge_admin": charge_admin,
  35231. "printor_admin": printor_admin,
  35232. "info": res.Output.Setlinfo,
  35233. "order": order,
  35234. "bedCostTotal": bedCostTotal,
  35235. "bedCostSelfTotal": bedCostSelfTotal,
  35236. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35237. "bedSelfTotal": bedSelfTotal,
  35238. "bedInscpTotal": bedInscpTotal,
  35239. "operationCostTotal": operationCostTotal,
  35240. "operationCostSelfTotal": operationCostSelfTotal,
  35241. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35242. "operationSelfTotal": operationSelfTotal,
  35243. "operationInscpTotal": operationInscpTotal,
  35244. "otherCostTotal": otherCostTotal,
  35245. "otherCostSelfTotal": otherCostSelfTotal,
  35246. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35247. "otherSelfTotal": otherSelfTotal,
  35248. "otherInscpTotal": otherInscpTotal,
  35249. "materialCostTotal": materialCostTotal,
  35250. "materialCostSelfTotal": materialCostSelfTotal,
  35251. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35252. "materialSelfTotal": materialSelfTotal,
  35253. "materialInscpTotal": materialInscpTotal,
  35254. "westernMedicineCostTotal": westernMedicineCostTotal,
  35255. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35256. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35257. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35258. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35259. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35260. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35261. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35262. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35263. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35264. "checkCostTotal": checkCostTotal,
  35265. "checkCostSelfTotal": checkCostSelfTotal,
  35266. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35267. "checkSelfTotal": checkSelfTotal,
  35268. "checkInscpTotal": checkInscpTotal,
  35269. "laboratoryCostTotal": laboratoryCostTotal,
  35270. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35271. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35272. "laboratorySelfTotal": laboratorySelfTotal,
  35273. "laboratoryInscpTotal": laboratoryInscpTotal,
  35274. "treatCostTotal": treatCostTotal,
  35275. "treatCostSelfTotal": treatCostSelfTotal,
  35276. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35277. "treatSelfTotal": treatSelfTotal,
  35278. "treatInscpTotal": treatInscpTotal,
  35279. "doctor_info": doctor_info,
  35280. "doctor_code": adminRole_two.DoctorCode,
  35281. "doctor_name": doctor_name,
  35282. "health_card_no": order.PsnNo,
  35283. "department": departments.Name,
  35284. "yiliao_leibie": yiliao_leibie,
  35285. "after_money": order.AccountPrice,
  35286. "patient": patient,
  35287. "org_name": miConfig.OrgName,
  35288. "org_code": miConfig.Code,
  35289. "order_number": order.Number,
  35290. "his_hospital": his_hospital,
  35291. "his": his,
  35292. "dia_config": dia_config,
  35293. "psn_cash_pay": order.PsnCashPay,
  35294. //"check_order_info": cus_slice,
  35295. }
  35296. data3 = append(data3, data2)
  35297. }
  35298. }
  35299. }
  35300. c.ServeSuccessJSON(map[string]interface{}{
  35301. "infos": data3,
  35302. })
  35303. }
  35304. func (c *HisApiController) GetSettleAccounts() {
  35305. //id, _ := c.GetInt64("id")
  35306. //record_time := c.GetString("record_time")
  35307. order_id, _ := c.GetInt64("order_id")
  35308. admin_user_id, _ := c.GetInt64("admin_user_id")
  35309. //timeLayout := "2006-01-02"
  35310. //loc, _ := time.LoadLocation("Local")
  35311. //
  35312. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35313. //if err != nil {
  35314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35315. // return
  35316. //}Hbyb5203
  35317. //recordDateTime := theTime.Unix()
  35318. adminUser := c.GetAdminUserInfo()
  35319. order, _ := service.GetHisOrderByID(order_id)
  35320. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35321. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  35322. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  35323. orderInfos = append(orderInfos, orderInfos_two...)
  35324. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  35325. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  35326. var diagnosis_ids []string
  35327. if his.ID > 0 {
  35328. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  35329. } else {
  35330. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  35331. }
  35332. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  35333. var dia_config []*models.HisXtDiagnoseConfig
  35334. var name string
  35335. for _, item := range diagnosis_ids {
  35336. id, _ := strconv.ParseInt(item, 10, 64)
  35337. diagnosisConfig, _ := service.FindDiagnoseById(id)
  35338. dia_config = append(dia_config, &diagnosisConfig)
  35339. if len(name) == 0 {
  35340. name = diagnosisConfig.ClassName
  35341. } else {
  35342. name = name + "," + diagnosisConfig.ClassName
  35343. }
  35344. }
  35345. if patient.UserOrgId == 10215 {
  35346. name = "慢性肾功能不全(血透治疗)"
  35347. }
  35348. var bedCostTotal float64 = 0 //床位总费
  35349. var bedCostSelfTotal float64 = 0 //床位自费
  35350. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  35351. var bedSelfTotal float64 = 0 //床位部分项目自费
  35352. var bedInscpTotal float64 = 0 //床位部分项目自费
  35353. var operationCostTotal float64 = 0 //手术费
  35354. var operationCostSelfTotal float64 = 0 //手术费
  35355. var operationCostPartSelfTotal float64 = 0 //手术费
  35356. var operationSelfTotal float64 = 0 //床位部分项目自费
  35357. var operationInscpTotal float64 = 0 //床位部分项目自费
  35358. var otherCostTotal float64 = 0 //其他费用
  35359. var otherCostSelfTotal float64 = 0 //其他费用
  35360. var otherCostPartSelfTotal float64 = 0 //其他费用
  35361. var otherSelfTotal float64 = 0 //床位部分项目自费
  35362. var otherInscpTotal float64 = 0 //床位部分项目自费
  35363. var materialCostTotal float64 = 0 //材料费
  35364. var materialCostSelfTotal float64 = 0 //材料费
  35365. var materialCostPartSelfTotal float64 = 0 //材料费
  35366. var materialSelfTotal float64 = 0 //床位部分项目自费
  35367. var materialInscpTotal float64 = 0 //床位部分项目自费
  35368. var westernMedicineCostTotal float64 = 0 //西药费
  35369. var westernMedicineCostSelfTotal float64 = 0 //西药费
  35370. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  35371. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  35372. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  35373. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  35374. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  35375. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  35376. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  35377. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  35378. var checkCostTotal float64 = 0 //检查费
  35379. var checkCostSelfTotal float64 = 0 //检查费
  35380. var checkCostPartSelfTotal float64 = 0 //检查费
  35381. var checkSelfTotal float64 = 0 //床位部分项目自费
  35382. var checkInscpTotal float64 = 0 //床位部分项目自费
  35383. var laboratoryCostTotal float64 = 0 //化验费
  35384. var laboratoryCostSelfTotal float64 = 0 //化验费
  35385. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  35386. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  35387. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  35388. var treatCostTotal float64 = 0 //治疗费用
  35389. var treatCostSelfTotal float64 = 0 //治疗费用
  35390. var treatCostPartSelfTotal float64 = 0 //治疗费用
  35391. var treatSelfTotal float64 = 0 //床位部分项目自费
  35392. var treatInscpTotal float64 = 0 //床位部分项目自费
  35393. var zcCostTotal float64 = 0 //治疗费用
  35394. var zcCostSelfTotal float64 = 0 //治疗费用
  35395. var zcCostPartSelfTotal float64 = 0 //治疗费用
  35396. var zcSelfTotal float64 = 0 //床位部分项目自费
  35397. var zcInscpTotal float64 = 0 //床位部分项目自费
  35398. var huliCostTotal float64 = 0 //治疗费用
  35399. var huliCostSelfTotal float64 = 0 //治疗费用
  35400. var huliCostPartSelfTotal float64 = 0 //治疗费用
  35401. var huliSelfTotal float64 = 0 //床位部分项目自费
  35402. var huliInscpTotal float64 = 0 //床位部分项目自费
  35403. decimal.DivisionPrecision = 2
  35404. for _, item := range orderInfos {
  35405. if item.MedChrgitmType == "01" { //床位费
  35406. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35407. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35408. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35409. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35410. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35411. }
  35412. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  35413. if item.MedChrgitmType == "03" { //检查费
  35414. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35415. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35416. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35417. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35418. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35419. }
  35420. } else {
  35421. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  35422. fmt.Println("------------")
  35423. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35424. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35425. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35426. }
  35427. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  35428. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35429. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35430. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35431. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35432. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35433. }
  35434. }
  35435. if item.MedChrgitmType == "04" { //化验费
  35436. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35437. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35438. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35439. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35440. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35441. }
  35442. if item.MedChrgitmType == "05" { //治疗费
  35443. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35444. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35445. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35446. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35447. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35448. }
  35449. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  35450. fmt.Println("------------")
  35451. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35452. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35453. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35454. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35455. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35456. }
  35457. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  35458. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35459. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35460. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35461. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35462. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35463. }
  35464. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  35465. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35466. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35467. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35468. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35469. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35470. }
  35471. if item.MedChrgitmType == "09" { //西药费
  35472. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35473. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35474. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35475. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35476. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35477. }
  35478. if item.MedChrgitmType == "11" { //中成费
  35479. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35480. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35481. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35482. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35483. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35484. }
  35485. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  35486. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35487. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35488. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35489. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35490. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35491. }
  35492. if item.MedChrgitmType == "02" { //其他费
  35493. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35494. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35495. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35496. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35497. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35498. }
  35499. if item.MedChrgitmType == "07" { //其他费
  35500. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35501. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35502. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35503. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35504. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35505. }
  35506. }
  35507. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35508. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35509. var user_name string
  35510. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35511. if role.ID == 0 {
  35512. user_name = "管理员"
  35513. } else {
  35514. user_name = role.UserName
  35515. }
  35516. baseParams := models.BaseParams{
  35517. SecretKey: miConfig.SecretKey,
  35518. FixmedinsCode: miConfig.Code,
  35519. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35520. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35521. OrgName: miConfig.OrgName,
  35522. Doctor: user_name,
  35523. RequestUrl: miConfig.Url,
  35524. AccessKey: miConfig.AccessKey,
  35525. }
  35526. businessParams := models.BusinessParams{
  35527. PsnNo: order.PsnNo,
  35528. MdtrtId: order.MdtrtId,
  35529. SetlId: order.SetlId,
  35530. }
  35531. var res ResultEleven
  35532. var resah ResultElevenah
  35533. var resEleven10265 ResultEleven10265
  35534. if config.IsOpen == 1 {
  35535. if miConfig.MdtrtareaAdmvs == "421300" {
  35536. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35537. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35538. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35539. resp, requestErr := http.Get(api)
  35540. if requestErr != nil {
  35541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35542. return
  35543. }
  35544. body, ioErr := ioutil.ReadAll(resp.Body)
  35545. if ioErr != nil {
  35546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35548. return
  35549. }
  35550. var respJSON map[string]interface{}
  35551. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35554. return
  35555. }
  35556. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35557. result, _ := json.Marshal(respJSON)
  35558. fmt.Println("log")
  35559. fmt.Println(string(result))
  35560. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35561. utils.ErrorLog("解析失败:%v", err)
  35562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35563. return
  35564. }
  35565. } else if miConfig.MdtrtareaAdmvs == "420200" {
  35566. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35567. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35568. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35569. resp, requestErr := http.Get(api)
  35570. if requestErr != nil {
  35571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35572. return
  35573. }
  35574. body, ioErr := ioutil.ReadAll(resp.Body)
  35575. if ioErr != nil {
  35576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35578. return
  35579. }
  35580. var respJSON map[string]interface{}
  35581. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35584. return
  35585. }
  35586. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35587. result, _ := json.Marshal(respJSON)
  35588. fmt.Println("log")
  35589. fmt.Println(string(result))
  35590. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35591. utils.ErrorLog("解析失败:%v", err)
  35592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35593. return
  35594. }
  35595. } else if miConfig.MdtrtareaAdmvs == "420902" {
  35596. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35597. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35598. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35599. resp, requestErr := http.Get(api)
  35600. if requestErr != nil {
  35601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35602. return
  35603. }
  35604. body, ioErr := ioutil.ReadAll(resp.Body)
  35605. if ioErr != nil {
  35606. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35608. return
  35609. }
  35610. var respJSON map[string]interface{}
  35611. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35612. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35614. return
  35615. }
  35616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35617. result, _ := json.Marshal(respJSON)
  35618. fmt.Println("log")
  35619. fmt.Println(string(result))
  35620. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35621. utils.ErrorLog("解析失败:%v", err)
  35622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35623. return
  35624. }
  35625. } else if miConfig.MdtrtareaAdmvs == "421182" {
  35626. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35627. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35628. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  35629. resp, requestErr := http.Get(api)
  35630. if requestErr != nil {
  35631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35632. return
  35633. }
  35634. body, ioErr := ioutil.ReadAll(resp.Body)
  35635. if ioErr != nil {
  35636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35638. return
  35639. }
  35640. var respJSON map[string]interface{}
  35641. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35644. return
  35645. }
  35646. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35647. result, _ := json.Marshal(respJSON)
  35648. fmt.Println("log")
  35649. fmt.Println(string(result))
  35650. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35651. utils.ErrorLog("解析失败:%v", err)
  35652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35653. return
  35654. }
  35655. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  35656. var api string
  35657. if miConfig.MdtrtareaAdmvs == "320921" {
  35658. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35659. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35660. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35661. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35662. } else {
  35663. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35664. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35665. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35666. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35667. }
  35668. resp, requestErr := http.Get(api)
  35669. if requestErr != nil {
  35670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35671. return
  35672. }
  35673. body, ioErr := ioutil.ReadAll(resp.Body)
  35674. if ioErr != nil {
  35675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35677. return
  35678. }
  35679. var respJSON map[string]interface{}
  35680. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35683. return
  35684. }
  35685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35686. result, _ := json.Marshal(respJSON)
  35687. fmt.Println("log")
  35688. fmt.Println(string(result))
  35689. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35690. utils.ErrorLog("解析失败:%v", err)
  35691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35692. return
  35693. }
  35694. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35695. res.Output = resEleven10265.Output
  35696. res.ErrMsg = resEleven10265.ErrMsg
  35697. res.Cainfo = resEleven10265.Cainfo
  35698. res.WarnMsg = resEleven10265.WarnMsg
  35699. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35700. res.Infcode = infocode
  35701. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35702. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  35703. saveLog(result, requestLog, "5203", "结算单")
  35704. var dat map[string]interface{}
  35705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35706. fmt.Println(dat)
  35707. } else {
  35708. fmt.Println(err)
  35709. }
  35710. userJSONBytes, _ := json.Marshal(dat)
  35711. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35712. utils.ErrorLog("解析失败:%v", err)
  35713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35714. return
  35715. }
  35716. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35717. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35718. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35719. saveLog(result, requestLog, "5203", "结算单")
  35720. var dat map[string]interface{}
  35721. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35722. fmt.Println(dat)
  35723. } else {
  35724. fmt.Println(err)
  35725. }
  35726. userJSONBytes, _ := json.Marshal(dat)
  35727. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35728. utils.ErrorLog("解析失败:%v", err)
  35729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35730. return
  35731. }
  35732. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35733. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35734. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35735. saveLog(result, requestLog, "5203", "结算单")
  35736. var dat map[string]interface{}
  35737. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35738. fmt.Println(dat)
  35739. } else {
  35740. fmt.Println(err)
  35741. }
  35742. userJSONBytes, _ := json.Marshal(dat)
  35743. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35744. utils.ErrorLog("解析失败:%v", err)
  35745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35746. return
  35747. }
  35748. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35749. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35750. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35751. saveLog(result, requestLog, "5203", "结算单")
  35752. var dat map[string]interface{}
  35753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35754. fmt.Println(dat)
  35755. } else {
  35756. fmt.Println(err)
  35757. }
  35758. userJSONBytes, _ := json.Marshal(dat)
  35759. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35760. utils.ErrorLog("解析失败:%v", err)
  35761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35762. return
  35763. }
  35764. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35765. var api string
  35766. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35767. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35768. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35769. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35770. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35771. resp, requestErr := http.Get(api)
  35772. if requestErr != nil {
  35773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35774. return
  35775. }
  35776. body, ioErr := ioutil.ReadAll(resp.Body)
  35777. if ioErr != nil {
  35778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35780. return
  35781. }
  35782. var respJSON map[string]interface{}
  35783. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35786. return
  35787. }
  35788. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35789. if status == "0" {
  35790. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35791. c.ServeSuccessJSON(map[string]interface{}{
  35792. "failed_code": -10,
  35793. "msg": err_msg,
  35794. })
  35795. return
  35796. }
  35797. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35798. result, _ := json.Marshal(respJSON)
  35799. fmt.Println("log")
  35800. fmt.Println(string(result))
  35801. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35802. utils.ErrorLog("解析失败:%v", err)
  35803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35804. return
  35805. }
  35806. res.InfRefmsgid = resah.InfRefmsgid
  35807. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35808. // 创建对应的Time类型
  35809. t := time.UnixMilli(timestamp)
  35810. // 格式化成指定的日期字符串
  35811. str := t.Format("2006-01-02 15:04:05")
  35812. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35813. // 创建对应的Time类型
  35814. t3 := time.UnixMilli(timestamp2)
  35815. // 格式化成指定的日期字符串
  35816. str2 := t3.Format("2006-01-02 15:04:05")
  35817. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35818. // 创建对应的Time类型
  35819. t4 := time.UnixMilli(timestamp3)
  35820. // 格式化成指定的日期字符串
  35821. str3 := t4.Format("2006-01-02 15:04:05")
  35822. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35823. // 创建对应的Time类型
  35824. t5 := time.UnixMilli(timestamp4)
  35825. // 格式化成指定的日期字符串
  35826. str5 := t5.Format("2006-01-02 15:04:05")
  35827. res.Output.Setlinfo.Brdy = str2
  35828. res.Output.Setlinfo.SetlTime = str
  35829. res.Output.Setlinfo.Begndate = str3
  35830. res.Output.Setlinfo.Enddate = str5
  35831. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35832. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35833. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35834. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35835. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35836. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35837. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35838. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35839. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35840. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35841. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35842. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35843. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35844. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35845. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35846. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35847. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35848. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35849. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35850. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35851. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35852. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35853. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35854. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35855. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35856. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35857. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35858. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35859. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35860. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35861. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35862. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35863. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35864. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35865. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35866. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35867. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35868. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35869. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35870. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35871. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35872. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35873. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35874. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35875. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35876. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35877. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35878. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35879. //res.Output.Setldetail = resah.Output.Setldetail
  35880. res.ErrMsg = resah.ErrMsg
  35881. res.Cainfo = resah.Cainfo
  35882. res.WarnMsg = resah.WarnMsg
  35883. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35884. var api string
  35885. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35886. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35887. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35888. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35889. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35890. resp, requestErr := http.Get(api)
  35891. if requestErr != nil {
  35892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35893. return
  35894. }
  35895. body, ioErr := ioutil.ReadAll(resp.Body)
  35896. if ioErr != nil {
  35897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35899. return
  35900. }
  35901. var respJSON map[string]interface{}
  35902. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35905. return
  35906. }
  35907. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35908. if status == "0" {
  35909. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35910. c.ServeSuccessJSON(map[string]interface{}{
  35911. "failed_code": -10,
  35912. "msg": err_msg,
  35913. })
  35914. return
  35915. }
  35916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35917. result, _ := json.Marshal(respJSON)
  35918. fmt.Println("log")
  35919. fmt.Println(string(result))
  35920. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35921. utils.ErrorLog("解析失败:%v", err)
  35922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35923. return
  35924. }
  35925. res.InfRefmsgid = resah.InfRefmsgid
  35926. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35927. // 创建对应的Time类型
  35928. t := time.UnixMilli(timestamp)
  35929. // 格式化成指定的日期字符串
  35930. str := t.Format("2006-01-02 15:04:05")
  35931. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35932. // 创建对应的Time类型
  35933. t3 := time.UnixMilli(timestamp2)
  35934. // 格式化成指定的日期字符串
  35935. str2 := t3.Format("2006-01-02 15:04:05")
  35936. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35937. // 创建对应的Time类型
  35938. t4 := time.UnixMilli(timestamp3)
  35939. // 格式化成指定的日期字符串
  35940. str3 := t4.Format("2006-01-02 15:04:05")
  35941. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35942. // 创建对应的Time类型
  35943. t5 := time.UnixMilli(timestamp4)
  35944. // 格式化成指定的日期字符串
  35945. str5 := t5.Format("2006-01-02 15:04:05")
  35946. res.Output.Setlinfo.Brdy = str2
  35947. res.Output.Setlinfo.SetlTime = str
  35948. res.Output.Setlinfo.Begndate = str3
  35949. res.Output.Setlinfo.Enddate = str5
  35950. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35951. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35952. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35953. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35954. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35955. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35956. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35957. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35958. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35959. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35960. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35961. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35962. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35963. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35964. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35965. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35966. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35967. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35968. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35969. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35970. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35971. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35972. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35973. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35974. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35975. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35976. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35977. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35978. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35979. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35980. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35981. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35982. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35983. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35984. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35985. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35986. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35987. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35988. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35989. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35990. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35991. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35992. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35993. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35994. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35995. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35996. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35997. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35998. //res.Output.Setldetail = resah.Output.Setldetail
  35999. res.ErrMsg = resah.ErrMsg
  36000. res.Cainfo = resah.Cainfo
  36001. res.WarnMsg = resah.WarnMsg
  36002. } else if miConfig.MdtrtareaAdmvs == "430800" {
  36003. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  36004. saveLog(result, requestLog, "5203", "结算单")
  36005. var dat map[string]interface{}
  36006. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36007. fmt.Println(dat)
  36008. } else {
  36009. fmt.Println(err)
  36010. }
  36011. userJSONBytes, _ := json.Marshal(dat)
  36012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36013. utils.ErrorLog("解析失败:%v", err)
  36014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36015. return
  36016. }
  36017. } else if miConfig.MdtrtareaAdmvs == "150499" {
  36018. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36019. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36020. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36021. resp, requestErr := http.Get(api)
  36022. if requestErr != nil {
  36023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36024. return
  36025. }
  36026. body, ioErr := ioutil.ReadAll(resp.Body)
  36027. if ioErr != nil {
  36028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36030. return
  36031. }
  36032. var respJSON map[string]interface{}
  36033. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36036. return
  36037. }
  36038. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36039. result, _ := json.Marshal(respJSON)
  36040. fmt.Println("log")
  36041. fmt.Println(string(result))
  36042. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  36043. utils.ErrorLog("解析失败:%v", err)
  36044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36045. return
  36046. }
  36047. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36048. res.Output = resEleven10265.Output
  36049. res.ErrMsg = resEleven10265.ErrMsg
  36050. res.Cainfo = resEleven10265.Cainfo
  36051. res.WarnMsg = resEleven10265.WarnMsg
  36052. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36053. res.Infcode = infocode
  36054. } else if miConfig.MdtrtareaAdmvs == "441799" {
  36055. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36056. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36057. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36058. resp, requestErr := http.Get(api)
  36059. if requestErr != nil {
  36060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36061. return
  36062. }
  36063. body, ioErr := ioutil.ReadAll(resp.Body)
  36064. if ioErr != nil {
  36065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36067. return
  36068. }
  36069. var respJSON map[string]interface{}
  36070. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36073. return
  36074. }
  36075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36076. result, _ := json.Marshal(respJSON)
  36077. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36078. utils.ErrorLog("解析失败:%v", err)
  36079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36080. return
  36081. }
  36082. } else if miConfig.MdtrtareaAdmvs == "450721" {
  36083. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  36084. //return
  36085. } else {
  36086. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36087. if len(his.InsuplcAdmdvs) == 0 {
  36088. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  36089. } else {
  36090. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36091. }
  36092. result := service.Gdyb5203(baseParams, businessParams)
  36093. //service.Gdyb5204(baseParams, businessParams)
  36094. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36095. var dat map[string]interface{}
  36096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36097. fmt.Println(dat)
  36098. } else {
  36099. fmt.Println(err)
  36100. }
  36101. userJSONBytes, _ := json.Marshal(dat)
  36102. if miConfig.Code == "H15049901371" {
  36103. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36104. utils.ErrorLog("解析失败:%v", err)
  36105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36106. return
  36107. }
  36108. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36109. res.Output = resEleven10265.Output
  36110. res.ErrMsg = resEleven10265.ErrMsg
  36111. res.Cainfo = resEleven10265.Cainfo
  36112. res.WarnMsg = resEleven10265.WarnMsg
  36113. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36114. res.Infcode = infocode
  36115. } else {
  36116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36117. utils.ErrorLog("解析失败:%v", err)
  36118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36119. return
  36120. }
  36121. }
  36122. }
  36123. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36124. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36125. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36126. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36127. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36128. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36129. var doctor_name string
  36130. if roles.ID == 0 {
  36131. doctor_name = "管理员"
  36132. } else {
  36133. doctor_name = roles.UserName
  36134. }
  36135. yiliao_leibie := ""
  36136. switch order.MedType {
  36137. case "11":
  36138. yiliao_leibie = "普通门诊"
  36139. break
  36140. case "12":
  36141. yiliao_leibie = "门诊挂号"
  36142. break
  36143. case "13":
  36144. yiliao_leibie = "急诊"
  36145. break
  36146. case "14":
  36147. yiliao_leibie = "门诊特殊病"
  36148. break
  36149. case "15":
  36150. yiliao_leibie = "门诊统筹"
  36151. break
  36152. case "16":
  36153. yiliao_leibie = "门诊慢性病"
  36154. break
  36155. case "21":
  36156. yiliao_leibie = "普通住院"
  36157. break
  36158. }
  36159. //var rf []CustomFundPay
  36160. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  36161. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36162. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  36163. if res.Infcode == 0 {
  36164. 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{
  36165. c.ServeSuccessJSON(map[string]interface{}{
  36166. "diagnosis": name,
  36167. "order_infos": orderInfos,
  36168. "number": order.MdtrtId,
  36169. "date": order.SettleAccountsDate,
  36170. "charge_admin": charge_admin,
  36171. "printor_admin": printor_admin,
  36172. "info": res.Output.Setlinfo,
  36173. "order": order,
  36174. "bedCostTotal": bedCostTotal,
  36175. "bedCostSelfTotal": bedCostSelfTotal,
  36176. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36177. "bedSelfTotal": bedSelfTotal,
  36178. "bedInscpTotal": bedInscpTotal,
  36179. "operationCostTotal": operationCostTotal,
  36180. "operationCostSelfTotal": operationCostSelfTotal,
  36181. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36182. "operationSelfTotal": operationSelfTotal,
  36183. "operationInscpTotal": operationInscpTotal,
  36184. "otherCostTotal": otherCostTotal,
  36185. "otherCostSelfTotal": otherCostSelfTotal,
  36186. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36187. "otherSelfTotal": otherSelfTotal,
  36188. "otherInscpTotal": otherInscpTotal,
  36189. "materialCostTotal": materialCostTotal,
  36190. "materialCostSelfTotal": materialCostSelfTotal,
  36191. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36192. "materialSelfTotal": materialSelfTotal,
  36193. "materialInscpTotal": materialInscpTotal,
  36194. "westernMedicineCostTotal": westernMedicineCostTotal,
  36195. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36196. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36197. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36198. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36199. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36200. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36201. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36202. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36203. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36204. "checkCostTotal": checkCostTotal,
  36205. "checkCostSelfTotal": checkCostSelfTotal,
  36206. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36207. "checkSelfTotal": checkSelfTotal,
  36208. "checkInscpTotal": checkInscpTotal,
  36209. "laboratoryCostTotal": laboratoryCostTotal,
  36210. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36211. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36212. "laboratorySelfTotal": laboratorySelfTotal,
  36213. "laboratoryInscpTotal": laboratoryInscpTotal,
  36214. "treatCostTotal": treatCostTotal,
  36215. "treatCostSelfTotal": treatCostSelfTotal,
  36216. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36217. "treatSelfTotal": treatSelfTotal,
  36218. "treatInscpTotal": treatInscpTotal,
  36219. "doctor_info": doctor_info,
  36220. "doctor_code": adminRole_two.DoctorCode,
  36221. "doctor_name": doctor_name,
  36222. "health_card_no": order.PsnNo,
  36223. "department": departments.Name,
  36224. "yiliao_leibie": yiliao_leibie,
  36225. "after_money": order.AccountPrice,
  36226. "patient": patient,
  36227. "org_name": miConfig.OrgName,
  36228. "org_code": miConfig.Code,
  36229. "order_number": order.Number,
  36230. "his_hospital": his_hospital,
  36231. "his": his,
  36232. "dia_config": dia_config,
  36233. "psn_cash_pay": order.PsnCashPay,
  36234. "zcCostTotal": zcCostTotal,
  36235. "zcCostSelfTotal": zcCostSelfTotal,
  36236. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  36237. "zcSelfTotal": zcSelfTotal,
  36238. "zcInscpTotal": zcInscpTotal,
  36239. "huliCostTotal": huliCostTotal,
  36240. "huliCostSelfTotal": huliCostSelfTotal,
  36241. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  36242. "huliSelfTotal": huliSelfTotal,
  36243. "huliInscpTotal": huliInscpTotal,
  36244. //"funds": rf,
  36245. //"check_order_info": cus_slice,
  36246. })
  36247. } else {
  36248. c.ServeSuccessJSON(map[string]interface{}{
  36249. "diagnosis": name,
  36250. "order_infos": orderInfos,
  36251. "number": order.MdtrtId,
  36252. "date": order.SettleAccountsDate,
  36253. "charge_admin": charge_admin,
  36254. "printor_admin": printor_admin,
  36255. "info": order,
  36256. "order": order,
  36257. "bedCostTotal": bedCostTotal,
  36258. "bedCostSelfTotal": bedCostSelfTotal,
  36259. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36260. "bedSelfTotal": bedSelfTotal,
  36261. "bedInscpTotal": bedInscpTotal,
  36262. "operationCostTotal": operationCostTotal,
  36263. "operationCostSelfTotal": operationCostSelfTotal,
  36264. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36265. "operationSelfTotal": operationSelfTotal,
  36266. "operationInscpTotal": operationInscpTotal,
  36267. "otherCostTotal": otherCostTotal,
  36268. "otherCostSelfTotal": otherCostSelfTotal,
  36269. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36270. "otherSelfTotal": otherSelfTotal,
  36271. "otherInscpTotal": otherInscpTotal,
  36272. "materialCostTotal": materialCostTotal,
  36273. "materialCostSelfTotal": materialCostSelfTotal,
  36274. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36275. "materialSelfTotal": materialSelfTotal,
  36276. "materialInscpTotal": materialInscpTotal,
  36277. "westernMedicineCostTotal": westernMedicineCostTotal,
  36278. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36279. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36280. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36281. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36282. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36283. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36284. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36285. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36286. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36287. "checkCostTotal": checkCostTotal,
  36288. "checkCostSelfTotal": checkCostSelfTotal,
  36289. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36290. "checkSelfTotal": checkSelfTotal,
  36291. "checkInscpTotal": checkInscpTotal,
  36292. "laboratoryCostTotal": laboratoryCostTotal,
  36293. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36294. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36295. "laboratorySelfTotal": laboratorySelfTotal,
  36296. "laboratoryInscpTotal": laboratoryInscpTotal,
  36297. "treatCostTotal": treatCostTotal,
  36298. "treatCostSelfTotal": treatCostSelfTotal,
  36299. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36300. "treatSelfTotal": treatSelfTotal,
  36301. "treatInscpTotal": treatInscpTotal,
  36302. "doctor_info": doctor_info,
  36303. "doctor_code": adminRole_two.DoctorCode,
  36304. "doctor_name": doctor_name,
  36305. "health_card_no": order.PsnNo,
  36306. "department": departments.Name,
  36307. "yiliao_leibie": yiliao_leibie,
  36308. "after_money": order.AccountPrice,
  36309. "patient": patient,
  36310. "org_name": miConfig.OrgName,
  36311. "org_code": miConfig.Code,
  36312. "order_number": order.Number,
  36313. "his_hospital": his_hospital,
  36314. "his": his,
  36315. "dia_config": dia_config,
  36316. "psn_cash_pay": order.PsnCashPay,
  36317. "zcCostTotal": zcCostTotal,
  36318. "zcCostSelfTotal": zcCostSelfTotal,
  36319. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  36320. "zcSelfTotal": zcSelfTotal,
  36321. "zcInscpTotal": zcInscpTotal,
  36322. "huliCostTotal": huliCostTotal,
  36323. "huliCostSelfTotal": huliCostSelfTotal,
  36324. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  36325. "huliSelfTotal": huliSelfTotal,
  36326. "huliInscpTotal": huliInscpTotal,
  36327. //"funds": rf,
  36328. //"check_order_info": cus_slice,
  36329. })
  36330. }
  36331. }
  36332. }
  36333. }
  36334. //func (c *HisApiController) CheckTreatment() {
  36335. // patient_id, _ := c.GetInt64("patient_id")
  36336. // id_card_no := c.GetString("id_card_no")
  36337. // insutype := c.GetString("insutype")
  36338. // med_type := c.GetString("med_type")
  36339. // admin_user_id, _ := c.GetInt64("admin_user_id")
  36340. //
  36341. // adminUser := c.GetAdminUserInfo()
  36342. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36343. //
  36344. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36345. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36346. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36347. //
  36348. // if miConfig.MdtrtareaAdmvs == "421300" {
  36349. // var res ResultTwo
  36350. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  36351. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  36352. // "&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)
  36353. // resp, requestErr := http.Get(api)
  36354. // if requestErr != nil {
  36355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36356. // return
  36357. // }
  36358. //
  36359. // body, ioErr := ioutil.ReadAll(resp.Body)
  36360. // if ioErr != nil {
  36361. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36363. // return
  36364. // }
  36365. // var respJSON map[string]interface{}
  36366. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36367. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36369. // return
  36370. // }
  36371. //
  36372. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36373. // result, _ := json.Marshal(respJSON)
  36374. //
  36375. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  36376. // utils.ErrorLog("解析失败:%v", err)
  36377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36378. // return
  36379. // }
  36380. //
  36381. // if res.Infcode == 0 {
  36382. //
  36383. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  36384. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  36385. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  36386. // resp, requestErr := http.Get(api)
  36387. // if requestErr != nil {
  36388. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36389. // return
  36390. // }
  36391. //
  36392. // body, ioErr := ioutil.ReadAll(resp.Body)
  36393. // if ioErr != nil {
  36394. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36396. // return
  36397. // }
  36398. // var respJSON map[string]interface{}
  36399. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36400. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36401. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36402. // return
  36403. // }
  36404. // var res Result2001
  36405. //
  36406. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36407. // result2, _ := json.Marshal(respJSON)
  36408. //
  36409. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  36410. // utils.ErrorLog("解析失败:%v", err)
  36411. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36412. // return
  36413. // }
  36414. //
  36415. // if res.Infcode == 0 {
  36416. // c.ServeSuccessJSON(map[string]interface{}{
  36417. // "msg": res.Output.Trtinfo,
  36418. // })
  36419. // }
  36420. //
  36421. // } else {
  36422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  36423. // return
  36424. // }
  36425. //
  36426. // } else {
  36427. //
  36428. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36429. // var dat map[string]interface{}
  36430. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36431. // fmt.Println(dat)
  36432. // } else {
  36433. // fmt.Println(err)
  36434. // }
  36435. // userJSONBytes, _ := json.Marshal(dat)
  36436. // var res ResultTwo
  36437. // var res10265 ResultTwo10265
  36438. // if miConfig.Code == "H15049901371" {
  36439. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36440. // utils.ErrorLog("解析失败:%v", err)
  36441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36442. // return
  36443. // }
  36444. // res.ErrMsg = res10265.ErrMsg
  36445. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36446. // res.Infcode = infocode
  36447. // res.Output = res10265.Output
  36448. // res.InfRefmsgid = res10265.InfRefmsgid
  36449. // } else {
  36450. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36451. // utils.ErrorLog("解析失败:%v", err)
  36452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36453. // return
  36454. // }
  36455. // }
  36456. //
  36457. // var user_name string
  36458. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  36459. // if role.ID == 0 {
  36460. // user_name = "xxx"
  36461. // } else {
  36462. // user_name = role.UserName
  36463. // }
  36464. //
  36465. // baseParams := models.BaseParams{
  36466. // SecretKey: miConfig.SecretKey,
  36467. // FixmedinsCode: miConfig.Code,
  36468. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36469. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36470. // OrgName: miConfig.OrgName,
  36471. // Doctor: user_name,
  36472. // }
  36473. //
  36474. // if config.IsOpen == 1 {
  36475. // if miConfig.Code == "H15049901371" {
  36476. // if med_type == "14" {
  36477. // if insutype == "390" {
  36478. // med_type = "9933"
  36479. // } else if insutype == "310" {
  36480. // med_type = "990502"
  36481. // }
  36482. // } else if med_type == "11" {
  36483. // med_type = "11"
  36484. // }
  36485. // }
  36486. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  36487. // var dat map[string]interface{}
  36488. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36489. // fmt.Println(dat)
  36490. // } else {
  36491. // fmt.Println(err)
  36492. // }
  36493. // var res Result2001
  36494. // var res10265 Result2001Org10265
  36495. // if miConfig.Code == "H15049901371" {
  36496. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36497. // utils.ErrorLog("解析失败:%v", err)
  36498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36499. // return
  36500. // }
  36501. // res.ErrMsg = res10265.ErrMsg
  36502. // res.Output = res10265.Output
  36503. // res.InfRefmsgid = res10265.InfRefmsgid
  36504. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36505. // res.Infcode = infocode
  36506. // } else {
  36507. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  36508. // utils.ErrorLog("解析失败:%v", err)
  36509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36510. // return
  36511. // }
  36512. // }
  36513. // if res.Infcode == 0 {
  36514. // c.ServeSuccessJSON(map[string]interface{}{
  36515. // "msg": res.Output.Trtinfo,
  36516. // })
  36517. // }
  36518. // }
  36519. // }
  36520. //}
  36521. //func (c *HisApiController) PutRecord() {
  36522. // id, _ := c.GetInt64("id")
  36523. // record_time := c.GetString("record_time")
  36524. // timeLayout := "2006-01-02"
  36525. // loc, _ := time.LoadLocation("Local")
  36526. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36527. // if err != nil {
  36528. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36529. // return
  36530. // }
  36531. // recordDateTime := theTime.Unix()
  36532. //
  36533. // adminInfo := c.GetAdminUserInfo()
  36534. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  36535. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36536. //
  36537. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  36538. //
  36539. // fmt.Println(miConfig.SecretKey)
  36540. //
  36541. // if patient == nil {
  36542. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36543. // return
  36544. // }
  36545. // if len(patient.IdCardNo) == 0 {
  36546. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  36547. // return
  36548. // }
  36549. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  36550. // if config.IsOpen == 1 {
  36551. // 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
  36552. // resp, requestErr := http.Get(api)
  36553. // if requestErr != nil {
  36554. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36555. // return
  36556. // }
  36557. // defer resp.Body.Close()
  36558. // body, ioErr := ioutil.ReadAll(resp.Body)
  36559. // if ioErr != nil {
  36560. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36562. // return
  36563. // }
  36564. // var respJSON map[string]interface{}
  36565. //
  36566. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36567. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36569. // return
  36570. // }
  36571. //
  36572. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36573. // userJSONBytes, _ := json.Marshal(userJSON)
  36574. // var res ResultTwo
  36575. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36576. // utils.ErrorLog("解析失败:%v", err)
  36577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36578. // return
  36579. // }
  36580. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36581. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  36582. // infoStr := string(Iinfos)
  36583. // idetinfoStr := string(Idetinfos)
  36584. //
  36585. // if res.Infcode == 0 {
  36586. // his := models.VMHisPatient{
  36587. // Status: 1,
  36588. // Ctime: time.Now().Unix(),
  36589. // Mtime: time.Now().Unix(),
  36590. // PsnNo: res.Output.Baseinfo.PsnNo,
  36591. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  36592. // Certno: res.Output.Baseinfo.Certno,
  36593. // PsnName: res.Output.Baseinfo.PsnName,
  36594. // Gend: res.Output.Baseinfo.Gend,
  36595. // Naty: res.Output.Baseinfo.Naty,
  36596. // Brdy: res.Output.Baseinfo.Brdy,
  36597. // Age: res.Output.Baseinfo.Age,
  36598. // Iinfo: infoStr,
  36599. // Idetinfo: idetinfoStr,
  36600. // PatientId: patient.ID,
  36601. // RecordDate: theTime.Unix(),
  36602. // UserOrgId: adminInfo.CurrentOrgId,
  36603. // AdminUserId: adminInfo.AdminUser.Id,
  36604. // IsReturn: 1,
  36605. // }
  36606. //
  36607. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  36608. // //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")
  36609. // //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")
  36610. //
  36611. // //var dat map[string]interface{}
  36612. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36613. // // fmt.Println(dat)
  36614. // //} else {
  36615. // // fmt.Println(err)
  36616. // //}
  36617. //
  36618. // var dat2 map[string]interface{}
  36619. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36620. // fmt.Println(dat2)
  36621. // } else {
  36622. // fmt.Println(err)
  36623. // }
  36624. //
  36625. // } else {
  36626. // adminUser := c.GetAdminUserInfo()
  36627. // errlog := &models.HisOrderError{
  36628. // UserOrgId: adminUser.CurrentOrgId,
  36629. // Ctime: time.Now().Unix(),
  36630. // Mtime: time.Now().Unix(),
  36631. // ErrMsg: res.ErrMsg,
  36632. // Status: 1,
  36633. // PatientId: id,
  36634. // RecordTime: recordDateTime,
  36635. // Stage: 1,
  36636. // }
  36637. // service.CreateErrMsgLog(errlog)
  36638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  36639. // return
  36640. // }
  36641. // }
  36642. //
  36643. //}
  36644. //func (c *HisApiController) GetUploadDiag() {
  36645. // id, _ := c.GetInt64("id")
  36646. // record_time := c.GetString("record_time")
  36647. //
  36648. // diagnosis_id, _ := c.GetInt64("diagnosis")
  36649. // sick_type, _ := c.GetInt64("sick_type")
  36650. // reg_type, _ := c.GetInt64("reg_type")
  36651. //
  36652. // timeLayout := "2006-01-02"
  36653. // loc, _ := time.LoadLocation("Local")
  36654. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36655. // if err != nil {
  36656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36657. // return
  36658. // }
  36659. //
  36660. // var patientPrescription models.HisPrescriptionInfo
  36661. // recordDateTime := theTime.Unix()
  36662. // adminInfo := c.GetAdminUserInfo()
  36663. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36664. //
  36665. // if patientPrescription.ID == 0 {
  36666. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36667. // }
  36668. //
  36669. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  36670. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  36671. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36672. // sickConfig, _ := service.FindSickById(sick_type)
  36673. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36674. //
  36675. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  36676. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  36677. // "&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 +
  36678. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  36679. // resp2, requestErr2 := http.Get(api2)
  36680. // if requestErr2 != nil {
  36681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36682. // return
  36683. // }
  36684. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  36685. // if ioErr2 != nil {
  36686. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  36687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36688. // return
  36689. // }
  36690. // var respJSON2 map[string]interface{}
  36691. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  36692. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36693. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36694. // return
  36695. // }
  36696. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36697. // userJSONBytes2, _ := json.Marshal(respJSON2)
  36698. //
  36699. // var res2 ResultSix
  36700. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36701. // utils.ErrorLog("解析失败:%v", err)
  36702. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36703. // return
  36704. // }
  36705. // if res2.Infcode != 0 {
  36706. // adminUser := c.GetAdminUserInfo()
  36707. // errlog := &models.HisOrderError{
  36708. // UserOrgId: adminUser.CurrentOrgId,
  36709. // Ctime: time.Now().Unix(),
  36710. // Mtime: time.Now().Unix(),
  36711. // ErrMsg: res2.ErrMsg,
  36712. // Status: 1,
  36713. // PatientId: id,
  36714. // RecordTime: recordDateTime,
  36715. // Stage: 3,
  36716. // }
  36717. // service.CreateErrMsgLog(errlog)
  36718. //
  36719. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  36720. // return
  36721. // }
  36722. //
  36723. // c.ServeSuccessJSON(map[string]interface{}{
  36724. // "msg": "上传成功",
  36725. // })
  36726. //
  36727. //}
  36728. type QueryResult struct {
  36729. ID int64
  36730. Name string
  36731. Code string
  36732. List_type_code string
  36733. }
  36734. func (c *HisApiController) GetCheckCode() {
  36735. ids_str := c.GetString("ids")
  36736. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36737. ids_arr := strings.Split(ids_str, ",")
  36738. var queryResult []QueryResult
  36739. ids := make([]int64, 0)
  36740. for _, item := range ids_arr {
  36741. id, _ := strconv.ParseInt(item, 10, 64)
  36742. ids = append(ids, id)
  36743. }
  36744. if record_type == 1 {
  36745. drugs, _ := service.GetBatchDrugList(ids)
  36746. for _, item := range drugs {
  36747. result := QueryResult{
  36748. ID: item.ID,
  36749. Name: item.DrugName,
  36750. Code: item.MedicalInsuranceNumber,
  36751. List_type_code: "101",
  36752. }
  36753. queryResult = append(queryResult, result)
  36754. }
  36755. } else if record_type == 2 {
  36756. goods, _ := service.GetBatchGoodInformationList(ids)
  36757. fmt.Println(goods)
  36758. for _, item := range goods {
  36759. result := QueryResult{
  36760. ID: item.ID,
  36761. Name: item.GoodName,
  36762. Code: item.SocialSecurityDirectoryCode,
  36763. List_type_code: "301",
  36764. }
  36765. queryResult = append(queryResult, result)
  36766. }
  36767. } else if record_type == 3 {
  36768. projects, _ := service.GetBathchMyPorjecgList(ids)
  36769. for _, item := range projects {
  36770. result := QueryResult{
  36771. ID: item.ID,
  36772. Name: item.ProjectName,
  36773. Code: item.MedicalCode,
  36774. List_type_code: "201",
  36775. }
  36776. queryResult = append(queryResult, result)
  36777. }
  36778. }
  36779. admin_user_id, _ := c.GetInt64("admin_user_id")
  36780. adminUser := c.GetAdminUserInfo()
  36781. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36782. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36783. var user_name string
  36784. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36785. if role.ID == 0 {
  36786. user_name = "管理员"
  36787. } else {
  36788. user_name = role.UserName
  36789. }
  36790. baseParams := models.BaseParams{
  36791. SecretKey: miConfig.SecretKey,
  36792. FixmedinsCode: miConfig.Code,
  36793. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36794. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36795. OrgName: miConfig.OrgName,
  36796. Doctor: user_name,
  36797. }
  36798. var result string
  36799. if miConfig.MdtrtareaAdmvs == "430800" {
  36800. for _, item := range queryResult {
  36801. if record_type == 1 {
  36802. 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)
  36803. } else if record_type == 2 {
  36804. fmt.Println(item.Code)
  36805. 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)
  36806. } else if record_type == 3 {
  36807. 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)
  36808. }
  36809. var dat map[string]interface{}
  36810. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36811. fmt.Println(dat)
  36812. } else {
  36813. fmt.Println(err)
  36814. }
  36815. userJSONBytes, _ := json.Marshal(dat)
  36816. var res ResultSix
  36817. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36818. utils.ErrorLog("解析失败:%v", err)
  36819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36820. return
  36821. }
  36822. if res.Infcode == 0 {
  36823. if record_type == 1 {
  36824. service.UpdateBaseDrugById(item.ID)
  36825. } else if record_type == 2 {
  36826. service.UpdateGoodInformaitonByDetail(item.ID)
  36827. } else if record_type == 3 {
  36828. service.UpdateProjectById(item.ID)
  36829. }
  36830. c.ServeSuccessJSON(map[string]interface{}{
  36831. "failed_code": 0,
  36832. "msg": "目录对照成功",
  36833. })
  36834. } else {
  36835. c.ServeSuccessJSON(map[string]interface{}{
  36836. "failed_code": -10,
  36837. "msg": res.ErrMsg,
  36838. })
  36839. }
  36840. }
  36841. } else {
  36842. for _, item := range queryResult {
  36843. var result string
  36844. if record_type == 1 {
  36845. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36846. } else if record_type == 2 {
  36847. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36848. } else if record_type == 3 {
  36849. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36850. }
  36851. var dat map[string]interface{}
  36852. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36853. fmt.Println(dat)
  36854. } else {
  36855. fmt.Println(err)
  36856. }
  36857. userJSONBytes, _ := json.Marshal(dat)
  36858. var res ResultSix
  36859. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36860. utils.ErrorLog("解析失败:%v", err)
  36861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36862. return
  36863. }
  36864. if res.Infcode == 0 {
  36865. if record_type == 1 {
  36866. service.UpdateBaseDrugById(item.ID)
  36867. } else if record_type == 2 {
  36868. service.UpdateGoodInformaitonByDetail(item.ID)
  36869. } else if record_type == 3 {
  36870. service.UpdateProjectById(item.ID)
  36871. }
  36872. c.ServeSuccessJSON(map[string]interface{}{
  36873. "failed_code": 0,
  36874. "msg": "目录对照成功",
  36875. })
  36876. } else {
  36877. c.ServeSuccessJSON(map[string]interface{}{
  36878. "failed_code": -10,
  36879. "msg": res.ErrMsg,
  36880. })
  36881. }
  36882. }
  36883. }
  36884. }
  36885. func (c *HisApiController) UnCheckCode() {
  36886. ids_str := c.GetString("ids")
  36887. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36888. admin_user_id, _ := c.GetInt64("admin_user_id")
  36889. ids_arr := strings.Split(ids_str, ",")
  36890. var queryResult []QueryResult
  36891. ids := make([]int64, 0)
  36892. for _, item := range ids_arr {
  36893. id, _ := strconv.ParseInt(item, 10, 64)
  36894. ids = append(ids, id)
  36895. }
  36896. if record_type == 1 {
  36897. drugs, _ := service.GetBatchDrugList(ids)
  36898. for _, item := range drugs {
  36899. result := QueryResult{
  36900. ID: item.ID,
  36901. Name: item.DrugName,
  36902. Code: item.MedicalInsuranceNumber,
  36903. List_type_code: "101",
  36904. }
  36905. queryResult = append(queryResult, result)
  36906. }
  36907. } else if record_type == 2 {
  36908. goods, _ := service.GetBatchGoodInformationList(ids)
  36909. for _, item := range goods {
  36910. result := QueryResult{
  36911. ID: item.ID,
  36912. Name: item.GoodName,
  36913. Code: item.SocialSecurityDirectoryCode,
  36914. List_type_code: "301",
  36915. }
  36916. queryResult = append(queryResult, result)
  36917. }
  36918. } else if record_type == 3 {
  36919. projects, _ := service.GetBathchMyPorjecgList(ids)
  36920. for _, item := range projects {
  36921. result := QueryResult{
  36922. ID: item.ID,
  36923. Name: item.ProjectName,
  36924. Code: item.MedicalCode,
  36925. List_type_code: "201",
  36926. }
  36927. queryResult = append(queryResult, result)
  36928. }
  36929. }
  36930. adminUser := c.GetAdminUserInfo()
  36931. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36932. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36933. var user_name string
  36934. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36935. if role.ID == 0 {
  36936. user_name = "xxx"
  36937. } else {
  36938. user_name = role.UserName
  36939. }
  36940. baseParams := &models.BaseParams{
  36941. SecretKey: miConfig.SecretKey,
  36942. FixmedinsCode: miConfig.Code,
  36943. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36944. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36945. OrgName: miConfig.OrgName,
  36946. Doctor: user_name,
  36947. }
  36948. if config.IsOpen == 1 {
  36949. if miConfig.MdtrtareaAdmvs == "430800" {
  36950. for _, item := range queryResult {
  36951. var result string
  36952. if record_type == 1 {
  36953. 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)
  36954. } else if record_type == 2 {
  36955. fmt.Println(item.Code)
  36956. 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)
  36957. } else if record_type == 3 {
  36958. 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)
  36959. }
  36960. var dat map[string]interface{}
  36961. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36962. fmt.Println(dat)
  36963. } else {
  36964. fmt.Println(err)
  36965. }
  36966. userJSONBytes, _ := json.Marshal(dat)
  36967. var res ResultSix
  36968. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36969. utils.ErrorLog("解析失败:%v", err)
  36970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36971. return
  36972. }
  36973. if res.Infcode == 0 {
  36974. if record_type == 1 {
  36975. service.UpdateBaseDrugById(item.ID)
  36976. } else if record_type == 2 {
  36977. service.UpdateGoodInformaitonByDetail(item.ID)
  36978. } else if record_type == 3 {
  36979. service.UpdateProjectById(item.ID)
  36980. }
  36981. c.ServeSuccessJSON(map[string]interface{}{
  36982. "failed_code": 0,
  36983. "msg": "目录对照成功",
  36984. })
  36985. } else {
  36986. c.ServeSuccessJSON(map[string]interface{}{
  36987. "failed_code": -10,
  36988. "msg": res.ErrMsg,
  36989. })
  36990. }
  36991. }
  36992. } else {
  36993. for _, item := range queryResult {
  36994. var result string
  36995. if record_type == 1 {
  36996. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36997. } else if record_type == 2 {
  36998. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36999. } else if record_type == 3 {
  37000. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  37001. }
  37002. var dat2 map[string]interface{}
  37003. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37004. fmt.Println(dat2)
  37005. } else {
  37006. fmt.Println(err)
  37007. }
  37008. userJSONBytes, _ := json.Marshal(dat2)
  37009. var res ResultSix
  37010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37011. utils.ErrorLog("解析失败:%v", err)
  37012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37013. return
  37014. }
  37015. if res.Infcode == 0 {
  37016. if record_type == 1 {
  37017. service.UpdateDrugByIdDetail(item.ID)
  37018. } else if record_type == 2 {
  37019. service.UpdateGoodInfoById(item.ID)
  37020. } else if record_type == 3 {
  37021. service.UpdateMyProjectById(item.ID)
  37022. }
  37023. c.ServeSuccessJSON(map[string]interface{}{
  37024. "failed_code": 0,
  37025. "msg": "撤销目录对照成功",
  37026. })
  37027. } else {
  37028. c.ServeSuccessJSON(map[string]interface{}{
  37029. "failed_code": -10,
  37030. "msg": res.ErrMsg,
  37031. })
  37032. }
  37033. }
  37034. }
  37035. }
  37036. }
  37037. func (c *HisApiController) GetPatientInfo() {
  37038. id_card_no := c.GetString("id_card_no")
  37039. admin_user_id, _ := c.GetInt64("admin_user_id")
  37040. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  37041. if patient.ID == 0 {
  37042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37043. return
  37044. }
  37045. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  37046. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  37047. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  37048. var res ResultTwo
  37049. var res10265 ResultTwo10265
  37050. if config.IsOpen == 1 {
  37051. if miConfig.MdtrtareaAdmvs == "150499" {
  37052. //请求内网数据
  37053. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  37054. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  37055. "&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
  37056. resp, requestErr := http.Get(api)
  37057. if requestErr != nil {
  37058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37059. return
  37060. }
  37061. body, ioErr := ioutil.ReadAll(resp.Body)
  37062. if ioErr != nil {
  37063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37065. return
  37066. }
  37067. var respJSON map[string]interface{}
  37068. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37071. return
  37072. }
  37073. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37074. result_byte, _ := json.Marshal(respJSON)
  37075. result := string(result_byte)
  37076. var dat map[string]interface{}
  37077. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37078. fmt.Println(dat)
  37079. } else {
  37080. fmt.Println(err)
  37081. }
  37082. userJSONBytes, _ := json.Marshal(dat)
  37083. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37084. utils.ErrorLog("解析失败:%v", err)
  37085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37086. return
  37087. }
  37088. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37089. res.Infcode = Infcode
  37090. res.ErrMsg = res10265.ErrMsg
  37091. res.Output = res10265.Output
  37092. res.InfRefmsgid = res10265.InfRefmsgid
  37093. res.RespondTime = res10265.RespondTime
  37094. res.WarnInfo = res10265.WarnInfo
  37095. } else {
  37096. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37097. var dat map[string]interface{}
  37098. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37099. fmt.Println(dat)
  37100. } else {
  37101. fmt.Println(err)
  37102. }
  37103. userJSONBytes, _ := json.Marshal(dat)
  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 err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37111. // utils.ErrorLog("解析失败:%v", err)
  37112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37113. // return
  37114. //}
  37115. for index, item := range res.Output.Iinfo {
  37116. if item.PsnInsuStas == "2" {
  37117. fmt.Println("--------")
  37118. res.Output.Iinfo[index].Insutype = "300"
  37119. res.Output.Iinfo[index].PsnInsuStas = "1"
  37120. }
  37121. }
  37122. fmt.Println(res.Output.Iinfo)
  37123. if res.Infcode != 0 {
  37124. c.ServeSuccessJSON(map[string]interface{}{
  37125. "failed_code": -10,
  37126. "msg": res.ErrMsg,
  37127. })
  37128. } else {
  37129. c.ServeSuccessJSON(map[string]interface{}{
  37130. "failed_code": 0,
  37131. "info": res,
  37132. })
  37133. }
  37134. }
  37135. }
  37136. func (c *HisApiController) PsnPutOnRecord() {
  37137. record_type, _ := c.GetInt64("type")
  37138. patient_id, _ := c.GetInt64("patient_id")
  37139. admin_user_id, _ := c.GetInt64("admin_user_id")
  37140. start_time := c.GetString("start_time")
  37141. end_time := c.GetString("end_time")
  37142. adminUser := c.GetAdminUserInfo()
  37143. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37144. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37145. var patients []*models.Patients
  37146. if record_type == 1 { //全部备案
  37147. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  37148. patients = append(patients, patient...)
  37149. } else { //单个备案
  37150. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37151. patients = append(patients, patient)
  37152. }
  37153. var user_name string
  37154. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37155. if role.ID == 0 {
  37156. user_name = "xxx"
  37157. } else {
  37158. user_name = role.UserName
  37159. }
  37160. if config.IsOpen == 1 {
  37161. for _, item := range patients {
  37162. 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
  37163. resp, requestErr := http.Get(api)
  37164. if requestErr != nil {
  37165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37166. return
  37167. }
  37168. defer resp.Body.Close()
  37169. body, ioErr := ioutil.ReadAll(resp.Body)
  37170. if ioErr != nil {
  37171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37173. return
  37174. }
  37175. var respJSON map[string]interface{}
  37176. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37179. return
  37180. }
  37181. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37182. userJSONBytes, _ := json.Marshal(userJSON)
  37183. var res ResultTwo
  37184. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37185. utils.ErrorLog("解析失败:%v", err)
  37186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37187. return
  37188. }
  37189. if res.Infcode == 0 {
  37190. 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)
  37191. var dat map[string]interface{}
  37192. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37193. fmt.Println(dat)
  37194. } else {
  37195. fmt.Println(err)
  37196. }
  37197. userJSONBytes, _ := json.Marshal(dat)
  37198. var res2 ResultThirteen
  37199. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  37200. utils.ErrorLog("解析失败:%v", err)
  37201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37202. return
  37203. }
  37204. if res2.Infcode == 0 {
  37205. psnResult := &models.GdybPsnRecord{
  37206. UserOrgId: adminUser.CurrentOrgId,
  37207. PatientId: item.ID,
  37208. PsnNo: res.Output.Baseinfo.PsnNo,
  37209. Ctime: time.Now().Unix(),
  37210. Mtime: time.Now().Unix(),
  37211. Status: 1,
  37212. IsCancel: 1,
  37213. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  37214. }
  37215. service.CreatePsnRecord(psnResult)
  37216. } else {
  37217. c.ServeSuccessJSON(map[string]interface{}{
  37218. "failed_code": -10,
  37219. "msg": res2.ErrMsg,
  37220. })
  37221. return
  37222. }
  37223. }
  37224. }
  37225. }
  37226. }
  37227. func (c *HisApiController) PsnUnPutOnRecord() {
  37228. id, _ := c.GetInt64("id")
  37229. //record_type, _ := c.GetInt64("type")
  37230. admin_user_id, _ := c.GetInt64("admin_user_id")
  37231. adminUser := c.GetAdminUserInfo()
  37232. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37233. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37234. var user_name string
  37235. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37236. if role.ID == 0 {
  37237. user_name = "xxx"
  37238. } else {
  37239. user_name = role.UserName
  37240. }
  37241. psn_record, _ := service.GetPsnRecordById(id)
  37242. if psn_record.ID == 0 {
  37243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  37244. return
  37245. }
  37246. if config.IsOpen == 1 {
  37247. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  37248. var dat map[string]interface{}
  37249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37250. fmt.Println(dat)
  37251. } else {
  37252. fmt.Println(err)
  37253. }
  37254. userJSONBytes, _ := json.Marshal(dat)
  37255. var res ResultFourteen
  37256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37257. utils.ErrorLog("解析失败:%v", err)
  37258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37259. return
  37260. }
  37261. if res.Infcode == 0 {
  37262. psn_record.IsCancel = 2
  37263. service.CreatePsnRecord(&psn_record)
  37264. } else {
  37265. c.ServeSuccessJSON(map[string]interface{}{
  37266. "failed_code": -10,
  37267. "msg": res.ErrMsg,
  37268. })
  37269. return
  37270. }
  37271. }
  37272. }
  37273. func (c *HisApiController) PsnPutNCDSOnRecord() {
  37274. patient_id, _ := c.GetInt64("patient_id")
  37275. insutype_two := c.GetString("insutype")
  37276. psn_no := c.GetString("psn_no")
  37277. doctor_id, _ := c.GetInt64("doctor_id")
  37278. sick_id, _ := c.GetInt64("sick_id")
  37279. department_id, _ := c.GetInt64("department_id")
  37280. start_time := c.GetString("start_time")
  37281. end_time := c.GetString("end_time")
  37282. check_time := c.GetString("check_time")
  37283. hospital_code := c.GetString("hospital_code")
  37284. hospital_name := c.GetString("hospital_name")
  37285. adminUser := c.GetAdminUserInfo()
  37286. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37287. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37288. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37289. sick, _ := service.FindSickById(sick_id)
  37290. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  37291. if len(hospital_code) == 0 {
  37292. hospital_code = miConfig.Code
  37293. }
  37294. if len(hospital_name) == 0 {
  37295. hospital_name = miConfig.OrgName
  37296. }
  37297. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  37298. var res ResultTwo
  37299. var res10265 ResultTwo10265
  37300. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37301. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  37302. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  37303. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  37304. "&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
  37305. resp, requestErr := http.Get(api)
  37306. if requestErr != nil {
  37307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37308. return
  37309. }
  37310. body, ioErr := ioutil.ReadAll(resp.Body)
  37311. if ioErr != nil {
  37312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37314. return
  37315. }
  37316. var respJSON map[string]interface{}
  37317. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37320. return
  37321. }
  37322. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37323. result, _ := json.Marshal(respJSON)
  37324. fmt.Println("log")
  37325. fmt.Println(string(result))
  37326. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37327. utils.ErrorLog("解析失败:%v", err)
  37328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37329. return
  37330. }
  37331. res.ErrMsg = res10265.ErrMsg
  37332. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37333. res.Infcode = infocode
  37334. res.Output = res10265.Output
  37335. res.InfRefmsgid = res10265.InfRefmsgid
  37336. } else {
  37337. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  37338. if miConfig.Code == "H15049901371" {
  37339. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37340. utils.ErrorLog("解析失败:%v", err)
  37341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37342. return
  37343. }
  37344. res.ErrMsg = res10265.ErrMsg
  37345. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37346. res.Infcode = infocode
  37347. res.Output = res10265.Output
  37348. res.InfRefmsgid = res10265.InfRefmsgid
  37349. } else {
  37350. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37351. utils.ErrorLog("解析失败:%v", err)
  37352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37353. return
  37354. }
  37355. }
  37356. }
  37357. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37358. infoStr := string(Iinfos)
  37359. var rf []*ResultFive
  37360. json.Unmarshal([]byte(infoStr), &rf)
  37361. var insuplc_admdvs string
  37362. var insutype string
  37363. var is390 int = 0
  37364. var is310 int = 0
  37365. var insutypes []*ResultFive
  37366. for _, item := range rf {
  37367. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  37368. insutypes = append(insutypes, item)
  37369. }
  37370. }
  37371. if len(insutypes) == 1 {
  37372. insutype = insutypes[0].Insutype
  37373. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  37374. } else {
  37375. for _, i := range insutypes {
  37376. if i.Insutype == "390" {
  37377. is390 = 1
  37378. }
  37379. if i.Insutype == "310" {
  37380. is310 = 1
  37381. }
  37382. }
  37383. }
  37384. if is390 == 1 {
  37385. insutype = "390"
  37386. }
  37387. if is310 == 1 {
  37388. insutype = "310"
  37389. }
  37390. if len(insutypes) == 2 {
  37391. insutype = insutype_two
  37392. }
  37393. if len(insutypes) == 0 {
  37394. insutype = "310"
  37395. }
  37396. insutype = insutype_two
  37397. fmt.Println(insutype)
  37398. for _, item := range rf {
  37399. fmt.Println(item.Insutype)
  37400. fmt.Println(insutype)
  37401. if item.Insutype == insutype {
  37402. fmt.Println(item.Insutype)
  37403. fmt.Println(insutype)
  37404. insuplc_admdvs = item.InsuplcAdmdvs
  37405. }
  37406. }
  37407. fmt.Println(insuplc_admdvs)
  37408. var res2 ResultThirteen
  37409. var res10265_2 ResultThirteen10265
  37410. if config.IsOpen == 1 {
  37411. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37412. } else {
  37413. if miConfig.MdtrtareaAdmvs == "150499" {
  37414. //
  37415. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  37416. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  37417. // "&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
  37418. //resp, requestErr := http.Get(api)
  37419. //if requestErr != nil {
  37420. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37421. // return
  37422. //}
  37423. //
  37424. //body, ioErr := ioutil.ReadAll(resp.Body)
  37425. //if ioErr != nil {
  37426. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37427. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37428. // return
  37429. //}
  37430. //var respJSON map[string]interface{}
  37431. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37432. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37433. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37434. // return
  37435. //}
  37436. //
  37437. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37438. //result, _ := json.Marshal(respJSON)
  37439. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  37440. // utils.ErrorLog("解析失败:%v", err)
  37441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37442. // return
  37443. //}
  37444. //infocode = resThree.Infcode
  37445. //result, _ := json.Marshal(respJSON)
  37446. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  37447. // utils.ErrorLog("解析失败:%v", err)
  37448. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37449. // return
  37450. //}
  37451. //
  37452. //resThree.ErrMsg = resThree10265.ErrMsg
  37453. //
  37454. //resThree.Output = resThree10265.Output
  37455. //
  37456. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  37457. //
  37458. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  37459. //
  37460. } else {
  37461. 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)
  37462. var dat map[string]interface{}
  37463. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37464. fmt.Println(dat)
  37465. } else {
  37466. fmt.Println(err)
  37467. }
  37468. userJSONBytes, _ := json.Marshal(dat)
  37469. if miConfig.Code == "H15049901371" {
  37470. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  37471. utils.ErrorLog("解析失败:%v", err)
  37472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37473. return
  37474. }
  37475. res2.ErrMsg = res10265_2.ErrMsg
  37476. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  37477. res2.Infcode = infocode
  37478. res2.Output = res10265_2.Output
  37479. res2.InfRefmsgid = res10265_2.InfRefmsgid
  37480. } else {
  37481. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  37482. utils.ErrorLog("解析失败:%v", err)
  37483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37484. return
  37485. }
  37486. }
  37487. }
  37488. }
  37489. if res2.Infcode == 0 {
  37490. psnResult := &models.GdybPsnNcdsRecord{
  37491. UserOrgId: adminUser.CurrentOrgId,
  37492. PatientId: patient.ID,
  37493. PsnNo: psn_no,
  37494. DoctorId: doctor.AdminUserId,
  37495. DepartmentId: department_id,
  37496. SickType: sick_id,
  37497. Insutype: insutype,
  37498. Ctime: time.Now().Unix(),
  37499. Mtime: time.Now().Unix(),
  37500. Status: 1,
  37501. IsCancel: 1,
  37502. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  37503. }
  37504. service.CreatePsnNCDSRecord(psnResult)
  37505. c.ServeSuccessJSON(map[string]interface{}{
  37506. "failed_code": 0,
  37507. "msg": "备案成功",
  37508. "result": psnResult,
  37509. })
  37510. } else {
  37511. c.ServeSuccessJSON(map[string]interface{}{
  37512. "failed_code": -10,
  37513. "msg": res2.ErrMsg,
  37514. })
  37515. return
  37516. }
  37517. }
  37518. }
  37519. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  37520. id, _ := c.GetInt64("id")
  37521. admin_user_id, _ := c.GetInt64("admin_user_id")
  37522. adminUser := c.GetAdminUserInfo()
  37523. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37524. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37525. //config, _ := service.Ge(adminUser.CurrentOrgId)
  37526. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  37527. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37528. //var user_name string
  37529. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37530. //if role.ID == 0 {
  37531. // user_name = "xxx"
  37532. //} else {
  37533. // user_name = role.UserName
  37534. //}
  37535. psn_record, _ := service.GetPsnNCDSRecordById(id)
  37536. if psn_record.ID == 0 {
  37537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  37538. return
  37539. }
  37540. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  37541. var res ResultTwo
  37542. var res10265 ResultTwo10265
  37543. if miConfig.Code == "H15049901371" {
  37544. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37545. utils.ErrorLog("解析失败:%v", err)
  37546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37547. return
  37548. }
  37549. res.ErrMsg = res10265.ErrMsg
  37550. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37551. res.Infcode = infocode
  37552. res.Output = res10265.Output
  37553. res.InfRefmsgid = res10265.InfRefmsgid
  37554. } else {
  37555. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37556. utils.ErrorLog("解析失败:%v", err)
  37557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37558. return
  37559. }
  37560. }
  37561. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37562. infoStr := string(Iinfos)
  37563. var rf []*ResultFive
  37564. json.Unmarshal([]byte(infoStr), &rf)
  37565. var insuplc_admdvs string
  37566. var insutype string
  37567. var is390 int = 0
  37568. var is310 int = 0
  37569. var insutypes []*ResultFive
  37570. for _, item := range rf {
  37571. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  37572. insutypes = append(insutypes, item)
  37573. }
  37574. }
  37575. if len(insutypes) == 1 {
  37576. insutype = insutypes[0].Insutype
  37577. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  37578. } else {
  37579. for _, i := range insutypes {
  37580. if i.Insutype == "390" {
  37581. is390 = 1
  37582. }
  37583. if i.Insutype == "310" {
  37584. is310 = 1
  37585. }
  37586. }
  37587. }
  37588. if is390 == 1 {
  37589. insutype = "390"
  37590. }
  37591. if is310 == 1 {
  37592. insutype = "310"
  37593. }
  37594. if len(insutypes) == 0 {
  37595. insutype = "310"
  37596. }
  37597. insutype = psn_record.Insutype
  37598. for _, item := range rf {
  37599. if item.Insutype == insutype {
  37600. insuplc_admdvs = item.InsuplcAdmdvs
  37601. }
  37602. }
  37603. if config.IsOpen == 1 {
  37604. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  37605. var dat map[string]interface{}
  37606. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37607. fmt.Println(dat)
  37608. } else {
  37609. fmt.Println(err)
  37610. }
  37611. userJSONBytes, _ := json.Marshal(dat)
  37612. var res ResultFourteen
  37613. var res10265 ResultFourteen10265
  37614. if miConfig.Code == "H15049901371" {
  37615. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37616. utils.ErrorLog("解析失败:%v", err)
  37617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37618. return
  37619. }
  37620. res.ErrMsg = res10265.ErrMsg
  37621. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37622. res.Infcode = infocode
  37623. res.Output = res10265.Output
  37624. res.InfRefmsgid = res10265.InfRefmsgid
  37625. } else {
  37626. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37627. utils.ErrorLog("解析失败:%v", err)
  37628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37629. return
  37630. }
  37631. }
  37632. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37633. // utils.ErrorLog("解析失败:%v", err)
  37634. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37635. // return
  37636. //}
  37637. if res.Infcode == 0 {
  37638. psn_record.IsCancel = 2
  37639. service.CreatePsnNCDSRecord(&psn_record)
  37640. c.ServeSuccessJSON(map[string]interface{}{
  37641. "failed_code": 0,
  37642. "msg": "撤销备案成功",
  37643. })
  37644. } else {
  37645. c.ServeSuccessJSON(map[string]interface{}{
  37646. "failed_code": -10,
  37647. "msg": res.ErrMsg,
  37648. })
  37649. return
  37650. }
  37651. }
  37652. }
  37653. func (c *HisApiController) TestTest() {
  37654. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  37655. fmt.Println(patient.Iinfo)
  37656. }
  37657. type CustomData struct {
  37658. MsgId string
  37659. PsnNo string
  37660. Info string
  37661. }
  37662. func (c *HisApiController) ReversalData() {
  37663. var customData []*CustomData
  37664. custom := &CustomData{
  37665. MsgId: "H44022900158202103301714472004",
  37666. PsnNo: "44020000001101329945",
  37667. Info: "2207",
  37668. }
  37669. customData = append(customData, custom)
  37670. custom1 := &CustomData{
  37671. MsgId: "H4402290015820210330172057803",
  37672. PsnNo: "44020000001101161813",
  37673. Info: "2207",
  37674. }
  37675. customData = append(customData, custom1)
  37676. custom2 := &CustomData{
  37677. MsgId: "H44022900158202103301705198813",
  37678. PsnNo: "44190000133097375417",
  37679. Info: "2207",
  37680. }
  37681. customData = append(customData, custom2)
  37682. custom3 := &CustomData{
  37683. MsgId: "H44022900158202103301715524756",
  37684. PsnNo: "44020000001100187221",
  37685. Info: "2207",
  37686. }
  37687. customData = append(customData, custom3)
  37688. custom4 := &CustomData{
  37689. MsgId: "H44022900158202103301730376224",
  37690. PsnNo: "44020000001101959155",
  37691. Info: "2207",
  37692. }
  37693. customData = append(customData, custom4)
  37694. custom5 := &CustomData{
  37695. MsgId: "H44022900158202103301748008725",
  37696. PsnNo: "44020000001104246641",
  37697. Info: "2207",
  37698. }
  37699. customData = append(customData, custom5)
  37700. custom6 := &CustomData{
  37701. MsgId: "H44022900158202103301718096755",
  37702. PsnNo: "44020000001102211860",
  37703. Info: "2207",
  37704. }
  37705. customData = append(customData, custom6)
  37706. custom7 := &CustomData{
  37707. MsgId: "H44022900158202103301736551640",
  37708. PsnNo: "44020000001102687718",
  37709. Info: "2207",
  37710. }
  37711. customData = append(customData, custom7)
  37712. custom8 := &CustomData{
  37713. MsgId: "H44022900158202103301743097676",
  37714. PsnNo: "44020000001102127785",
  37715. Info: "2207",
  37716. }
  37717. customData = append(customData, custom8)
  37718. custom9 := &CustomData{
  37719. MsgId: "H44022900158202103301712304203",
  37720. PsnNo: "44020000001101518097",
  37721. Info: "2207",
  37722. }
  37723. customData = append(customData, custom9)
  37724. custom10 := &CustomData{
  37725. MsgId: "H44022900158202103301738448785",
  37726. PsnNo: "44020000001100500813",
  37727. Info: "2207",
  37728. }
  37729. customData = append(customData, custom10)
  37730. custom11 := &CustomData{
  37731. MsgId: "H44022900158202103301732455843",
  37732. PsnNo: "44020000001102690557",
  37733. Info: "2207",
  37734. }
  37735. customData = append(customData, custom11)
  37736. custom12 := &CustomData{
  37737. MsgId: "H44022900158202103301745421708",
  37738. PsnNo: "44020000001102211928",
  37739. Info: "2207",
  37740. }
  37741. customData = append(customData, custom12)
  37742. custom1212 := &CustomData{
  37743. MsgId: "H440229001582021033017351627",
  37744. PsnNo: "44020000001102481733",
  37745. Info: "2207",
  37746. }
  37747. customData = append(customData, custom1212)
  37748. custom13 := &CustomData{
  37749. MsgId: "H44022900158202103301740327951",
  37750. PsnNo: "44020000001103174866",
  37751. Info: "2207",
  37752. }
  37753. customData = append(customData, custom13)
  37754. custom14 := &CustomData{
  37755. MsgId: "H4402290015820210330174922668",
  37756. PsnNo: "44020000001102927272",
  37757. Info: "2207",
  37758. }
  37759. customData = append(customData, custom14)
  37760. custom15 := &CustomData{
  37761. MsgId: "H44022900158202103301752362273",
  37762. PsnNo: "44020000001102942890",
  37763. Info: "2207",
  37764. }
  37765. customData = append(customData, custom15)
  37766. custom16 := &CustomData{
  37767. MsgId: "H44022900158202103301751082917",
  37768. PsnNo: "44020000001101662162",
  37769. Info: "2207",
  37770. }
  37771. customData = append(customData, custom16)
  37772. custom17 := &CustomData{
  37773. MsgId: "H44022900158202103301754147728",
  37774. PsnNo: "44020000000229014511",
  37775. Info: "2207",
  37776. }
  37777. customData = append(customData, custom17)
  37778. adminUser := c.GetAdminUserInfo()
  37779. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37780. for _, item := range customData {
  37781. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37782. fmt.Println(result)
  37783. }
  37784. }
  37785. func (c *HisApiController) GetAllopatry() {
  37786. year := c.GetString("year")
  37787. month := c.GetString("month")
  37788. admin_user_id, _ := c.GetInt64("admin_user_id")
  37789. adminUser := c.GetAdminUserInfo()
  37790. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37791. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37792. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37793. var dat map[string]interface{}
  37794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37795. fmt.Println(dat)
  37796. } else {
  37797. fmt.Println(err)
  37798. }
  37799. userJSONBytes, _ := json.Marshal(dat)
  37800. var res models.Result9001
  37801. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37802. utils.ErrorLog("解析失败:%v", err)
  37803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37804. return
  37805. }
  37806. fmt.Println(res.Output.Signinoutb)
  37807. fmt.Println(res.Output.Signinoutb.SignNo)
  37808. fmt.Println(string(userJSONBytes))
  37809. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37810. var dat3 map[string]interface{}
  37811. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  37812. fmt.Println(dat3)
  37813. } else {
  37814. fmt.Println(err)
  37815. }
  37816. userJSONBytes3, _ := json.Marshal(dat3)
  37817. var res3 models.Result3260
  37818. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  37819. utils.ErrorLog("解析失败:%v", err)
  37820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37821. return
  37822. }
  37823. var curpage int
  37824. var pagesize int = 100
  37825. var start int = 1
  37826. //var stop int
  37827. //pagecount := 10
  37828. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  37829. var res22 []models.Result3260
  37830. for curpage = 1; curpage <= pagecount; curpage++ {
  37831. if curpage == 1 {
  37832. start = 0
  37833. } else {
  37834. start = (curpage-1)*pagesize + 1
  37835. }
  37836. fmt.Println(start)
  37837. //stop = curpage * pagesize
  37838. //if stop > int(res3.Output.Totalrow) {
  37839. // stop =int(res3.Output.Totalrow)
  37840. //}
  37841. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  37842. var dat2 map[string]interface{}
  37843. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37844. fmt.Println(dat)
  37845. } else {
  37846. fmt.Println(err)
  37847. }
  37848. userJSONBytes2, _ := json.Marshal(dat2)
  37849. var res2 models.Result3260
  37850. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37851. utils.ErrorLog("解析失败:%v", err)
  37852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37853. return
  37854. }
  37855. if res2.Infcode == 0 {
  37856. res22 = append(res22, res2)
  37857. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37858. //var dat2 map[string]interface{}
  37859. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37860. // fmt.Println(dat)
  37861. //} else {
  37862. // fmt.Println(err)
  37863. //}
  37864. //c.ServeSuccessJSON(map[string]interface{}{
  37865. // "list": res2.Output.Data,
  37866. //})
  37867. //continue
  37868. }
  37869. }
  37870. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37871. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37872. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  37873. //var dat2 map[string]interface{}
  37874. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37875. // fmt.Println(dat)
  37876. //} else {
  37877. // fmt.Println(err)
  37878. //}
  37879. //userJSONBytes2, _ := json.Marshal(dat2)
  37880. //var res2 models.Result3260
  37881. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37882. // utils.ErrorLog("解析失败:%v", err)
  37883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37884. // return
  37885. //}
  37886. //if res2.Infcode == 0 {
  37887. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37888. // var dat2 map[string]interface{}
  37889. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37890. // fmt.Println(dat)
  37891. // } else {
  37892. // fmt.Println(err)
  37893. // }
  37894. // c.ServeSuccessJSON(map[string]interface{}{
  37895. // "list": res2.Output.Data,
  37896. // })
  37897. //}
  37898. }
  37899. func (c *HisApiController) ComfirmAllopatry() {
  37900. year := c.GetString("year")
  37901. month := c.GetString("month")
  37902. admin_user_id, _ := c.GetInt64("admin_user_id")
  37903. adminUser := c.GetAdminUserInfo()
  37904. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37905. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37906. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37907. var dat map[string]interface{}
  37908. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37909. fmt.Println(dat)
  37910. } else {
  37911. fmt.Println(err)
  37912. }
  37913. userJSONBytes, _ := json.Marshal(dat)
  37914. var res models.Result9001
  37915. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37916. utils.ErrorLog("解析失败:%v", err)
  37917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37918. return
  37919. }
  37920. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37921. var dat2 map[string]interface{}
  37922. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37923. fmt.Println(dat)
  37924. } else {
  37925. fmt.Println(err)
  37926. }
  37927. userJSONBytes2, _ := json.Marshal(dat2)
  37928. var res2 models.Result3260
  37929. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37930. utils.ErrorLog("解析失败:%v", err)
  37931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37932. return
  37933. }
  37934. //if res2.Infcode == 0 {
  37935. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37936. // var dat map[string]interface{}
  37937. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37938. // fmt.Println(dat)
  37939. // } else {
  37940. // fmt.Println(err)
  37941. // }
  37942. // userJSONBytes, _ := json.Marshal(dat)
  37943. // var res3 models.Result3261
  37944. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37945. // utils.ErrorLog("解析失败:%v", err)
  37946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37947. // return
  37948. // }
  37949. //
  37950. // if res3.Infcode == 0 {
  37951. // record := &models.HisYidiClearRecord{
  37952. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37953. // Ctime: time.Now().Unix(),
  37954. // Mtime: time.Now().Unix(),
  37955. // Status: 1,
  37956. // MsgId: msgId,
  37957. // }
  37958. // service.SaveClearRecord(record)
  37959. // c.ServeSuccessJSON(map[string]interface{}{
  37960. // "msg": "提取成功",
  37961. // })
  37962. // }
  37963. //}
  37964. }
  37965. func (c *HisApiController) RefundAllopatry() {
  37966. year := c.GetString("year")
  37967. month := c.GetString("month")
  37968. //id, _ := c.GetInt64("id")
  37969. admin_user_id, _ := c.GetInt64("admin_user_id")
  37970. adminUser := c.GetAdminUserInfo()
  37971. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37972. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37973. //record, _ := service.GetClearRecordById(id)
  37974. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37975. var dat map[string]interface{}
  37976. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37977. fmt.Println(dat)
  37978. } else {
  37979. fmt.Println(err)
  37980. }
  37981. userJSONBytes, _ := json.Marshal(dat)
  37982. var res models.Result9001
  37983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37984. utils.ErrorLog("解析失败:%v", err)
  37985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37986. return
  37987. }
  37988. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37989. var dat2 map[string]interface{}
  37990. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37991. fmt.Println(dat)
  37992. } else {
  37993. fmt.Println(err)
  37994. }
  37995. userJSONBytes2, _ := json.Marshal(dat2)
  37996. var empty ResultFourteen
  37997. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37998. utils.ErrorLog("解析失败:%v", err)
  37999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38000. return
  38001. }
  38002. if empty.Infcode == 0 {
  38003. c.ServeSuccessJSON(map[string]interface{}{
  38004. "msg": "撤销成功",
  38005. })
  38006. return
  38007. }
  38008. }
  38009. func (c *HisApiController) ReversalOtherData() {
  38010. var customData []*CustomData
  38011. custom := &CustomData{
  38012. MsgId: "H44022900158202103301714472004",
  38013. PsnNo: "44020000001101329945",
  38014. Info: "2208",
  38015. }
  38016. customData = append(customData, custom)
  38017. custom1 := &CustomData{
  38018. MsgId: "H4402290015820210330172057803",
  38019. PsnNo: "44020000001101161813",
  38020. Info: "2208",
  38021. }
  38022. customData = append(customData, custom1)
  38023. custom2 := &CustomData{
  38024. MsgId: "H44022900158202103301705198813",
  38025. PsnNo: "44190000133097375417",
  38026. Info: "2208",
  38027. }
  38028. customData = append(customData, custom2)
  38029. custom3 := &CustomData{
  38030. MsgId: "H44022900158202103301715524756",
  38031. PsnNo: "44020000001100187221",
  38032. Info: "2208",
  38033. }
  38034. customData = append(customData, custom3)
  38035. custom4 := &CustomData{
  38036. MsgId: "H44022900158202103301730376224",
  38037. PsnNo: "44020000001101959155",
  38038. Info: "2208",
  38039. }
  38040. customData = append(customData, custom4)
  38041. custom5 := &CustomData{
  38042. MsgId: "H44022900158202103301748008725",
  38043. PsnNo: "44020000001104246641",
  38044. Info: "2208",
  38045. }
  38046. customData = append(customData, custom5)
  38047. custom6 := &CustomData{
  38048. MsgId: "H44022900158202103301718096755",
  38049. PsnNo: "44020000001102211860",
  38050. Info: "2208",
  38051. }
  38052. customData = append(customData, custom6)
  38053. custom7 := &CustomData{
  38054. MsgId: "H44022900158202103301736551640",
  38055. PsnNo: "44020000001102687718",
  38056. Info: "2208",
  38057. }
  38058. customData = append(customData, custom7)
  38059. custom8 := &CustomData{
  38060. MsgId: "H44022900158202103301743097676",
  38061. PsnNo: "44020000001102127785",
  38062. Info: "2208",
  38063. }
  38064. customData = append(customData, custom8)
  38065. custom9 := &CustomData{
  38066. MsgId: "H44022900158202103301712304203",
  38067. PsnNo: "44020000001101518097",
  38068. Info: "2208",
  38069. }
  38070. customData = append(customData, custom9)
  38071. custom10 := &CustomData{
  38072. MsgId: "H44022900158202103301738448785",
  38073. PsnNo: "44020000001100500813",
  38074. Info: "2208",
  38075. }
  38076. customData = append(customData, custom10)
  38077. custom11 := &CustomData{
  38078. MsgId: "H44022900158202103301732455843",
  38079. PsnNo: "44020000001102690557",
  38080. Info: "2208",
  38081. }
  38082. customData = append(customData, custom11)
  38083. custom12 := &CustomData{
  38084. MsgId: "H44022900158202103301745421708",
  38085. PsnNo: "44020000001102211928",
  38086. Info: "2208",
  38087. }
  38088. customData = append(customData, custom12)
  38089. custom1212 := &CustomData{
  38090. MsgId: "H440229001582021033017351627",
  38091. PsnNo: "44020000001102481733",
  38092. Info: "2208",
  38093. }
  38094. customData = append(customData, custom1212)
  38095. custom13 := &CustomData{
  38096. MsgId: "H44022900158202103301740327951",
  38097. PsnNo: "44020000001103174866",
  38098. Info: "2208",
  38099. }
  38100. customData = append(customData, custom13)
  38101. custom14 := &CustomData{
  38102. MsgId: "H4402290015820210330174922668",
  38103. PsnNo: "44020000001102927272",
  38104. Info: "2208",
  38105. }
  38106. customData = append(customData, custom14)
  38107. custom15 := &CustomData{
  38108. MsgId: "H44022900158202103301752362273",
  38109. PsnNo: "44020000001102942890",
  38110. Info: "2208",
  38111. }
  38112. customData = append(customData, custom15)
  38113. custom16 := &CustomData{
  38114. MsgId: "H44022900158202103301751082917",
  38115. PsnNo: "44020000001101662162",
  38116. Info: "2208",
  38117. }
  38118. customData = append(customData, custom16)
  38119. custom17 := &CustomData{
  38120. MsgId: "H44022900158202103301754147728",
  38121. PsnNo: "44020000000229014511",
  38122. Info: "2208",
  38123. }
  38124. customData = append(customData, custom17)
  38125. adminUser := c.GetAdminUserInfo()
  38126. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38127. for _, item := range customData {
  38128. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  38129. fmt.Println(result)
  38130. }
  38131. }
  38132. func PathExists(path string) (bool, error) {
  38133. _, err := os.Stat(path)
  38134. if err == nil {
  38135. return true, nil
  38136. }
  38137. if os.IsNotExist(err) {
  38138. return false, nil
  38139. }
  38140. return false, err
  38141. }
  38142. // 创建文件夹
  38143. func Mkdir(dir string) {
  38144. // 创建文件夹
  38145. exist, err := PathExists(dir)
  38146. if err != nil {
  38147. fmt.Println(err.Error())
  38148. } else {
  38149. if exist {
  38150. fmt.Println(dir + "文件夹已存在!")
  38151. } else {
  38152. // 文件夹名称,权限
  38153. err := os.Mkdir(dir, os.ModePerm)
  38154. if err != nil {
  38155. fmt.Println(dir+"文件夹创建失败:", err.Error())
  38156. } else {
  38157. fmt.Println(dir + "文件夹创建成功!")
  38158. }
  38159. }
  38160. }
  38161. }
  38162. // 压缩文件
  38163. func Zip(srcFile string, destZip string) error {
  38164. zipfile, err := os.Create(destZip)
  38165. if err != nil {
  38166. return err
  38167. }
  38168. defer zipfile.Close()
  38169. archive := zip.NewWriter(zipfile)
  38170. defer archive.Close()
  38171. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  38172. if err != nil {
  38173. return err
  38174. }
  38175. header, err := zip.FileInfoHeader(info)
  38176. if err != nil {
  38177. return err
  38178. }
  38179. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  38180. // header.Name = path
  38181. if info.IsDir() {
  38182. header.Name += "/"
  38183. } else {
  38184. header.Method = zip.Deflate
  38185. }
  38186. writer, err := archive.CreateHeader(header)
  38187. if err != nil {
  38188. return err
  38189. }
  38190. if !info.IsDir() {
  38191. file, err := os.Open(path)
  38192. if err != nil {
  38193. return err
  38194. }
  38195. defer file.Close()
  38196. _, err = io.Copy(writer, file)
  38197. }
  38198. return err
  38199. })
  38200. return err
  38201. }
  38202. func ReadFile(filePath string) []byte {
  38203. f, err := os.Open(filePath)
  38204. if err != nil {
  38205. fmt.Println("read file fail", err)
  38206. return nil
  38207. }
  38208. defer f.Close()
  38209. fd, err := ioutil.ReadAll(f)
  38210. if err != nil {
  38211. fmt.Println("read to fd fail", err)
  38212. return nil
  38213. }
  38214. return fd
  38215. }
  38216. func saveLogq(result string, request string, infno string, desc string) {
  38217. dir := "日志"
  38218. utils.Mkdir(dir)
  38219. month := time.Unix(1557042972, 0).Format("1")
  38220. year := time.Now().Format("2006")
  38221. month = time.Now().Format("01")
  38222. day := time.Now().Format("02")
  38223. hour := time.Now().Format("15")
  38224. min := time.Now().Format("04")
  38225. sec := time.Now().Format("05")
  38226. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  38227. file := year + month + day + "_log"
  38228. file_name := file + ".txt"
  38229. file_path := "日志" + "/" + file_name
  38230. exist, _ := utils.PathExists(file_path)
  38231. if exist { //存在
  38232. fmt.Println("存在")
  38233. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  38234. if err != nil {
  38235. fmt.Println("read fail")
  38236. }
  38237. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  38238. n, _ := f.Seek(0, 2)
  38239. _, err = f.WriteAt([]byte(content), n)
  38240. } else { //不存在
  38241. fmt.Println("文件不存在,创建文件")
  38242. f, err := os.Create("日志" + "/" + file_name)
  38243. defer f.Close()
  38244. if err != nil {
  38245. } else {
  38246. _, err = f.Write([]byte("记录日志"))
  38247. }
  38248. }
  38249. }
  38250. func saveLog(result string, request string, infno string, desc string) {
  38251. org_id, _ := beego.AppConfig.Int64("org_id")
  38252. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38253. dir := miConfig.OrgName + "日志"
  38254. utils.Mkdir(dir)
  38255. month := time.Unix(1557042972, 0).Format("1")
  38256. year := time.Now().Format("2006")
  38257. month = time.Now().Format("01")
  38258. day := time.Now().Format("02")
  38259. hour := time.Now().Format("15")
  38260. min := time.Now().Format("04")
  38261. sec := time.Now().Format("05")
  38262. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  38263. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  38264. file_name := file + ".txt"
  38265. file_path := miConfig.OrgName + "日志" + "/" + file_name
  38266. exist, _ := utils.PathExists(file_path)
  38267. if exist { //存在
  38268. fmt.Println("存在")
  38269. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  38270. if err != nil {
  38271. fmt.Println("read fail")
  38272. }
  38273. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  38274. n, _ := f.Seek(0, 2)
  38275. _, err = f.WriteAt([]byte(content), n)
  38276. } else { //不存在
  38277. fmt.Println("文件不存在,创建文件")
  38278. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  38279. defer f.Close()
  38280. if err != nil {
  38281. } else {
  38282. _, err = f.Write([]byte("记录日志"))
  38283. }
  38284. }
  38285. }
  38286. type Charset string
  38287. const (
  38288. UTF8 = Charset("UTF-8")
  38289. GB18030 = Charset("GB18030")
  38290. )
  38291. func ConvertToString(src string, srcCode string, tagCode string) string {
  38292. srcCoder := mahonia.NewDecoder(srcCode)
  38293. srcResult := srcCoder.ConvertString(src)
  38294. tagCoder := mahonia.NewDecoder(tagCode)
  38295. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  38296. result := string(cdata)
  38297. return result
  38298. }
  38299. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  38300. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  38301. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38302. var token string
  38303. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  38304. var api string
  38305. if miConfig.MdtrtareaAdmvs == "320921" {
  38306. 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 +
  38307. "&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
  38308. fmt.Println(api)
  38309. } else {
  38310. 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 +
  38311. "&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
  38312. }
  38313. resp, requestErr := http.Get(api)
  38314. if requestErr != nil {
  38315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38316. return ""
  38317. }
  38318. body, ioErr := ioutil.ReadAll(resp.Body)
  38319. if ioErr != nil {
  38320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38322. return ""
  38323. }
  38324. var respJSON map[string]interface{}
  38325. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38328. return ""
  38329. }
  38330. var status string
  38331. status = respJSON["data"].(map[string]interface{})["status"].(string)
  38332. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  38333. var res ResultTwo //1101结果
  38334. var res10265 ResultTwo10265 //1101结果
  38335. if status == "0" { //读卡成功
  38336. var card_info string //卡信息
  38337. var busi_card_info string
  38338. token = respJSON["data"].(map[string]interface{})["token"].(string)
  38339. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  38340. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  38341. fmt.Println(card_info)
  38342. fmt.Println(busi_card_info)
  38343. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  38344. result, _ := json.Marshal(respJSON)
  38345. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38346. utils.ErrorLog("解析失败:%v", err)
  38347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38348. return ""
  38349. }
  38350. res.ErrMsg = res10265.ErrMsg
  38351. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38352. res.Infcode = infocode
  38353. res.Output = res10265.Output
  38354. res.InfRefmsgid = res10265.InfRefmsgid
  38355. if res.Infcode == 0 {
  38356. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  38357. if err == gorm.ErrRecordNotFound {
  38358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  38359. return ""
  38360. } else if err != nil {
  38361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  38362. return ""
  38363. } else {
  38364. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38365. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  38366. infoStr := string(Iinfos)
  38367. idetinfoStr := string(Idetinfos)
  38368. psn := &models.HisPsn{
  38369. PsnNo: res.Output.Baseinfo.PsnNo,
  38370. PatientId: patient.ID,
  38371. Certno: res.Output.Baseinfo.Certno,
  38372. Gend: res.Output.Baseinfo.Gend,
  38373. Naty: res.Output.Baseinfo.Naty,
  38374. PsnCertType: res.Output.Baseinfo.PsnCertType,
  38375. PsnName: res.Output.Baseinfo.PsnName,
  38376. Idetinfo: idetinfoStr,
  38377. Insuinfo: infoStr,
  38378. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  38379. CardInfo: card_info,
  38380. VerifyNumber: token,
  38381. }
  38382. service.CreateHisPsn(psn)
  38383. return token
  38384. }
  38385. }
  38386. } else {
  38387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38388. return ""
  38389. }
  38390. } else { //读卡失败
  38391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38392. return ""
  38393. }
  38394. return token
  38395. }
  38396. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  38397. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  38398. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38399. var token string
  38400. var api string
  38401. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  38402. "&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
  38403. fmt.Println(api)
  38404. resp, requestErr := http.Get(api)
  38405. if requestErr != nil {
  38406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38407. return ""
  38408. }
  38409. body, ioErr := ioutil.ReadAll(resp.Body)
  38410. if ioErr != nil {
  38411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38413. return ""
  38414. }
  38415. var respJSON map[string]interface{}
  38416. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38419. return ""
  38420. }
  38421. var status string
  38422. status = respJSON["data"].(map[string]interface{})["status"].(string)
  38423. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  38424. var res ResultTwo //1101结果
  38425. if status == "1" { //读卡成功
  38426. var card_info string //卡信息
  38427. var busi_card_info string
  38428. token = respJSON["data"].(map[string]interface{})["token"].(string)
  38429. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  38430. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  38431. fmt.Println(card_info)
  38432. fmt.Println(busi_card_info)
  38433. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  38434. result, _ := json.Marshal(respJSON)
  38435. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38436. utils.ErrorLog("解析失败:%v", err)
  38437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38438. return ""
  38439. }
  38440. if res.Infcode == 0 {
  38441. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  38442. if err == gorm.ErrRecordNotFound {
  38443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  38444. return ""
  38445. } else if err != nil {
  38446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  38447. return ""
  38448. } else {
  38449. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38450. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  38451. infoStr := string(Iinfos)
  38452. idetinfoStr := string(Idetinfos)
  38453. psn := &models.HisPsn{
  38454. PsnNo: res.Output.Baseinfo.PsnNo,
  38455. PatientId: patient.ID,
  38456. Certno: res.Output.Baseinfo.Certno,
  38457. Gend: res.Output.Baseinfo.Gend,
  38458. Naty: res.Output.Baseinfo.Naty,
  38459. PsnCertType: res.Output.Baseinfo.PsnCertType,
  38460. PsnName: res.Output.Baseinfo.PsnName,
  38461. Idetinfo: idetinfoStr,
  38462. Insuinfo: infoStr,
  38463. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  38464. CardInfo: card_info,
  38465. VerifyNumber: token,
  38466. }
  38467. service.CreateHisPsn(psn)
  38468. return token
  38469. }
  38470. }
  38471. } else {
  38472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38473. return ""
  38474. }
  38475. return token
  38476. }
  38477. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  38478. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  38479. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38480. var token string
  38481. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  38482. var api string
  38483. if miConfig.MdtrtareaAdmvs == "320921" {
  38484. 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 +
  38485. "&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
  38486. fmt.Println(api)
  38487. } else {
  38488. 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 +
  38489. "&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
  38490. }
  38491. resp, requestErr := http.Get(api)
  38492. if requestErr != nil {
  38493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38494. return ""
  38495. }
  38496. body, ioErr := ioutil.ReadAll(resp.Body)
  38497. if ioErr != nil {
  38498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38500. return ""
  38501. }
  38502. var respJSON map[string]interface{}
  38503. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38506. return ""
  38507. }
  38508. var status string
  38509. status = respJSON["data"].(map[string]interface{})["status"].(string)
  38510. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  38511. var res ResultTwo //1101结果
  38512. var res10265 ResultTwo10265 //1101结果
  38513. if status == "0" { //读卡成功
  38514. var card_info string //卡信息
  38515. var busi_card_info string
  38516. token = respJSON["data"].(map[string]interface{})["token"].(string)
  38517. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  38518. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  38519. fmt.Println(card_info)
  38520. fmt.Println(busi_card_info)
  38521. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  38522. result, _ := json.Marshal(respJSON)
  38523. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38524. utils.ErrorLog("解析失败:%v", err)
  38525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38526. return ""
  38527. }
  38528. res.ErrMsg = res10265.ErrMsg
  38529. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38530. res.Infcode = infocode
  38531. res.Output = res10265.Output
  38532. res.InfRefmsgid = res10265.InfRefmsgid
  38533. if res.Infcode == 0 {
  38534. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  38535. if err == gorm.ErrRecordNotFound {
  38536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  38537. return ""
  38538. } else if err != nil {
  38539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  38540. return ""
  38541. } else {
  38542. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38543. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  38544. infoStr := string(Iinfos)
  38545. idetinfoStr := string(Idetinfos)
  38546. psn := &models.HisPsn{
  38547. PsnNo: res.Output.Baseinfo.PsnNo,
  38548. PatientId: patient.ID,
  38549. Certno: res.Output.Baseinfo.Certno,
  38550. Gend: res.Output.Baseinfo.Gend,
  38551. Naty: res.Output.Baseinfo.Naty,
  38552. PsnCertType: res.Output.Baseinfo.PsnCertType,
  38553. PsnName: res.Output.Baseinfo.PsnName,
  38554. Idetinfo: idetinfoStr,
  38555. Insuinfo: infoStr,
  38556. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  38557. CardInfo: card_info,
  38558. VerifyNumber: token,
  38559. }
  38560. service.CreateHisPsn(psn)
  38561. return token
  38562. }
  38563. }
  38564. } else {
  38565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38566. return ""
  38567. }
  38568. } else { //读卡失败
  38569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38570. return ""
  38571. }
  38572. return token
  38573. }
  38574. func DeleteExtraSpaceTwo(s string) string {
  38575. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  38576. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  38577. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  38578. reg, _ := regexp.Compile(regstr) //编译正则表达式
  38579. s2 := make([]byte, len(s1)) //定义字符数组切片
  38580. copy(s2, s1) //将字符串复制到切片
  38581. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  38582. for len(spc_index) > 0 { //找到适配项
  38583. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  38584. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  38585. }
  38586. return string(s2)
  38587. }
  38588. func Remove0000(s string) string {
  38589. str := make([]rune, 0, len(s))
  38590. for _, v := range []rune(s) {
  38591. if v == 0 {
  38592. continue
  38593. }
  38594. str = append(str, v)
  38595. }
  38596. return string(str)
  38597. }
  38598. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  38599. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  38600. readCard := DllDef.MustFindProc("EcQuery")
  38601. pCardInfo := make([]byte, 8192)
  38602. pBusiCardInfo := make([]byte, 8192)
  38603. data := make(map[string]interface{})
  38604. //pData := make(map[string]interface{})
  38605. inputData := make(map[string]interface{})
  38606. inputData["orgId"] = code
  38607. inputData["businessType"] = "01101"
  38608. inputData["operatorId"] = operator_id
  38609. inputData["operatorName"] = operator_name
  38610. inputData["officeId"] = "001"
  38611. inputData["officeName"] = "血透室"
  38612. //
  38613. data["data"] = inputData
  38614. data["transType"] = "ec.query"
  38615. data["orgId"] = code
  38616. bytesData, _ := json.Marshal(data)
  38617. pCardInfo = bytesData
  38618. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  38619. fmt.Println(ret2)
  38620. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  38621. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  38622. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  38623. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  38624. if ret2 != 0 {
  38625. return "", ""
  38626. }
  38627. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  38628. }
  38629. func DeleteExtraSpace(s string) string {
  38630. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  38631. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  38632. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  38633. reg, _ := regexp.Compile(regstr) //编译正则表达式
  38634. s2 := make([]byte, len(s1)) //定义字符数组切片
  38635. copy(s2, s1) //将字符串复制到切片
  38636. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  38637. for len(spc_index) > 0 { //找到适配项
  38638. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  38639. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  38640. }
  38641. return string(s2)
  38642. }
  38643. // 对账
  38644. func (c *HisApiController) Post3202() {
  38645. start_time := c.GetString("start_time")
  38646. end_time := c.GetString("end_time")
  38647. //insutype := c.GetString("insutype")
  38648. clr_type := c.GetString("clr_type")
  38649. clr_org := c.GetString("clr_optins")
  38650. admin_user_id, _ := c.GetInt64("admin_user_id")
  38651. adminUser := c.GetAdminUserInfo()
  38652. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38653. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38654. if len(clr_org) == 0 {
  38655. clr_org = miConfig.MdtrtareaAdmvs
  38656. }
  38657. timeLayout := "2006-01-02"
  38658. loc, _ := time.LoadLocation("Local")
  38659. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38660. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38661. var orders []*models.HisOrder
  38662. if clr_org == "421300" {
  38663. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38664. } else if clr_org == "420902" {
  38665. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38666. } else {
  38667. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38668. }
  38669. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38670. //fixmedins_setl_cnt := int64(len(orders))
  38671. var medfee_sumamt float64
  38672. var acct_pay float64
  38673. var fund_pay_sumamt float64
  38674. for _, item := range orders {
  38675. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38676. acct_pay = acct_pay + item.AcctPay
  38677. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38678. }
  38679. //var medfee_sumamt_two float64
  38680. //var acct_pay_two float64
  38681. //var fund_pay_sumamt_two float64
  38682. //for _, item := range orders_two {
  38683. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38684. // acct_pay_two = acct_pay_two + item.AcctPay
  38685. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38686. //}
  38687. //var user_name string
  38688. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38689. //if role.ID == 0 {
  38690. // user_name = "xxx"
  38691. //} else {
  38692. // user_name = role.UserName
  38693. //}
  38694. var res ResultSix
  38695. if config.IsOpen == 1 {
  38696. var bps []*models.BusinessParamsTwo
  38697. var bp models.BusinessParamsTwo
  38698. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38699. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38700. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38701. bp.MedfeeSumamt = medfee_sumamt_str
  38702. bp.AcctPay = acct_pay_str
  38703. bp.FundPaySumamt = fund_pay_sumamt_str
  38704. bp.Insutype = ""
  38705. bp.StmtBegndate = start_time
  38706. bp.ClrType = clr_type
  38707. bp.SetlOptins = clr_org
  38708. bp.StmtEnddate = end_time
  38709. bps = append(bps, &bp)
  38710. data := make(map[string]interface{})
  38711. data["bps"] = bps
  38712. data["org_name"] = miConfig.OrgName
  38713. data["doctor"] = role.UserName
  38714. data["fixmedins_code"] = miConfig.Code
  38715. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38716. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38717. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38718. if miConfig.MdtrtareaAdmvs == "421300" {
  38719. client := &http.Client{}
  38720. bytesData, _ := json.Marshal(data)
  38721. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  38722. resp, _ := client.Do(req)
  38723. defer resp.Body.Close()
  38724. body, ioErr := ioutil.ReadAll(resp.Body)
  38725. if ioErr != nil {
  38726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38728. return
  38729. }
  38730. var respJSON map[string]interface{}
  38731. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38734. return
  38735. }
  38736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38737. userJSONBytes, _ := json.Marshal(respJSON)
  38738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38739. utils.ErrorLog("解析失败:%v", err)
  38740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38741. return
  38742. }
  38743. }
  38744. if miConfig.MdtrtareaAdmvs == "420200" {
  38745. client := &http.Client{}
  38746. bytesData, _ := json.Marshal(data)
  38747. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  38748. resp, _ := client.Do(req)
  38749. defer resp.Body.Close()
  38750. body, ioErr := ioutil.ReadAll(resp.Body)
  38751. if ioErr != nil {
  38752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38754. return
  38755. }
  38756. var respJSON map[string]interface{}
  38757. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38760. return
  38761. }
  38762. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38763. userJSONBytes, _ := json.Marshal(respJSON)
  38764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38765. utils.ErrorLog("解析失败:%v", err)
  38766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38767. return
  38768. }
  38769. }
  38770. if miConfig.MdtrtareaAdmvs == "421182" {
  38771. client := &http.Client{}
  38772. bytesData, _ := json.Marshal(data)
  38773. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38774. resp, _ := client.Do(req)
  38775. defer resp.Body.Close()
  38776. body, ioErr := ioutil.ReadAll(resp.Body)
  38777. if ioErr != nil {
  38778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38780. return
  38781. }
  38782. var respJSON map[string]interface{}
  38783. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38786. return
  38787. }
  38788. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38789. userJSONBytes, _ := json.Marshal(respJSON)
  38790. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38791. utils.ErrorLog("解析失败:%v", err)
  38792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38793. return
  38794. }
  38795. }
  38796. if miConfig.MdtrtareaAdmvs == "420902" {
  38797. client := &http.Client{}
  38798. bytesData, _ := json.Marshal(data)
  38799. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38800. resp, _ := client.Do(req)
  38801. defer resp.Body.Close()
  38802. body, ioErr := ioutil.ReadAll(resp.Body)
  38803. if ioErr != nil {
  38804. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38806. return
  38807. }
  38808. var respJSON map[string]interface{}
  38809. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38812. return
  38813. }
  38814. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38815. userJSONBytes, _ := json.Marshal(respJSON)
  38816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38817. utils.ErrorLog("解析失败:%v", err)
  38818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38819. return
  38820. }
  38821. }
  38822. if res.Infcode == 0 {
  38823. c.ServeSuccessJSON(map[string]interface{}{
  38824. "msg": "发起成功",
  38825. })
  38826. } else {
  38827. c.ServeSuccessJSON(map[string]interface{}{
  38828. "failed_code": -10,
  38829. "msg": res.ErrMsg,
  38830. })
  38831. }
  38832. }
  38833. }
  38834. func (c *HisApiController) Post3204a() {
  38835. start_time := c.GetString("start_time")
  38836. end_time := c.GetString("end_time")
  38837. //insutype := c.GetString("insutype")
  38838. clr_type := c.GetString("clr_type")
  38839. clr_org := c.GetString("clr_optins")
  38840. admin_user_id, _ := c.GetInt64("admin_user_id")
  38841. adminUser := c.GetAdminUserInfo()
  38842. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38843. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38844. if len(clr_org) == 0 {
  38845. clr_org = miConfig.MdtrtareaAdmvs
  38846. }
  38847. timeLayout := "2006-01-02"
  38848. loc, _ := time.LoadLocation("Local")
  38849. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38850. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38851. var orders []*models.HisOrder
  38852. if clr_org == "421300" {
  38853. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38854. } else if clr_org == "420902" {
  38855. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38856. } else {
  38857. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38858. }
  38859. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38860. //fixmedins_setl_cnt := int64(len(orders))
  38861. var medfee_sumamt float64
  38862. var acct_pay float64
  38863. var fund_pay_sumamt float64
  38864. for _, item := range orders {
  38865. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38866. acct_pay = acct_pay + item.AcctPay
  38867. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38868. }
  38869. //var medfee_sumamt_two float64
  38870. //var acct_pay_two float64
  38871. //var fund_pay_sumamt_two float64
  38872. //for _, item := range orders_two {
  38873. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38874. // acct_pay_two = acct_pay_two + item.AcctPay
  38875. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38876. //}
  38877. //var user_name string
  38878. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38879. //if role.ID == 0 {
  38880. // user_name = "xxx"
  38881. //} else {
  38882. // user_name = role.UserName
  38883. //}
  38884. var res ResultSix
  38885. if config.IsOpen == 1 {
  38886. var bps []*models.BusinessParamsTwo
  38887. var bp models.BusinessParamsTwo
  38888. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38889. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38890. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38891. bp.MedfeeSumamt = medfee_sumamt_str
  38892. bp.AcctPay = acct_pay_str
  38893. bp.FundPaySumamt = fund_pay_sumamt_str
  38894. bp.Insutype = ""
  38895. bp.StmtBegndate = start_time
  38896. bp.ClrType = clr_type
  38897. bp.SetlOptins = clr_org
  38898. bp.StmtEnddate = end_time
  38899. bps = append(bps, &bp)
  38900. data := make(map[string]interface{})
  38901. data["bps"] = bps
  38902. data["org_name"] = miConfig.OrgName
  38903. data["doctor"] = role.UserName
  38904. data["fixmedins_code"] = miConfig.Code
  38905. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38906. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38907. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38908. if miConfig.MdtrtareaAdmvs == "421300" {
  38909. client := &http.Client{}
  38910. bytesData, _ := json.Marshal(data)
  38911. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38912. resp, _ := client.Do(req)
  38913. defer resp.Body.Close()
  38914. body, ioErr := ioutil.ReadAll(resp.Body)
  38915. if ioErr != nil {
  38916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38918. return
  38919. }
  38920. var respJSON map[string]interface{}
  38921. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38924. return
  38925. }
  38926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38927. userJSONBytes, _ := json.Marshal(respJSON)
  38928. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38929. utils.ErrorLog("解析失败:%v", err)
  38930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38931. return
  38932. }
  38933. }
  38934. if miConfig.MdtrtareaAdmvs == "420200" {
  38935. client := &http.Client{}
  38936. bytesData, _ := json.Marshal(data)
  38937. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38938. resp, _ := client.Do(req)
  38939. defer resp.Body.Close()
  38940. body, ioErr := ioutil.ReadAll(resp.Body)
  38941. if ioErr != nil {
  38942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38944. return
  38945. }
  38946. var respJSON map[string]interface{}
  38947. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38950. return
  38951. }
  38952. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38953. userJSONBytes, _ := json.Marshal(respJSON)
  38954. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38955. utils.ErrorLog("解析失败:%v", err)
  38956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38957. return
  38958. }
  38959. }
  38960. if miConfig.MdtrtareaAdmvs == "421182" {
  38961. client := &http.Client{}
  38962. bytesData, _ := json.Marshal(data)
  38963. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38964. resp, _ := client.Do(req)
  38965. defer resp.Body.Close()
  38966. body, ioErr := ioutil.ReadAll(resp.Body)
  38967. if ioErr != nil {
  38968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38970. return
  38971. }
  38972. var respJSON map[string]interface{}
  38973. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38976. return
  38977. }
  38978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38979. userJSONBytes, _ := json.Marshal(respJSON)
  38980. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38981. utils.ErrorLog("解析失败:%v", err)
  38982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38983. return
  38984. }
  38985. }
  38986. if miConfig.MdtrtareaAdmvs == "420902" {
  38987. client := &http.Client{}
  38988. bytesData, _ := json.Marshal(data)
  38989. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38990. resp, _ := client.Do(req)
  38991. defer resp.Body.Close()
  38992. body, ioErr := ioutil.ReadAll(resp.Body)
  38993. if ioErr != nil {
  38994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38996. return
  38997. }
  38998. var respJSON map[string]interface{}
  38999. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39002. return
  39003. }
  39004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39005. userJSONBytes, _ := json.Marshal(respJSON)
  39006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39007. utils.ErrorLog("解析失败:%v", err)
  39008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39009. return
  39010. }
  39011. }
  39012. if res.Infcode == 0 {
  39013. c.ServeSuccessJSON(map[string]interface{}{
  39014. "msg": "撤销成功",
  39015. })
  39016. } else {
  39017. c.ServeSuccessJSON(map[string]interface{}{
  39018. "failed_code": -10,
  39019. "msg": res.ErrMsg,
  39020. })
  39021. }
  39022. }
  39023. }
  39024. func (c *HisApiController) Post3204() {
  39025. admin_user_id, _ := c.GetInt64("admin_user_id")
  39026. id := c.GetString("id")
  39027. adminUser := c.GetAdminUserInfo()
  39028. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39029. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39030. //clr_org := miConfig.MdtrtareaAdmvs
  39031. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39032. var res ResultSix
  39033. if config.IsOpen == 1 {
  39034. data := make(map[string]interface{})
  39035. data["id"] = id
  39036. data["org_name"] = miConfig.OrgName
  39037. data["doctor"] = role.UserName
  39038. data["fixmedins_code"] = miConfig.Code
  39039. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39040. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39041. client := &http.Client{}
  39042. bytesData, _ := json.Marshal(data)
  39043. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  39044. resp, _ := client.Do(req)
  39045. defer resp.Body.Close()
  39046. body, ioErr := ioutil.ReadAll(resp.Body)
  39047. if ioErr != nil {
  39048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39050. return
  39051. }
  39052. var respJSON map[string]interface{}
  39053. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39056. return
  39057. }
  39058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39059. userJSONBytes, _ := json.Marshal(respJSON)
  39060. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39061. utils.ErrorLog("解析失败:%v", err)
  39062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39063. return
  39064. }
  39065. if res.Infcode == 0 {
  39066. c.ServeSuccessJSON(map[string]interface{}{
  39067. "msg": "发起成功",
  39068. })
  39069. } else {
  39070. c.ServeSuccessJSON(map[string]interface{}{
  39071. "failed_code": -10,
  39072. "msg": res.ErrMsg,
  39073. })
  39074. }
  39075. }
  39076. }
  39077. func (c *HisApiController) Post8404() {
  39078. admin_user_id, _ := c.GetInt64("admin_user_id")
  39079. month := c.GetString("month")
  39080. adminUser := c.GetAdminUserInfo()
  39081. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39082. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39083. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39084. var res ResultSix
  39085. if config.IsOpen == 1 {
  39086. data := make(map[string]interface{})
  39087. data["month"] = month
  39088. data["org_name"] = miConfig.OrgName
  39089. data["doctor"] = role.UserName
  39090. data["fixmedins_code"] = miConfig.Code
  39091. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39092. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39093. client := &http.Client{}
  39094. bytesData, _ := json.Marshal(data)
  39095. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  39096. resp, _ := client.Do(req)
  39097. defer resp.Body.Close()
  39098. body, ioErr := ioutil.ReadAll(resp.Body)
  39099. if ioErr != nil {
  39100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39102. return
  39103. }
  39104. var respJSON map[string]interface{}
  39105. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39108. return
  39109. }
  39110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39111. userJSONBytes, _ := json.Marshal(respJSON)
  39112. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39113. utils.ErrorLog("解析失败:%v", err)
  39114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39115. return
  39116. }
  39117. if res.Infcode == 0 {
  39118. c.ServeSuccessJSON(map[string]interface{}{
  39119. "msg": "查询成功",
  39120. })
  39121. } else {
  39122. c.ServeSuccessJSON(map[string]interface{}{
  39123. "failed_code": -10,
  39124. "msg": res.ErrMsg,
  39125. })
  39126. }
  39127. }
  39128. }
  39129. func (c *HisApiController) Post3202b() {
  39130. start_time := c.GetString("start_time")
  39131. end_time := c.GetString("end_time")
  39132. //insutype := c.GetString("insutype")
  39133. clr_type := c.GetString("clr_type")
  39134. clr_org := c.GetString("clr_optins")
  39135. admin_user_id, _ := c.GetInt64("admin_user_id")
  39136. adminUser := c.GetAdminUserInfo()
  39137. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39138. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39139. if len(clr_org) == 0 {
  39140. clr_org = miConfig.MdtrtareaAdmvs
  39141. }
  39142. timeLayout := "2006-01-02"
  39143. loc, _ := time.LoadLocation("Local")
  39144. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39145. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39146. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39147. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39148. //fixmedins_setl_cnt := int64(len(orders))
  39149. var medfee_sumamt float64
  39150. var acct_pay float64
  39151. var fund_pay_sumamt float64
  39152. for _, item := range orders {
  39153. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39154. acct_pay = acct_pay + item.AcctPay
  39155. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39156. }
  39157. //var medfee_sumamt_two float64
  39158. //var acct_pay_two float64
  39159. //var fund_pay_sumamt_two float64
  39160. //for _, item := range orders_two {
  39161. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39162. // acct_pay_two = acct_pay_two + item.AcctPay
  39163. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39164. //}
  39165. //var user_name string
  39166. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39167. //if role.ID == 0 {
  39168. // user_name = "xxx"
  39169. //} else {
  39170. // user_name = role.UserName
  39171. //}
  39172. var res ResultSix
  39173. if config.IsOpen == 1 {
  39174. var bps []*models.BusinessParamsTwo
  39175. var bp models.BusinessParamsTwo
  39176. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39177. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39178. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39179. bp.MedfeeSumamt = medfee_sumamt_str
  39180. bp.AcctPay = acct_pay_str
  39181. bp.FundPaySumamt = fund_pay_sumamt_str
  39182. bp.Insutype = "390"
  39183. bp.StmtBegndate = start_time
  39184. bp.ClrType = clr_type
  39185. bp.SetlOptins = clr_org
  39186. bp.StmtEnddate = end_time
  39187. bps = append(bps, &bp)
  39188. data := make(map[string]interface{})
  39189. data["bps"] = bps
  39190. data["org_name"] = miConfig.OrgName
  39191. data["doctor"] = role.UserName
  39192. data["fixmedins_code"] = miConfig.Code
  39193. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39194. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39195. if miConfig.MdtrtareaAdmvs == "421300" {
  39196. client := &http.Client{}
  39197. bytesData, _ := json.Marshal(data)
  39198. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  39199. resp, _ := client.Do(req)
  39200. defer resp.Body.Close()
  39201. body, ioErr := ioutil.ReadAll(resp.Body)
  39202. if ioErr != nil {
  39203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39205. return
  39206. }
  39207. var respJSON map[string]interface{}
  39208. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39211. return
  39212. }
  39213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39214. userJSONBytes, _ := json.Marshal(respJSON)
  39215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39216. utils.ErrorLog("解析失败:%v", err)
  39217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39218. return
  39219. }
  39220. }
  39221. if miConfig.MdtrtareaAdmvs == "420200" {
  39222. client := &http.Client{}
  39223. bytesData, _ := json.Marshal(data)
  39224. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  39225. resp, _ := client.Do(req)
  39226. defer resp.Body.Close()
  39227. body, ioErr := ioutil.ReadAll(resp.Body)
  39228. if ioErr != nil {
  39229. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39231. return
  39232. }
  39233. var respJSON map[string]interface{}
  39234. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39237. return
  39238. }
  39239. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39240. userJSONBytes, _ := json.Marshal(respJSON)
  39241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39242. utils.ErrorLog("解析失败:%v", err)
  39243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39244. return
  39245. }
  39246. }
  39247. if miConfig.MdtrtareaAdmvs == "421182" {
  39248. client := &http.Client{}
  39249. bytesData, _ := json.Marshal(data)
  39250. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  39251. resp, _ := client.Do(req)
  39252. defer resp.Body.Close()
  39253. body, ioErr := ioutil.ReadAll(resp.Body)
  39254. if ioErr != nil {
  39255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39257. return
  39258. }
  39259. var respJSON map[string]interface{}
  39260. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39263. return
  39264. }
  39265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39266. userJSONBytes, _ := json.Marshal(respJSON)
  39267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39268. utils.ErrorLog("解析失败:%v", err)
  39269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39270. return
  39271. }
  39272. }
  39273. if res.Infcode == 0 {
  39274. c.ServeSuccessJSON(map[string]interface{}{
  39275. "msg": "发起成功",
  39276. })
  39277. } else {
  39278. c.ServeSuccessJSON(map[string]interface{}{
  39279. "failed_code": -10,
  39280. "msg": res.ErrMsg,
  39281. })
  39282. }
  39283. }
  39284. }
  39285. func (c *HisApiController) Post1608() {
  39286. start_time := c.GetString("start_time")
  39287. end_time := c.GetString("end_time")
  39288. admin_user_id, _ := c.GetInt64("admin_user_id")
  39289. adminUser := c.GetAdminUserInfo()
  39290. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39291. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39292. timeLayout := "2006-01-02"
  39293. loc, _ := time.LoadLocation("Local")
  39294. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39295. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39296. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39297. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39298. fixmedins_setl_cnt := int64(len(orders))
  39299. var medfee_sumamt float64
  39300. var func_smamt float64
  39301. for _, item := range orders {
  39302. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39303. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  39304. }
  39305. times := strings.Split(start_time, "-")
  39306. time_tows := strings.Split(end_time, "-")
  39307. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39308. var res ResultSix
  39309. if config.IsOpen == 1 {
  39310. //var bps []*models.BusinessParamsTwo
  39311. //var bp models.BusinessParamsTwo
  39312. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39313. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  39314. data := make(map[string]interface{})
  39315. data["org_name"] = miConfig.OrgName
  39316. data["doctor"] = role.UserName
  39317. data["func_smamt"] = func_smamt_str
  39318. data["fixmedins_code"] = miConfig.Code
  39319. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39320. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39321. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  39322. data["medfee_sumamt"] = medfee_sumamt_str
  39323. data["start_time"] = times[0] + times[1] + times[2]
  39324. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  39325. if miConfig.MdtrtareaAdmvs == "421300" {
  39326. client := &http.Client{}
  39327. bytesData, _ := json.Marshal(data)
  39328. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  39329. resp, _ := client.Do(req)
  39330. defer resp.Body.Close()
  39331. body, ioErr := ioutil.ReadAll(resp.Body)
  39332. if ioErr != nil {
  39333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39335. return
  39336. }
  39337. var respJSON map[string]interface{}
  39338. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39341. return
  39342. }
  39343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39344. userJSONBytes, _ := json.Marshal(respJSON)
  39345. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39346. utils.ErrorLog("解析失败:%v", err)
  39347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39348. return
  39349. }
  39350. }
  39351. if miConfig.MdtrtareaAdmvs == "420200" {
  39352. client := &http.Client{}
  39353. bytesData, _ := json.Marshal(data)
  39354. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  39355. resp, _ := client.Do(req)
  39356. defer resp.Body.Close()
  39357. body, ioErr := ioutil.ReadAll(resp.Body)
  39358. if ioErr != nil {
  39359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39361. return
  39362. }
  39363. var respJSON map[string]interface{}
  39364. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39367. return
  39368. }
  39369. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39370. userJSONBytes, _ := json.Marshal(respJSON)
  39371. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39372. utils.ErrorLog("解析失败:%v", err)
  39373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39374. return
  39375. }
  39376. }
  39377. if miConfig.MdtrtareaAdmvs == "421182" {
  39378. client := &http.Client{}
  39379. bytesData, _ := json.Marshal(data)
  39380. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  39381. resp, _ := client.Do(req)
  39382. defer resp.Body.Close()
  39383. body, ioErr := ioutil.ReadAll(resp.Body)
  39384. if ioErr != nil {
  39385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39387. return
  39388. }
  39389. var respJSON map[string]interface{}
  39390. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39393. return
  39394. }
  39395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39396. userJSONBytes, _ := json.Marshal(respJSON)
  39397. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39398. utils.ErrorLog("解析失败:%v", err)
  39399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39400. return
  39401. }
  39402. }
  39403. if res.Infcode == 0 {
  39404. c.ServeSuccessJSON(map[string]interface{}{
  39405. "msg": "发起成功",
  39406. })
  39407. } else {
  39408. c.ServeSuccessJSON(map[string]interface{}{
  39409. "failed_code": -10,
  39410. "msg": res.ErrMsg,
  39411. })
  39412. }
  39413. }
  39414. }
  39415. // 5.11.1.1【5262】结算信息按时间段查询
  39416. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  39417. admin_user_id, _ := c.GetInt64("admin_user_id")
  39418. adminUser := c.GetAdminUserInfo()
  39419. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39420. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39421. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39422. var res Result5262
  39423. if config.IsOpen == 1 {
  39424. if miConfig.MdtrtareaAdmvs == "421300" {
  39425. data := make(map[string]interface{})
  39426. data["bps"] = bp
  39427. data["org_name"] = miConfig.OrgName
  39428. data["doctor"] = role.UserName
  39429. data["fixmedins_code"] = miConfig.Code
  39430. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39431. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39432. data["page"] = strconv.FormatInt(page, 10)
  39433. data["limit"] = strconv.FormatInt(limit, 10)
  39434. fmt.Println(data)
  39435. client := &http.Client{}
  39436. bytesData, _ := json.Marshal(data)
  39437. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  39438. resp, _ := client.Do(req)
  39439. defer resp.Body.Close()
  39440. body, ioErr := ioutil.ReadAll(resp.Body)
  39441. if ioErr != nil {
  39442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39444. return
  39445. }
  39446. var respJSON map[string]interface{}
  39447. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39450. return
  39451. }
  39452. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39453. userJSONBytes, _ := json.Marshal(respJSON)
  39454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39455. utils.ErrorLog("解析失败:%v", err)
  39456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39457. return
  39458. }
  39459. }
  39460. if miConfig.MdtrtareaAdmvs == "420200" {
  39461. data := make(map[string]interface{})
  39462. data["bps"] = bp
  39463. data["org_name"] = miConfig.OrgName
  39464. data["doctor"] = role.UserName
  39465. data["fixmedins_code"] = miConfig.Code
  39466. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39467. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39468. data["page"] = strconv.FormatInt(page, 10)
  39469. data["limit"] = strconv.FormatInt(limit, 10)
  39470. fmt.Println(data)
  39471. client := &http.Client{}
  39472. bytesData, _ := json.Marshal(data)
  39473. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  39474. resp, _ := client.Do(req)
  39475. defer resp.Body.Close()
  39476. body, ioErr := ioutil.ReadAll(resp.Body)
  39477. if ioErr != nil {
  39478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39480. return
  39481. }
  39482. var respJSON map[string]interface{}
  39483. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39486. return
  39487. }
  39488. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39489. userJSONBytes, _ := json.Marshal(respJSON)
  39490. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39491. utils.ErrorLog("解析失败:%v", err)
  39492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39493. return
  39494. }
  39495. }
  39496. if miConfig.MdtrtareaAdmvs == "421182" {
  39497. data := make(map[string]interface{})
  39498. data["bps"] = bp
  39499. data["org_name"] = miConfig.OrgName
  39500. data["doctor"] = role.UserName
  39501. data["fixmedins_code"] = miConfig.Code
  39502. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39503. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39504. data["page"] = strconv.FormatInt(page, 10)
  39505. data["limit"] = strconv.FormatInt(limit, 10)
  39506. fmt.Println(data)
  39507. client := &http.Client{}
  39508. bytesData, _ := json.Marshal(data)
  39509. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  39510. resp, _ := client.Do(req)
  39511. defer resp.Body.Close()
  39512. body, ioErr := ioutil.ReadAll(resp.Body)
  39513. if ioErr != nil {
  39514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39516. return
  39517. }
  39518. var respJSON map[string]interface{}
  39519. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39522. return
  39523. }
  39524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39525. userJSONBytes, _ := json.Marshal(respJSON)
  39526. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39527. utils.ErrorLog("解析失败:%v", err)
  39528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39529. return
  39530. }
  39531. }
  39532. if miConfig.MdtrtareaAdmvs == "420902" {
  39533. data := make(map[string]interface{})
  39534. data["bps"] = bp
  39535. data["org_name"] = miConfig.OrgName
  39536. data["doctor"] = role.UserName
  39537. data["fixmedins_code"] = miConfig.Code
  39538. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39539. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39540. data["page"] = strconv.FormatInt(page, 10)
  39541. data["limit"] = strconv.FormatInt(limit, 10)
  39542. fmt.Println(data)
  39543. client := &http.Client{}
  39544. bytesData, _ := json.Marshal(data)
  39545. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  39546. resp, _ := client.Do(req)
  39547. defer resp.Body.Close()
  39548. body, ioErr := ioutil.ReadAll(resp.Body)
  39549. if ioErr != nil {
  39550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39552. return
  39553. }
  39554. var respJSON map[string]interface{}
  39555. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39558. return
  39559. }
  39560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39561. userJSONBytes, _ := json.Marshal(respJSON)
  39562. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39563. utils.ErrorLog("解析失败:%v", err)
  39564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39565. return
  39566. }
  39567. }
  39568. if res.Infcode == 0 {
  39569. c.ServeSuccessJSON(map[string]interface{}{
  39570. "order": res.Output.Result,
  39571. "total": res.Output.PageInfo.RecordCounts,
  39572. })
  39573. } else {
  39574. c.ServeSuccessJSON(map[string]interface{}{
  39575. "failed_code": -10,
  39576. "msg": res.ErrMsg,
  39577. })
  39578. }
  39579. }
  39580. }
  39581. // 5.11.1.2【5267】异地结算信息时间段查询
  39582. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  39583. admin_user_id, _ := c.GetInt64("admin_user_id")
  39584. adminUser := c.GetAdminUserInfo()
  39585. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39586. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39587. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39588. var res Result5267
  39589. if config.IsOpen == 1 {
  39590. if miConfig.MdtrtareaAdmvs == "421300" {
  39591. data := make(map[string]interface{})
  39592. data["bps"] = bp
  39593. data["org_name"] = miConfig.OrgName
  39594. data["doctor"] = role.UserName
  39595. data["fixmedins_code"] = miConfig.Code
  39596. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39597. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39598. data["page"] = page
  39599. data["limit"] = limit
  39600. fmt.Println(data)
  39601. client := &http.Client{}
  39602. bytesData, _ := json.Marshal(data)
  39603. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  39604. resp, _ := client.Do(req)
  39605. defer resp.Body.Close()
  39606. body, ioErr := ioutil.ReadAll(resp.Body)
  39607. if ioErr != nil {
  39608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39610. return
  39611. }
  39612. var respJSON map[string]interface{}
  39613. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39616. return
  39617. }
  39618. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39619. userJSONBytes, _ := json.Marshal(respJSON)
  39620. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39621. utils.ErrorLog("解析失败:%v", err)
  39622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39623. return
  39624. }
  39625. }
  39626. if miConfig.MdtrtareaAdmvs == "420200" {
  39627. data := make(map[string]interface{})
  39628. data["bps"] = bp
  39629. data["org_name"] = miConfig.OrgName
  39630. data["doctor"] = role.UserName
  39631. data["fixmedins_code"] = miConfig.Code
  39632. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39633. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39634. data["page"] = page
  39635. data["limit"] = limit
  39636. fmt.Println(data)
  39637. client := &http.Client{}
  39638. bytesData, _ := json.Marshal(data)
  39639. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  39640. resp, _ := client.Do(req)
  39641. defer resp.Body.Close()
  39642. body, ioErr := ioutil.ReadAll(resp.Body)
  39643. if ioErr != nil {
  39644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39646. return
  39647. }
  39648. var respJSON map[string]interface{}
  39649. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39652. return
  39653. }
  39654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39655. userJSONBytes, _ := json.Marshal(respJSON)
  39656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39657. utils.ErrorLog("解析失败:%v", err)
  39658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39659. return
  39660. }
  39661. }
  39662. if miConfig.MdtrtareaAdmvs == "421182" {
  39663. data := make(map[string]interface{})
  39664. data["bps"] = bp
  39665. data["org_name"] = miConfig.OrgName
  39666. data["doctor"] = role.UserName
  39667. data["fixmedins_code"] = miConfig.Code
  39668. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39669. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39670. data["page"] = page
  39671. data["limit"] = limit
  39672. fmt.Println(data)
  39673. client := &http.Client{}
  39674. bytesData, _ := json.Marshal(data)
  39675. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  39676. resp, _ := client.Do(req)
  39677. defer resp.Body.Close()
  39678. body, ioErr := ioutil.ReadAll(resp.Body)
  39679. if ioErr != nil {
  39680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39682. return
  39683. }
  39684. var respJSON map[string]interface{}
  39685. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39688. return
  39689. }
  39690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39691. userJSONBytes, _ := json.Marshal(respJSON)
  39692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39693. utils.ErrorLog("解析失败:%v", err)
  39694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39695. return
  39696. }
  39697. }
  39698. if res.Infcode == 0 {
  39699. c.ServeSuccessJSON(map[string]interface{}{
  39700. "order": res.Output.Result,
  39701. "total": res.Output.PageInfo.RecordCounts,
  39702. })
  39703. } else {
  39704. c.ServeSuccessJSON(map[string]interface{}{
  39705. "failed_code": -10,
  39706. "msg": res.ErrMsg,
  39707. })
  39708. }
  39709. }
  39710. }
  39711. func (c *HisApiController) Post3501() {
  39712. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39713. data := make(map[string]interface{})
  39714. var struct3501s []models.Struct3501
  39715. var struct3501 models.Struct3501
  39716. struct3501.OrgName = miConfig.OrgName
  39717. struct3501.AccessKey = miConfig.AccessKey
  39718. struct3501.RequestUrl = miConfig.Url
  39719. struct3501.SecretKey = miConfig.SecretKey
  39720. struct3501.ManuDate = "2022-08-17"
  39721. struct3501.FixmedinsBchno = ""
  39722. struct3501.ManuLotnum = ""
  39723. struct3501.RxFlag = "0"
  39724. struct3501.ExpyEnd = "2022-08-17"
  39725. struct3501.Invdate = "2022-08-17"
  39726. struct3501.InvCnt = "20.25"
  39727. struct3501.Memo = ""
  39728. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39729. struct3501.FixmedinsHilistId = miConfig.Code
  39730. struct3501.FixmedinsHilistName = miConfig.OrgName
  39731. struct3501s = append(struct3501s, struct3501)
  39732. data["struct_3501s"] = struct3501s
  39733. client := &http.Client{}
  39734. bytesData, _ := json.Marshal(data)
  39735. var req *http.Request
  39736. if miConfig.MdtrtareaAdmvs == "320921" {
  39737. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39738. } else {
  39739. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39740. }
  39741. resp, _ := client.Do(req)
  39742. defer resp.Body.Close()
  39743. body, ioErr := ioutil.ReadAll(resp.Body)
  39744. if ioErr != nil {
  39745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39747. return
  39748. }
  39749. var respJSON map[string]interface{}
  39750. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39753. return
  39754. }
  39755. var res ResultSix
  39756. var resSix10265 ResultSix10265 //1101结果
  39757. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39758. result, _ := json.Marshal(respJSON)
  39759. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39760. utils.ErrorLog("解析失败:%v", err)
  39761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39762. return
  39763. }
  39764. res.InfRefmsgid = resSix10265.InfRefmsgid
  39765. res.Output = resSix10265.Output
  39766. res.ErrMsg = resSix10265.ErrMsg
  39767. res.Cainfo = resSix10265.Cainfo
  39768. res.WarnMsg = resSix10265.WarnMsg
  39769. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39770. res.Infcode = infocode
  39771. if infocode == 0 {
  39772. c.ServeSuccessJSON(map[string]interface{}{
  39773. "msg": "上传成功",
  39774. })
  39775. return
  39776. } else {
  39777. c.ServeSuccessJSON(map[string]interface{}{
  39778. "failed_code": -10,
  39779. "msg": res.ErrMsg,
  39780. })
  39781. return
  39782. }
  39783. }
  39784. func (c *HisApiController) Post3502() {
  39785. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39786. data := make(map[string]interface{})
  39787. var struct3502s []models.Struct3502
  39788. var struct3502 models.Struct3502
  39789. struct3502.OrgName = miConfig.OrgName
  39790. struct3502.AccessKey = miConfig.AccessKey
  39791. struct3502.RequestUrl = miConfig.Url
  39792. struct3502.SecretKey = miConfig.SecretKey
  39793. struct3502.ManuDate = "2022-08-15"
  39794. struct3502.FixmedinsBchno = ""
  39795. struct3502.ManuLotnum = ""
  39796. struct3502.RxFlag = "0"
  39797. struct3502.ExpyEnd = "2022-08-15"
  39798. struct3502.Invdate = "2022-08-15"
  39799. struct3502.InvCnt = "20.25"
  39800. struct3502.Memo = ""
  39801. struct3502.MedListCodg = "XB01ABD056B002020200517"
  39802. struct3502.FixmedinsHilistId = miConfig.Code
  39803. struct3502.FixmedinsHilistName = miConfig.OrgName
  39804. struct3502s = append(struct3502s, struct3502)
  39805. data["struct_3502s"] = struct3502s
  39806. client := &http.Client{}
  39807. bytesData, _ := json.Marshal(data)
  39808. var req *http.Request
  39809. if miConfig.MdtrtareaAdmvs == "320921" {
  39810. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39811. } else {
  39812. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39813. }
  39814. resp, _ := client.Do(req)
  39815. defer resp.Body.Close()
  39816. body, ioErr := ioutil.ReadAll(resp.Body)
  39817. if ioErr != nil {
  39818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39820. return
  39821. }
  39822. var respJSON map[string]interface{}
  39823. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39826. return
  39827. }
  39828. var res ResultSix
  39829. var resSix10265 ResultSix10265 //1101结果
  39830. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39831. result, _ := json.Marshal(respJSON)
  39832. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39833. utils.ErrorLog("解析失败:%v", err)
  39834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39835. return
  39836. }
  39837. res.InfRefmsgid = resSix10265.InfRefmsgid
  39838. res.Output = resSix10265.Output
  39839. res.ErrMsg = resSix10265.ErrMsg
  39840. res.Cainfo = resSix10265.Cainfo
  39841. res.WarnMsg = resSix10265.WarnMsg
  39842. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39843. res.Infcode = infocode
  39844. if infocode == 0 {
  39845. c.ServeSuccessJSON(map[string]interface{}{
  39846. "msg": "上传成功",
  39847. })
  39848. return
  39849. } else {
  39850. c.ServeSuccessJSON(map[string]interface{}{
  39851. "failed_code": -10,
  39852. "msg": res.ErrMsg,
  39853. })
  39854. return
  39855. }
  39856. }
  39857. func (c *HisApiController) Post3503() {
  39858. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39859. data := make(map[string]interface{})
  39860. var struct3501s []models.Struct3501
  39861. var struct3501 models.Struct3501
  39862. struct3501.OrgName = miConfig.OrgName
  39863. struct3501.AccessKey = miConfig.AccessKey
  39864. struct3501.RequestUrl = miConfig.Url
  39865. struct3501.SecretKey = miConfig.SecretKey
  39866. struct3501.ManuDate = "2022-08-15"
  39867. struct3501.FixmedinsBchno = ""
  39868. struct3501.ManuLotnum = ""
  39869. struct3501.RxFlag = "0"
  39870. struct3501.ExpyEnd = "2022-08-15"
  39871. struct3501.Invdate = "2022-08-15"
  39872. struct3501.InvCnt = "20.25"
  39873. struct3501.Memo = ""
  39874. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39875. struct3501.FixmedinsHilistId = miConfig.Code
  39876. struct3501.FixmedinsHilistName = miConfig.OrgName
  39877. struct3501s = append(struct3501s, struct3501)
  39878. data["struct_3501s"] = struct3501s
  39879. client := &http.Client{}
  39880. bytesData, _ := json.Marshal(data)
  39881. var req *http.Request
  39882. if miConfig.MdtrtareaAdmvs == "320921" {
  39883. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39884. } else {
  39885. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39886. }
  39887. resp, _ := client.Do(req)
  39888. defer resp.Body.Close()
  39889. body, ioErr := ioutil.ReadAll(resp.Body)
  39890. if ioErr != nil {
  39891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39893. return
  39894. }
  39895. var respJSON map[string]interface{}
  39896. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39899. return
  39900. }
  39901. var res ResultSix
  39902. var resSix10265 ResultSix10265 //1101结果
  39903. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39904. result, _ := json.Marshal(respJSON)
  39905. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39906. utils.ErrorLog("解析失败:%v", err)
  39907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39908. return
  39909. }
  39910. res.InfRefmsgid = resSix10265.InfRefmsgid
  39911. res.Output = resSix10265.Output
  39912. res.ErrMsg = resSix10265.ErrMsg
  39913. res.Cainfo = resSix10265.Cainfo
  39914. res.WarnMsg = resSix10265.WarnMsg
  39915. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39916. res.Infcode = infocode
  39917. if infocode == 0 {
  39918. c.ServeSuccessJSON(map[string]interface{}{
  39919. "msg": "上传成功",
  39920. })
  39921. return
  39922. } else {
  39923. c.ServeSuccessJSON(map[string]interface{}{
  39924. "failed_code": -10,
  39925. "msg": res.ErrMsg,
  39926. })
  39927. return
  39928. }
  39929. }
  39930. func (c *HisApiController) Post3504() {
  39931. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39932. data := make(map[string]interface{})
  39933. var struct3501s []models.Struct3501
  39934. var struct3501 models.Struct3501
  39935. struct3501.OrgName = miConfig.OrgName
  39936. struct3501.AccessKey = miConfig.AccessKey
  39937. struct3501.RequestUrl = miConfig.Url
  39938. struct3501.SecretKey = miConfig.SecretKey
  39939. struct3501.ManuDate = "2022-08-15"
  39940. struct3501.FixmedinsBchno = ""
  39941. struct3501.ManuLotnum = ""
  39942. struct3501.RxFlag = "0"
  39943. struct3501.ExpyEnd = "2022-08-15"
  39944. struct3501.Invdate = "2022-08-15"
  39945. struct3501.InvCnt = "20.25"
  39946. struct3501.Memo = ""
  39947. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39948. struct3501.FixmedinsHilistId = miConfig.Code
  39949. struct3501.FixmedinsHilistName = miConfig.OrgName
  39950. struct3501s = append(struct3501s, struct3501)
  39951. data["struct_3501s"] = struct3501s
  39952. client := &http.Client{}
  39953. bytesData, _ := json.Marshal(data)
  39954. var req *http.Request
  39955. if miConfig.MdtrtareaAdmvs == "320921" {
  39956. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39957. } else {
  39958. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39959. }
  39960. resp, _ := client.Do(req)
  39961. defer resp.Body.Close()
  39962. body, ioErr := ioutil.ReadAll(resp.Body)
  39963. if ioErr != nil {
  39964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39966. return
  39967. }
  39968. var respJSON map[string]interface{}
  39969. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39972. return
  39973. }
  39974. var res ResultSix
  39975. var resSix10265 ResultSix10265 //1101结果
  39976. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39977. result, _ := json.Marshal(respJSON)
  39978. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39979. utils.ErrorLog("解析失败:%v", err)
  39980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39981. return
  39982. }
  39983. res.InfRefmsgid = resSix10265.InfRefmsgid
  39984. res.Output = resSix10265.Output
  39985. res.ErrMsg = resSix10265.ErrMsg
  39986. res.Cainfo = resSix10265.Cainfo
  39987. res.WarnMsg = resSix10265.WarnMsg
  39988. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39989. res.Infcode = infocode
  39990. if infocode == 0 {
  39991. c.ServeSuccessJSON(map[string]interface{}{
  39992. "msg": "上传成功",
  39993. })
  39994. return
  39995. } else {
  39996. c.ServeSuccessJSON(map[string]interface{}{
  39997. "failed_code": -10,
  39998. "msg": res.ErrMsg,
  39999. })
  40000. return
  40001. }
  40002. }
  40003. func (c *HisApiController) Post3505() {
  40004. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40005. data := make(map[string]interface{})
  40006. var struct3501s []models.Struct3501
  40007. var struct3501 models.Struct3501
  40008. struct3501.OrgName = miConfig.OrgName
  40009. struct3501.AccessKey = miConfig.AccessKey
  40010. struct3501.RequestUrl = miConfig.Url
  40011. struct3501.SecretKey = miConfig.SecretKey
  40012. struct3501.ManuDate = "2022-08-15"
  40013. struct3501.FixmedinsBchno = ""
  40014. struct3501.ManuLotnum = ""
  40015. struct3501.RxFlag = "0"
  40016. struct3501.ExpyEnd = "2022-08-15"
  40017. struct3501.Invdate = "2022-08-15"
  40018. struct3501.InvCnt = "20.25"
  40019. struct3501.Memo = ""
  40020. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40021. struct3501.FixmedinsHilistId = miConfig.Code
  40022. struct3501.FixmedinsHilistName = miConfig.OrgName
  40023. struct3501s = append(struct3501s, struct3501)
  40024. data["struct_3501s"] = struct3501s
  40025. client := &http.Client{}
  40026. bytesData, _ := json.Marshal(data)
  40027. var req *http.Request
  40028. if miConfig.MdtrtareaAdmvs == "320921" {
  40029. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40030. } else {
  40031. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40032. }
  40033. resp, _ := client.Do(req)
  40034. defer resp.Body.Close()
  40035. body, ioErr := ioutil.ReadAll(resp.Body)
  40036. if ioErr != nil {
  40037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40039. return
  40040. }
  40041. var respJSON map[string]interface{}
  40042. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40045. return
  40046. }
  40047. var res ResultSix
  40048. var resSix10265 ResultSix10265 //1101结果
  40049. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40050. result, _ := json.Marshal(respJSON)
  40051. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40052. utils.ErrorLog("解析失败:%v", err)
  40053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40054. return
  40055. }
  40056. res.InfRefmsgid = resSix10265.InfRefmsgid
  40057. res.Output = resSix10265.Output
  40058. res.ErrMsg = resSix10265.ErrMsg
  40059. res.Cainfo = resSix10265.Cainfo
  40060. res.WarnMsg = resSix10265.WarnMsg
  40061. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40062. res.Infcode = infocode
  40063. if infocode == 0 {
  40064. c.ServeSuccessJSON(map[string]interface{}{
  40065. "msg": "上传成功",
  40066. })
  40067. return
  40068. } else {
  40069. c.ServeSuccessJSON(map[string]interface{}{
  40070. "failed_code": -10,
  40071. "msg": res.ErrMsg,
  40072. })
  40073. return
  40074. }
  40075. }
  40076. func (c *HisApiController) Post3506() {
  40077. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40078. data := make(map[string]interface{})
  40079. var struct3501s []models.Struct3501
  40080. var struct3501 models.Struct3501
  40081. struct3501.OrgName = miConfig.OrgName
  40082. struct3501.AccessKey = miConfig.AccessKey
  40083. struct3501.RequestUrl = miConfig.Url
  40084. struct3501.SecretKey = miConfig.SecretKey
  40085. struct3501.ManuDate = "2022-08-15"
  40086. struct3501.FixmedinsBchno = ""
  40087. struct3501.ManuLotnum = ""
  40088. struct3501.RxFlag = "0"
  40089. struct3501.ExpyEnd = "2022-08-15"
  40090. struct3501.Invdate = "2022-08-15"
  40091. struct3501.InvCnt = "20.25"
  40092. struct3501.Memo = ""
  40093. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40094. struct3501.FixmedinsHilistId = miConfig.Code
  40095. struct3501.FixmedinsHilistName = miConfig.OrgName
  40096. struct3501s = append(struct3501s, struct3501)
  40097. data["struct_3501s"] = struct3501s
  40098. client := &http.Client{}
  40099. bytesData, _ := json.Marshal(data)
  40100. var req *http.Request
  40101. if miConfig.MdtrtareaAdmvs == "320921" {
  40102. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40103. } else {
  40104. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40105. }
  40106. resp, _ := client.Do(req)
  40107. defer resp.Body.Close()
  40108. body, ioErr := ioutil.ReadAll(resp.Body)
  40109. if ioErr != nil {
  40110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40112. return
  40113. }
  40114. var respJSON map[string]interface{}
  40115. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40118. return
  40119. }
  40120. var res ResultSix
  40121. var resSix10265 ResultSix10265 //1101结果
  40122. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40123. result, _ := json.Marshal(respJSON)
  40124. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40125. utils.ErrorLog("解析失败:%v", err)
  40126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40127. return
  40128. }
  40129. res.InfRefmsgid = resSix10265.InfRefmsgid
  40130. res.Output = resSix10265.Output
  40131. res.ErrMsg = resSix10265.ErrMsg
  40132. res.Cainfo = resSix10265.Cainfo
  40133. res.WarnMsg = resSix10265.WarnMsg
  40134. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40135. res.Infcode = infocode
  40136. if infocode == 0 {
  40137. c.ServeSuccessJSON(map[string]interface{}{
  40138. "msg": "上传成功",
  40139. })
  40140. return
  40141. } else {
  40142. c.ServeSuccessJSON(map[string]interface{}{
  40143. "failed_code": -10,
  40144. "msg": res.ErrMsg,
  40145. })
  40146. return
  40147. }
  40148. }
  40149. func (c *HisApiController) Post3507() {
  40150. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40151. data := make(map[string]interface{})
  40152. var struct3501s []models.Struct3501
  40153. var struct3501 models.Struct3501
  40154. struct3501.OrgName = miConfig.OrgName
  40155. struct3501.AccessKey = miConfig.AccessKey
  40156. struct3501.RequestUrl = miConfig.Url
  40157. struct3501.SecretKey = miConfig.SecretKey
  40158. struct3501.ManuDate = "2022-08-15"
  40159. struct3501.FixmedinsBchno = ""
  40160. struct3501.ManuLotnum = ""
  40161. struct3501.RxFlag = "0"
  40162. struct3501.ExpyEnd = "2022-08-15"
  40163. struct3501.Invdate = "2022-08-15"
  40164. struct3501.InvCnt = "20.25"
  40165. struct3501.Memo = ""
  40166. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40167. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  40168. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  40169. struct3501s = append(struct3501s, struct3501)
  40170. data["struct_3501s"] = struct3501s
  40171. client := &http.Client{}
  40172. bytesData, _ := json.Marshal(data)
  40173. var req *http.Request
  40174. if miConfig.MdtrtareaAdmvs == "320921" {
  40175. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40176. } else {
  40177. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40178. }
  40179. resp, _ := client.Do(req)
  40180. defer resp.Body.Close()
  40181. body, ioErr := ioutil.ReadAll(resp.Body)
  40182. if ioErr != nil {
  40183. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40185. return
  40186. }
  40187. var respJSON map[string]interface{}
  40188. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40191. return
  40192. }
  40193. var res ResultSix
  40194. var resSix10265 ResultSix10265 //1101结果
  40195. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40196. result, _ := json.Marshal(respJSON)
  40197. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40198. utils.ErrorLog("解析失败:%v", err)
  40199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40200. return
  40201. }
  40202. res.InfRefmsgid = resSix10265.InfRefmsgid
  40203. res.Output = resSix10265.Output
  40204. res.ErrMsg = resSix10265.ErrMsg
  40205. res.Cainfo = resSix10265.Cainfo
  40206. res.WarnMsg = resSix10265.WarnMsg
  40207. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40208. res.Infcode = infocode
  40209. if infocode == 0 {
  40210. c.ServeSuccessJSON(map[string]interface{}{
  40211. "msg": "上传成功",
  40212. })
  40213. return
  40214. } else {
  40215. c.ServeSuccessJSON(map[string]interface{}{
  40216. "failed_code": -10,
  40217. "msg": res.ErrMsg,
  40218. })
  40219. return
  40220. }
  40221. }
  40222. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  40223. // WebSocket服务器地址
  40224. serverURL := "ws://127.0.0.1:8899"
  40225. // 解析WebSocket服务器地址
  40226. u, err := url.Parse(serverURL)
  40227. if err != nil {
  40228. }
  40229. // 建立WebSocket连接
  40230. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40231. if err != nil {
  40232. }
  40233. defer conn.Close()
  40234. input2 := make(map[string]interface{})
  40235. input := make(map[string]interface{})
  40236. inputData := make(map[string]interface{})
  40237. inputData["orgId"] = code
  40238. inputData["businessType"] = "01101"
  40239. inputData["operatorId"] = operator_id
  40240. inputData["operatorName"] = operator_name
  40241. inputData["officeId"] = "001"
  40242. inputData["officeName"] = "血透室"
  40243. inputData["deviceType"] = ""
  40244. input["data"] = inputData
  40245. input["orgId"] = code
  40246. input["transType"] = "ec.query"
  40247. //if md == ""
  40248. if md[:4] == "4403" {
  40249. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40250. } else if md[:4] == "4401" {
  40251. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40252. } else {
  40253. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40254. }
  40255. input2["indata"] = input
  40256. fmt.Println(input2)
  40257. bytesData, _ := json.Marshal(input2)
  40258. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40259. if err != nil {
  40260. fmt.Println(err)
  40261. }
  40262. // 接收消息
  40263. _, receivedMessage, err := conn.ReadMessage()
  40264. if err != nil {
  40265. fmt.Println(err)
  40266. }
  40267. return "", string(receivedMessage)
  40268. }
  40269. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  40270. // WebSocket服务器地址
  40271. serverURL := "ws://127.0.0.1:8899"
  40272. // 解析WebSocket服务器地址
  40273. u, err := url.Parse(serverURL)
  40274. if err != nil {
  40275. }
  40276. // 建立WebSocket连接
  40277. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40278. if err != nil {
  40279. }
  40280. defer conn.Close()
  40281. input2 := make(map[string]interface{})
  40282. input := make(map[string]interface{})
  40283. inputData := make(map[string]interface{})
  40284. inputData["orgId"] = code
  40285. inputData["businessType"] = "01101"
  40286. inputData["operatorId"] = operator_id
  40287. inputData["operatorName"] = operator_name
  40288. inputData["officeId"] = "001"
  40289. inputData["officeName"] = "血透室"
  40290. inputData["deviceType"] = ""
  40291. input["data"] = inputData
  40292. input["orgId"] = code
  40293. input["transType"] = "ec.query"
  40294. //if md == ""
  40295. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  40296. input2["indata"] = input
  40297. fmt.Println(input2)
  40298. bytesData, _ := json.Marshal(input2)
  40299. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40300. if err != nil {
  40301. fmt.Println(err)
  40302. }
  40303. // 接收消息
  40304. _, receivedMessage, err := conn.ReadMessage()
  40305. if err != nil {
  40306. fmt.Println(err)
  40307. }
  40308. return "", string(receivedMessage)
  40309. }
  40310. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  40311. // WebSocket服务器地址
  40312. serverURL := "ws://127.0.0.1:8899"
  40313. // 解析WebSocket服务器地址
  40314. u, err := url.Parse(serverURL)
  40315. if err != nil {
  40316. }
  40317. // 建立WebSocket连接
  40318. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40319. if err != nil {
  40320. }
  40321. defer conn.Close()
  40322. input2 := make(map[string]interface{})
  40323. input := make(map[string]interface{})
  40324. inputData := make(map[string]interface{})
  40325. inputData["orgId"] = code
  40326. inputData["businessType"] = "01301"
  40327. inputData["operatorId"] = operator_id
  40328. inputData["operatorName"] = operator_name
  40329. inputData["officeId"] = "001"
  40330. inputData["officeName"] = "血透室"
  40331. inputData["deviceType"] = ""
  40332. input["data"] = inputData
  40333. input["orgId"] = code
  40334. input["transType"] = "ec.query"
  40335. //if md == ""
  40336. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  40337. input2["indata"] = input
  40338. fmt.Println(input2)
  40339. bytesData, _ := json.Marshal(input2)
  40340. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40341. if err != nil {
  40342. fmt.Println(err)
  40343. }
  40344. // 接收消息
  40345. _, receivedMessage, err := conn.ReadMessage()
  40346. if err != nil {
  40347. fmt.Println(err)
  40348. }
  40349. return "", string(receivedMessage)
  40350. }
  40351. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  40352. // WebSocket服务器地址
  40353. serverURL := "ws://127.0.0.1:8899"
  40354. // 解析WebSocket服务器地址
  40355. u, err := url.Parse(serverURL)
  40356. if err != nil {
  40357. }
  40358. // 建立WebSocket连接
  40359. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40360. if err != nil {
  40361. }
  40362. defer conn.Close()
  40363. input2 := make(map[string]interface{})
  40364. input := make(map[string]interface{})
  40365. inputData := make(map[string]interface{})
  40366. inputData["orgId"] = code
  40367. inputData["businessType"] = "01103"
  40368. inputData["operatorId"] = operator_id
  40369. inputData["operatorName"] = operator_name
  40370. inputData["officeId"] = "001"
  40371. inputData["officeName"] = "血透室"
  40372. inputData["deviceType"] = ""
  40373. input["data"] = inputData
  40374. input["orgId"] = code
  40375. input["transType"] = "ec.query"
  40376. //if md ==
  40377. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  40378. input2["indata"] = input
  40379. fmt.Println(input2)
  40380. bytesData, _ := json.Marshal(input2)
  40381. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40382. if err != nil {
  40383. fmt.Println(err)
  40384. }
  40385. // 接收消息
  40386. _, receivedMessage, err := conn.ReadMessage()
  40387. if err != nil {
  40388. fmt.Println(err)
  40389. }
  40390. return "", string(receivedMessage)
  40391. }
  40392. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  40393. // WebSocket服务器地址
  40394. serverURL := "ws://127.0.0.1:8899"
  40395. // 解析WebSocket服务器地址
  40396. u, err := url.Parse(serverURL)
  40397. if err != nil {
  40398. }
  40399. // 建立WebSocket连接
  40400. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40401. if err != nil {
  40402. }
  40403. defer conn.Close()
  40404. input2 := make(map[string]interface{})
  40405. input := make(map[string]interface{})
  40406. inputData := make(map[string]interface{})
  40407. inputData["orgId"] = code
  40408. inputData["businessType"] = "01101"
  40409. inputData["operatorId"] = operator_id
  40410. inputData["operatorName"] = operator_name
  40411. inputData["officeId"] = "001"
  40412. inputData["officeName"] = "血透室"
  40413. inputData["deviceType"] = ""
  40414. input["data"] = inputData
  40415. input["orgId"] = code
  40416. input["transType"] = "ec.query"
  40417. //if md == ""
  40418. if md[:4] == "4403" {
  40419. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40420. } else if md[:4] == "4401" {
  40421. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40422. } else {
  40423. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40424. }
  40425. input2["indata"] = input
  40426. fmt.Println(input2)
  40427. bytesData, _ := json.Marshal(input2)
  40428. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40429. if err != nil {
  40430. fmt.Println(err)
  40431. }
  40432. // 接收消息
  40433. _, receivedMessage, err := conn.ReadMessage()
  40434. if err != nil {
  40435. fmt.Println(err)
  40436. }
  40437. return "", string(receivedMessage)
  40438. }
  40439. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  40440. // WebSocket服务器地址
  40441. serverURL := "ws://127.0.0.1:8899"
  40442. // 解析WebSocket服务器地址
  40443. u, err := url.Parse(serverURL)
  40444. if err != nil {
  40445. }
  40446. // 建立WebSocket连接
  40447. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40448. if err != nil {
  40449. }
  40450. defer conn.Close()
  40451. input2 := make(map[string]interface{})
  40452. input := make(map[string]interface{})
  40453. inputData := make(map[string]interface{})
  40454. inputData["orgId"] = code
  40455. inputData["businessType"] = "01301"
  40456. inputData["operatorId"] = operator_id
  40457. inputData["operatorName"] = operator_name
  40458. inputData["officeId"] = "001"
  40459. inputData["officeName"] = "血透室"
  40460. inputData["deviceType"] = ""
  40461. input["data"] = inputData
  40462. input["orgId"] = code
  40463. input["transType"] = "ec.query"
  40464. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40465. input2["indata"] = input
  40466. bytesData, _ := json.Marshal(input2)
  40467. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40468. if err != nil {
  40469. fmt.Println(err)
  40470. }
  40471. // 接收消息
  40472. _, receivedMessage, err := conn.ReadMessage()
  40473. if err != nil {
  40474. fmt.Println(err)
  40475. }
  40476. return "", string(receivedMessage)
  40477. }
  40478. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  40479. newArr = make([]string, 0)
  40480. for i := 0; i < len(arr); i++ {
  40481. repeat := false
  40482. for j := i + 1; j < len(arr); j++ {
  40483. if arr[i] == arr[j] {
  40484. repeat = true
  40485. break
  40486. }
  40487. }
  40488. if !repeat {
  40489. newArr = append(newArr, arr[i])
  40490. }
  40491. }
  40492. return
  40493. }
  40494. func getBirthdateAndAge(idNumber string) (string, int, error) {
  40495. if len(idNumber) != 18 {
  40496. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  40497. }
  40498. // 提取出生日期
  40499. year, err := strconv.Atoi(idNumber[6:10])
  40500. if err != nil {
  40501. return "", 0, err
  40502. }
  40503. month, err := strconv.Atoi(idNumber[10:12])
  40504. if err != nil {
  40505. return "", 0, err
  40506. }
  40507. day, err := strconv.Atoi(idNumber[12:14])
  40508. if err != nil {
  40509. return "", 0, err
  40510. }
  40511. // 格式化生日字符串
  40512. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  40513. birthdateFormatted := birthdate.Format("2006-01-02")
  40514. // 计算年龄
  40515. today := time.Now()
  40516. age := today.Year() - birthdate.Year()
  40517. if today.YearDay() < birthdate.YearDay() {
  40518. age--
  40519. }
  40520. return birthdateFormatted, age, nil
  40521. }
  40522. // 从身份证号码中提取出生年月日
  40523. func getBirthDateFromIDCard(idCard string) (string, error) {
  40524. // 身份证号码长度应为18位
  40525. if len(idCard) != 18 {
  40526. return "", fmt.Errorf("身份证号码长度应为18位")
  40527. }
  40528. // 提取出生日期部分 (YYYYMMDD)
  40529. birthDateStr := idCard[6:14]
  40530. // 解析出生日期
  40531. birthDate, err := time.Parse("20060102", birthDateStr)
  40532. if err != nil {
  40533. return "", fmt.Errorf("解析出生日期失败: %v", err)
  40534. }
  40535. // 格式化出生日期为 YYYY-MM-DD
  40536. formattedDate := birthDate.Format("2006-01-02")
  40537. return formattedDate, nil
  40538. }