his_api_controller.go 1.6MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896
  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. timeLayout := "2006-01-02"
  7439. loc, _ := time.LoadLocation("Local")
  7440. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7441. if err != nil {
  7442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7443. return
  7444. }
  7445. recordDateTime := theTime.Unix()
  7446. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7447. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7448. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7449. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7450. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7451. for _, item := range prescriptions {
  7452. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7453. if his.IdCardType == 1 {
  7454. bas := strings.Split(psn.CardInfo, "|")
  7455. basNumber := bas[1]
  7456. fmt.Println(basNumber)
  7457. card_sn := bas[3]
  7458. card_no := bas[2]
  7459. cFYLJG001.MdtrtCertType = "03"
  7460. cFYLJG001.CardSn = card_sn
  7461. cFYLJG001.MdtrtCertNo = card_no
  7462. cFYLJG001.EcToken = ""
  7463. cFYLJG001.AuthNo = ""
  7464. } else if his.IdCardType == 2 {
  7465. cFYLJG001.MdtrtCertType = "02"
  7466. cFYLJG001.CardSn = ""
  7467. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7468. cFYLJG001.EcToken = ""
  7469. cFYLJG001.AuthNo = ""
  7470. } else if his.IdCardType == 4 {
  7471. cFYLJG001.MdtrtCertType = "01"
  7472. cFYLJG001.CardSn = ""
  7473. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7474. cFYLJG001.EcToken = psn.VerifyNumber
  7475. cFYLJG001.AuthNo = ""
  7476. }
  7477. cFYLJG001.BizTypeCode = "01"
  7478. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7479. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7480. cFYLJG001.RxTypeCode = "1"
  7481. tempTime := time.Unix(item.PreTime, 0)
  7482. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7483. cFYLJG001.PrscTime = timeFormatOne
  7484. var count float64
  7485. if item.Type == 1 {
  7486. for _, sumItem := range item.HisDoctorAdviceInfo {
  7487. count = count + sumItem.PrescribingNumber
  7488. }
  7489. }
  7490. cFYLJG001.RxDrugCnt = count
  7491. cFYLJG001.ValiDays = "5"
  7492. ts := time.Unix(item.PreTime, 0)
  7493. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7494. tempTime3 := time.Unix(record_time2, 0)
  7495. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7496. cFYLJG001.ValiEndTime = timeFormat3
  7497. cFYLJG001.RxCotnFlag = "0"
  7498. for _, subItem := range item.HisDoctorAdviceInfo {
  7499. var drug models.RxDrug
  7500. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7501. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7502. drug.RxItemTypeCode = "11"
  7503. drug.DrugDosform = "乳膏剂" //TODO
  7504. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7505. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7506. }
  7507. drug.MedcWayDscr = subItem.DeliveryWay
  7508. tempTime2 := time.Unix(subItem.StartTime, 0)
  7509. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7510. drug.MedcBegntime = timeFormatTwo
  7511. if subItem.Day > 0 {
  7512. ts := time.Unix(subItem.StartTime, 0)
  7513. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7514. tempTime4 := time.Unix(record_time, 0)
  7515. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7516. drug.MedcEndtime = timeFormat5
  7517. } else {
  7518. tempTime2 := time.Unix(subItem.StartTime, 0)
  7519. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7520. drug.MedcEndtime = timeFormatTwo
  7521. }
  7522. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7523. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7524. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7525. drug.DrugCnt = subItem.PrescribingNumber
  7526. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7527. drug.DrugGenname = subItem.AdviceName
  7528. drug.MedcWayCodg = subItem.DeliveryWay
  7529. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7530. drug.SinDoscnt = subItem.SingleDose
  7531. drug.SinDosunt = subItem.SingleDoseUnit
  7532. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7533. drug.UsedFrquName = subItem.ExecutionFrequency
  7534. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7535. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7536. drug.HospApprFlag = "1"
  7537. cFYLJG001.List = append(cFYLJG001.List, drug)
  7538. }
  7539. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7540. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  7541. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7542. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7543. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7544. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7545. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7546. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7547. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7548. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7549. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7550. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7551. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7552. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7553. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7554. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7555. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7556. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7557. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7558. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7559. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7560. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7561. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7562. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7563. tempTime2 := time.Now().Unix()
  7564. tempTime6 := time.Unix(tempTime2, 0)
  7565. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7566. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7567. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7568. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7569. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7570. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7571. //memo := make(map[string]interface{})
  7572. //inputData := make(map[string]interface{}, 0)
  7573. //type MyData struct {
  7574. // Insutype string `json:"insutype"`
  7575. //}
  7576. //
  7577. // data := MyData{
  7578. // Insutype: his.Insutype,
  7579. //}
  7580. //
  7581. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7582. var config []*models.HisXtDiagnoseConfig
  7583. for _, item := range diagnosis_ids {
  7584. id, _ := strconv.ParseInt(item, 10, 64)
  7585. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7586. config = append(config, &diagnosisConfig)
  7587. }
  7588. for index, subitem := range config {
  7589. if index == 0 {
  7590. var dia models.DiseInfo
  7591. dia.DiagType = "1"
  7592. dia.MaindiagFlag = "1"
  7593. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7594. dia.DiagCode = subitem.CountryCode
  7595. dia.DiagName = subitem.ClassName
  7596. dia.DiagDept = "肾内科"
  7597. dia.DiagDrNo = doctor.DoctorNumber
  7598. dia.DiagDrName = doctor.UserName
  7599. tempTime3 := time.Unix(item.PreTime, 0)
  7600. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7601. dia.DiagTime = timeFormatTwo
  7602. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7603. } else {
  7604. var dia models.DiseInfo
  7605. dia.DiagType = "1"
  7606. dia.MaindiagFlag = "0"
  7607. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7608. dia.DiagCode = subitem.CountryCode
  7609. dia.DiagName = subitem.ClassName
  7610. dia.DiagDept = "肾内科"
  7611. dia.DiagDrNo = doctor.DoctorNumber
  7612. dia.DiagDrName = doctor.UserName
  7613. tempTime3 := time.Unix(item.PreTime, 0)
  7614. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7615. dia.DiagTime = timeFormatTwo
  7616. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7617. }
  7618. }
  7619. if miConfig.MdtrtareaAdmvs == "340699" {
  7620. //result, request := service.GetAHCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7621. //saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7622. } else {
  7623. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7624. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7625. var res ResultCFYLJG001
  7626. var respJSON2 map[string]interface{}
  7627. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7630. return
  7631. }
  7632. userJSONBytes2, _ := json.Marshal(respJSON2)
  7633. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7634. utils.ErrorLog("解析失败:%v", err)
  7635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7636. return
  7637. }
  7638. if res.Infcode == -1 {
  7639. c.ServeSuccessJSON(map[string]interface{}{
  7640. "failed_code": -10,
  7641. "msg": res.ErrMsg,
  7642. })
  7643. return
  7644. } else {
  7645. var flow models.HisPrescriptionFlow
  7646. flow.Ctime = time.Now().Unix()
  7647. flow.SignDigest = ""
  7648. flow.RxTraceCode = res.Output.RxTraceCode
  7649. flow.HiRxno = res.Output.HiRxno
  7650. flow.MID = his.Number
  7651. flow.Status = 1
  7652. flow.DCode = doctor_info.DoctorNumber
  7653. flow.OriginalRxFile = ""
  7654. flow.OriginalValue = ""
  7655. flow.SignCertDn = ""
  7656. flow.UserOrgId = 10454
  7657. flow.SignCertSn = ""
  7658. flow.Mtime = time.Now().Unix()
  7659. service.Createflow(&flow)
  7660. c.ServeSuccessJSON(map[string]interface{}{
  7661. "msg": "上传成功",
  7662. })
  7663. }
  7664. }
  7665. }
  7666. }
  7667. func (c *HisApiController) GetCFYLJG002() {
  7668. admin_user_id, _ := c.GetInt64("admin_user_id")
  7669. his_patient_id, _ := c.GetInt64("his_patient_id")
  7670. record_time := c.GetString("record_time")
  7671. admin_user_id = 3626
  7672. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7673. //id, _ := c.GetInt64("id")
  7674. admin_user_id = 3626
  7675. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7676. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7677. flow, _ := service.Getflowtwo(his.Number)
  7678. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7679. //record_time := c.GetString("record_time")
  7680. patient_id, _ := c.GetInt64("patient_id")
  7681. //patient_id = 23834
  7682. //record_time = "2023-09-18"
  7683. timeLayout := "2006-01-02"
  7684. loc, _ := time.LoadLocation("Local")
  7685. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7686. if err != nil {
  7687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7688. return
  7689. }
  7690. recordDateTime := theTime.Unix()
  7691. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7692. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7693. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7694. dept, _ := service.GetDepartMentDetail(info.Departments)
  7695. inputData := make(map[string]interface{})
  7696. inputData["rxTraceCode"] = flow.RxTraceCode
  7697. inputData["hiRxno"] = flow.HiRxno
  7698. inputData["mdtrtId"] = flow.MID
  7699. inputData["patnName"] = his.PsnName
  7700. inputData["psnCertType"] = his.PsnCertType
  7701. inputData["certno"] = his.Certno
  7702. inputData["fixmedinsName"] = miConfig.OrgName
  7703. inputData["fixmedinsCode"] = miConfig.Code
  7704. inputData["drCode"] = doctor_info.DoctorNumber
  7705. inputData["prscDrName"] = doctor_info.UserName
  7706. inputData["pharDeptName"] = dept.Name
  7707. inputData["pharDeptCode"] = dept.Number
  7708. inputData["pharProfttlCodg"] = dept.Name
  7709. inputData["pharProfttlName"] = ""
  7710. inputData["pharCode"] = "HY440309002107"
  7711. inputData["pharCertType"] = "01"
  7712. inputData["pharCertno"] = "430482199408260023"
  7713. inputData["pharName"] = "彭斯遥"
  7714. inputData["pharPracCertNo"] = ""
  7715. tempTime2 := time.Unix(info.Ctime, 0)
  7716. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7717. inputData["pharChkTime"] = timeFormatTwo
  7718. bytesData, _ := json.Marshal(inputData)
  7719. fmt.Println(string(bytesData))
  7720. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7721. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7722. if err != nil {
  7723. fmt.Println("Error reading PDF file:", err)
  7724. return
  7725. }
  7726. // 将 PDF 文件内容进行 Base64 编码
  7727. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7728. fmt.Println(err)
  7729. if miConfig.MdtrtareaAdmvs == "340699" {
  7730. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7731. //saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7732. } else {
  7733. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7734. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7735. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7736. var res2 Result002
  7737. var respJSON2 map[string]interface{}
  7738. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7741. return
  7742. }
  7743. userJSONBytes2, _ := json.Marshal(respJSON2)
  7744. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7745. utils.ErrorLog("解析失败:%v", err)
  7746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7747. return
  7748. }
  7749. if res2.Infcode == 0 {
  7750. flow.Ctime = time.Now().Unix()
  7751. flow.SignDigest = res2.Output.SignDigest
  7752. flow.RxFile = res2.Output.RxFile
  7753. flow.MID = his.Number
  7754. flow.Status = 1
  7755. flow.DCode = doctor_info.DoctorNumber
  7756. flow.OriginalRxFile = rx_encoded
  7757. flow.OriginalValue = encoded
  7758. flow.SignCertDn = res2.Output.SignCertDn
  7759. flow.SignCertSn = res2.Output.SignCertSn
  7760. flow.Mtime = time.Now().Unix()
  7761. service.Saveflow(flow)
  7762. c.ServeSuccessJSON(map[string]interface{}{
  7763. "msg": "预签名成功",
  7764. })
  7765. } else {
  7766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7767. return
  7768. }
  7769. }
  7770. }
  7771. func (c *HisApiController) GetCFYLJG003() {
  7772. admin_user_id, _ := c.GetInt64("admin_user_id")
  7773. his_patient_id, _ := c.GetInt64("his_patient_id")
  7774. record_time := c.GetString("record_time")
  7775. admin_user_id = 3626
  7776. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7777. //id, _ := c.GetInt64("id")
  7778. admin_user_id = 3626
  7779. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7780. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7781. flow, _ := service.Getflowtwo(his.Number)
  7782. //id = 3
  7783. patient_id, _ := c.GetInt64("patient_id")
  7784. //patient_id = 23834
  7785. //record_time = "2023-09-18"
  7786. timeLayout := "2006-01-02"
  7787. loc, _ := time.LoadLocation("Local")
  7788. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7789. if err != nil {
  7790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7791. return
  7792. }
  7793. recordDateTime := theTime.Unix()
  7794. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7795. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7796. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7797. dept, _ := service.GetDepartMentDetail(info.Departments)
  7798. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7799. var cFYLJG003 models.CFYLJG003
  7800. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7801. cFYLJG003.HiRxno = flow.HiRxno
  7802. cFYLJG003.MdtrtID = flow.MID
  7803. cFYLJG003.PatnName = his.Name
  7804. cFYLJG003.Certno = his.Certno
  7805. cFYLJG003.FixmedinsName = miConfig.OrgName
  7806. cFYLJG003.FixmedinsCode = miConfig.Code
  7807. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7808. cFYLJG003.PrscDrName = doctor_info.UserName
  7809. cFYLJG003.PharDeptName = dept.Name
  7810. cFYLJG003.PharDeptCode = dept.Number
  7811. cFYLJG003.PharCode = "HY440309002107"
  7812. cFYLJG003.PharCertType = "01"
  7813. cFYLJG003.PharCertno = "430482199408260023"
  7814. cFYLJG003.PharName = "彭斯遥"
  7815. cFYLJG003.PsnCertType = "01"
  7816. cFYLJG003.RxFile = flow.RxFile
  7817. cFYLJG003.SignDigest = flow.SignDigest
  7818. cFYLJG003.FixmedinsCode = miConfig.Code
  7819. cFYLJG003.PsnCertType = "01"
  7820. cFYLJG003.PharProfttlCodg = dept.Name
  7821. //inputData["pharProfttlCodg"] =dept.Name
  7822. tempTime2 := time.Unix(info.Ctime, 0)
  7823. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7824. cFYLJG003.PharChkTime = timeFormatTwo
  7825. if miConfig.MdtrtareaAdmvs == "340699" {
  7826. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7827. //result, request := service.GetAHCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7828. //saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  7829. } else {
  7830. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7831. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7832. var res ResultCFYLJG003
  7833. var respJSON2 map[string]interface{}
  7834. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7837. return
  7838. }
  7839. userJSONBytes2, _ := json.Marshal(respJSON2)
  7840. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7841. utils.ErrorLog("解析失败:%v", err)
  7842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7843. return
  7844. }
  7845. if res.Infcode == -1 {
  7846. c.ServeSuccessJSON(map[string]interface{}{
  7847. "failed_code": -10,
  7848. "msg": res.ErrMsg,
  7849. })
  7850. return
  7851. } else {
  7852. c.ServeSuccessJSON(map[string]interface{}{
  7853. "info": res.Output,
  7854. })
  7855. }
  7856. }
  7857. }
  7858. func (c *HisApiController) GetCFYLJG004() {
  7859. admin_user_id, _ := c.GetInt64("admin_user_id")
  7860. his_patient_id, _ := c.GetInt64("his_patient_id")
  7861. record_time := c.GetString("record_time")
  7862. admin_user_id = 3626
  7863. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7864. //id, _ := c.GetInt64("id")
  7865. admin_user_id = 3626
  7866. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7867. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7868. flow, _ := service.Getflowtwo(his.Number)
  7869. //id = 3
  7870. patient_id, _ := c.GetInt64("patient_id")
  7871. //patient_id = 23834
  7872. //record_time = "2023-09-18"
  7873. timeLayout := "2006-01-02"
  7874. loc, _ := time.LoadLocation("Local")
  7875. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7876. if err != nil {
  7877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7878. return
  7879. }
  7880. recordDateTime := theTime.Unix()
  7881. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7882. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7883. var cFYLJG004 models.CFYLJG004
  7884. cFYLJG004.HiRxno = flow.HiRxno
  7885. cFYLJG004.FixmedinsCode = miConfig.Code
  7886. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7887. cFYLJG004.UndoDrCertType = "01"
  7888. cFYLJG004.UndoRea = "撤销处方"
  7889. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7890. cFYLJG004.UndoDrName = doctor_info.UserName
  7891. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7892. if miConfig.MdtrtareaAdmvs == "340699" {
  7893. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7894. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7895. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  7896. } else {
  7897. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7898. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7899. var res ResultCFYLJG004
  7900. var respJSON2 map[string]interface{}
  7901. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7904. return
  7905. }
  7906. userJSONBytes2, _ := json.Marshal(respJSON2)
  7907. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7908. utils.ErrorLog("解析失败:%v", err)
  7909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7910. return
  7911. }
  7912. if res.Infcode == -1 {
  7913. c.ServeSuccessJSON(map[string]interface{}{
  7914. "failed_code": -10,
  7915. "msg": res.ErrMsg,
  7916. })
  7917. return
  7918. } else {
  7919. flow.Status = 0
  7920. service.Saveflow(flow)
  7921. c.ServeSuccessJSON(map[string]interface{}{
  7922. "msg": "撤销成功",
  7923. })
  7924. return
  7925. }
  7926. }
  7927. }
  7928. func (c *HisApiController) GetCFYLJG005() {
  7929. admin_user_id, _ := c.GetInt64("admin_user_id")
  7930. his_patient_id, _ := c.GetInt64("his_patient_id")
  7931. //record_time := c.GetString("record_time")
  7932. admin_user_id = 3626
  7933. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7934. //id, _ := c.GetInt64("id")
  7935. admin_user_id = 3626
  7936. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7937. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7938. flow, _ := service.Getflowtwo(his.Number)
  7939. //id = 3
  7940. var cFYLJG005 models.CFYLJG005
  7941. //patient_id, _ := c.GetInt64("patient_id")
  7942. cFYLJG005.HiRxno = flow.HiRxno
  7943. cFYLJG005.MdtrtID = flow.MID
  7944. cFYLJG005.EcToken = ""
  7945. cFYLJG005.PsnName = his.Name
  7946. cFYLJG005.PsnCertType = "01"
  7947. cFYLJG005.Certno = his.IdCardNo
  7948. if miConfig.MdtrtareaAdmvs == "340699" {
  7949. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7950. //result, request := service.GetAHCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7951. //saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7952. } else {
  7953. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7954. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7955. var res ResultCFYLJG005
  7956. var respJSON2 map[string]interface{}
  7957. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7960. return
  7961. }
  7962. userJSONBytes2, _ := json.Marshal(respJSON2)
  7963. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7964. utils.ErrorLog("解析失败:%v", err)
  7965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7966. return
  7967. }
  7968. if res.Infcode == -1 {
  7969. c.ServeSuccessJSON(map[string]interface{}{
  7970. "failed_code": -10,
  7971. "msg": res.ErrMsg,
  7972. })
  7973. return
  7974. } else {
  7975. c.ServeSuccessJSON(map[string]interface{}{
  7976. "info": res.Output,
  7977. })
  7978. return
  7979. }
  7980. }
  7981. }
  7982. func (c *HisApiController) GetCFYLJG006() {
  7983. admin_user_id, _ := c.GetInt64("admin_user_id")
  7984. his_patient_id, _ := c.GetInt64("his_patient_id")
  7985. admin_user_id = 3626
  7986. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7987. //id, _ := c.GetInt64("id")
  7988. admin_user_id = 3626
  7989. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7990. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7991. flow, _ := service.Getflowtwo(his.Number)
  7992. //id = 3
  7993. patient_id, _ := c.GetInt64("patient_id")
  7994. var cFYLJG006 models.CFYLJG006
  7995. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7996. cFYLJG006.HiRxno = flow.HiRxno
  7997. cFYLJG006.MdtrtID = flow.MID
  7998. cFYLJG006.PsnName = patient.Name
  7999. cFYLJG006.PsnCertType = "01"
  8000. cFYLJG006.Certno = patient.IdCardNo
  8001. if miConfig.MdtrtareaAdmvs == "340699" {
  8002. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8003. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8004. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8005. } else {
  8006. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8007. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8008. var res ResultCFYLJG006
  8009. var respJSON2 map[string]interface{}
  8010. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8013. return
  8014. }
  8015. userJSONBytes2, _ := json.Marshal(respJSON2)
  8016. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8017. utils.ErrorLog("解析失败:%v", err)
  8018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8019. return
  8020. }
  8021. if res.Infcode == -1 {
  8022. c.ServeSuccessJSON(map[string]interface{}{
  8023. "failed_code": -10,
  8024. "msg": res.ErrMsg,
  8025. })
  8026. return
  8027. } else {
  8028. c.ServeSuccessJSON(map[string]interface{}{
  8029. "info": res.Output,
  8030. })
  8031. return
  8032. }
  8033. }
  8034. }
  8035. func (c *HisApiController) GetCFYLJG007() {
  8036. admin_user_id, _ := c.GetInt64("admin_user_id")
  8037. his_patient_id, _ := c.GetInt64("his_patient_id")
  8038. admin_user_id = 3626
  8039. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8040. //id, _ := c.GetInt64("id")
  8041. admin_user_id = 3626
  8042. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8043. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8044. flow, _ := service.Getflowtwo(his.Number)
  8045. //id = 3
  8046. patient_id, _ := c.GetInt64("patient_id")
  8047. var cFYLJG007 models.CFYLJG007
  8048. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8049. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8050. cFYLJG007.HiRxno = flow.HiRxno
  8051. cFYLJG007.MdtrtID = flow.MID
  8052. cFYLJG007.PsnNo = his.PsnNo
  8053. cFYLJG007.PsnCertType = "01"
  8054. cFYLJG007.Certno = patient.IdCardNo
  8055. cFYLJG007.PsnName = patient.Name
  8056. if miConfig.MdtrtareaAdmvs == "340699" {
  8057. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8058. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8059. } else {
  8060. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8061. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8062. var res ResultCFYLJG007
  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,
  8084. })
  8085. return
  8086. }
  8087. }
  8088. }
  8089. func (c *HisApiController) GetCFYLJG008() {
  8090. admin_user_id, _ := c.GetInt64("admin_user_id")
  8091. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8092. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8093. var cFYLJG008 models.CFYLJG008
  8094. //id, _ := c.GetInt64("id")
  8095. patient_id, _ := c.GetInt64("patient_id")
  8096. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8097. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8098. //id = 3
  8099. //flow, _ := service.Getflow(id)
  8100. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8101. //
  8102. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8103. //patient_id, _ := c.GetInt64("patient_id")
  8104. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8105. record_time := c.GetString("record_time")
  8106. admin_user_id = 3626
  8107. patient_id = 19424
  8108. //his_patient_id = 263947
  8109. record_time = "2023-08-29"
  8110. timeLayout := "2006-01-02"
  8111. loc, _ := time.LoadLocation("Local")
  8112. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8113. if err != nil {
  8114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8115. return
  8116. }
  8117. recordDateTime := theTime.Unix()
  8118. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8119. cFYLJG008.FixmedinsName = ""
  8120. cFYLJG008.Lat = ""
  8121. cFYLJG008.Lng = ""
  8122. cFYLJG008.OrderType = "1"
  8123. cFYLJG008.PoolareaNo = ""
  8124. cFYLJG008.Lng = ""
  8125. cFYLJG008.PageNum = 1
  8126. cFYLJG008.PageSize = 10
  8127. var MPI models.MedinsProdInvChgDDTO
  8128. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8129. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8130. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8131. if miConfig.MdtrtareaAdmvs == "340699" {
  8132. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8133. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8134. } else {
  8135. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8136. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8137. var res ResultCFYLJG008
  8138. var respJSON2 map[string]interface{}
  8139. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8142. return
  8143. }
  8144. userJSONBytes2, _ := json.Marshal(respJSON2)
  8145. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8146. utils.ErrorLog("解析失败:%v", err)
  8147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8148. return
  8149. }
  8150. if res.Infcode == -1 {
  8151. c.ServeSuccessJSON(map[string]interface{}{
  8152. "failed_code": -10,
  8153. "msg": res.ErrMsg,
  8154. })
  8155. return
  8156. } else {
  8157. c.ServeSuccessJSON(map[string]interface{}{
  8158. "info": res.Output,
  8159. })
  8160. return
  8161. }
  8162. }
  8163. }
  8164. func (c *HisApiController) GetBL4201A() {
  8165. order_id, _ := c.GetInt64("order_id")
  8166. admin_user_id, _ := c.GetInt64("admin_user_id")
  8167. order, _ := service.GetHisOrderByIDTwo(order_id)
  8168. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8169. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8170. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8171. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8172. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8173. department, _ := service.GetDepartMentDetail(his.Departments)
  8174. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8175. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8176. if order.ID == 0 {
  8177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8178. return
  8179. }
  8180. var struct4201A models.Struct4201A
  8181. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8182. for _, items := range order_info {
  8183. memo := make(map[string]interface{})
  8184. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8185. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8186. fsiOPFLD.MedType = "14"
  8187. fsiOPFLD.BkkpSn = items.FeedetlSn
  8188. fsiOPFLD.FixmedinsCode = miConfig.Code
  8189. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8190. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8191. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8192. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8193. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8194. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8195. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8196. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8197. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8198. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8199. fsiOPFLD.BilgDeptName = department.Name
  8200. fsiOPFLD.BilgDeptCodg = department.Number
  8201. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8202. fsiOPFLD.BilgDrName = doctor.UserName
  8203. fsiOPFLD.MedChrgitmType = "09"
  8204. memo["hosp_appr_flag"] = "1"
  8205. memo["invoice_no"] = order.MdtrtId
  8206. memo["memo"] = "自费"
  8207. bytesData, _ := json.Marshal(memo)
  8208. fsiOPFLD.Memo = string(bytesData)
  8209. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8210. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8211. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8212. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8213. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8214. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8215. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8216. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8217. fsiOPFLD.BilgDeptName = department.Name
  8218. fsiOPFLD.BilgDeptCodg = department.Number
  8219. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8220. fsiOPFLD.BilgDrName = doctor.UserName
  8221. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8222. case 0:
  8223. break
  8224. case 1:
  8225. fsiOPFLD.MedChrgitmType = "14"
  8226. break
  8227. case 2:
  8228. fsiOPFLD.MedChrgitmType = "05"
  8229. break
  8230. case 3:
  8231. fsiOPFLD.MedChrgitmType = "03"
  8232. break
  8233. case 4:
  8234. fsiOPFLD.MedChrgitmType = "03"
  8235. break
  8236. case 5:
  8237. fsiOPFLD.MedChrgitmType = "08"
  8238. break
  8239. case 6:
  8240. fsiOPFLD.MedChrgitmType = "14"
  8241. break
  8242. case 7:
  8243. fsiOPFLD.MedChrgitmType = "14"
  8244. break
  8245. case 8:
  8246. fsiOPFLD.MedChrgitmType = "03"
  8247. break
  8248. case 9:
  8249. fsiOPFLD.MedChrgitmType = "14"
  8250. break
  8251. case 10:
  8252. fsiOPFLD.MedChrgitmType = "14"
  8253. break
  8254. case 11:
  8255. fsiOPFLD.MedChrgitmType = "06"
  8256. break
  8257. case 12:
  8258. fsiOPFLD.MedChrgitmType = "12"
  8259. break
  8260. case 13:
  8261. fsiOPFLD.MedChrgitmType = "01"
  8262. break
  8263. case 14:
  8264. fsiOPFLD.MedChrgitmType = "04"
  8265. break
  8266. case 15:
  8267. fsiOPFLD.MedChrgitmType = "14"
  8268. break
  8269. }
  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.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8277. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8278. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8279. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8280. fsiOPFLD.BilgDeptName = department.Name
  8281. fsiOPFLD.BilgDeptCodg = department.Number
  8282. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8283. fsiOPFLD.BilgDrName = doctor.UserName
  8284. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8285. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8286. fsiOPFLD.MedChrgitmType = "08"
  8287. memo["hosp_appr_flag"] = "1"
  8288. memo["invoice_no"] = order.MdtrtId
  8289. memo["memo"] = "自费"
  8290. bytesData, _ := json.Marshal(memo)
  8291. fsiOPFLD.Memo = string(bytesData)
  8292. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8293. }
  8294. }
  8295. }
  8296. for _, items := range order_info_two {
  8297. memo := make(map[string]interface{})
  8298. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8299. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8300. fsiOPFLD.MedType = "14"
  8301. fsiOPFLD.BkkpSn = items.FeedetlSn
  8302. fsiOPFLD.FixmedinsCode = miConfig.Code
  8303. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8304. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8305. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8306. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8307. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8308. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8309. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8310. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8311. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8312. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8313. fsiOPFLD.BilgDeptName = department.Name
  8314. fsiOPFLD.BilgDeptCodg = department.Number
  8315. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8316. fsiOPFLD.BilgDrName = doctor.UserName
  8317. fsiOPFLD.MedChrgitmType = "09"
  8318. memo["hosp_appr_flag"] = "1"
  8319. memo["invoice_no"] = order.MdtrtId
  8320. memo["memo"] = "自费"
  8321. bytesData, _ := json.Marshal(memo)
  8322. fsiOPFLD.Memo = string(bytesData)
  8323. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8324. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8325. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8326. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8327. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8328. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8329. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8330. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8331. fsiOPFLD.BilgDeptName = department.Name
  8332. fsiOPFLD.BilgDeptCodg = department.Number
  8333. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8334. fsiOPFLD.BilgDrName = doctor.UserName
  8335. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8336. case 0:
  8337. break
  8338. case 1:
  8339. fsiOPFLD.MedChrgitmType = "14"
  8340. break
  8341. case 2:
  8342. fsiOPFLD.MedChrgitmType = "05"
  8343. break
  8344. case 3:
  8345. fsiOPFLD.MedChrgitmType = "03"
  8346. break
  8347. case 4:
  8348. fsiOPFLD.MedChrgitmType = "03"
  8349. break
  8350. case 5:
  8351. fsiOPFLD.MedChrgitmType = "08"
  8352. break
  8353. case 6:
  8354. fsiOPFLD.MedChrgitmType = "14"
  8355. break
  8356. case 7:
  8357. fsiOPFLD.MedChrgitmType = "14"
  8358. break
  8359. case 8:
  8360. fsiOPFLD.MedChrgitmType = "03"
  8361. break
  8362. case 9:
  8363. fsiOPFLD.MedChrgitmType = "14"
  8364. break
  8365. case 10:
  8366. fsiOPFLD.MedChrgitmType = "14"
  8367. break
  8368. case 11:
  8369. fsiOPFLD.MedChrgitmType = "06"
  8370. break
  8371. case 12:
  8372. fsiOPFLD.MedChrgitmType = "12"
  8373. break
  8374. case 13:
  8375. fsiOPFLD.MedChrgitmType = "01"
  8376. break
  8377. case 14:
  8378. fsiOPFLD.MedChrgitmType = "04"
  8379. break
  8380. case 15:
  8381. fsiOPFLD.MedChrgitmType = "14"
  8382. break
  8383. }
  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.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8391. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8392. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8393. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8394. fsiOPFLD.BilgDeptName = department.Name
  8395. fsiOPFLD.BilgDeptCodg = department.Number
  8396. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8397. fsiOPFLD.BilgDrName = doctor.UserName
  8398. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8399. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8400. fsiOPFLD.MedChrgitmType = "08"
  8401. memo["hosp_appr_flag"] = "1"
  8402. memo["invoice_no"] = order.MdtrtId
  8403. memo["memo"] = "自费"
  8404. bytesData, _ := json.Marshal(memo)
  8405. fsiOPFLD.Memo = string(bytesData)
  8406. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8407. }
  8408. }
  8409. }
  8410. fmt.Println(fsiOPFLDs)
  8411. struct4201A.Fopfd = fsiOPFLDs
  8412. fmt.Println(struct4201A.Fopfd)
  8413. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8414. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8415. var res2 ResultSix
  8416. var respJSON2 map[string]interface{}
  8417. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8420. return
  8421. }
  8422. userJSONBytes2, _ := json.Marshal(respJSON2)
  8423. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8424. utils.ErrorLog("解析失败:%v", err)
  8425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8426. return
  8427. }
  8428. if res2.Infcode != 0 {
  8429. c.ServeSuccessJSON(map[string]interface{}{
  8430. "failed_code": -10,
  8431. "msg": res2.ErrMsg,
  8432. })
  8433. return
  8434. } else {
  8435. order.IsUploadOrderInfo = 1
  8436. service.UpdateOrder(order)
  8437. c.ServeSuccessJSON(map[string]interface{}{
  8438. "msg": "上传成功",
  8439. })
  8440. }
  8441. }
  8442. func (c *HisApiController) Get3103() {
  8443. admin_user_id, _ := c.GetInt64("admin_user_id")
  8444. warm_type, _ := c.GetInt64("warm_type")
  8445. fk_state, _ := c.GetInt64("fk_state")
  8446. warm_ids := c.GetString("warm_ids")
  8447. desc := c.GetString("desc")
  8448. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8449. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8450. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  8451. saveLog(result, requestLog, "3103", "反馈")
  8452. var res2 ResultSix3103
  8453. var respJSON2 map[string]interface{}
  8454. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8457. return
  8458. }
  8459. userJSONBytes2, _ := json.Marshal(respJSON2)
  8460. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8461. utils.ErrorLog("解析失败:%v", err)
  8462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8463. return
  8464. }
  8465. if res2.Infcode != 0 {
  8466. c.ServeSuccessJSON(map[string]interface{}{
  8467. "failed_code": -10,
  8468. "msg": res2.ErrMsg,
  8469. })
  8470. return
  8471. } else {
  8472. c.ServeSuccessJSON(map[string]interface{}{
  8473. "msg": "反馈成功",
  8474. })
  8475. return
  8476. }
  8477. }
  8478. func (c *HisApiController) Get4201A() {
  8479. order_id, _ := c.GetInt64("order_id")
  8480. admin_user_id, _ := c.GetInt64("admin_user_id")
  8481. order, _ := service.GetHisOrderByIDTwo(order_id)
  8482. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8483. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8484. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8485. //order_info = append(order_info, order_info_two...)
  8486. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8487. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8488. department, _ := service.GetDepartMentDetail(his.Departments)
  8489. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8490. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8491. if order.ID == 0 {
  8492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8493. return
  8494. }
  8495. var struct4201A models.Struct4201A
  8496. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8497. for _, items := range order_info {
  8498. memo := make(map[string]interface{})
  8499. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8500. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8501. fsiOPFLD.MedType = "14"
  8502. fsiOPFLD.BkkpSn = items.FeedetlSn
  8503. fsiOPFLD.FixmedinsCode = miConfig.Code
  8504. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8505. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8506. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8507. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8508. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8509. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8510. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8511. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8512. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8513. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8514. fsiOPFLD.BilgDeptName = department.Name
  8515. fsiOPFLD.BilgDeptCodg = department.Number
  8516. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8517. fsiOPFLD.BilgDrName = doctor.UserName
  8518. fsiOPFLD.MedChrgitmType = "09"
  8519. memo["hosp_appr_flag"] = "1"
  8520. memo["invoice_no"] = order.MdtrtId
  8521. memo["memo"] = "自费"
  8522. bytesData, _ := json.Marshal(memo)
  8523. fsiOPFLD.Memo = string(bytesData)
  8524. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8525. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8526. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8527. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8528. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8529. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8530. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8531. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8532. fsiOPFLD.BilgDeptName = department.Name
  8533. fsiOPFLD.BilgDeptCodg = department.Number
  8534. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8535. fsiOPFLD.BilgDrName = doctor.UserName
  8536. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8537. case 0:
  8538. break
  8539. case 1:
  8540. fsiOPFLD.MedChrgitmType = "14"
  8541. break
  8542. case 2:
  8543. fsiOPFLD.MedChrgitmType = "05"
  8544. break
  8545. case 3:
  8546. fsiOPFLD.MedChrgitmType = "03"
  8547. break
  8548. case 4:
  8549. fsiOPFLD.MedChrgitmType = "03"
  8550. break
  8551. case 5:
  8552. fsiOPFLD.MedChrgitmType = "08"
  8553. break
  8554. case 6:
  8555. fsiOPFLD.MedChrgitmType = "14"
  8556. break
  8557. case 7:
  8558. fsiOPFLD.MedChrgitmType = "14"
  8559. break
  8560. case 8:
  8561. fsiOPFLD.MedChrgitmType = "03"
  8562. break
  8563. case 9:
  8564. fsiOPFLD.MedChrgitmType = "14"
  8565. break
  8566. case 10:
  8567. fsiOPFLD.MedChrgitmType = "14"
  8568. break
  8569. case 11:
  8570. fsiOPFLD.MedChrgitmType = "06"
  8571. break
  8572. case 12:
  8573. fsiOPFLD.MedChrgitmType = "12"
  8574. break
  8575. case 13:
  8576. fsiOPFLD.MedChrgitmType = "01"
  8577. break
  8578. case 14:
  8579. fsiOPFLD.MedChrgitmType = "04"
  8580. break
  8581. case 15:
  8582. fsiOPFLD.MedChrgitmType = "14"
  8583. break
  8584. }
  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.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8592. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8593. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8594. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8595. fsiOPFLD.BilgDeptName = department.Name
  8596. fsiOPFLD.BilgDeptCodg = department.Number
  8597. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8598. fsiOPFLD.BilgDrName = doctor.UserName
  8599. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8600. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8601. fsiOPFLD.MedChrgitmType = "08"
  8602. memo["hosp_appr_flag"] = "1"
  8603. memo["invoice_no"] = order.MdtrtId
  8604. memo["memo"] = "自费"
  8605. bytesData, _ := json.Marshal(memo)
  8606. fsiOPFLD.Memo = string(bytesData)
  8607. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8608. }
  8609. }
  8610. }
  8611. for _, items := range order_info_two {
  8612. memo := make(map[string]interface{})
  8613. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8614. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8615. fsiOPFLD.MedType = "14"
  8616. fsiOPFLD.BkkpSn = items.FeedetlSn
  8617. fsiOPFLD.FixmedinsCode = miConfig.Code
  8618. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8619. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8620. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8621. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8622. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8623. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8624. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8625. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8626. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8627. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8628. fsiOPFLD.BilgDeptName = department.Name
  8629. fsiOPFLD.BilgDeptCodg = department.Number
  8630. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8631. fsiOPFLD.BilgDrName = doctor.UserName
  8632. fsiOPFLD.MedChrgitmType = "09"
  8633. memo["hosp_appr_flag"] = "1"
  8634. memo["invoice_no"] = order.MdtrtId
  8635. memo["memo"] = "自费"
  8636. bytesData, _ := json.Marshal(memo)
  8637. fsiOPFLD.Memo = string(bytesData)
  8638. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8639. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8640. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8641. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8642. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8643. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8644. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8645. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8646. fsiOPFLD.BilgDeptName = department.Name
  8647. fsiOPFLD.BilgDeptCodg = department.Number
  8648. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8649. fsiOPFLD.BilgDrName = doctor.UserName
  8650. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8651. case 0:
  8652. break
  8653. case 1:
  8654. fsiOPFLD.MedChrgitmType = "14"
  8655. break
  8656. case 2:
  8657. fsiOPFLD.MedChrgitmType = "05"
  8658. break
  8659. case 3:
  8660. fsiOPFLD.MedChrgitmType = "03"
  8661. break
  8662. case 4:
  8663. fsiOPFLD.MedChrgitmType = "03"
  8664. break
  8665. case 5:
  8666. fsiOPFLD.MedChrgitmType = "08"
  8667. break
  8668. case 6:
  8669. fsiOPFLD.MedChrgitmType = "14"
  8670. break
  8671. case 7:
  8672. fsiOPFLD.MedChrgitmType = "14"
  8673. break
  8674. case 8:
  8675. fsiOPFLD.MedChrgitmType = "03"
  8676. break
  8677. case 9:
  8678. fsiOPFLD.MedChrgitmType = "14"
  8679. break
  8680. case 10:
  8681. fsiOPFLD.MedChrgitmType = "14"
  8682. break
  8683. case 11:
  8684. fsiOPFLD.MedChrgitmType = "06"
  8685. break
  8686. case 12:
  8687. fsiOPFLD.MedChrgitmType = "12"
  8688. break
  8689. case 13:
  8690. fsiOPFLD.MedChrgitmType = "01"
  8691. break
  8692. case 14:
  8693. fsiOPFLD.MedChrgitmType = "04"
  8694. break
  8695. case 15:
  8696. fsiOPFLD.MedChrgitmType = "14"
  8697. break
  8698. }
  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.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8706. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8707. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8708. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8709. fsiOPFLD.BilgDeptName = department.Name
  8710. fsiOPFLD.BilgDeptCodg = department.Number
  8711. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8712. fsiOPFLD.BilgDrName = doctor.UserName
  8713. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8714. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8715. fsiOPFLD.MedChrgitmType = "08"
  8716. memo["hosp_appr_flag"] = "1"
  8717. memo["invoice_no"] = order.MdtrtId
  8718. memo["memo"] = "自费"
  8719. bytesData, _ := json.Marshal(memo)
  8720. fsiOPFLD.Memo = string(bytesData)
  8721. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8722. }
  8723. }
  8724. }
  8725. fmt.Println(fsiOPFLDs)
  8726. struct4201A.Fopfd = fsiOPFLDs
  8727. fmt.Println(struct4201A.Fopfd)
  8728. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8729. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8730. var res2 ResultSix
  8731. var respJSON2 map[string]interface{}
  8732. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8735. return
  8736. }
  8737. userJSONBytes2, _ := json.Marshal(respJSON2)
  8738. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8739. utils.ErrorLog("解析失败:%v", err)
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8741. return
  8742. }
  8743. if res2.Infcode != 0 {
  8744. c.ServeSuccessJSON(map[string]interface{}{
  8745. "failed_code": -10,
  8746. "msg": res2.ErrMsg,
  8747. })
  8748. return
  8749. } else {
  8750. order.IsUploadOrderInfo = 1
  8751. service.UpdateOrder(order)
  8752. c.ServeSuccessJSON(map[string]interface{}{
  8753. "msg": "上传成功",
  8754. })
  8755. }
  8756. }
  8757. func (c *HisApiController) Get4202() {
  8758. order_id, _ := c.GetInt64("order_id")
  8759. admin_user_id, _ := c.GetInt64("admin_user_id")
  8760. order, _ := service.GetHisOrderByIDTwo(order_id)
  8761. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8762. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8763. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8764. if order.ID == 0 {
  8765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8766. return
  8767. }
  8768. var struct4202 models.Struct4202
  8769. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8770. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8771. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8772. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8773. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8774. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8775. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8776. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8777. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8778. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8779. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8780. var config []*models.HisXtDiagnoseConfig
  8781. for _, item := range diagnosis_ids {
  8782. id, _ := strconv.ParseInt(item, 10, 64)
  8783. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8784. config = append(config, &diagnosisConfig)
  8785. }
  8786. var tempDiaginfos []models.OwnPayPatnDiagListD
  8787. for index, item := range config {
  8788. if index == 0 {
  8789. var tempDiaginfo models.OwnPayPatnDiagListD
  8790. tempDiaginfo.InoutDiagType = "1"
  8791. tempDiaginfo.DiagCode = item.CountryCode
  8792. tempDiaginfo.DiagName = item.CountryContentName
  8793. tempDiaginfo.DiagType = "1"
  8794. tempDiaginfo.DiagSrtNo = "1"
  8795. tempDiaginfo.MaindiagFlag = "1"
  8796. tempDiaginfo.ValiFlag = "1"
  8797. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8798. } else {
  8799. var tempDiaginfo models.OwnPayPatnDiagListD
  8800. tempDiaginfo.DiagCode = item.CountryCode
  8801. tempDiaginfo.DiagName = item.CountryContentName
  8802. tempDiaginfo.DiagType = "2"
  8803. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8804. tempDiaginfo.MaindiagFlag = "0"
  8805. tempDiaginfo.ValiFlag = "1"
  8806. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8807. }
  8808. }
  8809. struct4202.ODiagListD = tempDiaginfos
  8810. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8811. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8812. var res2 ResultSix
  8813. var respJSON2 map[string]interface{}
  8814. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8817. return
  8818. }
  8819. userJSONBytes2, _ := json.Marshal(respJSON2)
  8820. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8821. utils.ErrorLog("解析失败:%v", err)
  8822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8823. return
  8824. }
  8825. if res2.Infcode != 0 {
  8826. c.ServeSuccessJSON(map[string]interface{}{
  8827. "failed_code": -10,
  8828. "msg": res2.ErrMsg,
  8829. })
  8830. return
  8831. } else {
  8832. order.IsUploadDiagnose = 1
  8833. service.UpdateOrder(order)
  8834. c.ServeSuccessJSON(map[string]interface{}{
  8835. "msg": "上传成功",
  8836. })
  8837. }
  8838. }
  8839. func (c *HisApiController) Get4203() {
  8840. admin_user_id, _ := c.GetInt64("admin_user_id")
  8841. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8842. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8843. order_id, _ := c.GetInt64("order_id")
  8844. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8845. number := ""
  8846. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8847. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8848. if his.ID == 0 {
  8849. number = hospital.Number
  8850. } else {
  8851. number = his.Number
  8852. }
  8853. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8854. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8855. var res2 ResultSix
  8856. var respJSON2 map[string]interface{}
  8857. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8860. return
  8861. }
  8862. userJSONBytes2, _ := json.Marshal(respJSON2)
  8863. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8864. utils.ErrorLog("解析失败:%v", err)
  8865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8866. return
  8867. }
  8868. if res2.Infcode != 0 {
  8869. c.ServeSuccessJSON(map[string]interface{}{
  8870. "failed_code": -10,
  8871. "msg": res2.ErrMsg,
  8872. })
  8873. return
  8874. } else {
  8875. order.IsUploadSuccess = 1
  8876. service.UpdateOrderTwo(order)
  8877. c.ServeSuccessJSON(map[string]interface{}{
  8878. "msg": "上传成功",
  8879. })
  8880. }
  8881. }
  8882. func (c *HisApiController) Get4205() {
  8883. order_id, _ := c.GetInt64("order_id")
  8884. admin_user_id, _ := c.GetInt64("admin_user_id")
  8885. fapiao_code := c.GetString("fapiao_code")
  8886. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8887. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8888. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8889. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8890. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8891. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8892. //order_info = append(order_info, order_info_two...)
  8893. department, _ := service.GetDepartMentDetail(his.Departments)
  8894. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8895. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8896. if order.ID == 0 {
  8897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8898. return
  8899. }
  8900. var struct4201A models.Struct4201A
  8901. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8902. for _, items := range order_info {
  8903. memo := make(map[string]interface{})
  8904. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8905. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8906. fsiOPFLD.MedType = pre.MedType
  8907. fsiOPFLD.FixmedinsCode = miConfig.Code
  8908. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8909. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8910. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8911. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8912. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8913. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8914. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8915. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8916. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8917. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8918. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8919. fsiOPFLD.BilgDeptName = department.Name
  8920. fsiOPFLD.BilgDeptCodg = department.Number
  8921. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8922. fsiOPFLD.BilgDrName = doctor.UserName
  8923. fsiOPFLD.MedChrgitmType = "09"
  8924. memo["hosp_appr_flag"] = "1"
  8925. memo["invoice_no"] = fapiao_code
  8926. memo["memo"] = "自费"
  8927. bytesData, _ := json.Marshal(memo)
  8928. fsiOPFLD.Memo = string(bytesData)
  8929. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8930. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8931. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8932. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8933. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8934. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8935. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8936. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8937. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8938. fsiOPFLD.BilgDeptName = department.Name
  8939. fsiOPFLD.BilgDeptCodg = department.Number
  8940. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8941. fsiOPFLD.BilgDrName = doctor.UserName
  8942. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8943. case 0:
  8944. break
  8945. case 1:
  8946. fsiOPFLD.MedChrgitmType = "14"
  8947. break
  8948. case 2:
  8949. fsiOPFLD.MedChrgitmType = "05"
  8950. break
  8951. case 3:
  8952. fsiOPFLD.MedChrgitmType = "03"
  8953. break
  8954. case 4:
  8955. fsiOPFLD.MedChrgitmType = "03"
  8956. break
  8957. case 5:
  8958. fsiOPFLD.MedChrgitmType = "08"
  8959. break
  8960. case 6:
  8961. fsiOPFLD.MedChrgitmType = "14"
  8962. break
  8963. case 7:
  8964. fsiOPFLD.MedChrgitmType = "14"
  8965. break
  8966. case 8:
  8967. fsiOPFLD.MedChrgitmType = "03"
  8968. break
  8969. case 9:
  8970. fsiOPFLD.MedChrgitmType = "14"
  8971. break
  8972. case 10:
  8973. fsiOPFLD.MedChrgitmType = "14"
  8974. break
  8975. case 11:
  8976. fsiOPFLD.MedChrgitmType = "06"
  8977. break
  8978. case 12:
  8979. fsiOPFLD.MedChrgitmType = "12"
  8980. break
  8981. case 13:
  8982. fsiOPFLD.MedChrgitmType = "01"
  8983. break
  8984. case 14:
  8985. fsiOPFLD.MedChrgitmType = "04"
  8986. break
  8987. case 15:
  8988. fsiOPFLD.MedChrgitmType = "14"
  8989. break
  8990. }
  8991. memo["hosp_appr_flag"] = "1"
  8992. memo["invoice_no"] = fapiao_code
  8993. memo["memo"] = "自费"
  8994. bytesData, _ := json.Marshal(memo)
  8995. fsiOPFLD.Memo = string(bytesData)
  8996. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8997. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8998. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8999. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9000. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9001. fsiOPFLD.BilgDeptName = department.Name
  9002. fsiOPFLD.BilgDeptCodg = department.Number
  9003. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9004. fsiOPFLD.BilgDrName = doctor.UserName
  9005. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9006. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9007. fsiOPFLD.MedChrgitmType = "08"
  9008. memo["hosp_appr_flag"] = "1"
  9009. memo["invoice_no"] = fapiao_code
  9010. memo["memo"] = "自费"
  9011. bytesData, _ := json.Marshal(memo)
  9012. fsiOPFLD.Memo = string(bytesData)
  9013. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9014. }
  9015. }
  9016. }
  9017. for _, items := range order_info_two {
  9018. memo := make(map[string]interface{})
  9019. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9020. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9021. fsiOPFLD.MedType = pre.MedType
  9022. fsiOPFLD.BkkpSn = items.FeedetlSn
  9023. fsiOPFLD.FixmedinsCode = miConfig.Code
  9024. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9025. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9026. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9027. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9028. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9029. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9030. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9031. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9032. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9033. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9034. fsiOPFLD.BilgDeptName = department.Name
  9035. fsiOPFLD.BilgDeptCodg = department.Number
  9036. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9037. fsiOPFLD.BilgDrName = doctor.UserName
  9038. fsiOPFLD.MedChrgitmType = "09"
  9039. memo["hosp_appr_flag"] = "1"
  9040. memo["invoice_no"] = fapiao_code
  9041. memo["memo"] = "自费"
  9042. bytesData, _ := json.Marshal(memo)
  9043. fsiOPFLD.Memo = string(bytesData)
  9044. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9045. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9046. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9047. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9048. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9049. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9050. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9051. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9052. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9053. fsiOPFLD.BilgDeptName = department.Name
  9054. fsiOPFLD.BilgDeptCodg = department.Number
  9055. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9056. fsiOPFLD.BilgDrName = doctor.UserName
  9057. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9058. case 0:
  9059. break
  9060. case 1:
  9061. fsiOPFLD.MedChrgitmType = "14"
  9062. break
  9063. case 2:
  9064. fsiOPFLD.MedChrgitmType = "05"
  9065. break
  9066. case 3:
  9067. fsiOPFLD.MedChrgitmType = "03"
  9068. break
  9069. case 4:
  9070. fsiOPFLD.MedChrgitmType = "03"
  9071. break
  9072. case 5:
  9073. fsiOPFLD.MedChrgitmType = "08"
  9074. break
  9075. case 6:
  9076. fsiOPFLD.MedChrgitmType = "14"
  9077. break
  9078. case 7:
  9079. fsiOPFLD.MedChrgitmType = "14"
  9080. break
  9081. case 8:
  9082. fsiOPFLD.MedChrgitmType = "03"
  9083. break
  9084. case 9:
  9085. fsiOPFLD.MedChrgitmType = "14"
  9086. break
  9087. case 10:
  9088. fsiOPFLD.MedChrgitmType = "14"
  9089. break
  9090. case 11:
  9091. fsiOPFLD.MedChrgitmType = "06"
  9092. break
  9093. case 12:
  9094. fsiOPFLD.MedChrgitmType = "12"
  9095. break
  9096. case 13:
  9097. fsiOPFLD.MedChrgitmType = "01"
  9098. break
  9099. case 14:
  9100. fsiOPFLD.MedChrgitmType = "04"
  9101. break
  9102. case 15:
  9103. fsiOPFLD.MedChrgitmType = "14"
  9104. break
  9105. }
  9106. memo["hosp_appr_flag"] = "1"
  9107. memo["invoice_no"] = fapiao_code
  9108. memo["memo"] = "自费"
  9109. bytesData, _ := json.Marshal(memo)
  9110. fsiOPFLD.Memo = string(bytesData)
  9111. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9112. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9113. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9114. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9115. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9116. fsiOPFLD.BilgDeptName = department.Name
  9117. fsiOPFLD.BilgDeptCodg = department.Number
  9118. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9119. fsiOPFLD.BilgDrName = doctor.UserName
  9120. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9121. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9122. fsiOPFLD.MedChrgitmType = "08"
  9123. memo["hosp_appr_flag"] = "1"
  9124. memo["invoice_no"] = fapiao_code
  9125. memo["memo"] = "自费"
  9126. bytesData, _ := json.Marshal(memo)
  9127. fsiOPFLD.Memo = string(bytesData)
  9128. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9129. }
  9130. }
  9131. }
  9132. fmt.Println(fsiOPFLDs)
  9133. struct4201A.Fopfd = fsiOPFLDs
  9134. fmt.Println(struct4201A.Fopfd)
  9135. var struct4202 models.Struct4202
  9136. timeLayout := "2006-01-02 15:04:05"
  9137. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9138. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9139. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9140. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9141. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9142. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9143. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9144. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9145. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9146. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9147. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9148. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9149. var config []*models.HisXtDiagnoseConfig
  9150. for _, item := range diagnosis_ids {
  9151. id, _ := strconv.ParseInt(item, 10, 64)
  9152. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9153. config = append(config, &diagnosisConfig)
  9154. }
  9155. var tempDiaginfos []models.OwnPayPatnDiagListD
  9156. for index, item := range config {
  9157. if index == 0 {
  9158. var tempDiaginfo models.OwnPayPatnDiagListD
  9159. tempDiaginfo.InoutDiagType = "1"
  9160. tempDiaginfo.DiagCode = item.CountryCode
  9161. tempDiaginfo.DiagName = item.CountryContentName
  9162. tempDiaginfo.DiagType = "1"
  9163. tempDiaginfo.DiagSrtNo = "1"
  9164. tempDiaginfo.MaindiagFlag = "1"
  9165. tempDiaginfo.ValiFlag = "1"
  9166. tempDiaginfo.DiagDrName = doctor.UserName
  9167. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9168. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9169. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9170. } else {
  9171. var tempDiaginfo models.OwnPayPatnDiagListD
  9172. tempDiaginfo.DiagCode = item.CountryCode
  9173. tempDiaginfo.DiagName = item.CountryContentName
  9174. tempDiaginfo.DiagType = "2"
  9175. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9176. tempDiaginfo.MaindiagFlag = "0"
  9177. tempDiaginfo.ValiFlag = "1"
  9178. tempDiaginfo.DiagDrName = doctor.UserName
  9179. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9180. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9181. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9182. }
  9183. }
  9184. struct4202.ODiagListD = tempDiaginfos
  9185. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9186. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9187. var res2 ResultSix
  9188. var respJSON2 map[string]interface{}
  9189. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9192. return
  9193. }
  9194. userJSONBytes2, _ := json.Marshal(respJSON2)
  9195. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9196. utils.ErrorLog("解析失败:%v", err)
  9197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9198. return
  9199. }
  9200. if res2.Infcode != 0 {
  9201. c.ServeSuccessJSON(map[string]interface{}{
  9202. "failed_code": -10,
  9203. "msg": res2.ErrMsg,
  9204. })
  9205. return
  9206. } else {
  9207. order.IsUploadDiagnose = 1
  9208. order.IsUploadOrderInfo = 1
  9209. service.UpdateOrderTwo(order)
  9210. c.ServeSuccessJSON(map[string]interface{}{
  9211. "msg": "上传成功",
  9212. })
  9213. }
  9214. }
  9215. func (c *HisApiController) Get4207() {
  9216. admin_user_id, _ := c.GetInt64("admin_user_id")
  9217. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9218. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9219. order_id, _ := c.GetInt64("order_id")
  9220. order, _ := service.GetHisOrderByIDTwo(order_id)
  9221. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9222. var struct4207 models.Struct4207
  9223. struct4207.PageNum = "1"
  9224. struct4207.PageSize = "1000"
  9225. struct4207.FixmedinsCode = miConfig.Code
  9226. struct4207.FixmedinsMdtrtID = order.Number
  9227. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9228. saveLog(result, requestLog, "4207", "查询")
  9229. var res2 ResultSix
  9230. var respJSON2 map[string]interface{}
  9231. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9234. return
  9235. }
  9236. userJSONBytes2, _ := json.Marshal(respJSON2)
  9237. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9238. utils.ErrorLog("解析失败:%v", err)
  9239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9240. return
  9241. }
  9242. if res2.Infcode != 0 {
  9243. c.ServeSuccessJSON(map[string]interface{}{
  9244. "failed_code": -10,
  9245. "msg": res2.ErrMsg,
  9246. })
  9247. return
  9248. } else {
  9249. c.ServeSuccessJSON(map[string]interface{}{
  9250. "msg": "查询成功",
  9251. })
  9252. }
  9253. }
  9254. func (c *HisApiController) Get4208() {
  9255. admin_user_id, _ := c.GetInt64("admin_user_id")
  9256. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9257. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9258. order_id, _ := c.GetInt64("order_id")
  9259. order, _ := service.GetHisOrderByIDTwo(order_id)
  9260. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9261. var struct4208 models.Struct4208
  9262. struct4208.PageNum = "1"
  9263. struct4208.PageSize = "1000"
  9264. struct4208.PsnCertType = "01"
  9265. struct4208.Certno = his.Certno
  9266. struct4208.MedType = order.MedType
  9267. struct4208.PsnName = his.Name
  9268. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9269. saveLog(result, requestLog, "4208", "查询")
  9270. var res2 ResultSix
  9271. var respJSON2 map[string]interface{}
  9272. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9275. return
  9276. }
  9277. userJSONBytes2, _ := json.Marshal(respJSON2)
  9278. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9279. utils.ErrorLog("解析失败:%v", err)
  9280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9281. return
  9282. }
  9283. if res2.Infcode != 0 {
  9284. c.ServeSuccessJSON(map[string]interface{}{
  9285. "failed_code": -10,
  9286. "msg": res2.ErrMsg,
  9287. })
  9288. return
  9289. } else {
  9290. c.ServeSuccessJSON(map[string]interface{}{
  9291. "msg": "查询成功",
  9292. })
  9293. }
  9294. }
  9295. func (c *HisApiController) Get4209() {
  9296. admin_user_id, _ := c.GetInt64("admin_user_id")
  9297. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9298. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9299. order_id, _ := c.GetInt64("order_id")
  9300. order, _ := service.GetHisOrderByIDTwo(order_id)
  9301. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9302. var struct4209 models.Struct4209
  9303. struct4209.FixmedinsMdtrtID = order.Number
  9304. struct4209.FixmedinsCode = miConfig.Code
  9305. struct4209.PageSize = "1000"
  9306. struct4209.PageNum = "1"
  9307. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9308. saveLog(result, requestLog, "4209", "查询")
  9309. var res2 ResultSix
  9310. var respJSON2 map[string]interface{}
  9311. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9314. return
  9315. }
  9316. userJSONBytes2, _ := json.Marshal(respJSON2)
  9317. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9318. utils.ErrorLog("解析失败:%v", err)
  9319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9320. return
  9321. }
  9322. if res2.Infcode != 0 {
  9323. c.ServeSuccessJSON(map[string]interface{}{
  9324. "failed_code": -10,
  9325. "msg": res2.ErrMsg,
  9326. })
  9327. return
  9328. } else {
  9329. c.ServeSuccessJSON(map[string]interface{}{
  9330. "msg": "查询成功",
  9331. })
  9332. }
  9333. }
  9334. type Result3101 struct {
  9335. Infcode string `json:"infcode"`
  9336. InfRefmsgid string `json:"inf_refmsgid"`
  9337. RefmsgTime string `json:"refmsg_time"`
  9338. RespondTime string `json:"respond_time"`
  9339. Enctype string `json:"enctype"`
  9340. Signtype string `json:"signtype"`
  9341. ErrMsg string `json:"err_msg"`
  9342. Output struct {
  9343. Result []struct {
  9344. JudgeResultDetailDtos []struct {
  9345. VolaItemType string `json:"vola_item_type"`
  9346. MdtrtID string `json:"mdtrt_id"`
  9347. JrdID string `json:"jrd_id"`
  9348. PatnID string `json:"patn_id"`
  9349. RxID string `json:"rx_id"`
  9350. VolaAmt interface{} `json:"vola_amt"`
  9351. } `json:"judge_result_detail_dtos"`
  9352. RuleID string `json:"rule_id"`
  9353. VolaEvid string `json:"vola_evid"`
  9354. MdtrtID string `json:"mdtrt_id"`
  9355. RuleName string `json:"rule_name"`
  9356. VolaAmtStas string `json:"vola_amt_stas"`
  9357. JrID string `json:"jr_id"`
  9358. PatnID string `json:"patn_id"`
  9359. SevDeg string `json:"sev_deg"`
  9360. VolaAmt float64 `json:"vola_amt"`
  9361. VolaBhvrType string `json:"vola_bhvr_type"`
  9362. VolaCont string `json:"vola_cont"`
  9363. } `json:"result"`
  9364. } `json:"output"`
  9365. }
  9366. type Resultgd3101 struct {
  9367. Infcode int64 `json:"infcode"`
  9368. InfRefmsgid string `json:"inf_refmsgid"`
  9369. RefmsgTime string `json:"refmsg_time"`
  9370. RespondTime string `json:"respond_time"`
  9371. Enctype string `json:"enctype"`
  9372. Signtype string `json:"signtype"`
  9373. ErrMsg string `json:"err_msg"`
  9374. Output struct {
  9375. Result []struct {
  9376. JudgeResultDetailDtos []struct {
  9377. VolaItemType string `json:"vola_item_type"`
  9378. MdtrtID string `json:"mdtrt_id"`
  9379. JrdID string `json:"jrd_id"`
  9380. PatnID string `json:"patn_id"`
  9381. RxID string `json:"rx_id"`
  9382. VolaAmt interface{} `json:"vola_amt"`
  9383. } `json:"judge_result_detail_dtos"`
  9384. RuleID string `json:"rule_id"`
  9385. VolaEvid string `json:"vola_evid"`
  9386. MdtrtID string `json:"mdtrt_id"`
  9387. RuleName string `json:"rule_name"`
  9388. VolaAmtStas string `json:"vola_amt_stas"`
  9389. JrID string `json:"jr_id"`
  9390. PatnID string `json:"patn_id"`
  9391. SevDeg string `json:"sev_deg"`
  9392. VolaAmt float64 `json:"vola_amt"`
  9393. VolaBhvrType string `json:"vola_bhvr_type"`
  9394. VolaCont string `json:"vola_cont"`
  9395. } `json:"result"`
  9396. } `json:"output"`
  9397. }
  9398. func (c *HisApiController) ReadEleToken() {
  9399. admin_user_id, _ := c.GetInt64("admin_user_id")
  9400. his_patient_id, _ := c.GetInt64("his_patient_id")
  9401. adminUser := c.GetAdminUserInfo()
  9402. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9403. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9404. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9405. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9406. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9407. if len(tokens) > 0 {
  9408. c.ServeSuccessJSON(map[string]interface{}{
  9409. "msg": "读取成功",
  9410. })
  9411. } else {
  9412. c.ServeSuccessJSON(map[string]interface{}{
  9413. "failed_code": -10,
  9414. "msg": "读取失败",
  9415. })
  9416. }
  9417. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9418. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9419. if len(tokens) > 0 {
  9420. c.ServeSuccessJSON(map[string]interface{}{
  9421. "msg": "读取成功",
  9422. })
  9423. } else {
  9424. c.ServeSuccessJSON(map[string]interface{}{
  9425. "failed_code": -10,
  9426. "msg": "读取失败",
  9427. })
  9428. }
  9429. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9430. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9431. if len(tokens) > 0 {
  9432. c.ServeSuccessJSON(map[string]interface{}{
  9433. "msg": "读取成功",
  9434. })
  9435. } else {
  9436. c.ServeSuccessJSON(map[string]interface{}{
  9437. "failed_code": -10,
  9438. "msg": "读取失败",
  9439. })
  9440. }
  9441. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9442. var api string
  9443. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9444. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName + "&is_settle=1"
  9445. resp, requestErr := http.Get(api)
  9446. if requestErr != nil {
  9447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9448. }
  9449. body, ioErr := ioutil.ReadAll(resp.Body)
  9450. if ioErr != nil {
  9451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9453. }
  9454. var respJSON map[string]interface{}
  9455. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9458. return
  9459. }
  9460. var status string
  9461. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9462. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9463. var token string
  9464. var res ResultTwo //1101结果
  9465. var res10265 ResultTwo10265 //1101结果
  9466. if status == "0" { //读卡成功
  9467. var card_info string //卡信息
  9468. var busi_card_info string
  9469. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9470. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9471. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9472. fmt.Println(card_info)
  9473. fmt.Println(busi_card_info)
  9474. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9475. result, _ := json.Marshal(respJSON)
  9476. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9477. utils.ErrorLog("解析失败:%v", err)
  9478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9479. return
  9480. }
  9481. res.ErrMsg = res10265.ErrMsg
  9482. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9483. res.Infcode = infocode
  9484. res.Output = res10265.Output
  9485. res.InfRefmsgid = res10265.InfRefmsgid
  9486. if res.Infcode == 0 {
  9487. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9488. if err == gorm.ErrRecordNotFound {
  9489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9490. return
  9491. } else if err != nil {
  9492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9493. return
  9494. } else {
  9495. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9496. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9497. infoStr := string(Iinfos)
  9498. idetinfoStr := string(Idetinfos)
  9499. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9500. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9501. psn := &models.HisPsn{
  9502. PsnNo: res.Output.Baseinfo.PsnNo,
  9503. PatientId: patient.ID,
  9504. Certno: res.Output.Baseinfo.Certno,
  9505. Gend: res.Output.Baseinfo.Gend,
  9506. Naty: res.Output.Baseinfo.Naty,
  9507. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9508. PsnName: res.Output.Baseinfo.PsnName,
  9509. Age: float64(age),
  9510. Brdy: b,
  9511. Idetinfo: idetinfoStr,
  9512. Insuinfo: infoStr,
  9513. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9514. CardInfo: card_info,
  9515. VerifyNumber: token,
  9516. IdCardType: 4,
  9517. }
  9518. var rf []*ResultFive
  9519. json.Unmarshal([]byte(infoStr), &rf)
  9520. var insutypes []*ResultFive
  9521. var insutype string
  9522. var is390 int = 0
  9523. var is310 int = 0
  9524. for _, item := range rf {
  9525. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9526. insutypes = append(insutypes, item)
  9527. }
  9528. }
  9529. if len(insutypes) == 1 {
  9530. insutype = insutypes[0].Insutype
  9531. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9532. } else {
  9533. for _, i := range insutypes {
  9534. if i.Insutype == "390" {
  9535. is390 = 1
  9536. }
  9537. if i.Insutype == "310" {
  9538. is310 = 1
  9539. }
  9540. }
  9541. }
  9542. if is390 == 1 {
  9543. insutype = "390"
  9544. }
  9545. if is310 == 1 {
  9546. insutype = "310"
  9547. }
  9548. if len(insutypes) == 0 {
  9549. insutype = "310"
  9550. }
  9551. service.CreateHisPsn(psn)
  9552. c.ServeSuccessJSON(map[string]interface{}{
  9553. "patient": patient,
  9554. "number": token,
  9555. "insutype": insutype,
  9556. })
  9557. }
  9558. } else {
  9559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9560. return
  9561. }
  9562. } else { //读卡失败
  9563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9564. return
  9565. }
  9566. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9567. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9568. if len(errMsg) == 0 {
  9569. type ELeData struct {
  9570. Data struct {
  9571. IdNo string `json:"idNo"`
  9572. IdType string `json:"idType"`
  9573. UserName string `json:"userName"`
  9574. EcToken string `json:"ecToken"`
  9575. InsuOrg string `json:"insuOrg"`
  9576. Gender string `json:"gender"`
  9577. Birthday string `json:"birthday"`
  9578. Nationality string `json:"nationality"`
  9579. Email string `json:"email"`
  9580. Extra string `json:"extra"`
  9581. } `json:"data"`
  9582. Code int `json:"code"`
  9583. Message string `json:"message"`
  9584. }
  9585. var ele ELeData
  9586. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9587. if err != nil {
  9588. utils.ErrorLog("解析失败:%v", err)
  9589. }
  9590. token := ele.Data.EcToken
  9591. if len(token) > 0 {
  9592. psn := &models.HisPsn{
  9593. PsnNo: his.PsnNo,
  9594. Age: 0,
  9595. PatientId: his.PatientId,
  9596. Certno: his.Certno,
  9597. Brdy: his.Brdy,
  9598. Gend: his.Gend,
  9599. Naty: his.Naty,
  9600. PsnCertType: his.PsnCertType,
  9601. PsnName: his.PsnName,
  9602. Idetinfo: his.Idetinfo,
  9603. Insuinfo: his.Iinfo,
  9604. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9605. CardInfo: outPutInfo,
  9606. VerifyNumber: token,
  9607. }
  9608. service.CreateHisPsn(psn)
  9609. }
  9610. if len(token) > 0 {
  9611. c.ServeSuccessJSON(map[string]interface{}{
  9612. "msg": "读取成功",
  9613. })
  9614. } else {
  9615. c.ServeSuccessJSON(map[string]interface{}{
  9616. "failed_code": -10,
  9617. "msg": "读取失败",
  9618. })
  9619. }
  9620. }
  9621. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9622. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9623. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9624. type ELeData struct {
  9625. Data struct {
  9626. IdNo string `json:"idNo"`
  9627. IdType string `json:"idType"`
  9628. UserName string `json:"userName"`
  9629. EcToken string `json:"ecToken"`
  9630. InsuOrg string `json:"insuOrg"`
  9631. Gender string `json:"gender"`
  9632. Birthday string `json:"birthday"`
  9633. Nationality string `json:"nationality"`
  9634. Email string `json:"email"`
  9635. Extra string `json:"extra"`
  9636. } `json:"data"`
  9637. Code int `json:"code"`
  9638. Message string `json:"message"`
  9639. }
  9640. var ele ELeData
  9641. err := json.Unmarshal([]byte(result), &ele)
  9642. if err != nil {
  9643. utils.ErrorLog("解析失败:%v", err)
  9644. }
  9645. token := ele.Data.EcToken
  9646. token = Remove0000(token)
  9647. fmt.Println(ele.Data.UserName)
  9648. 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)
  9649. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9650. var res ResultTwo
  9651. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9652. utils.ErrorLog("解析失败:%v", err)
  9653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9654. return
  9655. }
  9656. if res.Infcode == 0 {
  9657. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9658. if err == gorm.ErrRecordNotFound {
  9659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9660. return
  9661. } else if err != nil {
  9662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9663. return
  9664. } else {
  9665. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9666. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9667. infoStr := string(Iinfos)
  9668. idetinfoStr := string(Idetinfos)
  9669. psn := &models.HisPsn{
  9670. PsnNo: res.Output.Baseinfo.PsnNo,
  9671. PatientId: patient.ID,
  9672. Certno: res.Output.Baseinfo.Certno,
  9673. Gend: res.Output.Baseinfo.Gend,
  9674. Naty: res.Output.Baseinfo.Naty,
  9675. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9676. PsnName: res.Output.Baseinfo.PsnName,
  9677. Idetinfo: idetinfoStr,
  9678. Insuinfo: infoStr,
  9679. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9680. CardInfo: "",
  9681. VerifyNumber: token,
  9682. }
  9683. service.CreateHisPsn(psn)
  9684. c.ServeSuccessJSON(map[string]interface{}{
  9685. "patient": patient,
  9686. "number": token,
  9687. })
  9688. }
  9689. } else {
  9690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9691. return
  9692. }
  9693. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9694. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9695. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9696. type ELeData struct {
  9697. Data struct {
  9698. IdNo string `json:"idNo"`
  9699. IdType string `json:"idType"`
  9700. UserName string `json:"userName"`
  9701. EcToken string `json:"ecToken"`
  9702. InsuOrg string `json:"insuOrg"`
  9703. Gender string `json:"gender"`
  9704. Birthday string `json:"birthday"`
  9705. Nationality string `json:"nationality"`
  9706. Email string `json:"email"`
  9707. Extra string `json:"extra"`
  9708. } `json:"data"`
  9709. Code int `json:"code"`
  9710. Message string `json:"message"`
  9711. }
  9712. var ele ELeData
  9713. err := json.Unmarshal([]byte(result), &ele)
  9714. if err != nil {
  9715. utils.ErrorLog("解析失败:%v", err)
  9716. }
  9717. token := ele.Data.EcToken
  9718. token = Remove0000(token)
  9719. fmt.Println(ele.Data.UserName)
  9720. 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)
  9721. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9722. var res ResultTwo
  9723. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9724. utils.ErrorLog("解析失败:%v", err)
  9725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9726. return
  9727. }
  9728. if res.Infcode == 0 {
  9729. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9730. if err == gorm.ErrRecordNotFound {
  9731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9732. return
  9733. } else if err != nil {
  9734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9735. return
  9736. } else {
  9737. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9738. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9739. infoStr := string(Iinfos)
  9740. idetinfoStr := string(Idetinfos)
  9741. psn := &models.HisPsn{
  9742. PsnNo: res.Output.Baseinfo.PsnNo,
  9743. PatientId: patient.ID,
  9744. Certno: res.Output.Baseinfo.Certno,
  9745. Gend: res.Output.Baseinfo.Gend,
  9746. Naty: res.Output.Baseinfo.Naty,
  9747. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9748. PsnName: res.Output.Baseinfo.PsnName,
  9749. Idetinfo: idetinfoStr,
  9750. Insuinfo: infoStr,
  9751. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9752. CardInfo: "",
  9753. VerifyNumber: token,
  9754. }
  9755. service.CreateHisPsn(psn)
  9756. c.ServeSuccessJSON(map[string]interface{}{
  9757. "patient": patient,
  9758. "number": token,
  9759. })
  9760. }
  9761. } else {
  9762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9763. return
  9764. }
  9765. } else if miConfig.MdtrtareaAdmvs == "360100" {
  9766. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9767. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9768. type ELeData struct {
  9769. Data struct {
  9770. IdNo string `json:"idNo"`
  9771. IdType string `json:"idType"`
  9772. UserName string `json:"userName"`
  9773. EcToken string `json:"ecToken"`
  9774. InsuOrg string `json:"insuOrg"`
  9775. Gender string `json:"gender"`
  9776. Birthday string `json:"birthday"`
  9777. Nationality string `json:"nationality"`
  9778. Email string `json:"email"`
  9779. Extra string `json:"extra"`
  9780. } `json:"data"`
  9781. Code int `json:"code"`
  9782. Message string `json:"message"`
  9783. }
  9784. var ele ELeData
  9785. err := json.Unmarshal([]byte(result), &ele)
  9786. if err != nil {
  9787. utils.ErrorLog("解析失败:%v", err)
  9788. }
  9789. token := ele.Data.EcToken
  9790. token = Remove0000(token)
  9791. fmt.Println(ele.Data.UserName)
  9792. 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)
  9793. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9794. var res ResultTwo
  9795. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9796. utils.ErrorLog("解析失败:%v", err)
  9797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9798. return
  9799. }
  9800. if res.Infcode == 0 {
  9801. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9802. if err == gorm.ErrRecordNotFound {
  9803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9804. return
  9805. } else if err != nil {
  9806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9807. return
  9808. } else {
  9809. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9810. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9811. infoStr := string(Iinfos)
  9812. idetinfoStr := string(Idetinfos)
  9813. psn := &models.HisPsn{
  9814. PsnNo: res.Output.Baseinfo.PsnNo,
  9815. PatientId: patient.ID,
  9816. Certno: res.Output.Baseinfo.Certno,
  9817. Gend: res.Output.Baseinfo.Gend,
  9818. Naty: res.Output.Baseinfo.Naty,
  9819. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9820. PsnName: res.Output.Baseinfo.PsnName,
  9821. Idetinfo: idetinfoStr,
  9822. Insuinfo: infoStr,
  9823. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9824. CardInfo: "",
  9825. VerifyNumber: token,
  9826. }
  9827. service.CreateHisPsn(psn)
  9828. c.ServeSuccessJSON(map[string]interface{}{
  9829. "patient": patient,
  9830. "number": token,
  9831. })
  9832. }
  9833. } else {
  9834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9835. return
  9836. }
  9837. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9838. //if initFlag == 0 {
  9839. //c.TestGetJiangXiBasBaseInit()
  9840. //}
  9841. //if initEleFlag == 0 {
  9842. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9843. //}
  9844. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9845. utils.ErrorLog("解析失败:%v", json_result)
  9846. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9847. type ELeData struct {
  9848. Data struct {
  9849. IdNo string `json:"idNo"`
  9850. IdType string `json:"idType"`
  9851. UserName string `json:"userName"`
  9852. EcToken string `json:"ecToken"`
  9853. InsuOrg string `json:"insuOrg"`
  9854. Gender string `json:"gender"`
  9855. Birthday string `json:"birthday"`
  9856. Nationality string `json:"nationality"`
  9857. Email string `json:"email"`
  9858. Extra string `json:"extra"`
  9859. } `json:"data"`
  9860. Code int `json:"code"`
  9861. Message string `json:"message"`
  9862. }
  9863. var ele ELeData
  9864. err := json.Unmarshal([]byte(json_result), &ele)
  9865. if err != nil {
  9866. utils.ErrorLog("解析失败:%v", err)
  9867. }
  9868. token := ele.Data.EcToken
  9869. token = Remove0000(token)
  9870. //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)
  9871. 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)
  9872. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9873. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9874. var res ResultTwo
  9875. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9876. utils.ErrorLog("解析失败:%v", err)
  9877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9878. return
  9879. }
  9880. if res.Infcode == 0 {
  9881. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9882. if err == gorm.ErrRecordNotFound {
  9883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9884. return
  9885. } else if err != nil {
  9886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9887. return
  9888. } else {
  9889. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9890. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9891. infoStr := string(Iinfos)
  9892. idetinfoStr := string(Idetinfos)
  9893. psn := &models.HisPsn{
  9894. PsnNo: res.Output.Baseinfo.PsnNo,
  9895. PatientId: patient.ID,
  9896. Certno: res.Output.Baseinfo.Certno,
  9897. Gend: res.Output.Baseinfo.Gend,
  9898. Naty: res.Output.Baseinfo.Naty,
  9899. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9900. PsnName: res.Output.Baseinfo.PsnName,
  9901. Idetinfo: idetinfoStr,
  9902. Insuinfo: infoStr,
  9903. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9904. CardInfo: "",
  9905. VerifyNumber: token,
  9906. InsuplcAdmdvs: ele.Data.InsuOrg,
  9907. }
  9908. service.CreateHisPsn(psn)
  9909. c.ServeSuccessJSON(map[string]interface{}{
  9910. "patient": patient,
  9911. "number": token,
  9912. })
  9913. }
  9914. } else {
  9915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9916. return
  9917. }
  9918. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9919. res := c.GetoleInfo()
  9920. if res.Infcode == 0 {
  9921. var result string
  9922. if res.Output.MdtrtCertType == "01" {
  9923. 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)
  9924. } else if res.Output.MdtrtCertType == "02" {
  9925. 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)
  9926. } else if res.Output.MdtrtCertType == "03" {
  9927. 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)
  9928. }
  9929. var dat map[string]interface{}
  9930. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9931. fmt.Println(dat)
  9932. } else {
  9933. fmt.Println(err)
  9934. }
  9935. userJSONBytes, _ := json.Marshal(dat)
  9936. var res2 ResultTwo
  9937. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9938. utils.ErrorLog("解析失败:%v", err)
  9939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9940. return
  9941. }
  9942. if res2.Infcode == 0 {
  9943. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9944. if err == gorm.ErrRecordNotFound {
  9945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9946. return
  9947. } else if err != nil {
  9948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9949. return
  9950. } else {
  9951. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9952. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9953. infoStr := string(Iinfos)
  9954. idetinfoStr := string(Idetinfos)
  9955. var rf []*ResultFive
  9956. json.Unmarshal([]byte(infoStr), &rf)
  9957. var insutypes []*ResultFive
  9958. var insutype string
  9959. var is390 int = 0
  9960. var is310 int = 0
  9961. //var insuplc_admdvs string
  9962. for _, item := range rf {
  9963. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9964. insutypes = append(insutypes, item)
  9965. }
  9966. }
  9967. if len(insutypes) == 1 {
  9968. insutype = insutypes[0].Insutype
  9969. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9970. } else {
  9971. for _, i := range insutypes {
  9972. if i.Insutype == "390" {
  9973. is390 = 1
  9974. }
  9975. if i.Insutype == "310" {
  9976. is310 = 1
  9977. }
  9978. }
  9979. }
  9980. if is390 == 1 {
  9981. insutype = "390"
  9982. }
  9983. if is310 == 1 {
  9984. insutype = "310"
  9985. }
  9986. if len(insutypes) == 0 {
  9987. insutype = "310"
  9988. }
  9989. psn := &models.HisPsn{
  9990. PsnNo: res2.Output.Baseinfo.PsnNo,
  9991. PatientId: patient.ID,
  9992. Certno: res2.Output.Baseinfo.Certno,
  9993. Gend: res2.Output.Baseinfo.Gend,
  9994. Naty: res2.Output.Baseinfo.Naty,
  9995. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9996. PsnName: res2.Output.Baseinfo.PsnName,
  9997. Idetinfo: idetinfoStr,
  9998. Insuinfo: infoStr,
  9999. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10000. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10001. VerifyNumber: res.Output.EcToken,
  10002. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10003. }
  10004. service.CreateHisPsn(psn)
  10005. c.ServeSuccessJSON(map[string]interface{}{
  10006. "patient": patient,
  10007. "number": res.Output.CardNo,
  10008. "insutype": insutype,
  10009. })
  10010. }
  10011. } else {
  10012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10013. return
  10014. }
  10015. } else {
  10016. c.ServeSuccessJSON(map[string]interface{}{
  10017. "failed_code": -10,
  10018. "msg": res.ErrMsg,
  10019. })
  10020. }
  10021. } else {
  10022. //if initFlag == 0 {
  10023. // c.TestGetBasBaseInit()
  10024. //}
  10025. //token := c.GetEleBaseInfo()
  10026. //token = Remove0000(token)
  10027. type ELeData struct {
  10028. Code string `json:"code"`
  10029. Data struct {
  10030. Aac002 string `json:"aac002"`
  10031. Aaz500 string `json:"aaz500"`
  10032. ActCardNo string `json:"actCardNo"`
  10033. Bab520 string `json:"bab520"`
  10034. Bkz543 string `json:"bkz543"`
  10035. BusinessType string `json:"businessType"`
  10036. CertfCodg string `json:"certfCodg"`
  10037. EcIndexNo string `json:"ecIndexNo"`
  10038. EcToken string `json:"ecToken"`
  10039. ID0000 string `json:"id0000"`
  10040. IDNo string `json:"idNo"`
  10041. IDType string `json:"idType"`
  10042. Idcode string `json:"idcode"`
  10043. IdentityToken string `json:"identity_token"`
  10044. InsuOrg string `json:"insuOrg"`
  10045. OfficeID string `json:"officeId"`
  10046. OfficeName string `json:"officeName"`
  10047. OperatorID string `json:"operatorId"`
  10048. OperatorName string `json:"operatorName"`
  10049. OrgID string `json:"orgId"`
  10050. UserName string `json:"userName"`
  10051. } `json:"data"`
  10052. Infno interface{} `json:"infno"`
  10053. Message string `json:"message"`
  10054. OrgID string `json:"orgId"`
  10055. TransType string `json:"transType"`
  10056. }
  10057. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10058. fmt.Println(result)
  10059. outPutInfo := Remove0000(result)
  10060. fmt.Println(outPutInfo)
  10061. var ele ELeData
  10062. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10063. if err != nil {
  10064. utils.ErrorLog("解析失败:%v", err)
  10065. }
  10066. token := ele.Data.EcToken
  10067. var result2 string
  10068. var requestLog2 string
  10069. if len(token) > 0 {
  10070. if strings.Contains(ele.Data.IDNo, "HKG") {
  10071. 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)
  10072. } else {
  10073. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10074. }
  10075. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10076. var res ResultTwo
  10077. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10078. utils.ErrorLog("解析失败:%v", err)
  10079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10080. return
  10081. }
  10082. if res.Infcode == 0 {
  10083. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10084. if err == gorm.ErrRecordNotFound {
  10085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10086. return
  10087. } else if err != nil {
  10088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10089. return
  10090. } else {
  10091. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10092. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10093. infoStr := string(Iinfos)
  10094. idetinfoStr := string(Idetinfos)
  10095. psn := &models.HisPsn{
  10096. PsnNo: res.Output.Baseinfo.PsnNo,
  10097. PatientId: patient.ID,
  10098. Certno: res.Output.Baseinfo.Certno,
  10099. Gend: res.Output.Baseinfo.Gend,
  10100. Naty: res.Output.Baseinfo.Naty,
  10101. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10102. PsnName: res.Output.Baseinfo.PsnName,
  10103. Idetinfo: idetinfoStr,
  10104. Insuinfo: infoStr,
  10105. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10106. CardInfo: "",
  10107. VerifyNumber: token,
  10108. }
  10109. service.CreateHisPsn(psn)
  10110. c.ServeSuccessJSON(map[string]interface{}{
  10111. "msg": "读取成功",
  10112. })
  10113. }
  10114. } else {
  10115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10116. return
  10117. }
  10118. } else {
  10119. c.ServeSuccessJSON(map[string]interface{}{
  10120. "failed_code": -10,
  10121. "msg": "读取失败",
  10122. })
  10123. }
  10124. }
  10125. }
  10126. func (c *HisApiController) ReadEleFace() {
  10127. admin_user_id, _ := c.GetInt64("admin_user_id")
  10128. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10129. adminUser := c.GetAdminUserInfo()
  10130. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10131. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10132. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10133. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10134. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10135. if len(tokens) > 0 {
  10136. c.ServeSuccessJSON(map[string]interface{}{
  10137. "msg": "读取成功",
  10138. })
  10139. } else {
  10140. c.ServeSuccessJSON(map[string]interface{}{
  10141. "failed_code": -10,
  10142. "msg": "读取失败",
  10143. })
  10144. }
  10145. }
  10146. }
  10147. func (c *HisApiController) Get9001() {
  10148. adminUser := c.GetAdminUserInfo()
  10149. admin_user_id, _ := c.GetInt64("admin_user_id")
  10150. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10151. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10152. if miConfig.MdtrtareaAdmvs == "350500" {
  10153. service.GetFjAuthorizationInfo(miConfig.Code)
  10154. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10155. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10156. var dat map[string]interface{}
  10157. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10158. fmt.Println(dat)
  10159. } else {
  10160. fmt.Println(err)
  10161. }
  10162. userJSONBytes, _ := json.Marshal(dat)
  10163. var res models.Result9001
  10164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10165. utils.ErrorLog("解析失败:%v", err)
  10166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10167. return
  10168. }
  10169. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10170. fmt.Println(miConfig.SecretKey)
  10171. var res models.Result9001Two
  10172. 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 +
  10173. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10174. resp, requestErr := http.Get(api)
  10175. if requestErr != nil {
  10176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10177. return
  10178. }
  10179. body, ioErr := ioutil.ReadAll(resp.Body)
  10180. if ioErr != nil {
  10181. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10183. return
  10184. }
  10185. var respJSON map[string]interface{}
  10186. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10189. return
  10190. }
  10191. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10192. if status == "0" {
  10193. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10194. c.ServeSuccessJSON(map[string]interface{}{
  10195. "failed_code": -10,
  10196. "msg": err_msg,
  10197. })
  10198. return
  10199. }
  10200. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10201. result, _ := json.Marshal(respJSON)
  10202. fmt.Println("log")
  10203. fmt.Println(string(result))
  10204. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10205. utils.ErrorLog("解析失败:%v", err)
  10206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10207. return
  10208. }
  10209. if res.Infcode == 0 {
  10210. sign := models.HisSignIn{
  10211. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10212. SignNo: res.Output.Signinoutb.SignNo,
  10213. SignTime: "",
  10214. Ctime: time.Now().Unix(),
  10215. Mtime: time.Now().Unix(),
  10216. Status: 1,
  10217. InputLog: "",
  10218. OutputLog: "",
  10219. FixmedinsCode: miConfig.Code,
  10220. }
  10221. err := service.CreateSignIn(&sign)
  10222. if err == nil {
  10223. c.ServeSuccessJSON(map[string]interface{}{
  10224. "msg": "签到成功",
  10225. })
  10226. }
  10227. } else {
  10228. c.ServeSuccessJSON(map[string]interface{}{
  10229. "failed_code": -10,
  10230. "msg": res.ErrMsg,
  10231. })
  10232. return
  10233. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10234. //return
  10235. }
  10236. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10237. fmt.Println(miConfig.SecretKey)
  10238. var res models.Result9001Two
  10239. 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 +
  10240. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10241. resp, requestErr := http.Get(api)
  10242. if requestErr != nil {
  10243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10244. return
  10245. }
  10246. body, ioErr := ioutil.ReadAll(resp.Body)
  10247. if ioErr != nil {
  10248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10250. return
  10251. }
  10252. var respJSON map[string]interface{}
  10253. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10256. return
  10257. }
  10258. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10259. if status == "0" {
  10260. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10261. c.ServeSuccessJSON(map[string]interface{}{
  10262. "failed_code": -10,
  10263. "msg": err_msg,
  10264. })
  10265. return
  10266. }
  10267. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10268. result, _ := json.Marshal(respJSON)
  10269. fmt.Println("log")
  10270. fmt.Println(string(result))
  10271. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10272. utils.ErrorLog("解析失败:%v", err)
  10273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10274. return
  10275. }
  10276. if res.Infcode == 0 {
  10277. sign := models.HisSignIn{
  10278. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10279. SignNo: res.Output.Signinoutb.SignNo,
  10280. SignTime: "",
  10281. Ctime: time.Now().Unix(),
  10282. Mtime: time.Now().Unix(),
  10283. Status: 1,
  10284. InputLog: "",
  10285. OutputLog: "",
  10286. FixmedinsCode: miConfig.Code,
  10287. }
  10288. err := service.CreateSignIn(&sign)
  10289. if err == nil {
  10290. c.ServeSuccessJSON(map[string]interface{}{
  10291. "msg": "签到成功",
  10292. })
  10293. }
  10294. } else {
  10295. c.ServeSuccessJSON(map[string]interface{}{
  10296. "failed_code": -10,
  10297. "msg": res.ErrMsg,
  10298. })
  10299. return
  10300. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10301. //return
  10302. }
  10303. } else {
  10304. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10305. var dat map[string]interface{}
  10306. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10307. fmt.Println(dat)
  10308. } else {
  10309. fmt.Println(err)
  10310. }
  10311. userJSONBytes, _ := json.Marshal(dat)
  10312. var res models.Result9001
  10313. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10314. utils.ErrorLog("解析失败:%v", err)
  10315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10316. return
  10317. }
  10318. if res.Infcode == 0 {
  10319. sign := models.HisSignIn{
  10320. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10321. SignNo: res.Output.Signinoutb.SignNo,
  10322. SignTime: res.Output.Signinoutb.SignTime,
  10323. Ctime: time.Now().Unix(),
  10324. Mtime: time.Now().Unix(),
  10325. Status: 1,
  10326. InputLog: "",
  10327. OutputLog: "",
  10328. FixmedinsCode: miConfig.Code,
  10329. }
  10330. err := service.CreateSignIn(&sign)
  10331. if err == nil {
  10332. c.ServeSuccessJSON(map[string]interface{}{
  10333. "msg": "签到成功",
  10334. })
  10335. }
  10336. }
  10337. }
  10338. }
  10339. 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) {
  10340. var res Result3101
  10341. adminUser := c.GetAdminUserInfo()
  10342. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10343. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10344. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10345. //record_time := c.GetString("record_time")
  10346. //trig_scen := c.GetString("trig_scen")
  10347. timeLayout := "2006-01-02"
  10348. loc, _ := time.LoadLocation("Local")
  10349. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10350. if err != nil {
  10351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10352. return res
  10353. }
  10354. recordDateTime := theTime.Unix()
  10355. var patientPrescription models.HisPrescriptionInfo
  10356. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10357. //if patientPrescription.ID == 0 {
  10358. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10359. //}
  10360. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10361. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10362. //
  10363. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10364. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10365. var pp models.PublicParams
  10366. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10367. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10368. pp.FixmedinsName = miConfig.OrgName
  10369. pp.FixmedinsCode = miConfig.Code
  10370. pp.RequestUrl = miConfig.Url
  10371. pp.Cainfo = miConfig.Cainfo
  10372. pp.SecretKey = miConfig.SecretKey
  10373. pp.AccessKey = miConfig.AccessKey
  10374. pp.OpterName = roles.UserName
  10375. var config []*models.HisXtDiagnoseConfig
  10376. for _, item := range diagnosis_ids {
  10377. id, _ := strconv.ParseInt(item, 10, 64)
  10378. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10379. config = append(config, &diagnosisConfig)
  10380. }
  10381. var pd models.PatientDtos
  10382. pd.PatnID = his.PsnNo
  10383. pd.PatnName = his.Name
  10384. pd.Gend = his.Gend
  10385. pd.Brdy = his.Brdy
  10386. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10387. pd.CurrMdtrtID = his.Number
  10388. var fed models.FsiEncounterDtos
  10389. fed.MdtrtID = his.Number
  10390. fed.MedinsID = miConfig.Code
  10391. fed.MedinsName = miConfig.OrgName
  10392. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10393. fed.MedMdtrtType = "1"
  10394. fed.MedinsType = "1"
  10395. fed.MedinsLv = "11"
  10396. tm := time.Unix(his.RecordDate, 0)
  10397. s_tm := tm.Format("2006-01-02 15:04:05")
  10398. fed.AdmDate = s_tm
  10399. fed.DscgDate = s_tm
  10400. fed.DscgMainDiseCodg = config[0].CountryCode
  10401. fed.DscgMainDiseName = config[0].CountryContentName
  10402. //诊断信息
  10403. var fdds []*models.FsiDiagnoseDtos
  10404. for index, item := range config {
  10405. if index == 0 {
  10406. var fdd models.FsiDiagnoseDtos
  10407. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10408. fdd.InoutDiseType = "1"
  10409. fdd.MaindiseFlag = "1"
  10410. fdd.DiseDate = s_tm
  10411. fdd.DiasSrtNo = "1"
  10412. fdd.DiseName = item.CountryContentName
  10413. fdd.DiseCodg = item.CountryCode
  10414. fdds = append(fdds, &fdd)
  10415. } else {
  10416. var fdd models.FsiDiagnoseDtos
  10417. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10418. fdd.InoutDiseType = "1"
  10419. fdd.MaindiseFlag = "1"
  10420. fdd.DiseDate = s_tm
  10421. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10422. fdd.DiseName = item.CountryContentName
  10423. fdd.DiseCodg = item.CountryCode
  10424. fdds = append(fdds, &fdd)
  10425. }
  10426. }
  10427. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10428. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10429. fed.AdmDeptName = de.Name
  10430. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10431. fed.DscgDeptName = de.Name
  10432. fed.MedMdtrtType = "1"
  10433. fed.MedType = "11"
  10434. //if his.Insutype == "390" {
  10435. // fed.MedType = "1402"
  10436. //} else {
  10437. // fed.MedType = "9933"
  10438. //}
  10439. var orders []*models.FsiOrderDtos
  10440. if trig_scen == "2" {
  10441. //处方医嘱信息
  10442. for _, item := range prescriptions {
  10443. for _, subItem := range item.HisDoctorAdviceInfo {
  10444. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10445. var order models.FsiOrderDtos
  10446. order.RxID = strconv.FormatInt(item.ID, 10)
  10447. order.Rxno = strconv.FormatInt(item.ID, 10)
  10448. order.LongDrordFlag = "0"
  10449. order.HilistType = "1"
  10450. order.ChrgType = "1"
  10451. order.DrordBhvr = "-"
  10452. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10453. order.HosplistName = subItem.BaseDrugLib.DrugName
  10454. order.HilistLv = "1"
  10455. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10456. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10457. order.HosplistName = subItem.BaseDrugLib.DrugName
  10458. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10459. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10460. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10461. order.OwnpayAmt = ""
  10462. order.SelfpayAmt = ""
  10463. order.Spec = ""
  10464. order.SpecUnt = ""
  10465. order.DrordBegnDate = s_tm
  10466. order.DrordStopDate = ""
  10467. order.DrordDrCodg = doctor_info.DoctorNumber
  10468. order.DrordDeptName = department.Name
  10469. order.DrordDeptCodg = department.Number
  10470. order.DrordDrName = doctor_info.UserName
  10471. order.DrordDrProfttl = "234"
  10472. order.CurrDrordFlag = "1"
  10473. orders = append(orders, &order)
  10474. }
  10475. }
  10476. for _, subItem := range item.HisPrescriptionProject {
  10477. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10478. var order models.FsiOrderDtos
  10479. order.RxID = strconv.FormatInt(item.ID, 10)
  10480. order.Rxno = strconv.FormatInt(item.ID, 10)
  10481. order.LongDrordFlag = "0"
  10482. order.HilistType = "1"
  10483. order.ChrgType = "1"
  10484. order.DrordBhvr = "-"
  10485. order.HilistCode = subItem.HisProject.MedicalCode
  10486. order.HosplistName = subItem.HisProject.ProjectName
  10487. order.HilistLv = "1"
  10488. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10489. order.HosplistCode = subItem.HisProject.MedicalCode
  10490. order.HosplistName = subItem.HisProject.ProjectName
  10491. order.Cnt = subItem.Count
  10492. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10493. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10494. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10495. order.OwnpayAmt = ""
  10496. order.SelfpayAmt = ""
  10497. order.Spec = ""
  10498. order.SpecUnt = ""
  10499. order.DrordBegnDate = s_tm
  10500. order.DrordStopDate = ""
  10501. order.DrordDrCodg = doctor_info.DoctorNumber
  10502. order.DrordDeptName = department.Name
  10503. order.DrordDeptCodg = department.Number
  10504. order.DrordDrName = doctor_info.UserName
  10505. order.DrordDrProfttl = "234"
  10506. order.CurrDrordFlag = "1"
  10507. orders = append(orders, &order)
  10508. }
  10509. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10510. var order models.FsiOrderDtos
  10511. order.RxID = strconv.FormatInt(item.ID, 10)
  10512. order.Rxno = strconv.FormatInt(item.ID, 10)
  10513. order.LongDrordFlag = "0"
  10514. order.HilistType = "1"
  10515. order.ChrgType = "1"
  10516. order.DrordBhvr = "-"
  10517. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10518. order.HosplistName = subItem.GoodInfo.GoodName
  10519. order.HilistLv = "1"
  10520. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10521. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10522. order.HosplistName = subItem.GoodInfo.GoodName
  10523. order.Cnt = subItem.Count
  10524. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10525. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10526. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  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. }
  10543. //处方医嘱信息
  10544. }
  10545. fed.MatnStas = "0"
  10546. fed.MedfeeSumamt = "0"
  10547. fed.OwnpayAmt = "0"
  10548. fed.SelfpayAmt = "0"
  10549. fed.AcctPayamt = "0"
  10550. fed.MaAmt = "0"
  10551. fed.HifpPayamt = "0"
  10552. fed.SetlTotlnum = "1"
  10553. fed.Insutype = his.Insutype
  10554. fed.ReimFlag = "0"
  10555. fed.OutSetlFlag = "0"
  10556. var fopd []*models.FsiOperationDtosData
  10557. data := make(map[string]interface{})
  10558. data["fed"] = fed
  10559. data["fdd"] = fdds
  10560. data["fod"] = orders
  10561. data["pd"] = pd
  10562. data["pp"] = pp
  10563. data["fopd"] = fopd
  10564. data["trig_scen"] = trig_scen
  10565. fmt.Println(data)
  10566. fmt.Println(fed)
  10567. fmt.Println(fdds)
  10568. fmt.Println(orders)
  10569. fmt.Println(pd)
  10570. fmt.Println(pp)
  10571. fmt.Println(fopd)
  10572. client := &http.Client{}
  10573. bytesData, _ := json.Marshal(data)
  10574. var req *http.Request
  10575. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10576. if miConfig.MdtrtareaAdmvs == "320921" {
  10577. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10578. } else {
  10579. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10580. }
  10581. resp, _ := client.Do(req)
  10582. defer resp.Body.Close()
  10583. body, ioErr := ioutil.ReadAll(resp.Body)
  10584. if ioErr != nil {
  10585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10587. return res
  10588. }
  10589. var respJSON map[string]interface{}
  10590. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10593. return res
  10594. }
  10595. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10596. fmt.Println(respJSON)
  10597. result, _ := json.Marshal(respJSON)
  10598. fmt.Println(result)
  10599. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10600. utils.ErrorLog("解析失败:%v", err)
  10601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10602. return res
  10603. }
  10604. return res
  10605. } else {
  10606. //if miConfig.MdtrtareaAdmvs == "441202" {
  10607. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10608. saveLog(output, input, "3101", "事前")
  10609. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10610. utils.ErrorLog("解析失败:%v", err)
  10611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10612. return
  10613. }
  10614. return res
  10615. //}
  10616. }
  10617. }
  10618. 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) {
  10619. adminUser := c.GetAdminUserInfo()
  10620. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10621. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10622. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10623. //record_time := c.GetString("record_time")
  10624. //trig_scen := c.GetString("trig_scen")
  10625. timeLayout := "2006-01-02"
  10626. loc, _ := time.LoadLocation("Local")
  10627. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10628. if err != nil {
  10629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10630. return res
  10631. }
  10632. recordDateTime := theTime.Unix()
  10633. var patientPrescription models.HisPrescriptionInfo
  10634. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10635. if patientPrescription.ID == 0 {
  10636. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10637. }
  10638. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10639. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10640. //
  10641. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10642. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10643. var pp models.PublicParams
  10644. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10645. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10646. pp.FixmedinsName = miConfig.OrgName
  10647. pp.FixmedinsCode = miConfig.Code
  10648. pp.RequestUrl = miConfig.Url
  10649. pp.Cainfo = miConfig.Cainfo
  10650. pp.SecretKey = miConfig.SecretKey
  10651. pp.AccessKey = miConfig.AccessKey
  10652. pp.OpterName = roles.UserName
  10653. var config []*models.HisXtDiagnoseConfig
  10654. for _, item := range diagnosis_ids {
  10655. id, _ := strconv.ParseInt(item, 10, 64)
  10656. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10657. config = append(config, &diagnosisConfig)
  10658. }
  10659. var pd models.PatientDtos
  10660. pd.PatnID = his.PsnNo
  10661. pd.PatnName = his.Name
  10662. pd.Gend = his.Gend
  10663. pd.Brdy = his.Brdy
  10664. pd.Poolarea = his.InsuplcAdmdvs
  10665. pd.CurrMdtrtID = his.Number
  10666. var fed models.FsiEncounterDtos
  10667. fed.MdtrtID = his.Number
  10668. fed.MedinsID = miConfig.Code
  10669. fed.MedinsName = miConfig.OrgName
  10670. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10671. fed.MedMdtrtType = "1"
  10672. fed.MedinsType = "1"
  10673. fed.MedinsLv = "11"
  10674. tm := time.Unix(his.RecordDate, 0)
  10675. s_tm := tm.Format("2006-01-02 15:04:05")
  10676. fed.AdmDate = s_tm
  10677. fed.DscgDate = s_tm
  10678. fed.DscgMainDiseCodg = config[0].CountryCode
  10679. fed.DscgMainDiseName = config[0].CountryContentName
  10680. //诊断信息
  10681. var fdds []*models.FsiDiagnoseDtos
  10682. for index, item := range config {
  10683. if index == 0 {
  10684. var fdd models.FsiDiagnoseDtos
  10685. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10686. fdd.InoutDiseType = "1"
  10687. fdd.MaindiseFlag = "1"
  10688. fdd.DiseDate = s_tm
  10689. fdd.DiasSrtNo = "1"
  10690. fdd.DiseName = item.CountryContentName
  10691. fdd.DiseCodg = item.CountryCode
  10692. fdds = append(fdds, &fdd)
  10693. } else {
  10694. var fdd models.FsiDiagnoseDtos
  10695. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10696. fdd.InoutDiseType = "1"
  10697. fdd.MaindiseFlag = "1"
  10698. fdd.DiseDate = s_tm
  10699. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10700. fdd.DiseName = item.CountryContentName
  10701. fdd.DiseCodg = item.CountryCode
  10702. fdds = append(fdds, &fdd)
  10703. }
  10704. }
  10705. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10706. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10707. fed.AdmDeptName = department.Name
  10708. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10709. fed.DscgDeptName = department.Name
  10710. fed.MedMdtrtType = "1"
  10711. fed.MedType = "11"
  10712. //if his.Insutype == "390" {
  10713. // fed.MedType = "1402"
  10714. //} else {
  10715. // fed.MedType = "9933"
  10716. //}
  10717. var orders []*models.FsiOrderDtos
  10718. if trig_scen == "2" {
  10719. //处方医嘱信息
  10720. for _, item := range prescriptions {
  10721. for _, subItem := range item.HisDoctorAdviceInfo {
  10722. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10723. var order models.FsiOrderDtos
  10724. order.RxID = strconv.FormatInt(item.ID, 10)
  10725. order.Rxno = strconv.FormatInt(item.ID, 10)
  10726. order.LongDrordFlag = "0"
  10727. order.HilistType = "1"
  10728. order.ChrgType = "1"
  10729. order.DrordBhvr = "-"
  10730. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10731. order.HosplistName = subItem.BaseDrugLib.DrugName
  10732. order.HilistLv = "1"
  10733. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10734. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10735. order.HosplistName = subItem.BaseDrugLib.DrugName
  10736. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10737. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10738. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10739. order.OwnpayAmt = ""
  10740. order.SelfpayAmt = ""
  10741. order.Spec = ""
  10742. order.SpecUnt = ""
  10743. order.DrordBegnDate = s_tm
  10744. order.DrordStopDate = ""
  10745. order.DrordDrCodg = doctor_info.DoctorNumber
  10746. order.DrordDeptName = department.Name
  10747. order.DrordDeptCodg = department.Number
  10748. order.DrordDrName = doctor_info.UserName
  10749. order.DrordDrProfttl = "234"
  10750. order.CurrDrordFlag = "1"
  10751. orders = append(orders, &order)
  10752. }
  10753. }
  10754. for _, subItem := range item.HisPrescriptionProject {
  10755. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10756. var order models.FsiOrderDtos
  10757. order.RxID = strconv.FormatInt(item.ID, 10)
  10758. order.Rxno = strconv.FormatInt(item.ID, 10)
  10759. order.LongDrordFlag = "0"
  10760. order.HilistType = "1"
  10761. order.ChrgType = "1"
  10762. order.DrordBhvr = "-"
  10763. order.HilistCode = subItem.HisProject.MedicalCode
  10764. order.HosplistName = subItem.HisProject.ProjectName
  10765. order.HilistLv = "1"
  10766. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10767. order.HosplistCode = subItem.HisProject.MedicalCode
  10768. order.HosplistName = subItem.HisProject.ProjectName
  10769. order.Cnt = subItem.Count
  10770. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10771. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10772. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10773. order.OwnpayAmt = ""
  10774. order.SelfpayAmt = ""
  10775. order.Spec = ""
  10776. order.SpecUnt = ""
  10777. order.DrordBegnDate = s_tm
  10778. order.DrordStopDate = ""
  10779. order.DrordDrCodg = doctor_info.DoctorNumber
  10780. order.DrordDeptName = department.Name
  10781. order.DrordDeptCodg = department.Number
  10782. order.DrordDrName = doctor_info.UserName
  10783. order.DrordDrProfttl = "234"
  10784. order.CurrDrordFlag = "1"
  10785. orders = append(orders, &order)
  10786. }
  10787. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10788. var order models.FsiOrderDtos
  10789. order.RxID = strconv.FormatInt(item.ID, 10)
  10790. order.Rxno = strconv.FormatInt(item.ID, 10)
  10791. order.LongDrordFlag = "0"
  10792. order.HilistType = "1"
  10793. order.ChrgType = "1"
  10794. order.DrordBhvr = "-"
  10795. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10796. order.HosplistName = subItem.GoodInfo.GoodName
  10797. order.HilistLv = "1"
  10798. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10799. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10800. order.HosplistName = subItem.GoodInfo.GoodName
  10801. order.Cnt = subItem.Count
  10802. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10803. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10804. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  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. }
  10821. //处方医嘱信息
  10822. }
  10823. fed.MatnStas = "0"
  10824. fed.MedfeeSumamt = "0"
  10825. fed.OwnpayAmt = "0"
  10826. fed.SelfpayAmt = "0"
  10827. fed.AcctPayamt = "0"
  10828. fed.MaAmt = "0"
  10829. fed.HifpPayamt = "0"
  10830. fed.SetlTotlnum = "1"
  10831. fed.Insutype = his.Insutype
  10832. fed.ReimFlag = "0"
  10833. fed.OutSetlFlag = "0"
  10834. var fopd []*models.FsiOperationDtosData
  10835. data := make(map[string]interface{})
  10836. data["fed"] = fed
  10837. data["fdd"] = fdds
  10838. data["fod"] = orders
  10839. data["pd"] = pd
  10840. data["pp"] = pp
  10841. data["fopd"] = fopd
  10842. data["trig_scen"] = trig_scen
  10843. fmt.Println(data)
  10844. fmt.Println(fed)
  10845. fmt.Println(fdds)
  10846. fmt.Println(orders)
  10847. fmt.Println(pd)
  10848. fmt.Println(pp)
  10849. fmt.Println(fopd)
  10850. client := &http.Client{}
  10851. bytesData, _ := json.Marshal(data)
  10852. var req *http.Request
  10853. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10854. if miConfig.MdtrtareaAdmvs == "320921" {
  10855. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10856. } else {
  10857. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10858. }
  10859. resp, _ := client.Do(req)
  10860. defer resp.Body.Close()
  10861. body, ioErr := ioutil.ReadAll(resp.Body)
  10862. if ioErr != nil {
  10863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10865. return res
  10866. }
  10867. var respJSON map[string]interface{}
  10868. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10871. return res
  10872. }
  10873. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10874. fmt.Println(respJSON)
  10875. result, _ := json.Marshal(respJSON)
  10876. fmt.Println(result)
  10877. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10878. utils.ErrorLog("解析失败:%v", err)
  10879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10880. return res
  10881. }
  10882. return res
  10883. } else {
  10884. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10885. saveLog(output, input, "3101", "事前")
  10886. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10887. utils.ErrorLog("解析失败:%v", err)
  10888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10889. return
  10890. }
  10891. return res
  10892. }
  10893. return res
  10894. }
  10895. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10896. ////patient_id, _ := c.GetInt64("patient_id")
  10897. //order_id, _ := c.GetInt64("order_id")
  10898. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10899. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10900. //trig_scen := c.GetString("trig_scen")
  10901. adminUser := c.GetAdminUserInfo()
  10902. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10903. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10904. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10905. record_time := c.GetString("record_time")
  10906. order, _ := service.GetHisOrderByID(order_id)
  10907. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10908. timeLayout := "2006-01-02"
  10909. loc, _ := time.LoadLocation("Local")
  10910. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10911. if err != nil {
  10912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10913. return
  10914. }
  10915. recordDateTime := theTime.Unix()
  10916. var patientPrescription models.HisPrescriptionInfo
  10917. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10918. if patientPrescription.ID == 0 {
  10919. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10920. }
  10921. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10922. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10923. //
  10924. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10925. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10926. var pp models.PublicParams
  10927. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10928. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10929. pp.FixmedinsName = miConfig.OrgName
  10930. pp.FixmedinsCode = miConfig.Code
  10931. pp.RequestUrl = miConfig.Url
  10932. pp.Cainfo = miConfig.Cainfo
  10933. pp.SecretKey = miConfig.SecretKey
  10934. pp.AccessKey = miConfig.AccessKey
  10935. pp.OpterName = roles.UserName
  10936. var config []*models.HisXtDiagnoseConfig
  10937. for _, item := range diagnosis_ids {
  10938. id, _ := strconv.ParseInt(item, 10, 64)
  10939. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10940. config = append(config, &diagnosisConfig)
  10941. }
  10942. var pd models.PatientDtos
  10943. pd.PatnID = his.PsnNo
  10944. pd.PatnName = his.Name
  10945. pd.Gend = his.Gend
  10946. pd.Brdy = psn_info.Brdy
  10947. pd.Poolarea = his.InsuplcAdmdvs
  10948. pd.CurrMdtrtID = his.Number
  10949. var fed models.FsiEncounterDtos
  10950. fed.MdtrtID = his.Number
  10951. fed.MedinsID = miConfig.Code
  10952. fed.MedinsName = miConfig.OrgName
  10953. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10954. fed.MedMdtrtType = "1"
  10955. fed.MedinsType = "1"
  10956. fed.MedinsLv = "11"
  10957. tm := time.Unix(his.RecordDate, 0)
  10958. s_tm := tm.Format("2006-01-02 15:04:05")
  10959. fed.AdmDate = s_tm
  10960. fed.DscgDate = s_tm
  10961. fed.DscgMainDiseCodg = config[0].CountryCode
  10962. fed.DscgMainDiseName = config[0].CountryContentName
  10963. //诊断信息
  10964. var fdds []*models.FsiDiagnoseDtos
  10965. for index, item := range config {
  10966. if index == 0 {
  10967. var fdd models.FsiDiagnoseDtos
  10968. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10969. fdd.InoutDiseType = "1"
  10970. fdd.MaindiseFlag = "1"
  10971. fdd.DiseDate = s_tm
  10972. fdd.DiasSrtNo = "1"
  10973. fdd.DiseName = item.CountryContentName
  10974. fdd.DiseCodg = item.CountryCode
  10975. fdds = append(fdds, &fdd)
  10976. } else {
  10977. var fdd models.FsiDiagnoseDtos
  10978. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10979. fdd.InoutDiseType = "1"
  10980. fdd.MaindiseFlag = "1"
  10981. fdd.DiseDate = s_tm
  10982. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10983. fdd.DiseName = item.CountryContentName
  10984. fdd.DiseCodg = item.CountryCode
  10985. fdds = append(fdds, &fdd)
  10986. }
  10987. }
  10988. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10989. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10990. fed.AdmDeptName = department.Name
  10991. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10992. fed.DscgDeptName = department.Name
  10993. fed.MedType = order.MedType
  10994. //处方医嘱信息
  10995. var orders []*models.FsiOrderDtos
  10996. //for _, item := range prescriptions {
  10997. // for _, subItem := range item.HisDoctorAdviceInfo {
  10998. // var order models.FsiOrderDtos
  10999. // order.RxID = strconv.FormatInt(item.ID, 10)
  11000. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11001. // order.LongDrordFlag = "0"
  11002. // order.HilistType = "1"
  11003. // order.ChrgType = "1"
  11004. // order.DrordBhvr = "-"
  11005. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11006. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11007. // order.HilistLv = "1"
  11008. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11009. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11010. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11011. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11012. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11013. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11014. // order.OwnpayAmt = ""
  11015. // order.SelfpayAmt = ""
  11016. // order.Spec = ""
  11017. // order.SpecUnt = ""
  11018. // order.DrordBegnDate = s_tm
  11019. // order.DrordStopDate = ""
  11020. // order.DrordDrCodg = "1"
  11021. // order.DrordDeptName = department.Name
  11022. // order.DrordDrCodg = "1"
  11023. // order.DrordDrName = doctor_info.UserName
  11024. // order.DrordDrProfttl = ""
  11025. // order.CurrDrordFlag = "1"
  11026. // orders = append(orders, &order)
  11027. // }
  11028. // for _, subItem := range item.HisPrescriptionProject {
  11029. // if subItem.Type == 2 {
  11030. // var order models.FsiOrderDtos
  11031. // order.RxID = strconv.FormatInt(item.ID, 10)
  11032. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11033. // order.LongDrordFlag = "0"
  11034. // order.HilistType = "1"
  11035. // order.ChrgType = "1"
  11036. // order.DrordBhvr = "-"
  11037. // order.HilistCode = subItem.HisProject.MedicalCode
  11038. // order.HosplistName = subItem.HisProject.ProjectName
  11039. // order.HilistLv = "1"
  11040. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11041. // order.HosplistCode = subItem.HisProject.MedicalCode
  11042. // order.HosplistName = subItem.HisProject.ProjectName
  11043. // order.Cnt = subItem.Count
  11044. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11045. //
  11046. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11047. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11048. // order.OwnpayAmt = ""
  11049. // order.SelfpayAmt = ""
  11050. // order.Spec = ""
  11051. // order.SpecUnt = ""
  11052. // order.DrordBegnDate = s_tm
  11053. // order.DrordStopDate = ""
  11054. // order.DrordDrCodg = "1"
  11055. // order.DrordDeptName = department.Name
  11056. // order.DrordDrCodg = "1"
  11057. // order.DrordDrName = doctor_info.UserName
  11058. // order.DrordDrProfttl = ""
  11059. // order.CurrDrordFlag = "1"
  11060. // orders = append(orders, &order)
  11061. //
  11062. // }
  11063. // if subItem.Type == 3 {
  11064. //
  11065. // var order models.FsiOrderDtos
  11066. // order.RxID = strconv.FormatInt(item.ID, 10)
  11067. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11068. // order.LongDrordFlag = "0"
  11069. // order.HilistType = "1"
  11070. // order.ChrgType = "1"
  11071. // order.DrordBhvr = "-"
  11072. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11073. // order.HosplistName = subItem.GoodInfo.GoodName
  11074. // order.HilistLv = "1"
  11075. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11076. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11077. // order.HosplistName = subItem.GoodInfo.GoodName
  11078. // order.Cnt = subItem.Count
  11079. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11080. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11081. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11082. // order.OwnpayAmt = ""
  11083. // order.SelfpayAmt = ""
  11084. // order.Spec = ""
  11085. // order.SpecUnt = ""
  11086. // order.DrordBegnDate = s_tm
  11087. // order.DrordStopDate = ""
  11088. // order.DrordDrCodg = "1"
  11089. // order.DrordDeptName = department.Name
  11090. // order.DrordDrCodg = "1"
  11091. // order.DrordDrName = doctor_info.UserName
  11092. // order.DrordDrProfttl = ""
  11093. // order.CurrDrordFlag = "1"
  11094. // orders = append(orders, &order)
  11095. //
  11096. // }
  11097. // }
  11098. //}
  11099. for _, item := range prescriptions {
  11100. for _, subItem := range item.HisDoctorAdviceInfo {
  11101. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11102. var order models.FsiOrderDtos
  11103. order.RxID = strconv.FormatInt(item.ID, 10)
  11104. order.Rxno = strconv.FormatInt(item.ID, 10)
  11105. order.LongDrordFlag = "0"
  11106. order.HilistType = "101"
  11107. order.ChrgType = "1"
  11108. order.DrordBhvr = "-"
  11109. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11110. order.HosplistName = subItem.BaseDrugLib.DrugName
  11111. order.HilistLv = "1"
  11112. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11113. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11114. order.HosplistName = subItem.BaseDrugLib.DrugName
  11115. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11116. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11117. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11118. order.OwnpayAmt = ""
  11119. order.SelfpayAmt = ""
  11120. order.Spec = ""
  11121. order.SpecUnt = ""
  11122. order.DrordBegnDate = s_tm
  11123. order.DrordStopDate = ""
  11124. order.DrordDrCodg = doctor_info.DoctorNumber
  11125. order.DrordDeptName = department.Name
  11126. order.DrordDeptCodg = department.Number
  11127. order.DrordDrName = doctor_info.UserName
  11128. order.DrordDrProfttl = "234"
  11129. order.CurrDrordFlag = "1"
  11130. orders = append(orders, &order)
  11131. }
  11132. }
  11133. for _, subItem := range item.HisPrescriptionProject {
  11134. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11135. var order models.FsiOrderDtos
  11136. order.RxID = strconv.FormatInt(item.ID, 10)
  11137. order.Rxno = strconv.FormatInt(item.ID, 10)
  11138. order.LongDrordFlag = "0"
  11139. order.HilistType = "201"
  11140. order.ChrgType = "1"
  11141. order.DrordBhvr = "-"
  11142. order.HilistCode = subItem.HisProject.MedicalCode
  11143. order.HosplistName = subItem.HisProject.ProjectName
  11144. order.HilistLv = "1"
  11145. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11146. order.HosplistCode = subItem.HisProject.MedicalCode
  11147. order.HosplistName = subItem.HisProject.ProjectName
  11148. order.Cnt = subItem.Count
  11149. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11150. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11151. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11152. order.OwnpayAmt = ""
  11153. order.SelfpayAmt = ""
  11154. order.Spec = ""
  11155. order.SpecUnt = ""
  11156. order.DrordBegnDate = s_tm
  11157. order.DrordStopDate = ""
  11158. order.DrordDrCodg = doctor_info.DoctorNumber
  11159. order.DrordDeptName = department.Name
  11160. order.DrordDeptCodg = department.Number
  11161. order.DrordDrName = doctor_info.UserName
  11162. order.DrordDrProfttl = "234"
  11163. order.CurrDrordFlag = "1"
  11164. orders = append(orders, &order)
  11165. }
  11166. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11167. var order models.FsiOrderDtos
  11168. order.RxID = strconv.FormatInt(item.ID, 10)
  11169. order.Rxno = strconv.FormatInt(item.ID, 10)
  11170. order.LongDrordFlag = "0"
  11171. order.HilistType = "301"
  11172. order.ChrgType = "1"
  11173. order.DrordBhvr = "0"
  11174. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11175. order.HosplistName = subItem.GoodInfo.GoodName
  11176. order.HilistLv = "1"
  11177. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11178. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11179. order.HosplistName = subItem.GoodInfo.GoodName
  11180. order.Cnt = subItem.Count
  11181. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11182. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11183. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  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. }
  11200. //处方医嘱信息
  11201. fed.MatnStas = "0"
  11202. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11203. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11204. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11205. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11206. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11207. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11208. fed.SetlTotlnum = "1"
  11209. fed.Insutype = his.Insutype
  11210. fed.ReimFlag = "0"
  11211. fed.OutSetlFlag = "0"
  11212. var fopd []*models.FsiOperationDtosData
  11213. data := make(map[string]interface{})
  11214. data["fed"] = fed
  11215. data["fdd"] = fdds
  11216. data["fod"] = orders
  11217. data["pd"] = pd
  11218. data["pp"] = pp
  11219. data["fopd"] = fopd
  11220. data["trig_scen"] = trig_scen
  11221. client := &http.Client{}
  11222. bytesData, _ := json.Marshal(data)
  11223. var req *http.Request
  11224. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11225. if miConfig.MdtrtareaAdmvs == "320921" {
  11226. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11227. } else {
  11228. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11229. }
  11230. resp, _ := client.Do(req)
  11231. defer resp.Body.Close()
  11232. body, ioErr := ioutil.ReadAll(resp.Body)
  11233. if ioErr != nil {
  11234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11236. return res
  11237. }
  11238. var respJSON map[string]interface{}
  11239. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11242. return res
  11243. }
  11244. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11245. result, _ := json.Marshal(respJSON)
  11246. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11247. utils.ErrorLog("解析失败:%v", err)
  11248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11249. return res
  11250. }
  11251. return res
  11252. } else {
  11253. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11254. saveLog(output, input, "3102", "事中")
  11255. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11256. utils.ErrorLog("解析失败:%v", err)
  11257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11258. return
  11259. }
  11260. return res
  11261. }
  11262. return res
  11263. }
  11264. 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) {
  11265. var res Resultgd3101
  11266. adminUser := c.GetAdminUserInfo()
  11267. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11268. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11269. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11270. //record_time := c.GetString("record_time")
  11271. //trig_scen := c.GetString("trig_scen")
  11272. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11273. //psn_info, _ := service.GetPatientId(patient_id)
  11274. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11275. timeLayout := "2006-01-02"
  11276. loc, _ := time.LoadLocation("Local")
  11277. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11278. if err != nil {
  11279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11280. return res
  11281. }
  11282. recordDateTime := theTime.Unix()
  11283. var patientPrescription models.HisPrescriptionInfo
  11284. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11285. //if patientPrescription.ID == 0 {
  11286. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11287. //}
  11288. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11289. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11290. //
  11291. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11292. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11293. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11294. var pp models.PublicParams
  11295. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11296. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11297. pp.FixmedinsName = miConfig.OrgName
  11298. pp.FixmedinsCode = miConfig.Code
  11299. pp.RequestUrl = miConfig.Url
  11300. pp.Cainfo = miConfig.Cainfo
  11301. pp.SecretKey = miConfig.SecretKey
  11302. pp.AccessKey = miConfig.AccessKey
  11303. pp.OpterName = roles.UserName
  11304. var config []*models.HisXtDiagnoseConfig
  11305. for _, item := range diagnosis_ids {
  11306. id, _ := strconv.ParseInt(item, 10, 64)
  11307. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11308. config = append(config, &diagnosisConfig)
  11309. }
  11310. var pd models.PatientDtos
  11311. pd.PatnID = his.PsnNo
  11312. pd.PatnName = his.Name
  11313. pd.Gend = his.Gend
  11314. pd.Brdy = str
  11315. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11316. pd.CurrMdtrtID = his.Number
  11317. var fed models.FsiEncounterDtos
  11318. fed.MdtrtID = his.Number
  11319. fed.MedinsID = miConfig.Code
  11320. fed.MedinsName = miConfig.OrgName
  11321. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11322. fed.MedMdtrtType = "1"
  11323. fed.MedinsType = "1"
  11324. fed.MedinsLv = "11"
  11325. tm := time.Unix(his.RecordDate, 0)
  11326. s_tm := tm.Format("2006-01-02 15:04:05")
  11327. fed.AdmDate = s_tm
  11328. fed.DscgDate = s_tm
  11329. fed.DscgMainDiseCodg = config[0].CountryCode
  11330. fed.DscgMainDiseName = config[0].CountryContentName
  11331. //诊断信息
  11332. var fdds []*models.FsiDiagnoseDtos
  11333. for index, item := range config {
  11334. if index == 0 {
  11335. var fdd models.FsiDiagnoseDtos
  11336. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11337. fdd.InoutDiseType = "1"
  11338. fdd.MaindiseFlag = "1"
  11339. fdd.DiseDate = s_tm
  11340. fdd.DiasSrtNo = "1"
  11341. fdd.DiseName = item.CountryContentName
  11342. fdd.DiseCodg = item.CountryCode
  11343. fdds = append(fdds, &fdd)
  11344. } else {
  11345. var fdd models.FsiDiagnoseDtos
  11346. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11347. fdd.InoutDiseType = "1"
  11348. fdd.MaindiseFlag = "1"
  11349. fdd.DiseDate = s_tm
  11350. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11351. fdd.DiseName = item.CountryContentName
  11352. fdd.DiseCodg = item.CountryCode
  11353. fdds = append(fdds, &fdd)
  11354. }
  11355. }
  11356. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11357. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11358. fed.AdmDeptName = de.Name
  11359. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11360. fed.DscgDeptName = de.Name
  11361. fed.MedMdtrtType = "1"
  11362. fed.MedType = "11"
  11363. //if his.Insutype == "390" {
  11364. // fed.MedType = "1402"
  11365. //} else {
  11366. // fed.MedType = "9933"
  11367. //}
  11368. var orders []*models.FsiOrderDtos
  11369. if trig_scen == "2" {
  11370. //处方医嘱信息
  11371. for _, item := range prescriptions {
  11372. for _, subItem := range item.HisDoctorAdviceInfo {
  11373. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11374. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11375. var order models.FsiOrderDtos
  11376. order.RxID = strconv.FormatInt(item.ID, 10)
  11377. order.Rxno = strconv.FormatInt(item.ID, 10)
  11378. order.LongDrordFlag = "0"
  11379. order.HilistType = "101"
  11380. order.ChrgType = "1"
  11381. order.DrordBhvr = "0"
  11382. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11383. order.HosplistName = subItem.BaseDrugLib.DrugName
  11384. order.HilistLv = "1"
  11385. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11386. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11387. order.HosplistName = subItem.BaseDrugLib.DrugName
  11388. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11389. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11390. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11391. order.OwnpayAmt = ""
  11392. order.SelfpayAmt = ""
  11393. order.Spec = spec
  11394. order.SpecUnt = subItem.PrescribingNumberUnit
  11395. order.DrordBegnDate = s_tm
  11396. order.DrordStopDate = ""
  11397. order.DrordDrCodg = doctor_info.DoctorNumber
  11398. order.DrordDeptName = department.Name
  11399. order.DrordDeptCodg = department.Number
  11400. order.DrordDrName = doctor_info.UserName
  11401. order.DrordDrProfttl = "234"
  11402. order.CurrDrordFlag = "1"
  11403. orders = append(orders, &order)
  11404. }
  11405. }
  11406. for _, subItem := range item.HisPrescriptionProject {
  11407. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11408. var order models.FsiOrderDtos
  11409. order.RxID = strconv.FormatInt(item.ID, 10)
  11410. order.Rxno = strconv.FormatInt(item.ID, 10)
  11411. order.LongDrordFlag = "0"
  11412. order.HilistType = "201"
  11413. order.ChrgType = "1"
  11414. order.DrordBhvr = "0"
  11415. order.HilistCode = subItem.HisProject.MedicalCode
  11416. order.HosplistName = subItem.HisProject.ProjectName
  11417. order.HilistLv = "1"
  11418. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11419. order.HosplistCode = subItem.HisProject.MedicalCode
  11420. order.HosplistName = subItem.HisProject.ProjectName
  11421. order.Cnt = subItem.Count
  11422. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11423. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11424. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11425. order.OwnpayAmt = ""
  11426. order.SelfpayAmt = ""
  11427. order.Spec = subItem.Unit
  11428. order.SpecUnt = subItem.Unit
  11429. order.DrordBegnDate = s_tm
  11430. order.DrordStopDate = ""
  11431. order.DrordDrCodg = doctor_info.DoctorNumber
  11432. order.DrordDeptName = department.Name
  11433. order.DrordDeptCodg = department.Number
  11434. order.DrordDrName = doctor_info.UserName
  11435. order.DrordDrProfttl = "234"
  11436. order.CurrDrordFlag = "1"
  11437. orders = append(orders, &order)
  11438. }
  11439. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11440. var order models.FsiOrderDtos
  11441. order.RxID = strconv.FormatInt(item.ID, 10)
  11442. order.Rxno = strconv.FormatInt(item.ID, 10)
  11443. order.LongDrordFlag = "0"
  11444. order.HilistType = "301"
  11445. order.ChrgType = "1"
  11446. order.DrordBhvr = "0"
  11447. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11448. order.HosplistName = subItem.GoodInfo.GoodName
  11449. order.HilistLv = "1"
  11450. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11451. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11452. order.HosplistName = subItem.GoodInfo.GoodName
  11453. order.Cnt = subItem.Count
  11454. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11455. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11456. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11457. order.OwnpayAmt = ""
  11458. order.SelfpayAmt = ""
  11459. order.Spec = subItem.GoodInfo.SpecificationName
  11460. order.SpecUnt = subItem.Unit
  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. }
  11473. //处方医嘱信息
  11474. }
  11475. fed.MatnStas = "0"
  11476. fed.MedfeeSumamt = "0"
  11477. fed.OwnpayAmt = "0"
  11478. fed.SelfpayAmt = "0"
  11479. fed.AcctPayamt = "0"
  11480. fed.MaAmt = "0"
  11481. fed.HifpPayamt = "0"
  11482. fed.SetlTotlnum = "1"
  11483. fed.Insutype = his.Insutype
  11484. fed.ReimFlag = "0"
  11485. fed.OutSetlFlag = "0"
  11486. var fopd []*models.FsiOperationDtosData
  11487. data := make(map[string]interface{})
  11488. data["fed"] = fed
  11489. data["fdd"] = fdds
  11490. data["fod"] = orders
  11491. data["pd"] = pd
  11492. data["pp"] = pp
  11493. data["fopd"] = fopd
  11494. data["trig_scen"] = trig_scen
  11495. fmt.Println(data)
  11496. fmt.Println(fed)
  11497. fmt.Println(fdds)
  11498. fmt.Println(orders)
  11499. fmt.Println(pd)
  11500. fmt.Println(pp)
  11501. fmt.Println(fopd)
  11502. client := &http.Client{}
  11503. bytesData, _ := json.Marshal(data)
  11504. var req *http.Request
  11505. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11506. if miConfig.MdtrtareaAdmvs == "320921" {
  11507. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11508. } else {
  11509. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11510. }
  11511. resp, _ := client.Do(req)
  11512. defer resp.Body.Close()
  11513. body, ioErr := ioutil.ReadAll(resp.Body)
  11514. if ioErr != nil {
  11515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11517. return res
  11518. }
  11519. var respJSON map[string]interface{}
  11520. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11523. return res
  11524. }
  11525. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11526. fmt.Println(respJSON)
  11527. result, _ := json.Marshal(respJSON)
  11528. fmt.Println(result)
  11529. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11530. utils.ErrorLog("解析失败:%v", err)
  11531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11532. return res
  11533. }
  11534. return res
  11535. } else {
  11536. //if miConfig.MdtrtareaAdmvs == "441202" {
  11537. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11538. saveLog(output, input, "3101", "事前")
  11539. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11540. utils.ErrorLog("解析失败:%v", err)
  11541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11542. return
  11543. }
  11544. return res
  11545. //}
  11546. }
  11547. }
  11548. 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) {
  11549. adminUser := c.GetAdminUserInfo()
  11550. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11551. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11552. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11553. //record_time := c.GetString("record_time")
  11554. //trig_scen := c.GetString("trig_scen")
  11555. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11556. timeLayout := "2006-01-02"
  11557. loc, _ := time.LoadLocation("Local")
  11558. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11559. if err != nil {
  11560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11561. return res
  11562. }
  11563. recordDateTime := theTime.Unix()
  11564. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11565. var patientPrescription models.HisPrescriptionInfo
  11566. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11567. if patientPrescription.ID == 0 {
  11568. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11569. }
  11570. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11571. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11572. //
  11573. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11574. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11575. var pp models.PublicParams
  11576. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11577. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11578. pp.FixmedinsName = miConfig.OrgName
  11579. pp.FixmedinsCode = miConfig.Code
  11580. pp.RequestUrl = miConfig.Url
  11581. pp.Cainfo = miConfig.Cainfo
  11582. pp.SecretKey = miConfig.SecretKey
  11583. pp.AccessKey = miConfig.AccessKey
  11584. pp.OpterName = roles.UserName
  11585. var config []*models.HisXtDiagnoseConfig
  11586. for _, item := range diagnosis_ids {
  11587. id, _ := strconv.ParseInt(item, 10, 64)
  11588. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11589. config = append(config, &diagnosisConfig)
  11590. }
  11591. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11592. var pd models.PatientDtos
  11593. pd.PatnID = his.PsnNo
  11594. pd.PatnName = his.Name
  11595. pd.Gend = his.Gend
  11596. pd.Brdy = str
  11597. pd.Poolarea = his.InsuplcAdmdvs
  11598. pd.CurrMdtrtID = his.Number
  11599. var fed models.FsiEncounterDtos
  11600. fed.MdtrtID = his.Number
  11601. fed.MedinsID = miConfig.Code
  11602. fed.MedinsName = miConfig.OrgName
  11603. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11604. fed.MedMdtrtType = "1"
  11605. fed.MedinsType = "1"
  11606. fed.MedinsLv = "11"
  11607. tm := time.Unix(his.RecordDate, 0)
  11608. s_tm := tm.Format("2006-01-02 15:04:05")
  11609. fed.AdmDate = s_tm
  11610. fed.DscgDate = s_tm
  11611. fed.DscgMainDiseCodg = config[0].CountryCode
  11612. fed.DscgMainDiseName = config[0].CountryContentName
  11613. //诊断信息
  11614. var fdds []*models.FsiDiagnoseDtos
  11615. for index, item := range config {
  11616. if index == 0 {
  11617. var fdd models.FsiDiagnoseDtos
  11618. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11619. fdd.InoutDiseType = "1"
  11620. fdd.MaindiseFlag = "1"
  11621. fdd.DiseDate = s_tm
  11622. fdd.DiasSrtNo = "1"
  11623. fdd.DiseName = item.CountryContentName
  11624. fdd.DiseCodg = item.CountryCode
  11625. fdds = append(fdds, &fdd)
  11626. } else {
  11627. var fdd models.FsiDiagnoseDtos
  11628. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11629. fdd.InoutDiseType = "1"
  11630. fdd.MaindiseFlag = "1"
  11631. fdd.DiseDate = s_tm
  11632. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11633. fdd.DiseName = item.CountryContentName
  11634. fdd.DiseCodg = item.CountryCode
  11635. fdds = append(fdds, &fdd)
  11636. }
  11637. }
  11638. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11639. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11640. fed.AdmDeptName = department.Name
  11641. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11642. fed.DscgDeptName = department.Name
  11643. fed.MedMdtrtType = "1"
  11644. fed.MedType = "11"
  11645. //if his.Insutype == "390" {
  11646. // fed.MedType = "1402"
  11647. //} else {
  11648. // fed.MedType = "9933"
  11649. //}
  11650. var orders []*models.FsiOrderDtos
  11651. if trig_scen == "2" {
  11652. //处方医嘱信息
  11653. for _, item := range prescriptions {
  11654. for _, subItem := range item.HisDoctorAdviceInfo {
  11655. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11656. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11657. var order models.FsiOrderDtos
  11658. order.RxID = strconv.FormatInt(item.ID, 10)
  11659. order.Rxno = strconv.FormatInt(item.ID, 10)
  11660. order.LongDrordFlag = "0"
  11661. order.HilistType = "101"
  11662. order.ChrgType = "1"
  11663. order.DrordBhvr = "0"
  11664. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11665. order.HosplistName = subItem.BaseDrugLib.DrugName
  11666. order.HilistLv = "1"
  11667. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11668. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11669. order.HosplistName = subItem.BaseDrugLib.DrugName
  11670. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11671. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11672. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11673. order.OwnpayAmt = ""
  11674. order.SelfpayAmt = ""
  11675. order.Spec = spec
  11676. order.SpecUnt = subItem.PrescribingNumberUnit
  11677. order.DrordBegnDate = s_tm
  11678. order.DrordStopDate = ""
  11679. order.DrordDrCodg = doctor_info.DoctorNumber
  11680. order.DrordDeptName = department.Name
  11681. order.DrordDeptCodg = department.Number
  11682. order.DrordDrName = doctor_info.UserName
  11683. order.DrordDrProfttl = "234"
  11684. order.CurrDrordFlag = "1"
  11685. orders = append(orders, &order)
  11686. }
  11687. }
  11688. for _, subItem := range item.HisPrescriptionProject {
  11689. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11690. var order models.FsiOrderDtos
  11691. order.RxID = strconv.FormatInt(item.ID, 10)
  11692. order.Rxno = strconv.FormatInt(item.ID, 10)
  11693. order.LongDrordFlag = "0"
  11694. order.HilistType = "201"
  11695. order.ChrgType = "1"
  11696. order.DrordBhvr = "0"
  11697. order.HilistCode = subItem.HisProject.MedicalCode
  11698. order.HosplistName = subItem.HisProject.ProjectName
  11699. order.HilistLv = "1"
  11700. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11701. order.HosplistCode = subItem.HisProject.MedicalCode
  11702. order.HosplistName = subItem.HisProject.ProjectName
  11703. order.Cnt = subItem.Count
  11704. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11705. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11706. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11707. order.OwnpayAmt = ""
  11708. order.SelfpayAmt = ""
  11709. order.Spec = subItem.Unit
  11710. order.SpecUnt = subItem.Unit
  11711. order.DrordBegnDate = s_tm
  11712. order.DrordStopDate = ""
  11713. order.DrordDrCodg = doctor_info.DoctorNumber
  11714. order.DrordDeptName = department.Name
  11715. order.DrordDeptCodg = department.Number
  11716. order.DrordDrName = doctor_info.UserName
  11717. order.DrordDrProfttl = "234"
  11718. order.CurrDrordFlag = "1"
  11719. orders = append(orders, &order)
  11720. }
  11721. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11722. var order models.FsiOrderDtos
  11723. order.RxID = strconv.FormatInt(item.ID, 10)
  11724. order.Rxno = strconv.FormatInt(item.ID, 10)
  11725. order.LongDrordFlag = "0"
  11726. order.HilistType = "301"
  11727. order.ChrgType = "1"
  11728. order.DrordBhvr = "0"
  11729. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11730. order.HosplistName = subItem.GoodInfo.GoodName
  11731. order.HilistLv = "1"
  11732. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11733. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11734. order.HosplistName = subItem.GoodInfo.GoodName
  11735. order.Cnt = subItem.Count
  11736. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11737. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11738. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11739. order.OwnpayAmt = ""
  11740. order.SelfpayAmt = ""
  11741. order.Spec = subItem.GoodInfo.SpecificationName
  11742. order.SpecUnt = subItem.Unit
  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. }
  11755. //处方医嘱信息
  11756. }
  11757. fed.MatnStas = "0"
  11758. fed.MedfeeSumamt = "0"
  11759. fed.OwnpayAmt = "0"
  11760. fed.SelfpayAmt = "0"
  11761. fed.AcctPayamt = "0"
  11762. fed.MaAmt = "0"
  11763. fed.HifpPayamt = "0"
  11764. fed.SetlTotlnum = "1"
  11765. fed.Insutype = his.Insutype
  11766. fed.ReimFlag = "0"
  11767. fed.OutSetlFlag = "0"
  11768. var fopd []*models.FsiOperationDtosData
  11769. data := make(map[string]interface{})
  11770. data["fed"] = fed
  11771. data["fdd"] = fdds
  11772. data["fod"] = orders
  11773. data["pd"] = pd
  11774. data["pp"] = pp
  11775. data["fopd"] = fopd
  11776. data["trig_scen"] = trig_scen
  11777. fmt.Println(data)
  11778. fmt.Println(fed)
  11779. fmt.Println(fdds)
  11780. fmt.Println(orders)
  11781. fmt.Println(pd)
  11782. fmt.Println(pp)
  11783. fmt.Println(fopd)
  11784. client := &http.Client{}
  11785. bytesData, _ := json.Marshal(data)
  11786. var req *http.Request
  11787. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11788. if miConfig.MdtrtareaAdmvs == "320921" {
  11789. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11790. } else {
  11791. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11792. }
  11793. resp, _ := client.Do(req)
  11794. defer resp.Body.Close()
  11795. body, ioErr := ioutil.ReadAll(resp.Body)
  11796. if ioErr != nil {
  11797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11799. return res
  11800. }
  11801. var respJSON map[string]interface{}
  11802. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11805. return res
  11806. }
  11807. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11808. fmt.Println(respJSON)
  11809. result, _ := json.Marshal(respJSON)
  11810. fmt.Println(result)
  11811. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11812. utils.ErrorLog("解析失败:%v", err)
  11813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11814. return res
  11815. }
  11816. return res
  11817. } else {
  11818. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11819. saveLog(output, input, "3101", "事前")
  11820. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11821. utils.ErrorLog("解析失败:%v", err)
  11822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11823. return
  11824. }
  11825. return res
  11826. }
  11827. return res
  11828. }
  11829. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11830. adminUser := c.GetAdminUserInfo()
  11831. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11832. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11833. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11834. record_time := c.GetString("record_time")
  11835. order, _ := service.GetHisOrderByID(order_id)
  11836. timeLayout := "2006-01-02"
  11837. loc, _ := time.LoadLocation("Local")
  11838. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11839. if err != nil {
  11840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11841. return
  11842. }
  11843. recordDateTime := theTime.Unix()
  11844. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11845. var patientPrescription models.HisPrescriptionInfo
  11846. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11847. if patientPrescription.ID == 0 {
  11848. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11849. }
  11850. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11851. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11852. //
  11853. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11854. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11855. var pp models.PublicParams
  11856. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11857. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11858. pp.FixmedinsName = miConfig.OrgName
  11859. pp.FixmedinsCode = miConfig.Code
  11860. pp.RequestUrl = miConfig.Url
  11861. pp.Cainfo = miConfig.Cainfo
  11862. pp.SecretKey = miConfig.SecretKey
  11863. pp.AccessKey = miConfig.AccessKey
  11864. pp.OpterName = roles.UserName
  11865. var config []*models.HisXtDiagnoseConfig
  11866. for _, item := range diagnosis_ids {
  11867. id, _ := strconv.ParseInt(item, 10, 64)
  11868. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11869. config = append(config, &diagnosisConfig)
  11870. }
  11871. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11872. var pd models.PatientDtos
  11873. pd.PatnID = his.PsnNo
  11874. pd.PatnName = his.Name
  11875. pd.Gend = his.Gend
  11876. pd.Brdy = str
  11877. pd.Poolarea = his.InsuplcAdmdvs
  11878. pd.CurrMdtrtID = his.Number
  11879. var fed models.FsiEncounterDtos
  11880. fed.MdtrtID = his.Number
  11881. fed.MedinsID = miConfig.Code
  11882. fed.MedinsName = miConfig.OrgName
  11883. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11884. fed.MedMdtrtType = "1"
  11885. fed.MedinsType = "1"
  11886. fed.MedinsLv = "11"
  11887. tm := time.Unix(his.RecordDate, 0)
  11888. s_tm := tm.Format("2006-01-02 15:04:05")
  11889. fed.AdmDate = s_tm
  11890. fed.DscgDate = s_tm
  11891. fed.DscgMainDiseCodg = config[0].CountryCode
  11892. fed.DscgMainDiseName = config[0].CountryContentName
  11893. //诊断信息
  11894. var fdds []*models.FsiDiagnoseDtos
  11895. for index, item := range config {
  11896. if index == 0 {
  11897. var fdd models.FsiDiagnoseDtos
  11898. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11899. fdd.InoutDiseType = "1"
  11900. fdd.MaindiseFlag = "1"
  11901. fdd.DiseDate = s_tm
  11902. fdd.DiasSrtNo = "1"
  11903. fdd.DiseName = item.CountryContentName
  11904. fdd.DiseCodg = item.CountryCode
  11905. fdds = append(fdds, &fdd)
  11906. } else {
  11907. var fdd models.FsiDiagnoseDtos
  11908. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11909. fdd.InoutDiseType = "1"
  11910. fdd.MaindiseFlag = "1"
  11911. fdd.DiseDate = s_tm
  11912. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11913. fdd.DiseName = item.CountryContentName
  11914. fdd.DiseCodg = item.CountryCode
  11915. fdds = append(fdds, &fdd)
  11916. }
  11917. }
  11918. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11919. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11920. fed.AdmDeptName = department.Name
  11921. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11922. fed.DscgDeptName = department.Name
  11923. fed.MedType = order.MedType
  11924. //处方医嘱信息
  11925. var orders []*models.FsiOrderDtos
  11926. //for _, item := range prescriptions {
  11927. // for _, subItem := range item.HisDoctorAdviceInfo {
  11928. // var order models.FsiOrderDtos
  11929. // order.RxID = strconv.FormatInt(item.ID, 10)
  11930. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11931. // order.LongDrordFlag = "0"
  11932. // order.HilistType = "1"
  11933. // order.ChrgType = "1"
  11934. // order.DrordBhvr = "-"
  11935. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11936. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11937. // order.HilistLv = "1"
  11938. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11939. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11940. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11941. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11942. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11943. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11944. // order.OwnpayAmt = ""
  11945. // order.SelfpayAmt = ""
  11946. // order.Spec = ""
  11947. // order.SpecUnt = ""
  11948. // order.DrordBegnDate = s_tm
  11949. // order.DrordStopDate = ""
  11950. // order.DrordDrCodg = "1"
  11951. // order.DrordDeptName = department.Name
  11952. // order.DrordDrCodg = "1"
  11953. // order.DrordDrName = doctor_info.UserName
  11954. // order.DrordDrProfttl = ""
  11955. // order.CurrDrordFlag = "1"
  11956. // orders = append(orders, &order)
  11957. // }
  11958. // for _, subItem := range item.HisPrescriptionProject {
  11959. // if subItem.Type == 2 {
  11960. // var order models.FsiOrderDtos
  11961. // order.RxID = strconv.FormatInt(item.ID, 10)
  11962. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11963. // order.LongDrordFlag = "0"
  11964. // order.HilistType = "1"
  11965. // order.ChrgType = "1"
  11966. // order.DrordBhvr = "-"
  11967. // order.HilistCode = subItem.HisProject.MedicalCode
  11968. // order.HosplistName = subItem.HisProject.ProjectName
  11969. // order.HilistLv = "1"
  11970. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11971. // order.HosplistCode = subItem.HisProject.MedicalCode
  11972. // order.HosplistName = subItem.HisProject.ProjectName
  11973. // order.Cnt = subItem.Count
  11974. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11975. //
  11976. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11977. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11978. // order.OwnpayAmt = ""
  11979. // order.SelfpayAmt = ""
  11980. // order.Spec = ""
  11981. // order.SpecUnt = ""
  11982. // order.DrordBegnDate = s_tm
  11983. // order.DrordStopDate = ""
  11984. // order.DrordDrCodg = "1"
  11985. // order.DrordDeptName = department.Name
  11986. // order.DrordDrCodg = "1"
  11987. // order.DrordDrName = doctor_info.UserName
  11988. // order.DrordDrProfttl = ""
  11989. // order.CurrDrordFlag = "1"
  11990. // orders = append(orders, &order)
  11991. //
  11992. // }
  11993. // if subItem.Type == 3 {
  11994. //
  11995. // var order models.FsiOrderDtos
  11996. // order.RxID = strconv.FormatInt(item.ID, 10)
  11997. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11998. // order.LongDrordFlag = "0"
  11999. // order.HilistType = "1"
  12000. // order.ChrgType = "1"
  12001. // order.DrordBhvr = "-"
  12002. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12003. // order.HosplistName = subItem.GoodInfo.GoodName
  12004. // order.HilistLv = "1"
  12005. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12006. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12007. // order.HosplistName = subItem.GoodInfo.GoodName
  12008. // order.Cnt = subItem.Count
  12009. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12010. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12011. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12012. // order.OwnpayAmt = ""
  12013. // order.SelfpayAmt = ""
  12014. // order.Spec = ""
  12015. // order.SpecUnt = ""
  12016. // order.DrordBegnDate = s_tm
  12017. // order.DrordStopDate = ""
  12018. // order.DrordDrCodg = "1"
  12019. // order.DrordDeptName = department.Name
  12020. // order.DrordDrCodg = "1"
  12021. // order.DrordDrName = doctor_info.UserName
  12022. // order.DrordDrProfttl = ""
  12023. // order.CurrDrordFlag = "1"
  12024. // orders = append(orders, &order)
  12025. //
  12026. // }
  12027. // }
  12028. //}
  12029. for _, item := range prescriptions {
  12030. for _, subItem := range item.HisDoctorAdviceInfo {
  12031. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12032. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12033. var order models.FsiOrderDtos
  12034. order.RxID = strconv.FormatInt(item.ID, 10)
  12035. order.Rxno = strconv.FormatInt(item.ID, 10)
  12036. order.LongDrordFlag = "0"
  12037. order.HilistType = "101"
  12038. order.ChrgType = "01"
  12039. order.DrordBhvr = "0"
  12040. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12041. order.HosplistName = subItem.BaseDrugLib.DrugName
  12042. order.HilistLv = "1"
  12043. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12044. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12045. order.HosplistName = subItem.BaseDrugLib.DrugName
  12046. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12047. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12048. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12049. order.OwnpayAmt = ""
  12050. order.SelfpayAmt = ""
  12051. order.Spec = spec
  12052. order.SpecUnt = subItem.PrescribingNumberUnit
  12053. order.DrordBegnDate = s_tm
  12054. order.DrordStopDate = ""
  12055. order.DrordDrCodg = doctor_info.DoctorNumber
  12056. order.DrordDeptName = department.Name
  12057. order.DrordDeptCodg = department.Number
  12058. order.DrordDrName = doctor_info.UserName
  12059. order.DrordDrProfttl = "234"
  12060. order.CurrDrordFlag = "1"
  12061. orders = append(orders, &order)
  12062. }
  12063. }
  12064. for _, subItem := range item.HisPrescriptionProject {
  12065. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12066. var order models.FsiOrderDtos
  12067. order.RxID = strconv.FormatInt(item.ID, 10)
  12068. order.Rxno = strconv.FormatInt(item.ID, 10)
  12069. order.LongDrordFlag = "0"
  12070. order.HilistType = "201"
  12071. order.ChrgType = "05"
  12072. order.DrordBhvr = "0"
  12073. order.HilistCode = subItem.HisProject.MedicalCode
  12074. order.HosplistName = subItem.HisProject.ProjectName
  12075. order.HilistLv = "1"
  12076. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12077. order.HosplistCode = subItem.HisProject.MedicalCode
  12078. order.HosplistName = subItem.HisProject.ProjectName
  12079. order.Cnt = subItem.Count
  12080. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12081. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12082. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12083. order.OwnpayAmt = ""
  12084. order.SelfpayAmt = ""
  12085. order.Spec = subItem.Unit
  12086. order.SpecUnt = subItem.Unit
  12087. order.DrordBegnDate = s_tm
  12088. order.DrordStopDate = ""
  12089. order.DrordDrCodg = doctor_info.DoctorNumber
  12090. order.DrordDeptName = department.Name
  12091. order.DrordDeptCodg = department.Number
  12092. order.DrordDrName = doctor_info.UserName
  12093. order.DrordDrProfttl = "234"
  12094. order.CurrDrordFlag = "1"
  12095. orders = append(orders, &order)
  12096. }
  12097. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12098. var order models.FsiOrderDtos
  12099. order.RxID = strconv.FormatInt(item.ID, 10)
  12100. order.Rxno = strconv.FormatInt(item.ID, 10)
  12101. order.LongDrordFlag = "0"
  12102. order.HilistType = "301"
  12103. order.ChrgType = "08"
  12104. order.DrordBhvr = "0"
  12105. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12106. order.HosplistName = subItem.GoodInfo.GoodName
  12107. order.HilistLv = "1"
  12108. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12109. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12110. order.HosplistName = subItem.GoodInfo.GoodName
  12111. order.Cnt = subItem.Count
  12112. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12113. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12114. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12115. order.OwnpayAmt = ""
  12116. order.SelfpayAmt = ""
  12117. order.Spec = subItem.GoodInfo.SpecificationName
  12118. order.SpecUnt = subItem.Unit
  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. }
  12131. //处方医嘱信息
  12132. fed.MatnStas = "0"
  12133. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12134. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12135. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12136. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12137. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12138. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12139. fed.SetlTotlnum = "1"
  12140. fed.Insutype = his.Insutype
  12141. fed.ReimFlag = "0"
  12142. fed.OutSetlFlag = "0"
  12143. var fopd []*models.FsiOperationDtosData
  12144. data := make(map[string]interface{})
  12145. data["fed"] = fed
  12146. data["fdd"] = fdds
  12147. data["fod"] = orders
  12148. data["pd"] = pd
  12149. data["pp"] = pp
  12150. data["fopd"] = fopd
  12151. data["trig_scen"] = trig_scen
  12152. client := &http.Client{}
  12153. bytesData, _ := json.Marshal(data)
  12154. var req *http.Request
  12155. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12156. if miConfig.MdtrtareaAdmvs == "320921" {
  12157. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12158. } else {
  12159. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12160. }
  12161. resp, _ := client.Do(req)
  12162. defer resp.Body.Close()
  12163. body, ioErr := ioutil.ReadAll(resp.Body)
  12164. if ioErr != nil {
  12165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12167. return res
  12168. }
  12169. var respJSON map[string]interface{}
  12170. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12173. return res
  12174. }
  12175. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12176. result, _ := json.Marshal(respJSON)
  12177. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12178. utils.ErrorLog("解析失败:%v", err)
  12179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12180. return res
  12181. }
  12182. return res
  12183. } else {
  12184. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12185. saveLog(output, input, "3102", "事中")
  12186. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12187. utils.ErrorLog("解析失败:%v", err)
  12188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12189. return
  12190. }
  12191. return res
  12192. }
  12193. return res
  12194. }
  12195. func (c *HisApiController) Check() {
  12196. psn_no := c.GetString("psn_no")
  12197. in := c.GetString("in")
  12198. mt := c.GetString("mt")
  12199. baseParams := models.BaseParams{
  12200. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12201. FixmedinsCode: "H15049901371",
  12202. InsuplcAdmdvs: "150499",
  12203. MdtrtareaAdmvs: "150499",
  12204. OrgName: "赤峰费森血液透析中心",
  12205. Doctor: "1111",
  12206. }
  12207. service.Gdyb2001(baseParams, psn_no, in, mt)
  12208. }
  12209. func (c *HisApiController) GetPsnNcdsInfo() {
  12210. admin_user_id, _ := c.GetInt64("admin_user_id")
  12211. patient_id, _ := c.GetInt64("patient_id")
  12212. //id, _ := c.GetInt64("id")
  12213. adminUser := c.GetAdminUserInfo()
  12214. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12215. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12216. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12217. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12218. //psn_record, _ := service.GetP(id)
  12219. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12220. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12221. //
  12222. //if psn_record.ID == 0 {
  12223. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12224. // return
  12225. //}
  12226. var res Result5301
  12227. var res10265 Result5301For10265
  12228. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12229. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12230. var api string
  12231. if miConfig.MdtrtareaAdmvs == "320921" {
  12232. 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 +
  12233. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12234. } else {
  12235. 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 +
  12236. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12237. }
  12238. resp, requestErr := http.Get(api)
  12239. if requestErr != nil {
  12240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12241. return
  12242. }
  12243. body, ioErr := ioutil.ReadAll(resp.Body)
  12244. if ioErr != nil {
  12245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12247. return
  12248. }
  12249. var respJSON map[string]interface{}
  12250. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12253. return
  12254. }
  12255. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12256. result, _ := json.Marshal(respJSON)
  12257. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12258. utils.ErrorLog("解析失败:%v", err)
  12259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12260. return
  12261. }
  12262. res.ErrMsg = res10265.ErrMsg
  12263. res.Output = res10265.Output
  12264. res.InfRefmsgid = res10265.InfRefmsgid
  12265. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12266. res.Infcode = infocode
  12267. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12268. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12269. var api string
  12270. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12271. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12272. resp, requestErr := http.Get(api)
  12273. if requestErr != nil {
  12274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12275. return
  12276. }
  12277. body, ioErr := ioutil.ReadAll(resp.Body)
  12278. if ioErr != nil {
  12279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12281. return
  12282. }
  12283. var respJSON map[string]interface{}
  12284. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12287. return
  12288. }
  12289. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12290. if status == "0" {
  12291. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12292. c.ServeSuccessJSON(map[string]interface{}{
  12293. "failed_code": -10,
  12294. "msg": err_msg,
  12295. })
  12296. return
  12297. }
  12298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12299. result, _ := json.Marshal(respJSON)
  12300. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12301. utils.ErrorLog("解析失败:%v", err)
  12302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12303. return
  12304. }
  12305. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12306. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12307. var api string
  12308. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12309. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12310. resp, requestErr := http.Get(api)
  12311. if requestErr != nil {
  12312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12313. return
  12314. }
  12315. body, ioErr := ioutil.ReadAll(resp.Body)
  12316. if ioErr != nil {
  12317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12319. return
  12320. }
  12321. var respJSON map[string]interface{}
  12322. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12325. return
  12326. }
  12327. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12328. if status == "0" {
  12329. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12330. c.ServeSuccessJSON(map[string]interface{}{
  12331. "failed_code": -10,
  12332. "msg": err_msg,
  12333. })
  12334. return
  12335. }
  12336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12337. result, _ := json.Marshal(respJSON)
  12338. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12339. utils.ErrorLog("解析失败:%v", err)
  12340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12341. return
  12342. }
  12343. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12344. p, _ := service.GetHisPatientById(patient_id)
  12345. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12346. var dat map[string]interface{}
  12347. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12348. fmt.Println(dat)
  12349. } else {
  12350. fmt.Println(err)
  12351. }
  12352. userJSONBytes, _ := json.Marshal(dat)
  12353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12354. utils.ErrorLog("解析失败:%v", err)
  12355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12356. return
  12357. }
  12358. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12359. p, _ := service.GetHisPatientById(patient_id)
  12360. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12361. var dat map[string]interface{}
  12362. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12363. fmt.Println(dat)
  12364. } else {
  12365. fmt.Println(err)
  12366. }
  12367. userJSONBytes, _ := json.Marshal(dat)
  12368. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12369. utils.ErrorLog("解析失败:%v", err)
  12370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12371. return
  12372. }
  12373. } else if miConfig.MdtrtareaAdmvs == "360100" {
  12374. p, _ := service.GetHisPatientById(patient_id)
  12375. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12376. var dat map[string]interface{}
  12377. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12378. fmt.Println(dat)
  12379. } else {
  12380. fmt.Println(err)
  12381. }
  12382. userJSONBytes, _ := json.Marshal(dat)
  12383. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12384. utils.ErrorLog("解析失败:%v", err)
  12385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12386. return
  12387. }
  12388. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12389. p, _ := service.GetHisPatientById(patient_id)
  12390. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12391. var dat map[string]interface{}
  12392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12393. fmt.Println(dat)
  12394. } else {
  12395. fmt.Println(err)
  12396. }
  12397. userJSONBytes, _ := json.Marshal(dat)
  12398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12399. utils.ErrorLog("解析失败:%v", err)
  12400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12401. return
  12402. }
  12403. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12404. p, _ := service.GetHisPatientById(patient_id)
  12405. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12406. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12407. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12408. resp, requestErr := http.Get(api)
  12409. if requestErr != nil {
  12410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12411. return
  12412. }
  12413. body, ioErr := ioutil.ReadAll(resp.Body)
  12414. if ioErr != nil {
  12415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12417. return
  12418. }
  12419. var respJSON map[string]interface{}
  12420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12423. return
  12424. }
  12425. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12426. result, _ := json.Marshal(respJSON)
  12427. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12428. utils.ErrorLog("解析失败:%v", err)
  12429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12430. return
  12431. }
  12432. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12433. p, _ := service.GetHisPatientById(patient_id)
  12434. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12435. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12436. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12437. resp, requestErr := http.Get(api)
  12438. if requestErr != nil {
  12439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12440. return
  12441. }
  12442. body, ioErr := ioutil.ReadAll(resp.Body)
  12443. if ioErr != nil {
  12444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12446. return
  12447. }
  12448. var respJSON map[string]interface{}
  12449. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12452. return
  12453. }
  12454. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12455. result, _ := json.Marshal(respJSON)
  12456. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12457. utils.ErrorLog("解析失败:%v", err)
  12458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12459. return
  12460. }
  12461. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12462. p, _ := service.GetHisPatientById(patient_id)
  12463. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12464. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12465. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12466. resp, requestErr := http.Get(api)
  12467. if requestErr != nil {
  12468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12469. return
  12470. }
  12471. body, ioErr := ioutil.ReadAll(resp.Body)
  12472. if ioErr != nil {
  12473. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12475. return
  12476. }
  12477. var respJSON map[string]interface{}
  12478. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12481. return
  12482. }
  12483. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12484. result, _ := json.Marshal(respJSON)
  12485. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12486. utils.ErrorLog("解析失败:%v", err)
  12487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12488. return
  12489. }
  12490. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12491. p, _ := service.GetHisPatientById(patient_id)
  12492. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12493. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12494. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12495. resp, requestErr := http.Get(api)
  12496. if requestErr != nil {
  12497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12498. return
  12499. }
  12500. body, ioErr := ioutil.ReadAll(resp.Body)
  12501. if ioErr != nil {
  12502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12504. return
  12505. }
  12506. var respJSON map[string]interface{}
  12507. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12510. return
  12511. }
  12512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12513. result, _ := json.Marshal(respJSON)
  12514. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12515. utils.ErrorLog("解析失败:%v", err)
  12516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12517. return
  12518. }
  12519. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12520. p, _ := service.GetHisPatientById(patient_id)
  12521. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12522. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12523. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12524. resp, requestErr := http.Get(api)
  12525. if requestErr != nil {
  12526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12527. return
  12528. }
  12529. body, ioErr := ioutil.ReadAll(resp.Body)
  12530. if ioErr != nil {
  12531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12533. return
  12534. }
  12535. var respJSON map[string]interface{}
  12536. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12539. return
  12540. }
  12541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12542. result, _ := json.Marshal(respJSON)
  12543. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12544. utils.ErrorLog("解析失败:%v", err)
  12545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12546. return
  12547. }
  12548. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12549. p, _ := service.GetHisPatientById(patient_id)
  12550. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12551. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12552. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12553. resp, requestErr := http.Get(api)
  12554. if requestErr != nil {
  12555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12556. return
  12557. }
  12558. body, ioErr := ioutil.ReadAll(resp.Body)
  12559. if ioErr != nil {
  12560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12562. return
  12563. }
  12564. var respJSON map[string]interface{}
  12565. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12568. return
  12569. }
  12570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12571. result, _ := json.Marshal(respJSON)
  12572. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12573. utils.ErrorLog("解析失败:%v", err)
  12574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12575. return
  12576. }
  12577. } else {
  12578. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12579. var dat map[string]interface{}
  12580. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12581. fmt.Println(dat)
  12582. } else {
  12583. fmt.Println(err)
  12584. }
  12585. userJSONBytes, _ := json.Marshal(dat)
  12586. if miConfig.Code == "H15049901371" {
  12587. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12588. utils.ErrorLog("解析失败:%v", err)
  12589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12590. return
  12591. }
  12592. res.InfRefmsgid = res10265.InfRefmsgid
  12593. res.Output = res10265.Output
  12594. res.ErrMsg = res10265.ErrMsg
  12595. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12596. res.Infcode = infocode
  12597. } else {
  12598. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12599. utils.ErrorLog("解析失败:%v", err)
  12600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12601. return
  12602. }
  12603. }
  12604. }
  12605. if res.Infcode == 0 {
  12606. c.ServeSuccessJSON(map[string]interface{}{
  12607. "result": res.Output.Result,
  12608. })
  12609. }
  12610. }
  12611. func (c *HisApiController) CheckInsutype() {
  12612. his_patient_id, _ := c.GetInt64("his_patient_id")
  12613. admin_user_id, _ := c.GetInt64("admin_user_id")
  12614. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12615. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12616. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12617. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12618. var dat map[string]interface{}
  12619. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12620. fmt.Println(dat)
  12621. } else {
  12622. fmt.Println(err)
  12623. }
  12624. userJSONBytes, _ := json.Marshal(dat)
  12625. var res Result90100
  12626. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12627. utils.ErrorLog("解析失败:%v", err)
  12628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12629. return
  12630. }
  12631. if res.Infcode != 0 {
  12632. c.ServeSuccessJSON(map[string]interface{}{
  12633. "failed_code": -10,
  12634. "msg": res.ErrMsg,
  12635. })
  12636. return
  12637. } else {
  12638. fmt.Println(res)
  12639. }
  12640. }
  12641. func (c *HisApiController) CheckCardPWD() {
  12642. card_pwd := c.GetString("card_pwd")
  12643. his_patient_id, _ := c.GetInt64("his_patient_id")
  12644. admin_user_id, _ := c.GetInt64("admin_user_id")
  12645. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12646. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12647. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12648. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12649. bas := strings.Split(psn.CardInfo, "|")
  12650. basNumber := bas[2]
  12651. if psn.InsuplcAdmdvs[:4] == "4403" {
  12652. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12653. var dat map[string]interface{}
  12654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12655. fmt.Println(dat)
  12656. } else {
  12657. fmt.Println(err)
  12658. }
  12659. userJSONBytes, _ := json.Marshal(dat)
  12660. var res Result90991
  12661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12662. utils.ErrorLog("解析失败:%v", err)
  12663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12664. return
  12665. }
  12666. if res.Infcode != 0 {
  12667. c.ServeSuccessJSON(map[string]interface{}{
  12668. "failed_code": -10,
  12669. "msg": res.ErrMsg,
  12670. })
  12671. return
  12672. } else {
  12673. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12674. var msg string
  12675. switch res.Output.Result.CardStat {
  12676. case "00":
  12677. msg = "未激活"
  12678. break
  12679. case "10":
  12680. msg = "激活"
  12681. break
  12682. case "20":
  12683. msg = "窗口挂失"
  12684. break
  12685. case "21":
  12686. msg = "电话挂失"
  12687. break
  12688. case "22":
  12689. msg = "单位网上申报挂失"
  12690. break
  12691. case "23":
  12692. msg = "保健办挂失"
  12693. break
  12694. case "24":
  12695. msg = "个人网上挂失"
  12696. break
  12697. case "25":
  12698. msg = "网上服务大厅挂失"
  12699. break
  12700. case "30":
  12701. msg = "注销"
  12702. break
  12703. case "40":
  12704. msg = "回收"
  12705. break
  12706. case "99":
  12707. msg = "制卡中(无效卡)"
  12708. break
  12709. }
  12710. c.ServeSuccessJSON(map[string]interface{}{
  12711. "failed_code": -10,
  12712. "msg": msg,
  12713. })
  12714. return
  12715. } else {
  12716. c.ServeSuccessJSON(map[string]interface{}{
  12717. "msg": "校验成功",
  12718. })
  12719. return
  12720. }
  12721. }
  12722. } else {
  12723. c.ServeSuccessJSON(map[string]interface{}{
  12724. "msg": "校验成功",
  12725. })
  12726. return
  12727. }
  12728. }
  12729. func (c *HisApiController) CheckCardPWDTwo() {
  12730. //card_pwd := c.GetString("card_pwd")
  12731. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12732. admin_user_id, _ := c.GetInt64("admin_user_id")
  12733. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12734. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12735. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12736. var dat map[string]interface{}
  12737. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12738. fmt.Println(dat)
  12739. } else {
  12740. fmt.Println(err)
  12741. }
  12742. userJSONBytes, _ := json.Marshal(dat)
  12743. var res Result90991
  12744. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12745. utils.ErrorLog("解析失败:%v", err)
  12746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12747. return
  12748. }
  12749. if res.Infcode != 0 {
  12750. c.ServeSuccessJSON(map[string]interface{}{
  12751. "failed_code": -10,
  12752. "msg": res.ErrMsg,
  12753. })
  12754. return
  12755. } else {
  12756. if res.Output.Result.SscnoCheckStat == "0" {
  12757. var msg string
  12758. switch res.Output.Result.CardStat {
  12759. case "00":
  12760. msg = "未激活"
  12761. break
  12762. case "10":
  12763. msg = "激活"
  12764. break
  12765. case "20":
  12766. msg = "窗口挂失"
  12767. break
  12768. case "21":
  12769. msg = "电话挂失"
  12770. break
  12771. case "22":
  12772. msg = "单位网上申报挂失"
  12773. break
  12774. case "23":
  12775. msg = "保健办挂失"
  12776. break
  12777. case "24":
  12778. msg = "个人网上挂失"
  12779. break
  12780. case "25":
  12781. msg = "网上服务大厅挂失"
  12782. break
  12783. case "30":
  12784. msg = "注销"
  12785. break
  12786. case "40":
  12787. msg = "回收"
  12788. break
  12789. case "99":
  12790. msg = "制卡中(无效卡)"
  12791. break
  12792. }
  12793. c.ServeSuccessJSON(map[string]interface{}{
  12794. "failed_code": -10,
  12795. "msg": msg,
  12796. })
  12797. return
  12798. } else {
  12799. c.ServeSuccessJSON(map[string]interface{}{
  12800. "msg": "校验成功",
  12801. })
  12802. return
  12803. }
  12804. }
  12805. }
  12806. type ELeCertData struct {
  12807. Data struct {
  12808. Extra string `json:"extra"`
  12809. IDNo string `json:"idNo"`
  12810. IDType string `json:"idType"`
  12811. EcToken string `json:"ecToken"`
  12812. InsuOrg string `json:"insuOrg"`
  12813. UserName string `json:"userName"`
  12814. EcIndexNo string `json:"ecIndexNo"`
  12815. Gender string `json:"gender"`
  12816. Birthday string `json:"birthday"`
  12817. Nationality string `json:"nationality"`
  12818. Email string `json:"email"`
  12819. } `json:"OutData"`
  12820. }
  12821. func (c *HisApiController) ReadCard() {
  12822. id_card_type, _ := c.GetInt64("id_card_type")
  12823. admin_user_id, _ := c.GetInt64("admin_user_id")
  12824. certificates, _ := c.GetInt64("certificates")
  12825. //
  12826. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12827. id_card_no := c.GetString("id_card_no")
  12828. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12829. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12830. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12831. switch id_card_type {
  12832. case 1:
  12833. if miConfig.MdtrtareaAdmvs == "421300" {
  12834. var res ResultTwo
  12835. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12836. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12837. "&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)
  12838. resp, requestErr := http.Get(api)
  12839. if requestErr != nil {
  12840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12841. return
  12842. }
  12843. body, ioErr := ioutil.ReadAll(resp.Body)
  12844. if ioErr != nil {
  12845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12847. return
  12848. }
  12849. var respJSON map[string]interface{}
  12850. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12853. return
  12854. }
  12855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12856. result, _ := json.Marshal(respJSON)
  12857. fmt.Println("log")
  12858. fmt.Println(string(result))
  12859. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12860. utils.ErrorLog("解析失败:%v", err)
  12861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12862. return
  12863. }
  12864. if res.Infcode == 0 {
  12865. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12866. if err == gorm.ErrRecordNotFound {
  12867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12868. return
  12869. } else if err != nil {
  12870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12871. return
  12872. } else {
  12873. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12874. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12875. infoStr := string(Iinfos)
  12876. idetinfoStr := string(Idetinfos)
  12877. var rf []*ResultFive
  12878. json.Unmarshal([]byte(infoStr), &rf)
  12879. var insutypes []*ResultFive
  12880. var insutype string
  12881. var is390 int = 0
  12882. var is310 int = 0
  12883. for _, item := range rf {
  12884. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12885. insutypes = append(insutypes, item)
  12886. }
  12887. }
  12888. if len(insutypes) == 1 {
  12889. insutype = insutypes[0].Insutype
  12890. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12891. } else {
  12892. for _, i := range insutypes {
  12893. if i.Insutype == "390" {
  12894. is390 = 1
  12895. }
  12896. if i.Insutype == "310" {
  12897. is310 = 1
  12898. }
  12899. }
  12900. }
  12901. if is390 == 1 {
  12902. insutype = "390"
  12903. }
  12904. if is310 == 1 {
  12905. insutype = "310"
  12906. }
  12907. if len(insutypes) == 0 {
  12908. insutype = "390"
  12909. }
  12910. var insuplc_admdvs string
  12911. for _, item := range rf {
  12912. if item.Insutype == insutype {
  12913. insuplc_admdvs = item.InsuplcAdmdvs
  12914. }
  12915. }
  12916. if strings.Contains(insuplc_admdvs, "4213") {
  12917. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12918. }
  12919. psn := &models.HisPsn{
  12920. PsnNo: res.Output.Baseinfo.PsnNo,
  12921. PatientId: patient.ID,
  12922. Certno: res.Output.Baseinfo.Certno,
  12923. Gend: res.Output.Baseinfo.Gend,
  12924. Naty: res.Output.Baseinfo.Naty,
  12925. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12926. PsnName: res.Output.Baseinfo.PsnName,
  12927. Idetinfo: idetinfoStr,
  12928. Insuinfo: infoStr,
  12929. InsuplcAdmdvs: insuplc_admdvs,
  12930. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12931. }
  12932. service.CreateHisPsn(psn)
  12933. c.ServeSuccessJSON(map[string]interface{}{
  12934. "patient": patient,
  12935. "number": res.Output.Baseinfo.Certno,
  12936. })
  12937. }
  12938. } else {
  12939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12940. return
  12941. }
  12942. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12943. var res ResultTwo
  12944. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12945. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12946. "&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)
  12947. resp, requestErr := http.Get(api)
  12948. if requestErr != nil {
  12949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12950. return
  12951. }
  12952. body, ioErr := ioutil.ReadAll(resp.Body)
  12953. if ioErr != nil {
  12954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12956. return
  12957. }
  12958. var respJSON map[string]interface{}
  12959. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12962. return
  12963. }
  12964. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12965. result, _ := json.Marshal(respJSON)
  12966. fmt.Println("log")
  12967. fmt.Println(string(result))
  12968. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12969. utils.ErrorLog("解析失败:%v", err)
  12970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12971. return
  12972. }
  12973. if res.Infcode == 0 {
  12974. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12975. if err == gorm.ErrRecordNotFound {
  12976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12977. return
  12978. } else if err != nil {
  12979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12980. return
  12981. } else {
  12982. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12983. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12984. infoStr := string(Iinfos)
  12985. idetinfoStr := string(Idetinfos)
  12986. psn := &models.HisPsn{
  12987. PsnNo: res.Output.Baseinfo.PsnNo,
  12988. PatientId: patient.ID,
  12989. Certno: res.Output.Baseinfo.Certno,
  12990. Gend: res.Output.Baseinfo.Gend,
  12991. Naty: res.Output.Baseinfo.Naty,
  12992. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12993. PsnName: res.Output.Baseinfo.PsnName,
  12994. Idetinfo: idetinfoStr,
  12995. Insuinfo: infoStr,
  12996. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12997. }
  12998. service.CreateHisPsn(psn)
  12999. var rf []*ResultFive
  13000. json.Unmarshal([]byte(infoStr), &rf)
  13001. var insutypes []*ResultFive
  13002. var insutype string
  13003. var is390 int = 0
  13004. var is310 int = 0
  13005. for _, item := range rf {
  13006. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13007. insutypes = append(insutypes, item)
  13008. }
  13009. }
  13010. if len(insutypes) == 1 {
  13011. insutype = insutypes[0].Insutype
  13012. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13013. } else {
  13014. for _, i := range insutypes {
  13015. if i.Insutype == "390" {
  13016. is390 = 1
  13017. }
  13018. if i.Insutype == "310" {
  13019. is310 = 1
  13020. }
  13021. }
  13022. }
  13023. if is390 == 1 {
  13024. insutype = "390"
  13025. }
  13026. if is310 == 1 {
  13027. insutype = "310"
  13028. }
  13029. if len(insutypes) == 0 {
  13030. insutype = "310"
  13031. }
  13032. c.ServeSuccessJSON(map[string]interface{}{
  13033. "patient": patient,
  13034. "number": res.Output.Baseinfo.Certno,
  13035. "insutype": insutype,
  13036. })
  13037. }
  13038. } else {
  13039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13040. return
  13041. }
  13042. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13043. var res ResultTwo
  13044. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13045. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13046. "&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)
  13047. resp, requestErr := http.Get(api)
  13048. if requestErr != nil {
  13049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13050. return
  13051. }
  13052. body, ioErr := ioutil.ReadAll(resp.Body)
  13053. if ioErr != nil {
  13054. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13056. return
  13057. }
  13058. var respJSON map[string]interface{}
  13059. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13060. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13062. return
  13063. }
  13064. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13065. result, _ := json.Marshal(respJSON)
  13066. fmt.Println("log")
  13067. fmt.Println(string(result))
  13068. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13069. utils.ErrorLog("解析失败:%v", err)
  13070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13071. return
  13072. }
  13073. if res.Infcode == 0 {
  13074. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13075. if err == gorm.ErrRecordNotFound {
  13076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13077. return
  13078. } else if err != nil {
  13079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13080. return
  13081. } else {
  13082. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13083. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13084. infoStr := string(Iinfos)
  13085. idetinfoStr := string(Idetinfos)
  13086. var rf []*ResultFive
  13087. json.Unmarshal([]byte(infoStr), &rf)
  13088. var insutypes []*ResultFive
  13089. var insutype string
  13090. var is390 int = 0
  13091. var is310 int = 0
  13092. for _, item := range rf {
  13093. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13094. insutypes = append(insutypes, item)
  13095. }
  13096. }
  13097. if len(insutypes) == 1 {
  13098. insutype = insutypes[0].Insutype
  13099. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13100. } else {
  13101. for _, i := range insutypes {
  13102. if i.Insutype == "390" {
  13103. is390 = 1
  13104. }
  13105. if i.Insutype == "310" {
  13106. is310 = 1
  13107. }
  13108. }
  13109. }
  13110. if is390 == 1 {
  13111. insutype = "390"
  13112. }
  13113. if is310 == 1 {
  13114. insutype = "310"
  13115. }
  13116. if len(insutypes) == 0 {
  13117. insutype = "390"
  13118. }
  13119. var insuplc_admdvs string
  13120. for _, item := range rf {
  13121. if item.Insutype == insutype {
  13122. insuplc_admdvs = item.InsuplcAdmdvs
  13123. }
  13124. }
  13125. psn := &models.HisPsn{
  13126. PsnNo: res.Output.Baseinfo.PsnNo,
  13127. PatientId: patient.ID,
  13128. Certno: res.Output.Baseinfo.Certno,
  13129. Gend: res.Output.Baseinfo.Gend,
  13130. Naty: res.Output.Baseinfo.Naty,
  13131. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13132. PsnName: res.Output.Baseinfo.PsnName,
  13133. Idetinfo: idetinfoStr,
  13134. Insuinfo: infoStr,
  13135. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13136. InsuplcAdmdvs: insuplc_admdvs,
  13137. }
  13138. service.CreateHisPsn(psn)
  13139. for _, item := range rf {
  13140. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13141. insutypes = append(insutypes, item)
  13142. }
  13143. }
  13144. if len(insutypes) == 1 {
  13145. insutype = insutypes[0].Insutype
  13146. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13147. } else {
  13148. for _, i := range insutypes {
  13149. if i.Insutype == "390" {
  13150. is390 = 1
  13151. }
  13152. if i.Insutype == "310" {
  13153. is310 = 1
  13154. }
  13155. }
  13156. }
  13157. if is390 == 1 {
  13158. insutype = "390"
  13159. }
  13160. if is310 == 1 {
  13161. insutype = "310"
  13162. }
  13163. if len(insutypes) == 0 {
  13164. insutype = "310"
  13165. }
  13166. c.ServeSuccessJSON(map[string]interface{}{
  13167. "patient": patient,
  13168. "number": res.Output.Baseinfo.Certno,
  13169. "insutype": insutype,
  13170. })
  13171. }
  13172. } else {
  13173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13174. return
  13175. }
  13176. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13177. var res ResultTwo
  13178. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13179. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13180. "&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)
  13181. resp, requestErr := http.Get(api)
  13182. if requestErr != nil {
  13183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13184. return
  13185. }
  13186. body, ioErr := ioutil.ReadAll(resp.Body)
  13187. if ioErr != nil {
  13188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13190. return
  13191. }
  13192. var respJSON map[string]interface{}
  13193. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13196. return
  13197. }
  13198. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13199. result, _ := json.Marshal(respJSON)
  13200. fmt.Println("log")
  13201. fmt.Println(string(result))
  13202. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13203. utils.ErrorLog("解析失败:%v", err)
  13204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13205. return
  13206. }
  13207. if res.Infcode == 0 {
  13208. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13209. if err == gorm.ErrRecordNotFound {
  13210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13211. return
  13212. } else if err != nil {
  13213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13214. return
  13215. } else {
  13216. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13217. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13218. infoStr := string(Iinfos)
  13219. idetinfoStr := string(Idetinfos)
  13220. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13221. psn := &models.HisPsn{
  13222. PsnNo: res.Output.Baseinfo.PsnNo,
  13223. PatientId: patient.ID,
  13224. Certno: res.Output.Baseinfo.Certno,
  13225. Brdy: b,
  13226. Age: float64(age),
  13227. Gend: res.Output.Baseinfo.Gend,
  13228. Naty: res.Output.Baseinfo.Naty,
  13229. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13230. PsnName: res.Output.Baseinfo.PsnName,
  13231. Idetinfo: idetinfoStr,
  13232. Insuinfo: infoStr,
  13233. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13234. }
  13235. service.CreateHisPsn(psn)
  13236. var rf []*ResultFive
  13237. json.Unmarshal([]byte(infoStr), &rf)
  13238. var insutypes []*ResultFive
  13239. var insutype string
  13240. var is390 int = 0
  13241. var is310 int = 0
  13242. for _, item := range rf {
  13243. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13244. insutypes = append(insutypes, item)
  13245. }
  13246. }
  13247. if len(insutypes) == 1 {
  13248. insutype = insutypes[0].Insutype
  13249. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13250. } else {
  13251. for _, i := range insutypes {
  13252. if i.Insutype == "390" {
  13253. is390 = 1
  13254. }
  13255. if i.Insutype == "310" {
  13256. is310 = 1
  13257. }
  13258. }
  13259. }
  13260. if is390 == 1 {
  13261. insutype = "390"
  13262. }
  13263. if is310 == 1 {
  13264. insutype = "310"
  13265. }
  13266. if len(insutypes) == 0 {
  13267. insutype = "310"
  13268. }
  13269. c.ServeSuccessJSON(map[string]interface{}{
  13270. "patient": patient,
  13271. "number": res.Output.Baseinfo.Certno,
  13272. "insutype": insutype,
  13273. })
  13274. }
  13275. } else {
  13276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13277. return
  13278. }
  13279. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13280. var api string
  13281. if miConfig.MdtrtareaAdmvs == "320921" {
  13282. 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 +
  13283. "&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
  13284. fmt.Println(api)
  13285. } else {
  13286. 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 +
  13287. "&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)
  13288. }
  13289. resp, requestErr := http.Get(api)
  13290. if requestErr != nil {
  13291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13292. return
  13293. }
  13294. body, ioErr := ioutil.ReadAll(resp.Body)
  13295. if ioErr != nil {
  13296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13298. return
  13299. }
  13300. var respJSON map[string]interface{}
  13301. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13304. return
  13305. }
  13306. var status string
  13307. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13308. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13309. //console.log()
  13310. fmt.Println("type===")
  13311. fmt.Println(card_type)
  13312. var token string
  13313. var res ResultTwo //1101结果
  13314. var res10265 ResultTwo10265 //1101结果
  13315. var card_info string //卡信息
  13316. var busi_card_info string
  13317. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13318. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13319. if status == "0" { //读卡成功
  13320. if card_type == "1" {
  13321. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13322. result, _ := json.Marshal(respJSON)
  13323. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13324. utils.ErrorLog("解析失败:%v", err)
  13325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13326. return
  13327. }
  13328. res.ErrMsg = res10265.ErrMsg
  13329. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13330. res.Infcode = infocode
  13331. res.Output = res10265.Output
  13332. res.InfRefmsgid = res10265.InfRefmsgid
  13333. } else {
  13334. //var card_info string //卡信息
  13335. //var busi_card_info string
  13336. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13337. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13338. //fmt.Println(card_info)
  13339. //fmt.Println(busi_card_info)
  13340. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13341. result, _ := json.Marshal(respJSON)
  13342. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13343. utils.ErrorLog("解析失败:%v", err)
  13344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13345. return
  13346. }
  13347. res.ErrMsg = res10265.ErrMsg
  13348. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13349. res.Infcode = infocode
  13350. res.Output = res10265.Output
  13351. res.InfRefmsgid = res10265.InfRefmsgid
  13352. }
  13353. if res.Infcode == 0 {
  13354. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13355. if err == gorm.ErrRecordNotFound {
  13356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13357. return
  13358. } else if err != nil {
  13359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13360. return
  13361. } else {
  13362. if card_type == "1" {
  13363. bas := strings.Split(card_info, "|")
  13364. basNumber := bas[2]
  13365. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13366. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13367. infoStr := string(Iinfos)
  13368. idetinfoStr := string(Idetinfos)
  13369. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13370. psn := &models.HisPsn{
  13371. PsnNo: res.Output.Baseinfo.PsnNo,
  13372. PatientId: patient.ID,
  13373. Certno: res.Output.Baseinfo.Certno,
  13374. Brdy: b,
  13375. Age: float64(age),
  13376. Gend: res.Output.Baseinfo.Gend,
  13377. Naty: res.Output.Baseinfo.Naty,
  13378. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13379. PsnName: res.Output.Baseinfo.PsnName,
  13380. Idetinfo: idetinfoStr,
  13381. Insuinfo: infoStr,
  13382. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13383. CardInfo: card_info,
  13384. VerifyNumber: busi_card_info,
  13385. }
  13386. service.CreateHisPsn(psn)
  13387. var rf []*ResultFive
  13388. json.Unmarshal([]byte(infoStr), &rf)
  13389. var insutypes []*ResultFive
  13390. var insutype string
  13391. var is390 int = 0
  13392. var is310 int = 0
  13393. for _, item := range rf {
  13394. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13395. insutypes = append(insutypes, item)
  13396. }
  13397. }
  13398. if len(insutypes) == 1 {
  13399. insutype = insutypes[0].Insutype
  13400. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13401. } else {
  13402. for _, i := range insutypes {
  13403. if i.Insutype == "390" {
  13404. is390 = 1
  13405. }
  13406. if i.Insutype == "310" {
  13407. is310 = 1
  13408. }
  13409. }
  13410. }
  13411. if is390 == 1 {
  13412. insutype = "390"
  13413. }
  13414. if is310 == 1 {
  13415. insutype = "310"
  13416. }
  13417. if len(insutypes) == 0 {
  13418. insutype = "310"
  13419. }
  13420. c.ServeSuccessJSON(map[string]interface{}{
  13421. "patient": patient,
  13422. "number": basNumber,
  13423. "insutype": insutype,
  13424. })
  13425. } else {
  13426. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13427. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13428. infoStr := string(Iinfos)
  13429. idetinfoStr := string(Idetinfos)
  13430. psn := &models.HisPsn{
  13431. PsnNo: res.Output.Baseinfo.PsnNo,
  13432. PatientId: patient.ID,
  13433. Certno: res.Output.Baseinfo.Certno,
  13434. Gend: res.Output.Baseinfo.Gend,
  13435. Naty: res.Output.Baseinfo.Naty,
  13436. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13437. PsnName: res.Output.Baseinfo.PsnName,
  13438. Idetinfo: idetinfoStr,
  13439. Insuinfo: infoStr,
  13440. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13441. CardInfo: card_info,
  13442. VerifyNumber: token,
  13443. }
  13444. service.CreateHisPsn(psn)
  13445. c.ServeSuccessJSON(map[string]interface{}{
  13446. "patient": patient,
  13447. "number": token,
  13448. })
  13449. }
  13450. }
  13451. } else {
  13452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13453. return
  13454. }
  13455. } else { //读卡失败
  13456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13457. return
  13458. }
  13459. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13460. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13461. cardnum = DeleteExtraSpaceTwo(cardnum)
  13462. cardCode = DeleteExtraSpaceTwo(cardCode)
  13463. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13464. name = DeleteExtraSpaceTwo(name)
  13465. errmsg = DeleteExtraSpaceTwo(errmsg)
  13466. cardnum = Remove0000(cardnum)
  13467. cardCode = Remove0000(cardCode)
  13468. id_card_no = Remove0000(id_card_no)
  13469. name = Remove0000(name)
  13470. errmsg = Remove0000(errmsg)
  13471. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13472. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13473. //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)
  13474. //fmt.Println(result2)
  13475. //fmt.Println(requestLog2)
  13476. //fmt.Println(errMsgLog2)
  13477. 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)
  13478. saveLog(result, requestLog, "1101", "获取人员信息")
  13479. fmt.Println(errMsgLog)
  13480. if len(errMsgLog) > 0 {
  13481. } else {
  13482. var dat map[string]interface{}
  13483. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13484. fmt.Println(dat)
  13485. } else {
  13486. fmt.Println(err)
  13487. }
  13488. userJSONBytes, _ := json.Marshal(dat)
  13489. var res ResultTwo
  13490. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13491. utils.ErrorLog("解析失败:%v", err)
  13492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13493. return
  13494. }
  13495. res.ErrMsg = errMsgLog
  13496. if res.Infcode == 0 {
  13497. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13498. if err == gorm.ErrRecordNotFound {
  13499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13500. return
  13501. } else if err != nil {
  13502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13503. return
  13504. } else {
  13505. fmt.Println(res)
  13506. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13507. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13508. infoStr := string(Iinfos)
  13509. idetinfoStr := string(Idetinfos)
  13510. var rf []*ResultFive
  13511. json.Unmarshal([]byte(infoStr), &rf)
  13512. var insutypes []*ResultFive
  13513. var insutype string
  13514. var is390 int = 0
  13515. var is310 int = 0
  13516. for _, item := range rf {
  13517. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13518. insutypes = append(insutypes, item)
  13519. }
  13520. }
  13521. if len(insutypes) == 1 {
  13522. insutype = insutypes[0].Insutype
  13523. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13524. } else {
  13525. for _, i := range insutypes {
  13526. if i.Insutype == "390" {
  13527. is390 = 1
  13528. }
  13529. if i.Insutype == "310" {
  13530. is310 = 1
  13531. }
  13532. }
  13533. }
  13534. if is390 == 1 {
  13535. insutype = "390"
  13536. }
  13537. if is310 == 1 {
  13538. insutype = "310"
  13539. }
  13540. if len(insutypes) == 0 {
  13541. insutype = "390"
  13542. }
  13543. var insuplc_admdvs string
  13544. for _, item := range rf {
  13545. if item.Insutype == insutype {
  13546. insuplc_admdvs = item.InsuplcAdmdvs
  13547. }
  13548. }
  13549. psn := &models.HisPsn{
  13550. PsnNo: res.Output.Baseinfo.PsnNo,
  13551. PatientId: patient.ID,
  13552. Certno: res.Output.Baseinfo.Certno,
  13553. Gend: res.Output.Baseinfo.Gend,
  13554. Naty: res.Output.Baseinfo.Naty,
  13555. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13556. PsnName: res.Output.Baseinfo.PsnName,
  13557. Idetinfo: idetinfoStr,
  13558. Insuinfo: infoStr,
  13559. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13560. CardInfo: basStr,
  13561. VerifyNumber: "",
  13562. InsuplcAdmdvs: insuplc_admdvs,
  13563. }
  13564. service.CreateHisPsn(psn)
  13565. c.ServeSuccessJSON(map[string]interface{}{
  13566. "patient": patient,
  13567. "number": cardnum,
  13568. "insutype": insutype,
  13569. })
  13570. }
  13571. } else {
  13572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13573. return
  13574. }
  13575. }
  13576. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13577. fmt.Println(initFlag)
  13578. fmt.Println("initFlag")
  13579. if initFlag == 0 {
  13580. c.TestGetJiangXiBasBaseInit()
  13581. }
  13582. basStr := c.GetBasBaseInfo()
  13583. if len(basStr) == 0 {
  13584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13585. return
  13586. }
  13587. fmt.Println(basStr)
  13588. bas := strings.Split(basStr, "|")
  13589. basNumber := bas[1]
  13590. fmt.Println(basNumber)
  13591. card := bas[2]
  13592. card_sn := bas[3]
  13593. fmt.Println(card_sn)
  13594. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13595. 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)
  13596. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13597. var dat map[string]interface{}
  13598. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13599. fmt.Println(dat)
  13600. } else {
  13601. fmt.Println(err)
  13602. }
  13603. userJSONBytes, _ := json.Marshal(dat)
  13604. var res ResultTwo
  13605. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13606. utils.ErrorLog("解析失败:%v", err)
  13607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13608. return
  13609. }
  13610. if res.Infcode == 0 {
  13611. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13612. if err == gorm.ErrRecordNotFound {
  13613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13614. return
  13615. } else if err != nil {
  13616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13617. return
  13618. } else {
  13619. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13620. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13621. infoStr := string(Iinfos)
  13622. idetinfoStr := string(Idetinfos)
  13623. var rf []*ResultFive
  13624. json.Unmarshal([]byte(infoStr), &rf)
  13625. var insutypes []*ResultFive
  13626. var insutype string
  13627. var is390 int = 0
  13628. var is310 int = 0
  13629. var insuplc_admdvs string
  13630. for _, item := range rf {
  13631. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13632. insutypes = append(insutypes, item)
  13633. }
  13634. }
  13635. if len(insutypes) == 1 {
  13636. insutype = insutypes[0].Insutype
  13637. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13638. } else {
  13639. for _, i := range insutypes {
  13640. if i.Insutype == "390" {
  13641. is390 = 1
  13642. }
  13643. if i.Insutype == "310" {
  13644. is310 = 1
  13645. }
  13646. }
  13647. }
  13648. if is390 == 1 {
  13649. insutype = "390"
  13650. }
  13651. if is310 == 1 {
  13652. insutype = "310"
  13653. }
  13654. if len(insutypes) == 0 {
  13655. insutype = "310"
  13656. }
  13657. for _, item := range rf {
  13658. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13659. insuplc_admdvs = item.InsuplcAdmdvs
  13660. }
  13661. }
  13662. psn := &models.HisPsn{
  13663. PsnNo: res.Output.Baseinfo.PsnNo,
  13664. PatientId: patient.ID,
  13665. Certno: res.Output.Baseinfo.Certno,
  13666. Gend: res.Output.Baseinfo.Gend,
  13667. Naty: res.Output.Baseinfo.Naty,
  13668. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13669. PsnName: res.Output.Baseinfo.PsnName,
  13670. Idetinfo: idetinfoStr,
  13671. Insuinfo: infoStr,
  13672. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13673. CardInfo: basStr,
  13674. InsuplcAdmdvs: insuplc_admdvs,
  13675. VerifyNumber: "",
  13676. }
  13677. service.CreateHisPsn(psn)
  13678. c.ServeSuccessJSON(map[string]interface{}{
  13679. "patient": patient,
  13680. "number": basNumber,
  13681. "insutype": insutype,
  13682. })
  13683. }
  13684. } else {
  13685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13686. return
  13687. }
  13688. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13689. basStr := c.GetBasBaseInfo22222()
  13690. fmt.Println(basStr)
  13691. if len(basStr) == 0 {
  13692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13693. return
  13694. }
  13695. fmt.Println(basStr)
  13696. bas := strings.Split(basStr, "|")
  13697. basNumber := bas[2] //卡号
  13698. card_sn := bas[3] //
  13699. id_card_No := bas[1] //卡号
  13700. fmt.Println(basNumber)
  13701. fmt.Println(card_sn)
  13702. fmt.Println(id_card_No)
  13703. var patient service.Patients
  13704. if len(id_card_No) == 0 {
  13705. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13706. } else {
  13707. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13708. }
  13709. 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)
  13710. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13711. var dat map[string]interface{}
  13712. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13713. fmt.Println(dat)
  13714. } else {
  13715. fmt.Println(err)
  13716. }
  13717. userJSONBytes, _ := json.Marshal(dat)
  13718. var res ResultTwo
  13719. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13720. utils.ErrorLog("解析失败:%v", err)
  13721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13722. return
  13723. }
  13724. if res.Infcode == 0 {
  13725. var pateint2 service.Patients
  13726. var err error
  13727. if len(id_card_No) == 0 {
  13728. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13729. } else {
  13730. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13731. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13732. }
  13733. if err == gorm.ErrRecordNotFound {
  13734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13735. return
  13736. } else if err != nil {
  13737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13738. return
  13739. } else {
  13740. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13741. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13742. infoStr := string(Iinfos)
  13743. idetinfoStr := string(Idetinfos)
  13744. var rf []*ResultFive
  13745. json.Unmarshal([]byte(infoStr), &rf)
  13746. var insutypes []*ResultFive
  13747. var insutype string
  13748. var is390 int = 0
  13749. var is310 int = 0
  13750. var insuplc_admdvs string
  13751. for _, item := range rf {
  13752. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13753. insutypes = append(insutypes, item)
  13754. }
  13755. }
  13756. if len(insutypes) == 1 {
  13757. insutype = insutypes[0].Insutype
  13758. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13759. } else {
  13760. for _, i := range insutypes {
  13761. if i.Insutype == "390" {
  13762. is390 = 1
  13763. }
  13764. if i.Insutype == "310" {
  13765. is310 = 1
  13766. }
  13767. }
  13768. }
  13769. if is390 == 1 {
  13770. insutype = "390"
  13771. }
  13772. if is310 == 1 {
  13773. insutype = "310"
  13774. }
  13775. if len(insutypes) == 0 {
  13776. insutype = "310"
  13777. }
  13778. for _, item := range rf {
  13779. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13780. insuplc_admdvs = item.InsuplcAdmdvs
  13781. }
  13782. }
  13783. psn := &models.HisPsn{
  13784. PsnNo: res.Output.Baseinfo.PsnNo,
  13785. PatientId: pateint2.ID,
  13786. Certno: res.Output.Baseinfo.Certno,
  13787. Gend: res.Output.Baseinfo.Gend,
  13788. Naty: res.Output.Baseinfo.Naty,
  13789. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13790. PsnName: res.Output.Baseinfo.PsnName,
  13791. Idetinfo: idetinfoStr,
  13792. Insuinfo: infoStr,
  13793. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13794. CardInfo: basStr,
  13795. InsuplcAdmdvs: insuplc_admdvs,
  13796. VerifyNumber: "",
  13797. }
  13798. service.CreateHisPsn(psn)
  13799. c.ServeSuccessJSON(map[string]interface{}{
  13800. "patient": patient,
  13801. "number": basNumber,
  13802. "insutype": insutype,
  13803. })
  13804. }
  13805. } else {
  13806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13807. return
  13808. }
  13809. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13810. fmt.Println(initFlag)
  13811. fmt.Println("initFlag")
  13812. if initFlag == 0 {
  13813. c.TestGetJiangXiBasBaseInittwo()
  13814. }
  13815. basStr := c.GetBasBaseInfo()
  13816. if len(basStr) == 0 {
  13817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13818. return
  13819. }
  13820. fmt.Println(basStr)
  13821. bas := strings.Split(basStr, "|")
  13822. basNumber := bas[1]
  13823. fmt.Println(basNumber)
  13824. card_sn := bas[3]
  13825. fmt.Println(card_sn)
  13826. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13827. 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)
  13828. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13829. var dat map[string]interface{}
  13830. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13831. fmt.Println(dat)
  13832. } else {
  13833. fmt.Println(err)
  13834. }
  13835. userJSONBytes, _ := json.Marshal(dat)
  13836. var res ResultTwo
  13837. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13838. utils.ErrorLog("解析失败:%v", err)
  13839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13840. return
  13841. }
  13842. if res.Infcode == 0 {
  13843. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13844. if err == gorm.ErrRecordNotFound {
  13845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13846. return
  13847. } else if err != nil {
  13848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13849. return
  13850. } else {
  13851. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13852. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13853. infoStr := string(Iinfos)
  13854. idetinfoStr := string(Idetinfos)
  13855. var rf []*ResultFive
  13856. json.Unmarshal([]byte(infoStr), &rf)
  13857. var insutypes []*ResultFive
  13858. var insutype string
  13859. var is390 int = 0
  13860. var is310 int = 0
  13861. var insuplc_admdvs string
  13862. for _, item := range rf {
  13863. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13864. insutypes = append(insutypes, item)
  13865. }
  13866. }
  13867. if len(insutypes) == 1 {
  13868. insutype = insutypes[0].Insutype
  13869. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13870. } else {
  13871. for _, i := range insutypes {
  13872. if i.Insutype == "390" {
  13873. is390 = 1
  13874. }
  13875. if i.Insutype == "310" {
  13876. is310 = 1
  13877. }
  13878. }
  13879. }
  13880. if is390 == 1 {
  13881. insutype = "390"
  13882. }
  13883. if is310 == 1 {
  13884. insutype = "310"
  13885. }
  13886. if len(insutypes) == 0 {
  13887. insutype = "310"
  13888. }
  13889. for _, item := range rf {
  13890. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13891. insuplc_admdvs = item.InsuplcAdmdvs
  13892. }
  13893. }
  13894. psn := &models.HisPsn{
  13895. PsnNo: res.Output.Baseinfo.PsnNo,
  13896. PatientId: patient.ID,
  13897. Certno: res.Output.Baseinfo.Certno,
  13898. Gend: res.Output.Baseinfo.Gend,
  13899. Naty: res.Output.Baseinfo.Naty,
  13900. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13901. PsnName: res.Output.Baseinfo.PsnName,
  13902. Idetinfo: idetinfoStr,
  13903. Insuinfo: infoStr,
  13904. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13905. CardInfo: basStr,
  13906. InsuplcAdmdvs: insuplc_admdvs,
  13907. VerifyNumber: "",
  13908. }
  13909. service.CreateHisPsn(psn)
  13910. c.ServeSuccessJSON(map[string]interface{}{
  13911. "patient": patient,
  13912. "number": basNumber,
  13913. "insutype": insutype,
  13914. })
  13915. }
  13916. } else {
  13917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13918. return
  13919. }
  13920. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13921. fmt.Println(initFlag)
  13922. fmt.Println("initFlag")
  13923. if initFlag == 0 {
  13924. c.TestGetHnBasBaseInit()
  13925. }
  13926. basStr := c.GetBasBaseInfo()
  13927. if len(basStr) == 0 {
  13928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13929. return
  13930. }
  13931. fmt.Println(basStr)
  13932. bas := strings.Split(basStr, "|")
  13933. basNumber := bas[1]
  13934. fmt.Println(basNumber)
  13935. card_sn := bas[3]
  13936. card_no := bas[2]
  13937. fmt.Println(card_sn)
  13938. name := bas[4]
  13939. name = ConvertToString(name, "gbk", "utf-8")
  13940. 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)
  13941. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13942. var dat map[string]interface{}
  13943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13944. fmt.Println(dat)
  13945. } else {
  13946. fmt.Println(err)
  13947. }
  13948. userJSONBytes, _ := json.Marshal(dat)
  13949. var res ResultTwo
  13950. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13951. utils.ErrorLog("解析失败:%v", err)
  13952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13953. return
  13954. }
  13955. if res.Infcode == 0 {
  13956. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13957. if err == gorm.ErrRecordNotFound {
  13958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13959. return
  13960. } else if err != nil {
  13961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13962. return
  13963. } else {
  13964. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13965. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13966. infoStr := string(Iinfos)
  13967. idetinfoStr := string(Idetinfos)
  13968. psn := &models.HisPsn{
  13969. PsnNo: res.Output.Baseinfo.PsnNo,
  13970. PatientId: patient.ID,
  13971. Certno: res.Output.Baseinfo.Certno,
  13972. Gend: res.Output.Baseinfo.Gend,
  13973. Naty: res.Output.Baseinfo.Naty,
  13974. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13975. PsnName: res.Output.Baseinfo.PsnName,
  13976. Idetinfo: idetinfoStr,
  13977. Insuinfo: infoStr,
  13978. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13979. CardInfo: basStr,
  13980. VerifyNumber: "",
  13981. }
  13982. service.CreateHisPsn(psn)
  13983. var rf []*ResultFive
  13984. json.Unmarshal([]byte(infoStr), &rf)
  13985. var insutypes []*ResultFive
  13986. var insutype string
  13987. var is390 int = 0
  13988. var is310 int = 0
  13989. for _, item := range rf {
  13990. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13991. insutypes = append(insutypes, item)
  13992. }
  13993. }
  13994. if len(insutypes) == 1 {
  13995. insutype = insutypes[0].Insutype
  13996. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13997. } else {
  13998. for _, i := range insutypes {
  13999. if i.Insutype == "390" {
  14000. is390 = 1
  14001. }
  14002. if i.Insutype == "310" {
  14003. is310 = 1
  14004. }
  14005. }
  14006. }
  14007. if is390 == 1 {
  14008. insutype = "390"
  14009. }
  14010. if is310 == 1 {
  14011. insutype = "310"
  14012. }
  14013. if len(insutypes) == 0 {
  14014. insutype = "310"
  14015. }
  14016. c.ServeSuccessJSON(map[string]interface{}{
  14017. "patient": patient,
  14018. "number": basNumber,
  14019. "insutype": insutype,
  14020. })
  14021. }
  14022. } else {
  14023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14024. return
  14025. }
  14026. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14027. var api string
  14028. 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 +
  14029. "&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
  14030. fmt.Println(api)
  14031. resp, requestErr := http.Get(api)
  14032. if requestErr != nil {
  14033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14034. return
  14035. }
  14036. body, ioErr := ioutil.ReadAll(resp.Body)
  14037. if ioErr != nil {
  14038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14040. return
  14041. }
  14042. var respJSON map[string]interface{}
  14043. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14046. return
  14047. }
  14048. var res ResultTwo //1101结果
  14049. var res10265 ResultTwo10265 //1101结果
  14050. var card_info string //卡信息
  14051. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14052. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14053. result, _ := json.Marshal(respJSON)
  14054. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14055. utils.ErrorLog("解析失败:%v", err)
  14056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14057. return
  14058. }
  14059. res.ErrMsg = res10265.ErrMsg
  14060. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14061. res.Infcode = infocode
  14062. res.Output = res10265.Output
  14063. res.InfRefmsgid = res10265.InfRefmsgid
  14064. if res.Infcode == 0 {
  14065. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14066. if err == gorm.ErrRecordNotFound {
  14067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14068. return
  14069. } else if err != nil {
  14070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14071. return
  14072. } else {
  14073. bas := strings.Split(card_info, "|")
  14074. basNumber := bas[2]
  14075. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14076. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14077. infoStr := string(Iinfos)
  14078. idetinfoStr := string(Idetinfos)
  14079. psn := &models.HisPsn{
  14080. PsnNo: res.Output.Baseinfo.PsnNo,
  14081. PatientId: patient.ID,
  14082. Certno: res.Output.Baseinfo.Certno,
  14083. Gend: res.Output.Baseinfo.Gend,
  14084. Naty: res.Output.Baseinfo.Naty,
  14085. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14086. PsnName: res.Output.Baseinfo.PsnName,
  14087. Idetinfo: idetinfoStr,
  14088. Insuinfo: infoStr,
  14089. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14090. CardInfo: card_info,
  14091. VerifyNumber: token,
  14092. }
  14093. service.CreateHisPsn(psn)
  14094. var rf []*ResultFive
  14095. json.Unmarshal([]byte(infoStr), &rf)
  14096. var insutypes []*ResultFive
  14097. var insutype string
  14098. var is390 int = 0
  14099. var is310 int = 0
  14100. for _, item := range rf {
  14101. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14102. insutypes = append(insutypes, item)
  14103. }
  14104. }
  14105. if len(insutypes) == 1 {
  14106. insutype = insutypes[0].Insutype
  14107. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14108. } else {
  14109. for _, i := range insutypes {
  14110. if i.Insutype == "390" {
  14111. is390 = 1
  14112. }
  14113. if i.Insutype == "310" {
  14114. is310 = 1
  14115. }
  14116. }
  14117. }
  14118. if is390 == 1 {
  14119. insutype = "390"
  14120. }
  14121. if is310 == 1 {
  14122. insutype = "310"
  14123. }
  14124. if len(insutypes) == 0 {
  14125. insutype = "310"
  14126. }
  14127. c.ServeSuccessJSON(map[string]interface{}{
  14128. "patient": patient,
  14129. "number": basNumber,
  14130. "insutype": insutype,
  14131. })
  14132. }
  14133. } else {
  14134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14135. return
  14136. }
  14137. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14138. res := c.GetoleInfo()
  14139. if res.Infcode == 0 {
  14140. var result string
  14141. if res.Output.MdtrtCertType == "01" {
  14142. 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)
  14143. } else if res.Output.MdtrtCertType == "02" {
  14144. 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)
  14145. } else if res.Output.MdtrtCertType == "03" {
  14146. 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)
  14147. }
  14148. var dat map[string]interface{}
  14149. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14150. fmt.Println(dat)
  14151. } else {
  14152. fmt.Println(err)
  14153. }
  14154. userJSONBytes, _ := json.Marshal(dat)
  14155. var res2 ResultTwo
  14156. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14157. utils.ErrorLog("解析失败:%v", err)
  14158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14159. return
  14160. }
  14161. if res2.Infcode == 0 {
  14162. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14163. if err == gorm.ErrRecordNotFound {
  14164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14165. return
  14166. } else if err != nil {
  14167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14168. return
  14169. } else {
  14170. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14171. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14172. infoStr := string(Iinfos)
  14173. idetinfoStr := string(Idetinfos)
  14174. var rf []*ResultFive
  14175. json.Unmarshal([]byte(infoStr), &rf)
  14176. var insutypes []*ResultFive
  14177. var insutype string
  14178. var is390 int = 0
  14179. var is310 int = 0
  14180. //var insuplc_admdvs string
  14181. for _, item := range rf {
  14182. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14183. insutypes = append(insutypes, item)
  14184. }
  14185. }
  14186. if len(insutypes) == 1 {
  14187. insutype = insutypes[0].Insutype
  14188. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14189. } else {
  14190. for _, i := range insutypes {
  14191. if i.Insutype == "390" {
  14192. is390 = 1
  14193. }
  14194. if i.Insutype == "310" {
  14195. is310 = 1
  14196. }
  14197. }
  14198. }
  14199. if is390 == 1 {
  14200. insutype = "390"
  14201. }
  14202. if is310 == 1 {
  14203. insutype = "310"
  14204. }
  14205. if len(insutypes) == 0 {
  14206. insutype = "310"
  14207. }
  14208. psn := &models.HisPsn{
  14209. PsnNo: res2.Output.Baseinfo.PsnNo,
  14210. PatientId: patient.ID,
  14211. Certno: res2.Output.Baseinfo.Certno,
  14212. Gend: res2.Output.Baseinfo.Gend,
  14213. Naty: res2.Output.Baseinfo.Naty,
  14214. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14215. PsnName: res2.Output.Baseinfo.PsnName,
  14216. Idetinfo: idetinfoStr,
  14217. Insuinfo: infoStr,
  14218. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14219. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14220. VerifyNumber: res.Output.EcToken,
  14221. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14222. }
  14223. if res.Output.MdtrtCertType == "01" {
  14224. psn.VerifyNumber = res.Output.EcToken
  14225. //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)
  14226. } else if res.Output.MdtrtCertType == "02" {
  14227. psn.VerifyNumber = res.Output.MdtrtCertNo
  14228. //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)
  14229. } else if res.Output.MdtrtCertType == "03" {
  14230. psn.VerifyNumber = res.Output.MdtrtCertNo
  14231. //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)
  14232. }
  14233. var balc float64
  14234. for _, item := range rf {
  14235. if item.Insutype == insutype {
  14236. balc = item.Balc
  14237. }
  14238. }
  14239. service.CreateHisPsn(psn)
  14240. c.ServeSuccessJSON(map[string]interface{}{
  14241. "patient": patient,
  14242. "number": res.Output.CardNo,
  14243. "insutype": insutype,
  14244. "blac": balc,
  14245. "desc": idetinfoStr,
  14246. })
  14247. }
  14248. } else {
  14249. c.ServeSuccessJSON(map[string]interface{}{
  14250. "failed_code": -10,
  14251. "msg": res2.ErrMsg,
  14252. })
  14253. }
  14254. } else {
  14255. c.ServeSuccessJSON(map[string]interface{}{
  14256. "failed_code": -10,
  14257. "msg": res.ErrMsg,
  14258. })
  14259. }
  14260. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14261. var api string
  14262. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14263. "&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
  14264. fmt.Println(api)
  14265. resp, requestErr := http.Get(api)
  14266. if requestErr != nil {
  14267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14268. return
  14269. }
  14270. body, ioErr := ioutil.ReadAll(resp.Body)
  14271. if ioErr != nil {
  14272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14274. return
  14275. }
  14276. var respJSON map[string]interface{}
  14277. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14280. return
  14281. }
  14282. var status string
  14283. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14284. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14285. //console.log()
  14286. fmt.Println("type===")
  14287. fmt.Println(card_type)
  14288. var token string
  14289. var res ResultTwo //1101结果
  14290. //var res10265 ResultTwoesultTwo10265 //1101结果
  14291. var card_info string //卡信息
  14292. var busi_card_info string
  14293. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14294. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14295. if status == "0" { //读卡成功
  14296. if card_type == "1" {
  14297. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14298. result, _ := json.Marshal(respJSON)
  14299. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14300. utils.ErrorLog("解析失败:%v", err)
  14301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14302. return
  14303. }
  14304. } else {
  14305. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14306. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14307. result, _ := json.Marshal(respJSON)
  14308. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14309. utils.ErrorLog("解析失败:%v", err)
  14310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14311. return
  14312. }
  14313. }
  14314. if res.Infcode == 0 {
  14315. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14316. if err == gorm.ErrRecordNotFound {
  14317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14318. return
  14319. } else if err != nil {
  14320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14321. return
  14322. } else {
  14323. if card_type == "1" {
  14324. bas := strings.Split(card_info, "|")
  14325. basNumber := bas[2]
  14326. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14327. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14328. infoStr := string(Iinfos)
  14329. idetinfoStr := string(Idetinfos)
  14330. psn := &models.HisPsn{
  14331. PsnNo: res.Output.Baseinfo.PsnNo,
  14332. PatientId: patient.ID,
  14333. Certno: res.Output.Baseinfo.Certno,
  14334. Gend: res.Output.Baseinfo.Gend,
  14335. Naty: res.Output.Baseinfo.Naty,
  14336. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14337. PsnName: res.Output.Baseinfo.PsnName,
  14338. Idetinfo: idetinfoStr,
  14339. Insuinfo: infoStr,
  14340. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14341. CardInfo: card_info,
  14342. VerifyNumber: busi_card_info,
  14343. }
  14344. service.CreateHisPsn(psn)
  14345. var rf []*ResultFive
  14346. json.Unmarshal([]byte(infoStr), &rf)
  14347. var insutypes []*ResultFive
  14348. var insutype string
  14349. var is390 int = 0
  14350. var is310 int = 0
  14351. for _, item := range rf {
  14352. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14353. insutypes = append(insutypes, item)
  14354. }
  14355. }
  14356. if len(insutypes) == 1 {
  14357. insutype = insutypes[0].Insutype
  14358. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14359. } else {
  14360. for _, i := range insutypes {
  14361. if i.Insutype == "390" {
  14362. is390 = 1
  14363. }
  14364. if i.Insutype == "310" {
  14365. is310 = 1
  14366. }
  14367. }
  14368. }
  14369. if is390 == 1 {
  14370. insutype = "390"
  14371. }
  14372. if is310 == 1 {
  14373. insutype = "310"
  14374. }
  14375. if len(insutypes) == 0 {
  14376. insutype = "310"
  14377. }
  14378. c.ServeSuccessJSON(map[string]interface{}{
  14379. "patient": patient,
  14380. "number": basNumber,
  14381. "insutype": insutype,
  14382. })
  14383. } else {
  14384. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14385. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14386. infoStr := string(Iinfos)
  14387. idetinfoStr := string(Idetinfos)
  14388. psn := &models.HisPsn{
  14389. PsnNo: res.Output.Baseinfo.PsnNo,
  14390. PatientId: patient.ID,
  14391. Certno: res.Output.Baseinfo.Certno,
  14392. Gend: res.Output.Baseinfo.Gend,
  14393. Naty: res.Output.Baseinfo.Naty,
  14394. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14395. PsnName: res.Output.Baseinfo.PsnName,
  14396. Idetinfo: idetinfoStr,
  14397. Insuinfo: infoStr,
  14398. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14399. CardInfo: card_info,
  14400. VerifyNumber: token,
  14401. }
  14402. service.CreateHisPsn(psn)
  14403. c.ServeSuccessJSON(map[string]interface{}{
  14404. "patient": patient,
  14405. "number": token,
  14406. })
  14407. }
  14408. }
  14409. } else {
  14410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14411. return
  14412. }
  14413. } else { //读卡失败
  14414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14415. return
  14416. }
  14417. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14418. var api string
  14419. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14420. "&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
  14421. fmt.Println(api)
  14422. resp, requestErr := http.Get(api)
  14423. if requestErr != nil {
  14424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14425. return
  14426. }
  14427. body, ioErr := ioutil.ReadAll(resp.Body)
  14428. if ioErr != nil {
  14429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14431. return
  14432. }
  14433. var respJSON map[string]interface{}
  14434. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14437. return
  14438. }
  14439. var status string
  14440. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14441. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14442. //console.log()
  14443. fmt.Println("type===")
  14444. fmt.Println(card_type)
  14445. var token string
  14446. var res ResultTwo //1101结果
  14447. //var res10265 ResultTwoesultTwo10265 //1101结果
  14448. var card_info string //卡信息
  14449. //var busi_card_info string
  14450. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14451. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14452. if status == "0" { //读卡成功
  14453. if card_type == "1" {
  14454. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14455. result, _ := json.Marshal(respJSON)
  14456. fmt.Println(result)
  14457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14458. utils.ErrorLog("解析失败:%v", err)
  14459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14460. return
  14461. }
  14462. fmt.Println(res)
  14463. } else {
  14464. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14465. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14466. result, _ := json.Marshal(respJSON)
  14467. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14468. utils.ErrorLog("解析失败:%v", err)
  14469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14470. return
  14471. }
  14472. }
  14473. if res.Infcode == 0 {
  14474. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14475. if err == gorm.ErrRecordNotFound {
  14476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14477. return
  14478. } else if err != nil {
  14479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14480. return
  14481. } else {
  14482. if card_type == "1" {
  14483. bas := strings.Split(card_info, "|")
  14484. basNumber := bas[2]
  14485. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14486. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14487. infoStr := string(Iinfos)
  14488. idetinfoStr := string(Idetinfos)
  14489. psn := &models.HisPsn{
  14490. PsnNo: res.Output.Baseinfo.PsnNo,
  14491. PatientId: patient.ID,
  14492. Certno: res.Output.Baseinfo.Certno,
  14493. Gend: res.Output.Baseinfo.Gend,
  14494. Naty: res.Output.Baseinfo.Naty,
  14495. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14496. PsnName: res.Output.Baseinfo.PsnName,
  14497. Idetinfo: idetinfoStr,
  14498. Insuinfo: infoStr,
  14499. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14500. CardInfo: card_info,
  14501. //VerifyNumber: busi_card_info,
  14502. }
  14503. service.CreateHisPsn(psn)
  14504. var rf []*ResultFive
  14505. json.Unmarshal([]byte(infoStr), &rf)
  14506. var insutypes []*ResultFive
  14507. var insutype string
  14508. var is390 int = 0
  14509. var is310 int = 0
  14510. for _, item := range rf {
  14511. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14512. insutypes = append(insutypes, item)
  14513. }
  14514. }
  14515. if len(insutypes) == 1 {
  14516. insutype = insutypes[0].Insutype
  14517. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14518. } else {
  14519. for _, i := range insutypes {
  14520. if i.Insutype == "390" {
  14521. is390 = 1
  14522. }
  14523. if i.Insutype == "310" {
  14524. is310 = 1
  14525. }
  14526. }
  14527. }
  14528. if is390 == 1 {
  14529. insutype = "390"
  14530. }
  14531. if is310 == 1 {
  14532. insutype = "310"
  14533. }
  14534. if len(insutypes) == 0 {
  14535. insutype = "310"
  14536. }
  14537. c.ServeSuccessJSON(map[string]interface{}{
  14538. "patient": patient,
  14539. "number": basNumber,
  14540. "insutype": insutype,
  14541. })
  14542. } else {
  14543. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14544. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14545. infoStr := string(Iinfos)
  14546. idetinfoStr := string(Idetinfos)
  14547. psn := &models.HisPsn{
  14548. PsnNo: res.Output.Baseinfo.PsnNo,
  14549. PatientId: patient.ID,
  14550. Certno: res.Output.Baseinfo.Certno,
  14551. Gend: res.Output.Baseinfo.Gend,
  14552. Naty: res.Output.Baseinfo.Naty,
  14553. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14554. PsnName: res.Output.Baseinfo.PsnName,
  14555. Idetinfo: idetinfoStr,
  14556. Insuinfo: infoStr,
  14557. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14558. CardInfo: card_info,
  14559. VerifyNumber: token,
  14560. }
  14561. service.CreateHisPsn(psn)
  14562. c.ServeSuccessJSON(map[string]interface{}{
  14563. "patient": patient,
  14564. "number": token,
  14565. })
  14566. }
  14567. }
  14568. } else {
  14569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14570. return
  14571. }
  14572. } else { //读卡失败
  14573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14574. return
  14575. }
  14576. } else {
  14577. if initFlag == 0 {
  14578. c.TestGetBasBaseInit()
  14579. }
  14580. basStr := c.GetBasBaseInfo()
  14581. if len(basStr) == 0 {
  14582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14583. return
  14584. }
  14585. fmt.Println(basStr)
  14586. bas := strings.Split(basStr, "|")
  14587. basNumber := bas[1]
  14588. fmt.Println(basNumber)
  14589. card_sn := bas[3]
  14590. fmt.Println(card_sn)
  14591. cardNumber := bas[2]
  14592. fmt.Println(cardNumber)
  14593. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14594. var result string
  14595. if bas[0][:2] == "44" {
  14596. 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)
  14597. } else {
  14598. 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)
  14599. }
  14600. var dat map[string]interface{}
  14601. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14602. fmt.Println(dat)
  14603. } else {
  14604. fmt.Println(err)
  14605. }
  14606. userJSONBytes, _ := json.Marshal(dat)
  14607. var res ResultTwo
  14608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14609. utils.ErrorLog("解析失败:%v", err)
  14610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14611. return
  14612. }
  14613. if res.Infcode == 0 {
  14614. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14615. if err == gorm.ErrRecordNotFound {
  14616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14617. return
  14618. } else if err != nil {
  14619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14620. return
  14621. } else {
  14622. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14623. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14624. infoStr := string(Iinfos)
  14625. idetinfoStr := string(Idetinfos)
  14626. var rf []*ResultFive
  14627. json.Unmarshal([]byte(infoStr), &rf)
  14628. var insutypes []*ResultFive
  14629. var insutype string
  14630. var is390 int = 0
  14631. var is310 int = 0
  14632. var insuplc_admdvs string
  14633. for _, item := range rf {
  14634. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14635. insutypes = append(insutypes, item)
  14636. }
  14637. }
  14638. if len(insutypes) == 1 {
  14639. insutype = insutypes[0].Insutype
  14640. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14641. } else {
  14642. for _, i := range insutypes {
  14643. if i.Insutype == "390" {
  14644. is390 = 1
  14645. }
  14646. if i.Insutype == "310" {
  14647. is310 = 1
  14648. }
  14649. }
  14650. }
  14651. if is390 == 1 {
  14652. insutype = "390"
  14653. }
  14654. if is310 == 1 {
  14655. insutype = "310"
  14656. }
  14657. if len(insutypes) == 0 {
  14658. insutype = "310"
  14659. }
  14660. for _, item := range rf {
  14661. if item.Insutype == insutype {
  14662. insuplc_admdvs = item.InsuplcAdmdvs
  14663. }
  14664. }
  14665. psn := &models.HisPsn{
  14666. PsnNo: res.Output.Baseinfo.PsnNo,
  14667. PatientId: patient.ID,
  14668. Certno: res.Output.Baseinfo.Certno,
  14669. Gend: res.Output.Baseinfo.Gend,
  14670. Naty: res.Output.Baseinfo.Naty,
  14671. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14672. PsnName: res.Output.Baseinfo.PsnName,
  14673. Idetinfo: idetinfoStr,
  14674. Insuinfo: infoStr,
  14675. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14676. CardInfo: basStr,
  14677. VerifyNumber: "",
  14678. InsuplcAdmdvs: insuplc_admdvs,
  14679. }
  14680. service.CreateHisPsn(psn)
  14681. c.ServeSuccessJSON(map[string]interface{}{
  14682. "patient": patient,
  14683. "number": basNumber,
  14684. })
  14685. }
  14686. } else {
  14687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14688. return
  14689. }
  14690. break
  14691. }
  14692. case 2:
  14693. if miConfig.MdtrtareaAdmvs == "430800" {
  14694. if initFlag == 0 {
  14695. c.TestGetHnBasBaseInit()
  14696. }
  14697. SFZStr := c.GetSFZBaseInfo()
  14698. if len(SFZStr) == 0 {
  14699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14700. return
  14701. }
  14702. fmt.Println(SFZStr)
  14703. id_card_str := strings.Split(SFZStr, "^")
  14704. card_no := id_card_str[0]
  14705. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14706. //name := id_card_str[1]
  14707. //name = ConvertToString(name, "gbk", "utf-8")
  14708. 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)
  14709. var dat map[string]interface{}
  14710. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14711. fmt.Println(dat)
  14712. } else {
  14713. fmt.Println(err)
  14714. }
  14715. userJSONBytes, _ := json.Marshal(dat)
  14716. var res ResultTwo
  14717. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14718. utils.ErrorLog("解析失败:%v", err)
  14719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14720. return
  14721. }
  14722. if res.Infcode == 0 {
  14723. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14724. if err == gorm.ErrRecordNotFound {
  14725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14726. return
  14727. } else if err != nil {
  14728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14729. return
  14730. } else {
  14731. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14732. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14733. infoStr := string(Iinfos)
  14734. idetinfoStr := string(Idetinfos)
  14735. var rf []*ResultFive
  14736. json.Unmarshal([]byte(infoStr), &rf)
  14737. var insutypes []*ResultFive
  14738. var insutype string
  14739. var is390 int = 0
  14740. var is310 int = 0
  14741. for _, item := range rf {
  14742. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14743. insutypes = append(insutypes, item)
  14744. }
  14745. }
  14746. if len(insutypes) == 1 {
  14747. insutype = insutypes[0].Insutype
  14748. } else {
  14749. for _, i := range insutypes {
  14750. if i.Insutype == "390" {
  14751. is390 = 1
  14752. }
  14753. if i.Insutype == "310" {
  14754. is310 = 1
  14755. }
  14756. }
  14757. }
  14758. if is390 == 1 {
  14759. insutype = "390"
  14760. }
  14761. if is310 == 1 {
  14762. insutype = "310"
  14763. }
  14764. if len(insutypes) == 0 {
  14765. insutype = "310"
  14766. }
  14767. var InsuplcAdmdvs string
  14768. for _, item := range rf {
  14769. if item.Insutype == insutype {
  14770. InsuplcAdmdvs = item.InsuplcAdmdvs
  14771. }
  14772. }
  14773. psn := &models.HisPsn{
  14774. PsnNo: res.Output.Baseinfo.PsnNo,
  14775. PatientId: patient.ID,
  14776. Certno: res.Output.Baseinfo.Certno,
  14777. Gend: res.Output.Baseinfo.Gend,
  14778. Naty: res.Output.Baseinfo.Naty,
  14779. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14780. PsnName: res.Output.Baseinfo.PsnName,
  14781. Idetinfo: idetinfoStr,
  14782. Insuinfo: infoStr,
  14783. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14784. CardInfo: SFZStr,
  14785. VerifyNumber: "",
  14786. InsuplcAdmdvs: InsuplcAdmdvs,
  14787. }
  14788. service.CreateHisPsn(psn)
  14789. c.ServeSuccessJSON(map[string]interface{}{
  14790. "patient": patient,
  14791. "number": card_no,
  14792. "insutype": insutype,
  14793. })
  14794. }
  14795. } else {
  14796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14797. return
  14798. }
  14799. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14800. var res ResultTwo
  14801. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14802. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14803. "&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)
  14804. resp, requestErr := http.Get(api)
  14805. if requestErr != nil {
  14806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14807. return
  14808. }
  14809. body, ioErr := ioutil.ReadAll(resp.Body)
  14810. if ioErr != nil {
  14811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14813. return
  14814. }
  14815. var respJSON map[string]interface{}
  14816. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14819. return
  14820. }
  14821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14822. result, _ := json.Marshal(respJSON)
  14823. fmt.Println("log")
  14824. fmt.Println(string(result))
  14825. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14826. utils.ErrorLog("解析失败:%v", err)
  14827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14828. return
  14829. }
  14830. if res.Infcode == 0 {
  14831. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14832. if err == gorm.ErrRecordNotFound {
  14833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14834. return
  14835. } else if err != nil {
  14836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14837. return
  14838. } else {
  14839. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14840. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14841. infoStr := string(Iinfos)
  14842. idetinfoStr := string(Idetinfos)
  14843. psn := &models.HisPsn{
  14844. PsnNo: res.Output.Baseinfo.PsnNo,
  14845. PatientId: patient.ID,
  14846. Certno: res.Output.Baseinfo.Certno,
  14847. Gend: res.Output.Baseinfo.Gend,
  14848. Naty: res.Output.Baseinfo.Naty,
  14849. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14850. PsnName: res.Output.Baseinfo.PsnName,
  14851. Idetinfo: idetinfoStr,
  14852. Insuinfo: infoStr,
  14853. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14854. }
  14855. service.CreateHisPsn(psn)
  14856. c.ServeSuccessJSON(map[string]interface{}{
  14857. "patient": patient,
  14858. "number": res.Output.Baseinfo.Certno,
  14859. })
  14860. }
  14861. } else {
  14862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14863. return
  14864. }
  14865. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14866. var res ResultTwo
  14867. api := miConfig.Url + "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 == "420902" {
  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. var rf []*ResultFive
  14976. json.Unmarshal([]byte(infoStr), &rf)
  14977. var insutypes []*ResultFive
  14978. var insutype string
  14979. var is390 int = 0
  14980. var is310 int = 0
  14981. for _, item := range rf {
  14982. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14983. insutypes = append(insutypes, item)
  14984. }
  14985. }
  14986. if len(insutypes) == 1 {
  14987. insutype = insutypes[0].Insutype
  14988. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14989. } else {
  14990. for _, i := range insutypes {
  14991. if i.Insutype == "390" {
  14992. is390 = 1
  14993. }
  14994. if i.Insutype == "310" {
  14995. is310 = 1
  14996. }
  14997. }
  14998. }
  14999. if is390 == 1 {
  15000. insutype = "390"
  15001. }
  15002. if is310 == 1 {
  15003. insutype = "310"
  15004. }
  15005. if len(insutypes) == 0 {
  15006. insutype = "390"
  15007. }
  15008. var insuplc_admdvs string
  15009. for _, item := range rf {
  15010. if item.Insutype == insutype {
  15011. insuplc_admdvs = item.InsuplcAdmdvs
  15012. }
  15013. }
  15014. psn := &models.HisPsn{
  15015. PsnNo: res.Output.Baseinfo.PsnNo,
  15016. PatientId: patient.ID,
  15017. Certno: res.Output.Baseinfo.Certno,
  15018. Gend: res.Output.Baseinfo.Gend,
  15019. Naty: res.Output.Baseinfo.Naty,
  15020. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15021. PsnName: res.Output.Baseinfo.PsnName,
  15022. Idetinfo: idetinfoStr,
  15023. Insuinfo: infoStr,
  15024. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15025. InsuplcAdmdvs: insuplc_admdvs,
  15026. }
  15027. service.CreateHisPsn(psn)
  15028. c.ServeSuccessJSON(map[string]interface{}{
  15029. "patient": patient,
  15030. "number": res.Output.Baseinfo.Certno,
  15031. })
  15032. }
  15033. } else {
  15034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15035. return
  15036. }
  15037. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15038. res := c.GetoleInfo()
  15039. if res.Infcode == 0 {
  15040. var result string
  15041. if res.Output.MdtrtCertType == "01" {
  15042. 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)
  15043. } else if res.Output.MdtrtCertType == "02" {
  15044. 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)
  15045. } else if res.Output.MdtrtCertType == "03" {
  15046. 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)
  15047. }
  15048. var dat map[string]interface{}
  15049. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15050. fmt.Println(dat)
  15051. } else {
  15052. fmt.Println(err)
  15053. }
  15054. userJSONBytes, _ := json.Marshal(dat)
  15055. var res2 ResultTwo
  15056. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15057. utils.ErrorLog("解析失败:%v", err)
  15058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15059. return
  15060. }
  15061. if res2.Infcode == 0 {
  15062. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15063. if err == gorm.ErrRecordNotFound {
  15064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15065. return
  15066. } else if err != nil {
  15067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15068. return
  15069. } else {
  15070. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15071. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15072. infoStr := string(Iinfos)
  15073. idetinfoStr := string(Idetinfos)
  15074. var rf []*ResultFive
  15075. json.Unmarshal([]byte(infoStr), &rf)
  15076. var insutypes []*ResultFive
  15077. var insutype string
  15078. var is390 int = 0
  15079. var is310 int = 0
  15080. //var insuplc_admdvs string
  15081. for _, item := range rf {
  15082. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15083. insutypes = append(insutypes, item)
  15084. }
  15085. }
  15086. if len(insutypes) == 1 {
  15087. insutype = insutypes[0].Insutype
  15088. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15089. } else {
  15090. for _, i := range insutypes {
  15091. if i.Insutype == "390" {
  15092. is390 = 1
  15093. }
  15094. if i.Insutype == "310" {
  15095. is310 = 1
  15096. }
  15097. }
  15098. }
  15099. if is390 == 1 {
  15100. insutype = "390"
  15101. }
  15102. if is310 == 1 {
  15103. insutype = "310"
  15104. }
  15105. if len(insutypes) == 0 {
  15106. insutype = "310"
  15107. }
  15108. psn := &models.HisPsn{
  15109. PsnNo: res2.Output.Baseinfo.PsnNo,
  15110. PatientId: patient.ID,
  15111. //Brdy: res2.Output.Baseinfo.Brdy,
  15112. Certno: res2.Output.Baseinfo.Certno,
  15113. Gend: res2.Output.Baseinfo.Gend,
  15114. Naty: res2.Output.Baseinfo.Naty,
  15115. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15116. PsnName: res2.Output.Baseinfo.PsnName,
  15117. Idetinfo: idetinfoStr,
  15118. Insuinfo: infoStr,
  15119. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15120. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15121. VerifyNumber: res.Output.EcToken,
  15122. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15123. }
  15124. service.CreateHisPsn(psn)
  15125. var balc float64
  15126. for _, item := range rf {
  15127. if item.Insutype == insutype {
  15128. balc = item.Balc
  15129. }
  15130. }
  15131. c.ServeSuccessJSON(map[string]interface{}{
  15132. "patient": patient,
  15133. "number": res.Output.CardNo,
  15134. "insutype": insutype,
  15135. "blac": balc,
  15136. "desc": idetinfoStr,
  15137. })
  15138. }
  15139. } else {
  15140. c.ServeSuccessJSON(map[string]interface{}{
  15141. "failed_code": -10,
  15142. "msg": res2.ErrMsg,
  15143. })
  15144. }
  15145. } else {
  15146. c.ServeSuccessJSON(map[string]interface{}{
  15147. "failed_code": -10,
  15148. "msg": res.ErrMsg,
  15149. })
  15150. }
  15151. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15152. var insuplc_admdvs string
  15153. if len(patient.InsuplcAdmdvs) > 0 {
  15154. insuplc_admdvs = patient.InsuplcAdmdvs
  15155. } else {
  15156. if len(insuplc_admdvs_str) > 0 {
  15157. insuplc_admdvs = insuplc_admdvs_str
  15158. } else {
  15159. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15160. }
  15161. }
  15162. //请求内网数据
  15163. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15164. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15165. "&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=" + ""
  15166. resp, requestErr := http.Get(api)
  15167. if requestErr != nil {
  15168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15169. return
  15170. }
  15171. body, ioErr := ioutil.ReadAll(resp.Body)
  15172. if ioErr != nil {
  15173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15175. return
  15176. }
  15177. var respJSON map[string]interface{}
  15178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15181. return
  15182. }
  15183. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15184. if status == "0" {
  15185. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15186. c.ServeSuccessJSON(map[string]interface{}{
  15187. "failed_code": -10,
  15188. "msg": err_msg,
  15189. })
  15190. return
  15191. }
  15192. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15193. var res ResultTwo
  15194. result, _ := json.Marshal(respJSON)
  15195. fmt.Println("log")
  15196. fmt.Println(string(result))
  15197. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15198. utils.ErrorLog("解析失败:%v", err)
  15199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15200. return
  15201. }
  15202. if res.Infcode == 0 {
  15203. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15204. if err == gorm.ErrRecordNotFound {
  15205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15206. return
  15207. } else if err != nil {
  15208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15209. return
  15210. } else {
  15211. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15212. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15213. infoStr := string(Iinfos)
  15214. idetinfoStr := string(Idetinfos)
  15215. psn := &models.HisPsn{
  15216. PsnNo: res.Output.Baseinfo.PsnNo,
  15217. PatientId: patient.ID,
  15218. Certno: res.Output.Baseinfo.Certno,
  15219. Gend: res.Output.Baseinfo.Gend,
  15220. Naty: res.Output.Baseinfo.Naty,
  15221. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15222. PsnName: res.Output.Baseinfo.PsnName,
  15223. Idetinfo: idetinfoStr,
  15224. Insuinfo: infoStr,
  15225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15226. }
  15227. service.CreateHisPsn(psn)
  15228. var rf []*ResultFive
  15229. json.Unmarshal([]byte(infoStr), &rf)
  15230. var insutypes []*ResultFive
  15231. var is390 int = 0
  15232. var is310 int = 0
  15233. var insutype string
  15234. for _, item := range rf {
  15235. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15236. insutypes = append(insutypes, item)
  15237. }
  15238. }
  15239. if len(insutypes) == 1 {
  15240. insutype = insutypes[0].Insutype
  15241. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15242. } else {
  15243. for _, i := range insutypes {
  15244. if i.Insutype == "390" {
  15245. is390 = 1
  15246. }
  15247. if i.Insutype == "310" {
  15248. is310 = 1
  15249. }
  15250. }
  15251. }
  15252. if is390 == 1 {
  15253. insutype = "390"
  15254. }
  15255. if is310 == 1 {
  15256. insutype = "310"
  15257. }
  15258. if len(insutypes) == 0 {
  15259. insutype = "390"
  15260. }
  15261. c.ServeSuccessJSON(map[string]interface{}{
  15262. "patient": patient,
  15263. "insutype": insutype,
  15264. "number": res.Output.Baseinfo.Certno,
  15265. "info": res,
  15266. })
  15267. }
  15268. } else {
  15269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15270. return
  15271. }
  15272. } else {
  15273. SFZStr := c.GetSFZBaseInfo()
  15274. id_card_str := strings.Split(SFZStr, "^")
  15275. id_card_number := id_card_str[0]
  15276. card_sn := ""
  15277. 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)
  15278. var dat map[string]interface{}
  15279. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15280. fmt.Println(dat)
  15281. } else {
  15282. fmt.Println(err)
  15283. }
  15284. userJSONBytes, _ := json.Marshal(dat)
  15285. var res ResultTwo
  15286. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15287. utils.ErrorLog("解析失败:%v", err)
  15288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15289. return
  15290. }
  15291. if res.Infcode == 0 {
  15292. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15293. if err == gorm.ErrRecordNotFound {
  15294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15295. return
  15296. } else if err != nil {
  15297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15298. return
  15299. } else {
  15300. c.ServeSuccessJSON(map[string]interface{}{
  15301. "patient": patient,
  15302. "number": id_card_number,
  15303. })
  15304. }
  15305. } else {
  15306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15307. return
  15308. }
  15309. }
  15310. break
  15311. case 3:
  15312. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15313. var api string
  15314. if miConfig.MdtrtareaAdmvs == "320921" {
  15315. 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 +
  15316. "&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
  15317. fmt.Println(api)
  15318. } else {
  15319. 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 +
  15320. "&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)
  15321. }
  15322. resp, requestErr := http.Get(api)
  15323. if requestErr != nil {
  15324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15325. return
  15326. }
  15327. body, ioErr := ioutil.ReadAll(resp.Body)
  15328. if ioErr != nil {
  15329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15331. return
  15332. }
  15333. var respJSON map[string]interface{}
  15334. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15337. return
  15338. }
  15339. var status string
  15340. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15341. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15342. var token string
  15343. var res ResultTwo //1101结果
  15344. var res10265 ResultTwo10265 //1101结果
  15345. var card_info string //卡信息
  15346. var busi_card_info string
  15347. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15348. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15349. if status == "0" { //读卡成功
  15350. if card_type == "1" {
  15351. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15352. result, _ := json.Marshal(respJSON)
  15353. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15354. utils.ErrorLog("解析失败:%v", err)
  15355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15356. return
  15357. }
  15358. res.ErrMsg = res10265.ErrMsg
  15359. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15360. res.Infcode = infocode
  15361. res.Output = res10265.Output
  15362. res.InfRefmsgid = res10265.InfRefmsgid
  15363. } else {
  15364. //var card_info string //卡信息
  15365. //var busi_card_info string
  15366. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15367. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15368. //fmt.Println(card_info)
  15369. //fmt.Println(busi_card_info)
  15370. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15371. result, _ := json.Marshal(respJSON)
  15372. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15373. utils.ErrorLog("解析失败:%v", err)
  15374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15375. return
  15376. }
  15377. res.ErrMsg = res10265.ErrMsg
  15378. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15379. res.Infcode = infocode
  15380. res.Output = res10265.Output
  15381. res.InfRefmsgid = res10265.InfRefmsgid
  15382. }
  15383. if res.Infcode == 0 {
  15384. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15385. if err == gorm.ErrRecordNotFound {
  15386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15387. return
  15388. } else if err != nil {
  15389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15390. return
  15391. } else {
  15392. if card_type == "1" {
  15393. bas := strings.Split(card_info, "|")
  15394. basNumber := bas[2]
  15395. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15396. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15397. infoStr := string(Iinfos)
  15398. idetinfoStr := string(Idetinfos)
  15399. psn := &models.HisPsn{
  15400. PsnNo: res.Output.Baseinfo.PsnNo,
  15401. PatientId: patient.ID,
  15402. Certno: res.Output.Baseinfo.Certno,
  15403. //Brdy: res.Output.Baseinfo.Brdy,
  15404. Gend: res.Output.Baseinfo.Gend,
  15405. Naty: res.Output.Baseinfo.Naty,
  15406. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15407. PsnName: res.Output.Baseinfo.PsnName,
  15408. Idetinfo: idetinfoStr,
  15409. Insuinfo: infoStr,
  15410. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15411. CardInfo: card_info,
  15412. VerifyNumber: busi_card_info,
  15413. }
  15414. service.CreateHisPsn(psn)
  15415. c.ServeSuccessJSON(map[string]interface{}{
  15416. "patient": patient,
  15417. "number": basNumber,
  15418. })
  15419. } else {
  15420. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15421. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15422. infoStr := string(Iinfos)
  15423. idetinfoStr := string(Idetinfos)
  15424. psn := &models.HisPsn{
  15425. PsnNo: res.Output.Baseinfo.PsnNo,
  15426. PatientId: patient.ID,
  15427. Certno: res.Output.Baseinfo.Certno,
  15428. Gend: res.Output.Baseinfo.Gend,
  15429. Naty: res.Output.Baseinfo.Naty,
  15430. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15431. PsnName: res.Output.Baseinfo.PsnName,
  15432. Idetinfo: idetinfoStr,
  15433. Insuinfo: infoStr,
  15434. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15435. CardInfo: card_info,
  15436. VerifyNumber: token,
  15437. }
  15438. service.CreateHisPsn(psn)
  15439. var rf []*ResultFive
  15440. json.Unmarshal([]byte(infoStr), &rf)
  15441. var insutypes []*ResultFive
  15442. var insutype string
  15443. var is390 int = 0
  15444. var is310 int = 0
  15445. for _, item := range rf {
  15446. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15447. insutypes = append(insutypes, item)
  15448. }
  15449. }
  15450. if len(insutypes) == 1 {
  15451. insutype = insutypes[0].Insutype
  15452. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15453. } else {
  15454. for _, i := range insutypes {
  15455. if i.Insutype == "390" {
  15456. is390 = 1
  15457. }
  15458. if i.Insutype == "310" {
  15459. is310 = 1
  15460. }
  15461. }
  15462. }
  15463. if is390 == 1 {
  15464. insutype = "390"
  15465. }
  15466. if is310 == 1 {
  15467. insutype = "310"
  15468. }
  15469. if len(insutypes) == 0 {
  15470. insutype = "310"
  15471. }
  15472. c.ServeSuccessJSON(map[string]interface{}{
  15473. "patient": patient,
  15474. "number": token,
  15475. "insutype": insutype,
  15476. })
  15477. }
  15478. }
  15479. } else {
  15480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15481. return
  15482. }
  15483. } else { //读卡失败
  15484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15485. return
  15486. }
  15487. }
  15488. break
  15489. case 4:
  15490. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15491. var api string
  15492. if miConfig.MdtrtareaAdmvs == "320921" {
  15493. 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 +
  15494. "&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
  15495. fmt.Println(api)
  15496. } else {
  15497. 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 +
  15498. "&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)
  15499. }
  15500. resp, requestErr := http.Get(api)
  15501. if requestErr != nil {
  15502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15503. return
  15504. }
  15505. body, ioErr := ioutil.ReadAll(resp.Body)
  15506. if ioErr != nil {
  15507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15509. return
  15510. }
  15511. var respJSON map[string]interface{}
  15512. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15515. return
  15516. }
  15517. var status string
  15518. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15519. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15520. var token string
  15521. var res ResultTwo //1101结果
  15522. var res10265 ResultTwo10265 //1101结果
  15523. if status == "0" { //读卡成功
  15524. var card_info string //卡信息
  15525. var busi_card_info string
  15526. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15527. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15528. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15529. fmt.Println(card_info)
  15530. fmt.Println(busi_card_info)
  15531. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15532. result, _ := json.Marshal(respJSON)
  15533. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15534. utils.ErrorLog("解析失败:%v", err)
  15535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15536. return
  15537. }
  15538. res.ErrMsg = res10265.ErrMsg
  15539. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15540. res.Infcode = infocode
  15541. res.Output = res10265.Output
  15542. res.InfRefmsgid = res10265.InfRefmsgid
  15543. if res.Infcode == 0 {
  15544. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15545. if err == gorm.ErrRecordNotFound {
  15546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15547. return
  15548. } else if err != nil {
  15549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15550. return
  15551. } else {
  15552. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15553. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15554. infoStr := string(Iinfos)
  15555. idetinfoStr := string(Idetinfos)
  15556. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15557. psn := &models.HisPsn{
  15558. PsnNo: res.Output.Baseinfo.PsnNo,
  15559. PatientId: patient.ID,
  15560. Certno: res.Output.Baseinfo.Certno,
  15561. Brdy: b,
  15562. Age: float64(age),
  15563. //Brdy: res.Output.Baseinfo.Brdy,
  15564. Gend: res.Output.Baseinfo.Gend,
  15565. Naty: res.Output.Baseinfo.Naty,
  15566. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15567. PsnName: res.Output.Baseinfo.PsnName,
  15568. Idetinfo: idetinfoStr,
  15569. Insuinfo: infoStr,
  15570. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15571. CardInfo: card_info,
  15572. VerifyNumber: token,
  15573. }
  15574. var rf []*ResultFive
  15575. json.Unmarshal([]byte(infoStr), &rf)
  15576. var insutypes []*ResultFive
  15577. var insutype string
  15578. var is390 int = 0
  15579. var is310 int = 0
  15580. for _, item := range rf {
  15581. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15582. insutypes = append(insutypes, item)
  15583. }
  15584. }
  15585. if len(insutypes) == 1 {
  15586. insutype = insutypes[0].Insutype
  15587. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15588. } else {
  15589. for _, i := range insutypes {
  15590. if i.Insutype == "390" {
  15591. is390 = 1
  15592. }
  15593. if i.Insutype == "310" {
  15594. is310 = 1
  15595. }
  15596. }
  15597. }
  15598. if is390 == 1 {
  15599. insutype = "390"
  15600. }
  15601. if is310 == 1 {
  15602. insutype = "310"
  15603. }
  15604. if len(insutypes) == 0 {
  15605. insutype = "310"
  15606. }
  15607. service.CreateHisPsn(psn)
  15608. c.ServeSuccessJSON(map[string]interface{}{
  15609. "patient": patient,
  15610. "number": token,
  15611. "insutype": insutype,
  15612. })
  15613. }
  15614. } else {
  15615. c.ServeSuccessJSON(map[string]interface{}{
  15616. "failed_code": -10,
  15617. "msg": res.ErrMsg,
  15618. })
  15619. }
  15620. } else { //读卡失败
  15621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15622. return
  15623. }
  15624. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15625. var api string
  15626. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15627. "&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
  15628. resp, requestErr := http.Get(api)
  15629. if requestErr != nil {
  15630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15631. return
  15632. }
  15633. body, ioErr := ioutil.ReadAll(resp.Body)
  15634. if ioErr != nil {
  15635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15637. return
  15638. }
  15639. var respJSON map[string]interface{}
  15640. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15643. return
  15644. }
  15645. var status string
  15646. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15647. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15648. var token string
  15649. var res ResultTwo //1101结果
  15650. if status == "1" { //读卡成功
  15651. var card_info string //卡信息
  15652. var busi_card_info string
  15653. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15654. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15655. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15656. fmt.Println(card_info)
  15657. fmt.Println(busi_card_info)
  15658. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15659. result, _ := json.Marshal(respJSON)
  15660. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15661. utils.ErrorLog("解析失败:%v", err)
  15662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15663. return
  15664. }
  15665. if res.Infcode == 0 {
  15666. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15667. if err == gorm.ErrRecordNotFound {
  15668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15669. return
  15670. } else if err != nil {
  15671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15672. return
  15673. } else {
  15674. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15675. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15676. infoStr := string(Iinfos)
  15677. idetinfoStr := string(Idetinfos)
  15678. psn := &models.HisPsn{
  15679. PsnNo: res.Output.Baseinfo.PsnNo,
  15680. PatientId: patient.ID,
  15681. Certno: res.Output.Baseinfo.Certno,
  15682. Gend: res.Output.Baseinfo.Gend,
  15683. Naty: res.Output.Baseinfo.Naty,
  15684. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15685. PsnName: res.Output.Baseinfo.PsnName,
  15686. Idetinfo: idetinfoStr,
  15687. Insuinfo: infoStr,
  15688. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15689. CardInfo: card_info,
  15690. VerifyNumber: token,
  15691. }
  15692. var rf []*ResultFive
  15693. json.Unmarshal([]byte(infoStr), &rf)
  15694. var insutypes []*ResultFive
  15695. var insutype string
  15696. var is390 int = 0
  15697. var is310 int = 0
  15698. for _, item := range rf {
  15699. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15700. insutypes = append(insutypes, item)
  15701. }
  15702. }
  15703. if len(insutypes) == 1 {
  15704. insutype = insutypes[0].Insutype
  15705. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15706. } else {
  15707. for _, i := range insutypes {
  15708. if i.Insutype == "390" {
  15709. is390 = 1
  15710. }
  15711. if i.Insutype == "310" {
  15712. is310 = 1
  15713. }
  15714. }
  15715. }
  15716. if is390 == 1 {
  15717. insutype = "390"
  15718. }
  15719. if is310 == 1 {
  15720. insutype = "310"
  15721. }
  15722. if len(insutypes) == 0 {
  15723. insutype = "310"
  15724. }
  15725. service.CreateHisPsn(psn)
  15726. c.ServeSuccessJSON(map[string]interface{}{
  15727. "patient": patient,
  15728. "number": token,
  15729. "insutype": insutype,
  15730. })
  15731. }
  15732. } else {
  15733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15734. return
  15735. }
  15736. } else { //读卡失败
  15737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15738. return
  15739. }
  15740. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15741. var api string
  15742. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15743. "&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
  15744. resp, requestErr := http.Get(api)
  15745. if requestErr != nil {
  15746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15747. return
  15748. }
  15749. body, ioErr := ioutil.ReadAll(resp.Body)
  15750. if ioErr != nil {
  15751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15753. return
  15754. }
  15755. var respJSON map[string]interface{}
  15756. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15759. return
  15760. }
  15761. var status string
  15762. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15763. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15764. var token string
  15765. var res ResultTwo //1101结果
  15766. if status == "1" { //读卡成功
  15767. var card_info string //卡信息
  15768. var busi_card_info string
  15769. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15770. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15771. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15772. fmt.Println(card_info)
  15773. fmt.Println(busi_card_info)
  15774. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15775. result, _ := json.Marshal(respJSON)
  15776. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15777. utils.ErrorLog("解析失败:%v", err)
  15778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15779. return
  15780. }
  15781. if res.Infcode == 0 {
  15782. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15783. if err == gorm.ErrRecordNotFound {
  15784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15785. return
  15786. } else if err != nil {
  15787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15788. return
  15789. } else {
  15790. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15791. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15792. infoStr := string(Iinfos)
  15793. idetinfoStr := string(Idetinfos)
  15794. psn := &models.HisPsn{
  15795. PsnNo: res.Output.Baseinfo.PsnNo,
  15796. PatientId: patient.ID,
  15797. Certno: res.Output.Baseinfo.Certno,
  15798. Gend: res.Output.Baseinfo.Gend,
  15799. Naty: res.Output.Baseinfo.Naty,
  15800. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15801. PsnName: res.Output.Baseinfo.PsnName,
  15802. Idetinfo: idetinfoStr,
  15803. Insuinfo: infoStr,
  15804. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15805. CardInfo: card_info,
  15806. VerifyNumber: token,
  15807. }
  15808. var rf []*ResultFive
  15809. json.Unmarshal([]byte(infoStr), &rf)
  15810. var insutypes []*ResultFive
  15811. var insutype string
  15812. var is390 int = 0
  15813. var is310 int = 0
  15814. for _, item := range rf {
  15815. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15816. insutypes = append(insutypes, item)
  15817. }
  15818. }
  15819. if len(insutypes) == 1 {
  15820. insutype = insutypes[0].Insutype
  15821. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15822. } else {
  15823. for _, i := range insutypes {
  15824. if i.Insutype == "390" {
  15825. is390 = 1
  15826. }
  15827. if i.Insutype == "310" {
  15828. is310 = 1
  15829. }
  15830. }
  15831. }
  15832. if is390 == 1 {
  15833. insutype = "390"
  15834. }
  15835. if is310 == 1 {
  15836. insutype = "310"
  15837. }
  15838. if len(insutypes) == 0 {
  15839. insutype = "310"
  15840. }
  15841. service.CreateHisPsn(psn)
  15842. c.ServeSuccessJSON(map[string]interface{}{
  15843. "patient": patient,
  15844. "number": token,
  15845. "insutype": insutype,
  15846. })
  15847. }
  15848. } else {
  15849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15850. return
  15851. }
  15852. } else { //读卡失败
  15853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15854. return
  15855. }
  15856. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15857. //idNo := c.GetString("idNo")
  15858. //userName := c.GetString("userName")
  15859. //ecToken := c.GetString("ecToken")
  15860. //insuOrg := c.GetString("insuOrg")
  15861. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15862. utils.ErrorLog("解析失败:%v", json_result)
  15863. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15864. type ELeData struct {
  15865. Data struct {
  15866. IdNo string `json:"idNo"`
  15867. IdType string `json:"idType"`
  15868. UserName string `json:"userName"`
  15869. EcToken string `json:"ecToken"`
  15870. InsuOrg string `json:"insuOrg"`
  15871. Gender string `json:"gender"`
  15872. Birthday string `json:"birthday"`
  15873. Nationality string `json:"nationality"`
  15874. Email string `json:"email"`
  15875. Extra string `json:"extra"`
  15876. } `json:"data"`
  15877. Code int `json:"code"`
  15878. Message string `json:"message"`
  15879. }
  15880. var ele ELeData
  15881. err := json.Unmarshal([]byte(json_result), &ele)
  15882. if err != nil {
  15883. utils.ErrorLog("解析失败:%v", err)
  15884. }
  15885. token := ele.Data.EcToken
  15886. token = Remove0000(token)
  15887. 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)
  15888. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15889. var res ResultTwo
  15890. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15891. utils.ErrorLog("解析失败:%v", err)
  15892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15893. return
  15894. }
  15895. if res.Infcode == 0 {
  15896. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15897. if err == gorm.ErrRecordNotFound {
  15898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15899. return
  15900. } else if err != nil {
  15901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15902. return
  15903. } else {
  15904. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15905. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15906. infoStr := string(Iinfos)
  15907. idetinfoStr := string(Idetinfos)
  15908. psn := &models.HisPsn{
  15909. PsnNo: res.Output.Baseinfo.PsnNo,
  15910. PatientId: patient.ID,
  15911. Certno: res.Output.Baseinfo.Certno,
  15912. Gend: res.Output.Baseinfo.Gend,
  15913. Naty: res.Output.Baseinfo.Naty,
  15914. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15915. PsnName: res.Output.Baseinfo.PsnName,
  15916. Idetinfo: idetinfoStr,
  15917. Insuinfo: infoStr,
  15918. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15919. CardInfo: "",
  15920. Stage: "1",
  15921. VerifyNumber: token,
  15922. InsuplcAdmdvs: ele.Data.InsuOrg,
  15923. }
  15924. service.CreateHisPsn(psn)
  15925. var rf []*ResultFive
  15926. json.Unmarshal([]byte(infoStr), &rf)
  15927. var insutypes []*ResultFive
  15928. var insutype string
  15929. var is390 int = 0
  15930. var is310 int = 0
  15931. for _, item := range rf {
  15932. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15933. insutypes = append(insutypes, item)
  15934. }
  15935. }
  15936. if len(insutypes) == 1 {
  15937. insutype = insutypes[0].Insutype
  15938. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15939. } else {
  15940. for _, i := range insutypes {
  15941. if i.Insutype == "390" {
  15942. is390 = 1
  15943. }
  15944. if i.Insutype == "310" {
  15945. is310 = 1
  15946. }
  15947. }
  15948. }
  15949. if is390 == 1 {
  15950. insutype = "390"
  15951. }
  15952. if is310 == 1 {
  15953. insutype = "310"
  15954. }
  15955. if len(insutypes) == 0 {
  15956. insutype = "310"
  15957. }
  15958. c.ServeSuccessJSON(map[string]interface{}{
  15959. "patient": patient,
  15960. "number": token,
  15961. "insutype": insutype,
  15962. })
  15963. }
  15964. } else {
  15965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15966. return
  15967. }
  15968. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15969. //if initFlag == 0 {
  15970. //c.TestGetJiangXiBasBaseInit()
  15971. //}
  15972. //if initEleFlag == 0 {
  15973. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15974. //}
  15975. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15976. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15977. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15978. type ELeData struct {
  15979. Data struct {
  15980. IdNo string `json:"idNo"`
  15981. IdType string `json:"idType"`
  15982. UserName string `json:"userName"`
  15983. EcToken string `json:"ecToken"`
  15984. InsuOrg string `json:"insuOrg"`
  15985. Gender string `json:"gender"`
  15986. Birthday string `json:"birthday"`
  15987. Nationality string `json:"nationality"`
  15988. Email string `json:"email"`
  15989. Extra string `json:"extra"`
  15990. } `json:"data"`
  15991. Code int `json:"code"`
  15992. Message string `json:"message"`
  15993. }
  15994. var ele ELeData
  15995. err := json.Unmarshal([]byte(result), &ele)
  15996. if err != nil {
  15997. utils.ErrorLog("解析失败:%v", err)
  15998. }
  15999. token := ele.Data.EcToken
  16000. token = Remove0000(token)
  16001. 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)
  16002. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16003. var res ResultTwo
  16004. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16005. utils.ErrorLog("解析失败:%v", err)
  16006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16007. return
  16008. }
  16009. if res.Infcode == 0 {
  16010. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16011. if err == gorm.ErrRecordNotFound {
  16012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16013. return
  16014. } else if err != nil {
  16015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16016. return
  16017. } else {
  16018. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16019. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16020. infoStr := string(Iinfos)
  16021. idetinfoStr := string(Idetinfos)
  16022. psn := &models.HisPsn{
  16023. PsnNo: res.Output.Baseinfo.PsnNo,
  16024. PatientId: patient.ID,
  16025. Certno: res.Output.Baseinfo.Certno,
  16026. Gend: res.Output.Baseinfo.Gend,
  16027. Naty: res.Output.Baseinfo.Naty,
  16028. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16029. PsnName: res.Output.Baseinfo.PsnName,
  16030. Idetinfo: idetinfoStr,
  16031. Insuinfo: infoStr,
  16032. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16033. CardInfo: "",
  16034. VerifyNumber: token,
  16035. InsuplcAdmdvs: ele.Data.InsuOrg,
  16036. }
  16037. service.CreateHisPsn(psn)
  16038. var rf []*ResultFive
  16039. json.Unmarshal([]byte(infoStr), &rf)
  16040. var insutypes []*ResultFive
  16041. var insutype string
  16042. var is390 int = 0
  16043. var is310 int = 0
  16044. for _, item := range rf {
  16045. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16046. insutypes = append(insutypes, item)
  16047. }
  16048. }
  16049. if len(insutypes) == 1 {
  16050. insutype = insutypes[0].Insutype
  16051. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16052. } else {
  16053. for _, i := range insutypes {
  16054. if i.Insutype == "390" {
  16055. is390 = 1
  16056. }
  16057. if i.Insutype == "310" {
  16058. is310 = 1
  16059. }
  16060. }
  16061. }
  16062. if is390 == 1 {
  16063. insutype = "390"
  16064. }
  16065. if is310 == 1 {
  16066. insutype = "310"
  16067. }
  16068. if len(insutypes) == 0 {
  16069. insutype = "310"
  16070. }
  16071. c.ServeSuccessJSON(map[string]interface{}{
  16072. "patient": patient,
  16073. "number": token,
  16074. "insutype": insutype,
  16075. })
  16076. }
  16077. } else {
  16078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16079. return
  16080. }
  16081. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16082. //if initFlag == 0 {
  16083. //c.TestGetJiangXiBasBaseInit()
  16084. //}
  16085. //if initEleFlag == 0 {
  16086. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16087. //}
  16088. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16089. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16090. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16091. type ELeData struct {
  16092. Data struct {
  16093. IdNo string `json:"idNo"`
  16094. IdType string `json:"idType"`
  16095. UserName string `json:"userName"`
  16096. EcToken string `json:"ecToken"`
  16097. InsuOrg string `json:"insuOrg"`
  16098. Gender string `json:"gender"`
  16099. Birthday string `json:"birthday"`
  16100. Nationality string `json:"nationality"`
  16101. Email string `json:"email"`
  16102. Extra string `json:"extra"`
  16103. } `json:"data"`
  16104. Code int `json:"code"`
  16105. Message string `json:"message"`
  16106. }
  16107. var ele ELeData
  16108. err := json.Unmarshal([]byte(result), &ele)
  16109. if err != nil {
  16110. utils.ErrorLog("解析失败:%v", err)
  16111. }
  16112. token := ele.Data.EcToken
  16113. token = Remove0000(token)
  16114. 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)
  16115. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16116. var res ResultTwo
  16117. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16118. utils.ErrorLog("解析失败:%v", err)
  16119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16120. return
  16121. }
  16122. if res.Infcode == 0 {
  16123. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16124. if err == gorm.ErrRecordNotFound {
  16125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16126. return
  16127. } else if err != nil {
  16128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16129. return
  16130. } else {
  16131. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16132. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16133. infoStr := string(Iinfos)
  16134. idetinfoStr := string(Idetinfos)
  16135. psn := &models.HisPsn{
  16136. PsnNo: res.Output.Baseinfo.PsnNo,
  16137. PatientId: patient.ID,
  16138. Certno: res.Output.Baseinfo.Certno,
  16139. Gend: res.Output.Baseinfo.Gend,
  16140. Naty: res.Output.Baseinfo.Naty,
  16141. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16142. PsnName: res.Output.Baseinfo.PsnName,
  16143. Idetinfo: idetinfoStr,
  16144. Insuinfo: infoStr,
  16145. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16146. CardInfo: "",
  16147. VerifyNumber: token,
  16148. InsuplcAdmdvs: ele.Data.InsuOrg,
  16149. }
  16150. service.CreateHisPsn(psn)
  16151. var rf []*ResultFive
  16152. json.Unmarshal([]byte(infoStr), &rf)
  16153. var insutypes []*ResultFive
  16154. var insutype string
  16155. var is390 int = 0
  16156. var is310 int = 0
  16157. for _, item := range rf {
  16158. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16159. insutypes = append(insutypes, item)
  16160. }
  16161. }
  16162. if len(insutypes) == 1 {
  16163. insutype = insutypes[0].Insutype
  16164. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16165. } else {
  16166. for _, i := range insutypes {
  16167. if i.Insutype == "390" {
  16168. is390 = 1
  16169. }
  16170. if i.Insutype == "310" {
  16171. is310 = 1
  16172. }
  16173. }
  16174. }
  16175. if is390 == 1 {
  16176. insutype = "390"
  16177. }
  16178. if is310 == 1 {
  16179. insutype = "310"
  16180. }
  16181. if len(insutypes) == 0 {
  16182. insutype = "310"
  16183. }
  16184. c.ServeSuccessJSON(map[string]interface{}{
  16185. "patient": patient,
  16186. "number": token,
  16187. "insutype": insutype,
  16188. })
  16189. }
  16190. } else {
  16191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16192. return
  16193. }
  16194. } else if miConfig.MdtrtareaAdmvs == "360100" {
  16195. //if initFlag == 0 {
  16196. //c.TestGetJiangXiBasBaseInit()
  16197. //}
  16198. //if initEleFlag == 0 {
  16199. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16200. //}
  16201. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16202. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16203. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16204. type ELeData struct {
  16205. Data struct {
  16206. IdNo string `json:"idNo"`
  16207. IdType string `json:"idType"`
  16208. UserName string `json:"userName"`
  16209. EcToken string `json:"ecToken"`
  16210. InsuOrg string `json:"insuOrg"`
  16211. Gender string `json:"gender"`
  16212. Birthday string `json:"birthday"`
  16213. Nationality string `json:"nationality"`
  16214. Email string `json:"email"`
  16215. Extra string `json:"extra"`
  16216. } `json:"data"`
  16217. Code int `json:"code"`
  16218. Message string `json:"message"`
  16219. }
  16220. var ele ELeData
  16221. err := json.Unmarshal([]byte(result), &ele)
  16222. if err != nil {
  16223. utils.ErrorLog("解析失败:%v", err)
  16224. }
  16225. token := ele.Data.EcToken
  16226. token = Remove0000(token)
  16227. 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)
  16228. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16229. var res ResultTwo
  16230. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16231. utils.ErrorLog("解析失败:%v", err)
  16232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16233. return
  16234. }
  16235. if res.Infcode == 0 {
  16236. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16237. if err == gorm.ErrRecordNotFound {
  16238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16239. return
  16240. } else if err != nil {
  16241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16242. return
  16243. } else {
  16244. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16245. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16246. infoStr := string(Iinfos)
  16247. idetinfoStr := string(Idetinfos)
  16248. psn := &models.HisPsn{
  16249. PsnNo: res.Output.Baseinfo.PsnNo,
  16250. PatientId: patient.ID,
  16251. Certno: res.Output.Baseinfo.Certno,
  16252. Gend: res.Output.Baseinfo.Gend,
  16253. Naty: res.Output.Baseinfo.Naty,
  16254. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16255. PsnName: res.Output.Baseinfo.PsnName,
  16256. Idetinfo: idetinfoStr,
  16257. Insuinfo: infoStr,
  16258. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16259. CardInfo: "",
  16260. VerifyNumber: token,
  16261. InsuplcAdmdvs: ele.Data.InsuOrg,
  16262. }
  16263. service.CreateHisPsn(psn)
  16264. var rf []*ResultFive
  16265. json.Unmarshal([]byte(infoStr), &rf)
  16266. var insutypes []*ResultFive
  16267. var insutype string
  16268. var is390 int = 0
  16269. var is310 int = 0
  16270. for _, item := range rf {
  16271. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16272. insutypes = append(insutypes, item)
  16273. }
  16274. }
  16275. if len(insutypes) == 1 {
  16276. insutype = insutypes[0].Insutype
  16277. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16278. } else {
  16279. for _, i := range insutypes {
  16280. if i.Insutype == "390" {
  16281. is390 = 1
  16282. }
  16283. if i.Insutype == "310" {
  16284. is310 = 1
  16285. }
  16286. }
  16287. }
  16288. if is390 == 1 {
  16289. insutype = "390"
  16290. }
  16291. if is310 == 1 {
  16292. insutype = "310"
  16293. }
  16294. if len(insutypes) == 0 {
  16295. insutype = "310"
  16296. }
  16297. c.ServeSuccessJSON(map[string]interface{}{
  16298. "patient": patient,
  16299. "number": token,
  16300. "insutype": insutype,
  16301. })
  16302. }
  16303. } else {
  16304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16305. return
  16306. }
  16307. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16308. //if initFlag == 0 {
  16309. c.TestGetJiangXiBasBaseInit()
  16310. //}
  16311. //if initEleFlag == 0 {
  16312. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16313. //}
  16314. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16315. type ELeData struct {
  16316. Data struct {
  16317. IdNo string `json:"idNo"`
  16318. IdType string `json:"idType"`
  16319. UserName string `json:"userName"`
  16320. EcToken string `json:"ecToken"`
  16321. InsuOrg string `json:"insuOrg"`
  16322. Gender string `json:"gender"`
  16323. Birthday string `json:"birthday"`
  16324. Nationality string `json:"nationality"`
  16325. Email string `json:"email"`
  16326. Extra string `json:"extra"`
  16327. } `json:"data"`
  16328. Code int `json:"code"`
  16329. Message string `json:"message"`
  16330. }
  16331. var ele ELeData
  16332. err := json.Unmarshal([]byte(json_result), &ele)
  16333. if err != nil {
  16334. utils.ErrorLog("解析失败:%v", err)
  16335. }
  16336. token := ele.Data.EcToken
  16337. token = Remove0000(token)
  16338. 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)
  16339. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16340. var res ResultTwo
  16341. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16342. utils.ErrorLog("解析失败:%v", err)
  16343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16344. return
  16345. }
  16346. if res.Infcode == 0 {
  16347. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16348. if err == gorm.ErrRecordNotFound {
  16349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16350. return
  16351. } else if err != nil {
  16352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16353. return
  16354. } else {
  16355. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16356. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16357. infoStr := string(Iinfos)
  16358. idetinfoStr := string(Idetinfos)
  16359. psn := &models.HisPsn{
  16360. PsnNo: res.Output.Baseinfo.PsnNo,
  16361. PatientId: patient.ID,
  16362. Certno: res.Output.Baseinfo.Certno,
  16363. Gend: res.Output.Baseinfo.Gend,
  16364. Naty: res.Output.Baseinfo.Naty,
  16365. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16366. PsnName: res.Output.Baseinfo.PsnName,
  16367. Idetinfo: idetinfoStr,
  16368. Insuinfo: infoStr,
  16369. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16370. CardInfo: "",
  16371. VerifyNumber: token,
  16372. }
  16373. service.CreateHisPsn(psn)
  16374. var rf []*ResultFive
  16375. json.Unmarshal([]byte(infoStr), &rf)
  16376. var insutypes []*ResultFive
  16377. var insutype string
  16378. var is390 int = 0
  16379. var is310 int = 0
  16380. for _, item := range rf {
  16381. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16382. insutypes = append(insutypes, item)
  16383. }
  16384. }
  16385. if len(insutypes) == 1 {
  16386. insutype = insutypes[0].Insutype
  16387. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16388. } else {
  16389. for _, i := range insutypes {
  16390. if i.Insutype == "390" {
  16391. is390 = 1
  16392. }
  16393. if i.Insutype == "310" {
  16394. is310 = 1
  16395. }
  16396. }
  16397. }
  16398. if is390 == 1 {
  16399. insutype = "390"
  16400. }
  16401. if is310 == 1 {
  16402. insutype = "310"
  16403. }
  16404. if len(insutypes) == 0 {
  16405. insutype = "310"
  16406. }
  16407. c.ServeSuccessJSON(map[string]interface{}{
  16408. "patient": patient,
  16409. "number": token,
  16410. "insutype": insutype,
  16411. })
  16412. }
  16413. } else {
  16414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16415. return
  16416. }
  16417. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16418. type ELeData struct {
  16419. Code string `json:"code"`
  16420. Data struct {
  16421. Aac002 string `json:"aac002"`
  16422. Aaz500 string `json:"aaz500"`
  16423. ActCardNo string `json:"actCardNo"`
  16424. Bab520 string `json:"bab520"`
  16425. Bkz543 string `json:"bkz543"`
  16426. BusinessType string `json:"businessType"`
  16427. CertfCodg string `json:"certfCodg"`
  16428. EcIndexNo string `json:"ecIndexNo"`
  16429. EcToken string `json:"ecToken"`
  16430. ID0000 string `json:"id0000"`
  16431. IDNo string `json:"idNo"`
  16432. IDType string `json:"idType"`
  16433. Idcode string `json:"idcode"`
  16434. IdentityToken string `json:"identity_token"`
  16435. InsuOrg string `json:"insuOrg"`
  16436. OfficeID string `json:"officeId"`
  16437. OfficeName string `json:"officeName"`
  16438. OperatorID string `json:"operatorId"`
  16439. OperatorName string `json:"operatorName"`
  16440. OrgID string `json:"orgId"`
  16441. UserName string `json:"userName"`
  16442. } `json:"data"`
  16443. Infno interface{} `json:"infno"`
  16444. Message string `json:"message"`
  16445. OrgID string `json:"orgId"`
  16446. TransType string `json:"transType"`
  16447. }
  16448. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16449. outPutInfo = Remove0000(outPutInfo)
  16450. if len(outPutInfo) > 0 {
  16451. var ele ELeData
  16452. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16453. if err != nil {
  16454. utils.ErrorLog("解析失败:%v", err)
  16455. }
  16456. token := ele.Data.EcToken
  16457. fmt.Println(inputInfo)
  16458. fmt.Println(outPutInfo)
  16459. 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)
  16460. saveLog(result, requestLog, "1101", "获取人员信息")
  16461. var dat map[string]interface{}
  16462. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16463. fmt.Println(dat)
  16464. } else {
  16465. fmt.Println(err)
  16466. }
  16467. userJSONBytes, _ := json.Marshal(dat)
  16468. var res ResultTwo
  16469. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16470. utils.ErrorLog("解析失败:%v", err)
  16471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16472. return
  16473. }
  16474. res.ErrMsg = errMsgLog
  16475. if res.Infcode == 0 {
  16476. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16477. if err == gorm.ErrRecordNotFound {
  16478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16479. return
  16480. } else if err != nil {
  16481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16482. return
  16483. } else {
  16484. fmt.Println(res)
  16485. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16486. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16487. infoStr := string(Iinfos)
  16488. idetinfoStr := string(Idetinfos)
  16489. psn := &models.HisPsn{
  16490. PsnNo: res.Output.Baseinfo.PsnNo,
  16491. PatientId: patient.ID,
  16492. Certno: res.Output.Baseinfo.Certno,
  16493. Gend: res.Output.Baseinfo.Gend,
  16494. Naty: res.Output.Baseinfo.Naty,
  16495. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16496. PsnName: res.Output.Baseinfo.PsnName,
  16497. Idetinfo: idetinfoStr,
  16498. Insuinfo: infoStr,
  16499. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16500. CardInfo: outPutInfo,
  16501. VerifyNumber: token,
  16502. InsuplcAdmdvs: ele.Data.InsuOrg,
  16503. }
  16504. service.CreateHisPsn(psn)
  16505. var rf []*ResultFive
  16506. json.Unmarshal([]byte(infoStr), &rf)
  16507. var insutypes []*ResultFive
  16508. var insutype string
  16509. var is390 int = 0
  16510. var is310 int = 0
  16511. for _, item := range rf {
  16512. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16513. insutypes = append(insutypes, item)
  16514. }
  16515. }
  16516. if len(insutypes) == 1 {
  16517. insutype = insutypes[0].Insutype
  16518. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16519. } else {
  16520. for _, i := range insutypes {
  16521. if i.Insutype == "390" {
  16522. is390 = 1
  16523. }
  16524. if i.Insutype == "310" {
  16525. is310 = 1
  16526. }
  16527. }
  16528. }
  16529. if is390 == 1 {
  16530. insutype = "390"
  16531. }
  16532. if is310 == 1 {
  16533. insutype = "310"
  16534. }
  16535. if len(insutypes) == 0 {
  16536. insutype = "310"
  16537. }
  16538. c.ServeSuccessJSON(map[string]interface{}{
  16539. "patient": patient,
  16540. "number": token,
  16541. "insutype": insutype,
  16542. })
  16543. }
  16544. } else {
  16545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16546. return
  16547. }
  16548. }
  16549. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16550. var api string
  16551. 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 +
  16552. "&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
  16553. resp, requestErr := http.Get(api)
  16554. if requestErr != nil {
  16555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16556. return
  16557. }
  16558. body, ioErr := ioutil.ReadAll(resp.Body)
  16559. if ioErr != nil {
  16560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16562. return
  16563. }
  16564. var respJSON map[string]interface{}
  16565. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16568. return
  16569. }
  16570. var status string
  16571. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16572. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16573. var token string
  16574. var res ResultTwo //1101结果
  16575. var res10265 ResultTwo10265 //1101结果
  16576. if status == "0" { //读卡成功
  16577. var card_info string //卡信息
  16578. var busi_card_info string
  16579. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16580. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16581. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16582. fmt.Println(card_info)
  16583. fmt.Println(busi_card_info)
  16584. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16585. result, _ := json.Marshal(respJSON)
  16586. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16587. utils.ErrorLog("解析失败:%v", err)
  16588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16589. return
  16590. }
  16591. res.ErrMsg = res10265.ErrMsg
  16592. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16593. res.Infcode = infocode
  16594. res.Output = res10265.Output
  16595. res.InfRefmsgid = res10265.InfRefmsgid
  16596. if res.Infcode == 0 {
  16597. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16598. if err == gorm.ErrRecordNotFound {
  16599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16600. return
  16601. } else if err != nil {
  16602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16603. return
  16604. } else {
  16605. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16606. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16607. infoStr := string(Iinfos)
  16608. idetinfoStr := string(Idetinfos)
  16609. psn := &models.HisPsn{
  16610. PsnNo: res.Output.Baseinfo.PsnNo,
  16611. PatientId: patient.ID,
  16612. Certno: res.Output.Baseinfo.Certno,
  16613. Gend: res.Output.Baseinfo.Gend,
  16614. Naty: res.Output.Baseinfo.Naty,
  16615. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16616. PsnName: res.Output.Baseinfo.PsnName,
  16617. Idetinfo: idetinfoStr,
  16618. Insuinfo: infoStr,
  16619. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16620. CardInfo: card_info,
  16621. VerifyNumber: token,
  16622. }
  16623. var rf []*ResultFive
  16624. json.Unmarshal([]byte(infoStr), &rf)
  16625. var insutypes []*ResultFive
  16626. var insutype string
  16627. var is390 int = 0
  16628. var is310 int = 0
  16629. for _, item := range rf {
  16630. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16631. insutypes = append(insutypes, item)
  16632. }
  16633. }
  16634. if len(insutypes) == 1 {
  16635. insutype = insutypes[0].Insutype
  16636. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16637. } else {
  16638. for _, i := range insutypes {
  16639. if i.Insutype == "390" {
  16640. is390 = 1
  16641. }
  16642. if i.Insutype == "310" {
  16643. is310 = 1
  16644. }
  16645. }
  16646. }
  16647. if is390 == 1 {
  16648. insutype = "390"
  16649. }
  16650. if is310 == 1 {
  16651. insutype = "310"
  16652. }
  16653. if len(insutypes) == 0 {
  16654. insutype = "310"
  16655. }
  16656. service.CreateHisPsn(psn)
  16657. c.ServeSuccessJSON(map[string]interface{}{
  16658. "patient": patient,
  16659. "number": token,
  16660. "insutype": insutype,
  16661. })
  16662. }
  16663. } else {
  16664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16665. return
  16666. }
  16667. } else { //读卡失败
  16668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16669. return
  16670. }
  16671. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16672. res := c.GetoleInfo()
  16673. if res.Infcode == 0 {
  16674. var result string
  16675. if res.Output.MdtrtCertType == "01" {
  16676. 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)
  16677. } else if res.Output.MdtrtCertType == "02" {
  16678. 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)
  16679. } else if res.Output.MdtrtCertType == "03" {
  16680. 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)
  16681. }
  16682. var dat map[string]interface{}
  16683. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16684. fmt.Println(dat)
  16685. } else {
  16686. fmt.Println(err)
  16687. }
  16688. userJSONBytes, _ := json.Marshal(dat)
  16689. var res2 ResultTwo
  16690. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16691. utils.ErrorLog("解析失败:%v", err)
  16692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16693. return
  16694. }
  16695. if res2.Infcode == 0 {
  16696. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16697. if err == gorm.ErrRecordNotFound {
  16698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16699. return
  16700. } else if err != nil {
  16701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16702. return
  16703. } else {
  16704. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16705. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16706. infoStr := string(Iinfos)
  16707. idetinfoStr := string(Idetinfos)
  16708. var rf []*ResultFive
  16709. json.Unmarshal([]byte(infoStr), &rf)
  16710. var insutypes []*ResultFive
  16711. var insutype string
  16712. var is390 int = 0
  16713. var is310 int = 0
  16714. //var insuplc_admdvs string
  16715. for _, item := range rf {
  16716. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16717. insutypes = append(insutypes, item)
  16718. }
  16719. }
  16720. if len(insutypes) == 1 {
  16721. insutype = insutypes[0].Insutype
  16722. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16723. } else {
  16724. for _, i := range insutypes {
  16725. if i.Insutype == "390" {
  16726. is390 = 1
  16727. }
  16728. if i.Insutype == "310" {
  16729. is310 = 1
  16730. }
  16731. }
  16732. }
  16733. if is390 == 1 {
  16734. insutype = "390"
  16735. }
  16736. if is310 == 1 {
  16737. insutype = "310"
  16738. }
  16739. if len(insutypes) == 0 {
  16740. insutype = "310"
  16741. }
  16742. psn := &models.HisPsn{
  16743. PsnNo: res2.Output.Baseinfo.PsnNo,
  16744. PatientId: patient.ID,
  16745. Certno: res2.Output.Baseinfo.Certno,
  16746. Gend: res2.Output.Baseinfo.Gend,
  16747. Naty: res2.Output.Baseinfo.Naty,
  16748. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16749. PsnName: res2.Output.Baseinfo.PsnName,
  16750. Idetinfo: idetinfoStr,
  16751. Insuinfo: infoStr,
  16752. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16753. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16754. VerifyNumber: res.Output.EcToken,
  16755. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16756. }
  16757. if res.Output.MdtrtCertType == "01" {
  16758. psn.VerifyNumber = res.Output.EcToken
  16759. //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)
  16760. } else if res.Output.MdtrtCertType == "02" {
  16761. psn.VerifyNumber = res.Output.CardNo
  16762. //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)
  16763. } else if res.Output.MdtrtCertType == "03" {
  16764. psn.VerifyNumber = res.Output.MdtrtCertNo
  16765. //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)
  16766. }
  16767. service.CreateHisPsn(psn)
  16768. var balc float64
  16769. for _, item := range rf {
  16770. if item.Insutype == insutype {
  16771. balc = item.Balc
  16772. }
  16773. }
  16774. c.ServeSuccessJSON(map[string]interface{}{
  16775. "patient": patient,
  16776. "number": res.Output.CardNo,
  16777. "insutype": insutype,
  16778. "blac": balc,
  16779. "desc": idetinfoStr,
  16780. })
  16781. }
  16782. } else {
  16783. c.ServeSuccessJSON(map[string]interface{}{
  16784. "failed_code": -10,
  16785. "msg": res2.ErrMsg,
  16786. })
  16787. }
  16788. } else {
  16789. c.ServeSuccessJSON(map[string]interface{}{
  16790. "failed_code": -10,
  16791. "msg": res.ErrMsg,
  16792. })
  16793. }
  16794. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16795. var res ResultTwo
  16796. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16797. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16798. "&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)
  16799. resp, requestErr := http.Get(api)
  16800. if requestErr != nil {
  16801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16802. return
  16803. }
  16804. body, ioErr := ioutil.ReadAll(resp.Body)
  16805. if ioErr != nil {
  16806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16808. return
  16809. }
  16810. var respJSON map[string]interface{}
  16811. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16814. return
  16815. }
  16816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16817. result, _ := json.Marshal(respJSON)
  16818. fmt.Println("log")
  16819. fmt.Println(string(result))
  16820. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16821. utils.ErrorLog("解析失败:%v", err)
  16822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16823. return
  16824. }
  16825. if res.Infcode == 0 {
  16826. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16827. if err == gorm.ErrRecordNotFound {
  16828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16829. return
  16830. } else if err != nil {
  16831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16832. return
  16833. } else {
  16834. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16835. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16836. infoStr := string(Iinfos)
  16837. idetinfoStr := string(Idetinfos)
  16838. var rf []*ResultFive
  16839. json.Unmarshal([]byte(infoStr), &rf)
  16840. var insutypes []*ResultFive
  16841. var insutype string
  16842. var is390 int = 0
  16843. var is310 int = 0
  16844. for _, item := range rf {
  16845. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16846. insutypes = append(insutypes, item)
  16847. }
  16848. }
  16849. if len(insutypes) == 1 {
  16850. insutype = insutypes[0].Insutype
  16851. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16852. } else {
  16853. for _, i := range insutypes {
  16854. if i.Insutype == "390" {
  16855. is390 = 1
  16856. }
  16857. if i.Insutype == "310" {
  16858. is310 = 1
  16859. }
  16860. }
  16861. }
  16862. if is390 == 1 {
  16863. insutype = "390"
  16864. }
  16865. if is310 == 1 {
  16866. insutype = "310"
  16867. }
  16868. if len(insutypes) == 0 {
  16869. insutype = "390"
  16870. }
  16871. var insuplc_admdvs string
  16872. for _, item := range rf {
  16873. if item.Insutype == insutype {
  16874. insuplc_admdvs = item.InsuplcAdmdvs
  16875. }
  16876. }
  16877. psn := &models.HisPsn{
  16878. PsnNo: res.Output.Baseinfo.PsnNo,
  16879. PatientId: patient.ID,
  16880. Certno: res.Output.Baseinfo.Certno,
  16881. Gend: res.Output.Baseinfo.Gend,
  16882. Naty: res.Output.Baseinfo.Naty,
  16883. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16884. PsnName: res.Output.Baseinfo.PsnName,
  16885. Idetinfo: idetinfoStr,
  16886. Insuinfo: infoStr,
  16887. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16888. InsuplcAdmdvs: insuplc_admdvs,
  16889. }
  16890. service.CreateHisPsn(psn)
  16891. c.ServeSuccessJSON(map[string]interface{}{
  16892. "patient": patient,
  16893. "number": res.Output.Baseinfo.Certno,
  16894. })
  16895. }
  16896. } else {
  16897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16898. return
  16899. }
  16900. } else {
  16901. type ELeData struct {
  16902. Code string `json:"code"`
  16903. Data struct {
  16904. Aac002 string `json:"aac002"`
  16905. Aaz500 string `json:"aaz500"`
  16906. ActCardNo string `json:"actCardNo"`
  16907. Bab520 string `json:"bab520"`
  16908. Bkz543 string `json:"bkz543"`
  16909. BusinessType string `json:"businessType"`
  16910. CertfCodg string `json:"certfCodg"`
  16911. EcIndexNo string `json:"ecIndexNo"`
  16912. EcToken string `json:"ecToken"`
  16913. ID0000 string `json:"id0000"`
  16914. IDNo string `json:"idNo"`
  16915. IDType string `json:"idType"`
  16916. Idcode string `json:"idcode"`
  16917. IdentityToken string `json:"identity_token"`
  16918. InsuOrg string `json:"insuOrg"`
  16919. OfficeID string `json:"officeId"`
  16920. OfficeName string `json:"officeName"`
  16921. OperatorID string `json:"operatorId"`
  16922. OperatorName string `json:"operatorName"`
  16923. OrgID string `json:"orgId"`
  16924. UserName string `json:"userName"`
  16925. } `json:"data"`
  16926. Infno interface{} `json:"infno"`
  16927. Message string `json:"message"`
  16928. OrgID string `json:"orgId"`
  16929. TransType string `json:"transType"`
  16930. }
  16931. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16932. fmt.Println(result)
  16933. outPutInfo := Remove0000(result)
  16934. fmt.Println(outPutInfo)
  16935. if len(outPutInfo) > 0 {
  16936. var ele ELeData
  16937. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16938. if err != nil {
  16939. utils.ErrorLog("解析失败:%v", err)
  16940. }
  16941. token := ele.Data.EcToken
  16942. fmt.Println(outPutInfo)
  16943. 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)
  16944. saveLog(result, requestLog, "1101", "获取人员信息")
  16945. var dat map[string]interface{}
  16946. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16947. fmt.Println(dat)
  16948. } else {
  16949. fmt.Println(err)
  16950. }
  16951. userJSONBytes, _ := json.Marshal(dat)
  16952. var res ResultTwo
  16953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16954. utils.ErrorLog("解析失败:%v", err)
  16955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16956. return
  16957. }
  16958. if res.Infcode == 0 {
  16959. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16960. if err == gorm.ErrRecordNotFound {
  16961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16962. return
  16963. } else if err != nil {
  16964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16965. return
  16966. } else {
  16967. fmt.Println(res)
  16968. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16969. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16970. infoStr := string(Iinfos)
  16971. idetinfoStr := string(Idetinfos)
  16972. psn := &models.HisPsn{
  16973. PsnNo: res.Output.Baseinfo.PsnNo,
  16974. PatientId: patient.ID,
  16975. Certno: res.Output.Baseinfo.Certno,
  16976. Gend: res.Output.Baseinfo.Gend,
  16977. Naty: res.Output.Baseinfo.Naty,
  16978. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16979. PsnName: res.Output.Baseinfo.PsnName,
  16980. Idetinfo: idetinfoStr,
  16981. Insuinfo: infoStr,
  16982. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16983. CardInfo: outPutInfo,
  16984. VerifyNumber: token,
  16985. InsuplcAdmdvs: ele.Data.InsuOrg,
  16986. }
  16987. service.CreateHisPsn(psn)
  16988. var rf []*ResultFive
  16989. json.Unmarshal([]byte(infoStr), &rf)
  16990. var insutypes []*ResultFive
  16991. var insutype string
  16992. var is390 int = 0
  16993. var is310 int = 0
  16994. for _, item := range rf {
  16995. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16996. insutypes = append(insutypes, item)
  16997. }
  16998. }
  16999. if len(insutypes) == 1 {
  17000. insutype = insutypes[0].Insutype
  17001. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17002. } else {
  17003. for _, i := range insutypes {
  17004. if i.Insutype == "390" {
  17005. is390 = 1
  17006. }
  17007. if i.Insutype == "310" {
  17008. is310 = 1
  17009. }
  17010. }
  17011. }
  17012. if is390 == 1 {
  17013. insutype = "390"
  17014. }
  17015. if is310 == 1 {
  17016. insutype = "310"
  17017. }
  17018. if len(insutypes) == 0 {
  17019. insutype = "310"
  17020. }
  17021. c.ServeSuccessJSON(map[string]interface{}{
  17022. "patient": patient,
  17023. "number": token,
  17024. "insutype": insutype,
  17025. })
  17026. }
  17027. } else {
  17028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17029. return
  17030. }
  17031. }
  17032. //fmt.Println(result)
  17033. //
  17034. //if initFlag == 0 {
  17035. // c.TestGetBasBaseInit()
  17036. //}
  17037. //token := c.GetEleBaseInfo()
  17038. //
  17039. //token = Remove0000(token)
  17040. //
  17041. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17042. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17043. ////
  17044. //var res ResultTwo
  17045. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17046. // utils.ErrorLog("解析失败:%v", err)
  17047. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17048. // return
  17049. //}
  17050. //
  17051. //if res.Infcode == 0 {
  17052. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17053. // if err == gorm.ErrRecordNotFound {
  17054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17055. // return
  17056. // } else if err != nil {
  17057. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17058. // return
  17059. //
  17060. // } else {
  17061. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17062. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17063. // infoStr := string(Iinfos)
  17064. // idetinfoStr := string(Idetinfos)
  17065. //
  17066. //
  17067. //
  17068. //
  17069. // var rf []*ResultFive
  17070. // json.Unmarshal([]byte(infoStr), &rf)
  17071. //
  17072. // var insutypes []*ResultFive
  17073. // var insutype string
  17074. // var is390 int = 0
  17075. // var is310 int = 0
  17076. // var insuplc_admdvs string
  17077. //
  17078. // for _, item := range rf {
  17079. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17080. // insutypes = append(insutypes, item)
  17081. // }
  17082. // }
  17083. //
  17084. // if len(insutypes) == 1 {
  17085. // insutype = insutypes[0].Insutype
  17086. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17087. // } else {
  17088. // for _, i := range insutypes {
  17089. // if i.Insutype == "390" {
  17090. // is390 = 1
  17091. // }
  17092. //
  17093. // if i.Insutype == "310" {
  17094. // is310 = 1
  17095. // }
  17096. // }
  17097. // }
  17098. // if is390 == 1 {
  17099. // insutype = "390"
  17100. // }
  17101. //
  17102. // if is310 == 1 {
  17103. // insutype = "310"
  17104. // }
  17105. // if len(insutypes) == 0 {
  17106. // insutype = "310"
  17107. // }
  17108. // for _, item := range rf {
  17109. // if item.Insutype == insutype {
  17110. // insuplc_admdvs = item.InsuplcAdmdvs
  17111. // }
  17112. // }
  17113. // psn := &models.HisPsn{
  17114. // PsnNo: res.Output.Baseinfo.PsnNo,
  17115. // Age: res.Output.Baseinfo.Age,
  17116. // PatientId: patient.ID,
  17117. // Certno: res.Output.Baseinfo.Certno,
  17118. // Brdy: res.Output.Baseinfo.Brdy,
  17119. // Gend: res.Output.Baseinfo.Gend,
  17120. // Naty: res.Output.Baseinfo.Naty,
  17121. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17122. // PsnName: res.Output.Baseinfo.PsnName,
  17123. // Idetinfo: idetinfoStr,
  17124. // Insuinfo: infoStr,
  17125. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17126. // CardInfo: "",
  17127. // VerifyNumber: token,
  17128. // InsuplcAdmdvs: insuplc_admdvs,
  17129. // }
  17130. // service.CreateHisPsn(psn)
  17131. //
  17132. // c.ServeSuccessJSON(map[string]interface{}{
  17133. // "patient": patient,
  17134. // "number": token,
  17135. // })
  17136. // }
  17137. //} else {
  17138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17139. // return
  17140. //}
  17141. }
  17142. break
  17143. case 5:
  17144. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17145. var api string
  17146. if miConfig.MdtrtareaAdmvs == "320921" {
  17147. 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 +
  17148. "&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
  17149. fmt.Println(api)
  17150. } else {
  17151. 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 +
  17152. "&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)
  17153. }
  17154. resp, requestErr := http.Get(api)
  17155. if requestErr != nil {
  17156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17157. return
  17158. }
  17159. body, ioErr := ioutil.ReadAll(resp.Body)
  17160. if ioErr != nil {
  17161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17163. return
  17164. }
  17165. var respJSON map[string]interface{}
  17166. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17169. return
  17170. }
  17171. var status string
  17172. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17173. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17174. var token string
  17175. var res ResultTwo //1101结果
  17176. var res10265 ResultTwo10265 //1101结果
  17177. if status == "0" { //读卡成功
  17178. var card_info string //卡信息
  17179. //var busi_card_info string
  17180. var auth_info string
  17181. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17182. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17183. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17184. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17185. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17186. result, _ := json.Marshal(respJSON)
  17187. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17188. utils.ErrorLog("解析失败:%v", err)
  17189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17190. return
  17191. }
  17192. res.ErrMsg = res10265.ErrMsg
  17193. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17194. res.Infcode = infocode
  17195. res.Output = res10265.Output
  17196. res.InfRefmsgid = res10265.InfRefmsgid
  17197. if res.Infcode == 0 {
  17198. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17199. if err == gorm.ErrRecordNotFound {
  17200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17201. return
  17202. } else if err != nil {
  17203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17204. return
  17205. } else {
  17206. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17207. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17208. infoStr := string(Iinfos)
  17209. idetinfoStr := string(Idetinfos)
  17210. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  17211. psn := &models.HisPsn{
  17212. PsnNo: res.Output.Baseinfo.PsnNo,
  17213. PatientId: patient.ID,
  17214. Certno: res.Output.Baseinfo.Certno,
  17215. Gend: res.Output.Baseinfo.Gend,
  17216. Brdy: b,
  17217. Age: float64(age),
  17218. Naty: res.Output.Baseinfo.Naty,
  17219. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17220. PsnName: res.Output.Baseinfo.PsnName,
  17221. Idetinfo: idetinfoStr,
  17222. Insuinfo: infoStr,
  17223. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17224. CardInfo: card_info,
  17225. VerifyNumber: token,
  17226. AuthInfo: auth_info,
  17227. }
  17228. var rf []*ResultFive
  17229. json.Unmarshal([]byte(infoStr), &rf)
  17230. var insutypes []*ResultFive
  17231. var insutype string
  17232. var is390 int = 0
  17233. var is310 int = 0
  17234. for _, item := range rf {
  17235. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17236. insutypes = append(insutypes, item)
  17237. }
  17238. }
  17239. if len(insutypes) == 1 {
  17240. insutype = insutypes[0].Insutype
  17241. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17242. } else {
  17243. for _, i := range insutypes {
  17244. if i.Insutype == "390" {
  17245. is390 = 1
  17246. }
  17247. if i.Insutype == "310" {
  17248. is310 = 1
  17249. }
  17250. }
  17251. }
  17252. if is390 == 1 {
  17253. insutype = "390"
  17254. }
  17255. if is310 == 1 {
  17256. insutype = "310"
  17257. }
  17258. if len(insutypes) == 0 {
  17259. insutype = "310"
  17260. }
  17261. service.CreateHisPsn(psn)
  17262. c.ServeSuccessJSON(map[string]interface{}{
  17263. "patient": patient,
  17264. "number": token,
  17265. "insutype": insutype,
  17266. })
  17267. }
  17268. } else {
  17269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17270. return
  17271. }
  17272. } else { //读卡失败
  17273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17274. return
  17275. }
  17276. }
  17277. break
  17278. }
  17279. }
  17280. var initFlag int64 = 0
  17281. var initEleFlag int64 = 0
  17282. func (c *HisApiController) TestGetBasBaseInit() {
  17283. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17284. Iinit := DllDef.MustFindProc("Init")
  17285. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17286. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  17287. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  17288. if ret != 0 {
  17289. fmt.Println("SSCard的报错原因:", err)
  17290. fmt.Println("SSCard的运算结果为:", ret)
  17291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17292. return
  17293. }
  17294. result := int(ret)
  17295. fmt.Println("SSCard的运算结果为1:", result)
  17296. initFlag = 1
  17297. return
  17298. }
  17299. func (c *HisApiController) HandleJiangXiReadCard() {
  17300. fmt.Println("~~~~~~")
  17301. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17302. admin_user_id, _ := c.GetInt64("admin_user_id")
  17303. id_card_type, _ := c.GetInt64("id_card_type")
  17304. //certificates, _ := c.GetInt64("certificates")
  17305. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17306. if initFlag == 0 {
  17307. c.TestGetJiangXiBasBaseInit()
  17308. }
  17309. basStr := c.GetBasBaseInfo()
  17310. if len(basStr) == 0 {
  17311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17312. return
  17313. }
  17314. fmt.Println(basStr)
  17315. bas := strings.Split(basStr, "|")
  17316. basNumber := bas[1]
  17317. fmt.Println(basNumber)
  17318. card_sn := bas[3]
  17319. fmt.Println(card_sn)
  17320. 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, "")
  17321. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  17322. var dat map[string]interface{}
  17323. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17324. fmt.Println(dat)
  17325. } else {
  17326. fmt.Println(err)
  17327. }
  17328. userJSONBytes, _ := json.Marshal(dat)
  17329. var res ResultTwo
  17330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17331. utils.ErrorLog("解析失败:%v", err)
  17332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17333. return
  17334. }
  17335. if res.Infcode == 0 {
  17336. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  17337. if err == gorm.ErrRecordNotFound {
  17338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17339. return
  17340. } else if err != nil {
  17341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17342. return
  17343. } else {
  17344. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17345. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17346. infoStr := string(Iinfos)
  17347. idetinfoStr := string(Idetinfos)
  17348. psn := &models.HisPsn{
  17349. PsnNo: res.Output.Baseinfo.PsnNo,
  17350. PatientId: patient.ID,
  17351. Certno: res.Output.Baseinfo.Certno,
  17352. Gend: res.Output.Baseinfo.Gend,
  17353. Naty: res.Output.Baseinfo.Naty,
  17354. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17355. PsnName: res.Output.Baseinfo.PsnName,
  17356. Idetinfo: idetinfoStr,
  17357. Insuinfo: infoStr,
  17358. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17359. CardInfo: basStr,
  17360. VerifyNumber: "",
  17361. }
  17362. service.CreateHisPsn(psn)
  17363. c.ServeSuccessJSON(map[string]interface{}{
  17364. "patient": patient,
  17365. "number": basNumber,
  17366. })
  17367. }
  17368. } else {
  17369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17370. return
  17371. }
  17372. }
  17373. func (c *HisApiController) TestGetHnBasBaseInit() {
  17374. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17375. Iinit := DllDef.MustFindProc("Init")
  17376. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17377. //http://10.77.211.236/CSB/hsa-fsi-1303
  17378. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17379. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17380. // 调用 Init 函数
  17381. 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"))))
  17382. //if ret != 0 {
  17383. fmt.Println("SSCard的报错原因:", err)
  17384. fmt.Println("SSCard的运算结果为:", ret)
  17385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17386. // return
  17387. //}
  17388. result := int(ret)
  17389. fmt.Println("SSCard的运算结果为1:", result)
  17390. initFlag = 1
  17391. return
  17392. }
  17393. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17394. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17395. Iinit := DllDef.MustFindProc("Init")
  17396. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17397. //http://10.77.211.236/CSB/hsa-fsi-1303
  17398. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  17399. if ret != 0 {
  17400. fmt.Println("SSCard的报错原因:", err)
  17401. fmt.Println("SSCard的运算结果为:", ret)
  17402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17403. return
  17404. }
  17405. result := int(ret)
  17406. fmt.Println("SSCard的运算结果为1:", result)
  17407. initFlag = 1
  17408. return
  17409. }
  17410. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17411. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17412. Iinit := DllDef.MustFindProc("Init")
  17413. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17414. //http://10.77.211.236/CSB/hsa-fsi-1303
  17415. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17416. if ret != 0 {
  17417. fmt.Println("SSCard的报错原因:", err)
  17418. fmt.Println("SSCard的运算结果为:", ret)
  17419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17420. return
  17421. }
  17422. result := int(ret)
  17423. fmt.Println("SSCard的运算结果为1:", result)
  17424. initFlag = 1
  17425. return
  17426. }
  17427. func (c *HisApiController) GetSFZBaseInfo() string {
  17428. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17429. readCard := DllDef.MustFindProc("ReadSFZ")
  17430. if readCard == nil {
  17431. fmt.Println("readcard is nil")
  17432. readCard = DllDef.MustFindProc("ReadSFZ")
  17433. }
  17434. str := make([]byte, 8096)
  17435. str1 := make([]byte, 8096)
  17436. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17437. fmt.Println(r)
  17438. return Remove0000(string(str))
  17439. }
  17440. func (c *HisApiController) GetEleBaseInfo() string {
  17441. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17442. readCard := DllDef.MustFindProc("GetQRBase")
  17443. fmt.Println(readCard)
  17444. if readCard == nil {
  17445. fmt.Println("readcard is nil")
  17446. readCard = DllDef.MustFindProc("GetQRBase")
  17447. }
  17448. str := make([]byte, 1024)
  17449. str1 := make([]byte, 1024)
  17450. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17451. fmt.Println(ret2)
  17452. fmt.Println(string(str1))
  17453. fmt.Println(string(str))
  17454. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17455. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17456. if ret2 != 0 {
  17457. return ""
  17458. }
  17459. return string(str)
  17460. }
  17461. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17462. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17463. readCard := DllDef.MustFindProc("NationEcTrans")
  17464. fmt.Println(readCard)
  17465. fmt.Println("!!!!!")
  17466. pBusiCardInfo := make([]byte, 2048)
  17467. input := make(map[string]interface{})
  17468. inputData := make(map[string]interface{})
  17469. inputData["orgId"] = code
  17470. inputData["businessType"] = "01101"
  17471. inputData["operatorId"] = "1"
  17472. inputData["operatorName"] = "admin"
  17473. inputData["officeId"] = "001"
  17474. inputData["officeName"] = "血透室"
  17475. inputData["deviceType"] = ""
  17476. input["data"] = inputData
  17477. input["orgId"] = code
  17478. input["transType"] = "ec.query"
  17479. bytesData, _ := json.Marshal(input)
  17480. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17481. fmt.Println(ret2)
  17482. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17483. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17484. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17485. }
  17486. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17487. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17488. readCard := DllDef.MustFindProc("NationEcTrans")
  17489. fmt.Println(readCard)
  17490. fmt.Println("!!!!!")
  17491. pBusiCardInfo := make([]byte, 2048)
  17492. input := make(map[string]interface{})
  17493. inputData := make(map[string]interface{})
  17494. inputData["orgId"] = code
  17495. inputData["businessType"] = "01101"
  17496. inputData["operatorId"] = "9"
  17497. inputData["operatorName"] = "admin"
  17498. inputData["officeId"] = "001"
  17499. inputData["officeName"] = "血透室"
  17500. inputData["deviceType"] = ""
  17501. input["data"] = inputData
  17502. input["orgId"] = code
  17503. input["transType"] = "ec.query"
  17504. bytesData, _ := json.Marshal(input)
  17505. 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])))
  17506. fmt.Println(ret2)
  17507. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17508. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17509. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17510. }
  17511. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17512. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17513. readCard := DllDef.MustFindProc("NationEcTrans")
  17514. fmt.Println(readCard)
  17515. fmt.Println("!!!!!")
  17516. pBusiCardInfo := make([]byte, 2048)
  17517. input := make(map[string]interface{})
  17518. inputData := make(map[string]interface{})
  17519. inputData["orgId"] = code
  17520. inputData["businessType"] = "01301"
  17521. inputData["operatorId"] = "9"
  17522. inputData["operatorName"] = "admin"
  17523. inputData["officeId"] = "001"
  17524. inputData["officeName"] = "血透室"
  17525. inputData["deviceType"] = ""
  17526. input["data"] = inputData
  17527. input["orgId"] = code
  17528. input["transType"] = "ec.query"
  17529. bytesData, _ := json.Marshal(input)
  17530. 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])))
  17531. fmt.Println(ret2)
  17532. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17533. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17534. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17535. }
  17536. func GetJxEleBaseInfo(org_id int64) string {
  17537. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17538. readCard := DllDef.MustFindProc("NationEcTrans")
  17539. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17540. if readCard == nil {
  17541. fmt.Println("readcard is nil")
  17542. readCard = DllDef.MustFindProc("NationEcTrans")
  17543. }
  17544. str1 := make([]byte, 1024)
  17545. data := make(map[string]interface{})
  17546. inputData := make(map[string]interface{})
  17547. inputData["orgId"] = miConfig.Code
  17548. inputData["businessType"] = "01101"
  17549. inputData["operatorId"] = "test001"
  17550. inputData["operatorName"] = "cn"
  17551. inputData["officeId"] = "32760"
  17552. inputData["officeName"] = "waike"
  17553. inputData["deviceType"] = ""
  17554. data["data"] = inputData
  17555. data["transType"] = "ec.query"
  17556. data["extra "] = ""
  17557. data["orgId"] = miConfig.Code
  17558. bytesData, _ := json.Marshal(data)
  17559. //bytesData, _ := json.Marshal(data)
  17560. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17561. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17562. fmt.Println(ret2)
  17563. fmt.Println(string(str1))
  17564. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17565. if ret2 != 0 {
  17566. return ""
  17567. }
  17568. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17569. }
  17570. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17571. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17572. // readCard := DllDef.MustFindProc("NationEcTrans")
  17573. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17574. //
  17575. // if readCard == nil {
  17576. // fmt.Println("readcard is nil")
  17577. // readCard = DllDef.MustFindProc("NationEcTrans")
  17578. // }
  17579. // str1 := make([]byte, 1024)
  17580. //
  17581. // data := make(map[string]interface{})
  17582. //
  17583. // inputData := make(map[string]interface{})
  17584. // inputData["orgId"] = miConfig.Code
  17585. // inputData["businessType"] = "01101"
  17586. // inputData["operatorId"] = "test001"
  17587. // inputData["operatorName"] = "cn"
  17588. // inputData["officeId"] = "32760"
  17589. // inputData["officeName"] = "waike"
  17590. // inputData["deviceType"] = ""
  17591. //
  17592. // data["data"] = inputData
  17593. // data["transType"] = "ec.query"
  17594. // data["extra "] = ""
  17595. // data["orgId"] = miConfig.Code
  17596. // bytesData, _ := json.Marshal(data)
  17597. // //bytesData, _ := json.Marshal(data)
  17598. //
  17599. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17600. //
  17601. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17602. // fmt.Println(ret2)
  17603. // fmt.Println(string(str1))
  17604. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17605. //
  17606. // if ret2 != 0 {
  17607. // return ""
  17608. // }
  17609. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17610. //}
  17611. func GetJxEleBaseInitInfo(org_id int64) string {
  17612. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17613. readCard := DllDef.MustFindProc("NationEcTrans")
  17614. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17615. if readCard == nil {
  17616. fmt.Println("readcard is nil")
  17617. readCard = DllDef.MustFindProc("NationEcTrans")
  17618. }
  17619. str1 := make([]byte, 2048)
  17620. data := make(map[string]interface{})
  17621. inputData := make(map[string]interface{})
  17622. inputData["orgId"] = miConfig.Code
  17623. inputData["businessType"] = "01101"
  17624. inputData["operatorId"] = "1"
  17625. inputData["operatorName"] = "huangchuang"
  17626. inputData["officeId"] = "101"
  17627. inputData["officeName"] = "xuetou"
  17628. inputData["deviceType"] = ""
  17629. data["data"] = inputData
  17630. data["transType"] = "ec.query"
  17631. data["orgId"] = miConfig.Code
  17632. bytesData, _ := json.Marshal(data)
  17633. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17634. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17635. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17636. fmt.Println(ret2)
  17637. fmt.Println(string(str1))
  17638. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17639. if ret2 != 0 {
  17640. return ""
  17641. }
  17642. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17643. initEleFlag = 1
  17644. }
  17645. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17646. }
  17647. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17648. // // 构建命令
  17649. // cmd := exec.Command("python", "b.py")
  17650. //
  17651. // // 执行命令并等待完成
  17652. // output, err := cmd.CombinedOutput()
  17653. // if err != nil {
  17654. // fmt.Println("Error executing Python script:", err)
  17655. // return
  17656. // }
  17657. //
  17658. // // 打印Python脚本的输出
  17659. // fmt.Println(string(output))
  17660. //}
  17661. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17662. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17663. readCard := DllDef.MustFindProc("gxyb_call")
  17664. if readCard == nil {
  17665. fmt.Println("readcard is nil")
  17666. readCard = DllDef.MustFindProc("gxyb_call")
  17667. }
  17668. str := make([]byte, 1024)
  17669. str1 := make([]byte, 1024)
  17670. //data := make(map[string]interface{})
  17671. currentTime := time.Now()
  17672. // 格式化时间为 "YYYYMMDDHH24MISS"
  17673. formattedTime := currentTime.Format("20060102150405")
  17674. inputData := make(map[string]interface{})
  17675. inputData2 := make(map[string]interface{})
  17676. inputData["transNo"] = "1401"
  17677. inputData["transType"] = "passwordCheck"
  17678. inputData["timestamp"] = formattedTime
  17679. inputData2["fixmedinsCode"] = code
  17680. inputData2["psnNo"] = ""
  17681. inputData["data"] = inputData2
  17682. jsonBytes, err := json.Marshal(inputData)
  17683. if err != nil {
  17684. fmt.Println("Error encoding map to JSON:", err)
  17685. }
  17686. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17687. fmt.Println(string(str1))
  17688. fmt.Println(string(str))
  17689. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17690. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17691. if ret2 != 0 {
  17692. return ""
  17693. }
  17694. return string(str)
  17695. }
  17696. func (c *HisApiController) GetoleInfo() Response {
  17697. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17698. defer ole.CoUninitialize()
  17699. // Replace with the ProgID or CLSID of your COM object
  17700. progID := "YinHai.XJ.Actual.Interface.New"
  17701. // Create COM object
  17702. unknown, err := oleutil.CreateObject(progID)
  17703. if err != nil {
  17704. fmt.Println("Unable to create COM object:", err)
  17705. }
  17706. defer unknown.Release()
  17707. // Query for the IDispatch interface
  17708. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17709. if err != nil {
  17710. fmt.Println("Unable to get IDispatch interface:", err)
  17711. }
  17712. defer dispatch.Release()
  17713. // Prepare parameters
  17714. transNo := "1401"
  17715. transType := "passwordCheck"
  17716. timestamp := time.Now().Unix()
  17717. fixmedinsCode := "H45072101171"
  17718. psnNo := ""
  17719. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17720. result2 := ""
  17721. // Call COM object's method using the IDispatch interface
  17722. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17723. fmt.Println(resulr)
  17724. fmt.Println(result2)
  17725. if err != nil {
  17726. fmt.Println("调用COM对象方法失败:", err)
  17727. }
  17728. var response Response
  17729. err2 := json.Unmarshal([]byte(result2), &response)
  17730. if err2 != nil {
  17731. fmt.Println("解析JSON失败:", err)
  17732. }
  17733. return response
  17734. }
  17735. func (c *HisApiController) GetBasBaseInfo() string {
  17736. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17737. readCard := DllDef.MustFindProc("ReadCardBas")
  17738. if readCard == nil {
  17739. fmt.Println("readcard is nil")
  17740. readCard = DllDef.MustFindProc("ReadCardBas")
  17741. }
  17742. str := make([]byte, 1024)
  17743. str1 := make([]byte, 1024)
  17744. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17745. fmt.Println(string(str1))
  17746. fmt.Println(string(str))
  17747. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17748. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17749. if ret2 != 0 {
  17750. return ""
  17751. }
  17752. return string(str)
  17753. }
  17754. type Program struct {
  17755. FunctionID string `xml:"function_id"`
  17756. CardInfo string `xml:"cardinfo"`
  17757. User string `xml:"user"`
  17758. }
  17759. func (c *HisApiController) GetBasBaseInfo1111() string {
  17760. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17761. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17762. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17763. if readCard == nil {
  17764. fmt.Println("readcard is nil")
  17765. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17766. }
  17767. if readCard2 == nil {
  17768. fmt.Println("readcard is nil")
  17769. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17770. }
  17771. str := make([]byte, 1024)
  17772. str1 := make([]byte, 1024)
  17773. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17774. str3 := make([]byte, 1024)
  17775. str4 := make([]byte, 1024)
  17776. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17777. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17778. //if err != nil {
  17779. // fmt.Println("Error opening file:", err)
  17780. //}
  17781. //defer file.Close()
  17782. //
  17783. //var lastProgram Program
  17784. //scanner := bufio.NewScanner(file)
  17785. //inProgram := false
  17786. //
  17787. //for scanner.Scan() {
  17788. // line := scanner.Text()
  17789. // if strings.Contains(line, "<program>") {
  17790. // inProgram = true
  17791. // programXML := "<program>"
  17792. // for scanner.Scan() {
  17793. // line = scanner.Text()
  17794. // programXML += line
  17795. // if strings.Contains(line, "</program>") {
  17796. // programXML += "</program>"
  17797. // break
  17798. // }
  17799. // }
  17800. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17801. // // 解析成功,更新最后的 Program
  17802. // }
  17803. // inProgram = false
  17804. // }
  17805. //}
  17806. //
  17807. // fmt.Println("Error reading file:", inProgram)
  17808. //
  17809. //if err := scanner.Err(); err != nil {
  17810. // fmt.Println("Error reading file:", err)
  17811. //}
  17812. // 输出最后一次的 Program
  17813. //fmt.Printf("最后一次的 <program>:\n")
  17814. //fmt.Printf("<program>\n")
  17815. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17816. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17817. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17818. //fmt.Printf("</program>\n")
  17819. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17820. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17821. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17822. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17823. return ConvertToString(string(str), "gbk", "utf-8")
  17824. }
  17825. func (c *HisApiController) GetBasBaseInfo22222() string {
  17826. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17827. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17828. if readCard == nil {
  17829. fmt.Println("readcard is nil")
  17830. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17831. }
  17832. str := make([]byte, 1024)
  17833. str1 := make([]byte, 1024)
  17834. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17835. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17836. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17837. //if err != nil {
  17838. // fmt.Println("Error opening file:", err)
  17839. //}
  17840. //defer file.Close()
  17841. //
  17842. //var lastProgram Program
  17843. //scanner := bufio.NewScanner(file)
  17844. //inProgram := false
  17845. //
  17846. //for scanner.Scan() {
  17847. // line := scanner.Text()
  17848. // if strings.Contains(line, "<program>") {
  17849. // inProgram = true
  17850. // programXML := "<program>"
  17851. // for scanner.Scan() {
  17852. // line = scanner.Text()
  17853. // programXML += line
  17854. // if strings.Contains(line, "</program>") {
  17855. // programXML += "</program>"
  17856. // break
  17857. // }
  17858. // }
  17859. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17860. // // 解析成功,更新最后的 Program
  17861. // }
  17862. // inProgram = false
  17863. // }
  17864. //}
  17865. //
  17866. // fmt.Println("Error reading file:", inProgram)
  17867. //
  17868. //if err := scanner.Err(); err != nil {
  17869. // fmt.Println("Error reading file:", err)
  17870. //}
  17871. // 输出最后一次的 Program
  17872. //fmt.Printf("最后一次的 <program>:\n")
  17873. //fmt.Printf("<program>\n")
  17874. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17875. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17876. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17877. //fmt.Printf("</program>\n")
  17878. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17879. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17880. return ConvertToString(string(str1), "gbk", "utf-8")
  17881. }
  17882. func (c *HisApiController) GetahBasBaseInfo() string {
  17883. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17884. readCard := DllDef.MustFindProc("iReadCardBas")
  17885. if readCard == nil {
  17886. fmt.Println("readcard is nil")
  17887. readCard = DllDef.MustFindProc("iReadCardBas")
  17888. }
  17889. //str := make([]byte, 1024)
  17890. str1 := make([]byte, 1024)
  17891. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17892. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17893. //if err != nil {
  17894. // fmt.Println("Error opening file:", err)
  17895. //}
  17896. //defer file.Close()
  17897. //
  17898. //var lastProgram Program
  17899. //scanner := bufio.NewScanner(file)
  17900. //inProgram := false
  17901. //
  17902. //for scanner.Scan() {
  17903. // line := scanner.Text()
  17904. // if strings.Contains(line, "<program>") {
  17905. // inProgram = true
  17906. // programXML := "<program>"
  17907. // for scanner.Scan() {
  17908. // line = scanner.Text()
  17909. // programXML += line
  17910. // if strings.Contains(line, "</program>") {
  17911. // programXML += "</program>"
  17912. // break
  17913. // }
  17914. // }
  17915. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17916. // // 解析成功,更新最后的 Program
  17917. // }
  17918. // inProgram = false
  17919. // }
  17920. //}
  17921. //
  17922. // fmt.Println("Error reading file:", inProgram)
  17923. //
  17924. //if err := scanner.Err(); err != nil {
  17925. // fmt.Println("Error reading file:", err)
  17926. //}
  17927. // 输出最后一次的 Program
  17928. //fmt.Printf("最后一次的 <program>:\n")
  17929. //fmt.Printf("<program>\n")
  17930. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17931. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17932. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17933. //fmt.Printf("</program>\n")
  17934. fmt.Println(string(str1))
  17935. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17936. if ret2 != 0 {
  17937. return ""
  17938. }
  17939. return string(str1)
  17940. }
  17941. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17942. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17943. readCard := DllDef.MustFindProc("read_cardinfo")
  17944. if readCard == nil {
  17945. fmt.Println("readcard is nil")
  17946. readCard = DllDef.MustFindProc("read_cardinfo")
  17947. }
  17948. str := make([]byte, 1024) //卡号
  17949. str1 := make([]byte, 1024) //卡识别码
  17950. str2 := make([]byte, 1024) //身份证号
  17951. str3 := make([]byte, 1024) //姓名
  17952. str4 := make([]byte, 1024) //错误信息
  17953. 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])))
  17954. fmt.Println(string(str1))
  17955. fmt.Println(string(str))
  17956. fmt.Println(string(str2))
  17957. fmt.Println(string(str3))
  17958. fmt.Println(string(str4))
  17959. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17960. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17961. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17962. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17963. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17964. if ret2 != 0 {
  17965. return "", "", "", "", ""
  17966. }
  17967. return string(str), string(str1), string(str2), string(str3), string(str4)
  17968. }
  17969. type CustomFundPay struct {
  17970. FundPayType string `json:"fund_pay_type"`
  17971. FundPayamt float64 `json:"fund_payamt"`
  17972. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17973. }
  17974. //func (c *HisApiController) GetBatchSettleList() {
  17975. // start_time_str := c.GetString("start_time")
  17976. // //end_time_str := c.GetString("end_time")
  17977. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17978. //
  17979. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17980. //
  17981. // for _, item := range orders {
  17982. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17983. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17984. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17985. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17986. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17987. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17988. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17989. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17990. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17991. //
  17992. // if order.ID == 0 {
  17993. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17994. // return
  17995. // }
  17996. //
  17997. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17998. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17999. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18000. // //fmt.Println(count)
  18001. // //var zero string
  18002. // //number := count + 1
  18003. // //if number >= 1000 {
  18004. // // zero = "0000" + strconv.FormatInt(number, 10)
  18005. // //} else if number >= 10000 {
  18006. // // zero = "000" + strconv.FormatInt(number, 10)
  18007. // //} else if number >= 100000 {
  18008. // // zero = "00" + strconv.FormatInt(number, 10)
  18009. // //} else if number >= 1000000 {
  18010. // // zero = "0" + strconv.FormatInt(number, 10)
  18011. // //} else {
  18012. // // zero = strconv.FormatInt(number, 10)
  18013. // //}
  18014. // //fmt.Println(zero)
  18015. //
  18016. // struct4101 := service.Struct4101{
  18017. // PsnNo: order.PsnNo,
  18018. // MdtrtId: order.MdtrtId,
  18019. // SetlId: order.SetlId,
  18020. // PsnName: order.PsnName,
  18021. // Gend: order.Gend,
  18022. // Brdy: his.Brdy,
  18023. // Age: his.Age,
  18024. // Naty: order.Naty,
  18025. // PatnCertType: "01",
  18026. // Certno: order.Certno,
  18027. // Prfs: "90",
  18028. // ConerName: roles[0].UserName,
  18029. // PatnRlts: "99",
  18030. // ConerAddr: miConfig.OrgName,
  18031. // ConerTel: admin.Mobile,
  18032. // HiType: order.Insutype,
  18033. // Insuplc: miConfig.InsuplcAdmdvs,
  18034. // MaindiagFlag: "1",
  18035. // BillCode: order.SetlId,
  18036. // BillNo: order.SetlId,
  18037. // BizSn: order.Number,
  18038. // PsnSelfPay: order.PsnPartAmt,
  18039. // PsnOwnPay: order.PsnPartAmt,
  18040. // AcctPay: order.AcctPay,
  18041. // PsnCashpay: order.PsnCashPay,
  18042. // HiPaymtd: "1",
  18043. // Hsorg: miConfig.InsuplcAdmdvs,
  18044. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18045. // MedinsFillPsn: curRoles.UserName,
  18046. // MedinsFillDept: miConfig.OrgName,
  18047. // IptMedType: "2",
  18048. // }
  18049. // struct4101.SetlBegnDate = order.SetlTime
  18050. // struct4101.SetlEndDate = order.SetlTime
  18051. // time_arr := strings.Split(order.SetlTime, " ")
  18052. // struct4101.AdmTime = time_arr[0]
  18053. // struct4101.AdmEndTime = time_arr[0]
  18054. //
  18055. // var rf []CustomFundPay
  18056. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18057. //
  18058. // var tempFunPays []service.CustomStruct
  18059. // for _, item := range rf {
  18060. // var tempFunPay service.CustomStruct
  18061. // tempFunPay.FundPayamt = item.FundPayamt
  18062. // tempFunPay.FundPayType = item.FundPayType
  18063. // tempFunPays = append(tempFunPays, tempFunPay)
  18064. // }
  18065. // struct4101.CustomStruct = tempFunPays
  18066. //
  18067. // var tempDiaginfos []service.DiaginfoStructTwo
  18068. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18069. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18070. //
  18071. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18072. // var config []*models.HisXtDiagnoseConfig
  18073. // for _, item := range diagnosis_ids {
  18074. // id, _ := strconv.ParseInt(item, 10, 64)
  18075. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18076. // config = append(config, &diagnosisConfig)
  18077. // }
  18078. //
  18079. // for index, item := range config {
  18080. // if index == 0 {
  18081. // var tempDiaginfo service.DiaginfoStructTwo
  18082. // tempDiaginfo.DiagCode = item.CountryCode
  18083. // tempDiaginfo.DiagName = item.CountryContentName
  18084. // tempDiaginfo.DiagType = "1"
  18085. // tempDiaginfo.MaindiagFlag = "1"
  18086. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18087. // } else {
  18088. // var tempDiaginfo service.DiaginfoStructTwo
  18089. // tempDiaginfo.DiagCode = item.CountryCode
  18090. // tempDiaginfo.DiagName = item.CountryContentName
  18091. // tempDiaginfo.DiagType = "1"
  18092. // tempDiaginfo.MaindiagFlag = "0"
  18093. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18094. // }
  18095. // }
  18096. // struct4101.Diseinfo = tempDiaginfos
  18097. //
  18098. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18099. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18100. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18101. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18102. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18103. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18104. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18105. //
  18106. // var iteminfo service.IteminfoStruct
  18107. //
  18108. // var bedCostTotal float64 = 0 //床位总费
  18109. // var bedCostSelfTotal float64 = 0 //床位自费
  18110. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18111. //
  18112. // var operationCostTotal float64 = 0 //手术费
  18113. // var operationCostSelfTotal float64 = 0 //手术费
  18114. // var operationCostPartSelfTotal float64 = 0 //手术费
  18115. //
  18116. // var otherCostTotal float64 = 0 //其他费用
  18117. // var otherCostSelfTotal float64 = 0 //其他费用
  18118. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18119. //
  18120. // var materialCostTotal float64 = 0 //材料费
  18121. // var materialCostSelfTotal float64 = 0 //材料费
  18122. // var materialCostPartSelfTotal float64 = 0 //材料费
  18123. //
  18124. // var westernMedicineCostTotal float64 = 0 //西药费
  18125. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18126. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18127. //
  18128. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18129. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18130. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18131. //
  18132. // var checkCostTotal float64 = 0 //检查费
  18133. // var checkCostSelfTotal float64 = 0 //检查费
  18134. // var checkCostPartSelfTotal float64 = 0 //检查费
  18135. //
  18136. // var laboratoryCostTotal float64 = 0 //化验费
  18137. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18138. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18139. //
  18140. // var treatCostTotal float64 = 0 //治疗费用
  18141. // var treatCostSelfTotal float64 = 0 //治疗费用
  18142. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18143. //
  18144. // decimal.DivisionPrecision = 2
  18145. //
  18146. // var bed_fulamt_ownpay_amt float64 = 0
  18147. // var operation_fulamt_ownpay_amt float64 = 0
  18148. // var other_fulamt_ownpay_amt float64 = 0
  18149. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18150. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18151. // var check_fulamt_ownpay_amt float64 = 0
  18152. // var material_fulamt_ownpay_amt float64 = 0
  18153. // var laboratory_fulamt_ownpay_amt float64 = 0
  18154. // var treat_fulamt_ownpay_amt float64 = 0
  18155. //
  18156. // var bed_claa_sunmfee float64 = 0
  18157. // var bed_clab_amt float64 = 0
  18158. // var bed_other_amt float64 = 0
  18159. //
  18160. // var operation_claa_sunmfee float64 = 0
  18161. // var operation_clab_amt float64 = 0
  18162. // var operation_other_amt float64 = 0
  18163. //
  18164. // var other_claa_sunmfee float64 = 0
  18165. // var other_clab_amt float64 = 0
  18166. // var other_other_amt float64 = 0
  18167. //
  18168. // var westernMedicine_claa_sunmfee float64 = 0
  18169. // var westernMedicine_clab_amt float64 = 0
  18170. // var westernMedicine_other_amt float64 = 0
  18171. //
  18172. // var chineseTraditional_claa_sunmfee float64 = 0
  18173. // var chineseTraditional_clab_amt float64 = 0
  18174. // var chineseTraditional_other_amt float64 = 0
  18175. //
  18176. // var check_claa_sunmfee float64 = 0
  18177. // var check_clab_amt float64 = 0
  18178. // var check_other_amt float64 = 0
  18179. //
  18180. // var material_claa_sunmfee float64 = 0
  18181. // var material_clab_amt float64 = 0
  18182. // var material_other_amt float64 = 0
  18183. //
  18184. // var laboratory_claa_sunmfee float64 = 0
  18185. // var laboratory_clab_amt float64 = 0
  18186. // var laboratory_other_amt float64 = 0
  18187. //
  18188. // var treat_claa_sunmfee float64 = 0
  18189. // var treat_clab_amt float64 = 0
  18190. // var treat_other_amt float64 = 0
  18191. //
  18192. // for _, item := range order.HisOrderInfo {
  18193. // if item.MedChrgitmType == "01" { //床位费
  18194. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18195. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18196. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18197. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18198. // if item.ChrgitmLv == "1" {
  18199. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18200. // }
  18201. // if item.ChrgitmLv == "2" {
  18202. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18203. //
  18204. // }
  18205. // if item.ChrgitmLv == "3" {
  18206. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18207. // }
  18208. //
  18209. // }
  18210. //
  18211. // if item.MedChrgitmType == "03" { //检查费
  18212. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18213. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18214. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18215. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18216. // if item.ChrgitmLv == "1" {
  18217. //
  18218. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18219. //
  18220. // }
  18221. // if item.ChrgitmLv == "2" {
  18222. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18223. //
  18224. // }
  18225. // if item.ChrgitmLv == "3" {
  18226. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18227. // }
  18228. // }
  18229. //
  18230. // if item.MedChrgitmType == "04" { //化验费
  18231. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18232. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18233. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18234. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18235. // if item.ChrgitmLv == "1" {
  18236. //
  18237. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18238. //
  18239. // }
  18240. // if item.ChrgitmLv == "2" {
  18241. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18242. //
  18243. // }
  18244. // if item.ChrgitmLv == "3" {
  18245. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18246. // }
  18247. // }
  18248. //
  18249. // if item.MedChrgitmType == "05" { //治疗费
  18250. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18251. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18252. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18253. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18254. // if item.ChrgitmLv == "1" {
  18255. //
  18256. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18257. //
  18258. // }
  18259. // if item.ChrgitmLv == "2" {
  18260. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18261. //
  18262. // }
  18263. // if item.ChrgitmLv == "3" {
  18264. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18265. // }
  18266. // }
  18267. //
  18268. // if item.MedChrgitmType == "06" { //手术费
  18269. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18270. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18271. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18272. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18273. //
  18274. // if item.ChrgitmLv == "1" {
  18275. //
  18276. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18277. //
  18278. // }
  18279. // if item.ChrgitmLv == "2" {
  18280. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18281. //
  18282. // }
  18283. // if item.ChrgitmLv == "3" {
  18284. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18285. // }
  18286. // }
  18287. //
  18288. // if item.MedChrgitmType == "08" { //材料费
  18289. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18290. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18291. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18292. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18293. // if item.ChrgitmLv == "1" {
  18294. //
  18295. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18296. //
  18297. // }
  18298. // if item.ChrgitmLv == "2" {
  18299. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18300. //
  18301. // }
  18302. // if item.ChrgitmLv == "3" {
  18303. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18304. // }
  18305. // }
  18306. //
  18307. // if item.MedChrgitmType == "09" { //西药费
  18308. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18309. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18310. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18311. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18312. // if item.ChrgitmLv == "1" {
  18313. //
  18314. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18315. //
  18316. // }
  18317. // if item.ChrgitmLv == "2" {
  18318. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18319. //
  18320. // }
  18321. // if item.ChrgitmLv == "3" {
  18322. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18323. // }
  18324. // }
  18325. //
  18326. // if item.MedChrgitmType == "11" { //中成费
  18327. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18328. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18329. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18330. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18331. // if item.ChrgitmLv == "1" {
  18332. //
  18333. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18334. //
  18335. // }
  18336. // if item.ChrgitmLv == "2" {
  18337. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18338. //
  18339. // }
  18340. // if item.ChrgitmLv == "3" {
  18341. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18342. // }
  18343. // }
  18344. //
  18345. // if item.MedChrgitmType == "14" { //其他费
  18346. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18347. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18348. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18349. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18350. // if item.ChrgitmLv == "1" {
  18351. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18352. //
  18353. // }
  18354. // if item.ChrgitmLv == "2" {
  18355. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18356. //
  18357. // }
  18358. // if item.ChrgitmLv == "3" {
  18359. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18360. // }
  18361. // }
  18362. //
  18363. // }
  18364. //
  18365. // var iteminfoStructs []service.IteminfoStruct
  18366. //
  18367. // if bedCostTotal != 0 {
  18368. // iteminfo.MedChrgitm = "01"
  18369. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18370. // iteminfo.Amt = bedCostTotal
  18371. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18372. // iteminfo.ClabAmt = bed_clab_amt
  18373. // iteminfo.OthAmt = bed_other_amt
  18374. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18375. // }
  18376. //
  18377. // if checkCostTotal != 0 {
  18378. // iteminfo.MedChrgitm = "03"
  18379. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18380. // iteminfo.Amt = checkCostTotal
  18381. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18382. // iteminfo.ClabAmt = check_clab_amt
  18383. // iteminfo.OthAmt = check_other_amt
  18384. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18385. //
  18386. // }
  18387. //
  18388. // if laboratoryCostTotal != 0 {
  18389. // iteminfo.MedChrgitm = "04"
  18390. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18391. // iteminfo.Amt = laboratoryCostTotal
  18392. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18393. // iteminfo.ClabAmt = laboratory_clab_amt
  18394. // iteminfo.OthAmt = laboratory_other_amt
  18395. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18396. //
  18397. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18398. //
  18399. // }
  18400. //
  18401. // if treatCostTotal != 0 {
  18402. // iteminfo.MedChrgitm = "05"
  18403. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18404. // iteminfo.Amt = treatCostTotal
  18405. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18406. // iteminfo.ClabAmt = treat_clab_amt
  18407. // iteminfo.OthAmt = treat_other_amt
  18408. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18409. // //(struct4101.IteminfoStruct, iteminfo)
  18410. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18411. // }
  18412. //
  18413. // if operationCostTotal != 0 {
  18414. // iteminfo.MedChrgitm = "06"
  18415. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18416. // iteminfo.Amt = operationCostTotal
  18417. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18418. // iteminfo.ClabAmt = operation_clab_amt
  18419. // iteminfo.OthAmt = operation_other_amt
  18420. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18421. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18422. // }
  18423. //
  18424. // if materialCostTotal != 0 {
  18425. // iteminfo.MedChrgitm = "08"
  18426. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18427. // iteminfo.Amt = materialCostTotal
  18428. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18429. // iteminfo.ClabAmt = material_clab_amt
  18430. // iteminfo.OthAmt = material_other_amt
  18431. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18432. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18433. // }
  18434. //
  18435. // if westernMedicineCostTotal != 0 {
  18436. // iteminfo.MedChrgitm = "09"
  18437. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18438. // iteminfo.Amt = westernMedicineCostTotal
  18439. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18440. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18441. // iteminfo.OthAmt = westernMedicine_other_amt
  18442. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18443. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18444. //
  18445. // }
  18446. // if chineseTraditionalMedicineCostTotal != 0 {
  18447. // iteminfo.MedChrgitm = "11"
  18448. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18449. // iteminfo.Amt = westernMedicineCostTotal
  18450. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18451. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18452. // iteminfo.OthAmt = westernMedicine_other_amt
  18453. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18454. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18455. //
  18456. // }
  18457. // if otherCostTotal != 0 {
  18458. // iteminfo.MedChrgitm = "14"
  18459. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18460. // iteminfo.Amt = otherCostTotal
  18461. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18462. // iteminfo.ClabAmt = other_clab_amt
  18463. // iteminfo.OthAmt = other_other_amt
  18464. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18465. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18466. //
  18467. // }
  18468. // struct4101.IteminfoStruct = iteminfoStructs
  18469. // struct4101.Ntly = "中国"
  18470. // struct4101.AdmCaty = "A03.06"
  18471. //
  18472. // struct4101.DoctorName = doctor.UserName
  18473. // struct4101.DoctorCode = doctor.DoctorNumber
  18474. //
  18475. // var res ResultSeventeen
  18476. //
  18477. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18478. // struct4101.BillCode = order.Number
  18479. // struct4101.BillNo = order.SetlId
  18480. // var resOther ResultSeventeenOther
  18481. // var pp models.PublicParams
  18482. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18483. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18484. // pp.FixmedinsName = miConfig.OrgName
  18485. // pp.FixmedinsCode = miConfig.Code
  18486. // pp.RequestUrl = miConfig.Url
  18487. // pp.Cainfo = miConfig.Cainfo
  18488. // pp.SecretKey = miConfig.SecretKey
  18489. // pp.AccessKey = miConfig.AccessKey
  18490. // pp.OpterName = curRoles.UserName
  18491. //
  18492. // client := &http.Client{}
  18493. // var req *http.Request
  18494. // data := make(map[string]interface{})
  18495. // data["struct4101"] = struct4101
  18496. // data["pp"] = pp
  18497. // bytesData, _ := json.Marshal(data)
  18498. // if miConfig.MdtrtareaAdmvs == "320921" {
  18499. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18500. // } else {
  18501. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18502. // }
  18503. // resp, _ := client.Do(req)
  18504. // defer resp.Body.Close()
  18505. // body, ioErr := ioutil.ReadAll(resp.Body)
  18506. // if ioErr != nil {
  18507. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18509. // return
  18510. // }
  18511. // var respJSON map[string]interface{}
  18512. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18513. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18515. // return
  18516. // }
  18517. //
  18518. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18519. // userJSONBytes, _ := json.Marshal(respJSON)
  18520. // fmt.Println("log")
  18521. // fmt.Println(string(userJSONBytes))
  18522. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18523. // utils.ErrorLog("解析失败:%v", err)
  18524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18525. // return
  18526. // }
  18527. // res.InfRefmsgid = resOther.InfRefmsgid
  18528. // res.Output = resOther.Output
  18529. // res.ErrMsg = resOther.ErrMsg
  18530. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18531. // res.Infcode = infocode
  18532. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18533. //
  18534. // var pp models.PublicParams
  18535. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18536. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18537. // pp.FixmedinsName = miConfig.OrgName
  18538. // pp.FixmedinsCode = miConfig.Code
  18539. // pp.RequestUrl = miConfig.Url
  18540. // pp.Cainfo = miConfig.Cainfo
  18541. // pp.SecretKey = miConfig.SecretKey
  18542. // pp.AccessKey = miConfig.AccessKey
  18543. // pp.OpterName = curRoles.UserName
  18544. // result, _ := service.Jxyb4101(struct4101, pp)
  18545. // var dat map[string]interface{}
  18546. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18547. // fmt.Println(dat)
  18548. // } else {
  18549. // fmt.Println(err)
  18550. // }
  18551. // userJSONBytes, _ := json.Marshal(dat)
  18552. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18553. // utils.ErrorLog("解析失败:%v", err)
  18554. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18555. // return
  18556. // }
  18557. //
  18558. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18559. // var pp models.PublicParams
  18560. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18561. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18562. // pp.FixmedinsName = miConfig.OrgName
  18563. // pp.FixmedinsCode = miConfig.Code
  18564. // pp.RequestUrl = miConfig.Url
  18565. // pp.Cainfo = miConfig.Cainfo
  18566. // pp.SecretKey = miConfig.SecretKey
  18567. // pp.AccessKey = miConfig.AccessKey
  18568. // pp.OpterName = curRoles.UserName
  18569. // result, _ := service.Hnyb4101(struct4101, pp)
  18570. // var dat map[string]interface{}
  18571. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18572. // fmt.Println(dat)
  18573. // } else {
  18574. // fmt.Println(err)
  18575. // }
  18576. // userJSONBytes, _ := json.Marshal(dat)
  18577. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18578. // utils.ErrorLog("解析失败:%v", err)
  18579. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18580. // return
  18581. // }
  18582. //
  18583. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18584. // var resOther ResultSeventeenOther
  18585. //
  18586. // var pp models.PublicParams
  18587. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18588. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18589. // pp.FixmedinsName = miConfig.OrgName
  18590. // pp.FixmedinsCode = miConfig.Code
  18591. // pp.RequestUrl = miConfig.Url
  18592. // pp.Cainfo = miConfig.Cainfo
  18593. // pp.SecretKey = miConfig.SecretKey
  18594. // pp.AccessKey = miConfig.AccessKey
  18595. // pp.OpterName = curRoles.UserName
  18596. // client := &http.Client{}
  18597. // var req *http.Request
  18598. // data := make(map[string]interface{})
  18599. // data["struct4101"] = struct4101
  18600. // data["pp"] = pp
  18601. // bytesData, _ := json.Marshal(data)
  18602. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18603. // resp, _ := client.Do(req)
  18604. // defer resp.Body.Close()
  18605. // body, ioErr := ioutil.ReadAll(resp.Body)
  18606. // if ioErr != nil {
  18607. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18609. // return
  18610. // }
  18611. // var respJSON map[string]interface{}
  18612. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18613. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18615. // return
  18616. // }
  18617. //
  18618. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18619. // userJSONBytes, _ := json.Marshal(respJSON)
  18620. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18621. // utils.ErrorLog("解析失败:%v", err)
  18622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18623. // return
  18624. // }
  18625. // res.InfRefmsgid = resOther.InfRefmsgid
  18626. // res.Output = resOther.Output
  18627. // res.ErrMsg = resOther.ErrMsg
  18628. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18629. // res.Infcode = infocode
  18630. //
  18631. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18632. // var pp models.PublicParams
  18633. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18634. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18635. // pp.FixmedinsName = miConfig.OrgName
  18636. // pp.FixmedinsCode = miConfig.Code
  18637. // pp.RequestUrl = miConfig.Url
  18638. // pp.Cainfo = miConfig.Cainfo
  18639. // pp.SecretKey = miConfig.SecretKey
  18640. // pp.AccessKey = miConfig.AccessKey
  18641. // pp.OpterName = curRoles.UserName
  18642. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18643. // fmt.Println(requestLog)
  18644. // fmt.Println(errMsgLog)
  18645. //
  18646. // saveLog(result, requestLog, "4101a", "上传清单")
  18647. //
  18648. // var dat map[string]interface{}
  18649. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18650. // fmt.Println(dat)
  18651. // } else {
  18652. // fmt.Println(err)
  18653. // }
  18654. // userJSONBytes, _ := json.Marshal(dat)
  18655. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18656. // utils.ErrorLog("解析失败:%v", err)
  18657. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18658. // return
  18659. // }
  18660. //
  18661. // } else {
  18662. //
  18663. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18664. // var dat map[string]interface{}
  18665. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18666. // fmt.Println(dat)
  18667. // } else {
  18668. // fmt.Println(err)
  18669. // }
  18670. // userJSONBytes, _ := json.Marshal(dat)
  18671. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18672. // utils.ErrorLog("解析失败:%v", err)
  18673. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18674. // return
  18675. // }
  18676. // }
  18677. //
  18678. // if res.Infcode != 0 {
  18679. // adminUser := c.GetAdminUserInfo()
  18680. // errlog := &models.HisOrderError{
  18681. // UserOrgId: adminUser.CurrentOrgId,
  18682. // Ctime: time.Now().Unix(),
  18683. // Mtime: time.Now().Unix(),
  18684. // ErrMsg: res.ErrMsg,
  18685. // Status: 1,
  18686. // PatientId: order.ID,
  18687. // Stage: 10265,
  18688. // }
  18689. // service.CreateErrMsgLog(errlog)
  18690. // continue
  18691. // } else {
  18692. // //order.FaPiaoNumber = zero
  18693. // //order.FaPiaoCode = last_order.FaPiaoCode
  18694. // //service.UpdateOrder(order)
  18695. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18696. // Number: res.Output.SetlListId,
  18697. // Status: 1,
  18698. // Ctime: time.Now().Unix(),
  18699. // Mtime: time.Now().Unix(),
  18700. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18701. // IsUpload: 1,
  18702. // OrderId: order.ID,
  18703. // }
  18704. // service.CreateUploadRecord(hisFundSettleListResult)
  18705. // c.ServeSuccessJSON(map[string]interface{}{
  18706. // "msg": "上传成功",
  18707. // "result": hisFundSettleListResult,
  18708. // })
  18709. // continue
  18710. // }
  18711. // }
  18712. //}
  18713. func (c *HisApiController) GetbatchSettleList() {
  18714. //order_id, _ := c.GetInt64("order_id")
  18715. admin_user_id, _ := c.GetInt64("admin_user_id")
  18716. orders, _ := service.GetAllHisOrderTwo10485()
  18717. for _, item := range orders {
  18718. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18719. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18720. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18721. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18722. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18723. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18724. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18725. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18726. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18727. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18728. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18729. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18730. //fmt.Println(count)
  18731. //var zero string
  18732. //number := count + 1
  18733. //if number >= 1000 {
  18734. // zero = "0000" + strconv.FormatInt(number, 10)
  18735. //} else if number >= 10000 {
  18736. // zero = "000" + strconv.FormatInt(number, 10)
  18737. //} else if number >= 100000 {
  18738. // zero = "00" + strconv.FormatInt(number, 10)
  18739. //} else if number >= 1000000 {
  18740. // zero = "0" + strconv.FormatInt(number, 10)
  18741. //} else {
  18742. // zero = strconv.FormatInt(number, 10)
  18743. //}
  18744. //fmt.Println(zero)
  18745. struct4101 := service.Struct4101{
  18746. PsnNo: order.PsnNo,
  18747. MdtrtId: order.MdtrtId,
  18748. SetlId: order.SetlId,
  18749. PsnName: order.PsnName,
  18750. Gend: order.Gend,
  18751. Brdy: his.Brdy,
  18752. Age: his.Age,
  18753. Naty: order.Naty,
  18754. PatnCertType: "01",
  18755. Certno: order.Certno,
  18756. Prfs: "90",
  18757. ConerName: roles[0].UserName,
  18758. PatnRlts: "99",
  18759. ConerAddr: miConfig.OrgName,
  18760. ConerTel: admin.Mobile,
  18761. HiType: order.Insutype,
  18762. Insuplc: miConfig.InsuplcAdmdvs,
  18763. MaindiagFlag: "1",
  18764. BillCode: order.SetlId,
  18765. BillNo: order.SetlId,
  18766. BizSn: order.Number,
  18767. PsnSelfPay: order.PsnPartAmt,
  18768. PsnOwnPay: order.PsnPartAmt,
  18769. AcctPay: order.AcctPay,
  18770. PsnCashpay: order.PsnCashPay,
  18771. HiPaymtd: "1",
  18772. Hsorg: miConfig.InsuplcAdmdvs,
  18773. HsorgOpter: miConfig.InsuplcAdmdvs,
  18774. MedinsFillPsn: curRoles.UserName,
  18775. MedinsFillDept: miConfig.OrgName,
  18776. IptMedType: "2",
  18777. }
  18778. struct4101.SetlBegnDate = order.SetlTime
  18779. struct4101.SetlEndDate = order.SetlTime
  18780. time_arr := strings.Split(order.SetlTime, " ")
  18781. struct4101.AdmTime = time_arr[0]
  18782. struct4101.AdmEndTime = time_arr[0]
  18783. //var rf []CustomFundPay
  18784. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18785. //
  18786. //var tempFunPays []service.CustomStruct
  18787. //for _, item := range rf {
  18788. // var tempFunPay service.CustomStruct
  18789. // tempFunPay.FundPayamt = item.FundPayamt
  18790. // tempFunPay.FundPayType = item.FundPayType
  18791. // tempFunPays = append(tempFunPays, tempFunPay)
  18792. //}
  18793. //struct4101.CustomStruct = tempFunPays
  18794. var tempDiaginfos []service.DiaginfoStructTwo
  18795. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18796. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18797. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18798. var config []*models.HisXtDiagnoseConfig
  18799. for _, item := range diagnosis_ids {
  18800. id, _ := strconv.ParseInt(item, 10, 64)
  18801. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18802. config = append(config, &diagnosisConfig)
  18803. }
  18804. for index, item := range config {
  18805. if index == 0 {
  18806. var tempDiaginfo service.DiaginfoStructTwo
  18807. tempDiaginfo.DiagCode = item.CountryCode
  18808. tempDiaginfo.DiagName = item.CountryContentName
  18809. tempDiaginfo.DiagType = "1"
  18810. tempDiaginfo.MaindiagFlag = "1"
  18811. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18812. } else {
  18813. var tempDiaginfo service.DiaginfoStructTwo
  18814. tempDiaginfo.DiagCode = item.CountryCode
  18815. tempDiaginfo.DiagName = item.CountryContentName
  18816. tempDiaginfo.DiagType = "1"
  18817. tempDiaginfo.MaindiagFlag = "0"
  18818. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18819. }
  18820. }
  18821. struct4101.Diseinfo = tempDiaginfos
  18822. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18823. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18824. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18825. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18826. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18827. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18828. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18829. var iteminfo service.IteminfoStruct
  18830. var bedCostTotal float64 = 0 //床位总费
  18831. var bedCostSelfTotal float64 = 0 //床位自费
  18832. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18833. var operationCostTotal float64 = 0 //手术费
  18834. var operationCostSelfTotal float64 = 0 //手术费
  18835. var operationCostPartSelfTotal float64 = 0 //手术费
  18836. var otherCostTotal float64 = 0 //其他费用
  18837. var otherCostSelfTotal float64 = 0 //其他费用
  18838. var otherCostPartSelfTotal float64 = 0 //其他费用
  18839. var materialCostTotal float64 = 0 //材料费
  18840. var materialCostSelfTotal float64 = 0 //材料费
  18841. var materialCostPartSelfTotal float64 = 0 //材料费
  18842. var westernMedicineCostTotal float64 = 0 //西药费
  18843. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18844. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18845. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18846. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18847. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18848. var checkCostTotal float64 = 0 //检查费
  18849. var checkCostSelfTotal float64 = 0 //检查费
  18850. var checkCostPartSelfTotal float64 = 0 //检查费
  18851. var laboratoryCostTotal float64 = 0 //化验费
  18852. var laboratoryCostSelfTotal float64 = 0 //化验费
  18853. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18854. var treatCostTotal float64 = 0 //治疗费用
  18855. var treatCostSelfTotal float64 = 0 //治疗费用
  18856. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18857. decimal.DivisionPrecision = 2
  18858. var bed_fulamt_ownpay_amt float64 = 0
  18859. var operation_fulamt_ownpay_amt float64 = 0
  18860. var other_fulamt_ownpay_amt float64 = 0
  18861. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18862. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18863. var check_fulamt_ownpay_amt float64 = 0
  18864. var material_fulamt_ownpay_amt float64 = 0
  18865. var laboratory_fulamt_ownpay_amt float64 = 0
  18866. var treat_fulamt_ownpay_amt float64 = 0
  18867. var bed_claa_sunmfee float64 = 0
  18868. var bed_clab_amt float64 = 0
  18869. var bed_other_amt float64 = 0
  18870. var operation_claa_sunmfee float64 = 0
  18871. var operation_clab_amt float64 = 0
  18872. var operation_other_amt float64 = 0
  18873. var other_claa_sunmfee float64 = 0
  18874. var other_clab_amt float64 = 0
  18875. var other_other_amt float64 = 0
  18876. var westernMedicine_claa_sunmfee float64 = 0
  18877. var westernMedicine_clab_amt float64 = 0
  18878. var westernMedicine_other_amt float64 = 0
  18879. var chineseTraditional_claa_sunmfee float64 = 0
  18880. var chineseTraditional_clab_amt float64 = 0
  18881. var chineseTraditional_other_amt float64 = 0
  18882. var check_claa_sunmfee float64 = 0
  18883. var check_clab_amt float64 = 0
  18884. var check_other_amt float64 = 0
  18885. var material_claa_sunmfee float64 = 0
  18886. var material_clab_amt float64 = 0
  18887. var material_other_amt float64 = 0
  18888. var laboratory_claa_sunmfee float64 = 0
  18889. var laboratory_clab_amt float64 = 0
  18890. var laboratory_other_amt float64 = 0
  18891. var treat_claa_sunmfee float64 = 0
  18892. var treat_clab_amt float64 = 0
  18893. var treat_other_amt float64 = 0
  18894. for _, item := range order.HisOrderInfo {
  18895. if item.MedChrgitmType == "01" { //床位费
  18896. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18897. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18898. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18899. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18900. if item.ChrgitmLv == "1" {
  18901. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18902. }
  18903. if item.ChrgitmLv == "2" {
  18904. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18905. }
  18906. if item.ChrgitmLv == "3" {
  18907. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18908. }
  18909. }
  18910. if item.MedChrgitmType == "03" { //检查费
  18911. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18912. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18913. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18914. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18915. if item.ChrgitmLv == "1" {
  18916. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18917. }
  18918. if item.ChrgitmLv == "2" {
  18919. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18920. }
  18921. if item.ChrgitmLv == "3" {
  18922. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18923. }
  18924. }
  18925. if item.MedChrgitmType == "04" { //化验费
  18926. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18927. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18928. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18929. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18930. if item.ChrgitmLv == "1" {
  18931. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18932. }
  18933. if item.ChrgitmLv == "2" {
  18934. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18935. }
  18936. if item.ChrgitmLv == "3" {
  18937. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18938. }
  18939. }
  18940. if item.MedChrgitmType == "05" { //治疗费
  18941. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18942. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18943. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18944. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18945. if item.ChrgitmLv == "1" {
  18946. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18947. }
  18948. if item.ChrgitmLv == "2" {
  18949. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18950. }
  18951. if item.ChrgitmLv == "3" {
  18952. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18953. }
  18954. }
  18955. if item.MedChrgitmType == "06" { //手术费
  18956. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18957. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18958. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18959. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18960. if item.ChrgitmLv == "1" {
  18961. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18962. }
  18963. if item.ChrgitmLv == "2" {
  18964. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18965. }
  18966. if item.ChrgitmLv == "3" {
  18967. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18968. }
  18969. }
  18970. if item.MedChrgitmType == "08" { //材料费
  18971. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18972. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18973. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18974. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18975. if item.ChrgitmLv == "1" {
  18976. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18977. }
  18978. if item.ChrgitmLv == "2" {
  18979. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18980. }
  18981. if item.ChrgitmLv == "3" {
  18982. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18983. }
  18984. }
  18985. if item.MedChrgitmType == "09" { //西药费
  18986. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18987. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18988. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18989. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18990. if item.ChrgitmLv == "1" {
  18991. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18992. }
  18993. if item.ChrgitmLv == "2" {
  18994. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18995. }
  18996. if item.ChrgitmLv == "3" {
  18997. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18998. }
  18999. }
  19000. if item.MedChrgitmType == "11" { //中成费
  19001. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19002. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19003. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19004. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19005. if item.ChrgitmLv == "1" {
  19006. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19007. }
  19008. if item.ChrgitmLv == "2" {
  19009. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19010. }
  19011. if item.ChrgitmLv == "3" {
  19012. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19013. }
  19014. }
  19015. if item.MedChrgitmType == "14" { //其他费
  19016. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19017. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19018. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19019. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19020. if item.ChrgitmLv == "1" {
  19021. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19022. }
  19023. if item.ChrgitmLv == "2" {
  19024. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19025. }
  19026. if item.ChrgitmLv == "3" {
  19027. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19028. }
  19029. }
  19030. }
  19031. var iteminfoStructs []service.IteminfoStruct
  19032. if bedCostTotal != 0 {
  19033. iteminfo.MedChrgitm = "01"
  19034. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19035. iteminfo.Amt = bedCostTotal
  19036. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19037. iteminfo.ClabAmt = bed_clab_amt
  19038. iteminfo.OthAmt = bed_other_amt
  19039. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19040. }
  19041. if checkCostTotal != 0 {
  19042. iteminfo.MedChrgitm = "03"
  19043. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19044. iteminfo.Amt = checkCostTotal
  19045. iteminfo.ClaaSumfee = check_claa_sunmfee
  19046. iteminfo.ClabAmt = check_clab_amt
  19047. iteminfo.OthAmt = check_other_amt
  19048. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19049. }
  19050. if laboratoryCostTotal != 0 {
  19051. iteminfo.MedChrgitm = "04"
  19052. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19053. iteminfo.Amt = laboratoryCostTotal
  19054. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19055. iteminfo.ClabAmt = laboratory_clab_amt
  19056. iteminfo.OthAmt = laboratory_other_amt
  19057. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19058. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19059. }
  19060. if treatCostTotal != 0 {
  19061. iteminfo.MedChrgitm = "05"
  19062. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19063. iteminfo.Amt = treatCostTotal
  19064. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19065. iteminfo.ClabAmt = treat_clab_amt
  19066. iteminfo.OthAmt = treat_other_amt
  19067. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19068. //(struct4101.IteminfoStruct, iteminfo)
  19069. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19070. }
  19071. if operationCostTotal != 0 {
  19072. iteminfo.MedChrgitm = "06"
  19073. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19074. iteminfo.Amt = operationCostTotal
  19075. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19076. iteminfo.ClabAmt = operation_clab_amt
  19077. iteminfo.OthAmt = operation_other_amt
  19078. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19079. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19080. }
  19081. if materialCostTotal != 0 {
  19082. iteminfo.MedChrgitm = "08"
  19083. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19084. iteminfo.Amt = materialCostTotal
  19085. iteminfo.ClaaSumfee = material_claa_sunmfee
  19086. iteminfo.ClabAmt = material_clab_amt
  19087. iteminfo.OthAmt = material_other_amt
  19088. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19089. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19090. }
  19091. if westernMedicineCostTotal != 0 {
  19092. iteminfo.MedChrgitm = "09"
  19093. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19094. iteminfo.Amt = westernMedicineCostTotal
  19095. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19096. iteminfo.ClabAmt = westernMedicine_clab_amt
  19097. iteminfo.OthAmt = westernMedicine_other_amt
  19098. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19099. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19100. }
  19101. if chineseTraditionalMedicineCostTotal != 0 {
  19102. iteminfo.MedChrgitm = "11"
  19103. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19104. iteminfo.Amt = westernMedicineCostTotal
  19105. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19106. iteminfo.ClabAmt = westernMedicine_clab_amt
  19107. iteminfo.OthAmt = westernMedicine_other_amt
  19108. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19109. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19110. }
  19111. if otherCostTotal != 0 {
  19112. iteminfo.MedChrgitm = "14"
  19113. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19114. iteminfo.Amt = otherCostTotal
  19115. iteminfo.ClaaSumfee = other_claa_sunmfee
  19116. iteminfo.ClabAmt = other_clab_amt
  19117. iteminfo.OthAmt = other_other_amt
  19118. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19119. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19120. }
  19121. struct4101.IteminfoStruct = iteminfoStructs
  19122. struct4101.Ntly = "中国"
  19123. struct4101.AdmCaty = "A03.06"
  19124. struct4101.DoctorName = doctor.UserName
  19125. struct4101.DoctorCode = doctor.DoctorNumber
  19126. var res ResultSeventeen
  19127. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19128. struct4101.BillCode = order.Number
  19129. struct4101.BillNo = order.SetlId
  19130. var resOther ResultSeventeenOther
  19131. var pp models.PublicParams
  19132. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19133. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19134. pp.FixmedinsName = miConfig.OrgName
  19135. pp.FixmedinsCode = miConfig.Code
  19136. pp.RequestUrl = miConfig.Url
  19137. pp.Cainfo = miConfig.Cainfo
  19138. pp.SecretKey = miConfig.SecretKey
  19139. pp.AccessKey = miConfig.AccessKey
  19140. pp.OpterName = curRoles.UserName
  19141. client := &http.Client{}
  19142. var req *http.Request
  19143. data := make(map[string]interface{})
  19144. data["struct4101"] = struct4101
  19145. data["pp"] = pp
  19146. bytesData, _ := json.Marshal(data)
  19147. if miConfig.MdtrtareaAdmvs == "320921" {
  19148. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19149. } else {
  19150. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19151. }
  19152. resp, _ := client.Do(req)
  19153. defer resp.Body.Close()
  19154. body, ioErr := ioutil.ReadAll(resp.Body)
  19155. if ioErr != nil {
  19156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19158. return
  19159. }
  19160. var respJSON map[string]interface{}
  19161. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19164. return
  19165. }
  19166. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19167. userJSONBytes, _ := json.Marshal(respJSON)
  19168. fmt.Println("log")
  19169. fmt.Println(string(userJSONBytes))
  19170. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19171. utils.ErrorLog("解析失败:%v", err)
  19172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19173. return
  19174. }
  19175. res.InfRefmsgid = resOther.InfRefmsgid
  19176. res.Output = resOther.Output
  19177. res.ErrMsg = resOther.ErrMsg
  19178. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19179. res.Infcode = infocode
  19180. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19181. var pp models.PublicParams
  19182. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19183. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19184. pp.FixmedinsName = miConfig.OrgName
  19185. pp.FixmedinsCode = miConfig.Code
  19186. pp.RequestUrl = miConfig.Url
  19187. pp.Cainfo = miConfig.Cainfo
  19188. pp.SecretKey = miConfig.SecretKey
  19189. pp.AccessKey = miConfig.AccessKey
  19190. pp.OpterName = curRoles.UserName
  19191. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19192. result, _ := service.Jxyb4101(struct4101, pp)
  19193. var dat map[string]interface{}
  19194. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19195. fmt.Println(dat)
  19196. } else {
  19197. fmt.Println(err)
  19198. }
  19199. userJSONBytes, _ := json.Marshal(dat)
  19200. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19201. utils.ErrorLog("解析失败:%v", err)
  19202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19203. return
  19204. }
  19205. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19206. var pp models.PublicParams
  19207. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19208. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19209. pp.FixmedinsName = miConfig.OrgName
  19210. pp.FixmedinsCode = miConfig.Code
  19211. pp.RequestUrl = miConfig.Url
  19212. pp.Cainfo = miConfig.Cainfo
  19213. pp.SecretKey = miConfig.SecretKey
  19214. pp.AccessKey = miConfig.AccessKey
  19215. pp.OpterName = curRoles.UserName
  19216. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19217. result, _ := service.Jxyb4101(struct4101, pp)
  19218. var dat map[string]interface{}
  19219. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19220. fmt.Println(dat)
  19221. } else {
  19222. fmt.Println(err)
  19223. }
  19224. userJSONBytes, _ := json.Marshal(dat)
  19225. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19226. utils.ErrorLog("解析失败:%v", err)
  19227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19228. return
  19229. }
  19230. } else if miConfig.MdtrtareaAdmvs == "360100" {
  19231. var pp models.PublicParams
  19232. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19233. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19234. pp.FixmedinsName = miConfig.OrgName
  19235. pp.FixmedinsCode = miConfig.Code
  19236. pp.RequestUrl = miConfig.Url
  19237. pp.Cainfo = miConfig.Cainfo
  19238. pp.SecretKey = miConfig.SecretKey
  19239. pp.AccessKey = miConfig.AccessKey
  19240. pp.OpterName = curRoles.UserName
  19241. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19242. result, _ := service.Jxyb4101(struct4101, pp)
  19243. var dat map[string]interface{}
  19244. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19245. fmt.Println(dat)
  19246. } else {
  19247. fmt.Println(err)
  19248. }
  19249. userJSONBytes, _ := json.Marshal(dat)
  19250. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19251. utils.ErrorLog("解析失败:%v", err)
  19252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19253. return
  19254. }
  19255. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19256. var pp models.PublicParams
  19257. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19258. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19259. pp.FixmedinsName = miConfig.OrgName
  19260. pp.FixmedinsCode = miConfig.Code
  19261. pp.RequestUrl = miConfig.Url
  19262. pp.Cainfo = miConfig.Cainfo
  19263. pp.SecretKey = miConfig.SecretKey
  19264. pp.AccessKey = miConfig.AccessKey
  19265. pp.OpterName = curRoles.UserName
  19266. result, _ := service.Hnyb4101(struct4101, pp)
  19267. var dat map[string]interface{}
  19268. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19269. fmt.Println(dat)
  19270. } else {
  19271. fmt.Println(err)
  19272. }
  19273. userJSONBytes, _ := json.Marshal(dat)
  19274. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19275. utils.ErrorLog("解析失败:%v", err)
  19276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19277. return
  19278. }
  19279. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19280. var resOther ResultSeventeenOther
  19281. var pp models.PublicParams
  19282. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19283. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19284. pp.FixmedinsName = miConfig.OrgName
  19285. pp.FixmedinsCode = miConfig.Code
  19286. pp.RequestUrl = miConfig.Url
  19287. pp.Cainfo = miConfig.Cainfo
  19288. pp.SecretKey = miConfig.SecretKey
  19289. pp.AccessKey = miConfig.AccessKey
  19290. pp.OpterName = curRoles.UserName
  19291. client := &http.Client{}
  19292. var req *http.Request
  19293. data := make(map[string]interface{})
  19294. data["struct4101"] = struct4101
  19295. data["pp"] = pp
  19296. bytesData, _ := json.Marshal(data)
  19297. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19298. resp, _ := client.Do(req)
  19299. defer resp.Body.Close()
  19300. body, ioErr := ioutil.ReadAll(resp.Body)
  19301. if ioErr != nil {
  19302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19304. return
  19305. }
  19306. var respJSON map[string]interface{}
  19307. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19310. return
  19311. }
  19312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19313. userJSONBytes, _ := json.Marshal(respJSON)
  19314. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19315. utils.ErrorLog("解析失败:%v", err)
  19316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19317. return
  19318. }
  19319. res.InfRefmsgid = resOther.InfRefmsgid
  19320. res.Output = resOther.Output
  19321. res.ErrMsg = resOther.ErrMsg
  19322. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19323. res.Infcode = infocode
  19324. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19325. var pp models.PublicParams
  19326. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19327. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19328. pp.FixmedinsName = miConfig.OrgName
  19329. pp.FixmedinsCode = miConfig.Code
  19330. pp.RequestUrl = miConfig.Url
  19331. pp.Cainfo = miConfig.Cainfo
  19332. pp.SecretKey = miConfig.SecretKey
  19333. pp.AccessKey = miConfig.AccessKey
  19334. pp.OpterName = curRoles.UserName
  19335. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19336. fmt.Println(requestLog)
  19337. fmt.Println(errMsgLog)
  19338. saveLog(result, requestLog, "4101a", "上传清单")
  19339. var dat map[string]interface{}
  19340. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19341. fmt.Println(dat)
  19342. } else {
  19343. fmt.Println(err)
  19344. }
  19345. userJSONBytes, _ := json.Marshal(dat)
  19346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19347. utils.ErrorLog("解析失败:%v", err)
  19348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19349. return
  19350. }
  19351. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19352. var pp models.PublicParams
  19353. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19354. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19355. pp.FixmedinsName = miConfig.OrgName
  19356. pp.FixmedinsCode = miConfig.Code
  19357. pp.RequestUrl = miConfig.Url
  19358. pp.Cainfo = miConfig.Cainfo
  19359. pp.SecretKey = miConfig.SecretKey
  19360. pp.AccessKey = miConfig.AccessKey
  19361. pp.OpterName = curRoles.UserName
  19362. client := &http.Client{}
  19363. var req *http.Request
  19364. data := make(map[string]interface{})
  19365. data["struct4101"] = struct4101
  19366. data["pp"] = pp
  19367. bytesData, _ := json.Marshal(data)
  19368. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19369. resp, _ := client.Do(req)
  19370. defer resp.Body.Close()
  19371. body, ioErr := ioutil.ReadAll(resp.Body)
  19372. if ioErr != nil {
  19373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19375. return
  19376. }
  19377. var respJSON map[string]interface{}
  19378. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19381. return
  19382. }
  19383. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19384. userJSONBytes, _ := json.Marshal(respJSON)
  19385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19386. utils.ErrorLog("解析失败:%v", err)
  19387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19388. return
  19389. }
  19390. } else {
  19391. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19392. var dat map[string]interface{}
  19393. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19394. fmt.Println(dat)
  19395. } else {
  19396. fmt.Println(err)
  19397. }
  19398. userJSONBytes, _ := json.Marshal(dat)
  19399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19400. utils.ErrorLog("解析失败:%v", err)
  19401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19402. return
  19403. }
  19404. }
  19405. if res.Infcode != 0 {
  19406. errlog := &models.HisOrderError{
  19407. UserOrgId: order.UserOrgId,
  19408. Ctime: time.Now().Unix(),
  19409. Mtime: time.Now().Unix(),
  19410. ErrMsg: res.ErrMsg + "解析失败",
  19411. Status: 1,
  19412. PatientId: order.ID,
  19413. Stage: 10485,
  19414. }
  19415. service.CreateErrMsgLog(errlog)
  19416. continue
  19417. //c.ServeSuccessJSON(map[string]interface{}{
  19418. // "failed_code": -10,
  19419. // "msg": res.ErrMsg,
  19420. //})
  19421. } else {
  19422. //order.FaPiaoNumber = zero
  19423. //order.FaPiaoCode = last_order.FaPiaoCode
  19424. //service.UpdateOrder(order)
  19425. hisFundSettleListResult := &models.HisFundSettleListResult{
  19426. Number: res.Output.SetlListId,
  19427. Status: 1,
  19428. Ctime: time.Now().Unix(),
  19429. Mtime: time.Now().Unix(),
  19430. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19431. IsUpload: 1,
  19432. OrderId: order.ID,
  19433. }
  19434. service.CreateUploadRecord(hisFundSettleListResult)
  19435. continue
  19436. }
  19437. }
  19438. }
  19439. func (c *HisApiController) GetSettleList() {
  19440. order_id, _ := c.GetInt64("order_id")
  19441. admin_user_id, _ := c.GetInt64("admin_user_id")
  19442. order, _ := service.GetHisOrderByIDTwo(order_id)
  19443. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19444. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19445. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19446. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19447. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19448. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19449. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19450. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19451. if order.ID == 0 {
  19452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19453. return
  19454. }
  19455. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19456. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19457. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19458. //fmt.Println(count)
  19459. //var zero string
  19460. //number := count + 1
  19461. //if number >= 1000 {
  19462. // zero = "0000" + strconv.FormatInt(number, 10)
  19463. //} else if number >= 10000 {
  19464. // zero = "000" + strconv.FormatInt(number, 10)
  19465. //} else if number >= 100000 {
  19466. // zero = "00" + strconv.FormatInt(number, 10)
  19467. //} else if number >= 1000000 {
  19468. // zero = "0" + strconv.FormatInt(number, 10)
  19469. //} else {
  19470. // zero = strconv.FormatInt(number, 10)
  19471. //}
  19472. //fmt.Println(zero)
  19473. struct4101 := service.Struct4101{
  19474. PsnNo: order.PsnNo,
  19475. MdtrtId: order.MdtrtId,
  19476. SetlId: order.SetlId,
  19477. PsnName: order.PsnName,
  19478. Gend: order.Gend,
  19479. Brdy: his.Brdy,
  19480. Age: his.Age,
  19481. Naty: order.Naty,
  19482. PatnCertType: "01",
  19483. Certno: order.Certno,
  19484. Prfs: "90",
  19485. ConerName: roles[0].UserName,
  19486. PatnRlts: "99",
  19487. ConerAddr: miConfig.OrgName,
  19488. ConerTel: admin.Mobile,
  19489. HiType: order.Insutype,
  19490. Insuplc: miConfig.InsuplcAdmdvs,
  19491. MaindiagFlag: "1",
  19492. BillCode: order.SetlId,
  19493. BillNo: order.SetlId,
  19494. BizSn: order.Number,
  19495. PsnSelfPay: order.PsnPartAmt,
  19496. PsnOwnPay: order.PsnPartAmt,
  19497. AcctPay: order.AcctPay,
  19498. PsnCashpay: order.PsnCashPay,
  19499. HiPaymtd: "1",
  19500. Hsorg: miConfig.InsuplcAdmdvs,
  19501. HsorgOpter: miConfig.InsuplcAdmdvs,
  19502. MedinsFillPsn: curRoles.UserName,
  19503. MedinsFillDept: miConfig.OrgName,
  19504. IptMedType: "2",
  19505. }
  19506. struct4101.SetlBegnDate = order.SetlTime
  19507. struct4101.SetlEndDate = order.SetlTime
  19508. time_arr := strings.Split(order.SetlTime, " ")
  19509. struct4101.AdmTime = time_arr[0]
  19510. struct4101.AdmEndTime = time_arr[0]
  19511. //
  19512. //var rf []CustomFundPay
  19513. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19514. //
  19515. //var tempFunPays []service.CustomStruct
  19516. //for _, item := range rf {
  19517. // var tempFunPay service.CustomStruct
  19518. // tempFunPay.FundPayamt = item.FundPayamt
  19519. // tempFunPay.FundPayType = item.FundPayType
  19520. // tempFunPays = append(tempFunPays, tempFunPay)
  19521. //}
  19522. //struct4101.CustomStruct = tempFunPays
  19523. var tempDiaginfos []service.DiaginfoStructTwo
  19524. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19525. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19526. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19527. var config []*models.HisXtDiagnoseConfig
  19528. for _, item := range diagnosis_ids {
  19529. id, _ := strconv.ParseInt(item, 10, 64)
  19530. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19531. config = append(config, &diagnosisConfig)
  19532. }
  19533. if miConfig.Code == "H15049901371" {
  19534. //for _, item := range config {
  19535. // if item.ID == 138 {
  19536. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19537. var tempDiaginfo service.DiaginfoStructTwo
  19538. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19539. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19540. tempDiaginfo.DiagType = "1"
  19541. tempDiaginfo.MaindiagFlag = "1"
  19542. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19543. //}
  19544. //}
  19545. for _, item := range config {
  19546. if item.ID != 138 {
  19547. var tempDiaginfo service.DiaginfoStructTwo
  19548. tempDiaginfo.DiagCode = item.CountryCode
  19549. tempDiaginfo.DiagName = item.CountryContentName
  19550. tempDiaginfo.DiagType = "1"
  19551. tempDiaginfo.MaindiagFlag = "0"
  19552. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19553. }
  19554. }
  19555. } else {
  19556. for index, item := range config {
  19557. if index == 0 {
  19558. var tempDiaginfo service.DiaginfoStructTwo
  19559. tempDiaginfo.DiagCode = item.CountryCode
  19560. tempDiaginfo.DiagName = item.CountryContentName
  19561. tempDiaginfo.DiagType = "1"
  19562. tempDiaginfo.MaindiagFlag = "1"
  19563. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19564. } else {
  19565. var tempDiaginfo service.DiaginfoStructTwo
  19566. tempDiaginfo.DiagCode = item.CountryCode
  19567. tempDiaginfo.DiagName = item.CountryContentName
  19568. tempDiaginfo.DiagType = "1"
  19569. tempDiaginfo.MaindiagFlag = "0"
  19570. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19571. }
  19572. }
  19573. }
  19574. struct4101.Diseinfo = tempDiaginfos
  19575. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19576. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19577. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19578. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19579. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19580. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19581. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19582. var iteminfo service.IteminfoStruct
  19583. var bedCostTotal float64 = 0 //床位总费
  19584. var bedCostSelfTotal float64 = 0 //床位自费
  19585. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19586. var operationCostTotal float64 = 0 //手术费
  19587. var operationCostSelfTotal float64 = 0 //手术费
  19588. var operationCostPartSelfTotal float64 = 0 //手术费
  19589. var otherCostTotal float64 = 0 //其他费用
  19590. var otherCostSelfTotal float64 = 0 //其他费用
  19591. var otherCostPartSelfTotal float64 = 0 //其他费用
  19592. var materialCostTotal float64 = 0 //材料费
  19593. var materialCostSelfTotal float64 = 0 //材料费
  19594. var materialCostPartSelfTotal float64 = 0 //材料费
  19595. var westernMedicineCostTotal float64 = 0 //西药费
  19596. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19597. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19598. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19599. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19600. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19601. var checkCostTotal float64 = 0 //检查费
  19602. var checkCostSelfTotal float64 = 0 //检查费
  19603. var checkCostPartSelfTotal float64 = 0 //检查费
  19604. var laboratoryCostTotal float64 = 0 //化验费
  19605. var laboratoryCostSelfTotal float64 = 0 //化验费
  19606. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19607. var treatCostTotal float64 = 0 //治疗费用
  19608. var treatCostSelfTotal float64 = 0 //治疗费用
  19609. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19610. decimal.DivisionPrecision = 2
  19611. var bed_fulamt_ownpay_amt float64 = 0
  19612. var operation_fulamt_ownpay_amt float64 = 0
  19613. var other_fulamt_ownpay_amt float64 = 0
  19614. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19615. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19616. var check_fulamt_ownpay_amt float64 = 0
  19617. var material_fulamt_ownpay_amt float64 = 0
  19618. var laboratory_fulamt_ownpay_amt float64 = 0
  19619. var treat_fulamt_ownpay_amt float64 = 0
  19620. var bed_claa_sunmfee float64 = 0
  19621. var bed_clab_amt float64 = 0
  19622. var bed_other_amt float64 = 0
  19623. var operation_claa_sunmfee float64 = 0
  19624. var operation_clab_amt float64 = 0
  19625. var operation_other_amt float64 = 0
  19626. var other_claa_sunmfee float64 = 0
  19627. var other_clab_amt float64 = 0
  19628. var other_other_amt float64 = 0
  19629. var westernMedicine_claa_sunmfee float64 = 0
  19630. var westernMedicine_clab_amt float64 = 0
  19631. var westernMedicine_other_amt float64 = 0
  19632. var chineseTraditional_claa_sunmfee float64 = 0
  19633. var chineseTraditional_clab_amt float64 = 0
  19634. var chineseTraditional_other_amt float64 = 0
  19635. var check_claa_sunmfee float64 = 0
  19636. var check_clab_amt float64 = 0
  19637. var check_other_amt float64 = 0
  19638. var material_claa_sunmfee float64 = 0
  19639. var material_clab_amt float64 = 0
  19640. var material_other_amt float64 = 0
  19641. var laboratory_claa_sunmfee float64 = 0
  19642. var laboratory_clab_amt float64 = 0
  19643. var laboratory_other_amt float64 = 0
  19644. var treat_claa_sunmfee float64 = 0
  19645. var treat_clab_amt float64 = 0
  19646. var treat_other_amt float64 = 0
  19647. for _, item := range order.HisOrderInfo {
  19648. if item.MedChrgitmType == "01" { //床位费
  19649. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19650. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19651. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19652. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19653. if item.ChrgitmLv == "1" {
  19654. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19655. }
  19656. if item.ChrgitmLv == "2" {
  19657. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19658. }
  19659. if item.ChrgitmLv == "3" {
  19660. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19661. }
  19662. }
  19663. if item.MedChrgitmType == "03" { //检查费
  19664. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19665. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19666. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19667. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19668. if item.ChrgitmLv == "1" {
  19669. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19670. }
  19671. if item.ChrgitmLv == "2" {
  19672. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19673. }
  19674. if item.ChrgitmLv == "3" {
  19675. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19676. }
  19677. }
  19678. if item.MedChrgitmType == "04" { //化验费
  19679. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19680. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19681. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19682. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19683. if item.ChrgitmLv == "1" {
  19684. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19685. }
  19686. if item.ChrgitmLv == "2" {
  19687. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19688. }
  19689. if item.ChrgitmLv == "3" {
  19690. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19691. }
  19692. }
  19693. if item.MedChrgitmType == "05" { //治疗费
  19694. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19695. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19696. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19697. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19698. if item.ChrgitmLv == "1" {
  19699. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19700. }
  19701. if item.ChrgitmLv == "2" {
  19702. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19703. }
  19704. if item.ChrgitmLv == "3" {
  19705. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19706. }
  19707. }
  19708. if item.MedChrgitmType == "06" { //手术费
  19709. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19710. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19711. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19712. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19713. if item.ChrgitmLv == "1" {
  19714. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19715. }
  19716. if item.ChrgitmLv == "2" {
  19717. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19718. }
  19719. if item.ChrgitmLv == "3" {
  19720. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19721. }
  19722. }
  19723. if item.MedChrgitmType == "08" { //材料费
  19724. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19725. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19726. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19727. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19728. if item.ChrgitmLv == "1" {
  19729. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19730. }
  19731. if item.ChrgitmLv == "2" {
  19732. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19733. }
  19734. if item.ChrgitmLv == "3" {
  19735. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19736. }
  19737. }
  19738. if item.MedChrgitmType == "09" { //西药费
  19739. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19740. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19741. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19742. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19743. if item.ChrgitmLv == "1" {
  19744. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19745. }
  19746. if item.ChrgitmLv == "2" {
  19747. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19748. }
  19749. if item.ChrgitmLv == "3" {
  19750. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19751. }
  19752. }
  19753. if item.MedChrgitmType == "11" { //中成费
  19754. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19755. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19756. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19757. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19758. if item.ChrgitmLv == "1" {
  19759. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19760. }
  19761. if item.ChrgitmLv == "2" {
  19762. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19763. }
  19764. if item.ChrgitmLv == "3" {
  19765. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19766. }
  19767. }
  19768. if item.MedChrgitmType == "14" { //其他费
  19769. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19770. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19771. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19772. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19773. if item.ChrgitmLv == "1" {
  19774. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19775. }
  19776. if item.ChrgitmLv == "2" {
  19777. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19778. }
  19779. if item.ChrgitmLv == "3" {
  19780. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19781. }
  19782. }
  19783. }
  19784. var iteminfoStructs []service.IteminfoStruct
  19785. if bedCostTotal != 0 {
  19786. iteminfo.MedChrgitm = "01"
  19787. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19788. iteminfo.Amt = bedCostTotal
  19789. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19790. iteminfo.ClabAmt = bed_clab_amt
  19791. iteminfo.OthAmt = bed_other_amt
  19792. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19793. }
  19794. if checkCostTotal != 0 {
  19795. iteminfo.MedChrgitm = "03"
  19796. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19797. iteminfo.Amt = checkCostTotal
  19798. iteminfo.ClaaSumfee = check_claa_sunmfee
  19799. iteminfo.ClabAmt = check_clab_amt
  19800. iteminfo.OthAmt = check_other_amt
  19801. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19802. }
  19803. if laboratoryCostTotal != 0 {
  19804. iteminfo.MedChrgitm = "04"
  19805. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19806. iteminfo.Amt = laboratoryCostTotal
  19807. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19808. iteminfo.ClabAmt = laboratory_clab_amt
  19809. iteminfo.OthAmt = laboratory_other_amt
  19810. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19811. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19812. }
  19813. if treatCostTotal != 0 {
  19814. iteminfo.MedChrgitm = "05"
  19815. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19816. iteminfo.Amt = treatCostTotal
  19817. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19818. iteminfo.ClabAmt = treat_clab_amt
  19819. iteminfo.OthAmt = treat_other_amt
  19820. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19821. //(struct4101.IteminfoStruct, iteminfo)
  19822. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19823. }
  19824. if operationCostTotal != 0 {
  19825. iteminfo.MedChrgitm = "06"
  19826. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19827. iteminfo.Amt = operationCostTotal
  19828. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19829. iteminfo.ClabAmt = operation_clab_amt
  19830. iteminfo.OthAmt = operation_other_amt
  19831. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19832. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19833. }
  19834. if materialCostTotal != 0 {
  19835. iteminfo.MedChrgitm = "08"
  19836. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19837. iteminfo.Amt = materialCostTotal
  19838. iteminfo.ClaaSumfee = material_claa_sunmfee
  19839. iteminfo.ClabAmt = material_clab_amt
  19840. iteminfo.OthAmt = material_other_amt
  19841. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19842. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19843. }
  19844. if westernMedicineCostTotal != 0 {
  19845. iteminfo.MedChrgitm = "09"
  19846. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19847. iteminfo.Amt = westernMedicineCostTotal
  19848. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19849. iteminfo.ClabAmt = westernMedicine_clab_amt
  19850. iteminfo.OthAmt = westernMedicine_other_amt
  19851. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19852. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19853. }
  19854. if chineseTraditionalMedicineCostTotal != 0 {
  19855. iteminfo.MedChrgitm = "11"
  19856. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19857. iteminfo.Amt = westernMedicineCostTotal
  19858. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19859. iteminfo.ClabAmt = westernMedicine_clab_amt
  19860. iteminfo.OthAmt = westernMedicine_other_amt
  19861. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19862. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19863. }
  19864. if otherCostTotal != 0 {
  19865. iteminfo.MedChrgitm = "14"
  19866. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19867. iteminfo.Amt = otherCostTotal
  19868. iteminfo.ClaaSumfee = other_claa_sunmfee
  19869. iteminfo.ClabAmt = other_clab_amt
  19870. iteminfo.OthAmt = other_other_amt
  19871. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19872. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19873. }
  19874. struct4101.IteminfoStruct = iteminfoStructs
  19875. struct4101.Ntly = "中国"
  19876. struct4101.AdmCaty = "A03.06"
  19877. struct4101.DoctorName = doctor.UserName
  19878. struct4101.DoctorCode = doctor.DoctorNumber
  19879. var res ResultSeventeen
  19880. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19881. struct4101.BillCode = order.Number
  19882. struct4101.BillNo = order.SetlId
  19883. var resOther ResultSeventeenOther
  19884. var pp models.PublicParams
  19885. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19886. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19887. pp.FixmedinsName = miConfig.OrgName
  19888. pp.FixmedinsCode = miConfig.Code
  19889. pp.RequestUrl = miConfig.Url
  19890. pp.Cainfo = miConfig.Cainfo
  19891. pp.SecretKey = miConfig.SecretKey
  19892. pp.AccessKey = miConfig.AccessKey
  19893. pp.OpterName = curRoles.UserName
  19894. client := &http.Client{}
  19895. var req *http.Request
  19896. data := make(map[string]interface{})
  19897. data["struct4101"] = struct4101
  19898. data["pp"] = pp
  19899. bytesData, _ := json.Marshal(data)
  19900. if miConfig.MdtrtareaAdmvs == "320921" {
  19901. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19902. } else {
  19903. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19904. }
  19905. resp, _ := client.Do(req)
  19906. defer resp.Body.Close()
  19907. body, ioErr := ioutil.ReadAll(resp.Body)
  19908. if ioErr != nil {
  19909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19911. return
  19912. }
  19913. var respJSON map[string]interface{}
  19914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19917. return
  19918. }
  19919. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19920. userJSONBytes, _ := json.Marshal(respJSON)
  19921. fmt.Println("log")
  19922. fmt.Println(string(userJSONBytes))
  19923. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19924. utils.ErrorLog("解析失败:%v", err)
  19925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19926. return
  19927. }
  19928. res.InfRefmsgid = resOther.InfRefmsgid
  19929. res.Output = resOther.Output
  19930. res.ErrMsg = resOther.ErrMsg
  19931. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19932. res.Infcode = infocode
  19933. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19934. var pp models.PublicParams
  19935. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19936. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19937. pp.FixmedinsName = miConfig.OrgName
  19938. pp.FixmedinsCode = miConfig.Code
  19939. pp.RequestUrl = miConfig.Url
  19940. pp.Cainfo = miConfig.Cainfo
  19941. pp.SecretKey = miConfig.SecretKey
  19942. pp.AccessKey = miConfig.AccessKey
  19943. pp.OpterName = curRoles.UserName
  19944. result, _ := service.Jxyb4101(struct4101, pp)
  19945. var dat map[string]interface{}
  19946. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19947. fmt.Println(dat)
  19948. } else {
  19949. fmt.Println(err)
  19950. }
  19951. userJSONBytes, _ := json.Marshal(dat)
  19952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19953. utils.ErrorLog("解析失败:%v", err)
  19954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19955. return
  19956. }
  19957. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19958. var pp models.PublicParams
  19959. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19960. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19961. pp.FixmedinsName = miConfig.OrgName
  19962. pp.FixmedinsCode = miConfig.Code
  19963. pp.RequestUrl = miConfig.Url
  19964. pp.Cainfo = miConfig.Cainfo
  19965. pp.SecretKey = miConfig.SecretKey
  19966. pp.AccessKey = miConfig.AccessKey
  19967. pp.OpterName = curRoles.UserName
  19968. result, _ := service.Jxyb4101(struct4101, pp)
  19969. var dat map[string]interface{}
  19970. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19971. fmt.Println(dat)
  19972. } else {
  19973. fmt.Println(err)
  19974. }
  19975. userJSONBytes, _ := json.Marshal(dat)
  19976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19977. utils.ErrorLog("解析失败:%v", err)
  19978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19979. return
  19980. }
  19981. } else if miConfig.MdtrtareaAdmvs == "360100" {
  19982. var pp models.PublicParams
  19983. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19984. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19985. pp.FixmedinsName = miConfig.OrgName
  19986. pp.FixmedinsCode = miConfig.Code
  19987. pp.RequestUrl = miConfig.Url
  19988. pp.Cainfo = miConfig.Cainfo
  19989. pp.SecretKey = miConfig.SecretKey
  19990. pp.AccessKey = miConfig.AccessKey
  19991. pp.OpterName = curRoles.UserName
  19992. result, _ := service.Jxyb4101(struct4101, pp)
  19993. var dat map[string]interface{}
  19994. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19995. fmt.Println(dat)
  19996. } else {
  19997. fmt.Println(err)
  19998. }
  19999. userJSONBytes, _ := json.Marshal(dat)
  20000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20001. utils.ErrorLog("解析失败:%v", err)
  20002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20003. return
  20004. }
  20005. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20006. var pp models.PublicParams
  20007. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20008. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20009. pp.FixmedinsName = miConfig.OrgName
  20010. pp.FixmedinsCode = miConfig.Code
  20011. pp.RequestUrl = miConfig.Url
  20012. pp.Cainfo = miConfig.Cainfo
  20013. pp.SecretKey = miConfig.SecretKey
  20014. pp.AccessKey = miConfig.AccessKey
  20015. pp.OpterName = curRoles.UserName
  20016. result, _ := service.Hnyb4101(struct4101, pp)
  20017. var dat map[string]interface{}
  20018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20019. fmt.Println(dat)
  20020. } else {
  20021. fmt.Println(err)
  20022. }
  20023. userJSONBytes, _ := json.Marshal(dat)
  20024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20025. utils.ErrorLog("解析失败:%v", err)
  20026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20027. return
  20028. }
  20029. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20030. var resOther ResultSeventeenOther
  20031. var pp models.PublicParams
  20032. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20033. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20034. pp.FixmedinsName = miConfig.OrgName
  20035. pp.FixmedinsCode = miConfig.Code
  20036. pp.RequestUrl = miConfig.Url
  20037. pp.Cainfo = miConfig.Cainfo
  20038. pp.SecretKey = miConfig.SecretKey
  20039. pp.AccessKey = miConfig.AccessKey
  20040. pp.OpterName = curRoles.UserName
  20041. client := &http.Client{}
  20042. var req *http.Request
  20043. data := make(map[string]interface{})
  20044. data["struct4101"] = struct4101
  20045. data["pp"] = pp
  20046. bytesData, _ := json.Marshal(data)
  20047. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20048. resp, _ := client.Do(req)
  20049. defer resp.Body.Close()
  20050. body, ioErr := ioutil.ReadAll(resp.Body)
  20051. if ioErr != nil {
  20052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20054. return
  20055. }
  20056. var respJSON map[string]interface{}
  20057. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20060. return
  20061. }
  20062. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20063. userJSONBytes, _ := json.Marshal(respJSON)
  20064. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20065. utils.ErrorLog("解析失败:%v", err)
  20066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20067. return
  20068. }
  20069. res.InfRefmsgid = resOther.InfRefmsgid
  20070. res.Output = resOther.Output
  20071. res.ErrMsg = resOther.ErrMsg
  20072. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20073. res.Infcode = infocode
  20074. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20075. var pp models.PublicParams
  20076. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20077. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20078. pp.FixmedinsName = miConfig.OrgName
  20079. pp.FixmedinsCode = miConfig.Code
  20080. pp.RequestUrl = miConfig.Url
  20081. pp.Cainfo = miConfig.Cainfo
  20082. pp.SecretKey = miConfig.SecretKey
  20083. pp.AccessKey = miConfig.AccessKey
  20084. pp.OpterName = curRoles.UserName
  20085. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20086. fmt.Println(requestLog)
  20087. fmt.Println(errMsgLog)
  20088. saveLog(result, requestLog, "4101a", "上传清单")
  20089. var dat map[string]interface{}
  20090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20091. fmt.Println(dat)
  20092. } else {
  20093. fmt.Println(err)
  20094. }
  20095. userJSONBytes, _ := json.Marshal(dat)
  20096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20097. utils.ErrorLog("解析失败:%v", err)
  20098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20099. return
  20100. }
  20101. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20102. var pp models.PublicParams
  20103. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20104. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20105. pp.FixmedinsName = miConfig.OrgName
  20106. pp.FixmedinsCode = miConfig.Code
  20107. pp.RequestUrl = miConfig.Url
  20108. pp.Cainfo = miConfig.Cainfo
  20109. pp.SecretKey = miConfig.SecretKey
  20110. pp.AccessKey = miConfig.AccessKey
  20111. pp.OpterName = curRoles.UserName
  20112. client := &http.Client{}
  20113. var req *http.Request
  20114. data := make(map[string]interface{})
  20115. data["struct4101"] = struct4101
  20116. data["pp"] = pp
  20117. bytesData, _ := json.Marshal(data)
  20118. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20119. resp, _ := client.Do(req)
  20120. defer resp.Body.Close()
  20121. body, ioErr := ioutil.ReadAll(resp.Body)
  20122. if ioErr != nil {
  20123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20125. return
  20126. }
  20127. var respJSON map[string]interface{}
  20128. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20131. return
  20132. }
  20133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20134. userJSONBytes, _ := json.Marshal(respJSON)
  20135. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20136. utils.ErrorLog("解析失败:%v", err)
  20137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20138. return
  20139. }
  20140. } else {
  20141. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20142. var dat map[string]interface{}
  20143. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20144. fmt.Println(dat)
  20145. } else {
  20146. fmt.Println(err)
  20147. }
  20148. userJSONBytes, _ := json.Marshal(dat)
  20149. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20150. utils.ErrorLog("解析失败:%v", err)
  20151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20152. return
  20153. }
  20154. }
  20155. if res.Infcode != 0 {
  20156. c.ServeSuccessJSON(map[string]interface{}{
  20157. "failed_code": -10,
  20158. "msg": res.ErrMsg,
  20159. })
  20160. return
  20161. } else {
  20162. //order.FaPiaoNumber = zero
  20163. //order.FaPiaoCode = last_order.FaPiaoCode
  20164. //service.UpdateOrder(order)
  20165. hisFundSettleListResult := &models.HisFundSettleListResult{
  20166. Number: res.Output.SetlListId,
  20167. Status: 1,
  20168. Ctime: time.Now().Unix(),
  20169. Mtime: time.Now().Unix(),
  20170. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20171. IsUpload: 1,
  20172. OrderId: order_id,
  20173. }
  20174. service.CreateUploadRecord(hisFundSettleListResult)
  20175. c.ServeSuccessJSON(map[string]interface{}{
  20176. "msg": "上传成功",
  20177. "result": hisFundSettleListResult,
  20178. })
  20179. return
  20180. }
  20181. }
  20182. func (c *HisApiController) GetSettleListHospital() {
  20183. order_id, _ := c.GetInt64("order_id")
  20184. admin_user_id, _ := c.GetInt64("admin_user_id")
  20185. order, _ := service.GetHisOrderByIDTwo(order_id)
  20186. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20187. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  20188. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20189. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20190. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20191. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20192. if order.ID == 0 {
  20193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20194. return
  20195. }
  20196. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20197. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20198. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20199. fmt.Println(count)
  20200. var zero string
  20201. number := count + 1
  20202. if number >= 1000 {
  20203. zero = "0000" + strconv.FormatInt(number, 10)
  20204. } else if number >= 10000 {
  20205. zero = "000" + strconv.FormatInt(number, 10)
  20206. } else if number >= 100000 {
  20207. zero = "00" + strconv.FormatInt(number, 10)
  20208. } else if number >= 1000000 {
  20209. zero = "0" + strconv.FormatInt(number, 10)
  20210. } else {
  20211. zero = strconv.FormatInt(number, 10)
  20212. }
  20213. fmt.Println(zero)
  20214. struct4101 := service.Struct4101{
  20215. PsnNo: order.PsnNo,
  20216. MdtrtId: order.MdtrtId,
  20217. SetlId: order.SetlId,
  20218. PsnName: order.PsnName,
  20219. Gend: order.Gend,
  20220. Brdy: his.Brdy,
  20221. Age: int64(order.Age),
  20222. Naty: order.Naty,
  20223. PatnCertType: "01",
  20224. Certno: order.Certno,
  20225. Prfs: "90",
  20226. ConerName: roles[0].UserName,
  20227. PatnRlts: "99",
  20228. ConerAddr: miConfig.OrgName,
  20229. ConerTel: admin.Mobile,
  20230. HiType: order.Insutype,
  20231. Insuplc: miConfig.InsuplcAdmdvs,
  20232. MaindiagFlag: "1",
  20233. BillCode: order.SetlId,
  20234. BillNo: order.SetlId,
  20235. BizSn: order.Number,
  20236. PsnSelfPay: order.PsnPartAmt,
  20237. PsnOwnPay: order.PsnPartAmt,
  20238. AcctPay: order.AcctPay,
  20239. PsnCashpay: order.PsnCashPay,
  20240. HiPaymtd: "1",
  20241. Hsorg: miConfig.InsuplcAdmdvs,
  20242. HsorgOpter: miConfig.InsuplcAdmdvs,
  20243. MedinsFillPsn: curRoles.UserName,
  20244. MedinsFillDept: depart.Name,
  20245. IptMedType: "2",
  20246. AdmTime: his.InHosptialTime,
  20247. AdmEndTime: his.OutHosptialTime,
  20248. }
  20249. struct4101.SetlBegnDate = order.SetlTime
  20250. struct4101.SetlEndDate = order.SetlTime
  20251. //var rf []CustomFundPay
  20252. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20253. //
  20254. //var tempFunPays []service.CustomStruct
  20255. //for _, item := range rf {
  20256. // var tempFunPay service.CustomStruct
  20257. // tempFunPay.FundPayamt = item.FundPayamt
  20258. // tempFunPay.FundPayType = item.FundPayType
  20259. // tempFunPays = append(tempFunPays, tempFunPay)
  20260. //}
  20261. //struct4101.CustomStruct = tempFunPays
  20262. var tempDiaginfos []service.DiaginfoStructTwo
  20263. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20264. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20265. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  20266. //for _, item := range infos {
  20267. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  20268. //}
  20269. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  20270. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  20271. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20272. fmt.Println(diagnosis_ids_arr)
  20273. if order.UserOrgId == 10210 {
  20274. var diagnosis_ids_arr_two []int64
  20275. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  20276. var config []*models.HisXtDiagnoseConfig
  20277. for _, id := range diagnosis_ids_arr_two {
  20278. //id, _ := strconv.ParseInt(item, 10, 64)
  20279. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20280. if diagnosisConfig.ID > 0 {
  20281. config = append(config, &diagnosisConfig)
  20282. }
  20283. }
  20284. for index, item := range config {
  20285. if item.ID > 0 {
  20286. if index == 0 {
  20287. var tempDiaginfo service.DiaginfoStructTwo
  20288. tempDiaginfo.DiagCode = item.CountryCode
  20289. tempDiaginfo.DiagName = item.CountryContentName
  20290. tempDiaginfo.DiagType = "1"
  20291. tempDiaginfo.MaindiagFlag = "1"
  20292. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20293. } else {
  20294. var tempDiaginfo service.DiaginfoStructTwo
  20295. tempDiaginfo.DiagCode = item.CountryCode
  20296. tempDiaginfo.DiagName = item.CountryContentName
  20297. tempDiaginfo.DiagType = "1"
  20298. tempDiaginfo.MaindiagFlag = "0"
  20299. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20300. }
  20301. }
  20302. }
  20303. struct4101.Diseinfo = tempDiaginfos
  20304. } else {
  20305. var config []*models.HisXtDiagnoseConfig
  20306. for _, item := range diagnosis_ids_arr {
  20307. id, _ := strconv.ParseInt(item, 10, 64)
  20308. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20309. if diagnosisConfig.ID > 0 {
  20310. config = append(config, &diagnosisConfig)
  20311. }
  20312. }
  20313. for index, item := range config {
  20314. if item.ID > 0 {
  20315. if index == 0 {
  20316. var tempDiaginfo service.DiaginfoStructTwo
  20317. tempDiaginfo.DiagCode = item.CountryCode
  20318. tempDiaginfo.DiagName = item.CountryContentName
  20319. tempDiaginfo.DiagType = "1"
  20320. tempDiaginfo.MaindiagFlag = "1"
  20321. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20322. } else {
  20323. var tempDiaginfo service.DiaginfoStructTwo
  20324. tempDiaginfo.DiagCode = item.CountryCode
  20325. tempDiaginfo.DiagName = item.CountryContentName
  20326. tempDiaginfo.DiagType = "1"
  20327. tempDiaginfo.MaindiagFlag = "0"
  20328. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20329. }
  20330. }
  20331. }
  20332. struct4101.Diseinfo = tempDiaginfos
  20333. }
  20334. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20335. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20336. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20337. tempOpspdiseinfo2.OprnOprtCode = ""
  20338. tempOpspdiseinfo2.OprnOprtName = ""
  20339. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20340. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20341. var iteminfo service.IteminfoStruct
  20342. var bedCostTotal float64 = 0 //床位总费
  20343. var bedCostSelfTotal float64 = 0 //床位自费
  20344. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20345. var operationCostTotal float64 = 0 //手术费
  20346. var operationCostSelfTotal float64 = 0 //手术费
  20347. var operationCostPartSelfTotal float64 = 0 //手术费
  20348. var otherCostTotal float64 = 0 //其他费用
  20349. var otherCostSelfTotal float64 = 0 //其他费用
  20350. var otherCostPartSelfTotal float64 = 0 //其他费用
  20351. var materialCostTotal float64 = 0 //材料费
  20352. var materialCostSelfTotal float64 = 0 //材料费
  20353. var materialCostPartSelfTotal float64 = 0 //材料费
  20354. var westernMedicineCostTotal float64 = 0 //西药费
  20355. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20356. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20357. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20358. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20359. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20360. var checkCostTotal float64 = 0 //检查费
  20361. var checkCostSelfTotal float64 = 0 //检查费
  20362. var checkCostPartSelfTotal float64 = 0 //检查费
  20363. var laboratoryCostTotal float64 = 0 //化验费
  20364. var laboratoryCostSelfTotal float64 = 0 //化验费
  20365. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20366. var treatCostTotal float64 = 0 //治疗费用
  20367. var treatCostSelfTotal float64 = 0 //治疗费用
  20368. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20369. decimal.DivisionPrecision = 2
  20370. var bed_fulamt_ownpay_amt float64 = 0
  20371. var operation_fulamt_ownpay_amt float64 = 0
  20372. var other_fulamt_ownpay_amt float64 = 0
  20373. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20374. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20375. var check_fulamt_ownpay_amt float64 = 0
  20376. var material_fulamt_ownpay_amt float64 = 0
  20377. var laboratory_fulamt_ownpay_amt float64 = 0
  20378. var treat_fulamt_ownpay_amt float64 = 0
  20379. var bed_claa_sunmfee float64 = 0
  20380. var bed_clab_amt float64 = 0
  20381. var bed_other_amt float64 = 0
  20382. var operation_claa_sunmfee float64 = 0
  20383. var operation_clab_amt float64 = 0
  20384. var operation_other_amt float64 = 0
  20385. var other_claa_sunmfee float64 = 0
  20386. var other_clab_amt float64 = 0
  20387. var other_other_amt float64 = 0
  20388. var westernMedicine_claa_sunmfee float64 = 0
  20389. var westernMedicine_clab_amt float64 = 0
  20390. var westernMedicine_other_amt float64 = 0
  20391. var chineseTraditional_claa_sunmfee float64 = 0
  20392. var chineseTraditional_clab_amt float64 = 0
  20393. var chineseTraditional_other_amt float64 = 0
  20394. var check_claa_sunmfee float64 = 0
  20395. var check_clab_amt float64 = 0
  20396. var check_other_amt float64 = 0
  20397. var material_claa_sunmfee float64 = 0
  20398. var material_clab_amt float64 = 0
  20399. var material_other_amt float64 = 0
  20400. var laboratory_claa_sunmfee float64 = 0
  20401. var laboratory_clab_amt float64 = 0
  20402. var laboratory_other_amt float64 = 0
  20403. var treat_claa_sunmfee float64 = 0
  20404. var treat_clab_amt float64 = 0
  20405. var treat_other_amt float64 = 0
  20406. for _, item := range order.HisOrderInfo {
  20407. if item.MedChrgitmType == "01" { //床位费
  20408. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20409. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20410. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20411. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20412. if item.ChrgitmLv == "1" {
  20413. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20414. }
  20415. if item.ChrgitmLv == "2" {
  20416. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20417. }
  20418. if item.ChrgitmLv == "3" {
  20419. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20420. }
  20421. }
  20422. if item.MedChrgitmType == "03" { //检查费
  20423. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20424. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20425. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20426. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20427. if item.ChrgitmLv == "1" {
  20428. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20429. }
  20430. if item.ChrgitmLv == "2" {
  20431. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20432. }
  20433. if item.ChrgitmLv == "3" {
  20434. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20435. }
  20436. }
  20437. if item.MedChrgitmType == "04" { //化验费
  20438. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20439. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20440. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20441. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20442. if item.ChrgitmLv == "1" {
  20443. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20444. }
  20445. if item.ChrgitmLv == "2" {
  20446. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20447. }
  20448. if item.ChrgitmLv == "3" {
  20449. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20450. }
  20451. }
  20452. if item.MedChrgitmType == "05" { //治疗费
  20453. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20454. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20455. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20456. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20457. if item.ChrgitmLv == "1" {
  20458. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20459. }
  20460. if item.ChrgitmLv == "2" {
  20461. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20462. }
  20463. if item.ChrgitmLv == "3" {
  20464. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20465. }
  20466. }
  20467. if item.MedChrgitmType == "06" { //手术费
  20468. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20469. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20470. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20471. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20472. if item.ChrgitmLv == "1" {
  20473. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20474. }
  20475. if item.ChrgitmLv == "2" {
  20476. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20477. }
  20478. if item.ChrgitmLv == "3" {
  20479. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20480. }
  20481. }
  20482. if item.MedChrgitmType == "08" { //材料费
  20483. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20484. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20485. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20486. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20487. if item.ChrgitmLv == "1" {
  20488. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20489. }
  20490. if item.ChrgitmLv == "2" {
  20491. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20492. }
  20493. if item.ChrgitmLv == "3" {
  20494. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20495. }
  20496. }
  20497. if item.MedChrgitmType == "09" { //西药费
  20498. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20499. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20500. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20501. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20502. if item.ChrgitmLv == "1" {
  20503. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20504. }
  20505. if item.ChrgitmLv == "2" {
  20506. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20507. }
  20508. if item.ChrgitmLv == "3" {
  20509. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20510. }
  20511. }
  20512. if item.MedChrgitmType == "11" { //中成费
  20513. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20514. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20515. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20516. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20517. if item.ChrgitmLv == "1" {
  20518. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20519. }
  20520. if item.ChrgitmLv == "2" {
  20521. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20522. }
  20523. if item.ChrgitmLv == "3" {
  20524. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20525. }
  20526. }
  20527. if item.MedChrgitmType == "14" { //其他费
  20528. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20529. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20530. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20531. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20532. if item.ChrgitmLv == "1" {
  20533. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20534. }
  20535. if item.ChrgitmLv == "2" {
  20536. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20537. }
  20538. if item.ChrgitmLv == "3" {
  20539. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20540. }
  20541. }
  20542. }
  20543. var iteminfoStructs []service.IteminfoStruct
  20544. if bedCostTotal != 0 {
  20545. iteminfo.MedChrgitm = "01"
  20546. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20547. iteminfo.Amt = bedCostTotal
  20548. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20549. iteminfo.ClabAmt = bed_clab_amt
  20550. iteminfo.OthAmt = bed_other_amt
  20551. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20552. }
  20553. if checkCostTotal != 0 {
  20554. iteminfo.MedChrgitm = "03"
  20555. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20556. iteminfo.Amt = checkCostTotal
  20557. iteminfo.ClaaSumfee = check_claa_sunmfee
  20558. iteminfo.ClabAmt = check_clab_amt
  20559. iteminfo.OthAmt = check_other_amt
  20560. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20561. }
  20562. if laboratoryCostTotal != 0 {
  20563. iteminfo.MedChrgitm = "04"
  20564. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20565. iteminfo.Amt = laboratoryCostTotal
  20566. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20567. iteminfo.ClabAmt = laboratory_clab_amt
  20568. iteminfo.OthAmt = laboratory_other_amt
  20569. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20570. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20571. }
  20572. if treatCostTotal != 0 {
  20573. iteminfo.MedChrgitm = "05"
  20574. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20575. iteminfo.Amt = treatCostTotal
  20576. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20577. iteminfo.ClabAmt = treat_clab_amt
  20578. iteminfo.OthAmt = treat_other_amt
  20579. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20580. //(struct4101.IteminfoStruct, iteminfo)
  20581. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20582. }
  20583. if operationCostTotal != 0 {
  20584. iteminfo.MedChrgitm = "06"
  20585. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20586. iteminfo.Amt = operationCostTotal
  20587. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20588. iteminfo.ClabAmt = operation_clab_amt
  20589. iteminfo.OthAmt = operation_other_amt
  20590. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20591. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20592. }
  20593. if materialCostTotal != 0 {
  20594. iteminfo.MedChrgitm = "08"
  20595. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20596. iteminfo.Amt = materialCostTotal
  20597. iteminfo.ClaaSumfee = material_claa_sunmfee
  20598. iteminfo.ClabAmt = material_clab_amt
  20599. iteminfo.OthAmt = material_other_amt
  20600. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20601. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20602. }
  20603. if westernMedicineCostTotal != 0 {
  20604. iteminfo.MedChrgitm = "09"
  20605. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20606. iteminfo.Amt = westernMedicineCostTotal
  20607. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20608. iteminfo.ClabAmt = westernMedicine_clab_amt
  20609. iteminfo.OthAmt = westernMedicine_other_amt
  20610. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20611. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20612. }
  20613. if chineseTraditionalMedicineCostTotal != 0 {
  20614. iteminfo.MedChrgitm = "11"
  20615. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20616. iteminfo.Amt = westernMedicineCostTotal
  20617. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20618. iteminfo.ClabAmt = westernMedicine_clab_amt
  20619. iteminfo.OthAmt = westernMedicine_other_amt
  20620. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20621. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20622. }
  20623. if otherCostTotal != 0 {
  20624. iteminfo.MedChrgitm = "14"
  20625. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20626. iteminfo.Amt = otherCostTotal
  20627. iteminfo.ClaaSumfee = other_claa_sunmfee
  20628. iteminfo.ClabAmt = other_clab_amt
  20629. iteminfo.OthAmt = other_other_amt
  20630. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20631. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20632. }
  20633. struct4101.IteminfoStruct = iteminfoStructs
  20634. struct4101.Ntly = "中国"
  20635. struct4101.AdmCaty = "A03.06"
  20636. var resOther ResultSeventeenOther
  20637. var res ResultSeventeen
  20638. if miConfig.MdtrtareaAdmvs == "150499" {
  20639. var pp models.PublicParams
  20640. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20641. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20642. pp.FixmedinsName = miConfig.OrgName
  20643. pp.FixmedinsCode = miConfig.Code
  20644. pp.RequestUrl = miConfig.Url
  20645. pp.Cainfo = miConfig.Cainfo
  20646. pp.SecretKey = miConfig.SecretKey
  20647. pp.AccessKey = miConfig.AccessKey
  20648. pp.OpterName = curRoles.UserName
  20649. client := &http.Client{}
  20650. var req *http.Request
  20651. data := make(map[string]interface{})
  20652. data["struct4101"] = struct4101
  20653. data["pp"] = pp
  20654. bytesData, _ := json.Marshal(data)
  20655. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20656. resp, _ := client.Do(req)
  20657. defer resp.Body.Close()
  20658. body, ioErr := ioutil.ReadAll(resp.Body)
  20659. if ioErr != nil {
  20660. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20662. return
  20663. }
  20664. var respJSON map[string]interface{}
  20665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20668. return
  20669. }
  20670. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20671. userJSONBytes, _ := json.Marshal(respJSON)
  20672. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20673. utils.ErrorLog("解析失败:%v", err)
  20674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20675. return
  20676. }
  20677. res.InfRefmsgid = resOther.InfRefmsgid
  20678. res.Output = resOther.Output
  20679. res.ErrMsg = resOther.ErrMsg
  20680. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20681. res.Infcode = infocode
  20682. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20683. var pp models.PublicParams
  20684. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20685. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20686. pp.FixmedinsName = miConfig.OrgName
  20687. pp.FixmedinsCode = miConfig.Code
  20688. pp.RequestUrl = miConfig.Url
  20689. pp.Cainfo = miConfig.Cainfo
  20690. pp.SecretKey = miConfig.SecretKey
  20691. pp.AccessKey = miConfig.AccessKey
  20692. pp.OpterName = curRoles.UserName
  20693. result, _ := service.Jxyb4101(struct4101, pp)
  20694. var dat map[string]interface{}
  20695. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20696. fmt.Println(dat)
  20697. } else {
  20698. fmt.Println(err)
  20699. }
  20700. userJSONBytes, _ := json.Marshal(dat)
  20701. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20702. utils.ErrorLog("解析失败:%v", err)
  20703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20704. return
  20705. }
  20706. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20707. var pp models.PublicParams
  20708. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20709. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20710. pp.FixmedinsName = miConfig.OrgName
  20711. pp.FixmedinsCode = miConfig.Code
  20712. pp.RequestUrl = miConfig.Url
  20713. pp.Cainfo = miConfig.Cainfo
  20714. pp.SecretKey = miConfig.SecretKey
  20715. pp.AccessKey = miConfig.AccessKey
  20716. pp.OpterName = curRoles.UserName
  20717. result, _ := service.Jxyb4101(struct4101, pp)
  20718. var dat map[string]interface{}
  20719. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20720. fmt.Println(dat)
  20721. } else {
  20722. fmt.Println(err)
  20723. }
  20724. userJSONBytes, _ := json.Marshal(dat)
  20725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20726. utils.ErrorLog("解析失败:%v", err)
  20727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20728. return
  20729. }
  20730. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20731. var pp models.PublicParams
  20732. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20733. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20734. pp.FixmedinsName = miConfig.OrgName
  20735. pp.FixmedinsCode = miConfig.Code
  20736. pp.RequestUrl = miConfig.Url
  20737. pp.Cainfo = miConfig.Cainfo
  20738. pp.SecretKey = miConfig.SecretKey
  20739. pp.AccessKey = miConfig.AccessKey
  20740. pp.OpterName = curRoles.UserName
  20741. result, _ := service.Jxyb4101(struct4101, pp)
  20742. var dat map[string]interface{}
  20743. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20744. fmt.Println(dat)
  20745. } else {
  20746. fmt.Println(err)
  20747. }
  20748. userJSONBytes, _ := json.Marshal(dat)
  20749. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20750. utils.ErrorLog("解析失败:%v", err)
  20751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20752. return
  20753. }
  20754. } else {
  20755. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20756. var dat map[string]interface{}
  20757. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20758. fmt.Println(dat)
  20759. } else {
  20760. fmt.Println(err)
  20761. }
  20762. userJSONBytes, _ := json.Marshal(dat)
  20763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20764. utils.ErrorLog("解析失败:%v", err)
  20765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20766. return
  20767. }
  20768. }
  20769. if res.Infcode != 0 {
  20770. c.ServeSuccessJSON(map[string]interface{}{
  20771. "failed_code": -10,
  20772. "msg": res.ErrMsg,
  20773. })
  20774. return
  20775. } else {
  20776. if miConfig.MdtrtareaAdmvs != "150499" {
  20777. order.FaPiaoNumber = zero
  20778. order.FaPiaoCode = last_order.FaPiaoCode
  20779. service.UpdateOrder(order)
  20780. }
  20781. hisFundSettleListResult := &models.HisFundSettleListResult{
  20782. Number: res.Output.SetlListId,
  20783. Status: 1,
  20784. Ctime: time.Now().Unix(),
  20785. Mtime: time.Now().Unix(),
  20786. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20787. IsUpload: 1,
  20788. OrderId: order_id,
  20789. }
  20790. service.CreateUploadRecord(hisFundSettleListResult)
  20791. c.ServeSuccessJSON(map[string]interface{}{
  20792. "msg": "上传成功",
  20793. "result": hisFundSettleListResult,
  20794. })
  20795. return
  20796. }
  20797. }
  20798. //func (c *HisApiController) GetBatchSettleList() {
  20799. // orders, _ := service.GetAllHisOrder(10106)
  20800. // for _, item := range orders {
  20801. // order_id := item.ID
  20802. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20803. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20804. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20805. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20806. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20807. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20808. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20809. //
  20810. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20811. //
  20812. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20813. //
  20814. // if order.ID == 0 {
  20815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20816. // return
  20817. // }
  20818. // if his.BalanceAccountsType == 2 {
  20819. // continue
  20820. // }
  20821. // struct4101 := service.Struct4101{
  20822. // PsnNo: order.PsnNo,
  20823. // MdtrtId: order.MdtrtId,
  20824. // SetlId: order.SetlId,
  20825. // PsnName: order.PsnName,
  20826. // Gend: order.Gend,
  20827. // Brdy: his.Brdy,
  20828. // Age: his.Age,
  20829. // Naty: order.Naty,
  20830. // PatnCertType: "01",
  20831. // Certno: order.Certno,
  20832. // Prfs: "90",
  20833. // ConerName: roles[0].UserName,
  20834. // PatnRlts: "99",
  20835. // ConerAddr: miConfig.OrgName,
  20836. // ConerTel: admin.Mobile,
  20837. // HiType: order.Insutype,
  20838. // Insuplc: his.InsuplcAdmdvs,
  20839. // MaindiagFlag: "1",
  20840. // BillCode: order.SetlId,
  20841. // BillNo: order.SetlId,
  20842. // BizSn: order.Number,
  20843. // PsnSelfPay: order.PsnPartAmt,
  20844. // PsnOwnPay: order.PsnPartAmt,
  20845. // AcctPay: order.AcctPay,
  20846. // PsnCashpay: order.PsnCashPay,
  20847. // HiPaymtd: "1",
  20848. // Hsorg: his.InsuplcAdmdvs,
  20849. // HsorgOpter: his.InsuplcAdmdvs,
  20850. // MedinsFillPsn: curRoles.UserName,
  20851. // MedinsFillDept: depart.Name,
  20852. // IptMedType: "2",
  20853. // }
  20854. // struct4101.SetlBegnDate = order.SetlTime
  20855. // struct4101.SetlEndDate = order.SetlTime
  20856. // //if order.SettleType == 1 {
  20857. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20858. // // dateStr := t.Format("2006-01-02")
  20859. // // struct4101.SetlBegnDate = dateStr
  20860. // // struct4101.SetlEndDate = dateStr
  20861. // //} else {
  20862. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20863. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20864. // // dateStartStr := t.Format("2006-01-02")
  20865. // // dateEndStr := t2.Format("2006-01-02")
  20866. // // struct4101.SetlBegnDate = dateStartStr
  20867. // // struct4101.SetlEndDate = dateEndStr
  20868. // //}
  20869. //
  20870. // var rf []CustomFundPay
  20871. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20872. //
  20873. // var tempFunPays []service.CustomStruct
  20874. // var tempFunPay610100 service.CustomStruct
  20875. //
  20876. // for _, item := range rf {
  20877. // if item.FundPayType == "610100" {
  20878. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20879. // tempFunPay610100.FundPayType = item.FundPayType
  20880. // } else {
  20881. // var tempFunPay service.CustomStruct
  20882. // tempFunPay.FundPayamt = item.FundPayamt
  20883. // tempFunPay.FundPayType = item.FundPayType
  20884. // tempFunPays = append(tempFunPays, tempFunPay)
  20885. // }
  20886. // }
  20887. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20888. // struct4101.CustomStruct = tempFunPays
  20889. //
  20890. // var tempDiaginfos []service.DiaginfoStructTwo
  20891. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20892. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20893. //
  20894. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20895. // var config []*models.HisXtDiagnoseConfig
  20896. // for _, item := range diagnosis_ids {
  20897. // id, _ := strconv.ParseInt(item, 10, 64)
  20898. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20899. // config = append(config, &diagnosisConfig)
  20900. // }
  20901. //
  20902. // for index, item := range config {
  20903. // if index == 0 {
  20904. // var tempDiaginfo service.DiaginfoStructTwo
  20905. // tempDiaginfo.DiagCode = item.CountryCode
  20906. // tempDiaginfo.DiagName = item.CountryContentName
  20907. // tempDiaginfo.DiagType = "1"
  20908. // tempDiaginfo.MaindiagFlag = "1"
  20909. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20910. // } else {
  20911. //
  20912. // var tempDiaginfo service.DiaginfoStructTwo
  20913. // tempDiaginfo.DiagCode = item.CountryCode
  20914. // tempDiaginfo.DiagName = item.CountryContentName
  20915. // tempDiaginfo.DiagType = "2"
  20916. // tempDiaginfo.MaindiagFlag = "0"
  20917. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20918. // }
  20919. // }
  20920. // struct4101.Diseinfo = tempDiaginfos
  20921. //
  20922. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20923. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20924. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20925. // tempOpspdiseinfo2.OprnOprtCode = ""
  20926. // tempOpspdiseinfo2.OprnOprtName = ""
  20927. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20928. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20929. //
  20930. // var iteminfo service.IteminfoStruct
  20931. //
  20932. // var bedCostTotal float64 = 0 //床位总费
  20933. // var bedCostSelfTotal float64 = 0 //床位自费
  20934. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20935. //
  20936. // var examineCostTotal float64 = 0 //诊查总费
  20937. // var examineCostSelfTotal float64 = 0 //诊查自费
  20938. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20939. //
  20940. // var nursingCostTotal float64 = 0 //护理总费
  20941. // var nursingCostSelfTotal float64 = 0 //护理自费
  20942. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20943. //
  20944. // var chineseMedicineCostTotal float64 = 0 //中成药
  20945. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20946. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20947. //
  20948. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20949. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20950. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20951. //
  20952. // var registerCostTotal float64 = 0 //一般诊疗费
  20953. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20954. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20955. //
  20956. // var operationCostTotal float64 = 0 //手术费
  20957. // var operationCostSelfTotal float64 = 0 //手术费
  20958. // var operationCostPartSelfTotal float64 = 0 //手术费
  20959. //
  20960. // var otherCostTotal float64 = 0 //其他费用
  20961. // var otherCostSelfTotal float64 = 0 //其他费用
  20962. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20963. //
  20964. // var materialCostTotal float64 = 0 //材料费
  20965. // var materialCostSelfTotal float64 = 0 //材料费
  20966. // var materialCostPartSelfTotal float64 = 0 //材料费
  20967. //
  20968. // var westernMedicineCostTotal float64 = 0 //西药费
  20969. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20970. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20971. //
  20972. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20973. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20974. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20975. //
  20976. // var checkCostTotal float64 = 0 //检查费
  20977. // var checkCostSelfTotal float64 = 0 //检查费
  20978. // var checkCostPartSelfTotal float64 = 0 //检查费
  20979. //
  20980. // var laboratoryCostTotal float64 = 0 //化验费
  20981. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20982. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20983. //
  20984. // var treatCostTotal float64 = 0 //治疗费用
  20985. // var treatCostSelfTotal float64 = 0 //治疗费用
  20986. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20987. //
  20988. // decimal.DivisionPrecision = 2
  20989. //
  20990. // var bed_fulamt_ownpay_amt float64 = 0
  20991. //
  20992. // var examine_fulamt_ownpay_amt float64 = 0
  20993. //
  20994. // var nursing_fulamt_ownpay_amt float64 = 0
  20995. //
  20996. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20997. //
  20998. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20999. //
  21000. // var register_fulamt_ownpay_amt float64 = 0
  21001. //
  21002. // var operation_fulamt_ownpay_amt float64 = 0
  21003. // var other_fulamt_ownpay_amt float64 = 0
  21004. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21005. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21006. // var check_fulamt_ownpay_amt float64 = 0
  21007. // var material_fulamt_ownpay_amt float64 = 0
  21008. // var laboratory_fulamt_ownpay_amt float64 = 0
  21009. // var treat_fulamt_ownpay_amt float64 = 0
  21010. //
  21011. // var bed_claa_sunmfee float64 = 0
  21012. // var bed_clab_amt float64 = 0
  21013. // var bed_other_amt float64 = 0
  21014. //
  21015. // var examine_claa_sunmfee float64 = 0
  21016. // var examine_clab_amt float64 = 0
  21017. // var examine_other_amt float64 = 0
  21018. //
  21019. // var nursing_claa_sunmfee float64 = 0
  21020. // var nursing_clab_amt float64 = 0
  21021. // var nursing_other_amt float64 = 0
  21022. //
  21023. // var chinese_medicine_claa_sunmfee float64 = 0
  21024. // var chinese_medicine_clab_amt float64 = 0
  21025. // var chinese_medicine_other_amt float64 = 0
  21026. //
  21027. // var commonly_treatment_claa_sunmfee float64 = 0
  21028. // var commonly_treatment_clab_amt float64 = 0
  21029. // var commonly_treatment_other_amt float64 = 0
  21030. //
  21031. // var operation_claa_sunmfee float64 = 0
  21032. // var operation_clab_amt float64 = 0
  21033. // var operation_other_amt float64 = 0
  21034. //
  21035. // var other_claa_sunmfee float64 = 0
  21036. // var other_clab_amt float64 = 0
  21037. // var other_other_amt float64 = 0
  21038. //
  21039. // var westernMedicine_claa_sunmfee float64 = 0
  21040. // var westernMedicine_clab_amt float64 = 0
  21041. // var westernMedicine_other_amt float64 = 0
  21042. //
  21043. // var chineseTraditional_claa_sunmfee float64 = 0
  21044. // var chineseTraditional_clab_amt float64 = 0
  21045. // var chineseTraditional_other_amt float64 = 0
  21046. //
  21047. // var check_claa_sunmfee float64 = 0
  21048. // var check_clab_amt float64 = 0
  21049. // var check_other_amt float64 = 0
  21050. //
  21051. // var material_claa_sunmfee float64 = 0
  21052. // var material_clab_amt float64 = 0
  21053. // var material_other_amt float64 = 0
  21054. //
  21055. // var laboratory_claa_sunmfee float64 = 0
  21056. // var laboratory_clab_amt float64 = 0
  21057. // var laboratory_other_amt float64 = 0
  21058. //
  21059. // var treat_claa_sunmfee float64 = 0
  21060. // var treat_clab_amt float64 = 0
  21061. // var treat_other_amt float64 = 0
  21062. //
  21063. // var register_claa_sunmfee float64 = 0
  21064. // var register_clab_amt float64 = 0
  21065. // var register_other_amt float64 = 0
  21066. //
  21067. // for _, item := range order.HisOrderInfo {
  21068. // if item.MedChrgitmType == "01" { //床位费
  21069. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21070. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21071. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21072. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21073. // if item.ChrgitmLv == "1" {
  21074. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21075. // }
  21076. // if item.ChrgitmLv == "2" {
  21077. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21078. //
  21079. // }
  21080. // if item.ChrgitmLv == "3" {
  21081. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21082. // }
  21083. //
  21084. // }
  21085. //
  21086. // if item.MedChrgitmType == "02" { //诊查
  21087. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21088. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21089. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21090. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21091. // if item.ChrgitmLv == "1" {
  21092. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21093. // }
  21094. // if item.ChrgitmLv == "2" {
  21095. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21096. //
  21097. // }
  21098. // if item.ChrgitmLv == "3" {
  21099. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21100. // }
  21101. //
  21102. // }
  21103. //
  21104. // if item.MedChrgitmType == "03" { //检查费
  21105. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21106. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21107. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21108. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21109. // if item.ChrgitmLv == "1" {
  21110. //
  21111. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21112. //
  21113. // }
  21114. // if item.ChrgitmLv == "2" {
  21115. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21116. //
  21117. // }
  21118. // if item.ChrgitmLv == "3" {
  21119. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21120. // }
  21121. // }
  21122. //
  21123. // if item.MedChrgitmType == "04" { //化验费
  21124. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21125. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21126. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21127. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21128. // if item.ChrgitmLv == "1" {
  21129. //
  21130. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21131. //
  21132. // }
  21133. // if item.ChrgitmLv == "2" {
  21134. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21135. //
  21136. // }
  21137. // if item.ChrgitmLv == "3" {
  21138. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21139. // }
  21140. // }
  21141. //
  21142. // if item.MedChrgitmType == "05" { //治疗费
  21143. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21144. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21145. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21146. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21147. // if item.ChrgitmLv == "1" {
  21148. //
  21149. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21150. //
  21151. // }
  21152. // if item.ChrgitmLv == "2" {
  21153. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21154. //
  21155. // }
  21156. // if item.ChrgitmLv == "3" {
  21157. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21158. // }
  21159. // }
  21160. //
  21161. // if item.MedChrgitmType == "06" { //手术费
  21162. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21163. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21164. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21165. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21166. //
  21167. // if item.ChrgitmLv == "1" {
  21168. //
  21169. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21170. //
  21171. // }
  21172. // if item.ChrgitmLv == "2" {
  21173. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21174. //
  21175. // }
  21176. // if item.ChrgitmLv == "3" {
  21177. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21178. // }
  21179. // }
  21180. //
  21181. // if item.MedChrgitmType == "07" { //手术费
  21182. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21183. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21184. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21185. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21186. //
  21187. // if item.ChrgitmLv == "1" {
  21188. //
  21189. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21190. //
  21191. // }
  21192. // if item.ChrgitmLv == "2" {
  21193. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21194. //
  21195. // }
  21196. // if item.ChrgitmLv == "3" {
  21197. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21198. // }
  21199. // }
  21200. //
  21201. // if item.MedChrgitmType == "08" { //材料费
  21202. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21203. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21204. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21205. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21206. // if item.ChrgitmLv == "1" {
  21207. //
  21208. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21209. //
  21210. // }
  21211. // if item.ChrgitmLv == "2" {
  21212. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21213. //
  21214. // }
  21215. // if item.ChrgitmLv == "3" {
  21216. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21217. // }
  21218. // }
  21219. // if item.MedChrgitmType == "09" { //西药费
  21220. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21221. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21222. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21223. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21224. // if item.ChrgitmLv == "1" {
  21225. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21226. // }
  21227. // if item.ChrgitmLv == "2" {
  21228. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21229. // }
  21230. // if item.ChrgitmLv == "3" {
  21231. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21232. // }
  21233. // }
  21234. // if item.MedChrgitmType == "10" { //中药饮片
  21235. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21236. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21237. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21238. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21239. // if item.ChrgitmLv == "1" {
  21240. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21241. // }
  21242. // if item.ChrgitmLv == "2" {
  21243. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21244. // }
  21245. // if item.ChrgitmLv == "3" {
  21246. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21247. // }
  21248. // }
  21249. //
  21250. // if item.MedChrgitmType == "11" { //中成费
  21251. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21252. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21253. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21254. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21255. // if item.ChrgitmLv == "1" {
  21256. //
  21257. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21258. //
  21259. // }
  21260. // if item.ChrgitmLv == "2" {
  21261. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21262. //
  21263. // }
  21264. // if item.ChrgitmLv == "3" {
  21265. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21266. // }
  21267. // }
  21268. //
  21269. // if item.MedChrgitmType == "12" { //中成费
  21270. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21271. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21272. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21273. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21274. // if item.ChrgitmLv == "1" {
  21275. //
  21276. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21277. //
  21278. // }
  21279. // if item.ChrgitmLv == "2" {
  21280. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21281. //
  21282. // }
  21283. // if item.ChrgitmLv == "3" {
  21284. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21285. // }
  21286. // }
  21287. //
  21288. // if item.MedChrgitmType == "13" { //中成费
  21289. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21290. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21291. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21292. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21293. // if item.ChrgitmLv == "1" {
  21294. //
  21295. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21296. //
  21297. // }
  21298. // if item.ChrgitmLv == "2" {
  21299. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21300. //
  21301. // }
  21302. // if item.ChrgitmLv == "3" {
  21303. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21304. // }
  21305. // }
  21306. //
  21307. // if item.MedChrgitmType == "14" { //其他费
  21308. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21309. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21310. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21311. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21312. // if item.ChrgitmLv == "1" {
  21313. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21314. //
  21315. // }
  21316. // if item.ChrgitmLv == "2" {
  21317. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21318. //
  21319. // }
  21320. // if item.ChrgitmLv == "3" {
  21321. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21322. // }
  21323. // }
  21324. //
  21325. // }
  21326. //
  21327. // var iteminfoStructs []service.IteminfoStruct
  21328. //
  21329. // if bedCostTotal != 0 {
  21330. // iteminfo.MedChrgitm = "01"
  21331. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21332. // iteminfo.Amt = bedCostTotal
  21333. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  21334. // iteminfo.ClabAmt = bed_clab_amt
  21335. // iteminfo.OthAmt = bed_other_amt
  21336. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21337. // }
  21338. //
  21339. // if examineCostTotal != 0 {
  21340. // iteminfo.MedChrgitm = "02"
  21341. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  21342. // iteminfo.Amt = examineCostTotal
  21343. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  21344. // iteminfo.ClabAmt = examine_clab_amt
  21345. // iteminfo.OthAmt = examine_other_amt
  21346. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21347. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21348. // }
  21349. //
  21350. // if checkCostTotal != 0 {
  21351. // iteminfo.MedChrgitm = "03"
  21352. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21353. // iteminfo.Amt = checkCostTotal
  21354. // iteminfo.ClaaSumfee = check_claa_sunmfee
  21355. // iteminfo.ClabAmt = check_clab_amt
  21356. // iteminfo.OthAmt = check_other_amt
  21357. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21358. //
  21359. // }
  21360. //
  21361. // if laboratoryCostTotal != 0 {
  21362. // iteminfo.MedChrgitm = "04"
  21363. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21364. // iteminfo.Amt = laboratoryCostTotal
  21365. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21366. // iteminfo.ClabAmt = laboratory_clab_amt
  21367. // iteminfo.OthAmt = laboratory_other_amt
  21368. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21369. //
  21370. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21371. //
  21372. // }
  21373. //
  21374. // if treatCostTotal != 0 {
  21375. // iteminfo.MedChrgitm = "05"
  21376. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21377. // iteminfo.Amt = treatCostTotal
  21378. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  21379. // iteminfo.ClabAmt = treat_clab_amt
  21380. // iteminfo.OthAmt = treat_other_amt
  21381. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21382. // //(struct4101.IteminfoStruct, iteminfo)
  21383. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21384. // }
  21385. //
  21386. // if operationCostTotal != 0 {
  21387. // iteminfo.MedChrgitm = "06"
  21388. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21389. // iteminfo.Amt = operationCostTotal
  21390. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  21391. // iteminfo.ClabAmt = operation_clab_amt
  21392. // iteminfo.OthAmt = operation_other_amt
  21393. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21394. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21395. // }
  21396. //
  21397. // if nursingCostTotal != 0 {
  21398. // iteminfo.MedChrgitm = "07"
  21399. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  21400. // iteminfo.Amt = nursingCostTotal
  21401. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  21402. // iteminfo.ClabAmt = nursing_clab_amt
  21403. // iteminfo.OthAmt = nursing_other_amt
  21404. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21405. // }
  21406. //
  21407. // if materialCostTotal != 0 {
  21408. // iteminfo.MedChrgitm = "08"
  21409. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21410. // iteminfo.Amt = materialCostTotal
  21411. // iteminfo.ClaaSumfee = material_claa_sunmfee
  21412. // iteminfo.ClabAmt = material_clab_amt
  21413. // iteminfo.OthAmt = material_other_amt
  21414. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21415. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21416. // }
  21417. //
  21418. // if westernMedicineCostTotal != 0 {
  21419. // iteminfo.MedChrgitm = "09"
  21420. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21421. // iteminfo.Amt = westernMedicineCostTotal
  21422. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21423. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21424. // iteminfo.OthAmt = westernMedicine_other_amt
  21425. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21426. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21427. //
  21428. // }
  21429. //
  21430. // if chineseMedicineCostTotal != 0 {
  21431. // iteminfo.MedChrgitm = "10"
  21432. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  21433. // iteminfo.Amt = chineseMedicineCostTotal
  21434. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  21435. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  21436. // iteminfo.OthAmt = chinese_medicine_other_amt
  21437. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21438. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21439. //
  21440. // }
  21441. //
  21442. // if chineseTraditionalMedicineCostTotal != 0 {
  21443. // iteminfo.MedChrgitm = "11"
  21444. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21445. // iteminfo.Amt = westernMedicineCostTotal
  21446. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21447. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21448. // iteminfo.OthAmt = westernMedicine_other_amt
  21449. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21450. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21451. //
  21452. // }
  21453. //
  21454. // if commonlyTreatmentCostTotal != 0 {
  21455. // iteminfo.MedChrgitm = "12"
  21456. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21457. // iteminfo.Amt = commonlyTreatmentCostTotal
  21458. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21459. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21460. // iteminfo.OthAmt = commonly_treatment_other_amt
  21461. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21462. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21463. //
  21464. // }
  21465. //
  21466. // if registerCostTotal != 0 {
  21467. // iteminfo.MedChrgitm = "13"
  21468. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21469. // iteminfo.Amt = registerCostTotal
  21470. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21471. // iteminfo.ClabAmt = register_clab_amt
  21472. // iteminfo.OthAmt = register_other_amt
  21473. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21474. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21475. //
  21476. // }
  21477. //
  21478. // if otherCostTotal != 0 {
  21479. // iteminfo.MedChrgitm = "14"
  21480. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21481. // iteminfo.Amt = otherCostTotal
  21482. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21483. // iteminfo.ClabAmt = other_clab_amt
  21484. // iteminfo.OthAmt = other_other_amt
  21485. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21486. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21487. //
  21488. // }
  21489. // struct4101.IteminfoStruct = iteminfoStructs
  21490. // time_arr := strings.Split(order.SetlTime, " ")
  21491. // struct4101.AdmTime = time_arr[0]
  21492. // struct4101.AdmEndTime = time_arr[0]
  21493. //
  21494. // struct4101.DoctorName = doctor.UserName
  21495. // struct4101.DoctorCode = doctor.DoctorNumber
  21496. //
  21497. // struct4101.Ntly = "中国"
  21498. // struct4101.AdmCaty = "A03.06"
  21499. // var res ResultSeventeen
  21500. // if miConfig.MdtrtareaAdmvs == "421300" {
  21501. // data := make(map[string]interface{})
  21502. // data["struct4101"] = struct4101
  21503. // data["secret_key"] = miConfig.SecretKey
  21504. // data["org_name"] = miConfig.OrgName
  21505. // data["opera"] = curRoles.UserName
  21506. // data["code"] = miConfig.Code
  21507. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21508. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21509. //
  21510. // client := &http.Client{}
  21511. // bytesData, _ := json.Marshal(data)
  21512. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21513. // resp, _ := client.Do(req)
  21514. // defer resp.Body.Close()
  21515. // body, ioErr := ioutil.ReadAll(resp.Body)
  21516. // if ioErr != nil {
  21517. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21518. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21519. // return
  21520. // }
  21521. // var respJSON map[string]interface{}
  21522. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21523. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21525. // return
  21526. // }
  21527. //
  21528. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21529. // userJSONBytes, _ := json.Marshal(respJSON)
  21530. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21531. // utils.ErrorLog("解析失败:%v", err)
  21532. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21533. // adminUser := c.GetAdminUserInfo()
  21534. // errlog := &models.HisOrderError{
  21535. // UserOrgId: adminUser.CurrentOrgId,
  21536. // Ctime: time.Now().Unix(),
  21537. // Mtime: time.Now().Unix(),
  21538. // ErrMsg: res.ErrMsg + "解析失败",
  21539. // Status: 1,
  21540. // PatientId: order_id,
  21541. // Stage: 10088,
  21542. // }
  21543. // service.CreateErrMsgLog(errlog)
  21544. // continue
  21545. // }
  21546. //
  21547. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21548. // data := make(map[string]interface{})
  21549. // data["struct4101"] = struct4101
  21550. // data["secret_key"] = miConfig.SecretKey
  21551. // data["org_name"] = miConfig.OrgName
  21552. // data["opera"] = curRoles.UserName
  21553. // data["code"] = miConfig.Code
  21554. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21555. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21556. //
  21557. // client := &http.Client{}
  21558. // bytesData, _ := json.Marshal(data)
  21559. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21560. // resp, _ := client.Do(req)
  21561. // defer resp.Body.Close()
  21562. // body, ioErr := ioutil.ReadAll(resp.Body)
  21563. // if ioErr != nil {
  21564. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21565. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21566. // return
  21567. // }
  21568. // var respJSON map[string]interface{}
  21569. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21570. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21572. // return
  21573. // }
  21574. //
  21575. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21576. // userJSONBytes, _ := json.Marshal(respJSON)
  21577. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21578. // utils.ErrorLog("解析失败:%v", err)
  21579. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21580. // adminUser := c.GetAdminUserInfo()
  21581. // errlog := &models.HisOrderError{
  21582. // UserOrgId: adminUser.CurrentOrgId,
  21583. // Ctime: time.Now().Unix(),
  21584. // Mtime: time.Now().Unix(),
  21585. // ErrMsg: res.ErrMsg + "解析失败",
  21586. // Status: 1,
  21587. // PatientId: order_id,
  21588. // Stage: 10088,
  21589. // }
  21590. // service.CreateErrMsgLog(errlog)
  21591. // continue
  21592. // }
  21593. //
  21594. // } else {
  21595. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21596. // fmt.Println(result)
  21597. //
  21598. // var dat map[string]interface{}
  21599. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21600. // fmt.Println(dat)
  21601. // } else {
  21602. // fmt.Println(err)
  21603. // }
  21604. // userJSONBytes, _ := json.Marshal(dat)
  21605. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21606. // utils.ErrorLog("解析失败:%v", err)
  21607. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21608. // adminUser := c.GetAdminUserInfo()
  21609. // errlog := &models.HisOrderError{
  21610. // UserOrgId: adminUser.CurrentOrgId,
  21611. // Ctime: time.Now().Unix(),
  21612. // Mtime: time.Now().Unix(),
  21613. // ErrMsg: res.ErrMsg + "解析失败",
  21614. // Status: 1,
  21615. // PatientId: order_id,
  21616. // Stage: 10106,
  21617. // }
  21618. // service.CreateErrMsgLog(errlog)
  21619. // continue
  21620. // }
  21621. // }
  21622. //
  21623. // if res.Infcode != 0 {
  21624. // adminUser := c.GetAdminUserInfo()
  21625. // errlog := &models.HisOrderError{
  21626. // UserOrgId: adminUser.CurrentOrgId,
  21627. // Ctime: time.Now().Unix(),
  21628. // Mtime: time.Now().Unix(),
  21629. // ErrMsg: res.ErrMsg,
  21630. // Status: 1,
  21631. // PatientId: order_id,
  21632. // Stage: 10106,
  21633. // }
  21634. // service.CreateErrMsgLog(errlog)
  21635. // continue
  21636. // } else {
  21637. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21638. // Number: res.Output.SetlListId,
  21639. // Status: 1,
  21640. // Ctime: time.Now().Unix(),
  21641. // Mtime: time.Now().Unix(),
  21642. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21643. // IsUpload: 1,
  21644. // OrderId: order_id,
  21645. // }
  21646. // service.CreateUploadRecord(hisFundSettleListResult)
  21647. // continue
  21648. // }
  21649. // }
  21650. //}
  21651. func (c *HisApiController) GetOrgInfo() {
  21652. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21653. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21654. }
  21655. func (c *HisApiController) GetHisPatientInfo() {
  21656. medical_insurance_card := c.GetString("medical_insurance_card")
  21657. id_card_type, _ := c.GetInt64("id_card_type")
  21658. id_card := c.GetString("id_card")
  21659. adminInfo := c.GetAdminUserInfo()
  21660. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21661. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21662. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21663. IdCardNo := ""
  21664. if id_card_type == 1 {
  21665. IdCardNo = medical_insurance_card
  21666. } else if id_card_type == 2 {
  21667. IdCardNo = id_card
  21668. }
  21669. if config.IsOpen == 1 {
  21670. 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
  21671. resp, requestErr := http.Get(api)
  21672. if requestErr != nil {
  21673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21674. return
  21675. }
  21676. defer resp.Body.Close()
  21677. body, ioErr := ioutil.ReadAll(resp.Body)
  21678. if ioErr != nil {
  21679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21681. return
  21682. }
  21683. var respJSON map[string]interface{}
  21684. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21685. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21687. return
  21688. }
  21689. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21690. userJSONBytes, _ := json.Marshal(userJSON)
  21691. var res ResultTwo
  21692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21693. utils.ErrorLog("解析失败:%v", err)
  21694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21695. return
  21696. }
  21697. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21698. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21699. infoStr := string(Iinfos)
  21700. idetinfoStr := string(Idetinfos)
  21701. if res.Infcode == 0 {
  21702. his := models.VMHisPatient{
  21703. Status: 1,
  21704. Ctime: time.Now().Unix(),
  21705. Mtime: time.Now().Unix(),
  21706. PsnNo: res.Output.Baseinfo.PsnNo,
  21707. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21708. Certno: res.Output.Baseinfo.Certno,
  21709. PsnName: res.Output.Baseinfo.PsnName,
  21710. Gend: res.Output.Baseinfo.Gend,
  21711. Naty: res.Output.Baseinfo.Naty,
  21712. Iinfo: infoStr,
  21713. Idetinfo: idetinfoStr,
  21714. UserOrgId: adminInfo.CurrentOrgId,
  21715. IsReturn: 1,
  21716. IdCardType: id_card_type,
  21717. }
  21718. c.ServeSuccessJSON(map[string]interface{}{
  21719. "info": his,
  21720. })
  21721. } else {
  21722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21723. return
  21724. }
  21725. }
  21726. }
  21727. //func GetBasBaseInfo() (jsonStr string, err error) {
  21728. //
  21729. // handle := syscall.NewLazyDLL("SSCard.dll")
  21730. // add := handle.NewProc("ReadCardBas")
  21731. // str := make([]byte, 1024)
  21732. // str1 := make([]byte, 1024)
  21733. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21734. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21735. //
  21736. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21737. //
  21738. // fmt.Println("> Add(4,5)的结果为:", ret)
  21739. // handle.Release()
  21740. //
  21741. // return "", nil
  21742. //
  21743. //}
  21744. //func GetQRBaseInfo() (jsonStr string, err error) {
  21745. // handle := syscall.LoadDLL("SSCard.dll")
  21746. // ReadCardBas := handle.FindProc("GetQRBase")
  21747. //
  21748. // str := make([]byte, 256)
  21749. // str1 := make([]byte, 256)
  21750. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21751. //
  21752. // fmt.Println(string(str))
  21753. // fmt.Println(r)
  21754. // return string(str), nil
  21755. //}
  21756. //func CardInit() int {
  21757. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21758. // add := DllTestDef.MustFindProc("Init")
  21759. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21760. // if err != nil {
  21761. // fmt.Println("SSCard的运算结果为:", ret)
  21762. // }
  21763. // result := int(ret)
  21764. // return result
  21765. //}
  21766. //func CardInit() int {
  21767. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21768. // if err != nil {
  21769. // fmt.Println("SSCard的运算结果为:", ret)
  21770. // }
  21771. // fmt.Println(err)
  21772. // result := int(ret)
  21773. // return result
  21774. //}
  21775. func IntPtr(n int) uintptr {
  21776. return uintptr(n)
  21777. }
  21778. func StrPtr(s string) uintptr {
  21779. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21780. }
  21781. type Result2001 struct {
  21782. Cainfo interface{} `json:"cainfo"`
  21783. ErrMsg string `json:"err_msg"`
  21784. InfRefmsgid string `json:"inf_refmsgid"`
  21785. Infcode int64 `json:"infcode"`
  21786. Output struct {
  21787. Trtinfo struct {
  21788. PsnNo string `json:"psn_no"`
  21789. TrtChkType string `json:"trt_chk_type"`
  21790. FundPayType string `json:"fund_pay_type"`
  21791. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21792. Begndate string `json:"begndate"`
  21793. Enddate string `json:"enddate"`
  21794. TrtChkRslt string `json:"trt_chk_rslt"`
  21795. } `json:"trtinfo"`
  21796. } `json:"output"`
  21797. RefmsgTime string `json:"refmsg_time"`
  21798. RespondTime string `json:"respond_time"`
  21799. Signtype interface{} `json:"signtype"`
  21800. WarnMsg interface{} `json:"warn_msg"`
  21801. }
  21802. type Result2001Org10265 struct {
  21803. Cainfo interface{} `json:"cainfo"`
  21804. ErrMsg string `json:"err_msg"`
  21805. InfRefmsgid string `json:"inf_refmsgid"`
  21806. Infcode string `json:"infcode"`
  21807. Output struct {
  21808. Trtinfo struct {
  21809. PsnNo string `json:"psn_no"`
  21810. TrtChkType string `json:"trt_chk_type"`
  21811. FundPayType string `json:"fund_pay_type"`
  21812. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21813. Begndate string `json:"begndate"`
  21814. Enddate string `json:"enddate"`
  21815. TrtChkRslt string `json:"trt_chk_rslt"`
  21816. } `json:"trtinfo"`
  21817. } `json:"output"`
  21818. RefmsgTime string `json:"refmsg_time"`
  21819. RespondTime string `json:"respond_time"`
  21820. Signtype interface{} `json:"signtype"`
  21821. WarnMsg interface{} `json:"warn_msg"`
  21822. }
  21823. type ResultTwo struct {
  21824. ErrMsg string `json:"err_msg"`
  21825. InfRefmsgid string `json:"inf_refmsgid"`
  21826. Infcode int64 `json:"infcode"`
  21827. Output struct {
  21828. Baseinfo struct {
  21829. //Brdy string `json:"brdy"`
  21830. Certno string `json:"certno"`
  21831. Gend string `json:"gend"`
  21832. Naty string `json:"naty"`
  21833. PsnCertType string `json:"psn_cert_type"`
  21834. PsnName string `json:"psn_name"`
  21835. PsnNo string `json:"psn_no"`
  21836. } `json:"baseinfo"`
  21837. Idetinfo []interface{} `json:"idetinfo"`
  21838. Iinfo []struct {
  21839. Balc float64 `json:"balc"`
  21840. CvlservFlag string `json:"cvlserv_flag"`
  21841. EmpName string `json:"emp_name"`
  21842. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21843. Insutype string `json:"insutype"`
  21844. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21845. //PausInsuDate string `json:"paus_insu_date"`
  21846. //PsnInsuDate string `json:"psn_insu_date"`
  21847. PsnInsuStas string `json:"psn_insu_stas"`
  21848. PsnType string `json:"psn_type"`
  21849. } `json:"insuinfo"`
  21850. } `json:"output"`
  21851. RefmsgTime string `json:"refmsg_time"`
  21852. RespondTime string `json:"respond_time"`
  21853. Signtype interface{} `json:"signtype"`
  21854. WarnInfo interface{} `json:"warn_info"`
  21855. }
  21856. type ResultTwo10265 struct {
  21857. ErrMsg string `json:"err_msg"`
  21858. InfRefmsgid string `json:"inf_refmsgid"`
  21859. Infcode string `json:"infcode"`
  21860. Output struct {
  21861. Baseinfo struct {
  21862. //Brdy string `json:"brdy"`
  21863. Certno string `json:"certno"`
  21864. Gend string `json:"gend"`
  21865. Naty string `json:"naty"`
  21866. PsnCertType string `json:"psn_cert_type"`
  21867. PsnName string `json:"psn_name"`
  21868. PsnNo string `json:"psn_no"`
  21869. } `json:"baseinfo"`
  21870. Idetinfo []interface{} `json:"idetinfo"`
  21871. Iinfo []struct {
  21872. Balc float64 `json:"balc"`
  21873. CvlservFlag string `json:"cvlserv_flag"`
  21874. EmpName string `json:"emp_name"`
  21875. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21876. Insutype string `json:"insutype"`
  21877. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21878. PsnInsuStas string `json:"psn_insu_stas"`
  21879. PsnType string `json:"psn_type"`
  21880. } `json:"insuinfo"`
  21881. } `json:"output"`
  21882. RefmsgTime string `json:"refmsg_time"`
  21883. RespondTime string `json:"respond_time"`
  21884. Signtype interface{} `json:"signtype"`
  21885. WarnInfo interface{} `json:"warn_info"`
  21886. }
  21887. type ResultThree struct {
  21888. Cainfo interface{} `json:"cainfo"`
  21889. ErrMsg string `json:"err_msg"`
  21890. InfRefmsgid string `json:"inf_refmsgid"`
  21891. Infcode int64 `json:"infcode"`
  21892. Output struct {
  21893. Data struct {
  21894. IptOtpNo string `json:"ipt_otp_no"`
  21895. MdtrtID string `json:"mdtrt_id"`
  21896. PsnNo string `json:"psn_no"`
  21897. } `json:"data"`
  21898. } `json:"output"`
  21899. RefmsgTime string `json:"refmsg_time"`
  21900. RespondTime string `json:"respond_time"`
  21901. Signtype interface{} `json:"signtype"`
  21902. WarnMsg interface{} `json:"warn_msg"`
  21903. }
  21904. type ResultThree10265 struct {
  21905. Cainfo interface{} `json:"cainfo"`
  21906. ErrMsg string `json:"err_msg"`
  21907. InfRefmsgid string `json:"inf_refmsgid"`
  21908. Infcode string `json:"infcode"`
  21909. Output struct {
  21910. Data struct {
  21911. IptOtpNo string `json:"ipt_otp_no"`
  21912. MdtrtID string `json:"mdtrt_id"`
  21913. PsnNo string `json:"psn_no"`
  21914. } `json:"data"`
  21915. } `json:"output"`
  21916. RefmsgTime string `json:"refmsg_time"`
  21917. RespondTime string `json:"respond_time"`
  21918. Signtype interface{} `json:"signtype"`
  21919. WarnMsg interface{} `json:"warn_msg"`
  21920. }
  21921. type ResultFour struct {
  21922. Cainfo string `json:"cainfo"`
  21923. ErrMsg string `json:"err_msg"`
  21924. InfRefmsgid string `json:"inf_refmsgid"`
  21925. Infcode int64 `json:"infcode"`
  21926. Output struct {
  21927. Result []struct {
  21928. BasMednFlag string `json:"bas_medn_flag"`
  21929. ChldMedcFlag string `json:"chld_medc_flag"`
  21930. ChrgitmLv string `json:"chrgitm_lv"`
  21931. Cnt float64 `json:"cnt"`
  21932. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21933. DrtReimFlag string `json:"drt_reim_flag"`
  21934. FeedetlSn string `json:"feedetl_sn"`
  21935. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21936. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21937. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21938. ListSpItemFlag string `json:"list_sp_item_flag"`
  21939. LmtUsedFlag string `json:"lmt_used_flag"`
  21940. MedChrgitmType string `json:"med_chrgitm_type"`
  21941. Memo string `json:"memo"`
  21942. OverlmtAmt float64 `json:"overlmt_amt"`
  21943. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21944. Pric float64 `json:"pric"`
  21945. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21946. SelfpayProp float64 `json:"selfpay_prop"`
  21947. } `json:"result"`
  21948. } `json:"output"`
  21949. RefmsgTime string `json:"refmsg_time"`
  21950. RespondTime string `json:"respond_time"`
  21951. Signtype string `json:"signtype"`
  21952. WarnMsg string `json:"warn_msg"`
  21953. }
  21954. type ResultFour10265 struct {
  21955. Cainfo string `json:"cainfo"`
  21956. ErrMsg string `json:"err_msg"`
  21957. InfRefmsgid string `json:"inf_refmsgid"`
  21958. Infcode string `json:"infcode"`
  21959. Output struct {
  21960. Result []struct {
  21961. BasMednFlag string `json:"bas_medn_flag"`
  21962. ChldMedcFlag string `json:"chld_medc_flag"`
  21963. ChrgitmLv string `json:"chrgitm_lv"`
  21964. Cnt float64 `json:"cnt"`
  21965. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21966. DrtReimFlag string `json:"drt_reim_flag"`
  21967. FeedetlSn string `json:"feedetl_sn"`
  21968. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21969. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21970. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21971. ListSpItemFlag string `json:"list_sp_item_flag"`
  21972. LmtUsedFlag string `json:"lmt_used_flag"`
  21973. MedChrgitmType string `json:"med_chrgitm_type"`
  21974. Memo string `json:"memo"`
  21975. OverlmtAmt float64 `json:"overlmt_amt"`
  21976. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21977. Pric float64 `json:"pric"`
  21978. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21979. SelfpayProp float64 `json:"selfpay_prop"`
  21980. } `json:"result"`
  21981. } `json:"output"`
  21982. RefmsgTime string `json:"refmsg_time"`
  21983. RespondTime string `json:"respond_time"`
  21984. Signtype string `json:"signtype"`
  21985. WarnMsg string `json:"warn_msg"`
  21986. }
  21987. type ResultMemo struct {
  21988. InsuAdmdvs string `json:"insuAdmdvs"`
  21989. }
  21990. // [{"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}]
  21991. type ResultIDInfo struct {
  21992. Begntime string `json:"begntime"`
  21993. Endtime string `json:"endtime"`
  21994. Memo string `json:"memo"`
  21995. }
  21996. type ResultFive struct {
  21997. Balc float64 `json:"balc"`
  21998. CvlservFlag string `json:"cvlserv_flag"`
  21999. EmpName string `json:"emp_name"`
  22000. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22001. Insutype string `json:"insutype"`
  22002. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22003. PausInsuDate string `json:"paus_insu_date"`
  22004. PsnInsuDate string `json:"psn_insu_date"`
  22005. PsnInsuStas string `json:"psn_insu_stas"`
  22006. PsnType string `json:"psn_type"`
  22007. }
  22008. type ResultSix struct {
  22009. Cainfo interface{} `json:"cainfo"`
  22010. ErrMsg string `json:"err_msg"`
  22011. InfRefmsgid string `json:"inf_refmsgid"`
  22012. Infcode int64 `json:"infcode"`
  22013. Output struct {
  22014. } `json:"output"`
  22015. RefmsgTime string `json:"refmsg_time"`
  22016. RespondTime string `json:"respond_time"`
  22017. Signtype interface{} `json:"signtype"`
  22018. WarnMsg interface{} `json:"warn_msg"`
  22019. }
  22020. type ResultSix3103 struct {
  22021. Cainfo interface{} `json:"cainfo"`
  22022. ErrMsg string `json:"err_msg"`
  22023. InfRefmsgid string `json:"inf_refmsgid"`
  22024. Infcode int64 `json:"infcode"`
  22025. RefmsgTime string `json:"refmsg_time"`
  22026. RespondTime string `json:"respond_time"`
  22027. Signtype interface{} `json:"signtype"`
  22028. WarnMsg interface{} `json:"warn_msg"`
  22029. }
  22030. type FJ3507Result struct {
  22031. Cainfo interface{} `json:"cainfo"`
  22032. ErrMsg string `json:"err_msg"`
  22033. InfRefmsgid string `json:"inf_refmsgid"`
  22034. Infcode int64 `json:"infcode"`
  22035. Output struct {
  22036. retRslt string `json:"retRslt"`
  22037. msgRslt string `json:"msgRslt"`
  22038. } `json:"output"`
  22039. RefmsgTime string `json:"refmsg_time"`
  22040. RespondTime string `json:"respond_time"`
  22041. Signtype interface{} `json:"signtype"`
  22042. WarnMsg interface{} `json:"warn_msg"`
  22043. }
  22044. type FJ3507ResultFor10188 struct {
  22045. Cainfo interface{} `json:"cainfo"`
  22046. ErrMsg string `json:"err_msg"`
  22047. InfRefmsgid string `json:"inf_refmsgid"`
  22048. Infcode string `json:"infcode"`
  22049. RefmsgTime string `json:"refmsg_time"`
  22050. RespondTime string `json:"respond_time"`
  22051. Signtype interface{} `json:"signtype"`
  22052. WarnMsg interface{} `json:"warn_msg"`
  22053. }
  22054. type Result2406 struct {
  22055. Cainfo interface{} `json:"cainfo"`
  22056. ErrMsg string `json:"err_msg"`
  22057. InfRefmsgid string `json:"inf_refmsgid"`
  22058. Infcode int64 `json:"infcode"`
  22059. Output struct {
  22060. Result struct {
  22061. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22062. } `json:"result"`
  22063. } `json:"output"`
  22064. RefmsgTime string `json:"refmsg_time"`
  22065. RespondTime string `json:"respond_time"`
  22066. Signtype interface{} `json:"signtype"`
  22067. WarnMsg interface{} `json:"warn_msg"`
  22068. }
  22069. type GZResultSix struct {
  22070. Cainfo interface{} `json:"cainfo"`
  22071. ErrMsg string `json:"err_msg"`
  22072. InfRefmsgid string `json:"inf_refmsgid"`
  22073. Infcode int64 `json:"infcode"`
  22074. Output string `json:"output"`
  22075. RefmsgTime string `json:"refmsg_time"`
  22076. RespondTime string `json:"respond_time"`
  22077. Signtype interface{} `json:"signtype"`
  22078. WarnMsg interface{} `json:"warn_msg"`
  22079. }
  22080. type ResultSix10265 struct {
  22081. Cainfo interface{} `json:"cainfo"`
  22082. ErrMsg string `json:"err_msg"`
  22083. InfRefmsgid string `json:"inf_refmsgid"`
  22084. Infcode string `json:"infcode"`
  22085. Output struct {
  22086. } `json:"output"`
  22087. RefmsgTime string `json:"refmsg_time"`
  22088. RespondTime string `json:"respond_time"`
  22089. Signtype interface{} `json:"signtype"`
  22090. WarnMsg interface{} `json:"warn_msg"`
  22091. }
  22092. type ResultSeven struct {
  22093. Cainfo string `json:"cainfo"`
  22094. ErrMsg string `json:"err_msg"`
  22095. InfRefmsgid string `json:"inf_refmsgid"`
  22096. Infcode int64 `json:"infcode"`
  22097. Output struct {
  22098. Setlinfo struct {
  22099. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22100. AcctPay float64 `json:"acct_pay"`
  22101. ActPayDedc float64 `json:"act_pay_dedc"`
  22102. Age float64 `json:"age"`
  22103. Balc float64 `json:"balc"`
  22104. Certno string `json:"certno"`
  22105. ClrOptins string `json:"clr_optins"`
  22106. ClrType string `json:"clr_type"`
  22107. ClrWay string `json:"clr_way"`
  22108. CvlservFlag string `json:"cvlserv_flag"`
  22109. CvlservPay float64 `json:"cvlserv_pay"`
  22110. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22111. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22112. Gend string `json:"gend"`
  22113. HifesPay float64 `json:"hifes_pay"`
  22114. HifmiPay float64 `json:"hifmi_pay"`
  22115. HifpPay float64 `json:"hifp_pay"`
  22116. HospPartAmt float64 `json:"hosp_part_amt"`
  22117. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22118. Insutype string `json:"insutype"`
  22119. MafPay float64 `json:"maf_pay"`
  22120. MdtrtCertType string `json:"mdtrt_cert_type"`
  22121. HifobPay float64 `json:"hifob_pay"`
  22122. MdtrtID string `json:"mdtrt_id"`
  22123. MedType string `json:"med_type"`
  22124. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22125. MedinsSetlID string `json:"medins_setl_id"`
  22126. Naty string `json:"naty"`
  22127. OthPay float64 `json:"oth_pay"`
  22128. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22129. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22130. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22131. PsnCashPay float64 `json:"psn_cash_pay"`
  22132. PsnCertType string `json:"psn_cert_type"`
  22133. PsnName string `json:"psn_name"`
  22134. PsnNo string `json:"psn_no"`
  22135. PsnPartAmt float64 `json:"psn_part_amt"`
  22136. PsnType string `json:"psn_type"`
  22137. SetlID string `json:"setl_id"`
  22138. SetlTime string `json:"setl_time"`
  22139. } `json:"setlinfo"`
  22140. Setldetail interface{} `json:"setldetail"`
  22141. } `json:"output"`
  22142. RefmsgTime string `json:"refmsg_time"`
  22143. RespondTime string `json:"respond_time"`
  22144. Signtype interface{} `json:"signtype"`
  22145. WarnMsg interface{} `json:"warn_msg"`
  22146. }
  22147. type ResultSevenAH struct {
  22148. Cainfo string `json:"cainfo"`
  22149. ErrMsg string `json:"err_msg"`
  22150. InfRefmsgid string `json:"inf_refmsgid"`
  22151. Infcode int64 `json:"infcode"`
  22152. Output struct {
  22153. Setlinfo struct {
  22154. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22155. AcctPay float64 `json:"acct_pay"`
  22156. ActPayDedc float64 `json:"act_pay_dedc"`
  22157. Age float64 `json:"age"`
  22158. Balc float64 `json:"balc"`
  22159. Certno string `json:"certno"`
  22160. ClrOptins string `json:"clr_optins"`
  22161. ClrType string `json:"clr_type"`
  22162. ClrWay string `json:"clr_way"`
  22163. CvlservFlag string `json:"cvlserv_flag"`
  22164. CvlservPay float64 `json:"cvlserv_pay"`
  22165. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22166. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22167. Gend string `json:"gend"`
  22168. HifesPay float64 `json:"hifes_pay"`
  22169. HifmiPay float64 `json:"hifmi_pay"`
  22170. HifpPay float64 `json:"hifp_pay"`
  22171. HospPartAmt float64 `json:"hosp_part_amt"`
  22172. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22173. Insutype string `json:"insutype"`
  22174. MafPay float64 `json:"maf_pay"`
  22175. MdtrtCertType string `json:"mdtrt_cert_type"`
  22176. HifobPay float64 `json:"hifob_pay"`
  22177. MdtrtID string `json:"mdtrt_id"`
  22178. MedType string `json:"med_type"`
  22179. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22180. MedinsSetlID string `json:"medins_setl_id"`
  22181. Naty string `json:"naty"`
  22182. OthPay float64 `json:"oth_pay"`
  22183. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22184. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22185. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22186. PsnCashPay float64 `json:"psn_cash_pay"`
  22187. PsnCertType string `json:"psn_cert_type"`
  22188. PsnName string `json:"psn_name"`
  22189. PsnNo string `json:"psn_no"`
  22190. PsnPartAmt float64 `json:"psn_part_amt"`
  22191. PsnType string `json:"psn_type"`
  22192. SetlID string `json:"setl_id"`
  22193. SetlTime int64 `json:"setl_time"`
  22194. } `json:"setlinfo"`
  22195. Setldetail interface{} `json:"setldetail"`
  22196. } `json:"output"`
  22197. RefmsgTime string `json:"refmsg_time"`
  22198. RespondTime string `json:"respond_time"`
  22199. Signtype interface{} `json:"signtype"`
  22200. WarnMsg interface{} `json:"warn_msg"`
  22201. }
  22202. type ResultSeven10265 struct {
  22203. Cainfo string `json:"cainfo"`
  22204. ErrMsg string `json:"err_msg"`
  22205. InfRefmsgid string `json:"inf_refmsgid"`
  22206. Infcode string `json:"infcode"`
  22207. Output struct {
  22208. Setlinfo struct {
  22209. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22210. AcctPay float64 `json:"acct_pay"`
  22211. ActPayDedc float64 `json:"act_pay_dedc"`
  22212. Age float64 `json:"age"`
  22213. Balc float64 `json:"balc"`
  22214. Certno string `json:"certno"`
  22215. ClrOptins string `json:"clr_optins"`
  22216. ClrType string `json:"clr_type"`
  22217. ClrWay string `json:"clr_way"`
  22218. CvlservFlag string `json:"cvlserv_flag"`
  22219. CvlservPay float64 `json:"cvlserv_pay"`
  22220. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22221. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22222. Gend string `json:"gend"`
  22223. HifesPay float64 `json:"hifes_pay"`
  22224. HifmiPay float64 `json:"hifmi_pay"`
  22225. HifpPay float64 `json:"hifp_pay"`
  22226. HospPartAmt float64 `json:"hosp_part_amt"`
  22227. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22228. Insutype string `json:"insutype"`
  22229. MafPay float64 `json:"maf_pay"`
  22230. MdtrtCertType string `json:"mdtrt_cert_type"`
  22231. HifobPay float64 `json:"hifob_pay"`
  22232. MdtrtID string `json:"mdtrt_id"`
  22233. MedType string `json:"med_type"`
  22234. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22235. MedinsSetlID string `json:"medins_setl_id"`
  22236. Naty string `json:"naty"`
  22237. OthPay float64 `json:"oth_pay"`
  22238. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22239. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22240. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22241. PsnCashPay float64 `json:"psn_cash_pay"`
  22242. PsnCertType string `json:"psn_cert_type"`
  22243. PsnName string `json:"psn_name"`
  22244. PsnNo string `json:"psn_no"`
  22245. PsnPartAmt float64 `json:"psn_part_amt"`
  22246. PsnType string `json:"psn_type"`
  22247. SetlID string `json:"setl_id"`
  22248. SetlTime string `json:"setl_time"`
  22249. } `json:"setlinfo"`
  22250. Setldetail interface{} `json:"setldetail"`
  22251. } `json:"output"`
  22252. RefmsgTime string `json:"refmsg_time"`
  22253. RespondTime string `json:"respond_time"`
  22254. Signtype interface{} `json:"signtype"`
  22255. WarnMsg interface{} `json:"warn_msg"`
  22256. }
  22257. type ResultSeven10265Two struct {
  22258. Cainfo string `json:"cainfo"`
  22259. ErrMsg string `json:"err_msg"`
  22260. InfRefmsgid string `json:"inf_refmsgid"`
  22261. Infcode string `json:"infcode"`
  22262. Output struct {
  22263. Setlinfo struct {
  22264. AcctMulaidPay string `json:"acct_mulaid_pay"`
  22265. AcctPay float64 `json:"acct_pay"`
  22266. ActPayDedc float64 `json:"act_pay_dedc"`
  22267. Age float64 `json:"age"`
  22268. Balc float64 `json:"balc"`
  22269. Certno string `json:"certno"`
  22270. ClrOptins string `json:"clr_optins"`
  22271. ClrType string `json:"clr_type"`
  22272. ClrWay string `json:"clr_way"`
  22273. CvlservFlag string `json:"cvlserv_flag"`
  22274. CvlservPay float64 `json:"cvlserv_pay"`
  22275. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22276. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22277. Gend string `json:"gend"`
  22278. HifesPay float64 `json:"hifes_pay"`
  22279. HifmiPay float64 `json:"hifmi_pay"`
  22280. HifpPay float64 `json:"hifp_pay"`
  22281. HospPartAmt string `json:"hosp_part_amt"`
  22282. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22283. Insutype string `json:"insutype"`
  22284. MafPay float64 `json:"maf_pay"`
  22285. MdtrtCertType string `json:"mdtrt_cert_type"`
  22286. HifobPay float64 `json:"hifob_pay"`
  22287. MdtrtID string `json:"mdtrt_id"`
  22288. MedType string `json:"med_type"`
  22289. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22290. MedinsSetlID string `json:"medins_setl_id"`
  22291. Naty string `json:"naty"`
  22292. OthPay float64 `json:"oth_pay"`
  22293. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22294. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22295. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22296. PsnCashPay float64 `json:"psn_cash_pay"`
  22297. PsnCertType string `json:"psn_cert_type"`
  22298. PsnName string `json:"psn_name"`
  22299. PsnNo string `json:"psn_no"`
  22300. PsnPartAmt float64 `json:"psn_part_amt"`
  22301. PsnType string `json:"psn_type"`
  22302. SetlID string `json:"setl_id"`
  22303. SetlTime string `json:"setl_time"`
  22304. } `json:"setlinfo"`
  22305. Setldetail interface{} `json:"setldetail"`
  22306. } `json:"output"`
  22307. RefmsgTime string `json:"refmsg_time"`
  22308. RespondTime string `json:"respond_time"`
  22309. Signtype interface{} `json:"signtype"`
  22310. WarnMsg interface{} `json:"warn_msg"`
  22311. }
  22312. type GZResultSeven10265Two struct {
  22313. Cainfo string `json:"cainfo"`
  22314. ErrMsg string `json:"err_msg"`
  22315. InfRefmsgid string `json:"inf_refmsgid"`
  22316. Infcode int64 `json:"infcode"`
  22317. Output struct {
  22318. Setlinfo struct {
  22319. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22320. AcctPay float64 `json:"acct_pay"`
  22321. ActPayDedc float64 `json:"act_pay_dedc"`
  22322. Age float64 `json:"age"`
  22323. Balc float64 `json:"balc"`
  22324. Certno string `json:"certno"`
  22325. ClrOptins string `json:"clr_optins"`
  22326. ClrType string `json:"clr_type"`
  22327. ClrWay string `json:"clr_way"`
  22328. CvlservFlag string `json:"cvlserv_flag"`
  22329. CvlservPay float64 `json:"cvlserv_pay"`
  22330. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22331. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22332. Gend string `json:"gend"`
  22333. HifesPay float64 `json:"hifes_pay"`
  22334. HifmiPay float64 `json:"hifmi_pay"`
  22335. HifpPay float64 `json:"hifp_pay"`
  22336. HospPartAmt float64 `json:"hosp_part_amt"`
  22337. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22338. Insutype string `json:"insutype"`
  22339. MafPay float64 `json:"maf_pay"`
  22340. MdtrtCertType string `json:"mdtrt_cert_type"`
  22341. HifobPay float64 `json:"hifob_pay"`
  22342. MdtrtID string `json:"mdtrt_id"`
  22343. MedType string `json:"med_type"`
  22344. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22345. MedinsSetlID string `json:"medins_setl_id"`
  22346. Naty string `json:"naty"`
  22347. OthPay float64 `json:"oth_pay"`
  22348. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22349. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22350. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22351. PsnCashPay float64 `json:"psn_cash_pay"`
  22352. PsnCertType string `json:"psn_cert_type"`
  22353. PsnName string `json:"psn_name"`
  22354. PsnNo string `json:"psn_no"`
  22355. PsnPartAmt float64 `json:"psn_part_amt"`
  22356. PsnType string `json:"psn_type"`
  22357. SetlID string `json:"setl_id"`
  22358. SetlTime string `json:"setl_time"`
  22359. } `json:"setlinfo"`
  22360. Setldetail interface{} `json:"setldetail"`
  22361. } `json:"output"`
  22362. RefmsgTime string `json:"refmsg_time"`
  22363. RespondTime string `json:"respond_time"`
  22364. Signtype interface{} `json:"signtype"`
  22365. WarnMsg interface{} `json:"warn_msg"`
  22366. }
  22367. type ResultEight struct {
  22368. Cainfo string `json:"cainfo"`
  22369. ErrMsg string `json:"err_msg"`
  22370. InfRefmsgid string `json:"inf_refmsgid"`
  22371. Infcode int64 `json:"infcode"`
  22372. Output struct {
  22373. Stmtinfo struct {
  22374. SetlOptins string `json:"setl_optins"`
  22375. StmtRslt string `json:"stmt_rslt"`
  22376. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22377. } `json:"stmtinfo"`
  22378. } `json:"output"`
  22379. RefmsgTime string `json:"refmsg_time"`
  22380. RespondTime string `json:"respond_time"`
  22381. Signtype interface{} `json:"signtype"`
  22382. WarnMsg interface{} `json:"warn_msg"`
  22383. }
  22384. type ResultEightFor10188 struct {
  22385. Cainfo string `json:"cainfo"`
  22386. ErrMsg string `json:"err_msg"`
  22387. InfRefmsgid string `json:"inf_refmsgid"`
  22388. Infcode string `json:"infcode"`
  22389. Output struct {
  22390. Stmtinfo struct {
  22391. SetlOptins string `json:"setl_optins"`
  22392. StmtRslt string `json:"stmt_rslt"`
  22393. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22394. } `json:"stmtinfo"`
  22395. } `json:"output"`
  22396. RefmsgTime string `json:"refmsg_time"`
  22397. RespondTime string `json:"respond_time"`
  22398. Signtype interface{} `json:"signtype"`
  22399. WarnMsg interface{} `json:"warn_msg"`
  22400. }
  22401. type ResultNine struct {
  22402. Cainfo string `json:"cainfo"`
  22403. ErrMsg string `json:"err_msg"`
  22404. InfRefmsgid string `json:"inf_refmsgid"`
  22405. Infcode int64 `json:"infcode"`
  22406. Output struct {
  22407. FileQuryNo string `json:"file_qury_no"`
  22408. } `json:"output"`
  22409. RefmsgTime string `json:"refmsg_time"`
  22410. RespondTime string `json:"respond_time"`
  22411. Signtype interface{} `json:"signtype"`
  22412. WarnMsg interface{} `json:"warn_msg"`
  22413. }
  22414. type ResultTen struct {
  22415. Cainfo string `json:"cainfo"`
  22416. ErrMsg string `json:"err_msg"`
  22417. InfRefmsgid string `json:"inf_refmsgid"`
  22418. Infcode int64 `json:"infcode"`
  22419. Output struct {
  22420. Fileinfo struct {
  22421. DldEndtime string `json:"dld_endtime"`
  22422. FileQuryNo string `json:"file_qury_no"`
  22423. Filename string `json:"filename"`
  22424. } `json:"fileinfo"`
  22425. } `json:"output"`
  22426. RefmsgTime string `json:"refmsg_time"`
  22427. RespondTime string `json:"respond_time"`
  22428. Signtype interface{} `json:"signtype"`
  22429. WarnMsg interface{} `json:"warn_msg"`
  22430. }
  22431. type Result5262 struct {
  22432. ErrMsg string `json:"err_msg"`
  22433. InfRefmsgid string `json:"inf_refmsgid"`
  22434. Infcode int64 `json:"infcode"`
  22435. Output struct {
  22436. PageInfo struct {
  22437. Size int `json:"size"`
  22438. RecordCounts int `json:"record_counts"`
  22439. } `json:"page_info"`
  22440. Idetinfo []interface{} `json:"idetinfo"`
  22441. Result []struct {
  22442. SetlID string `json:"setl_id"`
  22443. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22444. MdtrtID string `json:"mdtrt_id"`
  22445. InitSetlID string `json:"init_setl_id,omitempty"`
  22446. PsnNo string `json:"psn_no"`
  22447. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22448. PsnName string `json:"psn_name"`
  22449. PsnCertType string `json:"psn_cert_type"`
  22450. Certno string `json:"certno"`
  22451. Gend string `json:"gend,omitempty"`
  22452. Naty string `json:"naty,omitempty"`
  22453. Brdy string `json:"brdy,omitempty"`
  22454. Age float64 `json:"age,omitempty"`
  22455. Insutype string `json:"insutype,omitempty"`
  22456. PsnType string `json:"psn_type"`
  22457. CvlservFlag string `json:"cvlserv_flag"`
  22458. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22459. SpPsnType string `json:"sp_psn_type,omitempty"`
  22460. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22461. ClctGrde string `json:"clct_grde,omitempty"`
  22462. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22463. NwbFlag string `json:"nwb_flag,omitempty"`
  22464. InsuAdmdvs string `json:"insu_admdvs"`
  22465. EmpNo string `json:"emp_no,omitempty"`
  22466. EmpName string `json:"emp_name,omitempty"`
  22467. EmpType string `json:"emp_type,omitempty"`
  22468. EconType string `json:"econ_type,omitempty"`
  22469. AfilIndu string `json:"afil_indu,omitempty"`
  22470. AfilRlts string `json:"afil_rlts,omitempty"`
  22471. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22472. PayLoc string `json:"pay_loc,omitempty"`
  22473. FixmedinsCode string `json:"fixmedins_code"`
  22474. FixmedinsName string `json:"fixmedins_name"`
  22475. HospLv string `json:"hosp_lv,omitempty"`
  22476. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22477. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22478. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22479. Begndate string `json:"begndate"`
  22480. Enddate string `json:"enddate"`
  22481. SetlTime string `json:"setl_time"`
  22482. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22483. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22484. MedType string `json:"med_type"`
  22485. SetlType string `json:"setl_type,omitempty"`
  22486. ClrType string `json:"clr_type,omitempty"`
  22487. ClrWay string `json:"clr_way,omitempty"`
  22488. PsnSetlway string `json:"psn_setlway,omitempty"`
  22489. ClrOptins string `json:"clr_optins,omitempty"`
  22490. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22491. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22492. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22493. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22494. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22495. DedcStd float64 `json:"dedc_std,omitempty"`
  22496. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22497. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22498. HifpPay float64 `json:"hifp_pay,omitempty"`
  22499. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22500. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22501. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22502. HifesPay float64 `json:"hifes_pay,omitempty"`
  22503. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22504. HifobPay float64 `json:"hifob_pay,omitempty"`
  22505. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22506. MafPay float64 `json:"maf_pay,omitempty"`
  22507. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22508. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22509. PsnPay float64 `json:"psn_pay,omitempty"`
  22510. AcctPay float64 `json:"acct_pay,omitempty"`
  22511. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22512. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22513. Balc float64 `json:"balc,omitempty"`
  22514. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22515. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22516. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22517. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22518. Year string `json:"year,omitempty"`
  22519. DiseNo string `json:"dise_no,omitempty"`
  22520. DiseName string `json:"dise_name,omitempty"`
  22521. Invono string `json:"invono,omitempty"`
  22522. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22523. ValiFlag string `json:"vali_flag,omitempty"`
  22524. Memo string `json:"memo,omitempty"`
  22525. Rid string `json:"rid"`
  22526. UpdtTime string `json:"updt_time,omitempty"`
  22527. CrterID string `json:"crter_id,omitempty"`
  22528. CrterName string `json:"crter_name,omitempty"`
  22529. CrteTime string `json:"crte_time,omitempty"`
  22530. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22531. OpterID string `json:"opter_id,omitempty"`
  22532. OpterName string `json:"opter_name,omitempty"`
  22533. OptTime string `json:"opt_time,omitempty"`
  22534. OptinsNo string `json:"optins_no,omitempty"`
  22535. PoolareaNo string `json:"poolarea_no,omitempty"`
  22536. } `json:"result"`
  22537. } `json:"output"`
  22538. RefmsgTime string `json:"refmsg_time"`
  22539. RespondTime string `json:"respond_time"`
  22540. Signtype interface{} `json:"signtype"`
  22541. WarnInfo interface{} `json:"warn_info"`
  22542. }
  22543. type Result5267 struct {
  22544. ErrMsg string `json:"err_msg"`
  22545. InfRefmsgid string `json:"inf_refmsgid"`
  22546. Infcode int64 `json:"infcode"`
  22547. Output struct {
  22548. PageInfo struct {
  22549. Size int `json:"size"`
  22550. RecordCounts int `json:"record_counts"`
  22551. } `json:"pageinfo"`
  22552. Result []struct {
  22553. SetlID string `json:"setl_id"`
  22554. ClrOptins string `json:"clr_optins"`
  22555. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22556. MdtrtID string `json:"mdtrt_id"`
  22557. InitSetlID string `json:"init_setl_id,omitempty"`
  22558. PsnNo string `json:"psn_no"`
  22559. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22560. PsnName string `json:"psn_name"`
  22561. PsnCertType string `json:"psn_cert_type"`
  22562. Certno string `json:"certno"`
  22563. Gend string `json:"gend,omitempty"`
  22564. Naty string `json:"naty,omitempty"`
  22565. Brdy string `json:"brdy,omitempty"`
  22566. Age float64 `json:"age,omitempty"`
  22567. Insutype string `json:"insutype,omitempty"`
  22568. PsnType string `json:"psn_type"`
  22569. CvlservFlag string `json:"cvlserv_flag"`
  22570. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22571. SpPsnType string `json:"sp_psn_type,omitempty"`
  22572. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22573. ClctGrde string `json:"clct_grde,omitempty"`
  22574. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22575. NwbFlag string `json:"nwb_flag,omitempty"`
  22576. InsuAdmdvs string `json:"insu_admdvs"`
  22577. EmpNo string `json:"emp_no,omitempty"`
  22578. EmpName string `json:"emp_name,omitempty"`
  22579. EmpType string `json:"emp_type,omitempty"`
  22580. EconType string `json:"econ_type,omitempty"`
  22581. AfilIndu string `json:"afil_indu,omitempty"`
  22582. AfilRlts string `json:"afil_rlts,omitempty"`
  22583. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22584. PayLoc string `json:"pay_loc,omitempty"`
  22585. FixmedinsCode string `json:"fixmedins_code"`
  22586. FixmedinsName string `json:"fixmedins_name"`
  22587. HospLv string `json:"hosp_lv,omitempty"`
  22588. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22589. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22590. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22591. Begndate string `json:"begndate,omitempty"`
  22592. Enddate string `json:"enddate,omitempty"`
  22593. SetlTime string `json:"setl_time,omitempty"`
  22594. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22595. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22596. MedType string `json:"med_type"`
  22597. SetlType string `json:"setl_type,omitempty"`
  22598. ClrType string `json:"clr_type,omitempty"`
  22599. ClrWay string `json:"clr_way,omitempty"`
  22600. PsnSetlway string `json:"psn_setlway,omitempty"`
  22601. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22602. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22603. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22604. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22605. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22606. DedcStd float64 `json:"dedc_std,omitempty"`
  22607. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22608. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22609. HifpPay float64 `json:"hifp_pay,omitempty"`
  22610. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22611. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22612. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22613. HifesPay float64 `json:"hifes_pay,omitempty"`
  22614. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22615. HifobPay float64 `json:"hifob_pay,omitempty"`
  22616. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22617. MafPay float64 `json:"maf_pay,omitempty"`
  22618. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22619. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22620. PsnPay float64 `json:"psn_pay,omitempty"`
  22621. AcctPay float64 `json:"acct_pay,omitempty"`
  22622. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22623. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22624. Balc float64 `json:"balc,omitempty"`
  22625. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22626. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22627. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22628. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22629. Year string `json:"year,omitempty"`
  22630. DiseNo string `json:"dise_no,omitempty"`
  22631. DiseName string `json:"dise_name,omitempty"`
  22632. Invono string `json:"invono,omitempty"`
  22633. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22634. Memo string `json:"memo,omitempty"`
  22635. UpdtTime string `json:"updt_time,omitempty"`
  22636. OpterID string `json:"opter_id,omitempty"`
  22637. OpterName string `json:"opter_name,omitempty"`
  22638. OptTime string `json:"opt_time,omitempty"`
  22639. OptinsNo string `json:"optins_no,omitempty"`
  22640. PoolareaNo string `json:"poolarea_no,omitempty"`
  22641. } `json:"result"`
  22642. } `json:"output"`
  22643. RefmsgTime string `json:"refmsg_time"`
  22644. RespondTime string `json:"respond_time"`
  22645. Signtype interface{} `json:"signtype"`
  22646. WarnInfo interface{} `json:"warn_info"`
  22647. }
  22648. // type Autogenerated struct {
  22649. // Output struct {
  22650. // Setlinfo struct {
  22651. // SetlTime string `json:"setl_time"`
  22652. // CvlservPay float64 `json:"cvlserv_pay"`
  22653. // Year string `json:"year"`
  22654. // MedType string `json:"med_type"`
  22655. // PsnPay float64 `json:"psn_pay"`
  22656. // OpterID string `json:"opter_id"`
  22657. // Begndate string `json:"begndate"`
  22658. // FlxempeFlag string `json:"flxempe_flag"`
  22659. // HifmiPay float64 `json:"hifmi_pay"`
  22660. // PsnNo string `json:"psn_no"`
  22661. // ActPayDedc float64 `json:"act_pay_dedc"`
  22662. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22663. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22664. // ClrWay string `json:"clr_way"`
  22665. // OthPay float64 `json:"oth_pay"`
  22666. // Gend string `json:"gend"`
  22667. // MdtrtID string `json:"mdtrt_id"`
  22668. // AcctPay float64 `json:"acct_pay"`
  22669. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22670. // Insutype string `json:"insutype"`
  22671. // Invono interface{} `json:"invono"`
  22672. // Enddate string `json:"enddate"`
  22673. // CashPayamt float64 `json:"cash_payamt"`
  22674. // PsnType string `json:"psn_type"`
  22675. // FixmedinsName string `json:"fixmedins_name"`
  22676. // HifpPay float64 `json:"hifp_pay"`
  22677. // NewFlag interface{} `json:"new_flag"`
  22678. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22679. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22680. // PayLoc string `json:"pay_loc"`
  22681. // ClrType string `json:"clr_type"`
  22682. // RefdSetlFlag string `json:"refd_setl_flag"`
  22683. // CvlservFlag string `json:"cvlserv_flag"`
  22684. // EmpName string `json:"emp_name"`
  22685. // Brdy string `json:"brdy"`
  22686. // Naty string `json:"naty"`
  22687. // Certno string `json:"certno"`
  22688. // DiseCode string `json:"dise_code"`
  22689. // FixmedinsCode string `json:"fixmedins_code"`
  22690. // DedcHospLv string `json:"dedc_hosp_lv"`
  22691. // OpterName string `json:"opter_name"`
  22692. // Balc float64 `json:"balc"`
  22693. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22694. // PsnCertType string `json:"psn_cert_type"`
  22695. // HifobPay float64 `json:"hifob_pay"`
  22696. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22697. // HifesPay float64 `json:"hifes_pay"`
  22698. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22699. // OptTime string `json:"opt_time"`
  22700. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22701. // SetlID string `json:"setl_id"`
  22702. // MafPay float64 `json:"maf_pay"`
  22703. // PsnName string `json:"psn_name"`
  22704. // InsuOptins interface{} `json:"insu_optins"`
  22705. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22706. // ClrOptins string `json:"clr_optins"`
  22707. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22708. // DiseName string `json:"dise_name"`
  22709. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22710. // Age float64 `json:"age"`
  22711. // DtrtCertType string `json:"dtrt_cert_type"`
  22712. // HospLv string `json:"hosp_lv"`
  22713. // } `json:"setlinfo"`
  22714. // Setldetail []struct {
  22715. // FundPayType string `json:"fund_pay_type"`
  22716. // FundPayamt float64 `json:"fund_payamt"`
  22717. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22718. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22719. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22720. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22721. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22722. // } `json:"setldetail"`
  22723. // } `json:"output"`
  22724. // Infcode int `json:"infcode"`
  22725. // WarnMsg interface{} `json:"warn_msg"`
  22726. // Cainfo interface{} `json:"cainfo"`
  22727. // ErrMsg interface{} `json:"err_msg"`
  22728. // RefmsgTime string `json:"refmsg_time"`
  22729. // Signtype interface{} `json:"signtype"`
  22730. // RespondTime string `json:"respond_time"`
  22731. // InfRefmsgid string `json:"inf_refmsgid"`
  22732. // }
  22733. type Result002 struct {
  22734. Cainfo interface{} `json:"cainfo"`
  22735. ErrMsg string `json:"err_msg"`
  22736. InfRefmsgid string `json:"inf_refmsgid"`
  22737. Infcode int64 `json:"infcode"`
  22738. Output struct {
  22739. RxFile string `json:"rx_file"`
  22740. SignDigest string `json:"sign_digest"`
  22741. SignCertSn string `json:"sign_cert_sn"`
  22742. SignCertDn string `json:"sign_cert_dn"`
  22743. } `json:"output"`
  22744. RefmsgTime string `json:"refmsg_time"`
  22745. RespondTime string `json:"respond_time"`
  22746. Signtype interface{} `json:"signtype"`
  22747. WarnMsg interface{} `json:"warn_msg"`
  22748. }
  22749. type Result003 struct {
  22750. Cainfo interface{} `json:"cainfo"`
  22751. ErrMsg string `json:"err_msg"`
  22752. InfRefmsgid string `json:"inf_refmsgid"`
  22753. Infcode int64 `json:"infcode"`
  22754. Output struct {
  22755. HiRxno string `json:"hi_rxno"`
  22756. RxStasCodg string `json:"rx_stas_codg"`
  22757. RxStasName string `json:"rx_stas_name"`
  22758. } `json:"output"`
  22759. RefmsgTime string `json:"refmsg_time"`
  22760. RespondTime string `json:"respond_time"`
  22761. Signtype interface{} `json:"signtype"`
  22762. WarnMsg interface{} `json:"warn_msg"`
  22763. }
  22764. type ResultEleven struct {
  22765. Cainfo string `json:"cainfo"`
  22766. ErrMsg string `json:"err_msg"`
  22767. InfRefmsgid string `json:"inf_refmsgid"`
  22768. Infcode int64 `json:"infcode"`
  22769. Output struct {
  22770. Setlinfo struct {
  22771. SetlTime string `json:"setl_time"`
  22772. CvlservPay float64 `json:"cvlserv_pay"`
  22773. Year string `json:"year"`
  22774. MedType string `json:"med_type"`
  22775. PsnPay float64 `json:"psn_pay"`
  22776. OpterID string `json:"opter_id"`
  22777. Begndate string `json:"begndate"`
  22778. FlxempeFlag string `json:"flxempe_flag"`
  22779. HifmiPay float64 `json:"hifmi_pay"`
  22780. PsnNo string `json:"psn_no"`
  22781. ActPayDedc float64 `json:"act_pay_dedc"`
  22782. MedinsSetlID interface{} `json:"medins_setl_id"`
  22783. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22784. ClrWay string `json:"clr_way"`
  22785. OthPay float64 `json:"oth_pay"`
  22786. Gend string `json:"gend"`
  22787. MdtrtID string `json:"mdtrt_id"`
  22788. AcctPay float64 `json:"acct_pay"`
  22789. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22790. Insutype string `json:"insutype"`
  22791. Invono interface{} `json:"invono"`
  22792. Enddate string `json:"enddate"`
  22793. CashPayamt float64 `json:"cash_payamt"`
  22794. PsnType string `json:"psn_type"`
  22795. FixmedinsName string `json:"fixmedins_name"`
  22796. HifpPay float64 `json:"hifp_pay"`
  22797. NewFlag interface{} `json:"new_flag"`
  22798. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22799. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22800. PayLoc string `json:"pay_loc"`
  22801. ClrType string `json:"clr_type"`
  22802. RefdSetlFlag string `json:"refd_setl_flag"`
  22803. CvlservFlag string `json:"cvlserv_flag"`
  22804. EmpName string `json:"emp_name"`
  22805. Brdy string `json:"brdy"`
  22806. Naty string `json:"naty"`
  22807. Certno string `json:"certno"`
  22808. DiseCode string `json:"dise_code"`
  22809. FixmedinsCode string `json:"fixmedins_code"`
  22810. DedcHospLv string `json:"dedc_hosp_lv"`
  22811. OpterName string `json:"opter_name"`
  22812. Balc float64 `json:"balc"`
  22813. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22814. PsnCertType string `json:"psn_cert_type"`
  22815. HifobPay float64 `json:"hifob_pay"`
  22816. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22817. HifesPay float64 `json:"hifes_pay"`
  22818. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22819. OptTime string `json:"opt_time"`
  22820. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22821. SetlID string `json:"setl_id"`
  22822. MafPay float64 `json:"maf_pay"`
  22823. PsnName string `json:"psn_name"`
  22824. InsuOptins interface{} `json:"insu_optins"`
  22825. PrefFundPay interface{} `json:"pref_fund_pay"`
  22826. ClrOptins string `json:"clr_optins"`
  22827. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22828. DiseName string `json:"dise_name"`
  22829. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22830. Age float64 `json:"age"`
  22831. DtrtCertType string `json:"dtrt_cert_type"`
  22832. HospLv string `json:"hosp_lv"`
  22833. PsnCashPay float64 `json:"psn_cash_pay"`
  22834. } `json:"setlinfo"`
  22835. } `json:"output"`
  22836. RefmsgTime string `json:"refmsg_time"`
  22837. RespondTime string `json:"respond_time"`
  22838. Signtype interface{} `json:"signtype"`
  22839. WarnMsg interface{} `json:"warn_msg"`
  22840. }
  22841. type ResultElevenah struct {
  22842. Cainfo string `json:"cainfo"`
  22843. ErrMsg string `json:"err_msg"`
  22844. InfRefmsgid string `json:"inf_refmsgid"`
  22845. Infcode int64 `json:"infcode"`
  22846. Output struct {
  22847. Setlinfo struct {
  22848. SetlTime int64 `json:"setl_time"`
  22849. CvlservPay float64 `json:"cvlserv_pay"`
  22850. Year string `json:"year"`
  22851. MedType string `json:"med_type"`
  22852. PsnPay float64 `json:"psn_pay"`
  22853. OpterID string `json:"opter_id"`
  22854. Begndate int64 `json:"begndate"`
  22855. FlxempeFlag string `json:"flxempe_flag"`
  22856. HifmiPay float64 `json:"hifmi_pay"`
  22857. PsnNo string `json:"psn_no"`
  22858. ActPayDedc float64 `json:"act_pay_dedc"`
  22859. MedinsSetlID interface{} `json:"medins_setl_id"`
  22860. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22861. ClrWay string `json:"clr_way"`
  22862. OthPay float64 `json:"oth_pay"`
  22863. Gend string `json:"gend"`
  22864. MdtrtID string `json:"mdtrt_id"`
  22865. AcctPay float64 `json:"acct_pay"`
  22866. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22867. Insutype string `json:"insutype"`
  22868. Invono interface{} `json:"invono"`
  22869. Enddate int64 `json:"enddate"`
  22870. CashPayamt float64 `json:"cash_payamt"`
  22871. PsnType string `json:"psn_type"`
  22872. FixmedinsName string `json:"fixmedins_name"`
  22873. HifpPay float64 `json:"hifp_pay"`
  22874. NewFlag interface{} `json:"new_flag"`
  22875. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22876. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22877. PayLoc string `json:"pay_loc"`
  22878. ClrType string `json:"clr_type"`
  22879. RefdSetlFlag string `json:"refd_setl_flag"`
  22880. CvlservFlag string `json:"cvlserv_flag"`
  22881. EmpName string `json:"emp_name"`
  22882. Brdy int64 `json:"brdy"`
  22883. Naty string `json:"naty"`
  22884. Certno string `json:"certno"`
  22885. DiseCode string `json:"dise_code"`
  22886. FixmedinsCode string `json:"fixmedins_code"`
  22887. DedcHospLv string `json:"dedc_hosp_lv"`
  22888. OpterName string `json:"opter_name"`
  22889. Balc float64 `json:"balc"`
  22890. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22891. PsnCertType string `json:"psn_cert_type"`
  22892. HifobPay float64 `json:"hifob_pay"`
  22893. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22894. HifesPay float64 `json:"hifes_pay"`
  22895. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22896. OptTime int64 `json:"opt_time"`
  22897. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22898. SetlID string `json:"setl_id"`
  22899. MafPay float64 `json:"maf_pay"`
  22900. PsnName string `json:"psn_name"`
  22901. InsuOptins interface{} `json:"insu_optins"`
  22902. PrefFundPay interface{} `json:"pref_fund_pay"`
  22903. ClrOptins string `json:"clr_optins"`
  22904. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22905. DiseName string `json:"dise_name"`
  22906. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22907. Age float64 `json:"age"`
  22908. DtrtCertType string `json:"dtrt_cert_type"`
  22909. HospLv string `json:"hosp_lv"`
  22910. PsnCashPay float64 `json:"psn_cash_pay"`
  22911. } `json:"setlinfo"`
  22912. } `json:"output"`
  22913. RefmsgTime string `json:"refmsg_time"`
  22914. RespondTime string `json:"respond_time"`
  22915. Signtype interface{} `json:"signtype"`
  22916. WarnMsg interface{} `json:"warn_msg"`
  22917. }
  22918. type ResultEleven10265 struct {
  22919. Cainfo string `json:"cainfo"`
  22920. ErrMsg string `json:"err_msg"`
  22921. InfRefmsgid string `json:"inf_refmsgid"`
  22922. Infcode string `json:"infcode"`
  22923. Output struct {
  22924. Setlinfo struct {
  22925. SetlTime string `json:"setl_time"`
  22926. CvlservPay float64 `json:"cvlserv_pay"`
  22927. Year string `json:"year"`
  22928. MedType string `json:"med_type"`
  22929. PsnPay float64 `json:"psn_pay"`
  22930. OpterID string `json:"opter_id"`
  22931. Begndate string `json:"begndate"`
  22932. FlxempeFlag string `json:"flxempe_flag"`
  22933. HifmiPay float64 `json:"hifmi_pay"`
  22934. PsnNo string `json:"psn_no"`
  22935. ActPayDedc float64 `json:"act_pay_dedc"`
  22936. MedinsSetlID interface{} `json:"medins_setl_id"`
  22937. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22938. ClrWay string `json:"clr_way"`
  22939. OthPay float64 `json:"oth_pay"`
  22940. Gend string `json:"gend"`
  22941. MdtrtID string `json:"mdtrt_id"`
  22942. AcctPay float64 `json:"acct_pay"`
  22943. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22944. Insutype string `json:"insutype"`
  22945. Invono interface{} `json:"invono"`
  22946. Enddate string `json:"enddate"`
  22947. CashPayamt float64 `json:"cash_payamt"`
  22948. PsnType string `json:"psn_type"`
  22949. FixmedinsName string `json:"fixmedins_name"`
  22950. HifpPay float64 `json:"hifp_pay"`
  22951. NewFlag interface{} `json:"new_flag"`
  22952. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22953. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22954. PayLoc string `json:"pay_loc"`
  22955. ClrType string `json:"clr_type"`
  22956. RefdSetlFlag string `json:"refd_setl_flag"`
  22957. CvlservFlag string `json:"cvlserv_flag"`
  22958. EmpName string `json:"emp_name"`
  22959. Brdy string `json:"brdy"`
  22960. Naty string `json:"naty"`
  22961. Certno string `json:"certno"`
  22962. DiseCode string `json:"dise_code"`
  22963. FixmedinsCode string `json:"fixmedins_code"`
  22964. DedcHospLv string `json:"dedc_hosp_lv"`
  22965. OpterName string `json:"opter_name"`
  22966. Balc float64 `json:"balc"`
  22967. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22968. PsnCertType string `json:"psn_cert_type"`
  22969. HifobPay float64 `json:"hifob_pay"`
  22970. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22971. HifesPay float64 `json:"hifes_pay"`
  22972. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22973. OptTime string `json:"opt_time"`
  22974. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22975. SetlID string `json:"setl_id"`
  22976. MafPay float64 `json:"maf_pay"`
  22977. PsnName string `json:"psn_name"`
  22978. InsuOptins interface{} `json:"insu_optins"`
  22979. PrefFundPay interface{} `json:"pref_fund_pay"`
  22980. ClrOptins string `json:"clr_optins"`
  22981. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22982. DiseName string `json:"dise_name"`
  22983. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22984. Age float64 `json:"age"`
  22985. DtrtCertType string `json:"dtrt_cert_type"`
  22986. HospLv string `json:"hosp_lv"`
  22987. PsnCashPay float64 `json:"psn_cash_pay"`
  22988. } `json:"setlinfo"`
  22989. } `json:"output"`
  22990. RefmsgTime string `json:"refmsg_time"`
  22991. RespondTime string `json:"respond_time"`
  22992. Signtype interface{} `json:"signtype"`
  22993. WarnMsg interface{} `json:"warn_msg"`
  22994. }
  22995. type ResultTwelve struct {
  22996. Cainfo string `json:"cainfo"`
  22997. ErrMsg string `json:"err_msg"`
  22998. InfRefmsgid string `json:"inf_refmsgid"`
  22999. Infcode int64 `json:"infcode"`
  23000. Output struct {
  23001. MdtrtId string `json:"mdtrt_id"`
  23002. ChrgBchno string `json:"chrg_bchno"`
  23003. PsnNo string `json:"psn_no"`
  23004. } `json:"output"`
  23005. RefmsgTime string `json:"refmsg_time"`
  23006. RespondTime string `json:"respond_time"`
  23007. Signtype interface{} `json:"signtype"`
  23008. WarnMsg interface{} `json:"warn_msg"`
  23009. }
  23010. type ResultThirteen struct {
  23011. ErrMsg string `json:"err_msg"`
  23012. InfRefmsgid string `json:"inf_refmsgid"`
  23013. Infcode int64 `json:"infcode"`
  23014. Output struct {
  23015. Result struct {
  23016. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23017. } `json:"result"`
  23018. } `json:"output"`
  23019. RefmsgTime string `json:"refmsg_time"`
  23020. RespondTime string `json:"respond_time"`
  23021. Signtype interface{} `json:"signtype"`
  23022. WarnInfo interface{} `json:"warn_info"`
  23023. }
  23024. type ResultThirteen10265 struct {
  23025. ErrMsg string `json:"err_msg"`
  23026. InfRefmsgid string `json:"inf_refmsgid"`
  23027. Infcode string `json:"infcode"`
  23028. Output struct {
  23029. Result struct {
  23030. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23031. } `json:"result"`
  23032. } `json:"output"`
  23033. RefmsgTime string `json:"refmsg_time"`
  23034. RespondTime string `json:"respond_time"`
  23035. Signtype interface{} `json:"signtype"`
  23036. WarnInfo interface{} `json:"warn_info"`
  23037. }
  23038. type ResultFourteen struct {
  23039. ErrMsg string `json:"err_msg"`
  23040. InfRefmsgid string `json:"inf_refmsgid"`
  23041. Infcode int64 `json:"infcode"`
  23042. Output struct {
  23043. } `json:"output"`
  23044. RefmsgTime string `json:"refmsg_time"`
  23045. RespondTime string `json:"respond_time"`
  23046. Signtype interface{} `json:"signtype"`
  23047. WarnInfo interface{} `json:"warn_info"`
  23048. }
  23049. type ResultCFYLJG001 struct {
  23050. ErrMsg string `json:"err_msg"`
  23051. InfRefmsgid string `json:"inf_refmsgid"`
  23052. Infcode int64 `json:"infcode"`
  23053. Output struct {
  23054. RxTraceCode string `json:"rx_trace_code"`
  23055. HiRxno string `json:"hi_rxno"`
  23056. } `json:"output"`
  23057. RefmsgTime string `json:"refmsg_time"`
  23058. RespondTime string `json:"respond_time"`
  23059. Signtype interface{} `json:"signtype"`
  23060. WarnInfo interface{} `json:"warn_info"`
  23061. }
  23062. type ResultCFYLJG007 struct {
  23063. ErrMsg string `json:"err_msg"`
  23064. InfRefmsgid string `json:"inf_refmsgid"`
  23065. Infcode int64 `json:"infcode"`
  23066. Output struct {
  23067. HiRxno string `json:"hi_rxno"`
  23068. RxStasName string `json:"rx_stas_name"`
  23069. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  23070. Seltdelts []interface{} `json:"seltdelts"`
  23071. RxUsedStasName string `json:"rx_used_stas_name"`
  23072. RxStasCodg string `json:"rx_stas_codg"`
  23073. } `json:"output"`
  23074. RefmsgTime string `json:"refmsg_time"`
  23075. RespondTime string `json:"respond_time"`
  23076. Signtype interface{} `json:"signtype"`
  23077. WarnInfo interface{} `json:"warn_info"`
  23078. }
  23079. type ResultCFYLJG002 struct {
  23080. ErrMsg string `json:"err_msg"`
  23081. InfRefmsgid string `json:"inf_refmsgid"`
  23082. Infcode int64 `json:"infcode"`
  23083. Output struct {
  23084. RxFile string `json:"rx_file"`
  23085. SignDigest string `json:"sign_digest"`
  23086. SignCertSn string `json:"sign_cert_sn"`
  23087. SignCertDn string `json:"sign_cert_dn"`
  23088. } `json:"output"`
  23089. RefmsgTime string `json:"refmsg_time"`
  23090. RespondTime string `json:"respond_time"`
  23091. Signtype interface{} `json:"signtype"`
  23092. WarnInfo interface{} `json:"warn_info"`
  23093. }
  23094. type ResultCFYLJG003 struct {
  23095. ErrMsg string `json:"err_msg"`
  23096. InfRefmsgid string `json:"inf_refmsgid"`
  23097. Infcode int64 `json:"infcode"`
  23098. Output struct {
  23099. HiRxno string `json:"hi_rxno"`
  23100. RxStasCodg string `json:"rx_stas_codg"`
  23101. RxStasName string `json:"rx_stas_name"`
  23102. } `json:"output"`
  23103. RefmsgTime string `json:"refmsg_time"`
  23104. RespondTime string `json:"respond_time"`
  23105. Signtype interface{} `json:"signtype"`
  23106. WarnInfo interface{} `json:"warn_info"`
  23107. }
  23108. type ResultCFYLJG004 struct {
  23109. ErrMsg string `json:"err_msg"`
  23110. InfRefmsgid string `json:"inf_refmsgid"`
  23111. Infcode int64 `json:"infcode"`
  23112. Output struct {
  23113. HiRxno string `json:"hi_rxno"`
  23114. RxStasCodg string `json:"rx_stas_codg"`
  23115. RxStasName string `json:"rx_stas_name"`
  23116. } `json:"output"`
  23117. RefmsgTime string `json:"refmsg_time"`
  23118. RespondTime string `json:"respond_time"`
  23119. Signtype interface{} `json:"signtype"`
  23120. WarnInfo interface{} `json:"warn_info"`
  23121. }
  23122. type ResultCFYLJG008 struct {
  23123. ErrMsg string `json:"err_msg"`
  23124. InfRefmsgid string `json:"inf_refmsgid"`
  23125. Infcode int64 `json:"infcode"`
  23126. Output struct {
  23127. PoolareaNo string `json:"poolareaNo"`
  23128. AdmdvsName string `json:"admdvsName"`
  23129. Count string `json:"count"`
  23130. } `json:"output"`
  23131. RefmsgTime string `json:"refmsg_time"`
  23132. RespondTime string `json:"respond_time"`
  23133. Signtype interface{} `json:"signtype"`
  23134. WarnInfo interface{} `json:"warn_info"`
  23135. }
  23136. type ResultCFYLJG005 struct {
  23137. ErrMsg string `json:"err_msg"`
  23138. InfRefmsgid string `json:"inf_refmsgid"`
  23139. Infcode int64 `json:"infcode"`
  23140. Output struct {
  23141. HiRxNo string `json:"hi_rxno"`
  23142. FixMedinsCode string `json:"fixmedins_code"`
  23143. FixMedinsName string `json:"fixmedins_name"`
  23144. RxStasCodg string `json:"rx_stas_codg"`
  23145. RxStasName string `json:"rx_stas_name"`
  23146. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  23147. RxUserdStasName string `json:"rx_userd_stas_name"`
  23148. PrscTime string `json:"prsc_time"`
  23149. RxDrugCnt float64 `json:"rx_drug_cnt"`
  23150. RxUsedWayCodg string `json:"rx_used_way_codg"`
  23151. RxUsedWayName string `json:"rx_used_way_name"`
  23152. RxFrquCodg string `json:"rx_frqu_codg"`
  23153. RxFrquName string `json:"rx_frqu_name"`
  23154. RxDosunt string `json:"rx_dosunt"`
  23155. RxDoscnt float64 `json:"rx_doscnt"`
  23156. RxDrordDscr string `json:"rx_drord_dscr"`
  23157. ValiDays int64 `json:"vali_days"`
  23158. ValiEndTime string `json:"vali_end_time"`
  23159. ReptFlag string `json:"rept_flag"`
  23160. MaxReptCnt int64 `json:"max_rept_cnt"`
  23161. ReptdCnt int64 `json:"reptd_cnt"`
  23162. MinInrvDays int64 `json:"min_inrv_days"`
  23163. RxTypeCode string `json:"rx_type_code"`
  23164. RxTypeName string `json:"rx_type_name"`
  23165. LongRxFlag string `json:"long_rx_flag"`
  23166. RxDetlList []struct {
  23167. MedListCodg string `json:"med_list_codg"`
  23168. MedinsListCodg string `json:"medins_list_codg"`
  23169. HospPrepFlag string `json:"hosp_prep_flag"`
  23170. RxItemTypeCode string `json:"rx_item_type_code"`
  23171. RxItemTypeName string `json:"rx_item_type_name"`
  23172. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  23173. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  23174. TcmHerbFoote string `json:"tcmherb_foote"`
  23175. MednTypeCode string `json:"medn_type_code"`
  23176. MednTypeName string `json:"medn_type_name"`
  23177. MainMedcFlag string `json:"main_medc_flag"`
  23178. UrgtFlag string `json:"urgt_flag"`
  23179. BasMednFlag string `json:"bas_medn_flag"`
  23180. ImpDrugFlag string `json:"imp_drug_flag"`
  23181. ProdBarc string `json:"prod_barc"`
  23182. DrugProdname string `json:"drug_prodname"`
  23183. GennameCodg string `json:"genname_codg"`
  23184. DrugGenname string `json:"drug_genname"`
  23185. DrugDosform string `json:"drug_dosform"`
  23186. DrugSpec string `json:"drug_spec"`
  23187. PrdrName string `json:"prdr_name"`
  23188. MedcWayCodg string `json:"medc_way_codg"`
  23189. MedcWayDscr string `json:"medc_way_dscr"`
  23190. MedcBegntime string `json:"medc_begntime"`
  23191. MedcEndtime string `json:"medc_endtime"`
  23192. MedcDays float64 `json:"medc_days"`
  23193. DrugPric float64 `json:"drug_pric"`
  23194. DrugSumamt float64 `json:"drug_sumamt"`
  23195. DrugCnt float64 `json:"drug_cnt"`
  23196. DrugDosunt string `json:"drug_dosunt"`
  23197. SinDoscnt float64 `json:"sin_doscnt"`
  23198. SinDosunt string `json:"sin_dosunt"`
  23199. UsedFrquCodg string `json:"used_frqu_codg"`
  23200. UsedFrquName string `json:"used_frqu_name"`
  23201. DrugTotlcnt string `json:"drug_totlcnt"`
  23202. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  23203. DiseCodg string `json:"dise_codg"`
  23204. HospApprFlag string `json:"hosp_appr_flag"`
  23205. } `json:"rx_detl_list"`
  23206. RxOtpinfo struct {
  23207. MedType string `json:"med_type"`
  23208. IptOtpNo string `json:"ipt_otp_no"`
  23209. OtpIptFlag string `json:"otp_ipt_flag"`
  23210. PatnName string `json:"patn_name"`
  23211. PatnAge float64 `json:"patn_age"`
  23212. PatnHgt float64 `json:"patn_hgt"`
  23213. PatnWt float64 `json:"patn_wt"`
  23214. Gend string `json:"gend"`
  23215. GesoVal float64 `json:"geso_val"`
  23216. NwbFlag string `json:"nwb_flag"`
  23217. NwbAge string `json:"nwb_age"`
  23218. SuckPrdFlag string `json:"suck_prd_flag"`
  23219. AlgsHis string `json:"algs_his"`
  23220. Insutype string `json:"insutype"`
  23221. PrscDeptName string `json:"prsc_dept_name"`
  23222. PrscDrName string `json:"prsc_dr_name"`
  23223. PharName string `json:"phar_name"`
  23224. PharChkTime string `json:"phar_chk_time"`
  23225. MdtrtTime string `json:"mdtrt_time"`
  23226. DiseCodg string `json:"dise_codg"`
  23227. DiseName string `json:"dise_name"`
  23228. SpDiseFlag string `json:"sp_dise_flag"`
  23229. MaindiagCode string `json:"maindiag_code"`
  23230. MaindiagName string `json:"maindiag_name"`
  23231. DiseCondDscr string `json:"dise_cond_dscr"`
  23232. FstdiagFlag string `json:"fstdiag_flag"`
  23233. } `json:"rx_otpinfo"`
  23234. RxDiseList []struct {
  23235. DiagType string `json:"diag_type"`
  23236. MaindiagFlag string `json:"maindiag_flag"`
  23237. DiagSrtNo string `json:"diag_srt_no"`
  23238. DiagCode string `json:"diag_code"`
  23239. DiagName string `json:"diag_name"`
  23240. DiagDept string `json:"diag_dept"`
  23241. DiagDrNo string `json:"diag_dr_no"`
  23242. DiagDrName string `json:"diag_dr_name"`
  23243. DiagTime string `json:"diag_time"`
  23244. TcmDiseCode string `json:"tcm_dise_code"`
  23245. TcmDiseName string `json:"tcm_dise_name"`
  23246. TcmSympCode string `json:"tcmsymp_code"`
  23247. TcmSymp string `json:"tcmsymp"`
  23248. } `json:"rx_dise_list"`
  23249. } `json:"output"`
  23250. RefmsgTime string `json:"refmsg_time"`
  23251. RespondTime string `json:"respond_time"`
  23252. Signtype interface{} `json:"signtype"`
  23253. WarnInfo interface{} `json:"warn_info"`
  23254. }
  23255. type ResultCFYLJG006 struct {
  23256. ErrMsg string `json:"err_msg"`
  23257. InfRefmsgid string `json:"inf_refmsgid"`
  23258. Infcode int64 `json:"infcode"`
  23259. Output struct {
  23260. HiRxNo string `json:"hi_rxno"`
  23261. PharCode string `json:"phar_code"`
  23262. PharName string `json:"phar_name"`
  23263. RxChkOpnn string `json:"rx_chk_opnn"`
  23264. RxChkTime string `json:"rx_chk_time"`
  23265. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  23266. RxChkStasName string `json:"rx_chk_stas_name"`
  23267. RxStasCodg string `json:"rx_stas_codg"`
  23268. RxStasName string `json:"rx_stas_name"`
  23269. } `json:"output"`
  23270. RefmsgTime string `json:"refmsg_time"`
  23271. RespondTime string `json:"respond_time"`
  23272. Signtype interface{} `json:"signtype"`
  23273. WarnInfo interface{} `json:"warn_info"`
  23274. }
  23275. type ResultFourteen10265 struct {
  23276. ErrMsg string `json:"err_msg"`
  23277. InfRefmsgid string `json:"inf_refmsgid"`
  23278. Infcode string `json:"infcode"`
  23279. Output struct {
  23280. } `json:"output"`
  23281. RefmsgTime string `json:"refmsg_time"`
  23282. RespondTime string `json:"respond_time"`
  23283. Signtype interface{} `json:"signtype"`
  23284. WarnInfo interface{} `json:"warn_info"`
  23285. }
  23286. type ResultSixteen struct {
  23287. Cainfo string `json:"cainfo"`
  23288. ErrMsg string `json:"err_msg"`
  23289. InfRefmsgid string `json:"inf_refmsgid"`
  23290. Infcode int64 `json:"infcode"`
  23291. Output struct {
  23292. Setlinfo struct {
  23293. MdtrtID string `json:"mdtrt_id"`
  23294. SetlID string `json:"setl_id"`
  23295. ClrOptins string `json:"clr_optins"`
  23296. SetlTime string `json:"setl_time"`
  23297. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23298. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23299. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23300. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23301. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23302. ActPayDedc float64 `json:"act_pay_dedc"`
  23303. HifpPay float64 `json:"hifp_pay"`
  23304. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23305. Lfpay float64 `json:"selfpay"`
  23306. CvlservPay float64 `json:"cvlserv_pay"`
  23307. HifesPay float64 `json:"hifes_pay"`
  23308. HifmiPay float64 `json:"hifmi_pay"`
  23309. HifobPay float64 `json:"hifob_pay"`
  23310. MafPay float64 `json:"maf_pay"`
  23311. OthPay float64 `json:"oth_pay"`
  23312. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23313. PsnPartAmt float64 `json:"psn_part_amt"`
  23314. AcctPay float64 `json:"acct_pay"`
  23315. Balc float64 `json:"balc"`
  23316. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23317. HospPartAmt float64 `json:"hosp_part_amt"`
  23318. MedinsSetlID string `json:"medins_setl_id"`
  23319. PdnCashPay string `json:"pdn_cash_pay"`
  23320. } `json:"setlinfo"`
  23321. } `json:"output"`
  23322. RefmsgTime string `json:"refmsg_time"`
  23323. RespondTime string `json:"respond_time"`
  23324. Signtype interface{} `json:"signtype"`
  23325. WarnMsg interface{} `json:"warn_msg"`
  23326. }
  23327. type ResultSixteen10265 struct {
  23328. Cainfo string `json:"cainfo"`
  23329. ErrMsg string `json:"err_msg"`
  23330. InfRefmsgid string `json:"inf_refmsgid"`
  23331. Infcode string `json:"infcode"`
  23332. Output struct {
  23333. Setlinfo struct {
  23334. MdtrtID string `json:"mdtrt_id"`
  23335. SetlID string `json:"setl_id"`
  23336. ClrOptins string `json:"clr_optins"`
  23337. SetlTime string `json:"setl_time"`
  23338. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23339. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23340. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23341. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23342. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23343. ActPayDedc float64 `json:"act_pay_dedc"`
  23344. HifpPay float64 `json:"hifp_pay"`
  23345. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23346. Lfpay float64 `json:"selfpay"`
  23347. CvlservPay float64 `json:"cvlserv_pay"`
  23348. HifesPay float64 `json:"hifes_pay"`
  23349. HifmiPay float64 `json:"hifmi_pay"`
  23350. HifobPay float64 `json:"hifob_pay"`
  23351. MafPay float64 `json:"maf_pay"`
  23352. OthPay float64 `json:"oth_pay"`
  23353. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23354. PsnPartAmt float64 `json:"psn_part_amt"`
  23355. AcctPay float64 `json:"acct_pay"`
  23356. Balc float64 `json:"balc"`
  23357. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23358. HospPartAmt float64 `json:"hosp_part_amt"`
  23359. MedinsSetlID string `json:"medins_setl_id"`
  23360. PdnCashPay string `json:"pdn_cash_pay"`
  23361. } `json:"setlinfo"`
  23362. } `json:"output"`
  23363. RefmsgTime string `json:"refmsg_time"`
  23364. RespondTime string `json:"respond_time"`
  23365. Signtype interface{} `json:"signtype"`
  23366. WarnMsg interface{} `json:"warn_msg"`
  23367. }
  23368. type ResultSixteen10265Two struct {
  23369. Cainfo string `json:"cainfo"`
  23370. ErrMsg string `json:"err_msg"`
  23371. InfRefmsgid string `json:"inf_refmsgid"`
  23372. Infcode string `json:"infcode"`
  23373. Output struct {
  23374. Setlinfo interface{} `json:"setlinfo"`
  23375. } `json:"output"`
  23376. RefmsgTime string `json:"refmsg_time"`
  23377. RespondTime string `json:"respond_time"`
  23378. Signtype interface{} `json:"signtype"`
  23379. WarnMsg interface{} `json:"warn_msg"`
  23380. }
  23381. type ResultgzSixteen10265Two struct {
  23382. Cainfo string `json:"cainfo"`
  23383. ErrMsg string `json:"err_msg"`
  23384. InfRefmsgid string `json:"inf_refmsgid"`
  23385. Infcode int64 `json:"infcode"`
  23386. Output struct {
  23387. Setlinfo interface{} `json:"setlinfo"`
  23388. } `json:"output"`
  23389. RefmsgTime string `json:"refmsg_time"`
  23390. RespondTime string `json:"respond_time"`
  23391. Signtype interface{} `json:"signtype"`
  23392. WarnMsg interface{} `json:"warn_msg"`
  23393. }
  23394. type ResultSeventeen struct {
  23395. ErrMsg string `json:"err_msg"`
  23396. InfRefmsgid string `json:"inf_refmsgid"`
  23397. Infcode int64 `json:"infcode"`
  23398. Output struct {
  23399. SetlListId string `json:"setl_list_id"`
  23400. } `json:"output"`
  23401. RefmsgTime string `json:"refmsg_time"`
  23402. RespondTime string `json:"respond_time"`
  23403. Signtype string `json:"signtype"`
  23404. WarnInfo string `json:"warn_info"`
  23405. }
  23406. type ResultSeventeenOther struct {
  23407. ErrMsg string `json:"err_msg"`
  23408. InfRefmsgid string `json:"inf_refmsgid"`
  23409. Infcode string `json:"infcode"`
  23410. Output struct {
  23411. SetlListId string `json:"setl_list_id"`
  23412. } `json:"output"`
  23413. RefmsgTime string `json:"refmsg_time"`
  23414. RespondTime string `json:"respond_time"`
  23415. Signtype string `json:"signtype"`
  23416. WarnInfo string `json:"warn_info"`
  23417. }
  23418. type Result90991 struct {
  23419. ErrMsg string `json:"err_msg"`
  23420. InfRefmsgid string `json:"inf_refmsgid"`
  23421. Infcode int64 `json:"infcode"`
  23422. Output struct {
  23423. Result struct {
  23424. PsnNo string `json:"psn_no"`
  23425. CardStat string `json:"card_stat"`
  23426. Certno string `json:"certno"`
  23427. PsnName string `json:"psn_name"`
  23428. CheckStat string `json:"check_stat"`
  23429. SscnoCheckStat string `json:"sscno_check_stat"`
  23430. } `json:"result"`
  23431. } `json:"output"`
  23432. RefmsgTime string `json:"refmsg_time"`
  23433. RespondTime string `json:"respond_time"`
  23434. Signtype interface{} `json:"signtype"`
  23435. WarnInfo interface{} `json:"warn_info"`
  23436. }
  23437. type Result90100 struct {
  23438. ErrMsg string `json:"err_msg"`
  23439. InfRefmsgid string `json:"inf_refmsgid"`
  23440. Infcode int64 `json:"infcode"`
  23441. Output struct {
  23442. PoolareaNo string `json:"poolarea_no"`
  23443. PoolareaNoName string `json:"poolarea_no_name"`
  23444. Insutype string `json:"insutype"`
  23445. InsutypeName string `json:"insutype_name"`
  23446. ClctType string `json:"clct_type"`
  23447. ClctTypeName string `json:"clct_type_name"`
  23448. ClctFlag string `json:"clct_flag"`
  23449. ClctFlagName string `json:"clct_flag_name"`
  23450. AccrymBegn string `json:"accrym_begn"`
  23451. AccrymEnd string `json:"accrym_end"`
  23452. ClctTime string `json:"clct_time"`
  23453. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23454. } `json:"output"`
  23455. RefmsgTime string `json:"refmsg_time"`
  23456. RespondTime string `json:"respond_time"`
  23457. Signtype interface{} `json:"signtype"`
  23458. WarnInfo interface{} `json:"warn_info"`
  23459. }
  23460. type Custom struct {
  23461. DetItemFeeSumamt string
  23462. Cut string
  23463. FeedetlSn string
  23464. Price string
  23465. MedListCodg string
  23466. Type int64
  23467. AdviceId int64
  23468. ProjectId int64
  23469. ItemId int64
  23470. }
  23471. type Result5301 struct {
  23472. ErrMsg string `json:"err_msg"`
  23473. InfRefmsgid string `json:"inf_refmsgid"`
  23474. Infcode int64 `json:"infcode"`
  23475. Output struct {
  23476. Result []struct {
  23477. OpspDiseCode string `json:"opsp_dise_code"`
  23478. OpspDiseName string `json:"opsp_dise_name"`
  23479. Begndate string `json:"begndate"`
  23480. Enddate string `json:"enddate"`
  23481. } `json:"feedetail"`
  23482. } `json:"output"`
  23483. RefmsgTime string `json:"refmsg_time"`
  23484. RespondTime string `json:"respond_time"`
  23485. Signtype interface{} `json:"signtype"`
  23486. WarnInfo interface{} `json:"warn_info"`
  23487. }
  23488. type Result5301For10265 struct {
  23489. ErrMsg string `json:"err_msg"`
  23490. InfRefmsgid string `json:"inf_refmsgid"`
  23491. Infcode string `json:"infcode"`
  23492. Output struct {
  23493. Result []struct {
  23494. OpspDiseCode string `json:"opsp_dise_code"`
  23495. OpspDiseName string `json:"opsp_dise_name"`
  23496. Begndate string `json:"begndate"`
  23497. Enddate string `json:"enddate"`
  23498. } `json:"feedetail"`
  23499. } `json:"output"`
  23500. RefmsgTime string `json:"refmsg_time"`
  23501. RespondTime string `json:"respond_time"`
  23502. Signtype interface{} `json:"signtype"`
  23503. WarnInfo interface{} `json:"warn_info"`
  23504. }
  23505. //获取个人信息----挂号-----上传就诊信息
  23506. func (c *HisApiController) GetRegisterInfo() {
  23507. id, _ := c.GetInt64("id")
  23508. record_time := c.GetString("record_time")
  23509. settlementValue, _ := c.GetInt64("settlement_value")
  23510. medical_insurance_card := c.GetString("medical_insurance_card")
  23511. name := c.GetString("name")
  23512. id_card_type, _ := c.GetInt64("id_card_type")
  23513. certificates, _ := c.GetInt64("certificates")
  23514. medical_care, _ := c.GetInt64("medical_care")
  23515. birthday := c.GetString("birthday")
  23516. id_card := c.GetString("id_card")
  23517. register_type, _ := c.GetInt64("register")
  23518. doctor, _ := c.GetInt64("doctor")
  23519. department, _ := c.GetInt64("department")
  23520. gender, _ := c.GetInt64("sex")
  23521. registration_fee, _ := c.GetFloat("registration_fee")
  23522. medical_expenses, _ := c.GetFloat("medical_expenses")
  23523. social_type, _ := c.GetInt64("social_type")
  23524. admin_user_id, _ := c.GetInt64("admin_user_id")
  23525. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23526. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  23527. mdtrt_type := c.GetString("mdtrt_type")
  23528. if id_card_type == 5 {
  23529. id_card_type = 4
  23530. }
  23531. timeLayout := "2006-01-02"
  23532. loc, _ := time.LoadLocation("Local")
  23533. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23534. birthUnix := birthdays.Unix()
  23535. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23536. if err != nil {
  23537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23538. return
  23539. }
  23540. recordDateTime := theTime.Unix()
  23541. adminInfo := c.GetAdminUserInfo()
  23542. var patient service.Patients
  23543. if id == 0 {
  23544. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23545. } else {
  23546. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23547. }
  23548. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23549. if patientPrescription.ID == 0 {
  23550. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23551. }
  23552. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23553. if patient.ID == 0 {
  23554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23555. return
  23556. }
  23557. if len(patient.IdCardNo) == 0 {
  23558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23559. return
  23560. }
  23561. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23562. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23563. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23564. //就诊结算未完成,不能进行二次挂号
  23565. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23566. if len(his) >= 1 {
  23567. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23568. if len(his) >= 1 && order.ID == 0 {
  23569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23570. return
  23571. }
  23572. }
  23573. //var register_log string
  23574. if config.IsOpen == 1 {
  23575. var res ResultTwo
  23576. var res10265 ResultTwo10265
  23577. var PsnNo string
  23578. var PsnCertType string
  23579. var Certno string
  23580. var PsnName string
  23581. var Gend string
  23582. var Naty string
  23583. var Brdy string
  23584. var Age float64
  23585. var infoStr string
  23586. var idetinfoStr string
  23587. var infocode int64
  23588. var verify_number string
  23589. fmt.Println(verify_number)
  23590. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23591. psn_info, _ := service.GetPsnByPatientId(id)
  23592. PsnNo = psn_info.PsnNo
  23593. PsnCertType = psn_info.PsnCertType
  23594. Certno = psn_info.Certno
  23595. PsnName = psn_info.PsnName
  23596. Gend = psn_info.Gend
  23597. Naty = psn_info.Naty
  23598. Brdy = psn_info.Brdy
  23599. Age = psn_info.Age
  23600. infoStr = psn_info.Insuinfo
  23601. idetinfoStr = psn_info.Idetinfo
  23602. infocode = 0
  23603. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23604. psn_info, _ := service.GetPsnByPatientId(id)
  23605. PsnNo = psn_info.PsnNo
  23606. PsnCertType = psn_info.PsnCertType
  23607. Certno = psn_info.Certno
  23608. PsnName = psn_info.PsnName
  23609. Gend = psn_info.Gend
  23610. Naty = psn_info.Naty
  23611. Brdy = psn_info.Brdy
  23612. Age = psn_info.Age
  23613. infoStr = psn_info.Insuinfo
  23614. idetinfoStr = psn_info.Idetinfo
  23615. infocode = 0
  23616. verify_number = psn_info.VerifyNumber
  23617. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23618. if id_card_type == 2 {
  23619. //请求内网数据
  23620. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23621. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23622. "&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
  23623. resp, requestErr := http.Get(api)
  23624. if requestErr != nil {
  23625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23626. return
  23627. }
  23628. body, ioErr := ioutil.ReadAll(resp.Body)
  23629. if ioErr != nil {
  23630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23632. return
  23633. }
  23634. var respJSON map[string]interface{}
  23635. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23638. return
  23639. }
  23640. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23641. result_byte, _ := json.Marshal(respJSON)
  23642. result := string(result_byte)
  23643. var dat map[string]interface{}
  23644. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23645. fmt.Println(dat)
  23646. } else {
  23647. fmt.Println(err)
  23648. }
  23649. userJSONBytes, _ := json.Marshal(dat)
  23650. var res ResultTwo
  23651. var resTwo10265 ResultTwo10265
  23652. if miConfig.Code == "H15049901371" {
  23653. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23654. utils.ErrorLog("解析失败:%v", err)
  23655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23656. return
  23657. }
  23658. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23659. res.Infcode = Infcode
  23660. res.ErrMsg = resTwo10265.ErrMsg
  23661. res.Output = resTwo10265.Output
  23662. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23663. res.RespondTime = resTwo10265.RespondTime
  23664. res.WarnInfo = resTwo10265.WarnInfo
  23665. } else {
  23666. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23667. utils.ErrorLog("解析失败:%v", err)
  23668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23669. return
  23670. }
  23671. }
  23672. //var insutypes []string
  23673. //var insutype string
  23674. //var is390 int = 0
  23675. //var is310 int = 0
  23676. //for _, item := range res.Output.Iinfo {
  23677. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23678. // insutypes = append(insutypes, item.Insutype)
  23679. // }
  23680. //}
  23681. //if len(insutypes) == 1 {
  23682. // insutype = insutypes[0]
  23683. //} else {
  23684. // for _, i := range insutypes {
  23685. // if i == "390" {
  23686. // is390 = 1
  23687. // }
  23688. //
  23689. // if i == "310" {
  23690. // is310 = 1
  23691. // }
  23692. // }
  23693. //}
  23694. //if is390 == 1 {
  23695. // insutype = "390"
  23696. //}
  23697. //if is310 == 1 {
  23698. // insutype = "310"
  23699. //}
  23700. //if len(insutypes) == 0 {
  23701. // insutype = "310"
  23702. //}
  23703. PsnNo = res.Output.Baseinfo.PsnNo
  23704. PsnCertType = res.Output.Baseinfo.PsnCertType
  23705. Certno = res.Output.Baseinfo.Certno
  23706. PsnName = res.Output.Baseinfo.PsnName
  23707. Gend = res.Output.Baseinfo.Gend
  23708. Naty = res.Output.Baseinfo.Naty
  23709. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23710. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23711. infoStr = string(Iinfos)
  23712. idetinfoStr = string(Idetinfos)
  23713. infocode = res.Infcode
  23714. //infocode = 0
  23715. //verify_number = psn_info.VerifyNumber
  23716. } else {
  23717. psn_info, _ := service.GetPsnByPatientId(id)
  23718. PsnNo = psn_info.PsnNo
  23719. PsnCertType = psn_info.PsnCertType
  23720. Certno = psn_info.Certno
  23721. PsnName = psn_info.PsnName
  23722. Gend = psn_info.Gend
  23723. Naty = psn_info.Naty
  23724. Brdy = psn_info.Brdy
  23725. Age = psn_info.Age
  23726. infoStr = psn_info.Insuinfo
  23727. idetinfoStr = psn_info.Idetinfo
  23728. infocode = 0
  23729. verify_number = psn_info.VerifyNumber
  23730. }
  23731. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23732. if id_card_type == 1 {
  23733. psn_info, _ := service.GetPsnByPatientId(id)
  23734. PsnNo = psn_info.PsnNo
  23735. PsnCertType = psn_info.PsnCertType
  23736. Certno = psn_info.Certno
  23737. PsnName = psn_info.PsnName
  23738. Gend = psn_info.Gend
  23739. Naty = psn_info.Naty
  23740. Brdy = psn_info.Brdy
  23741. Age = psn_info.Age
  23742. infoStr = psn_info.Insuinfo
  23743. idetinfoStr = psn_info.Idetinfo
  23744. infocode = 0
  23745. verify_number = psn_info.VerifyNumber
  23746. } else if id_card_type == 2 {
  23747. 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)
  23748. fmt.Println(errMsgLog)
  23749. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23750. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23751. utils.ErrorLog("解析失败:%v", err)
  23752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23753. return
  23754. }
  23755. PsnNo = res.Output.Baseinfo.PsnNo
  23756. PsnCertType = res.Output.Baseinfo.PsnCertType
  23757. Certno = res.Output.Baseinfo.Certno
  23758. PsnName = res.Output.Baseinfo.PsnName
  23759. Gend = res.Output.Baseinfo.Gend
  23760. Naty = res.Output.Baseinfo.Naty
  23761. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23762. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23763. infoStr = string(Iinfos)
  23764. idetinfoStr = string(Idetinfos)
  23765. infocode = res.Infcode
  23766. }
  23767. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23768. if id_card_type == 1 {
  23769. psn_info, _ := service.GetPsnByPatientId(id)
  23770. PsnNo = psn_info.PsnNo
  23771. PsnCertType = psn_info.PsnCertType
  23772. Certno = psn_info.Certno
  23773. PsnName = psn_info.PsnName
  23774. Gend = psn_info.Gend
  23775. Naty = psn_info.Naty
  23776. Brdy = psn_info.Brdy
  23777. Age = psn_info.Age
  23778. infoStr = psn_info.Insuinfo
  23779. idetinfoStr = psn_info.Idetinfo
  23780. infocode = 0
  23781. verify_number = psn_info.VerifyNumber
  23782. } else if id_card_type == 2 {
  23783. 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, "")
  23784. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23785. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23786. utils.ErrorLog("解析失败:%v", err)
  23787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23788. return
  23789. }
  23790. PsnNo = res.Output.Baseinfo.PsnNo
  23791. PsnCertType = res.Output.Baseinfo.PsnCertType
  23792. Certno = res.Output.Baseinfo.Certno
  23793. PsnName = res.Output.Baseinfo.PsnName
  23794. Gend = res.Output.Baseinfo.Gend
  23795. Naty = res.Output.Baseinfo.Naty
  23796. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23797. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23798. infoStr = string(Iinfos)
  23799. idetinfoStr = string(Idetinfos)
  23800. infocode = res.Infcode
  23801. } else {
  23802. psn_info, _ := service.GetPsnByPatientId(id)
  23803. PsnNo = psn_info.PsnNo
  23804. PsnCertType = psn_info.PsnCertType
  23805. Certno = psn_info.Certno
  23806. PsnName = psn_info.PsnName
  23807. Gend = psn_info.Gend
  23808. Naty = psn_info.Naty
  23809. Brdy = psn_info.Brdy
  23810. Age = psn_info.Age
  23811. infoStr = psn_info.Insuinfo
  23812. idetinfoStr = psn_info.Idetinfo
  23813. infocode = 0
  23814. verify_number = psn_info.VerifyNumber
  23815. }
  23816. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23817. if id_card_type == 1 {
  23818. psn_info, _ := service.GetPsnByPatientId(id)
  23819. PsnNo = psn_info.PsnNo
  23820. PsnCertType = psn_info.PsnCertType
  23821. Certno = psn_info.Certno
  23822. PsnName = psn_info.PsnName
  23823. Gend = psn_info.Gend
  23824. Naty = psn_info.Naty
  23825. Brdy = psn_info.Brdy
  23826. Age = psn_info.Age
  23827. infoStr = psn_info.Insuinfo
  23828. idetinfoStr = psn_info.Idetinfo
  23829. infocode = 0
  23830. verify_number = psn_info.VerifyNumber
  23831. } else if id_card_type == 2 {
  23832. psn_info, _ := service.GetPsnByPatientId(id)
  23833. PsnNo = psn_info.PsnNo
  23834. PsnCertType = psn_info.PsnCertType
  23835. Certno = psn_info.Certno
  23836. PsnName = psn_info.PsnName
  23837. Gend = psn_info.Gend
  23838. Naty = psn_info.Naty
  23839. Brdy = psn_info.Brdy
  23840. Age = psn_info.Age
  23841. infoStr = psn_info.Insuinfo
  23842. idetinfoStr = psn_info.Idetinfo
  23843. infocode = 0
  23844. verify_number = psn_info.VerifyNumber
  23845. } else {
  23846. psn_info, _ := service.GetPsnByPatientId(id)
  23847. PsnNo = psn_info.PsnNo
  23848. PsnCertType = psn_info.PsnCertType
  23849. Certno = psn_info.Certno
  23850. PsnName = psn_info.PsnName
  23851. Gend = psn_info.Gend
  23852. Naty = psn_info.Naty
  23853. Brdy = psn_info.Brdy
  23854. Age = psn_info.Age
  23855. infoStr = psn_info.Insuinfo
  23856. idetinfoStr = psn_info.Idetinfo
  23857. infocode = 0
  23858. verify_number = psn_info.VerifyNumber
  23859. }
  23860. } else if miConfig.MdtrtareaAdmvs == "360100" {
  23861. if id_card_type == 1 {
  23862. psn_info, _ := service.GetPsnByPatientId(id)
  23863. PsnNo = psn_info.PsnNo
  23864. PsnCertType = psn_info.PsnCertType
  23865. Certno = psn_info.Certno
  23866. PsnName = psn_info.PsnName
  23867. Gend = psn_info.Gend
  23868. Naty = psn_info.Naty
  23869. Brdy = psn_info.Brdy
  23870. Age = psn_info.Age
  23871. infoStr = psn_info.Insuinfo
  23872. idetinfoStr = psn_info.Idetinfo
  23873. infocode = 0
  23874. verify_number = psn_info.VerifyNumber
  23875. } else if id_card_type == 2 {
  23876. psn_info, _ := service.GetPsnByPatientId(id)
  23877. PsnNo = psn_info.PsnNo
  23878. PsnCertType = psn_info.PsnCertType
  23879. Certno = psn_info.Certno
  23880. PsnName = psn_info.PsnName
  23881. Gend = psn_info.Gend
  23882. Naty = psn_info.Naty
  23883. Brdy = psn_info.Brdy
  23884. Age = psn_info.Age
  23885. infoStr = psn_info.Insuinfo
  23886. idetinfoStr = psn_info.Idetinfo
  23887. infocode = 0
  23888. verify_number = psn_info.VerifyNumber
  23889. } else {
  23890. psn_info, _ := service.GetPsnByPatientId(id)
  23891. PsnNo = psn_info.PsnNo
  23892. PsnCertType = psn_info.PsnCertType
  23893. Certno = psn_info.Certno
  23894. PsnName = psn_info.PsnName
  23895. Gend = psn_info.Gend
  23896. Naty = psn_info.Naty
  23897. Brdy = psn_info.Brdy
  23898. Age = psn_info.Age
  23899. infoStr = psn_info.Insuinfo
  23900. idetinfoStr = psn_info.Idetinfo
  23901. infocode = 0
  23902. verify_number = psn_info.VerifyNumber
  23903. }
  23904. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23905. psn_info, _ := service.GetPsnByPatientId(id)
  23906. PsnNo = psn_info.PsnNo
  23907. PsnCertType = psn_info.PsnCertType
  23908. Certno = psn_info.Certno
  23909. PsnName = psn_info.PsnName
  23910. Gend = psn_info.Gend
  23911. Naty = psn_info.Naty
  23912. Brdy = psn_info.Brdy
  23913. Age = psn_info.Age
  23914. infoStr = psn_info.Insuinfo
  23915. idetinfoStr = psn_info.Idetinfo
  23916. infocode = 0
  23917. verify_number = psn_info.VerifyNumber
  23918. idetinfoStr = psn_info.Idetinfo
  23919. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23920. if id_card_type == 1 {
  23921. psn_info, _ := service.GetPsnByPatientId(id)
  23922. PsnNo = psn_info.PsnNo
  23923. PsnCertType = psn_info.PsnCertType
  23924. Certno = psn_info.Certno
  23925. PsnName = psn_info.PsnName
  23926. Gend = psn_info.Gend
  23927. Naty = psn_info.Naty
  23928. Brdy = psn_info.Brdy
  23929. Age = psn_info.Age
  23930. infoStr = psn_info.Insuinfo
  23931. idetinfoStr = psn_info.Idetinfo
  23932. infocode = 0
  23933. verify_number = psn_info.VerifyNumber
  23934. } else if id_card_type == 2 {
  23935. 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)
  23936. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23937. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23938. utils.ErrorLog("解析失败:%v", err)
  23939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23940. return
  23941. }
  23942. PsnNo = res.Output.Baseinfo.PsnNo
  23943. PsnCertType = res.Output.Baseinfo.PsnCertType
  23944. Certno = res.Output.Baseinfo.Certno
  23945. PsnName = res.Output.Baseinfo.PsnName
  23946. Gend = res.Output.Baseinfo.Gend
  23947. Naty = res.Output.Baseinfo.Naty
  23948. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23949. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23950. infoStr = string(Iinfos)
  23951. idetinfoStr = string(Idetinfos)
  23952. infocode = res.Infcode
  23953. } else if id_card_type == 4 {
  23954. psn_info, _ := service.GetPsnByPatientId(id)
  23955. PsnNo = psn_info.PsnNo
  23956. PsnCertType = psn_info.PsnCertType
  23957. Certno = psn_info.Certno
  23958. PsnName = psn_info.PsnName
  23959. Gend = psn_info.Gend
  23960. Naty = psn_info.Naty
  23961. Brdy = psn_info.Brdy
  23962. Age = psn_info.Age
  23963. infoStr = psn_info.Insuinfo
  23964. idetinfoStr = psn_info.Idetinfo
  23965. infocode = 0
  23966. verify_number = psn_info.VerifyNumber
  23967. }
  23968. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23969. var result string
  23970. var requestLog string
  23971. 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), "")
  23972. if id_card_type == 4 {
  23973. psn_info, _ := service.GetPsnByPatientId(id)
  23974. PsnNo = psn_info.PsnNo
  23975. PsnCertType = psn_info.PsnCertType
  23976. Certno = psn_info.Certno
  23977. PsnName = psn_info.PsnName
  23978. Gend = psn_info.Gend
  23979. Naty = psn_info.Naty
  23980. Brdy = psn_info.Brdy
  23981. Age = psn_info.Age
  23982. infoStr = psn_info.Insuinfo
  23983. idetinfoStr = psn_info.Idetinfo
  23984. infocode = 0
  23985. verify_number = psn_info.VerifyNumber
  23986. } else {
  23987. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23988. if miConfig.Code == "H15049901371" {
  23989. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23990. utils.ErrorLog("解析失败:%v", err)
  23991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23992. return
  23993. }
  23994. res.ErrMsg = res10265.ErrMsg
  23995. res.Output = res10265.Output
  23996. res.InfRefmsgid = res10265.InfRefmsgid
  23997. } else {
  23998. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23999. utils.ErrorLog("解析失败:%v", err)
  24000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24001. return
  24002. }
  24003. }
  24004. PsnNo = res.Output.Baseinfo.PsnNo
  24005. PsnCertType = res.Output.Baseinfo.PsnCertType
  24006. Certno = res.Output.Baseinfo.Certno
  24007. PsnName = res.Output.Baseinfo.PsnName
  24008. Gend = res.Output.Baseinfo.Gend
  24009. Naty = res.Output.Baseinfo.Naty
  24010. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24011. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24012. infoStr = string(Iinfos)
  24013. idetinfoStr = string(Idetinfos)
  24014. if miConfig.Code == "H15049901371" {
  24015. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24016. } else {
  24017. infocode = res.Infcode
  24018. }
  24019. }
  24020. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24021. psn_info, _ := service.GetPsnByPatientId(id)
  24022. PsnNo = psn_info.PsnNo
  24023. PsnCertType = psn_info.PsnCertType
  24024. Certno = psn_info.Certno
  24025. PsnName = psn_info.PsnName
  24026. Gend = psn_info.Gend
  24027. Naty = psn_info.Naty
  24028. Brdy = psn_info.Brdy
  24029. Age = psn_info.Age
  24030. infoStr = psn_info.Insuinfo
  24031. idetinfoStr = psn_info.Idetinfo
  24032. infocode = 0
  24033. verify_number = psn_info.VerifyNumber
  24034. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24035. psn_info, _ := service.GetPsnByPatientId(id)
  24036. PsnNo = psn_info.PsnNo
  24037. PsnCertType = psn_info.PsnCertType
  24038. Certno = psn_info.Certno
  24039. PsnName = psn_info.PsnName
  24040. Gend = psn_info.Gend
  24041. Naty = psn_info.Naty
  24042. Brdy = psn_info.Brdy
  24043. Age = psn_info.Age
  24044. infoStr = psn_info.Insuinfo
  24045. idetinfoStr = psn_info.Idetinfo
  24046. infocode = 0
  24047. verify_number = psn_info.VerifyNumber
  24048. } else {
  24049. var result string
  24050. var requestLog string
  24051. //if miConfig.UserOrgId == 10138 {
  24052. if id_card_type != 4 || id_card_type != 1 {
  24053. var insa string
  24054. if len(patient.InsuplcAdmdvs) > 0 {
  24055. insa = patient.InsuplcAdmdvs
  24056. } else {
  24057. insa = miConfig.InsuplcAdmdvs
  24058. }
  24059. //psn_info, _ := service.GetPsnByPatientId(id)
  24060. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  24061. 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)
  24062. }
  24063. //}
  24064. //else {
  24065. // var insa string
  24066. // if len(patient.InsuplcAdmdvs) > 0 {
  24067. // insa = patient.InsuplcAdmdvs
  24068. // } else {
  24069. // insa = miConfig.InsuplcAdmdvs
  24070. // }
  24071. // 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)
  24072. //}
  24073. if id_card_type == 4 || id_card_type == 1 {
  24074. psn_info, _ := service.GetPsnByPatientId(id)
  24075. PsnNo = psn_info.PsnNo
  24076. PsnCertType = psn_info.PsnCertType
  24077. Certno = psn_info.Certno
  24078. PsnName = psn_info.PsnName
  24079. Gend = psn_info.Gend
  24080. Naty = psn_info.Naty
  24081. Brdy = psn_info.Brdy
  24082. Age = psn_info.Age
  24083. infoStr = psn_info.Insuinfo
  24084. idetinfoStr = psn_info.Idetinfo
  24085. infocode = 0
  24086. verify_number = psn_info.VerifyNumber
  24087. } else {
  24088. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24089. if miConfig.Code == "H15049901371" {
  24090. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24091. utils.ErrorLog("解析失败:%v", err)
  24092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24093. return
  24094. }
  24095. res.ErrMsg = res10265.ErrMsg
  24096. res.Output = res10265.Output
  24097. res.InfRefmsgid = res10265.InfRefmsgid
  24098. } else {
  24099. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24100. utils.ErrorLog("解析失败:%v", err)
  24101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24102. return
  24103. }
  24104. }
  24105. PsnNo = res.Output.Baseinfo.PsnNo
  24106. PsnCertType = res.Output.Baseinfo.PsnCertType
  24107. Certno = res.Output.Baseinfo.Certno
  24108. PsnName = res.Output.Baseinfo.PsnName
  24109. Gend = res.Output.Baseinfo.Gend
  24110. Naty = res.Output.Baseinfo.Naty
  24111. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24112. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24113. infoStr = string(Iinfos)
  24114. idetinfoStr = string(Idetinfos)
  24115. if miConfig.Code == "H15049901371" {
  24116. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24117. } else {
  24118. infocode = res.Infcode
  24119. }
  24120. }
  24121. }
  24122. if infocode == 0 {
  24123. his := models.VMHisPatient{
  24124. Name: name,
  24125. Gender: gender,
  24126. Birthday: birthUnix,
  24127. MedicalTreatmentType: medical_care,
  24128. IdType: certificates,
  24129. IdCardNo: id_card,
  24130. BalanceAccountsType: settlementValue,
  24131. SocialType: social_type,
  24132. MedicalInsuranceNumber: medical_insurance_card,
  24133. RegisterType: register_type,
  24134. RegisterCost: registration_fee,
  24135. TreatmentCost: medical_expenses,
  24136. Status: 1,
  24137. Ctime: time.Now().Unix(),
  24138. Mtime: time.Now().Unix(),
  24139. PsnNo: PsnNo,
  24140. PsnCertType: PsnCertType,
  24141. Certno: Certno,
  24142. PsnName: PsnName,
  24143. Gend: Gend,
  24144. Naty: Naty,
  24145. Brdy: Brdy,
  24146. Age: Age,
  24147. Iinfo: infoStr,
  24148. Idetinfo: idetinfoStr,
  24149. PatientId: patient.ID,
  24150. RecordDate: theTime.Unix(),
  24151. UserOrgId: adminInfo.CurrentOrgId,
  24152. AdminUserId: admin_user_id,
  24153. IsReturn: 1,
  24154. IdCardType: id_card_type,
  24155. Doctor: doctor,
  24156. Departments: department,
  24157. MdtrtGrpType: mdtrt_type,
  24158. }
  24159. timestamp := time.Now().Unix()
  24160. tempTime := time.Unix(timestamp, 0)
  24161. timeFormat := tempTime.Format("20060102150405")
  24162. chrgBchno := rand.Intn(100000) + 10000
  24163. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  24164. his.Number = ipt_otp_no
  24165. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  24166. department, _ := service.GetDepartMentDetail(department)
  24167. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  24168. IdCardNo := ""
  24169. if id_card_type == 1 {
  24170. // IdCardNo = medical_insurance_card
  24171. IdCardNo = patient.IdCardNo
  24172. } else {
  24173. IdCardNo = patient.IdCardNo
  24174. }
  24175. var rf []*ResultFive
  24176. json.Unmarshal([]byte(his.Iinfo), &rf)
  24177. var insutypes []*ResultFive
  24178. var insutype string
  24179. var insuplc_admdvs_temp string
  24180. var is390 int = 0
  24181. var is310 int = 0
  24182. for _, item := range rf {
  24183. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24184. insutypes = append(insutypes, item)
  24185. }
  24186. }
  24187. if len(insutypes) == 1 {
  24188. insutype = insutypes[0].Insutype
  24189. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24190. if insutype == "390" {
  24191. is390 = 1
  24192. }
  24193. if insutype == "310" {
  24194. is310 = 1
  24195. }
  24196. } else {
  24197. for _, i := range insutypes {
  24198. if i.Insutype == "390" {
  24199. is390 = 1
  24200. }
  24201. if i.Insutype == "310" {
  24202. is310 = 1
  24203. }
  24204. }
  24205. }
  24206. if is390 == 1 {
  24207. insutype = "390"
  24208. }
  24209. if is310 == 1 {
  24210. insutype = "310"
  24211. }
  24212. fmt.Println(social_type)
  24213. if social_type > 0 {
  24214. insutype = strconv.FormatInt(social_type, 10)
  24215. }
  24216. var infocode int64
  24217. var resThree ResultThree
  24218. var resThree10265 ResultThree10265
  24219. if len(insuplc_admdvs) == 0 {
  24220. psn_info, _ := service.GetPsnByPatientId(id)
  24221. //if len(psn_info.InsuplcAdmdvs) > 0 {
  24222. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24223. //}
  24224. } else {
  24225. insuplc_admdvs_temp = insuplc_admdvs
  24226. }
  24227. if miConfig.MdtrtareaAdmvs == "421300" {
  24228. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24229. psn_info, _ := service.GetPsnByPatientId(id)
  24230. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24231. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24232. "&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
  24233. resp, requestErr := http.Get(api)
  24234. if requestErr != nil {
  24235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24236. return
  24237. }
  24238. body, ioErr := ioutil.ReadAll(resp.Body)
  24239. if ioErr != nil {
  24240. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24242. return
  24243. }
  24244. var respJSON map[string]interface{}
  24245. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24248. return
  24249. }
  24250. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24251. result, _ := json.Marshal(respJSON)
  24252. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24253. utils.ErrorLog("解析失败:%v", err)
  24254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24255. return
  24256. }
  24257. infocode = resThree.Infcode
  24258. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24259. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24260. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24261. // insuplc_admdvs_temp =
  24262. //}
  24263. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24264. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24265. //}
  24266. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24267. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24268. "&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
  24269. resp, requestErr := http.Get(api)
  24270. if requestErr != nil {
  24271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24272. return
  24273. }
  24274. body, ioErr := ioutil.ReadAll(resp.Body)
  24275. if ioErr != nil {
  24276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24278. return
  24279. }
  24280. var respJSON map[string]interface{}
  24281. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24284. return
  24285. }
  24286. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24287. result, _ := json.Marshal(respJSON)
  24288. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24289. utils.ErrorLog("解析失败:%v", err)
  24290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24291. return
  24292. }
  24293. infocode = resThree.Infcode
  24294. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24295. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24296. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24297. // insuplc_admdvs_temp =
  24298. //}
  24299. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24300. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24301. //}
  24302. utils.ErrorLog("解析失败:%v", insutype)
  24303. utils.ErrorLog("解析失败:%v", PsnNo)
  24304. utils.ErrorLog("解析失败:%v", Certno)
  24305. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  24306. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  24307. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  24308. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  24309. utils.ErrorLog("解析失败:%v", PsnNo)
  24310. utils.ErrorLog("解析失败:%v", department.Number)
  24311. utils.ErrorLog("解析失败:%v", department.Name)
  24312. utils.ErrorLog("解析失败:%v", roles.UserName)
  24313. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24314. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24315. "&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
  24316. resp, requestErr := http.Get(api)
  24317. if requestErr != nil {
  24318. utils.ErrorLog("解析失败:%v", requestErr)
  24319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24320. return
  24321. }
  24322. body, ioErr := ioutil.ReadAll(resp.Body)
  24323. if ioErr != nil {
  24324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24326. return
  24327. }
  24328. var respJSON map[string]interface{}
  24329. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24332. return
  24333. }
  24334. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24335. result, _ := json.Marshal(respJSON)
  24336. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24337. utils.ErrorLog("解析失败:%v", err)
  24338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24339. return
  24340. }
  24341. infocode = resThree.Infcode
  24342. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24343. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24344. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24345. // insuplc_admdvs_temp =
  24346. //}
  24347. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24348. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24349. //}
  24350. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24351. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24352. "&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
  24353. resp, requestErr := http.Get(api)
  24354. if requestErr != nil {
  24355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24356. return
  24357. }
  24358. body, ioErr := ioutil.ReadAll(resp.Body)
  24359. if ioErr != nil {
  24360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24362. return
  24363. }
  24364. var respJSON map[string]interface{}
  24365. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24368. return
  24369. }
  24370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24371. result, _ := json.Marshal(respJSON)
  24372. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24373. utils.ErrorLog("解析失败:%v", err)
  24374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24375. return
  24376. }
  24377. infocode = resThree.Infcode
  24378. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24379. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24380. psn_info, _ := service.GetPsnByPatientId(id)
  24381. var verify_number string
  24382. if id_card_type == 4 {
  24383. verify_number = psn_info.VerifyNumber
  24384. } else if id_card_type == 1 {
  24385. bas := strings.Split(psn_info.CardInfo, "|")
  24386. cardNumber := bas[2]
  24387. verify_number = cardNumber
  24388. }
  24389. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24390. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24391. "&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
  24392. resp, requestErr := http.Get(api)
  24393. if requestErr != nil {
  24394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24395. return
  24396. }
  24397. body, ioErr := ioutil.ReadAll(resp.Body)
  24398. if ioErr != nil {
  24399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24401. return
  24402. }
  24403. var respJSON map[string]interface{}
  24404. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24407. return
  24408. }
  24409. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24410. result, _ := json.Marshal(respJSON)
  24411. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24412. // utils.ErrorLog("解析失败:%v", err)
  24413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24414. // return
  24415. //}
  24416. //infocode = resThree.Infcode
  24417. //result, _ := json.Marshal(respJSON)
  24418. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24419. utils.ErrorLog("解析失败:%v", err)
  24420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24421. return
  24422. }
  24423. resThree.ErrMsg = resThree10265.ErrMsg
  24424. resThree.Output = resThree10265.Output
  24425. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24426. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24427. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24428. psn_info, _ := service.GetPsnByPatientId(id)
  24429. his.PsnNo = psn_info.PsnNo
  24430. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24431. var cert_no string
  24432. if id_card_type == 3 {
  24433. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  24434. cert_no = IdCardNo
  24435. } else if id_card_type == 4 {
  24436. cert_no = IdCardNo
  24437. psn_info.VerifyNumber = psn_info.VerifyNumber
  24438. } else {
  24439. bas := strings.Split(psn_info.CardInfo, "|")
  24440. cert_no = bas[2]
  24441. }
  24442. var hisPrescription []*models.HisPrescription
  24443. for _, item := range rf {
  24444. if item.Insutype == insutype {
  24445. //insuplc_admdvs = item.InsuplcAdmdvs
  24446. his.InsuplcAdmdvs = insuplc_admdvs
  24447. }
  24448. }
  24449. his.Insutype = insutype
  24450. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24451. fmt.Println(res3101)
  24452. fmt.Println(res3101.Infcode)
  24453. if res3101.Infcode == "0" {
  24454. fmt.Println("33333333")
  24455. if len(res3101.Output.Result) > 0 {
  24456. fmt.Println("222222")
  24457. for _, item := range res3101.Output.Result {
  24458. if len(res3101.ErrMsg) == 0 {
  24459. res3101.ErrMsg = item.VolaCont
  24460. } else {
  24461. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24462. }
  24463. }
  24464. c.ServeSuccessJSON(map[string]interface{}{
  24465. "failed_code": -10,
  24466. "msg": res3101.ErrMsg,
  24467. })
  24468. return
  24469. } else {
  24470. fmt.Println("11111")
  24471. var api string
  24472. if miConfig.MdtrtareaAdmvs == "320921" {
  24473. ipt_otp_no = timeFormat
  24474. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24475. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24476. "&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
  24477. } else {
  24478. ipt_otp_no = timeFormat
  24479. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24480. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24481. "&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
  24482. }
  24483. resp, requestErr := http.Get(api)
  24484. if requestErr != nil {
  24485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24486. return
  24487. }
  24488. body, ioErr := ioutil.ReadAll(resp.Body)
  24489. if ioErr != nil {
  24490. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24492. return
  24493. }
  24494. var respJSON map[string]interface{}
  24495. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24498. return
  24499. }
  24500. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24501. result, _ := json.Marshal(respJSON)
  24502. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24503. utils.ErrorLog("解析失败:%v", err)
  24504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24505. return
  24506. }
  24507. resThree.ErrMsg = resThree10265.ErrMsg
  24508. resThree.Output = resThree10265.Output
  24509. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24510. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24511. }
  24512. } else if res3101.Infcode != "0" {
  24513. c.ServeSuccessJSON(map[string]interface{}{
  24514. "failed_code": -10,
  24515. "msg": res3101.ErrMsg,
  24516. })
  24517. return
  24518. }
  24519. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24520. psn_info, _ := service.GetPsnByPatientId(id)
  24521. var cert_no string
  24522. if id_card_type == 1 {
  24523. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24524. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24525. } else if id_card_type == 4 {
  24526. cert_no = psn_info.VerifyNumber
  24527. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24528. } else {
  24529. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24530. cert_no = psn_info.VerifyNumber
  24531. }
  24532. 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)
  24533. saveLog(result, requestLog, "2201", "挂号")
  24534. if miConfig.Code == "H15049901371" {
  24535. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24536. utils.ErrorLog("解析失败:%v", err)
  24537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24538. return
  24539. }
  24540. resThree.ErrMsg = resThree10265.ErrMsg
  24541. resThree.Output = resThree10265.Output
  24542. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24543. } else {
  24544. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24545. utils.ErrorLog("解析失败:%v", err)
  24546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24547. return
  24548. }
  24549. }
  24550. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24551. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24552. psn_info, _ := service.GetPsnByPatientId(id)
  24553. var result string
  24554. var requestLog string
  24555. if id_card_type == 1 {
  24556. bas := strings.Split(psn_info.CardInfo, "|")
  24557. basNumber := bas[2]
  24558. card_sn := bas[3]
  24559. 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)
  24560. saveLog(result, requestLog, "2201A", "挂号")
  24561. } else if id_card_type == 2 {
  24562. 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, "", "", "", "", "", "")
  24563. saveLog(result, requestLog, "2201A", "挂号")
  24564. } else {
  24565. 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)
  24566. saveLog(result, requestLog, "2201A", "挂号")
  24567. }
  24568. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24569. utils.ErrorLog("解析失败:%v", err)
  24570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24571. return
  24572. }
  24573. infocode = resThree.Infcode
  24574. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24575. psn_info, _ := service.GetPsnByPatientId(id)
  24576. var result string
  24577. var requestLog string
  24578. if id_card_type == 1 {
  24579. bas := strings.Split(psn_info.CardInfo, "|")
  24580. basNumber := bas[2]
  24581. card_sn := ""
  24582. 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)
  24583. saveLog(result, requestLog, "2201A", "挂号")
  24584. } else if id_card_type == 2 {
  24585. 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, "", "", "", "", "", "")
  24586. saveLog(result, requestLog, "2201A", "挂号")
  24587. } else {
  24588. 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)
  24589. saveLog(result, requestLog, "2201A", "挂号")
  24590. }
  24591. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24592. utils.ErrorLog("解析失败:%v", err)
  24593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24594. return
  24595. }
  24596. infocode = resThree.Infcode
  24597. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  24598. psn_info, _ := service.GetPsnByPatientId(id)
  24599. var result string
  24600. var requestLog string
  24601. if id_card_type == 1 {
  24602. bas := strings.Split(psn_info.CardInfo, "|")
  24603. basNumber := bas[2]
  24604. card_sn := ""
  24605. 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)
  24606. saveLog(result, requestLog, "2201A", "挂号")
  24607. } else if id_card_type == 2 {
  24608. 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, "", "", "", "", "", "")
  24609. saveLog(result, requestLog, "2201A", "挂号")
  24610. } else {
  24611. 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)
  24612. saveLog(result, requestLog, "2201A", "挂号")
  24613. }
  24614. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24615. utils.ErrorLog("解析失败:%v", err)
  24616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24617. return
  24618. }
  24619. infocode = resThree.Infcode
  24620. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24621. psn_info, _ := service.GetPsnByPatientId(id)
  24622. his.PsnNo = psn_info.PsnNo
  24623. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24624. var cert_no string
  24625. if id_card_type == 1 {
  24626. bas := strings.Split(psn_info.CardInfo, "|")
  24627. cert_no = bas[2]
  24628. } else if id_card_type == 4 {
  24629. cert_no = psn_info.VerifyNumber
  24630. psn_info.VerifyNumber = psn_info.VerifyNumber
  24631. IdCardNo = psn_info.VerifyNumber
  24632. } else {
  24633. cert_no = IdCardNo
  24634. psn_info.VerifyNumber = cert_no
  24635. }
  24636. for _, item := range rf {
  24637. if item.Insutype == insutype {
  24638. his.InsuplcAdmdvs = insuplc_admdvs
  24639. }
  24640. }
  24641. his.Insutype = insutype
  24642. var api string
  24643. ipt_otp_no = timeFormat
  24644. 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 +
  24645. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24646. "&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
  24647. resp, requestErr := http.Get(api)
  24648. if requestErr != nil {
  24649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24650. return
  24651. }
  24652. body, ioErr := ioutil.ReadAll(resp.Body)
  24653. if ioErr != nil {
  24654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24656. return
  24657. }
  24658. var respJSON map[string]interface{}
  24659. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24662. return
  24663. }
  24664. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24665. if status == "0" {
  24666. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24667. c.ServeSuccessJSON(map[string]interface{}{
  24668. "failed_code": -10,
  24669. "msg": err_msg,
  24670. })
  24671. return
  24672. }
  24673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24674. result, _ := json.Marshal(respJSON)
  24675. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24676. utils.ErrorLog("解析失败:%v", err)
  24677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24678. return
  24679. }
  24680. infocode = resThree.Infcode
  24681. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24682. psn_info, _ := service.GetPsnByPatientId(id)
  24683. his.PsnNo = psn_info.PsnNo
  24684. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24685. var cert_no string
  24686. if id_card_type == 1 {
  24687. bas := strings.Split(psn_info.CardInfo, "|")
  24688. cert_no = bas[2]
  24689. } else if id_card_type == 4 {
  24690. cert_no = psn_info.VerifyNumber
  24691. psn_info.VerifyNumber = psn_info.VerifyNumber
  24692. IdCardNo = psn_info.VerifyNumber
  24693. } else {
  24694. cert_no = IdCardNo
  24695. psn_info.VerifyNumber = cert_no
  24696. }
  24697. for _, item := range rf {
  24698. if item.Insutype == insutype {
  24699. his.InsuplcAdmdvs = insuplc_admdvs
  24700. patient.InsuplcAdmdvs = insuplc_admdvs
  24701. }
  24702. }
  24703. his.Insutype = insutype
  24704. var api string
  24705. ipt_otp_no = timeFormat
  24706. 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 +
  24707. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24708. "&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
  24709. resp, requestErr := http.Get(api)
  24710. if requestErr != nil {
  24711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24712. return
  24713. }
  24714. body, ioErr := ioutil.ReadAll(resp.Body)
  24715. if ioErr != nil {
  24716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24718. return
  24719. }
  24720. var respJSON map[string]interface{}
  24721. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24724. return
  24725. }
  24726. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24727. if status == "0" {
  24728. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24729. c.ServeSuccessJSON(map[string]interface{}{
  24730. "failed_code": -10,
  24731. "msg": err_msg,
  24732. })
  24733. return
  24734. }
  24735. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24736. result, _ := json.Marshal(respJSON)
  24737. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24738. utils.ErrorLog("解析失败:%v", err)
  24739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24740. return
  24741. }
  24742. infocode = resThree.Infcode
  24743. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24744. psn_info, _ := service.GetPsnByPatientId(id)
  24745. var result string
  24746. var requestLog string
  24747. if id_card_type == 1 {
  24748. bas := strings.Split(psn_info.CardInfo, "|")
  24749. basNumber := bas[2]
  24750. card_sn := bas[3]
  24751. 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)
  24752. saveLog(result, requestLog, "2201A", "挂号")
  24753. } else if id_card_type == 2 {
  24754. 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, "", "")
  24755. saveLog(result, requestLog, "2201A", "挂号")
  24756. } else {
  24757. 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, "", "")
  24758. saveLog(result, requestLog, "2201A", "挂号")
  24759. }
  24760. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24761. utils.ErrorLog("解析失败:%v", err)
  24762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24763. return
  24764. }
  24765. infocode = resThree.Infcode
  24766. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24767. psn_info, _ := service.GetPsnByPatientId(id)
  24768. 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)
  24769. saveLog(result, requestLog, "2201A", "挂号")
  24770. if miConfig.Code == "H15049901371" {
  24771. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24772. utils.ErrorLog("解析失败:%v", err)
  24773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24774. return
  24775. }
  24776. resThree.ErrMsg = resThree10265.ErrMsg
  24777. resThree.Output = resThree10265.Output
  24778. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24779. } else {
  24780. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24781. utils.ErrorLog("解析失败:%v", err)
  24782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24783. return
  24784. }
  24785. }
  24786. if miConfig.Code == "H15049901371" {
  24787. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24788. } else {
  24789. infocode = resThree.Infcode
  24790. }
  24791. } else {
  24792. psn_info, _ := service.GetPsnByPatientId(id)
  24793. if id_card_type == 4 || id_card_type == 1 {
  24794. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24795. }
  24796. var rf []*ResultFive
  24797. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24798. var insutypes []*ResultFive
  24799. var insutype string
  24800. var is390 int = 0
  24801. var is310 int = 0
  24802. for _, item := range rf {
  24803. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24804. insutypes = append(insutypes, item)
  24805. }
  24806. }
  24807. if len(insutypes) == 1 {
  24808. insutype = insutypes[0].Insutype
  24809. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24810. } else {
  24811. for _, i := range insutypes {
  24812. if i.Insutype == "390" {
  24813. is390 = 1
  24814. }
  24815. if i.Insutype == "310" {
  24816. is310 = 1
  24817. }
  24818. }
  24819. }
  24820. if is390 == 1 {
  24821. insutype = "390"
  24822. }
  24823. if is310 == 1 {
  24824. insutype = "310"
  24825. }
  24826. fmt.Println(len(insutypes))
  24827. if len(insutypes) == 0 {
  24828. for index, item := range rf {
  24829. if index == 0 {
  24830. insutype = item.Insutype
  24831. insuplc_admdvs = item.InsuplcAdmdvs
  24832. }
  24833. }
  24834. fmt.Println(insutype)
  24835. fmt.Println(insuplc_admdvs)
  24836. }
  24837. if social_type > 0 {
  24838. insutype = strconv.FormatInt(social_type, 10)
  24839. }
  24840. fmt.Println("--------")
  24841. fmt.Println(psn_info)
  24842. fmt.Println(psn_info.PsnNo)
  24843. if miConfig.MdtrtareaAdmvs == "441202" {
  24844. var hisPrescription []*models.HisPrescription
  24845. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24846. if res3101.Infcode == 0 {
  24847. fmt.Println("33333333")
  24848. if len(res3101.Output.Result) > 0 {
  24849. fmt.Println("222222")
  24850. for _, item := range res3101.Output.Result {
  24851. if len(res3101.ErrMsg) == 0 {
  24852. res3101.ErrMsg = item.VolaCont
  24853. } else {
  24854. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24855. }
  24856. }
  24857. c.ServeSuccessJSON(map[string]interface{}{
  24858. "failed_code": -10,
  24859. "msg": res3101.ErrMsg,
  24860. })
  24861. return
  24862. } else {
  24863. hour := time.Now().Format("15")
  24864. min := time.Now().Format("04")
  24865. sec := time.Now().Format("05")
  24866. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24867. fmt.Println(record_time_two)
  24868. 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)
  24869. saveLog(result, requestLog, "2201A", "挂号")
  24870. if miConfig.Code == "H15049901371" {
  24871. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24872. utils.ErrorLog("解析失败:%v", err)
  24873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24874. return
  24875. }
  24876. resThree.ErrMsg = resThree10265.ErrMsg
  24877. resThree.Output = resThree10265.Output
  24878. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24879. } else {
  24880. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24881. utils.ErrorLog("解析失败:%v", err)
  24882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24883. return
  24884. }
  24885. }
  24886. if miConfig.Code == "H15049901371" {
  24887. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24888. } else {
  24889. infocode = resThree.Infcode
  24890. }
  24891. }
  24892. } else if res3101.Infcode != 0 {
  24893. c.ServeSuccessJSON(map[string]interface{}{
  24894. "failed_code": -10,
  24895. "msg": res3101.ErrMsg,
  24896. })
  24897. return
  24898. }
  24899. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24900. var hisPrescription []*models.HisPrescription
  24901. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24902. if res3101.Infcode == 0 {
  24903. fmt.Println("33333333")
  24904. if len(res3101.Output.Result) > 0 {
  24905. fmt.Println("222222")
  24906. for _, item := range res3101.Output.Result {
  24907. if len(res3101.ErrMsg) == 0 {
  24908. res3101.ErrMsg = item.VolaCont
  24909. } else {
  24910. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24911. }
  24912. }
  24913. c.ServeSuccessJSON(map[string]interface{}{
  24914. "failed_code": -10,
  24915. "msg": res3101.ErrMsg,
  24916. })
  24917. return
  24918. } else {
  24919. hour := time.Now().Format("15")
  24920. min := time.Now().Format("04")
  24921. sec := time.Now().Format("05")
  24922. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24923. fmt.Println(record_time_two)
  24924. 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)
  24925. saveLog(result, requestLog, "2201A", "挂号")
  24926. if miConfig.Code == "H15049901371" {
  24927. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24928. utils.ErrorLog("解析失败:%v", err)
  24929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24930. return
  24931. }
  24932. resThree.ErrMsg = resThree10265.ErrMsg
  24933. resThree.Output = resThree10265.Output
  24934. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24935. } else {
  24936. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24937. utils.ErrorLog("解析失败:%v", err)
  24938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24939. return
  24940. }
  24941. }
  24942. if miConfig.Code == "H15049901371" {
  24943. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24944. } else {
  24945. infocode = resThree.Infcode
  24946. }
  24947. }
  24948. } else if res3101.Infcode != 0 {
  24949. c.ServeSuccessJSON(map[string]interface{}{
  24950. "failed_code": -10,
  24951. "msg": res3101.ErrMsg,
  24952. })
  24953. return
  24954. }
  24955. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24956. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24957. psn_info, _ := service.GetPsnByPatientId(id)
  24958. var verify_number string
  24959. if id_card_type == 4 {
  24960. verify_number = psn_info.VerifyNumber
  24961. } else if id_card_type == 1 {
  24962. bas := strings.Split(psn_info.CardInfo, "|")
  24963. cardNumber := bas[2]
  24964. verify_number = cardNumber
  24965. } else {
  24966. verify_number = psn_info.Certno
  24967. }
  24968. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24969. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24970. "&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
  24971. resp, requestErr := http.Get(api)
  24972. if requestErr != nil {
  24973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24974. return
  24975. }
  24976. body, ioErr := ioutil.ReadAll(resp.Body)
  24977. if ioErr != nil {
  24978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24980. return
  24981. }
  24982. var respJSON map[string]interface{}
  24983. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24986. return
  24987. }
  24988. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24989. result, _ := json.Marshal(respJSON)
  24990. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24991. utils.ErrorLog("解析失败:%v", err)
  24992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24993. return
  24994. }
  24995. infocode = resThree.Infcode
  24996. } else {
  24997. hour := time.Now().Format("15")
  24998. min := time.Now().Format("04")
  24999. sec := time.Now().Format("05")
  25000. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25001. if id_card_type == 1 {
  25002. for _, item := range rf {
  25003. if item.Insutype == strconv.FormatInt(social_type, 10) {
  25004. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  25005. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25006. } else if strconv.FormatInt(social_type, 10) == "390" {
  25007. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25008. } else {
  25009. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25010. }
  25011. }
  25012. }
  25013. }
  25014. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  25015. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25016. }
  25017. if id_card_type == 1 {
  25018. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  25019. bas := strings.Split(psn_info.CardInfo, "|")
  25020. basNumber := bas[1]
  25021. IdCardNo = basNumber
  25022. }
  25023. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  25024. IdCardNo = psn_info.VerifyNumber
  25025. }
  25026. if len(insuplc_admdvs_temp) == 0 {
  25027. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25028. }
  25029. var result string
  25030. var requestLog string
  25031. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" {
  25032. var hisPrescription []*models.HisPrescription
  25033. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25034. if res3101.Infcode == 0 {
  25035. if len(res3101.Output.Result) > 0 {
  25036. if len(res3101.Output.Result) > 0 {
  25037. c.ServeSuccessJSON(map[string]interface{}{
  25038. "failed_code": -10,
  25039. "failed_type": 100,
  25040. "warm_type": 1,
  25041. "msg": res3101,
  25042. })
  25043. return
  25044. } else {
  25045. c.ServeSuccessJSON(map[string]interface{}{
  25046. "failed_code": -10,
  25047. "msg": res3101.ErrMsg,
  25048. })
  25049. return
  25050. }
  25051. } else {
  25052. hour := time.Now().Format("15")
  25053. min := time.Now().Format("04")
  25054. sec := time.Now().Format("05")
  25055. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25056. fmt.Println(record_time_two)
  25057. if his.IdCardType == 2 {
  25058. IdCardNo = psn_info.Certno
  25059. psn_info.VerifyNumber = psn_info.Certno
  25060. } else if his.IdCardType == 4 {
  25061. IdCardNo = psn_info.Certno
  25062. } else {
  25063. bas := strings.Split(psn_info.CardInfo, "|")
  25064. IdCardNo = bas[2]
  25065. }
  25066. 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)
  25067. saveLog(result, requestLog, "2201A", "挂号")
  25068. if miConfig.Code == "H15049901371" {
  25069. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25070. utils.ErrorLog("解析失败:%v", err)
  25071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25072. return
  25073. }
  25074. resThree.ErrMsg = resThree10265.ErrMsg
  25075. resThree.Output = resThree10265.Output
  25076. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25077. } else {
  25078. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25079. utils.ErrorLog("解析失败:%v", err)
  25080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25081. return
  25082. }
  25083. }
  25084. if miConfig.Code == "H15049901371" {
  25085. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25086. } else {
  25087. infocode = resThree.Infcode
  25088. }
  25089. }
  25090. } else if res3101.Infcode != 0 {
  25091. c.ServeSuccessJSON(map[string]interface{}{
  25092. "failed_code": -10,
  25093. "msg": res3101.ErrMsg,
  25094. })
  25095. return
  25096. }
  25097. } else {
  25098. psn_info, _ := service.GetPsnByPatientId(id)
  25099. var rf []*ResultFive
  25100. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25101. //var insutypes []*ResultFive
  25102. var insutype string
  25103. var insutypes []*ResultFive
  25104. var is390 int = 0
  25105. var is310 int = 0
  25106. for _, item := range rf {
  25107. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25108. insutypes = append(insutypes, item)
  25109. }
  25110. }
  25111. if len(insutypes) == 1 {
  25112. insutype = insutypes[0].Insutype
  25113. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25114. } else {
  25115. for _, i := range insutypes {
  25116. if i.Insutype == "390" {
  25117. is390 = 1
  25118. }
  25119. if i.Insutype == "310" {
  25120. is310 = 1
  25121. }
  25122. }
  25123. }
  25124. if is390 == 1 {
  25125. insutype = "390"
  25126. }
  25127. if is310 == 1 {
  25128. insutype = "310"
  25129. }
  25130. if len(insutypes) == 0 {
  25131. insutype = "310"
  25132. }
  25133. if social_type > 0 {
  25134. insutype = strconv.FormatInt(social_type, 10)
  25135. }
  25136. for _, item := range rf {
  25137. if item.Insutype == insutype {
  25138. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25139. }
  25140. }
  25141. if len(insuplc_admdvs_tt) > 0{
  25142. insuplc_admdvs_temp = insuplc_admdvs_tt
  25143. }
  25144. 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)
  25145. saveLog(result, requestLog, "2201A", "挂号")
  25146. }
  25147. if miConfig.Code == "H15049901371" {
  25148. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25149. utils.ErrorLog("解析失败:%v", err)
  25150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25151. return
  25152. }
  25153. resThree.ErrMsg = resThree10265.ErrMsg
  25154. resThree.Output = resThree10265.Output
  25155. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25156. } else {
  25157. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25158. utils.ErrorLog("解析失败:%v", err)
  25159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25160. return
  25161. }
  25162. }
  25163. if miConfig.Code == "H15049901371" {
  25164. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25165. } else {
  25166. infocode = resThree.Infcode
  25167. }
  25168. }
  25169. }
  25170. if infocode == -1 {
  25171. adminUser := c.GetAdminUserInfo()
  25172. errlog := &models.HisOrderError{
  25173. UserOrgId: adminUser.CurrentOrgId,
  25174. Ctime: time.Now().Unix(),
  25175. Mtime: time.Now().Unix(),
  25176. ErrMsg: resThree.ErrMsg,
  25177. Status: 1,
  25178. PatientId: id,
  25179. RecordTime: recordDateTime,
  25180. Stage: 2,
  25181. }
  25182. service.CreateErrMsgLog(errlog)
  25183. c.ServeSuccessJSON(map[string]interface{}{
  25184. "failed_code": -10,
  25185. "msg": resThree.ErrMsg,
  25186. })
  25187. return
  25188. }
  25189. his.Number = resThree.Output.Data.MdtrtID
  25190. his.PsnNo = resThree.Output.Data.PsnNo
  25191. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  25192. his.IdCardNo = patient.IdCardNo
  25193. his.PhoneNumber = patient.Phone
  25194. his.UserOrgId = adminInfo.CurrentOrgId
  25195. his.Insutype = insutype
  25196. his.Ctime = time.Now().Unix()
  25197. his.Mtime = time.Now().Unix()
  25198. his.InsuplcAdmdvs = insuplc_admdvs_temp
  25199. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  25200. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25201. }
  25202. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  25203. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25204. }
  25205. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  25206. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25207. }
  25208. his.Status = 1
  25209. his.MdtrtGrpType = mdtrt_type
  25210. service.UpdateHisPatientStatus(&his)
  25211. service.UpdateHisPatient123(&patient)
  25212. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  25213. c.ServeSuccessJSON(map[string]interface{}{
  25214. "his_info": his,
  25215. })
  25216. } else {
  25217. adminUser := c.GetAdminUserInfo()
  25218. errlog := &models.HisOrderError{
  25219. UserOrgId: adminUser.CurrentOrgId,
  25220. Ctime: time.Now().Unix(),
  25221. Mtime: time.Now().Unix(),
  25222. ErrMsg: res.ErrMsg,
  25223. Status: 1,
  25224. PatientId: id,
  25225. RecordTime: recordDateTime,
  25226. Stage: 1,
  25227. }
  25228. service.CreateErrMsgLog(errlog)
  25229. c.ServeSuccessJSON(map[string]interface{}{
  25230. "failed_code": -10,
  25231. "msg": res.ErrMsg,
  25232. })
  25233. return
  25234. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  25235. }
  25236. }
  25237. }
  25238. func (c *HisApiController) GetUploadInfo() {
  25239. id, _ := c.GetInt64("id")
  25240. record_time := c.GetString("record_time")
  25241. his_patient_id, _ := c.GetInt64("his_patient_id")
  25242. order_id, _ := c.GetInt64("order_id")
  25243. pay_way, _ := c.GetInt64("pay_way")
  25244. pay_ways := c.GetString("pay_ways")
  25245. oth_desc := c.GetString("oth_desc")
  25246. pay_price, _ := c.GetFloat("pay_price")
  25247. pay_card_no := c.GetString("pay_card_no")
  25248. discount_price, _ := c.GetFloat("discount_price")
  25249. preferential_price, _ := c.GetFloat("preferential_price")
  25250. reality_price, _ := c.GetFloat("reality_price")
  25251. found_price, _ := c.GetFloat("found_price")
  25252. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  25253. private_price, _ := c.GetFloat("private_price")
  25254. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  25255. admin_user_id, _ := c.GetInt64("admin_user_id")
  25256. fapiao_code := c.GetString("fapiao_code")
  25257. fapiao_number := c.GetString("fapiao_number")
  25258. diagnosis_id := c.GetString("diagnosis")
  25259. sick_type, _ := c.GetInt64("sick_type")
  25260. reg_type, _ := c.GetInt64("p_type")
  25261. begin_time := c.GetString("begin_time")
  25262. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  25263. cash_pay := c.GetString("cash_pay")
  25264. band_card_pay := c.GetString("band_card_pay")
  25265. wechat_pay := c.GetString("wechat_pay")
  25266. ali_pay := c.GetString("ali_pay")
  25267. jifen_pay := c.GetString("jifen_pay")
  25268. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  25269. fmt.Println(acct_used_flag)
  25270. id_str := c.GetString("ids")
  25271. ids_arr := strings.Split(id_str, ",")
  25272. timeLayout := "2006-01-02"
  25273. loc, _ := time.LoadLocation("Local")
  25274. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25275. if err != nil {
  25276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25277. return
  25278. }
  25279. recordDateTime := theTime.Unix()
  25280. adminUser := c.GetAdminUserInfo()
  25281. var tempOrder models.HisOrder
  25282. tempOrder, _ = service.GetHisOrderByID(order_id)
  25283. var prescriptions []*models.HisPrescription
  25284. var start_time int64
  25285. var end_time int64
  25286. //押金模块
  25287. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  25288. tmp_decimal := c.GetString("tmp_decimal")
  25289. var decimal float64 //本次使用的押金
  25290. var errmsg error
  25291. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  25292. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  25293. return
  25294. }
  25295. if len(tmp_decimal) > 0 {
  25296. if tmp_decimal[0] == 45 {
  25297. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  25298. return
  25299. }
  25300. }
  25301. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  25302. fmt.Println(errs)
  25303. decimal = tt
  25304. //if adminUser.CurrentOrgId == 10106{
  25305. // if len(fapiao_code) == 0{
  25306. // fapiao_code = "144072080589"
  25307. // }
  25308. // if len(fapiao_number) == 0{
  25309. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  25310. // if order.ID == 0{
  25311. // fapiao_number = "00001520"
  25312. // }else{
  25313. // //fapiao_code = "00001520"
  25314. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  25315. // var zero string
  25316. // if fpNumber >= 1000{
  25317. // zero = "0000" + strconv.Itoa(fpNumber)
  25318. // }else if fpNumber >= 10000{
  25319. // zero = "000" + strconv.Itoa(fpNumber)
  25320. // } else if fpNumber >= 100000{
  25321. // zero = "00" + strconv.Itoa(fpNumber)
  25322. // } else if fpNumber >= 1000000{
  25323. // zero = "0" + strconv.Itoa(fpNumber)
  25324. // }else {
  25325. // zero = strconv.Itoa(fpNumber)
  25326. // }
  25327. // fapiao_number = zero
  25328. // }
  25329. // }
  25330. //}
  25331. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25332. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25333. var patientPrescription models.HisPrescriptionInfo
  25334. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25335. if patientPrescription.ID == 0 {
  25336. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  25337. }
  25338. //if patientPrescription.Do
  25339. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25340. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25341. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25342. diagnosis_ids := strings.Split(diagnosis_id, ",")
  25343. var config []*models.HisXtDiagnoseConfig
  25344. for _, item := range diagnosis_ids {
  25345. id, _ := strconv.ParseInt(item, 10, 64)
  25346. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25347. config = append(config, &diagnosisConfig)
  25348. }
  25349. sickConfig, _ := service.FindSickById(sick_type)
  25350. //if tempOrder.ID == 0 {
  25351. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  25352. //}
  25353. if tempOrder.ID == 0 {
  25354. var result string
  25355. var requestLog string
  25356. var res2 ResultSix
  25357. var res3 GZResultSix
  25358. var ressix10265 ResultSix10265
  25359. if miConfig.MdtrtareaAdmvs == "421300" {
  25360. data := make(map[string]interface{})
  25361. client := &http.Client{}
  25362. data["psn_no"] = his.PsnNo
  25363. data["mdtrt_id"] = his.Number
  25364. data["opter"] = roles.UserName
  25365. data["org_name"] = miConfig.OrgName
  25366. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25367. data["doctor_id"] = doctor_info.DoctorNumber
  25368. data["doctor_name"] = doctor_info.UserName
  25369. data["department"] = department.Name
  25370. data["fixmedins_code"] = miConfig.Code
  25371. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25372. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25373. data["secret_key"] = miConfig.SecretKey
  25374. data["sick_code"] = sickConfig.CountryCode
  25375. data["sick_name"] = sickConfig.ClassName
  25376. data["dept"] = strconv.FormatInt(department.ID, 10)
  25377. data["config"] = config
  25378. data["begin_time"] = begin_time
  25379. bytesData, _ := json.Marshal(data)
  25380. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25381. resp, _ := client.Do(req)
  25382. defer resp.Body.Close()
  25383. body, ioErr := ioutil.ReadAll(resp.Body)
  25384. if ioErr != nil {
  25385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25387. return
  25388. }
  25389. var respJSON map[string]interface{}
  25390. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25393. return
  25394. }
  25395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25396. userJSONBytes, _ := json.Marshal(respJSON)
  25397. fmt.Println("log")
  25398. fmt.Println(string(userJSONBytes))
  25399. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25400. utils.ErrorLog("解析失败:%v", err)
  25401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25402. return
  25403. }
  25404. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25405. data := make(map[string]interface{})
  25406. client := &http.Client{}
  25407. data["psn_no"] = his.PsnNo
  25408. data["mdtrt_id"] = his.Number
  25409. data["opter"] = roles.UserName
  25410. data["org_name"] = miConfig.OrgName
  25411. if reg_type == 11 && his.Insutype == "390" {
  25412. data["med_type"] = "110104"
  25413. } else {
  25414. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25415. }
  25416. data["doctor_id"] = doctor_info.DoctorNumber
  25417. data["doctor_name"] = doctor_info.UserName
  25418. data["department"] = department.Name
  25419. data["fixmedins_code"] = miConfig.Code
  25420. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25421. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25422. data["secret_key"] = miConfig.SecretKey
  25423. data["sick_code"] = sickConfig.CountryCode
  25424. data["sick_name"] = sickConfig.ClassName
  25425. data["dept"] = strconv.FormatInt(department.ID, 10)
  25426. data["config"] = config
  25427. data["begin_time"] = begin_time
  25428. bytesData, _ := json.Marshal(data)
  25429. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25430. resp, _ := client.Do(req)
  25431. defer resp.Body.Close()
  25432. body, ioErr := ioutil.ReadAll(resp.Body)
  25433. if ioErr != nil {
  25434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25436. return
  25437. }
  25438. var respJSON map[string]interface{}
  25439. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25442. return
  25443. }
  25444. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25445. userJSONBytes, _ := json.Marshal(respJSON)
  25446. fmt.Println("log")
  25447. fmt.Println(string(userJSONBytes))
  25448. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25449. utils.ErrorLog("解析失败:%v", err)
  25450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25451. return
  25452. }
  25453. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25454. data := make(map[string]interface{})
  25455. client := &http.Client{}
  25456. data["psn_no"] = his.PsnNo
  25457. data["mdtrt_id"] = his.Number
  25458. data["opter"] = roles.UserName
  25459. data["org_name"] = miConfig.OrgName
  25460. if reg_type == 11 && his.Insutype == "390" {
  25461. data["med_type"] = "110104"
  25462. } else {
  25463. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25464. }
  25465. data["doctor_id"] = doctor_info.DoctorNumber
  25466. data["doctor_name"] = doctor_info.UserName
  25467. data["department"] = department.Name
  25468. data["fixmedins_code"] = miConfig.Code
  25469. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25470. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25471. data["secret_key"] = miConfig.SecretKey
  25472. data["sick_code"] = sickConfig.CountryCode
  25473. data["sick_name"] = sickConfig.ClassName
  25474. data["dept"] = strconv.FormatInt(department.ID, 10)
  25475. data["config"] = config
  25476. data["begin_time"] = begin_time
  25477. bytesData, _ := json.Marshal(data)
  25478. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25479. resp, _ := client.Do(req)
  25480. defer resp.Body.Close()
  25481. body, ioErr := ioutil.ReadAll(resp.Body)
  25482. if ioErr != nil {
  25483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25485. return
  25486. }
  25487. var respJSON map[string]interface{}
  25488. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25491. return
  25492. }
  25493. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25494. userJSONBytes, _ := json.Marshal(respJSON)
  25495. fmt.Println("log")
  25496. fmt.Println(string(userJSONBytes))
  25497. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25498. utils.ErrorLog("解析失败:%v", err)
  25499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25500. return
  25501. }
  25502. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25503. data := make(map[string]interface{})
  25504. client := &http.Client{}
  25505. data["psn_no"] = his.PsnNo
  25506. data["mdtrt_id"] = his.Number
  25507. data["opter"] = roles.UserName
  25508. data["org_name"] = miConfig.OrgName
  25509. if reg_type == 11 && his.Insutype == "390" {
  25510. data["med_type"] = "110104"
  25511. } else {
  25512. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25513. }
  25514. data["doctor_id"] = doctor_info.DoctorNumber
  25515. data["doctor_name"] = doctor_info.UserName
  25516. data["department"] = department.Name
  25517. data["fixmedins_code"] = miConfig.Code
  25518. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25519. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25520. data["secret_key"] = miConfig.SecretKey
  25521. data["sick_code"] = sickConfig.CountryCode
  25522. data["sick_name"] = sickConfig.ClassName
  25523. data["dept"] = strconv.FormatInt(department.ID, 10)
  25524. data["config"] = config
  25525. data["begin_time"] = begin_time
  25526. bytesData, _ := json.Marshal(data)
  25527. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25528. resp, _ := client.Do(req)
  25529. defer resp.Body.Close()
  25530. body, ioErr := ioutil.ReadAll(resp.Body)
  25531. if ioErr != nil {
  25532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25534. return
  25535. }
  25536. var respJSON map[string]interface{}
  25537. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25540. return
  25541. }
  25542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25543. userJSONBytes, _ := json.Marshal(respJSON)
  25544. fmt.Println("log")
  25545. fmt.Println(string(userJSONBytes))
  25546. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25547. utils.ErrorLog("解析失败:%v", err)
  25548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25549. return
  25550. }
  25551. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25552. data := make(map[string]interface{})
  25553. client := &http.Client{}
  25554. data["psn_no"] = his.PsnNo
  25555. data["mdtrt_id"] = his.Number
  25556. data["doctor"] = roles.UserName
  25557. data["department"] = department.Name
  25558. data["org_name"] = miConfig.OrgName
  25559. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25560. data["doctor_id"] = doctor_info.DoctorNumber
  25561. data["new_doctor_name"] = doctor_info.UserName
  25562. data["fixmedins_code"] = miConfig.Code
  25563. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25564. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25565. data["secret_key"] = miConfig.SecretKey
  25566. data["sick_code"] = sickConfig.CountryCode
  25567. data["sick_name"] = sickConfig.ClassName
  25568. data["url"] = miConfig.Url
  25569. data["ak"] = miConfig.AccessKey
  25570. data["begin_time"] = begin_time
  25571. data["cainfo"] = miConfig.Cainfo
  25572. data["dept"] = strconv.FormatInt(department.ID, 10)
  25573. data["config"] = config
  25574. bytesData, _ := json.Marshal(data)
  25575. var req *http.Request
  25576. if miConfig.MdtrtareaAdmvs == "320921" {
  25577. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25578. //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 +
  25579. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25580. } else {
  25581. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25582. }
  25583. resp, _ := client.Do(req)
  25584. defer resp.Body.Close()
  25585. body, ioErr := ioutil.ReadAll(resp.Body)
  25586. if ioErr != nil {
  25587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25589. return
  25590. }
  25591. var respJSON map[string]interface{}
  25592. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25595. return
  25596. }
  25597. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25598. userJSONBytes, _ := json.Marshal(respJSON)
  25599. fmt.Println("log")
  25600. fmt.Println(string(userJSONBytes))
  25601. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25602. utils.ErrorLog("解析失败:%v", err)
  25603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25604. return
  25605. }
  25606. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25607. res2.Output = ressix10265.Output
  25608. res2.ErrMsg = ressix10265.ErrMsg
  25609. res2.Cainfo = ressix10265.Cainfo
  25610. res2.WarnMsg = ressix10265.WarnMsg
  25611. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25612. res2.Infcode = infocode
  25613. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25614. data := make(map[string]interface{})
  25615. client := &http.Client{}
  25616. data["psn_no"] = his.PsnNo
  25617. data["mdtrt_id"] = his.Number
  25618. data["doctor"] = roles.UserName
  25619. data["department"] = department.Name
  25620. data["org_name"] = miConfig.OrgName
  25621. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25622. data["doctor_id"] = doctor_info.DoctorNumber
  25623. data["new_doctor_name"] = doctor_info.UserName
  25624. data["fixmedins_code"] = miConfig.Code
  25625. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25626. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25627. data["secret_key"] = miConfig.SecretKey
  25628. data["sick_code"] = sickConfig.CountryCode
  25629. data["sick_name"] = sickConfig.ClassName
  25630. data["url"] = miConfig.Url
  25631. data["ak"] = miConfig.AccessKey
  25632. data["begin_time"] = begin_time
  25633. data["cainfo"] = miConfig.Cainfo
  25634. data["dept"] = strconv.FormatInt(department.ID, 10)
  25635. data["config"] = config
  25636. bytesData, _ := json.Marshal(data)
  25637. var req *http.Request
  25638. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25639. resp, _ := client.Do(req)
  25640. defer resp.Body.Close()
  25641. body, ioErr := ioutil.ReadAll(resp.Body)
  25642. if ioErr != nil {
  25643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25645. return
  25646. }
  25647. var respJSON map[string]interface{}
  25648. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25651. return
  25652. }
  25653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25654. userJSONBytes, _ := json.Marshal(respJSON)
  25655. fmt.Println("log")
  25656. fmt.Println(string(userJSONBytes))
  25657. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25658. utils.ErrorLog("解析失败:%v", err)
  25659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25660. return
  25661. }
  25662. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25663. res2.Output = ressix10265.Output
  25664. res2.ErrMsg = ressix10265.ErrMsg
  25665. res2.Cainfo = ressix10265.Cainfo
  25666. res2.WarnMsg = ressix10265.WarnMsg
  25667. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25668. res2.Infcode = infocode
  25669. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25670. 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)
  25671. saveLog(result, requestLog, "2203", "上传就诊信息")
  25672. var respJSON2 map[string]interface{}
  25673. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25676. return
  25677. }
  25678. userJSONBytes2, _ := json.Marshal(respJSON2)
  25679. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25680. utils.ErrorLog("解析失败:%v", err)
  25681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25682. return
  25683. }
  25684. 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)
  25685. fmt.Println(result2)
  25686. fmt.Println(src_request)
  25687. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25688. data := make(map[string]interface{})
  25689. client := &http.Client{}
  25690. data["psn_no"] = his.PsnNo
  25691. data["mdtrt_id"] = his.Number
  25692. data["doctor"] = roles.UserName
  25693. data["department"] = department.Name
  25694. data["org_name"] = miConfig.OrgName
  25695. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25696. data["doctor_id"] = doctor_info.DoctorNumber
  25697. data["new_doctor_name"] = doctor_info.UserName
  25698. data["fixmedins_code"] = miConfig.Code
  25699. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25700. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25701. data["secret_key"] = miConfig.SecretKey
  25702. data["sick_code"] = sickConfig.CountryCode
  25703. data["sick_name"] = sickConfig.ClassName
  25704. data["url"] = miConfig.Url
  25705. data["ak"] = miConfig.AccessKey
  25706. data["begin_time"] = begin_time
  25707. data["cainfo"] = miConfig.Cainfo
  25708. data["dept"] = strconv.FormatInt(department.ID, 10)
  25709. data["config"] = config
  25710. bytesData, _ := json.Marshal(data)
  25711. var req *http.Request
  25712. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25713. resp, _ := client.Do(req)
  25714. defer resp.Body.Close()
  25715. body, ioErr := ioutil.ReadAll(resp.Body)
  25716. if ioErr != nil {
  25717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25719. return
  25720. }
  25721. var respJSON map[string]interface{}
  25722. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25725. return
  25726. }
  25727. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25728. userJSONBytes, _ := json.Marshal(respJSON)
  25729. fmt.Println("log")
  25730. fmt.Println(string(userJSONBytes))
  25731. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25732. utils.ErrorLog("解析失败:%v", err)
  25733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25734. return
  25735. }
  25736. } else {
  25737. if miConfig.MdtrtareaAdmvs == "440781" { //
  25738. 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)
  25739. } else {
  25740. if miConfig.Code == "H15049901371" {
  25741. //赤峰地区国家医保医疗类别
  25742. //职工透析:医疗类别选特殊情况门诊990502
  25743. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25744. var med_type string
  25745. if his.Insutype == "390" {
  25746. if reg_type == 14 {
  25747. med_type = "9933"
  25748. } else if reg_type == 11 {
  25749. med_type = "11"
  25750. }
  25751. } else if his.Insutype == "310" {
  25752. if reg_type == 14 {
  25753. med_type = "990502"
  25754. } else if reg_type == 11 {
  25755. med_type = "11"
  25756. }
  25757. }
  25758. 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)
  25759. } else {
  25760. 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)
  25761. }
  25762. }
  25763. saveLog(result, requestLog, "2203", "上传就诊信息")
  25764. var respJSON2 map[string]interface{}
  25765. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25768. return
  25769. }
  25770. userJSONBytes2, _ := json.Marshal(respJSON2)
  25771. if miConfig.Code == "H15049901371" {
  25772. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25773. utils.ErrorLog("解析失败:%v", err)
  25774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25775. return
  25776. }
  25777. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25778. res2.Output = ressix10265.Output
  25779. res2.ErrMsg = ressix10265.ErrMsg
  25780. res2.Cainfo = ressix10265.Cainfo
  25781. res2.WarnMsg = ressix10265.WarnMsg
  25782. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25783. res2.Infcode = infocode
  25784. } else {
  25785. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25786. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25787. utils.ErrorLog("解析失败:%v", err)
  25788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25789. return
  25790. }
  25791. res2.Infcode = res3.Infcode
  25792. } else {
  25793. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25794. utils.ErrorLog("解析失败:%v", err)
  25795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25796. return
  25797. }
  25798. }
  25799. }
  25800. }
  25801. if res2.Infcode == -1 {
  25802. adminUser := c.GetAdminUserInfo()
  25803. errlog := &models.HisOrderError{
  25804. UserOrgId: adminUser.CurrentOrgId,
  25805. Ctime: time.Now().Unix(),
  25806. Mtime: time.Now().Unix(),
  25807. ErrMsg: res2.ErrMsg,
  25808. Status: 1,
  25809. PatientId: id,
  25810. RecordTime: recordDateTime,
  25811. Stage: 3,
  25812. }
  25813. service.CreateErrMsgLog(errlog)
  25814. c.ServeSuccessJSON(map[string]interface{}{
  25815. "failed_code": -10,
  25816. "msg": res2.ErrMsg,
  25817. })
  25818. return
  25819. } else {
  25820. his.Diagnosis = diagnosis_id
  25821. his.SickType = sickConfig.ID
  25822. //var p_type int64
  25823. //if reg_type == 1111 || reg_type == 1112 {
  25824. // p_type = 11
  25825. //
  25826. //}
  25827. his.PType = fmt.Sprintf("%d", reg_type)
  25828. service.UpdateHisPatientThree(&his)
  25829. data := make(map[string]interface{})
  25830. if settle_accounts_type == 1 { //日结
  25831. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25832. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25833. } else {
  25834. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25835. }
  25836. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25837. data["pre"] = prescriptions
  25838. } else { //月结
  25839. start_time_str := c.GetString("start_time")
  25840. end_time_str := c.GetString("end_time")
  25841. timeLayout := "2006-01-02"
  25842. loc, _ := time.LoadLocation("Local")
  25843. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25844. if err != nil {
  25845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25846. return
  25847. }
  25848. recordStartTime := theStartTime.Unix()
  25849. start_time = recordStartTime
  25850. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25851. if err != nil {
  25852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25853. return
  25854. }
  25855. recordEndTime := theEndTime.Unix()
  25856. end_time = recordEndTime
  25857. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25858. data["pre"] = prescriptions
  25859. }
  25860. timestamp := time.Now().Unix()
  25861. tempTime := time.Unix(timestamp, 0)
  25862. timeFormat := tempTime.Format("20060102150405")
  25863. chrgBchno := rand.Intn(100000) + 10000
  25864. new_chrg_bchno := ""
  25865. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25866. new_chrg_bchno = chrg_bchno
  25867. strconv.FormatInt(his.PatientId, 10)
  25868. client := &http.Client{}
  25869. if adminUser.CurrentOrgId == 10265 {
  25870. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25871. new_chrg_bchno = "0000"
  25872. }
  25873. }
  25874. data["psn_no"] = his.PsnNo
  25875. data["mdtrt_id"] = his.Number
  25876. data["chrg_bchno"] = new_chrg_bchno
  25877. data["org_name"] = miConfig.OrgName
  25878. data["doctor"] = doctor_info.UserName
  25879. data["doctor_id"] = doctor_info.DoctorNumber
  25880. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25881. data["fixmedins_code"] = miConfig.Code
  25882. data["dept_code"] = department.Number
  25883. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25884. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25885. data["secret_key"] = miConfig.SecretKey
  25886. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25887. data["url"] = miConfig.Url
  25888. data["ak"] = miConfig.AccessKey
  25889. data["new_doctor_name"] = patientPrescription.Doctor
  25890. data["diag_code"] = sickConfig.CountryCode
  25891. data["cainfo"] = miConfig.Cainfo
  25892. data["opter"] = roles.UserName
  25893. var ids []int64
  25894. for _, item := range prescriptions {
  25895. ids = append(ids, item.ID)
  25896. }
  25897. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25898. if config.IsOpen == 1 { //对接了医保,走医保流程
  25899. var res ResultFour
  25900. var resFour10265 ResultFour10265
  25901. if miConfig.MdtrtareaAdmvs == "421300" {
  25902. bytesData, _ := json.Marshal(data)
  25903. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25904. resp, _ := client.Do(req)
  25905. defer resp.Body.Close()
  25906. body, ioErr := ioutil.ReadAll(resp.Body)
  25907. if ioErr != nil {
  25908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25910. return
  25911. }
  25912. var respJSON map[string]interface{}
  25913. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25916. return
  25917. }
  25918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25919. userJSONBytes, _ := json.Marshal(respJSON)
  25920. fmt.Println("log")
  25921. fmt.Println(string(userJSONBytes))
  25922. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25923. utils.ErrorLog("解析失败:%v", err)
  25924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25925. return
  25926. }
  25927. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25928. bytesData, _ := json.Marshal(data)
  25929. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25930. resp, _ := client.Do(req)
  25931. defer resp.Body.Close()
  25932. body, ioErr := ioutil.ReadAll(resp.Body)
  25933. if ioErr != nil {
  25934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25936. return
  25937. }
  25938. var respJSON map[string]interface{}
  25939. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25942. return
  25943. }
  25944. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25945. userJSONBytes, _ := json.Marshal(respJSON)
  25946. fmt.Println("log")
  25947. fmt.Println(string(userJSONBytes))
  25948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25949. utils.ErrorLog("解析失败:%v", err)
  25950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25951. return
  25952. }
  25953. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25954. bytesData, _ := json.Marshal(data)
  25955. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25956. resp, _ := client.Do(req)
  25957. defer resp.Body.Close()
  25958. body, ioErr := ioutil.ReadAll(resp.Body)
  25959. if ioErr != nil {
  25960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25962. return
  25963. }
  25964. var respJSON map[string]interface{}
  25965. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25968. return
  25969. }
  25970. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25971. userJSONBytes, _ := json.Marshal(respJSON)
  25972. fmt.Println("log")
  25973. fmt.Println(string(userJSONBytes))
  25974. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25975. utils.ErrorLog("解析失败:%v", err)
  25976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25977. return
  25978. }
  25979. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25980. bytesData, _ := json.Marshal(data)
  25981. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25982. resp, _ := client.Do(req)
  25983. defer resp.Body.Close()
  25984. body, ioErr := ioutil.ReadAll(resp.Body)
  25985. if ioErr != nil {
  25986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25988. return
  25989. }
  25990. var respJSON map[string]interface{}
  25991. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25994. return
  25995. }
  25996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25997. userJSONBytes, _ := json.Marshal(respJSON)
  25998. fmt.Println("log")
  25999. fmt.Println(string(userJSONBytes))
  26000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26001. utils.ErrorLog("解析失败:%v", err)
  26002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26003. return
  26004. }
  26005. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26006. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26007. if result3101.Infcode == "0" {
  26008. if len(result3101.Output.Result) > 0 {
  26009. var errMsgs []string
  26010. for _, item := range result3101.Output.Result {
  26011. errMsgs = append(errMsgs, item.VolaCont)
  26012. }
  26013. c.ServeSuccessJSON(map[string]interface{}{
  26014. "failed_code": -10,
  26015. "msg": errMsgs,
  26016. })
  26017. return
  26018. }
  26019. }
  26020. bytesData, _ := json.Marshal(data)
  26021. var req *http.Request
  26022. if miConfig.MdtrtareaAdmvs == "320921" {
  26023. data["diag_code"] = sickConfig.CountryCode
  26024. fmt.Println(data)
  26025. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26026. } else {
  26027. data["diag_code"] = sickConfig.CountryCode
  26028. fmt.Println(data)
  26029. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26030. }
  26031. resp, _ := client.Do(req)
  26032. defer resp.Body.Close()
  26033. body, ioErr := ioutil.ReadAll(resp.Body)
  26034. if ioErr != nil {
  26035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26037. return
  26038. }
  26039. var respJSON map[string]interface{}
  26040. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26043. return
  26044. }
  26045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26046. userJSONBytes, _ := json.Marshal(respJSON)
  26047. fmt.Println("log")
  26048. fmt.Println(string(userJSONBytes))
  26049. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26050. utils.ErrorLog("解析失败:%v", err)
  26051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26052. return
  26053. }
  26054. res.InfRefmsgid = resFour10265.InfRefmsgid
  26055. res.Output = resFour10265.Output
  26056. res.ErrMsg = resFour10265.ErrMsg
  26057. res.Cainfo = resFour10265.Cainfo
  26058. res.WarnMsg = resFour10265.WarnMsg
  26059. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26060. res.Infcode = infocode
  26061. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26062. var pagesize int = 2
  26063. var start int = 1
  26064. var stop int
  26065. var pagecount int
  26066. var curpage int
  26067. var isSuccess bool = true
  26068. data["doctor_id"] = doctor_info.DoctorNumber
  26069. //总页数,向上取整,注意除之前要先转换类型为float64
  26070. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  26071. for curpage = 1; curpage <= pagecount; curpage++ {
  26072. if curpage == 1 {
  26073. start = 1
  26074. } else {
  26075. start = (curpage-1)*pagesize + 1
  26076. }
  26077. stop = curpage * pagesize
  26078. if stop > len(prescriptions) {
  26079. stop = len(prescriptions)
  26080. }
  26081. //var requestLog string
  26082. data["pre"] = prescriptions[start-1 : stop]
  26083. fmt.Println(data["pre"])
  26084. bytesData, _ := json.Marshal(data)
  26085. var req *http.Request
  26086. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  26087. resp, _ := client.Do(req)
  26088. defer resp.Body.Close()
  26089. body, ioErr := ioutil.ReadAll(resp.Body)
  26090. if ioErr != nil {
  26091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26093. return
  26094. }
  26095. var respJSON map[string]interface{}
  26096. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26099. return
  26100. }
  26101. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26102. userJSONBytes, _ := json.Marshal(respJSON)
  26103. fmt.Println("log")
  26104. fmt.Println(string(userJSONBytes))
  26105. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26106. utils.ErrorLog("解析失败:%v", err)
  26107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26108. return
  26109. }
  26110. res.InfRefmsgid = resFour10265.InfRefmsgid
  26111. res.Output = resFour10265.Output
  26112. res.ErrMsg = resFour10265.ErrMsg
  26113. res.Cainfo = resFour10265.Cainfo
  26114. res.WarnMsg = resFour10265.WarnMsg
  26115. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26116. res.Infcode = infocode
  26117. if infocode == 0 {
  26118. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  26119. } else {
  26120. isSuccess = false
  26121. errlog := &models.HisOrderError{
  26122. UserOrgId: adminUser.CurrentOrgId,
  26123. Ctime: time.Now().Unix(),
  26124. Mtime: time.Now().Unix(),
  26125. Number: chrg_bchno,
  26126. ErrMsg: "",
  26127. Status: 1,
  26128. PatientId: id,
  26129. RecordTime: recordDateTime,
  26130. Stage: 4,
  26131. }
  26132. service.CreateErrMsgLog(errlog)
  26133. c.ServeSuccessJSON(map[string]interface{}{
  26134. "failed_code": -10,
  26135. "msg": res.ErrMsg,
  26136. })
  26137. return
  26138. }
  26139. }
  26140. if isSuccess {
  26141. res.Infcode = 0
  26142. }
  26143. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26144. 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)
  26145. var dat map[string]interface{}
  26146. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26147. fmt.Println(dat)
  26148. } else {
  26149. fmt.Println(err)
  26150. }
  26151. saveLog(result, request_log, "2204", "上传费用明细")
  26152. userJSONBytes, _ := json.Marshal(dat)
  26153. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26154. utils.ErrorLog("解析失败:%v", err)
  26155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26156. return
  26157. }
  26158. res.InfRefmsgid = resFour10265.InfRefmsgid
  26159. res.Output = resFour10265.Output
  26160. res.ErrMsg = resFour10265.ErrMsg
  26161. res.Cainfo = resFour10265.Cainfo
  26162. res.WarnMsg = resFour10265.WarnMsg
  26163. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26164. res.Infcode = infocode
  26165. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26166. bytesData, _ := json.Marshal(data)
  26167. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  26168. resp, _ := client.Do(req)
  26169. defer resp.Body.Close()
  26170. body, ioErr := ioutil.ReadAll(resp.Body)
  26171. if ioErr != nil {
  26172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26174. return
  26175. }
  26176. var respJSON map[string]interface{}
  26177. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26180. return
  26181. }
  26182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26183. userJSONBytes, _ := json.Marshal(respJSON)
  26184. fmt.Println("log")
  26185. fmt.Println(string(userJSONBytes))
  26186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26187. utils.ErrorLog("解析失败:%v", err)
  26188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26189. return
  26190. }
  26191. } else {
  26192. if miConfig.Code == "H15049901371" {
  26193. 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)
  26194. var dat map[string]interface{}
  26195. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26196. fmt.Println(dat)
  26197. } else {
  26198. fmt.Println(err)
  26199. }
  26200. saveLog(result, request_log, "2204", "上传费用明细")
  26201. userJSONBytes, _ := json.Marshal(dat)
  26202. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26203. utils.ErrorLog("解析失败:%v", err)
  26204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26205. return
  26206. }
  26207. res.InfRefmsgid = resFour10265.InfRefmsgid
  26208. res.Output = resFour10265.Output
  26209. res.ErrMsg = resFour10265.ErrMsg
  26210. res.Cainfo = resFour10265.Cainfo
  26211. res.WarnMsg = resFour10265.WarnMsg
  26212. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26213. res.Infcode = infocode
  26214. } else {
  26215. 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)
  26216. var dat map[string]interface{}
  26217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26218. fmt.Println(dat)
  26219. } else {
  26220. fmt.Println(err)
  26221. }
  26222. saveLog(result, request_log, "2204", "上传费用明细")
  26223. userJSONBytes, _ := json.Marshal(dat)
  26224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26225. utils.ErrorLog("解析失败:%v", err)
  26226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26227. return
  26228. }
  26229. }
  26230. }
  26231. if res.Infcode == 0 {
  26232. order := &models.HisOrder{
  26233. UserOrgId: adminUser.CurrentOrgId,
  26234. HisPatientId: his.ID,
  26235. PatientId: his.PatientId,
  26236. SettleAccountsDate: recordDateTime,
  26237. MdtrtId: his.Number,
  26238. PsnNo: his.PsnNo,
  26239. MedType: strconv.FormatInt(reg_type, 10),
  26240. Ctime: time.Now().Unix(),
  26241. Mtime: time.Now().Unix(),
  26242. Status: 1,
  26243. Number: chrg_bchno,
  26244. Infcode: res.Infcode,
  26245. WarnMsg: res.WarnMsg,
  26246. Cainfo: res.Cainfo,
  26247. ErrMsg: res.ErrMsg,
  26248. RespondTime: res.RefmsgTime,
  26249. InfRefmsgid: res.InfRefmsgid,
  26250. OrderStatus: 1,
  26251. PayWay: pay_way,
  26252. PayWays: pay_ways,
  26253. OthDesc: oth_desc,
  26254. PayPrice: pay_price,
  26255. PayCardNo: pay_card_no,
  26256. DiscountPrice: discount_price,
  26257. PreferentialPrice: preferential_price,
  26258. RealityPrice: reality_price,
  26259. FoundPrice: found_price,
  26260. MedicalInsurancePrice: medical_insurance_price,
  26261. PrivatePrice: private_price,
  26262. IsMedicineInsurance: 1,
  26263. SettleType: settle_accounts_type,
  26264. SettleStartTime: start_time,
  26265. SettleEndTime: end_time,
  26266. Creator: roles.AdminUserId,
  26267. Modify: roles.AdminUserId,
  26268. FaPiaoNumber: fapiao_number,
  26269. FaPiaoCode: fapiao_code,
  26270. PType: 2,
  26271. Diagnosis: diagnosis_id,
  26272. CashPay: cash_pay,
  26273. WechatPay: wechat_pay,
  26274. AliPay: ali_pay,
  26275. JifenPay: jifen_pay,
  26276. BandCardPay: band_card_pay,
  26277. }
  26278. err = service.CreateOrder(order)
  26279. if err != nil {
  26280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  26281. return
  26282. }
  26283. for _, item := range res.Output.Result {
  26284. temp := strings.Split(item.FeedetlSn, "-")
  26285. var advice_id int64 = 0
  26286. var project_id int64 = 0
  26287. var types int64 = 0
  26288. id, _ := strconv.ParseInt(temp[2], 10, 64)
  26289. types, _ = strconv.ParseInt(temp[1], 10, 64)
  26290. if temp[1] == "1" {
  26291. advice_id = id
  26292. project_id = 0
  26293. } else if temp[1] == "2" {
  26294. advice_id = 0
  26295. project_id = id
  26296. }
  26297. if item.MedChrgitmType == "9" {
  26298. item.MedChrgitmType = "09"
  26299. }
  26300. info := &models.HisOrderInfo{
  26301. OrderNumber: order.Number,
  26302. FeedetlSn: item.FeedetlSn,
  26303. UploadDate: time.Now().Unix(),
  26304. AdviceId: advice_id,
  26305. DetItemFeeSumamt: item.DetItemFeeSumamt,
  26306. Cnt: item.Cnt,
  26307. Pric: float64(item.Pric),
  26308. PatientId: his.PatientId,
  26309. PricUplmtAmt: item.PricUplmtAmt,
  26310. SelfpayProp: item.SelfpayProp,
  26311. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  26312. OverlmtAmt: item.OverlmtAmt,
  26313. PreselfpayAmt: item.PreselfpayAmt,
  26314. BasMednFlag: item.BasMednFlag,
  26315. MedChrgitmType: item.MedChrgitmType,
  26316. HiNegoDrugFlag: item.HiNegoDrugFlag,
  26317. Status: 1,
  26318. Memo: item.Memo,
  26319. Mtime: time.Now().Unix(),
  26320. InscpScpAmt: item.InscpScpAmt,
  26321. DrtReimFlag: item.DrtReimFlag,
  26322. Ctime: time.Now().Unix(),
  26323. ListSpItemFlag: item.ListSpItemFlag,
  26324. ChldMedcFlag: item.ChldMedcFlag,
  26325. LmtUsedFlag: item.LmtUsedFlag,
  26326. ChrgitmLv: item.ChrgitmLv,
  26327. UserOrgId: adminUser.CurrentOrgId,
  26328. HisPatientId: his.ID,
  26329. OrderId: order.ID,
  26330. ProjectId: project_id,
  26331. Type: types,
  26332. }
  26333. service.CreateOrderInfo(info)
  26334. }
  26335. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  26336. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  26337. var total float64
  26338. for _, item := range prescriptions {
  26339. if item.Type == 1 { //药品
  26340. for _, subItem := range item.HisDoctorAdviceInfo {
  26341. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26342. total_one := price * subItem.PrescribingNumber
  26343. total = total + total_one
  26344. }
  26345. }
  26346. if item.Type == 2 { //项目
  26347. for _, subItem := range item.HisPrescriptionProject {
  26348. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  26349. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26350. total_one := price * cnt
  26351. total = total + total_one
  26352. }
  26353. }
  26354. }
  26355. allTotal := fmt.Sprintf("%.2f", total)
  26356. //if adminUser.CurrentOrgId == 9919 {
  26357. //
  26358. // allTotal = fmt.Sprintf("%.2f", total)
  26359. //
  26360. //} else {
  26361. //
  26362. // allTotal = fmt.Sprintf("%.2f", total)
  26363. //
  26364. //}
  26365. if res.Infcode == 0 {
  26366. var rf []*ResultFive
  26367. json.Unmarshal([]byte(his.Iinfo), &rf)
  26368. chrg_bchno := chrg_bchno
  26369. cert_no := his.Certno
  26370. var insutypes []string
  26371. var insutype string
  26372. var is390 int = 0
  26373. var is310 int = 0
  26374. for _, item := range rf {
  26375. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26376. insutypes = append(insutypes, item.Insutype)
  26377. }
  26378. }
  26379. if len(insutypes) == 1 {
  26380. insutype = insutypes[0]
  26381. } else {
  26382. for _, i := range insutypes {
  26383. if i == "390" {
  26384. is390 = 1
  26385. }
  26386. if i == "310" {
  26387. is310 = 1
  26388. }
  26389. }
  26390. }
  26391. if is390 == 1 {
  26392. insutype = "390"
  26393. }
  26394. if is310 == 1 {
  26395. insutype = "310"
  26396. }
  26397. if len(insutypes) == 0 {
  26398. insutype = "310"
  26399. }
  26400. if len(insutypes) == 2 {
  26401. insutype = strconv.FormatInt(his.SocialType, 10)
  26402. }
  26403. insutype = strconv.FormatInt(his.SocialType, 10)
  26404. //insutype = "390"
  26405. if his.IdCardType == 1 {
  26406. // cert_no = his.MedicalInsuranceNumber
  26407. cert_no = his.Certno
  26408. } else {
  26409. cert_no = his.Certno
  26410. }
  26411. var res ResultSeven
  26412. var resSeven10265 ResultSeven10265
  26413. var gzresSeven10265Two GZResultSeven10265Two
  26414. var src_resquest string
  26415. var result2 string
  26416. if miConfig.MdtrtareaAdmvs == "421300" {
  26417. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26418. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26419. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26420. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26421. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26422. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26423. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26424. resp, requestErr := http.Get(api)
  26425. if requestErr != nil {
  26426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26427. return
  26428. }
  26429. body, ioErr := ioutil.ReadAll(resp.Body)
  26430. if ioErr != nil {
  26431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26433. return
  26434. }
  26435. var respJSON map[string]interface{}
  26436. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26439. return
  26440. }
  26441. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26442. result, _ := json.Marshal(respJSON)
  26443. if miConfig.Code == "H15049901371" {
  26444. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26445. utils.ErrorLog("解析失败:%v", err)
  26446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26447. return
  26448. }
  26449. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26450. res.Output = resSeven10265.Output
  26451. res.ErrMsg = resSeven10265.ErrMsg
  26452. res.Cainfo = resSeven10265.Cainfo
  26453. res.WarnMsg = resSeven10265.WarnMsg
  26454. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26455. res.Infcode = infocode
  26456. } else {
  26457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26458. utils.ErrorLog("解析失败:%v", err)
  26459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26460. return
  26461. }
  26462. }
  26463. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26464. if reg_type == 11 && his.Insutype == "390" {
  26465. reg_type = 110104
  26466. }
  26467. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26468. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26469. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26470. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26471. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26472. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26473. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26474. resp, requestErr := http.Get(api)
  26475. if requestErr != nil {
  26476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26477. return
  26478. }
  26479. body, ioErr := ioutil.ReadAll(resp.Body)
  26480. if ioErr != nil {
  26481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26483. return
  26484. }
  26485. var respJSON map[string]interface{}
  26486. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26489. return
  26490. }
  26491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26492. result, _ := json.Marshal(respJSON)
  26493. if miConfig.Code == "H15049901371" {
  26494. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26495. utils.ErrorLog("解析失败:%v", err)
  26496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26497. return
  26498. }
  26499. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26500. res.Output = resSeven10265.Output
  26501. res.ErrMsg = resSeven10265.ErrMsg
  26502. res.Cainfo = resSeven10265.Cainfo
  26503. res.WarnMsg = resSeven10265.WarnMsg
  26504. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26505. res.Infcode = infocode
  26506. } else {
  26507. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26508. utils.ErrorLog("解析失败:%v", err)
  26509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26510. return
  26511. }
  26512. }
  26513. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26514. if reg_type == 11 && his.Insutype == "390" {
  26515. reg_type = 110104
  26516. }
  26517. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26518. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26519. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26520. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26521. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26522. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26523. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26524. resp, requestErr := http.Get(api)
  26525. if requestErr != nil {
  26526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26527. return
  26528. }
  26529. body, ioErr := ioutil.ReadAll(resp.Body)
  26530. if ioErr != nil {
  26531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26533. return
  26534. }
  26535. var respJSON map[string]interface{}
  26536. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26539. return
  26540. }
  26541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26542. result, _ := json.Marshal(respJSON)
  26543. if miConfig.Code == "H15049901371" {
  26544. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26545. utils.ErrorLog("解析失败:%v", err)
  26546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26547. return
  26548. }
  26549. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26550. res.Output = resSeven10265.Output
  26551. res.ErrMsg = resSeven10265.ErrMsg
  26552. res.Cainfo = resSeven10265.Cainfo
  26553. res.WarnMsg = resSeven10265.WarnMsg
  26554. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26555. res.Infcode = infocode
  26556. } else {
  26557. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26558. utils.ErrorLog("解析失败:%v", err)
  26559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26560. return
  26561. }
  26562. }
  26563. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26564. if reg_type == 11 && his.Insutype == "390" {
  26565. reg_type = 110104
  26566. }
  26567. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26568. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26569. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26570. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26571. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26572. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26573. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26574. resp, requestErr := http.Get(api)
  26575. if requestErr != nil {
  26576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26577. return
  26578. }
  26579. body, ioErr := ioutil.ReadAll(resp.Body)
  26580. if ioErr != nil {
  26581. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26583. return
  26584. }
  26585. var respJSON map[string]interface{}
  26586. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26589. return
  26590. }
  26591. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26592. result, _ := json.Marshal(respJSON)
  26593. if miConfig.Code == "H15049901371" {
  26594. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26595. utils.ErrorLog("解析失败:%v", err)
  26596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26597. return
  26598. }
  26599. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26600. res.Output = resSeven10265.Output
  26601. res.ErrMsg = resSeven10265.ErrMsg
  26602. res.Cainfo = resSeven10265.Cainfo
  26603. res.WarnMsg = resSeven10265.WarnMsg
  26604. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26605. res.Infcode = infocode
  26606. } else {
  26607. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26608. utils.ErrorLog("解析失败:%v", err)
  26609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26610. return
  26611. }
  26612. }
  26613. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26614. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26615. if result3101.Infcode == "0" {
  26616. if len(result3101.Output.Result) > 0 {
  26617. var errMsgs []string
  26618. for _, item := range result3101.Output.Result {
  26619. errMsgs = append(errMsgs, item.VolaCont)
  26620. }
  26621. c.ServeSuccessJSON(map[string]interface{}{
  26622. "failed_code": -10,
  26623. "msg": errMsgs,
  26624. })
  26625. return
  26626. } else {
  26627. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26628. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26629. bas := strings.Split(psn_info.CardInfo, "|")
  26630. if his.IdCardType == 1 {
  26631. cert_no = bas[2]
  26632. } else if his.IdCardType == 3 {
  26633. cert_no = his.Certno
  26634. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26635. } else if his.IdCardType == 4 {
  26636. cert_no = his.Certno
  26637. psn_info.VerifyNumber = psn_info.VerifyNumber
  26638. }
  26639. var api string
  26640. if miConfig.MdtrtareaAdmvs == "320921" {
  26641. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26642. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26643. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26644. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26645. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26646. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26647. "&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
  26648. } else {
  26649. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26650. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26651. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26652. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26653. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26654. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26655. "&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
  26656. }
  26657. resp, requestErr := http.Get(api)
  26658. if requestErr != nil {
  26659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26660. return
  26661. }
  26662. body, ioErr := ioutil.ReadAll(resp.Body)
  26663. if ioErr != nil {
  26664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26666. return
  26667. }
  26668. var respJSON map[string]interface{}
  26669. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26672. return
  26673. }
  26674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26675. result, _ := json.Marshal(respJSON)
  26676. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26677. utils.ErrorLog("解析失败:%v", err)
  26678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26679. return
  26680. }
  26681. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26682. res.Output = resSeven10265.Output
  26683. res.ErrMsg = resSeven10265.ErrMsg
  26684. res.Cainfo = resSeven10265.Cainfo
  26685. res.WarnMsg = resSeven10265.WarnMsg
  26686. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26687. res.Infcode = infocode
  26688. }
  26689. }
  26690. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26691. psn_info, _ := service.GetPsnByPatientId(id)
  26692. var verify_number string
  26693. if psn_info.IdCardType == 4 {
  26694. verify_number = psn_info.VerifyNumber
  26695. } else if psn_info.IdCardType == 1 {
  26696. bas := strings.Split(psn_info.CardInfo, "|")
  26697. cardNumber := bas[2]
  26698. verify_number = cardNumber
  26699. } else {
  26700. psn_info.IdCardType = 2
  26701. verify_number = psn_info.Certno
  26702. }
  26703. var api string
  26704. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26705. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26706. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26707. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26708. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26709. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26710. "&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
  26711. resp, requestErr := http.Get(api)
  26712. if requestErr != nil {
  26713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26714. return
  26715. }
  26716. body, ioErr := ioutil.ReadAll(resp.Body)
  26717. if ioErr != nil {
  26718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26720. return
  26721. }
  26722. var respJSON map[string]interface{}
  26723. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26726. return
  26727. }
  26728. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26729. result, _ := json.Marshal(respJSON)
  26730. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26731. utils.ErrorLog("解析失败:%v", err)
  26732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26733. return
  26734. }
  26735. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26736. res.Output = resSeven10265.Output
  26737. res.ErrMsg = resSeven10265.ErrMsg
  26738. res.Cainfo = resSeven10265.Cainfo
  26739. res.WarnMsg = resSeven10265.WarnMsg
  26740. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26741. res.Infcode = infocode
  26742. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26743. var cert_no string
  26744. if his.IdCardType == 4 {
  26745. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26746. cert_no = psn_info.VerifyNumber
  26747. 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)
  26748. } else if his.IdCardType == 1 {
  26749. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26750. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26751. 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)
  26752. }
  26753. //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)
  26754. var dat map[string]interface{}
  26755. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26756. fmt.Println(dat)
  26757. } else {
  26758. fmt.Println(err)
  26759. }
  26760. saveLog(result2, src_resquest, "2207", "结算")
  26761. userJSONBytes, _ := json.Marshal(dat)
  26762. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26763. utils.ErrorLog("解析失败:%v", err)
  26764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26765. return
  26766. }
  26767. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26768. res.Output = resSeven10265.Output
  26769. res.ErrMsg = resSeven10265.ErrMsg
  26770. res.Cainfo = resSeven10265.Cainfo
  26771. res.WarnMsg = resSeven10265.WarnMsg
  26772. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26773. res.Infcode = infocode
  26774. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26775. res2 := c.GetoleInfo()
  26776. if res2.Infcode == 0 {
  26777. var result string
  26778. var request_log string
  26779. var result_log string
  26780. if res2.Output.MdtrtCertType == "02" {
  26781. 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)
  26782. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26783. } else if res2.Output.MdtrtCertType == "01" {
  26784. 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)
  26785. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26786. } else {
  26787. 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)
  26788. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26789. }
  26790. var dat map[string]interface{}
  26791. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26792. fmt.Println(dat)
  26793. } else {
  26794. fmt.Println(err)
  26795. }
  26796. userJSONBytes, _ := json.Marshal(dat)
  26797. var res5 ResultTwo
  26798. //var resTwo10265 ResultTwo10265
  26799. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26800. utils.ErrorLog("解析失败:%v", err)
  26801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26802. return
  26803. }
  26804. if res5.Infcode == -1 {
  26805. c.ServeSuccessJSON(map[string]interface{}{
  26806. "failed_code": -10,
  26807. "msg": res5.ErrMsg,
  26808. })
  26809. return
  26810. }
  26811. var insutypes []string
  26812. var insutype string
  26813. var is390 int = 0
  26814. var is310 int = 0
  26815. for _, item := range res5.Output.Iinfo {
  26816. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26817. insutypes = append(insutypes, item.Insutype)
  26818. }
  26819. }
  26820. if len(insutypes) == 1 {
  26821. insutype = insutypes[0]
  26822. } else {
  26823. for _, i := range insutypes {
  26824. if i == "390" {
  26825. is390 = 1
  26826. }
  26827. if i == "310" {
  26828. is310 = 1
  26829. }
  26830. }
  26831. }
  26832. if is390 == 1 {
  26833. insutype = "390"
  26834. }
  26835. if is310 == 1 {
  26836. insutype = "310"
  26837. }
  26838. if len(insutypes) == 0 {
  26839. insutype = "310"
  26840. }
  26841. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26842. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26843. infoStr := string(Iinfos)
  26844. idetinfoStr := string(Idetinfos)
  26845. psn := &models.HisPsn{
  26846. PsnNo: res5.Output.Baseinfo.PsnNo,
  26847. PatientId: id,
  26848. Certno: res5.Output.Baseinfo.Certno,
  26849. Gend: res5.Output.Baseinfo.Gend,
  26850. Naty: res5.Output.Baseinfo.Naty,
  26851. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26852. PsnName: res5.Output.Baseinfo.PsnName,
  26853. Idetinfo: idetinfoStr,
  26854. Insuinfo: infoStr,
  26855. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26856. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26857. VerifyNumber: res2.Output.EcToken,
  26858. }
  26859. if res2.Output.MdtrtCertType == "01" {
  26860. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26861. psn.VerifyNumber = res2.Output.EcToken
  26862. } else if res2.Output.MdtrtCertType == "02" {
  26863. psn.VerifyNumber = res2.Output.CardNo
  26864. } else {
  26865. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26866. }
  26867. service.CreateHisPsn(psn)
  26868. if res2.Output.MdtrtCertType == "01" {
  26869. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26870. token := res2.Output.EcToken
  26871. 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)
  26872. } else if res2.Output.MdtrtCertType == "02" {
  26873. 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)
  26874. } else {
  26875. 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)
  26876. }
  26877. var dat2 map[string]interface{}
  26878. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26879. fmt.Println(dat2)
  26880. } else {
  26881. fmt.Println(err)
  26882. }
  26883. userJSONBytes3, _ := json.Marshal(dat2)
  26884. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26885. utils.ErrorLog("解析失败:%v", err)
  26886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26887. return
  26888. }
  26889. saveLog(result2, src_resquest, "2207", "结算")
  26890. } else {
  26891. c.ServeSuccessJSON(map[string]interface{}{
  26892. "failed_code": -10,
  26893. "msg": res2.ErrMsg,
  26894. })
  26895. return
  26896. }
  26897. } else {
  26898. if miConfig.Code == "H15049901371" {
  26899. //赤峰地区国家医保医疗类别
  26900. //职工透析:医疗类别选特殊情况门诊990502
  26901. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26902. var med_type string
  26903. if his.Insutype == "390" {
  26904. if reg_type == 14 {
  26905. med_type = "9933"
  26906. } else if reg_type == 11 {
  26907. med_type = "11"
  26908. }
  26909. } else if his.Insutype == "310" {
  26910. if reg_type == 14 {
  26911. med_type = "990502"
  26912. } else if reg_type == 11 {
  26913. med_type = "11"
  26914. }
  26915. }
  26916. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, "", admin_user_id)
  26917. } else {
  26918. if his.IdCardType == 4 {
  26919. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26920. var token string
  26921. token = psn_info.VerifyNumber
  26922. 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)
  26923. } else {
  26924. if his.IdCardType == 1 {
  26925. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26926. bas := strings.Split(psn_info.CardInfo, "|")
  26927. basNumber := bas[2]
  26928. cert_no = basNumber
  26929. }
  26930. 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)
  26931. }
  26932. }
  26933. //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)
  26934. var dat map[string]interface{}
  26935. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26936. fmt.Println(dat)
  26937. } else {
  26938. fmt.Println(err)
  26939. }
  26940. saveLog(result2, src_resquest, "2207", "结算")
  26941. userJSONBytes, _ := json.Marshal(dat)
  26942. if miConfig.Code == "H15049901371" {
  26943. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26944. utils.ErrorLog("解析失败:%v", err)
  26945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26946. return
  26947. }
  26948. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26949. res.Output = resSeven10265.Output
  26950. res.ErrMsg = resSeven10265.ErrMsg
  26951. res.Cainfo = resSeven10265.Cainfo
  26952. res.WarnMsg = resSeven10265.WarnMsg
  26953. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26954. res.Infcode = infocode
  26955. } else {
  26956. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26957. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26958. utils.ErrorLog("解析失败:%v", err)
  26959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26960. return
  26961. }
  26962. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26963. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26964. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26965. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26966. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26967. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26968. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26969. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26970. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26971. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26972. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26973. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26974. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26975. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26976. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26977. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26978. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26979. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26980. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26981. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26982. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26983. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26984. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26985. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26986. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26987. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26988. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26989. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26990. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26991. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26992. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26993. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26994. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26995. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26996. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26997. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26998. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26999. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27000. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27001. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27002. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27003. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27004. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27005. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27006. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27007. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27008. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27009. res.Cainfo = gzresSeven10265Two.Cainfo
  27010. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27011. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27012. //res.Infcode = infocode
  27013. } else {
  27014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27015. utils.ErrorLog("解析失败:%v", err)
  27016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27017. return
  27018. }
  27019. }
  27020. }
  27021. }
  27022. if res.Infcode == -1 {
  27023. errlog := &models.HisOrderError{
  27024. UserOrgId: adminUser.CurrentOrgId,
  27025. Ctime: time.Now().Unix(),
  27026. Mtime: time.Now().Unix(),
  27027. Number: chrg_bchno,
  27028. ErrMsg: res.ErrMsg,
  27029. Status: 1,
  27030. PatientId: id,
  27031. RecordTime: recordDateTime,
  27032. Stage: 6,
  27033. }
  27034. service.CreateErrMsgLog(errlog)
  27035. c.ServeSuccessJSON(map[string]interface{}{
  27036. "failed_code": -10,
  27037. "msg": res.ErrMsg,
  27038. })
  27039. return
  27040. } else {
  27041. sickConfig, _ := service.FindSickById(his.SickType)
  27042. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27043. order.OrderStatus = 2
  27044. order.Status = 1
  27045. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27046. order.SetlId = res.Output.Setlinfo.SetlID
  27047. order.PsnNo = res.Output.Setlinfo.PsnNo
  27048. order.PsnName = res.Output.Setlinfo.PsnName
  27049. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27050. order.Certno = res.Output.Setlinfo.Certno
  27051. order.Gend = res.Output.Setlinfo.Gend
  27052. order.Naty = res.Output.Setlinfo.Naty
  27053. order.Age = res.Output.Setlinfo.Age
  27054. order.Insutype = res.Output.Setlinfo.Insutype
  27055. order.PsnType = res.Output.Setlinfo.PsnType
  27056. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27057. order.SetlTime = res.Output.Setlinfo.SetlTime
  27058. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27059. if res.Output.Setlinfo.MedType == "140101" {
  27060. order.MedType = "14"
  27061. } else {
  27062. if res.Output.Setlinfo.MedType == "110104" {
  27063. order.MedType = "11"
  27064. } else {
  27065. order.MedType = res.Output.Setlinfo.MedType
  27066. }
  27067. }
  27068. if reg_type == 1112 {
  27069. order.MedType = "1112"
  27070. }
  27071. if reg_type == 1111 {
  27072. order.MedType = "1111"
  27073. }
  27074. order.ClrType = res.Output.Setlinfo.ClrType
  27075. if adminUser.CurrentOrgId == 10480 {
  27076. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27077. order.ClrType = "11"
  27078. } else {
  27079. order.ClrType = "9903"
  27080. }
  27081. }
  27082. if adminUser.CurrentOrgId == 10721 {
  27083. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27084. order.ClrType = "11"
  27085. } else {
  27086. order.ClrType = "9903"
  27087. }
  27088. }
  27089. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27090. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27091. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27092. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27093. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27094. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27095. order.HifpPay = res.Output.Setlinfo.HifpPay
  27096. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27097. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27098. order.HifesPay = res.Output.Setlinfo.HifesPay
  27099. order.HifobPay = res.Output.Setlinfo.HifobPay
  27100. order.MafPay = res.Output.Setlinfo.MafPay
  27101. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27102. order.OthPay = res.Output.Setlinfo.OthPay
  27103. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27104. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27105. order.AcctPay = res.Output.Setlinfo.AcctPay
  27106. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27107. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27108. order.Balc = res.Output.Setlinfo.Balc
  27109. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27110. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27111. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27112. //order.ClrType = res.Output.Setlinfo.ClrType
  27113. order.ClrWay = res.Output.Setlinfo.ClrWay
  27114. order.Creator = order.Creator
  27115. order.Modify = roles.AdminUserId
  27116. order.RequestLog = src_resquest
  27117. order.FaPiaoNumber = fapiao_number
  27118. order.FaPiaoCode = fapiao_code
  27119. order.SickName = sickConfig.ClassName
  27120. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27121. //detailStr := string(setlDetail)
  27122. //order.SetlDetail = detailStr
  27123. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27124. err = service.UpDateOrder(order)
  27125. if err == nil {
  27126. //判断是否使用了押金
  27127. if dec_way == "true" {
  27128. tmpstring := strconv.FormatInt(order.ID, 10)
  27129. order.Decimal = decimal
  27130. service.UpDateOrder(order)
  27131. //扣押金
  27132. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27133. if errmsg != nil {
  27134. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27135. return
  27136. }
  27137. }
  27138. c.ServeSuccessJSON(map[string]interface{}{
  27139. "msg": "结算成功",
  27140. })
  27141. } else {
  27142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27143. return
  27144. }
  27145. }
  27146. } else {
  27147. adminUser := c.GetAdminUserInfo()
  27148. errlog := &models.HisOrderError{
  27149. UserOrgId: adminUser.CurrentOrgId,
  27150. Ctime: time.Now().Unix(),
  27151. Mtime: time.Now().Unix(),
  27152. ErrMsg: res.ErrMsg,
  27153. Status: 1,
  27154. PatientId: id,
  27155. RecordTime: recordDateTime,
  27156. Stage: 4,
  27157. }
  27158. service.CreateErrMsgLog(errlog)
  27159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  27160. return
  27161. }
  27162. } else {
  27163. adminUser := c.GetAdminUserInfo()
  27164. errlog := &models.HisOrderError{
  27165. UserOrgId: adminUser.CurrentOrgId,
  27166. Ctime: time.Now().Unix(),
  27167. Mtime: time.Now().Unix(),
  27168. ErrMsg: res.ErrMsg,
  27169. Status: 1,
  27170. PatientId: id,
  27171. RecordTime: recordDateTime,
  27172. Stage: 4,
  27173. }
  27174. service.CreateErrMsgLog(errlog)
  27175. c.ServeSuccessJSON(map[string]interface{}{
  27176. "failed_code": -10,
  27177. "msg": res.ErrMsg,
  27178. })
  27179. return
  27180. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  27181. //return
  27182. }
  27183. }
  27184. }
  27185. } else if tempOrder.ID > 0 {
  27186. if tempOrder.IsPre == 1 {
  27187. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  27188. var rf []*ResultFive
  27189. json.Unmarshal([]byte(his.Iinfo), &rf)
  27190. chrg_bchno := tempOrder.Number
  27191. cert_no := his.Certno
  27192. var insutypes []string
  27193. var insutype string
  27194. var is390 int = 0
  27195. var is310 int = 0
  27196. for _, item := range rf {
  27197. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27198. insutypes = append(insutypes, item.Insutype)
  27199. }
  27200. }
  27201. if len(insutypes) == 1 {
  27202. insutype = insutypes[0]
  27203. } else {
  27204. for _, i := range insutypes {
  27205. if i == "390" {
  27206. is390 = 1
  27207. }
  27208. if i == "310" {
  27209. is310 = 1
  27210. }
  27211. }
  27212. }
  27213. if is390 == 1 {
  27214. insutype = "390"
  27215. }
  27216. if is310 == 1 {
  27217. insutype = "310"
  27218. }
  27219. if len(insutypes) == 0 {
  27220. insutype = "310"
  27221. }
  27222. if len(insutypes) == 2 {
  27223. insutype = strconv.FormatInt(his.SocialType, 10)
  27224. }
  27225. //insutype = "390"
  27226. if his.IdCardType == 1 {
  27227. // cert_no = his.MedicalInsuranceNumber
  27228. cert_no = his.Certno
  27229. } else {
  27230. cert_no = his.Certno
  27231. }
  27232. var res ResultSeven
  27233. var ahres ResultSevenAH
  27234. var resSeven10265 ResultSeven10265
  27235. var gzresSeven10265Two GZResultSeven10265Two
  27236. var src_resquest string
  27237. var result2 string
  27238. if miConfig.MdtrtareaAdmvs == "450721" {
  27239. res2 := c.GetoleInfo()
  27240. if res2.Infcode == 0 {
  27241. var result string
  27242. var request_log string
  27243. var result_log string
  27244. if res2.Output.MdtrtCertType == "02" {
  27245. 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)
  27246. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27247. } else if res2.Output.MdtrtCertType == "01" {
  27248. 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)
  27249. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27250. } else {
  27251. 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)
  27252. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27253. }
  27254. var dat map[string]interface{}
  27255. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27256. fmt.Println(dat)
  27257. } else {
  27258. fmt.Println(err)
  27259. }
  27260. userJSONBytes, _ := json.Marshal(dat)
  27261. var res5 ResultTwo
  27262. //var resTwo10265 ResultTwo10265
  27263. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27264. utils.ErrorLog("解析失败:%v", err)
  27265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27266. return
  27267. }
  27268. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  27269. if res5.Infcode == -1 {
  27270. c.ServeSuccessJSON(map[string]interface{}{
  27271. "failed_code": -10,
  27272. "msg": res5.ErrMsg,
  27273. })
  27274. return
  27275. }
  27276. var insutypes []string
  27277. var insutype string
  27278. var is390 int = 0
  27279. var is310 int = 0
  27280. for _, item := range res5.Output.Iinfo {
  27281. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27282. insutypes = append(insutypes, item.Insutype)
  27283. }
  27284. }
  27285. if len(insutypes) == 1 {
  27286. insutype = insutypes[0]
  27287. } else {
  27288. for _, i := range insutypes {
  27289. if i == "390" {
  27290. is390 = 1
  27291. }
  27292. if i == "310" {
  27293. is310 = 1
  27294. }
  27295. }
  27296. }
  27297. if is390 == 1 {
  27298. insutype = "390"
  27299. }
  27300. if is310 == 1 {
  27301. insutype = "310"
  27302. }
  27303. if len(insutypes) == 0 {
  27304. insutype = "310"
  27305. }
  27306. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27307. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27308. infoStr := string(Iinfos)
  27309. idetinfoStr := string(Idetinfos)
  27310. psn := &models.HisPsn{
  27311. PsnNo: res5.Output.Baseinfo.PsnNo,
  27312. PatientId: id,
  27313. Certno: res5.Output.Baseinfo.Certno,
  27314. Gend: res5.Output.Baseinfo.Gend,
  27315. Naty: res5.Output.Baseinfo.Naty,
  27316. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27317. PsnName: res5.Output.Baseinfo.PsnName,
  27318. Idetinfo: idetinfoStr,
  27319. Insuinfo: infoStr,
  27320. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27321. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27322. VerifyNumber: res2.Output.EcToken,
  27323. }
  27324. service.CreateHisPsn(psn)
  27325. if res2.Output.MdtrtCertType == "01" {
  27326. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27327. token := res2.Output.EcToken
  27328. 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)
  27329. } else if res2.Output.MdtrtCertType == "02" {
  27330. 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)
  27331. } else {
  27332. 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)
  27333. }
  27334. var dat2 map[string]interface{}
  27335. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27336. fmt.Println(dat2)
  27337. } else {
  27338. fmt.Println(err)
  27339. }
  27340. userJSONBytes3, _ := json.Marshal(dat2)
  27341. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27342. utils.ErrorLog("解析失败:%v", err)
  27343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27344. return
  27345. }
  27346. saveLog(result2, src_resquest, "2207", "结算")
  27347. } else {
  27348. c.ServeSuccessJSON(map[string]interface{}{
  27349. "failed_code": -10,
  27350. "msg": res2.ErrMsg,
  27351. })
  27352. return
  27353. }
  27354. } else if miConfig.MdtrtareaAdmvs == "421300" {
  27355. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27356. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27357. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27358. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27359. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27360. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27361. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27362. resp, requestErr := http.Get(api)
  27363. if requestErr != nil {
  27364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27365. return
  27366. }
  27367. body, ioErr := ioutil.ReadAll(resp.Body)
  27368. if ioErr != nil {
  27369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27371. return
  27372. }
  27373. var respJSON map[string]interface{}
  27374. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27377. return
  27378. }
  27379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27380. result, _ := json.Marshal(respJSON)
  27381. fmt.Println("log")
  27382. fmt.Println(string(result))
  27383. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27384. utils.ErrorLog("解析失败:%v", err)
  27385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27386. return
  27387. }
  27388. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27389. if reg_type == 11 && his.Insutype == "390" {
  27390. reg_type = 110104
  27391. }
  27392. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27393. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27394. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27395. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27396. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27397. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27398. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27399. resp, requestErr := http.Get(api)
  27400. if requestErr != nil {
  27401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27402. return
  27403. }
  27404. body, ioErr := ioutil.ReadAll(resp.Body)
  27405. if ioErr != nil {
  27406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27408. return
  27409. }
  27410. var respJSON map[string]interface{}
  27411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27414. return
  27415. }
  27416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27417. result, _ := json.Marshal(respJSON)
  27418. fmt.Println("log")
  27419. fmt.Println(string(result))
  27420. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27421. utils.ErrorLog("解析失败:%v", err)
  27422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27423. return
  27424. }
  27425. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27426. if reg_type == 11 && his.Insutype == "390" {
  27427. reg_type = 110104
  27428. }
  27429. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27430. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27431. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27432. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27433. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27434. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27435. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27436. resp, requestErr := http.Get(api)
  27437. if requestErr != nil {
  27438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27439. return
  27440. }
  27441. body, ioErr := ioutil.ReadAll(resp.Body)
  27442. if ioErr != nil {
  27443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27445. return
  27446. }
  27447. var respJSON map[string]interface{}
  27448. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27451. return
  27452. }
  27453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27454. result, _ := json.Marshal(respJSON)
  27455. fmt.Println("log")
  27456. fmt.Println(string(result))
  27457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27458. utils.ErrorLog("解析失败:%v", err)
  27459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27460. return
  27461. }
  27462. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27463. if reg_type == 11 && his.Insutype == "390" {
  27464. reg_type = 110104
  27465. }
  27466. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27467. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27468. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27469. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27470. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27471. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27472. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27473. resp, requestErr := http.Get(api)
  27474. if requestErr != nil {
  27475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27476. return
  27477. }
  27478. body, ioErr := ioutil.ReadAll(resp.Body)
  27479. if ioErr != nil {
  27480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27482. return
  27483. }
  27484. var respJSON map[string]interface{}
  27485. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27488. return
  27489. }
  27490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27491. result, _ := json.Marshal(respJSON)
  27492. fmt.Println("log")
  27493. fmt.Println(string(result))
  27494. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27495. utils.ErrorLog("解析失败:%v", err)
  27496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27497. return
  27498. }
  27499. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27500. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27501. if result3101.Infcode == "0" {
  27502. if len(result3101.Output.Result) > 0 {
  27503. var errMsgs []string
  27504. for _, item := range result3101.Output.Result {
  27505. errMsgs = append(errMsgs, item.VolaCont)
  27506. }
  27507. c.ServeSuccessJSON(map[string]interface{}{
  27508. "failed_code": -10,
  27509. "msg": errMsgs,
  27510. })
  27511. return
  27512. } else {
  27513. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27514. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27515. bas := strings.Split(psn_info.CardInfo, "|")
  27516. if his.IdCardType == 1 {
  27517. cert_no = bas[2]
  27518. } else if his.IdCardType == 3 {
  27519. cert_no = his.Certno
  27520. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27521. } else if his.IdCardType == 4 {
  27522. cert_no = his.Certno
  27523. psn_info.VerifyNumber = psn_info.VerifyNumber
  27524. }
  27525. //江苏地区国家医保医疗类别
  27526. //职工透析:医疗类别选特殊情况门诊9933
  27527. //居民血透门慢: 医疗类别选门诊慢病1402
  27528. //var med_type string
  27529. //if his.Insutype == "310" {
  27530. // if reg_type == 14 {
  27531. // med_type = "9933"
  27532. // } else if reg_type == 11 {
  27533. // med_type = "11"
  27534. //
  27535. // }
  27536. //} else if his.Insutype == "390" {
  27537. // if reg_type == 14 {
  27538. // med_type = "1402"
  27539. // } else if reg_type == 11 {
  27540. // med_type = "11"
  27541. // }
  27542. //}
  27543. var api string
  27544. if miConfig.MdtrtareaAdmvs == "320921" {
  27545. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27546. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27547. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27548. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27549. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27550. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27551. "&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
  27552. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27553. } else {
  27554. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27555. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27556. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27557. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27558. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27559. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27560. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27561. "&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
  27562. }
  27563. resp, requestErr := http.Get(api)
  27564. if requestErr != nil {
  27565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27566. return
  27567. }
  27568. body, ioErr := ioutil.ReadAll(resp.Body)
  27569. if ioErr != nil {
  27570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27572. return
  27573. }
  27574. var respJSON map[string]interface{}
  27575. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27578. return
  27579. }
  27580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27581. result, _ := json.Marshal(respJSON)
  27582. fmt.Println("log")
  27583. fmt.Println(string(result))
  27584. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27585. utils.ErrorLog("解析失败:%v", err)
  27586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27587. return
  27588. }
  27589. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27590. res.Output = resSeven10265.Output
  27591. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27592. res.ErrMsg = resSeven10265.ErrMsg
  27593. res.Cainfo = resSeven10265.Cainfo
  27594. res.WarnMsg = resSeven10265.WarnMsg
  27595. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27596. res.Infcode = infocode
  27597. }
  27598. }
  27599. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27600. psn_info, _ := service.GetPsnByPatientId(id)
  27601. var verify_number string
  27602. if psn_info.IdCardType == 4 {
  27603. verify_number = psn_info.VerifyNumber
  27604. } else if psn_info.IdCardType == 1 {
  27605. bas := strings.Split(psn_info.CardInfo, "|")
  27606. cardNumber := bas[2]
  27607. verify_number = cardNumber
  27608. } else {
  27609. verify_number = psn_info.Certno
  27610. psn_info.IdCardType = 2
  27611. }
  27612. var api string
  27613. new_chrg_bchno := chrg_bchno
  27614. if adminUser.CurrentOrgId == 10265 {
  27615. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27616. new_chrg_bchno = "0000"
  27617. }
  27618. }
  27619. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27620. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27621. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27622. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27623. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27624. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27625. "&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
  27626. resp, requestErr := http.Get(api)
  27627. if requestErr != nil {
  27628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27629. return
  27630. }
  27631. body, ioErr := ioutil.ReadAll(resp.Body)
  27632. if ioErr != nil {
  27633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27635. return
  27636. }
  27637. var respJSON map[string]interface{}
  27638. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27641. return
  27642. }
  27643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27644. result, _ := json.Marshal(respJSON)
  27645. fmt.Println("log")
  27646. fmt.Println(string(result))
  27647. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27648. utils.ErrorLog("解析失败:%v", err)
  27649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27650. return
  27651. }
  27652. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27653. res.Output = resSeven10265.Output
  27654. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27655. res.ErrMsg = resSeven10265.ErrMsg
  27656. res.Cainfo = resSeven10265.Cainfo
  27657. res.WarnMsg = resSeven10265.WarnMsg
  27658. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27659. res.Infcode = infocode
  27660. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27661. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27662. var cert_no string
  27663. if his.IdCardType == 1 {
  27664. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27665. } else {
  27666. cert_no = psn_info.VerifyNumber
  27667. }
  27668. 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)
  27669. var dat map[string]interface{}
  27670. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27671. fmt.Println(dat)
  27672. } else {
  27673. fmt.Println(err)
  27674. }
  27675. saveLog(result2, src_resquest, "2207", "结算")
  27676. userJSONBytes, _ := json.Marshal(dat)
  27677. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27678. utils.ErrorLog("解析失败:%v", err)
  27679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27680. return
  27681. }
  27682. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27683. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27684. var cert_no string
  27685. var card_sn string
  27686. if his.IdCardType == 1 {
  27687. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27688. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27689. bas := strings.Split(psn_info.CardInfo, "|")
  27690. card_sn = bas[3]
  27691. } else if his.IdCardType == 2 {
  27692. cert_no = his.IdCardNo
  27693. } else {
  27694. cert_no = psn_info.VerifyNumber
  27695. }
  27696. var rf []*ResultFive
  27697. json.Unmarshal([]byte(his.Iinfo), &rf)
  27698. var psn_type string
  27699. for _, item := range rf {
  27700. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27701. psn_type = item.PsnType
  27702. }
  27703. }
  27704. 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)
  27705. var dat map[string]interface{}
  27706. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27707. fmt.Println(dat)
  27708. } else {
  27709. fmt.Println(err)
  27710. }
  27711. saveLog(result2, src_resquest, "2207", "结算")
  27712. userJSONBytes, _ := json.Marshal(dat)
  27713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27714. utils.ErrorLog("解析失败:%v", err)
  27715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27716. return
  27717. }
  27718. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27719. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27720. var cert_no string
  27721. var card_sn string
  27722. if his.IdCardType == 1 {
  27723. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27724. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27725. //bas := strings.Split(psn_info.CardInfo, "|")
  27726. card_sn = ""
  27727. } else if his.IdCardType == 2 {
  27728. cert_no = his.IdCardNo
  27729. } else {
  27730. cert_no = psn_info.VerifyNumber
  27731. }
  27732. var rf []*ResultFive
  27733. json.Unmarshal([]byte(his.Iinfo), &rf)
  27734. var psn_type string
  27735. for _, item := range rf {
  27736. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27737. psn_type = item.PsnType
  27738. }
  27739. }
  27740. 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)
  27741. var dat map[string]interface{}
  27742. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27743. fmt.Println(dat)
  27744. } else {
  27745. fmt.Println(err)
  27746. }
  27747. saveLog(result2, src_resquest, "2207", "结算")
  27748. userJSONBytes, _ := json.Marshal(dat)
  27749. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27750. utils.ErrorLog("解析失败:%v", err)
  27751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27752. return
  27753. }
  27754. } else if miConfig.MdtrtareaAdmvs == "360100" {
  27755. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27756. var cert_no string
  27757. var card_sn string
  27758. if his.IdCardType == 1 {
  27759. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27760. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27761. //bas := strings.Split(psn_info.CardInfo, "|")
  27762. card_sn = ""
  27763. } else if his.IdCardType == 2 {
  27764. cert_no = his.IdCardNo
  27765. } else {
  27766. cert_no = psn_info.VerifyNumber
  27767. }
  27768. var rf []*ResultFive
  27769. json.Unmarshal([]byte(his.Iinfo), &rf)
  27770. var psn_type string
  27771. for _, item := range rf {
  27772. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27773. psn_type = item.PsnType
  27774. }
  27775. }
  27776. 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)
  27777. var dat map[string]interface{}
  27778. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27779. fmt.Println(dat)
  27780. } else {
  27781. fmt.Println(err)
  27782. }
  27783. saveLog(result2, src_resquest, "2207", "结算")
  27784. userJSONBytes, _ := json.Marshal(dat)
  27785. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27786. utils.ErrorLog("解析失败:%v", err)
  27787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27788. return
  27789. }
  27790. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27791. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27792. if his.IdCardType == 1 {
  27793. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27794. bas := strings.Split(psn_info.CardInfo, "|")
  27795. cert_no = bas[2]
  27796. } else if his.IdCardType == 3 {
  27797. cert_no = his.Certno
  27798. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27799. } else if his.IdCardType == 4 {
  27800. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27801. cert_no = psn_info.VerifyNumber
  27802. psn_info.VerifyNumber = psn_info.VerifyNumber
  27803. } else {
  27804. cert_no = his.Certno
  27805. psn_info.VerifyNumber = his.Certno
  27806. }
  27807. var api string
  27808. var med_type string
  27809. if his.Insutype == "390" {
  27810. if reg_type == 992102 {
  27811. med_type = "992102"
  27812. }
  27813. if reg_type == 140104 {
  27814. med_type = "140104"
  27815. }
  27816. if reg_type == 140201 {
  27817. med_type = "140201"
  27818. }
  27819. if reg_type == 14 {
  27820. med_type = "14"
  27821. }
  27822. } else if his.Insutype == "310" {
  27823. if reg_type == 992102 {
  27824. med_type = "992102"
  27825. }
  27826. if reg_type == 140104 {
  27827. med_type = "140104"
  27828. }
  27829. if reg_type == 140201 {
  27830. med_type = "140201"
  27831. }
  27832. if reg_type == 14 {
  27833. med_type = "14"
  27834. }
  27835. }
  27836. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27837. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27838. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27839. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27840. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27841. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27842. "&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
  27843. resp, requestErr := http.Get(api)
  27844. if requestErr != nil {
  27845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27846. return
  27847. }
  27848. body, ioErr := ioutil.ReadAll(resp.Body)
  27849. if ioErr != nil {
  27850. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27852. return
  27853. }
  27854. var respJSON map[string]interface{}
  27855. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27858. return
  27859. }
  27860. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27861. if status == "0" {
  27862. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27863. c.ServeSuccessJSON(map[string]interface{}{
  27864. "failed_code": -10,
  27865. "msg": err_msg,
  27866. })
  27867. return
  27868. }
  27869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27870. result, _ := json.Marshal(respJSON)
  27871. fmt.Println("log")
  27872. fmt.Println(string(result))
  27873. if err := json.Unmarshal(result, &ahres); err != nil {
  27874. utils.ErrorLog("解析失败:%v", err)
  27875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27876. return
  27877. }
  27878. res.InfRefmsgid = ahres.InfRefmsgid
  27879. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27880. // 创建对应的Time类型
  27881. t := time.UnixMilli(timestamp)
  27882. // 格式化成指定的日期字符串
  27883. str := t.Format("2006-01-02 15:04:05")
  27884. res.Output.Setlinfo.SetlTime = str
  27885. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27886. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27887. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27888. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27889. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27890. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27891. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27892. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27893. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27894. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27895. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27896. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27897. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27898. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27899. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27900. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27901. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27902. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27903. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27904. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27905. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27906. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27907. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27908. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27909. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27910. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27911. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27912. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27913. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27914. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27915. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27916. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27917. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27918. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27919. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27920. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27921. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27922. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27923. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27924. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27925. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27926. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27927. res.Output.Setldetail = ahres.Output.Setldetail
  27928. res.ErrMsg = ahres.ErrMsg
  27929. res.Cainfo = ahres.Cainfo
  27930. res.WarnMsg = ahres.WarnMsg
  27931. res.Infcode = ahres.Infcode
  27932. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27933. res.Output.Setlinfo.ClrType = "11"
  27934. } else {
  27935. res.Output.Setlinfo.ClrType = "9903"
  27936. }
  27937. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27938. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27939. if his.IdCardType == 1 {
  27940. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27941. bas := strings.Split(psn_info.CardInfo, "|")
  27942. cert_no = bas[2]
  27943. } else if his.IdCardType == 3 {
  27944. cert_no = his.Certno
  27945. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27946. } else if his.IdCardType == 4 {
  27947. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27948. cert_no = his.Certno
  27949. psn_info.VerifyNumber = psn_info.VerifyNumber
  27950. } else {
  27951. cert_no = his.Certno
  27952. psn_info.VerifyNumber = his.Certno
  27953. }
  27954. var api string
  27955. var med_type string
  27956. if his.Insutype == "390" {
  27957. if reg_type == 992102 {
  27958. med_type = "992102"
  27959. }
  27960. if reg_type == 140104 {
  27961. med_type = "140104"
  27962. }
  27963. if reg_type == 14 {
  27964. med_type = "14"
  27965. }
  27966. if reg_type == 140201 {
  27967. med_type = "140201"
  27968. }
  27969. } else if his.Insutype == "310" {
  27970. if reg_type == 992102 {
  27971. med_type = "992102"
  27972. }
  27973. if reg_type == 14 {
  27974. med_type = "14"
  27975. }
  27976. if reg_type == 140104 {
  27977. med_type = "140104"
  27978. }
  27979. if reg_type == 140201 {
  27980. med_type = "140201"
  27981. }
  27982. }
  27983. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27984. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27985. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27986. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27987. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27988. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27989. "&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
  27990. resp, requestErr := http.Get(api)
  27991. if requestErr != nil {
  27992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27993. return
  27994. }
  27995. body, ioErr := ioutil.ReadAll(resp.Body)
  27996. if ioErr != nil {
  27997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27999. return
  28000. }
  28001. var respJSON map[string]interface{}
  28002. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28005. return
  28006. }
  28007. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28008. if status == "0" {
  28009. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28010. c.ServeSuccessJSON(map[string]interface{}{
  28011. "failed_code": -10,
  28012. "msg": err_msg,
  28013. })
  28014. return
  28015. }
  28016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28017. result, _ := json.Marshal(respJSON)
  28018. fmt.Println("log")
  28019. fmt.Println(string(result))
  28020. if err := json.Unmarshal(result, &ahres); err != nil {
  28021. utils.ErrorLog("解析失败:%v", err)
  28022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28023. return
  28024. }
  28025. res.InfRefmsgid = ahres.InfRefmsgid
  28026. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28027. // 创建对应的Time类型
  28028. t := time.UnixMilli(timestamp)
  28029. // 格式化成指定的日期字符串
  28030. str := t.Format("2006-01-02 15:04:05")
  28031. res.Output.Setlinfo.SetlTime = str
  28032. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28033. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28034. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28035. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28036. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28037. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28038. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28039. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28040. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28041. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28042. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28043. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28044. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28045. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28046. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28047. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28048. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28049. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28050. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28051. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28052. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28053. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28054. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28055. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28056. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28057. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28058. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28059. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28060. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28061. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28062. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28063. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28064. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28065. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28066. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28067. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28068. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28069. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28070. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28071. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28072. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28073. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28074. res.Output.Setldetail = ahres.Output.Setldetail
  28075. res.ErrMsg = ahres.ErrMsg
  28076. res.Cainfo = ahres.Cainfo
  28077. res.WarnMsg = ahres.WarnMsg
  28078. res.Infcode = ahres.Infcode
  28079. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28080. res.Output.Setlinfo.ClrType = "11"
  28081. } else {
  28082. res.Output.Setlinfo.ClrType = "9903"
  28083. }
  28084. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28085. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28086. var cert_no string
  28087. if his.IdCardType == 1 {
  28088. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28089. } else if his.IdCardType == 2 {
  28090. cert_no = his.IdCardNo
  28091. } else {
  28092. cert_no = psn_info.VerifyNumber
  28093. }
  28094. 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, "")
  28095. var dat map[string]interface{}
  28096. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28097. fmt.Println(dat)
  28098. } else {
  28099. fmt.Println(err)
  28100. }
  28101. saveLog(result2, src_resquest, "2207", "结算")
  28102. userJSONBytes, _ := json.Marshal(dat)
  28103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28104. utils.ErrorLog("解析失败:%v", err)
  28105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28106. return
  28107. }
  28108. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28109. psn_info, _ := service.GetPsnByPatientId(id)
  28110. var verify_number string
  28111. if psn_info.IdCardType == 4 {
  28112. verify_number = psn_info.VerifyNumber
  28113. } else if psn_info.IdCardType == 1 {
  28114. bas := strings.Split(psn_info.CardInfo, "|")
  28115. cardNumber := bas[2]
  28116. verify_number = cardNumber
  28117. } else {
  28118. verify_number = psn_info.Certno
  28119. psn_info.IdCardType = 2
  28120. }
  28121. var api string
  28122. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28123. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28124. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28125. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28126. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28127. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28128. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  28129. resp, requestErr := http.Get(api)
  28130. if requestErr != nil {
  28131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28132. return
  28133. }
  28134. body, ioErr := ioutil.ReadAll(resp.Body)
  28135. if ioErr != nil {
  28136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28138. return
  28139. }
  28140. var respJSON map[string]interface{}
  28141. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28144. return
  28145. }
  28146. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28147. result, _ := json.Marshal(respJSON)
  28148. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28149. utils.ErrorLog("解析失败:%v", err)
  28150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28151. return
  28152. }
  28153. } else {
  28154. var src_resquest string
  28155. if miConfig.Code == "H15049901371" {
  28156. //赤峰地区国家医保医疗类别
  28157. //职工透析:医疗类别选特殊情况门诊990502
  28158. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28159. var med_type string
  28160. if his.Insutype == "390" {
  28161. if reg_type == 14 {
  28162. med_type = "9933"
  28163. } else if reg_type == 11 {
  28164. med_type = "11"
  28165. }
  28166. } else if his.Insutype == "310" {
  28167. if reg_type == 14 {
  28168. med_type = "990502"
  28169. } else if reg_type == 11 {
  28170. med_type = "11"
  28171. }
  28172. }
  28173. 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)
  28174. } else {
  28175. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" {
  28176. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28177. if result3101.Infcode == 0 {
  28178. if len(result3101.Output.Result) > 0 {
  28179. c.ServeSuccessJSON(map[string]interface{}{
  28180. "failed_code": -10,
  28181. "failed_type": 100,
  28182. "warm_type": 2,
  28183. "msg": result3101,
  28184. })
  28185. return
  28186. }
  28187. } else {
  28188. c.ServeSuccessJSON(map[string]interface{}{
  28189. "failed_code": -10,
  28190. "msg": result3101.ErrMsg,
  28191. })
  28192. return
  28193. }
  28194. }
  28195. if his.IdCardType == 4 {
  28196. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28197. token := psn_info.VerifyNumber
  28198. 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)
  28199. } else {
  28200. 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)
  28201. }
  28202. }
  28203. var dat map[string]interface{}
  28204. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28205. fmt.Println(dat)
  28206. } else {
  28207. fmt.Println(err)
  28208. }
  28209. saveLog(result2, src_resquest, "2207", "结算")
  28210. userJSONBytes, _ := json.Marshal(dat)
  28211. if miConfig.Code == "H15049901371" {
  28212. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28213. utils.ErrorLog("解析失败:%v", err)
  28214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28215. return
  28216. }
  28217. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28218. res.Output = resSeven10265.Output
  28219. res.ErrMsg = resSeven10265.ErrMsg
  28220. res.Cainfo = resSeven10265.Cainfo
  28221. res.WarnMsg = resSeven10265.WarnMsg
  28222. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28223. res.Infcode = infocode
  28224. } else {
  28225. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28226. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  28227. utils.ErrorLog("解析失败:%v", err)
  28228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28229. return
  28230. }
  28231. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  28232. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  28233. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  28234. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28235. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  28236. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  28237. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  28238. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28239. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  28240. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28241. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28242. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28243. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28244. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28245. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  28246. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  28247. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  28248. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  28249. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  28250. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  28251. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28252. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  28253. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  28254. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  28255. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  28256. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  28257. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  28258. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  28259. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  28260. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  28261. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  28262. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  28263. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  28264. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  28265. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28266. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  28267. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  28268. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  28269. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28270. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  28271. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  28272. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  28273. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  28274. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  28275. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  28276. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  28277. res.ErrMsg = gzresSeven10265Two.ErrMsg
  28278. res.Cainfo = gzresSeven10265Two.Cainfo
  28279. res.WarnMsg = gzresSeven10265Two.WarnMsg
  28280. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  28281. //res.Infcode = infocode
  28282. } else {
  28283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28284. utils.ErrorLog("解析失败:%v", err)
  28285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28286. return
  28287. }
  28288. }
  28289. }
  28290. }
  28291. if res.Infcode == -1 {
  28292. errlog := &models.HisOrderError{
  28293. UserOrgId: adminUser.CurrentOrgId,
  28294. Ctime: time.Now().Unix(),
  28295. Mtime: time.Now().Unix(),
  28296. Number: chrg_bchno,
  28297. ErrMsg: res.ErrMsg,
  28298. Status: 1,
  28299. PatientId: id,
  28300. RecordTime: recordDateTime,
  28301. Stage: 6,
  28302. }
  28303. service.CreateErrMsgLog(errlog)
  28304. c.ServeSuccessJSON(map[string]interface{}{
  28305. "failed_code": -10,
  28306. "msg": res.ErrMsg,
  28307. })
  28308. return
  28309. } else {
  28310. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  28311. order.OrderStatus = 2
  28312. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  28313. order.SetlId = res.Output.Setlinfo.SetlID
  28314. order.PsnNo = res.Output.Setlinfo.PsnNo
  28315. order.PsnName = res.Output.Setlinfo.PsnName
  28316. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  28317. order.Certno = res.Output.Setlinfo.Certno
  28318. order.Gend = res.Output.Setlinfo.Gend
  28319. order.Naty = res.Output.Setlinfo.Naty
  28320. order.Age = res.Output.Setlinfo.Age
  28321. order.Insutype = res.Output.Setlinfo.Insutype
  28322. order.PsnType = res.Output.Setlinfo.PsnType
  28323. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28324. order.SetlTime = res.Output.Setlinfo.SetlTime
  28325. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28326. order.PayWays = pay_ways
  28327. order.AcctUsedFlag = acct_used_flag
  28328. order.WechatPay = wechat_pay
  28329. order.AliPay = ali_pay
  28330. order.JifenPay = jifen_pay
  28331. order.BandCardPay = band_card_pay
  28332. order.CashPay = cash_pay
  28333. order.OthDesc = oth_desc
  28334. //order.MedType = res.Output.Setlinfo.MedType
  28335. if reg_type == 1112 {
  28336. order.MedType = "1112"
  28337. }
  28338. if reg_type == 1111 {
  28339. order.MedType = "1111"
  28340. }
  28341. order.ClrType = res.Output.Setlinfo.ClrType
  28342. if adminUser.CurrentOrgId == 10480 {
  28343. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28344. order.ClrType = "11"
  28345. } else {
  28346. order.ClrType = "9903"
  28347. }
  28348. }
  28349. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28350. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28351. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28352. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28353. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28354. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28355. order.HifpPay = res.Output.Setlinfo.HifpPay
  28356. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28357. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28358. order.HifesPay = res.Output.Setlinfo.HifesPay
  28359. order.HifobPay = res.Output.Setlinfo.HifobPay
  28360. order.MafPay = res.Output.Setlinfo.MafPay
  28361. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28362. order.OthPay = res.Output.Setlinfo.OthPay
  28363. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28364. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28365. order.AcctPay = res.Output.Setlinfo.AcctPay
  28366. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28367. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28368. order.Balc = res.Output.Setlinfo.Balc
  28369. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28370. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28371. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28372. order.ClrWay = res.Output.Setlinfo.ClrWay
  28373. order.Creator = order.Creator
  28374. order.Modify = roles.AdminUserId
  28375. order.RequestLog = src_resquest
  28376. order.Diagnosis = diagnosis_id
  28377. order.FaPiaoNumber = fapiao_number
  28378. order.FaPiaoCode = fapiao_code
  28379. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28380. detailStr := string(setlDetail)
  28381. order.SetlDetail = detailStr
  28382. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28383. err = service.UpDateOrder(order)
  28384. if err == nil {
  28385. //判断是否使用了押金
  28386. if dec_way == "true" {
  28387. tmpstring := strconv.FormatInt(order.ID, 10)
  28388. //扣押金
  28389. order.Decimal = decimal
  28390. service.UpDateOrder(order)
  28391. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28392. if errmsg != nil {
  28393. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28394. return
  28395. }
  28396. }
  28397. c.ServeSuccessJSON(map[string]interface{}{
  28398. "msg": "结算成功",
  28399. })
  28400. } else {
  28401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28402. return
  28403. }
  28404. }
  28405. }
  28406. }
  28407. }
  28408. // 上传明细-预结算-
  28409. func (c *HisApiController) GetPreUploadInfo() {
  28410. id, _ := c.GetInt64("id")
  28411. record_time := c.GetString("record_time")
  28412. his_patient_id, _ := c.GetInt64("his_patient_id")
  28413. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  28414. admin_user_id, _ := c.GetInt64("admin_user_id")
  28415. diagnosis_id := c.GetString("diagnosis")
  28416. sick_type, _ := c.GetInt64("sick_type")
  28417. reg_type, _ := c.GetInt64("p_type")
  28418. begin_time := c.GetString("begin_time")
  28419. acct_used_flag := c.GetString("acct_used_flag")
  28420. id_str := c.GetString("ids")
  28421. ids_arr := strings.Split(id_str, ",")
  28422. timeLayout := "2006-01-02"
  28423. loc, _ := time.LoadLocation("Local")
  28424. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28425. if err != nil {
  28426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28427. return
  28428. }
  28429. recordDateTime := theTime.Unix()
  28430. adminUser := c.GetAdminUserInfo()
  28431. diagnosis_ids := strings.Split(diagnosis_id, ",")
  28432. var config []*models.HisXtDiagnoseConfig
  28433. for _, item := range diagnosis_ids {
  28434. id, _ := strconv.ParseInt(item, 10, 64)
  28435. if id > 0 {
  28436. diagnosisConfig, _ := service.FindDiagnoseById(id)
  28437. config = append(config, &diagnosisConfig)
  28438. }
  28439. }
  28440. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  28441. sickConfig, _ := service.FindSickById(sick_type)
  28442. var prescriptions []*models.HisPrescription
  28443. var start_time int64
  28444. var end_time int64
  28445. var isSuccess bool = true
  28446. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28447. fmt.Println(his_patient_id)
  28448. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28449. timestamp := time.Now().Unix()
  28450. tempTime := time.Unix(timestamp, 0)
  28451. timeFormat := tempTime.Format("20060102150405")
  28452. chrgBchno := rand.Intn(100000) + 10000
  28453. new_chrg_bchno := ""
  28454. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  28455. new_chrg_bchno = chrg_bchno
  28456. if adminUser.CurrentOrgId == 10265 {
  28457. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28458. new_chrg_bchno = "0000"
  28459. }
  28460. }
  28461. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28462. var patientPrescription models.HisPrescriptionInfo
  28463. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  28464. if patientPrescription.ID == 0 {
  28465. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  28466. }
  28467. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28468. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28469. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  28470. strconv.FormatInt(his.PatientId, 10)
  28471. var res2406 Result2406
  28472. //安徽单病种处理
  28473. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  28474. data := make(map[string]interface{})
  28475. client := &http.Client{}
  28476. data["psn_no"] = his.PsnNo
  28477. data["mdtrt_id"] = his.Number
  28478. data["operator"] = roles.UserName
  28479. data["cert_no"] = his.IdCardNo
  28480. data["org_name"] = miConfig.OrgName
  28481. data["psn_name"] = his.Name
  28482. data["ipt_otp_no"] = his.IptOtpNo
  28483. data["ipt_psn_sp_flag_type"] = "0901"
  28484. data["ipt_psn_sp_flag"] = "1"
  28485. data["fixmedins_code"] = miConfig.Code
  28486. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28487. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28488. data["url"] = miConfig.Url
  28489. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28490. bytesData, _ := json.Marshal(data)
  28491. var req *http.Request
  28492. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28493. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28494. resp, _ := client.Do(req)
  28495. defer resp.Body.Close()
  28496. body, ioErr := ioutil.ReadAll(resp.Body)
  28497. if ioErr != nil {
  28498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28500. return
  28501. }
  28502. var respJSON map[string]interface{}
  28503. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28506. return
  28507. }
  28508. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28509. if status == "0" {
  28510. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28511. c.ServeSuccessJSON(map[string]interface{}{
  28512. "failed_code": -10,
  28513. "msg": err_msg,
  28514. })
  28515. return
  28516. }
  28517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28518. userJSONBytes, _ := json.Marshal(respJSON)
  28519. fmt.Println("log")
  28520. fmt.Println(string(userJSONBytes))
  28521. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28522. utils.ErrorLog("解析失败:%v", err)
  28523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28524. return
  28525. }
  28526. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  28527. data := make(map[string]interface{})
  28528. client := &http.Client{}
  28529. data["psn_no"] = his.PsnNo
  28530. data["mdtrt_id"] = his.Number
  28531. data["operator"] = roles.UserName
  28532. data["cert_no"] = his.IdCardNo
  28533. data["org_name"] = miConfig.OrgName
  28534. data["psn_name"] = his.Name
  28535. data["ipt_otp_no"] = his.IptOtpNo
  28536. data["ipt_psn_sp_flag_type"] = "0901"
  28537. data["ipt_psn_sp_flag"] = "1"
  28538. data["fixmedins_code"] = miConfig.Code
  28539. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28540. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28541. data["url"] = miConfig.Url
  28542. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28543. bytesData, _ := json.Marshal(data)
  28544. var req *http.Request
  28545. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28546. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28547. resp, _ := client.Do(req)
  28548. defer resp.Body.Close()
  28549. body, ioErr := ioutil.ReadAll(resp.Body)
  28550. if ioErr != nil {
  28551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28553. return
  28554. }
  28555. var respJSON map[string]interface{}
  28556. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28559. return
  28560. }
  28561. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28562. if status == "0" {
  28563. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28564. c.ServeSuccessJSON(map[string]interface{}{
  28565. "failed_code": -10,
  28566. "msg": err_msg,
  28567. })
  28568. return
  28569. }
  28570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28571. userJSONBytes, _ := json.Marshal(respJSON)
  28572. fmt.Println("log")
  28573. fmt.Println(string(userJSONBytes))
  28574. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28575. utils.ErrorLog("解析失败:%v", err)
  28576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28577. return
  28578. }
  28579. }
  28580. if res2406.Infcode != 0 {
  28581. adminUser := c.GetAdminUserInfo()
  28582. errlog := &models.HisOrderError{
  28583. UserOrgId: adminUser.CurrentOrgId,
  28584. Ctime: time.Now().Unix(),
  28585. Mtime: time.Now().Unix(),
  28586. ErrMsg: res2406.ErrMsg,
  28587. Status: 1,
  28588. PatientId: id,
  28589. RecordTime: recordDateTime,
  28590. Stage: 3,
  28591. }
  28592. service.CreateErrMsgLog(errlog)
  28593. c.ServeSuccessJSON(map[string]interface{}{
  28594. "failed_code": -10,
  28595. "msg": res2406.ErrMsg,
  28596. })
  28597. return
  28598. }
  28599. var res2 ResultSix
  28600. var res3 GZResultSix
  28601. var resSix10265 ResultSix10265
  28602. //var time_stamp string
  28603. if miConfig.MdtrtareaAdmvs == "421300" {
  28604. data := make(map[string]interface{})
  28605. client := &http.Client{}
  28606. data["psn_no"] = his.PsnNo
  28607. data["mdtrt_id"] = his.Number
  28608. data["department"] = department.Name
  28609. data["org_name"] = miConfig.OrgName
  28610. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28611. data["doctor_id"] = doctor_info.DoctorNumber
  28612. data["doctor_name"] = roles.UserName
  28613. data["fixmedins_code"] = miConfig.Code
  28614. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28615. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28616. data["secret_key"] = miConfig.SecretKey
  28617. data["sick_code"] = sickConfig.CountryCode
  28618. data["sick_name"] = sickConfig.ClassName
  28619. data["begin_time"] = begin_time
  28620. data["dept"] = strconv.FormatInt(department.ID, 10)
  28621. data["config"] = config
  28622. data["opter"] = roles.UserName
  28623. fmt.Println(data)
  28624. bytesData, _ := json.Marshal(data)
  28625. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28626. resp, _ := client.Do(req)
  28627. defer resp.Body.Close()
  28628. body, ioErr := ioutil.ReadAll(resp.Body)
  28629. if ioErr != nil {
  28630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28632. return
  28633. }
  28634. var respJSON map[string]interface{}
  28635. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28638. return
  28639. }
  28640. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28641. userJSONBytes, _ := json.Marshal(respJSON)
  28642. fmt.Println("log")
  28643. fmt.Println(string(userJSONBytes))
  28644. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28645. utils.ErrorLog("解析失败:%v", err)
  28646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28647. return
  28648. }
  28649. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28650. data := make(map[string]interface{})
  28651. client := &http.Client{}
  28652. data["psn_no"] = his.PsnNo
  28653. data["mdtrt_id"] = his.Number
  28654. data["department"] = department.Name
  28655. data["org_name"] = miConfig.OrgName
  28656. if reg_type == 11 && his.Insutype == "390" {
  28657. data["med_type"] = "110104"
  28658. } else {
  28659. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28660. }
  28661. data["doctor_id"] = doctor_info.DoctorNumber
  28662. data["doctor_name"] = roles.UserName
  28663. data["fixmedins_code"] = miConfig.Code
  28664. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28665. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28666. data["secret_key"] = miConfig.SecretKey
  28667. data["sick_code"] = sickConfig.CountryCode
  28668. data["sick_name"] = sickConfig.ClassName
  28669. data["begin_time"] = begin_time
  28670. data["dept"] = strconv.FormatInt(department.ID, 10)
  28671. data["config"] = config
  28672. data["opter"] = roles.UserName
  28673. fmt.Println(data)
  28674. bytesData, _ := json.Marshal(data)
  28675. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28676. resp, _ := client.Do(req)
  28677. defer resp.Body.Close()
  28678. body, ioErr := ioutil.ReadAll(resp.Body)
  28679. if ioErr != nil {
  28680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28682. return
  28683. }
  28684. var respJSON map[string]interface{}
  28685. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28688. return
  28689. }
  28690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28691. userJSONBytes, _ := json.Marshal(respJSON)
  28692. fmt.Println("log")
  28693. fmt.Println(string(userJSONBytes))
  28694. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28695. utils.ErrorLog("解析失败:%v", err)
  28696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28697. return
  28698. }
  28699. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28700. data := make(map[string]interface{})
  28701. client := &http.Client{}
  28702. data["psn_no"] = his.PsnNo
  28703. data["mdtrt_id"] = his.Number
  28704. data["department"] = department.Name
  28705. data["org_name"] = miConfig.OrgName
  28706. if reg_type == 11 && his.Insutype == "390" {
  28707. data["med_type"] = "110104"
  28708. } else {
  28709. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28710. }
  28711. data["doctor_id"] = doctor_info.DoctorNumber
  28712. data["doctor_name"] = roles.UserName
  28713. data["fixmedins_code"] = miConfig.Code
  28714. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28715. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28716. data["secret_key"] = miConfig.SecretKey
  28717. data["sick_code"] = sickConfig.CountryCode
  28718. data["sick_name"] = sickConfig.ClassName
  28719. data["begin_time"] = begin_time
  28720. data["dept"] = strconv.FormatInt(department.ID, 10)
  28721. data["config"] = config
  28722. data["opter"] = roles.UserName
  28723. fmt.Println(data)
  28724. bytesData, _ := json.Marshal(data)
  28725. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28726. resp, _ := client.Do(req)
  28727. defer resp.Body.Close()
  28728. body, ioErr := ioutil.ReadAll(resp.Body)
  28729. if ioErr != nil {
  28730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28732. return
  28733. }
  28734. var respJSON map[string]interface{}
  28735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28738. return
  28739. }
  28740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28741. userJSONBytes, _ := json.Marshal(respJSON)
  28742. fmt.Println("log")
  28743. fmt.Println(string(userJSONBytes))
  28744. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28745. utils.ErrorLog("解析失败:%v", err)
  28746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28747. return
  28748. }
  28749. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28750. data := make(map[string]interface{})
  28751. client := &http.Client{}
  28752. data["psn_no"] = his.PsnNo
  28753. data["mdtrt_id"] = his.Number
  28754. data["department"] = department.Name
  28755. data["org_name"] = miConfig.OrgName
  28756. if reg_type == 11 && his.Insutype == "390" {
  28757. data["med_type"] = "110104"
  28758. } else {
  28759. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28760. }
  28761. data["doctor_id"] = doctor_info.DoctorNumber
  28762. data["doctor_name"] = roles.UserName
  28763. data["fixmedins_code"] = miConfig.Code
  28764. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28765. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28766. data["secret_key"] = miConfig.SecretKey
  28767. data["sick_code"] = sickConfig.CountryCode
  28768. data["sick_name"] = sickConfig.ClassName
  28769. data["begin_time"] = begin_time
  28770. data["dept"] = strconv.FormatInt(department.ID, 10)
  28771. data["config"] = config
  28772. data["opter"] = roles.UserName
  28773. fmt.Println(data)
  28774. bytesData, _ := json.Marshal(data)
  28775. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28776. resp, _ := client.Do(req)
  28777. defer resp.Body.Close()
  28778. body, ioErr := ioutil.ReadAll(resp.Body)
  28779. if ioErr != nil {
  28780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28782. return
  28783. }
  28784. var respJSON map[string]interface{}
  28785. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28788. return
  28789. }
  28790. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28791. userJSONBytes, _ := json.Marshal(respJSON)
  28792. fmt.Println("log")
  28793. fmt.Println(string(userJSONBytes))
  28794. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28795. utils.ErrorLog("解析失败:%v", err)
  28796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28797. return
  28798. }
  28799. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28800. data := make(map[string]interface{})
  28801. client := &http.Client{}
  28802. data["psn_no"] = his.PsnNo
  28803. data["mdtrt_id"] = his.Number
  28804. data["doctor"] = roles.UserName
  28805. data["department"] = department.Name
  28806. data["org_name"] = miConfig.OrgName
  28807. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28808. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28809. data["fixmedins_code"] = miConfig.Code
  28810. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28811. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28812. data["secret_key"] = miConfig.SecretKey
  28813. data["sick_code"] = sickConfig.CountryCode
  28814. data["sick_name"] = sickConfig.ClassName
  28815. data["begin_time"] = begin_time
  28816. data["dept"] = strconv.FormatInt(department.ID, 10)
  28817. data["config"] = config
  28818. data["url"] = miConfig.Url
  28819. data["ak"] = miConfig.AccessKey
  28820. data["cainfo"] = miConfig.Cainfo
  28821. bytesData, _ := json.Marshal(data)
  28822. var req *http.Request
  28823. if miConfig.MdtrtareaAdmvs == "320921" {
  28824. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28825. } else {
  28826. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28827. }
  28828. resp, _ := client.Do(req)
  28829. defer resp.Body.Close()
  28830. body, ioErr := ioutil.ReadAll(resp.Body)
  28831. if ioErr != nil {
  28832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28834. return
  28835. }
  28836. var respJSON map[string]interface{}
  28837. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28840. return
  28841. }
  28842. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28843. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28844. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28846. userJSONBytes, _ := json.Marshal(respJSON)
  28847. fmt.Println("log")
  28848. fmt.Println(string(userJSONBytes))
  28849. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28850. utils.ErrorLog("解析失败:%v", err)
  28851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28852. return
  28853. }
  28854. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28855. res2.Output = resSix10265.Output
  28856. res2.ErrMsg = resSix10265.ErrMsg
  28857. res2.Cainfo = resSix10265.Cainfo
  28858. res2.WarnMsg = resSix10265.WarnMsg
  28859. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28860. res2.Infcode = infocode
  28861. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28862. data := make(map[string]interface{})
  28863. client := &http.Client{}
  28864. data["psn_no"] = his.PsnNo
  28865. data["mdtrt_id"] = his.Number
  28866. data["doctor"] = roles.UserName
  28867. data["department"] = department.Name
  28868. data["org_name"] = miConfig.OrgName
  28869. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28870. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28871. data["fixmedins_code"] = miConfig.Code
  28872. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28873. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28874. data["secret_key"] = miConfig.SecretKey
  28875. data["sick_code"] = sickConfig.CountryCode
  28876. data["sick_name"] = sickConfig.ClassName
  28877. data["begin_time"] = begin_time
  28878. data["dept"] = strconv.FormatInt(department.ID, 10)
  28879. data["config"] = config
  28880. //data["url"] = miConfig.Url
  28881. //data["ak"] = miConfig.AccessKey
  28882. data["cainfo"] = miConfig.Cainfo
  28883. fmt.Println(data)
  28884. bytesData, _ := json.Marshal(data)
  28885. var req *http.Request
  28886. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28887. resp, _ := client.Do(req)
  28888. defer resp.Body.Close()
  28889. body, ioErr := ioutil.ReadAll(resp.Body)
  28890. if ioErr != nil {
  28891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28893. return
  28894. }
  28895. var respJSON map[string]interface{}
  28896. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28899. return
  28900. }
  28901. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28902. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28903. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28904. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28905. userJSONBytes, _ := json.Marshal(respJSON)
  28906. fmt.Println("log")
  28907. fmt.Println(string(userJSONBytes))
  28908. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28909. utils.ErrorLog("解析失败:%v", err)
  28910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28911. return
  28912. }
  28913. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28914. res2.Output = resSix10265.Output
  28915. res2.ErrMsg = resSix10265.ErrMsg
  28916. res2.Cainfo = resSix10265.Cainfo
  28917. res2.WarnMsg = resSix10265.WarnMsg
  28918. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28919. res2.Infcode = infocode
  28920. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28921. 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)
  28922. saveLog(result, requestLog, "2203", "上传就诊信息")
  28923. var respJSON2 map[string]interface{}
  28924. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28927. return
  28928. }
  28929. userJSONBytes2, _ := json.Marshal(respJSON2)
  28930. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28931. utils.ErrorLog("解析失败:%v", err)
  28932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28933. return
  28934. }
  28935. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28936. var result string
  28937. var requestLog string
  28938. 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, "")
  28939. saveLog(result, requestLog, "2203", "上传就诊信息")
  28940. var respJSON2 map[string]interface{}
  28941. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28944. return
  28945. }
  28946. userJSONBytes2, _ := json.Marshal(respJSON2)
  28947. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28948. utils.ErrorLog("解析失败:%v", err)
  28949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28950. return
  28951. }
  28952. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28953. var result string
  28954. var requestLog string
  28955. 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, "")
  28956. saveLog(result, requestLog, "2203", "上传就诊信息")
  28957. var respJSON2 map[string]interface{}
  28958. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28961. return
  28962. }
  28963. userJSONBytes2, _ := json.Marshal(respJSON2)
  28964. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28965. utils.ErrorLog("解析失败:%v", err)
  28966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28967. return
  28968. }
  28969. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28970. var result string
  28971. var requestLog string
  28972. 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, "")
  28973. saveLog(result, requestLog, "2203", "上传就诊信息")
  28974. var respJSON2 map[string]interface{}
  28975. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28978. return
  28979. }
  28980. userJSONBytes2, _ := json.Marshal(respJSON2)
  28981. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28982. utils.ErrorLog("解析失败:%v", err)
  28983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28984. return
  28985. }
  28986. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28987. data := make(map[string]interface{})
  28988. client := &http.Client{}
  28989. data["psn_no"] = his.PsnNo
  28990. data["mdtrt_id"] = his.Number
  28991. data["operator"] = roles.UserName
  28992. data["department"] = department.Name
  28993. data["org_name"] = miConfig.OrgName
  28994. var med_type string
  28995. if his.Insutype == "390" {
  28996. if reg_type == 992102 {
  28997. med_type = "992102"
  28998. data["sick_code"] = "ZDZ940"
  28999. data["sick_name"] = "慢性肾衰竭"
  29000. }
  29001. if reg_type == 140104 {
  29002. med_type = "140104"
  29003. data["sick_code"] = sickConfig.CountryCode
  29004. data["sick_name"] = sickConfig.ClassName
  29005. }
  29006. if reg_type == 14 {
  29007. med_type = "140104"
  29008. data["sick_code"] = sickConfig.CountryCode
  29009. data["sick_name"] = sickConfig.ClassName
  29010. }
  29011. } else if his.Insutype == "310" {
  29012. if reg_type == 992102 {
  29013. med_type = "992102"
  29014. data["sick_code"] = "ZDZ940"
  29015. data["sick_name"] = "慢性肾衰竭"
  29016. }
  29017. if reg_type == 140104 {
  29018. med_type = "140104"
  29019. data["sick_code"] = sickConfig.CountryCode
  29020. data["sick_name"] = sickConfig.ClassName
  29021. }
  29022. if reg_type == 14 {
  29023. med_type = "14"
  29024. data["sick_code"] = sickConfig.CountryCode
  29025. data["sick_name"] = sickConfig.ClassName
  29026. }
  29027. }
  29028. data["med_type"] = med_type
  29029. data["doctor_number"] = doctor_info.DoctorNumber
  29030. data["doctor_name"] = doctor_info.UserName
  29031. data["fixmedins_code"] = miConfig.Code
  29032. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29033. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29034. data["secret_key"] = miConfig.SecretKey
  29035. data["begin_time"] = begin_time
  29036. data["dept"] = strconv.FormatInt(department.ID, 10)
  29037. data["config"] = config
  29038. data["url"] = miConfig.Url
  29039. data["ak"] = miConfig.AccessKey
  29040. data["cainfo"] = miConfig.Cainfo
  29041. bytesData, _ := json.Marshal(data)
  29042. var req *http.Request
  29043. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  29044. resp, _ := client.Do(req)
  29045. defer resp.Body.Close()
  29046. body, ioErr := ioutil.ReadAll(resp.Body)
  29047. if ioErr != nil {
  29048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29050. return
  29051. }
  29052. var respJSON map[string]interface{}
  29053. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29056. return
  29057. }
  29058. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29059. if status == "0" {
  29060. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29061. c.ServeSuccessJSON(map[string]interface{}{
  29062. "failed_code": -10,
  29063. "msg": err_msg,
  29064. })
  29065. return
  29066. }
  29067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29068. userJSONBytes, _ := json.Marshal(respJSON)
  29069. fmt.Println("log")
  29070. fmt.Println(string(userJSONBytes))
  29071. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29072. utils.ErrorLog("解析失败:%v", err)
  29073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29074. return
  29075. }
  29076. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29077. data := make(map[string]interface{})
  29078. client := &http.Client{}
  29079. data["psn_no"] = his.PsnNo
  29080. data["mdtrt_id"] = his.Number
  29081. data["operator"] = roles.UserName
  29082. data["department"] = department.Name
  29083. data["org_name"] = miConfig.OrgName
  29084. var med_type string
  29085. if his.Insutype == "390" {
  29086. if reg_type == 992102 {
  29087. med_type = "992102"
  29088. data["sick_code"] = sickConfig.CountryCode
  29089. data["sick_name"] = sickConfig.ClassName
  29090. }
  29091. if reg_type == 140104 {
  29092. med_type = "140104"
  29093. data["sick_code"] = sickConfig.CountryCode
  29094. data["sick_name"] = sickConfig.ClassName
  29095. }
  29096. if reg_type == 140201 {
  29097. med_type = "140201"
  29098. data["sick_code"] = sickConfig.CountryCode
  29099. data["sick_name"] = sickConfig.ClassName
  29100. }
  29101. if reg_type == 14 {
  29102. med_type = "14"
  29103. data["sick_code"] = sickConfig.CountryCode
  29104. data["sick_name"] = sickConfig.ClassName
  29105. }
  29106. } else if his.Insutype == "310" {
  29107. if reg_type == 992102 {
  29108. med_type = "992102"
  29109. data["sick_code"] = sickConfig.CountryCode
  29110. data["sick_name"] = sickConfig.ClassName
  29111. }
  29112. if reg_type == 140104 {
  29113. med_type = "140104"
  29114. data["sick_code"] = sickConfig.CountryCode
  29115. data["sick_name"] = sickConfig.ClassName
  29116. }
  29117. if reg_type == 140201 {
  29118. med_type = "140201"
  29119. data["sick_code"] = sickConfig.CountryCode
  29120. data["sick_name"] = sickConfig.ClassName
  29121. }
  29122. if reg_type == 14 {
  29123. med_type = "14"
  29124. data["sick_code"] = sickConfig.CountryCode
  29125. data["sick_name"] = sickConfig.ClassName
  29126. }
  29127. }
  29128. data["med_type"] = med_type
  29129. data["doctor_number"] = doctor_info.DoctorNumber
  29130. data["doctor_name"] = doctor_info.UserName
  29131. data["fixmedins_code"] = miConfig.Code
  29132. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29133. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29134. data["secret_key"] = miConfig.SecretKey
  29135. data["begin_time"] = begin_time
  29136. data["dept"] = strconv.FormatInt(department.ID, 10)
  29137. data["config"] = config
  29138. data["url"] = miConfig.Url
  29139. data["ak"] = miConfig.AccessKey
  29140. data["cainfo"] = miConfig.Cainfo
  29141. bytesData, _ := json.Marshal(data)
  29142. var req *http.Request
  29143. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  29144. resp, _ := client.Do(req)
  29145. defer resp.Body.Close()
  29146. body, ioErr := ioutil.ReadAll(resp.Body)
  29147. if ioErr != nil {
  29148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29150. return
  29151. }
  29152. var respJSON map[string]interface{}
  29153. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29156. return
  29157. }
  29158. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29159. if status == "0" {
  29160. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29161. c.ServeSuccessJSON(map[string]interface{}{
  29162. "failed_code": -10,
  29163. "msg": err_msg,
  29164. })
  29165. return
  29166. }
  29167. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29168. userJSONBytes, _ := json.Marshal(respJSON)
  29169. fmt.Println("log")
  29170. fmt.Println(string(userJSONBytes))
  29171. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29172. utils.ErrorLog("解析失败:%v", err)
  29173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29174. return
  29175. }
  29176. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29177. var result string
  29178. var requestLog string
  29179. 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, "")
  29180. saveLog(result, requestLog, "2203", "上传就诊信息")
  29181. var respJSON2 map[string]interface{}
  29182. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29185. return
  29186. }
  29187. userJSONBytes2, _ := json.Marshal(respJSON2)
  29188. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29189. utils.ErrorLog("解析失败:%v", err)
  29190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29191. return
  29192. }
  29193. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29194. data := make(map[string]interface{})
  29195. client := &http.Client{}
  29196. data["psn_no"] = his.PsnNo
  29197. data["mdtrt_id"] = his.Number
  29198. data["doctor"] = roles.UserName
  29199. data["department"] = department.Name
  29200. data["org_name"] = miConfig.OrgName
  29201. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29202. data["doctor_id"] = doctor_info.DoctorNumber
  29203. data["fixmedins_code"] = miConfig.Code
  29204. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29205. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29206. data["secret_key"] = miConfig.SecretKey
  29207. data["sick_code"] = sickConfig.CountryCode
  29208. data["sick_name"] = sickConfig.ClassName
  29209. data["begin_time"] = begin_time
  29210. data["new_doctor_name"] = doctor_info.UserName
  29211. data["dept"] = strconv.FormatInt(department.ID, 10)
  29212. data["config"] = config
  29213. bytesData, _ := json.Marshal(data)
  29214. var req *http.Request
  29215. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  29216. resp, _ := client.Do(req)
  29217. defer resp.Body.Close()
  29218. body, ioErr := ioutil.ReadAll(resp.Body)
  29219. if ioErr != nil {
  29220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29222. return
  29223. }
  29224. var respJSON map[string]interface{}
  29225. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29228. return
  29229. }
  29230. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29231. userJSONBytes, _ := json.Marshal(respJSON)
  29232. fmt.Println("log")
  29233. fmt.Println(string(userJSONBytes))
  29234. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29235. utils.ErrorLog("解析失败:%v", err)
  29236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29237. return
  29238. }
  29239. } else {
  29240. var result string
  29241. var requestLog string
  29242. if miConfig.MdtrtareaAdmvs == "440781" { //
  29243. 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)
  29244. } else {
  29245. if miConfig.Code == "H15049901371" {
  29246. //赤峰地区国家医保医疗类别
  29247. //职工透析:医疗类别选特殊情况门诊990502
  29248. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29249. var med_type string
  29250. if his.Insutype == "390" {
  29251. if reg_type == 14 {
  29252. med_type = "9933"
  29253. } else if reg_type == 11 {
  29254. med_type = "11"
  29255. }
  29256. } else if his.Insutype == "310" {
  29257. if reg_type == 14 {
  29258. med_type = "990502"
  29259. } else if reg_type == 11 {
  29260. med_type = "11"
  29261. }
  29262. }
  29263. 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)
  29264. } else {
  29265. 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)
  29266. }
  29267. saveLog(result, requestLog, "2203", "上传就诊信息")
  29268. var respJSON2 map[string]interface{}
  29269. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29272. return
  29273. }
  29274. userJSONBytes2, _ := json.Marshal(respJSON2)
  29275. if miConfig.Code == "H15049901371" {
  29276. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  29277. utils.ErrorLog("解析失败:%v", err)
  29278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29279. return
  29280. }
  29281. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29282. res2.Output = resSix10265.Output
  29283. res2.ErrMsg = resSix10265.ErrMsg
  29284. res2.Cainfo = resSix10265.Cainfo
  29285. res2.WarnMsg = resSix10265.WarnMsg
  29286. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29287. res2.Infcode = infocode
  29288. } else {
  29289. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29290. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  29291. utils.ErrorLog("解析失败:%v", err)
  29292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29293. return
  29294. }
  29295. res2.Infcode = res3.Infcode
  29296. } else {
  29297. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29298. utils.ErrorLog("解析失败:%v", err)
  29299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29300. return
  29301. }
  29302. }
  29303. }
  29304. }
  29305. }
  29306. if res2.Infcode == -1 {
  29307. adminUser := c.GetAdminUserInfo()
  29308. errlog := &models.HisOrderError{
  29309. UserOrgId: adminUser.CurrentOrgId,
  29310. Ctime: time.Now().Unix(),
  29311. Mtime: time.Now().Unix(),
  29312. ErrMsg: res2.ErrMsg,
  29313. Status: 1,
  29314. PatientId: id,
  29315. RecordTime: recordDateTime,
  29316. Stage: 3,
  29317. }
  29318. service.CreateErrMsgLog(errlog)
  29319. c.ServeSuccessJSON(map[string]interface{}{
  29320. "failed_code": -10,
  29321. "msg": res2.ErrMsg,
  29322. })
  29323. return
  29324. }
  29325. if res2.Infcode != 0 {
  29326. adminUser := c.GetAdminUserInfo()
  29327. errlog := &models.HisOrderError{
  29328. UserOrgId: adminUser.CurrentOrgId,
  29329. Ctime: time.Now().Unix(),
  29330. Mtime: time.Now().Unix(),
  29331. ErrMsg: res2.ErrMsg,
  29332. Status: 1,
  29333. PatientId: id,
  29334. RecordTime: recordDateTime,
  29335. Stage: 3,
  29336. }
  29337. service.CreateErrMsgLog(errlog)
  29338. c.ServeSuccessJSON(map[string]interface{}{
  29339. "failed_code": -10,
  29340. "msg": res2.ErrMsg,
  29341. })
  29342. return
  29343. } else {
  29344. his.Diagnosis = diagnosis_id
  29345. his.SickType = sickConfig.ID
  29346. his.PType = fmt.Sprintf("%d", reg_type)
  29347. service.UpdateHisPatientThree(&his)
  29348. data := make(map[string]interface{})
  29349. if settle_accounts_type == 1 { //日结
  29350. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  29351. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  29352. } else {
  29353. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  29354. }
  29355. data["pre"] = prescriptions
  29356. } else { //月结
  29357. start_time_str := c.GetString("start_time")
  29358. end_time_str := c.GetString("end_time")
  29359. timeLayout := "2006-01-02"
  29360. loc, _ := time.LoadLocation("Local")
  29361. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  29362. if err != nil {
  29363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29364. return
  29365. }
  29366. recordStartTime := theStartTime.Unix()
  29367. start_time = recordStartTime
  29368. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  29369. if err != nil {
  29370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29371. return
  29372. }
  29373. recordEndTime := theEndTime.Unix()
  29374. end_time = recordEndTime
  29375. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  29376. data["pre"] = prescriptions
  29377. }
  29378. client := &http.Client{}
  29379. data["psn_no"] = his.PsnNo
  29380. data["mdtrt_id"] = his.Number
  29381. data["chrg_bchno"] = new_chrg_bchno
  29382. data["org_name"] = miConfig.OrgName
  29383. data["doctor"] = doctor_info.UserName
  29384. data["doctor_id"] = doctor_info.DoctorNumber
  29385. data["dept"] = department.Name
  29386. data["fixmedins_code"] = miConfig.Code
  29387. data["opter"] = roles.UserName
  29388. data["dept_code"] = department.Number
  29389. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29390. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29391. data["secret_key"] = miConfig.SecretKey
  29392. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  29393. data["url"] = miConfig.Url
  29394. data["ak"] = miConfig.AccessKey
  29395. data["new_doctor_name"] = patientPrescription.Doctor
  29396. if his.Insutype == "390" {
  29397. if reg_type == 992102 {
  29398. data["diag_code"] = "ZDZ940"
  29399. }
  29400. if reg_type == 140104 {
  29401. data["diag_code"] = sickConfig.CountryCode
  29402. }
  29403. if reg_type == 140201 {
  29404. data["diag_code"] = sickConfig.CountryCode
  29405. }
  29406. if reg_type == 14 {
  29407. data["diag_code"] = sickConfig.CountryCode
  29408. }
  29409. } else if his.Insutype == "310" {
  29410. if miConfig.MdtrtareaAdmvs == "341203" {
  29411. if reg_type == 992102 {
  29412. data["diag_code"] = "ZDZ940"
  29413. }
  29414. if reg_type != 992102 {
  29415. data["diag_code"] = sickConfig.CountryCode
  29416. }
  29417. } else {
  29418. data["diag_code"] = sickConfig.CountryCode
  29419. }
  29420. }
  29421. data["cainfo"] = miConfig.Cainfo
  29422. data["opter"] = roles.UserName
  29423. var ids []int64
  29424. for _, item := range prescriptions {
  29425. ids = append(ids, item.ID)
  29426. }
  29427. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29428. if config.IsOpen == 1 { //对接了医保,走医保流程
  29429. var res ResultFour
  29430. var resFour10265 ResultFour10265
  29431. if miConfig.MdtrtareaAdmvs == "421300" {
  29432. bytesData, _ := json.Marshal(data)
  29433. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  29434. resp, _ := client.Do(req)
  29435. defer resp.Body.Close()
  29436. body, ioErr := ioutil.ReadAll(resp.Body)
  29437. if ioErr != nil {
  29438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29440. return
  29441. }
  29442. var respJSON map[string]interface{}
  29443. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29446. return
  29447. }
  29448. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29449. userJSONBytes, _ := json.Marshal(respJSON)
  29450. fmt.Println("log")
  29451. fmt.Println(string(userJSONBytes))
  29452. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29453. utils.ErrorLog("解析失败:%v", err)
  29454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29455. return
  29456. }
  29457. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29458. bytesData, _ := json.Marshal(data)
  29459. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  29460. resp, _ := client.Do(req)
  29461. defer resp.Body.Close()
  29462. body, ioErr := ioutil.ReadAll(resp.Body)
  29463. if ioErr != nil {
  29464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29466. return
  29467. }
  29468. var respJSON map[string]interface{}
  29469. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29472. return
  29473. }
  29474. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29475. userJSONBytes, _ := json.Marshal(respJSON)
  29476. fmt.Println("log")
  29477. fmt.Println(string(userJSONBytes))
  29478. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29479. utils.ErrorLog("解析失败:%v", err)
  29480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29481. return
  29482. }
  29483. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29484. bytesData, _ := json.Marshal(data)
  29485. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29486. resp, _ := client.Do(req)
  29487. defer resp.Body.Close()
  29488. body, ioErr := ioutil.ReadAll(resp.Body)
  29489. if ioErr != nil {
  29490. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29492. return
  29493. }
  29494. var respJSON map[string]interface{}
  29495. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29498. return
  29499. }
  29500. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29501. userJSONBytes, _ := json.Marshal(respJSON)
  29502. fmt.Println("log")
  29503. fmt.Println(string(userJSONBytes))
  29504. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29505. utils.ErrorLog("解析失败:%v", err)
  29506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29507. return
  29508. }
  29509. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29510. bytesData, _ := json.Marshal(data)
  29511. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29512. resp, _ := client.Do(req)
  29513. defer resp.Body.Close()
  29514. body, ioErr := ioutil.ReadAll(resp.Body)
  29515. if ioErr != nil {
  29516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29518. return
  29519. }
  29520. var respJSON map[string]interface{}
  29521. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29524. return
  29525. }
  29526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29527. userJSONBytes, _ := json.Marshal(respJSON)
  29528. fmt.Println("log")
  29529. fmt.Println(string(userJSONBytes))
  29530. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29531. utils.ErrorLog("解析失败:%v", err)
  29532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29533. return
  29534. }
  29535. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29536. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29537. if result3101.Infcode == "0" {
  29538. if len(result3101.Output.Result) > 0 {
  29539. var errMsgs []string
  29540. for _, item := range result3101.Output.Result {
  29541. errMsgs = append(errMsgs, item.VolaCont)
  29542. }
  29543. c.ServeSuccessJSON(map[string]interface{}{
  29544. "failed_code": -10,
  29545. "msg": errMsgs,
  29546. })
  29547. return
  29548. } else {
  29549. if miConfig.MdtrtareaAdmvs == "320921" {
  29550. data["doctor_id"] = "D320923012139"
  29551. } else {
  29552. data["doctor_id"] = "D371621008686"
  29553. }
  29554. bytesData, _ := json.Marshal(data)
  29555. var req *http.Request
  29556. if miConfig.MdtrtareaAdmvs == "320921" {
  29557. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29558. } else {
  29559. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29560. }
  29561. resp, _ := client.Do(req)
  29562. defer resp.Body.Close()
  29563. body, ioErr := ioutil.ReadAll(resp.Body)
  29564. if ioErr != nil {
  29565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29567. return
  29568. }
  29569. var respJSON map[string]interface{}
  29570. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29573. return
  29574. }
  29575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29576. userJSONBytes, _ := json.Marshal(respJSON)
  29577. fmt.Println("log")
  29578. fmt.Println(string(userJSONBytes))
  29579. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29580. utils.ErrorLog("解析失败:%v", err)
  29581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29582. return
  29583. }
  29584. res.InfRefmsgid = resFour10265.InfRefmsgid
  29585. res.Output = resFour10265.Output
  29586. res.ErrMsg = resFour10265.ErrMsg
  29587. res.Cainfo = resFour10265.Cainfo
  29588. res.WarnMsg = resFour10265.WarnMsg
  29589. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29590. res.Infcode = infocode
  29591. }
  29592. }
  29593. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29594. var pagesize int = 5
  29595. var start int = 1
  29596. var stop int
  29597. var pagecount int
  29598. var curpage int
  29599. data["doctor_id"] = doctor_info.DoctorNumber
  29600. var res2 ResultFour
  29601. //var result res.
  29602. //总页数,向上取整,注意除之前要先转换类型为float64
  29603. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29604. for curpage = 1; curpage <= pagecount; curpage++ {
  29605. if curpage == 1 {
  29606. start = 1
  29607. } else {
  29608. start = (curpage-1)*pagesize + 1
  29609. }
  29610. stop = curpage * pagesize
  29611. if stop > len(prescriptions) {
  29612. stop = len(prescriptions)
  29613. }
  29614. //var requestLog string
  29615. data["pre"] = prescriptions[start-1 : stop]
  29616. fmt.Println(data["pre"])
  29617. bytesData, _ := json.Marshal(data)
  29618. var req *http.Request
  29619. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29620. resp, _ := client.Do(req)
  29621. defer resp.Body.Close()
  29622. body, ioErr := ioutil.ReadAll(resp.Body)
  29623. if ioErr != nil {
  29624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29626. return
  29627. }
  29628. var respJSON map[string]interface{}
  29629. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29632. return
  29633. }
  29634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29635. userJSONBytes, _ := json.Marshal(respJSON)
  29636. fmt.Println("log")
  29637. fmt.Println(string(userJSONBytes))
  29638. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29639. utils.ErrorLog("解析失败:%v", err)
  29640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29641. return
  29642. }
  29643. res.InfRefmsgid = resFour10265.InfRefmsgid
  29644. res.Output = resFour10265.Output
  29645. res.ErrMsg = resFour10265.ErrMsg
  29646. res.Cainfo = resFour10265.Cainfo
  29647. res.WarnMsg = resFour10265.WarnMsg
  29648. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29649. res.Infcode = infocode
  29650. if infocode == 0 {
  29651. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29652. } else {
  29653. isSuccess = false
  29654. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29655. res.Infcode = -1
  29656. res.ErrMsg = resFour10265.ErrMsg
  29657. errlog := &models.HisOrderError{
  29658. UserOrgId: adminUser.CurrentOrgId,
  29659. Ctime: time.Now().Unix(),
  29660. Mtime: time.Now().Unix(),
  29661. Number: chrg_bchno,
  29662. ErrMsg: "",
  29663. Status: 1,
  29664. PatientId: id,
  29665. RecordTime: recordDateTime,
  29666. Stage: 4,
  29667. }
  29668. service.CreateErrMsgLog(errlog)
  29669. }
  29670. }
  29671. if isSuccess {
  29672. res.Infcode = 0
  29673. res.Output.Result = res2.Output.Result
  29674. } else {
  29675. order := &models.HisOrder{
  29676. UserOrgId: adminUser.CurrentOrgId,
  29677. HisPatientId: his.ID,
  29678. PatientId: his.PatientId,
  29679. SettleAccountsDate: recordDateTime,
  29680. Ctime: time.Now().Unix(),
  29681. Mtime: time.Now().Unix(),
  29682. MdtrtId: his.Number,
  29683. PsnNo: his.PsnNo,
  29684. MedType: strconv.FormatInt(reg_type, 10),
  29685. Status: 1,
  29686. Number: chrg_bchno,
  29687. Infcode: res.Infcode,
  29688. WarnMsg: res.WarnMsg,
  29689. Cainfo: res.Cainfo,
  29690. ErrMsg: res.ErrMsg,
  29691. RespondTime: res.RefmsgTime,
  29692. InfRefmsgid: res.InfRefmsgid,
  29693. OrderStatus: 1,
  29694. IsMedicineInsurance: 1,
  29695. SettleType: settle_accounts_type,
  29696. SettleStartTime: start_time,
  29697. SettleEndTime: end_time,
  29698. Creator: roles.AdminUserId,
  29699. Modify: roles.AdminUserId,
  29700. PType: 2,
  29701. Diagnosis: diagnosis_id,
  29702. }
  29703. err = service.CreateOrder(order)
  29704. if err != nil {
  29705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29706. return
  29707. }
  29708. c.ServeSuccessJSON(map[string]interface{}{
  29709. "failed_code": -10,
  29710. "msg": res2.ErrMsg,
  29711. })
  29712. return
  29713. }
  29714. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29715. 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)
  29716. var dat map[string]interface{}
  29717. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29718. fmt.Println(dat)
  29719. } else {
  29720. fmt.Println(err)
  29721. }
  29722. saveLog(result, request_log, "2204", "上传费用明细")
  29723. userJSONBytes, _ := json.Marshal(dat)
  29724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29725. utils.ErrorLog("解析失败:%v", err)
  29726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29727. return
  29728. }
  29729. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29730. 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, "", "")
  29731. var dat map[string]interface{}
  29732. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29733. fmt.Println(dat)
  29734. } else {
  29735. fmt.Println(err)
  29736. }
  29737. saveLog(result, request_log, "2204", "上传费用明细")
  29738. userJSONBytes, _ := json.Marshal(dat)
  29739. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29740. utils.ErrorLog("解析失败:%v", err)
  29741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29742. return
  29743. }
  29744. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29745. 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, "", "")
  29746. var dat map[string]interface{}
  29747. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29748. fmt.Println(dat)
  29749. } else {
  29750. fmt.Println(err)
  29751. }
  29752. saveLog(result, request_log, "2204", "上传费用明细")
  29753. userJSONBytes, _ := json.Marshal(dat)
  29754. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29755. utils.ErrorLog("解析失败:%v", err)
  29756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29757. return
  29758. }
  29759. } else if miConfig.MdtrtareaAdmvs == "360100" {
  29760. 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, "", "")
  29761. var dat map[string]interface{}
  29762. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29763. fmt.Println(dat)
  29764. } else {
  29765. fmt.Println(err)
  29766. }
  29767. saveLog(result, request_log, "2204", "上传费用明细")
  29768. userJSONBytes, _ := json.Marshal(dat)
  29769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29770. utils.ErrorLog("解析失败:%v", err)
  29771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29772. return
  29773. }
  29774. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29775. bytesData, _ := json.Marshal(data)
  29776. var req *http.Request
  29777. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29778. resp, _ := client.Do(req)
  29779. defer resp.Body.Close()
  29780. body, ioErr := ioutil.ReadAll(resp.Body)
  29781. if ioErr != nil {
  29782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29784. return
  29785. }
  29786. var respJSON map[string]interface{}
  29787. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29790. return
  29791. }
  29792. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29793. if status == "0" {
  29794. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29795. c.ServeSuccessJSON(map[string]interface{}{
  29796. "failed_code": -10,
  29797. "msg": err_msg,
  29798. })
  29799. return
  29800. }
  29801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29802. userJSONBytes, _ := json.Marshal(respJSON)
  29803. fmt.Println("log")
  29804. fmt.Println(string(userJSONBytes))
  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 == "340699" {
  29811. bytesData, _ := json.Marshal(data)
  29812. var req *http.Request
  29813. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29814. resp, _ := client.Do(req)
  29815. defer resp.Body.Close()
  29816. body, ioErr := ioutil.ReadAll(resp.Body)
  29817. if ioErr != nil {
  29818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29820. return
  29821. }
  29822. var respJSON map[string]interface{}
  29823. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29826. return
  29827. }
  29828. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29829. if status == "0" {
  29830. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29831. c.ServeSuccessJSON(map[string]interface{}{
  29832. "failed_code": -10,
  29833. "msg": err_msg,
  29834. })
  29835. return
  29836. }
  29837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29838. userJSONBytes, _ := json.Marshal(respJSON)
  29839. fmt.Println("log")
  29840. fmt.Println(string(userJSONBytes))
  29841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29842. utils.ErrorLog("解析失败:%v", err)
  29843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29844. return
  29845. }
  29846. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29847. 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, "", "")
  29848. var dat map[string]interface{}
  29849. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29850. fmt.Println(dat)
  29851. } else {
  29852. fmt.Println(err)
  29853. }
  29854. saveLog(result, request_log, "2204", "上传费用明细")
  29855. userJSONBytes, _ := json.Marshal(dat)
  29856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29857. utils.ErrorLog("解析失败:%v", err)
  29858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29859. return
  29860. }
  29861. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29862. bytesData, _ := json.Marshal(data)
  29863. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29864. resp, _ := client.Do(req)
  29865. defer resp.Body.Close()
  29866. body, ioErr := ioutil.ReadAll(resp.Body)
  29867. if ioErr != nil {
  29868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29870. return
  29871. }
  29872. var respJSON map[string]interface{}
  29873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29876. return
  29877. }
  29878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29879. userJSONBytes, _ := json.Marshal(respJSON)
  29880. fmt.Println("log")
  29881. fmt.Println(string(userJSONBytes))
  29882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29883. utils.ErrorLog("解析失败:%v", err)
  29884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29885. return
  29886. }
  29887. } else {
  29888. if miConfig.MdtrtareaAdmvs == "441202" {
  29889. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29890. if result3101.Infcode == 0 {
  29891. if len(result3101.Output.Result) > 0 {
  29892. var errMsgs []string
  29893. for _, item := range result3101.Output.Result {
  29894. errMsgs = append(errMsgs, item.VolaCont)
  29895. }
  29896. c.ServeSuccessJSON(map[string]interface{}{
  29897. "failed_code": -10,
  29898. "msg": errMsgs,
  29899. })
  29900. return
  29901. } else {
  29902. 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)
  29903. var dat map[string]interface{}
  29904. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29905. fmt.Println(dat)
  29906. } else {
  29907. fmt.Println(err)
  29908. }
  29909. saveLog(result, request_log, "2204", "上传费用明细")
  29910. userJSONBytes, _ := json.Marshal(dat)
  29911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29912. utils.ErrorLog("解析失败:%v", err)
  29913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29914. return
  29915. }
  29916. }
  29917. } else {
  29918. c.ServeSuccessJSON(map[string]interface{}{
  29919. "failed_code": -10,
  29920. "msg": result3101.ErrMsg,
  29921. })
  29922. return
  29923. }
  29924. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29925. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29926. if result3101.Infcode == 0 {
  29927. if len(result3101.Output.Result) > 0 {
  29928. var errMsgs []string
  29929. for _, item := range result3101.Output.Result {
  29930. errMsgs = append(errMsgs, item.VolaCont)
  29931. }
  29932. c.ServeSuccessJSON(map[string]interface{}{
  29933. "failed_code": -10,
  29934. "msg": errMsgs,
  29935. })
  29936. return
  29937. } else {
  29938. 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)
  29939. var dat map[string]interface{}
  29940. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29941. fmt.Println(dat)
  29942. } else {
  29943. fmt.Println(err)
  29944. }
  29945. saveLog(result, request_log, "2204", "上传费用明细")
  29946. userJSONBytes, _ := json.Marshal(dat)
  29947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29948. utils.ErrorLog("解析失败:%v", err)
  29949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29950. return
  29951. }
  29952. }
  29953. } else {
  29954. c.ServeSuccessJSON(map[string]interface{}{
  29955. "failed_code": -10,
  29956. "msg": result3101.ErrMsg,
  29957. })
  29958. return
  29959. }
  29960. } else {
  29961. if miConfig.Code == "H15049901371" {
  29962. 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)
  29963. var dat map[string]interface{}
  29964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29965. fmt.Println(dat)
  29966. } else {
  29967. fmt.Println(err)
  29968. }
  29969. saveLog(result, request_log, "2204", "上传费用明细")
  29970. userJSONBytes, _ := json.Marshal(dat)
  29971. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29972. utils.ErrorLog("解析失败:%v", err)
  29973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29974. return
  29975. }
  29976. res.InfRefmsgid = resFour10265.InfRefmsgid
  29977. res.Output = resFour10265.Output
  29978. res.ErrMsg = resFour10265.ErrMsg
  29979. res.Cainfo = resFour10265.Cainfo
  29980. res.WarnMsg = resFour10265.WarnMsg
  29981. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29982. res.Infcode = infocode
  29983. } else {
  29984. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483"{
  29985. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29986. if result3101.Infcode == 0 {
  29987. if len(result3101.Output.Result) > 0 {
  29988. c.ServeSuccessJSON(map[string]interface{}{
  29989. "failed_code": -10,
  29990. "failed_type": 100,
  29991. "warm_type": 1,
  29992. "msg": result3101,
  29993. })
  29994. return
  29995. } else {
  29996. 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)
  29997. var dat map[string]interface{}
  29998. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29999. fmt.Println(dat)
  30000. } else {
  30001. fmt.Println(err)
  30002. }
  30003. saveLog(result, request_log, "2204", "上传费用明细")
  30004. userJSONBytes, _ := json.Marshal(dat)
  30005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30006. utils.ErrorLog("解析失败:%v", err)
  30007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30008. return
  30009. }
  30010. }
  30011. } else {
  30012. c.ServeSuccessJSON(map[string]interface{}{
  30013. "failed_code": -10,
  30014. "msg": result3101.ErrMsg,
  30015. })
  30016. return
  30017. }
  30018. } else {
  30019. 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)
  30020. var dat map[string]interface{}
  30021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30022. fmt.Println(dat)
  30023. } else {
  30024. fmt.Println(err)
  30025. }
  30026. saveLog(result, request_log, "2204", "上传费用明细")
  30027. userJSONBytes, _ := json.Marshal(dat)
  30028. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30029. utils.ErrorLog("解析失败:%v", err)
  30030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30031. return
  30032. }
  30033. }
  30034. }
  30035. }
  30036. }
  30037. var total_two float64
  30038. if res.Infcode == -1 {
  30039. errlog := &models.HisOrderError{
  30040. UserOrgId: adminUser.CurrentOrgId,
  30041. Ctime: time.Now().Unix(),
  30042. Mtime: time.Now().Unix(),
  30043. Number: chrg_bchno,
  30044. ErrMsg: res.ErrMsg,
  30045. Status: 1,
  30046. PatientId: id,
  30047. RecordTime: recordDateTime,
  30048. Stage: 4,
  30049. }
  30050. service.CreateErrMsgLog(errlog)
  30051. c.ServeSuccessJSON(map[string]interface{}{
  30052. "failed_code": -10,
  30053. "msg": res.ErrMsg,
  30054. })
  30055. return
  30056. }
  30057. if res.Infcode == 0 {
  30058. order := &models.HisOrder{
  30059. UserOrgId: adminUser.CurrentOrgId,
  30060. HisPatientId: his.ID,
  30061. PatientId: his.PatientId,
  30062. SettleAccountsDate: recordDateTime,
  30063. Ctime: time.Now().Unix(),
  30064. Mtime: time.Now().Unix(),
  30065. MdtrtId: his.Number,
  30066. PsnNo: his.PsnNo,
  30067. MedType: strconv.FormatInt(reg_type, 10),
  30068. Status: 1,
  30069. Number: chrg_bchno,
  30070. Infcode: res.Infcode,
  30071. WarnMsg: res.WarnMsg,
  30072. Cainfo: res.Cainfo,
  30073. ErrMsg: res.ErrMsg,
  30074. RespondTime: res.RefmsgTime,
  30075. InfRefmsgid: res.InfRefmsgid,
  30076. OrderStatus: 1,
  30077. IsMedicineInsurance: 1,
  30078. SettleType: settle_accounts_type,
  30079. SettleStartTime: start_time,
  30080. SettleEndTime: end_time,
  30081. Creator: roles.AdminUserId,
  30082. Modify: roles.AdminUserId,
  30083. PType: 2,
  30084. Diagnosis: diagnosis_id,
  30085. }
  30086. err = service.CreateOrder(order)
  30087. if err != nil {
  30088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30089. return
  30090. }
  30091. for _, item := range res.Output.Result {
  30092. temp := strings.Split(item.FeedetlSn, "-")
  30093. var advice_id int64 = 0
  30094. var project_id int64 = 0
  30095. var types int64 = 0
  30096. id, _ := strconv.ParseInt(temp[2], 10, 64)
  30097. types, _ = strconv.ParseInt(temp[1], 10, 64)
  30098. if temp[1] == "1" {
  30099. advice_id = id
  30100. project_id = 0
  30101. } else if temp[1] == "2" {
  30102. advice_id = 0
  30103. project_id = id
  30104. }
  30105. total_two = total_two + item.DetItemFeeSumamt
  30106. info := &models.HisOrderInfo{
  30107. OrderNumber: order.Number,
  30108. FeedetlSn: item.FeedetlSn,
  30109. UploadDate: time.Now().Unix(),
  30110. AdviceId: advice_id,
  30111. DetItemFeeSumamt: item.DetItemFeeSumamt,
  30112. Cnt: item.Cnt,
  30113. Pric: float64(item.Pric),
  30114. PatientId: his.PatientId,
  30115. PricUplmtAmt: item.PricUplmtAmt,
  30116. SelfpayProp: item.SelfpayProp,
  30117. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  30118. OverlmtAmt: item.OverlmtAmt,
  30119. PreselfpayAmt: item.PreselfpayAmt,
  30120. BasMednFlag: item.BasMednFlag,
  30121. MedChrgitmType: item.MedChrgitmType,
  30122. HiNegoDrugFlag: item.HiNegoDrugFlag,
  30123. Status: 1,
  30124. Memo: item.Memo,
  30125. Mtime: time.Now().Unix(),
  30126. InscpScpAmt: item.InscpScpAmt,
  30127. DrtReimFlag: item.DrtReimFlag,
  30128. Ctime: time.Now().Unix(),
  30129. ListSpItemFlag: item.ListSpItemFlag,
  30130. ChldMedcFlag: item.ChldMedcFlag,
  30131. LmtUsedFlag: item.LmtUsedFlag,
  30132. ChrgitmLv: item.ChrgitmLv,
  30133. UserOrgId: adminUser.CurrentOrgId,
  30134. HisPatientId: his.ID,
  30135. OrderId: order.ID,
  30136. ProjectId: project_id,
  30137. Type: types,
  30138. }
  30139. service.CreateOrderInfo(info)
  30140. }
  30141. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  30142. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  30143. var total float64
  30144. for _, item := range prescriptions {
  30145. if item.Type == 1 { //药品
  30146. for _, subItem := range item.HisDoctorAdviceInfo {
  30147. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  30148. total_one := price * subItem.PrescribingNumber
  30149. fmt.Println("subItem")
  30150. fmt.Println(subItem.Price)
  30151. fmt.Println("price")
  30152. fmt.Println(price)
  30153. fmt.Println("total_one")
  30154. fmt.Println(total_one)
  30155. total = total + total_one
  30156. fmt.Println(total)
  30157. }
  30158. }
  30159. if item.Type == 2 { //项目
  30160. for _, subItem := range item.HisPrescriptionProject {
  30161. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  30162. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  30163. total_one := price * cnt
  30164. total = total + total_one
  30165. }
  30166. }
  30167. }
  30168. allTotal := fmt.Sprintf("%.2f", total)
  30169. if res.Infcode == 0 {
  30170. var rf []*ResultFive
  30171. json.Unmarshal([]byte(his.Iinfo), &rf)
  30172. chrg_bchno := chrg_bchno
  30173. cert_no := his.Certno
  30174. var insutypes []string
  30175. var insutype string
  30176. var is390 int = 0
  30177. var is310 int = 0
  30178. for _, item := range rf {
  30179. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  30180. insutypes = append(insutypes, item.Insutype)
  30181. }
  30182. }
  30183. if len(insutypes) == 1 {
  30184. insutype = insutypes[0]
  30185. } else {
  30186. for _, i := range insutypes {
  30187. if i == "390" {
  30188. is390 = 1
  30189. }
  30190. if i == "310" {
  30191. is310 = 1
  30192. }
  30193. }
  30194. }
  30195. if is390 == 1 {
  30196. insutype = "390"
  30197. }
  30198. if is310 == 1 {
  30199. insutype = "310"
  30200. }
  30201. if len(insutypes) == 0 {
  30202. insutype = "390"
  30203. }
  30204. if len(insutypes) == 2 {
  30205. insutype = strconv.FormatInt(his.SocialType, 10)
  30206. }
  30207. //insutype = "390"
  30208. if his.IdCardType == 1 {
  30209. cert_no = his.MedicalInsuranceNumber
  30210. } else {
  30211. cert_no = his.Certno
  30212. }
  30213. var res ResultSeven
  30214. var ahres ResultSevenAH
  30215. var resSeven10265 ResultSeven10265
  30216. var resSeven10265Two ResultSeven10265Two
  30217. var gzresSeven10265Two GZResultSeven10265Two
  30218. if miConfig.MdtrtareaAdmvs == "421300" {
  30219. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  30220. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30221. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30222. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30223. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30224. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30225. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30226. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30227. resp, requestErr := http.Get(api)
  30228. if requestErr != nil {
  30229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30230. return
  30231. }
  30232. body, ioErr := ioutil.ReadAll(resp.Body)
  30233. if ioErr != nil {
  30234. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30236. return
  30237. }
  30238. var respJSON map[string]interface{}
  30239. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30240. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30242. return
  30243. }
  30244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30245. result, _ := json.Marshal(respJSON)
  30246. fmt.Println("log")
  30247. fmt.Println(string(result))
  30248. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30249. utils.ErrorLog("解析失败:%v", err)
  30250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30251. return
  30252. }
  30253. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30254. if reg_type == 11 && his.Insutype == "390" {
  30255. reg_type = 110104
  30256. }
  30257. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30258. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30259. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30260. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30261. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30262. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30263. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30264. resp, requestErr := http.Get(api)
  30265. if requestErr != nil {
  30266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30267. return
  30268. }
  30269. body, ioErr := ioutil.ReadAll(resp.Body)
  30270. if ioErr != nil {
  30271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30273. return
  30274. }
  30275. var respJSON map[string]interface{}
  30276. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30279. return
  30280. }
  30281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30282. result, _ := json.Marshal(respJSON)
  30283. fmt.Println("log")
  30284. fmt.Println(string(result))
  30285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30286. utils.ErrorLog("解析失败:%v", err)
  30287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30288. return
  30289. }
  30290. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30291. if reg_type == 11 && his.Insutype == "390" {
  30292. reg_type = 110104
  30293. }
  30294. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30295. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30296. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30297. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30298. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30299. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30300. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30301. resp, requestErr := http.Get(api)
  30302. if requestErr != nil {
  30303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30304. return
  30305. }
  30306. body, ioErr := ioutil.ReadAll(resp.Body)
  30307. if ioErr != nil {
  30308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30310. return
  30311. }
  30312. var respJSON map[string]interface{}
  30313. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30314. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30316. return
  30317. }
  30318. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30319. result, _ := json.Marshal(respJSON)
  30320. fmt.Println("log")
  30321. fmt.Println(string(result))
  30322. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30323. utils.ErrorLog("解析失败:%v", err)
  30324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30325. return
  30326. }
  30327. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30328. if reg_type == 11 && his.Insutype == "390" {
  30329. reg_type = 110104
  30330. }
  30331. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30332. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30333. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30334. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30335. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30336. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30337. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30338. resp, requestErr := http.Get(api)
  30339. if requestErr != nil {
  30340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30341. return
  30342. }
  30343. body, ioErr := ioutil.ReadAll(resp.Body)
  30344. if ioErr != nil {
  30345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30347. return
  30348. }
  30349. var respJSON map[string]interface{}
  30350. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30353. return
  30354. }
  30355. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30356. result, _ := json.Marshal(respJSON)
  30357. fmt.Println("log")
  30358. fmt.Println(string(result))
  30359. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30360. utils.ErrorLog("解析失败:%v", err)
  30361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30362. return
  30363. }
  30364. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30365. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30366. if result3101.Infcode == "0" {
  30367. if len(result3101.Output.Result) > 0 {
  30368. var errMsgs []string
  30369. for _, item := range result3101.Output.Result {
  30370. errMsgs = append(errMsgs, item.VolaCont)
  30371. }
  30372. c.ServeSuccessJSON(map[string]interface{}{
  30373. "failed_code": -10,
  30374. "msg": errMsgs,
  30375. })
  30376. return
  30377. } else {
  30378. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30379. if his.IdCardType != 4 {
  30380. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30381. bas := strings.Split(psn_info.CardInfo, "|")
  30382. if his.IdCardType == 1 {
  30383. cert_no = bas[2]
  30384. } else {
  30385. cert_no = bas[1]
  30386. }
  30387. } else {
  30388. cert_no = his.Certno
  30389. }
  30390. //江苏地区国家医保医疗类别
  30391. //职工透析:医疗类别选特殊情况门诊9933
  30392. //居民血透门慢: 医疗类别选门诊慢病1402
  30393. //var med_type string
  30394. //if his.Insutype == "310" {
  30395. // if reg_type == 14 {
  30396. // med_type = "9933"
  30397. // } else if reg_type == 11 {
  30398. // med_type = "11"
  30399. //
  30400. // }
  30401. //} else if his.Insutype == "390" {
  30402. // if reg_type == 14 {
  30403. // med_type = "1402"
  30404. // } else if reg_type == 11 {
  30405. // med_type = "11"
  30406. // }
  30407. //}
  30408. var api string
  30409. if miConfig.MdtrtareaAdmvs == "320921" {
  30410. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30411. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30412. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30413. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30414. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30415. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30416. "&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
  30417. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30418. } else {
  30419. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30420. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30421. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30422. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30423. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30424. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30425. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30426. "&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
  30427. }
  30428. resp, requestErr := http.Get(api)
  30429. if requestErr != nil {
  30430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30431. return
  30432. }
  30433. body, ioErr := ioutil.ReadAll(resp.Body)
  30434. if ioErr != nil {
  30435. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30437. return
  30438. }
  30439. var respJSON map[string]interface{}
  30440. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30441. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30443. return
  30444. }
  30445. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30446. result, _ := json.Marshal(respJSON)
  30447. fmt.Println("log")
  30448. fmt.Println(string(result))
  30449. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  30450. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30451. utils.ErrorLog("解析失败:%v", err)
  30452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30453. return
  30454. }
  30455. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30456. res.Output = resSeven10265.Output
  30457. res.ErrMsg = resSeven10265.ErrMsg
  30458. res.Cainfo = resSeven10265.Cainfo
  30459. res.WarnMsg = resSeven10265.WarnMsg
  30460. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30461. res.Infcode = infocode
  30462. } else {
  30463. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  30464. utils.ErrorLog("解析失败:%v", err)
  30465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30466. return
  30467. }
  30468. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  30469. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  30470. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  30471. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  30472. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30473. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  30474. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  30475. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  30476. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  30477. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  30478. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  30479. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30480. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  30481. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  30482. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  30483. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30484. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  30485. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  30486. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  30487. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  30488. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  30489. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30490. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  30491. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  30492. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  30493. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  30494. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  30495. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  30496. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  30497. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  30498. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30499. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  30500. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  30501. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  30502. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30503. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30504. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30505. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30506. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  30507. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  30508. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  30509. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  30510. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  30511. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  30512. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  30513. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  30514. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  30515. res.ErrMsg = resSeven10265Two.ErrMsg
  30516. res.Cainfo = resSeven10265Two.Cainfo
  30517. res.WarnMsg = resSeven10265Two.WarnMsg
  30518. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30519. res.Infcode = infocode
  30520. }
  30521. }
  30522. }
  30523. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30524. psn_info, _ := service.GetPsnByPatientId(id)
  30525. var verify_number string
  30526. if psn_info.IdCardType == 4 {
  30527. verify_number = psn_info.VerifyNumber
  30528. } else if psn_info.IdCardType == 1 {
  30529. bas := strings.Split(psn_info.CardInfo, "|")
  30530. cardNumber := bas[2]
  30531. verify_number = cardNumber
  30532. } else {
  30533. psn_info.IdCardType = 2
  30534. verify_number = psn_info.Certno
  30535. }
  30536. var api string
  30537. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30538. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  30539. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30540. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30541. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  30542. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30543. "&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
  30544. resp, requestErr := http.Get(api)
  30545. if requestErr != nil {
  30546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30547. return
  30548. }
  30549. body, ioErr := ioutil.ReadAll(resp.Body)
  30550. if ioErr != nil {
  30551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30553. return
  30554. }
  30555. var respJSON map[string]interface{}
  30556. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30559. return
  30560. }
  30561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30562. result, _ := json.Marshal(respJSON)
  30563. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30564. utils.ErrorLog("解析失败:%v", err)
  30565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30566. return
  30567. }
  30568. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30569. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  30570. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  30571. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30572. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  30573. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  30574. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  30575. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  30576. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  30577. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  30578. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  30579. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  30580. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  30581. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30582. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  30583. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  30584. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  30585. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  30586. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  30587. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  30588. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30589. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  30590. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  30591. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  30592. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  30593. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  30594. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  30595. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  30596. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  30597. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  30598. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  30599. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  30600. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  30601. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  30602. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30603. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  30604. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  30605. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  30606. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  30607. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  30608. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  30609. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30610. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30611. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30612. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30613. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30614. res.ErrMsg = resSeven10265.ErrMsg
  30615. res.Cainfo = resSeven10265.Cainfo
  30616. res.WarnMsg = resSeven10265.WarnMsg
  30617. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30618. res.Infcode = infocode
  30619. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30620. acct_used_flag := "1"
  30621. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30622. var result string
  30623. var request_log string
  30624. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30625. 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)
  30626. } else {
  30627. 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)
  30628. }
  30629. var dat map[string]interface{}
  30630. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30631. fmt.Println(dat)
  30632. } else {
  30633. fmt.Println(err)
  30634. }
  30635. saveLog(result, request_log, "2206", "预结算")
  30636. userJSONBytes, _ := json.Marshal(dat)
  30637. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30638. utils.ErrorLog("解析失败:%v", err)
  30639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30640. return
  30641. }
  30642. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30643. var result string
  30644. var request_log string
  30645. if his.IdCardType == 2 {
  30646. insutype = strconv.FormatInt(his.SocialType, 10)
  30647. 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, "")
  30648. } else if his.IdCardType == 1 {
  30649. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30650. bas := strings.Split(psn_info.CardInfo, "|")
  30651. basNumber := bas[2]
  30652. card_sn := bas[3]
  30653. var rf []*ResultFive
  30654. json.Unmarshal([]byte(his.Iinfo), &rf)
  30655. var psn_type string
  30656. for _, item := range rf {
  30657. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30658. psn_type = item.PsnType
  30659. }
  30660. }
  30661. insutype = strconv.FormatInt(his.SocialType, 10)
  30662. 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)
  30663. } else {
  30664. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30665. //bas := strings.Split(psn_info.CardInfo, "|")
  30666. //basNumber := bas[2]
  30667. //card_sn := bas[3]
  30668. var rf []*ResultFive
  30669. json.Unmarshal([]byte(his.Iinfo), &rf)
  30670. var psn_type string
  30671. for _, item := range rf {
  30672. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30673. psn_type = item.PsnType
  30674. }
  30675. }
  30676. insutype = strconv.FormatInt(his.SocialType, 10)
  30677. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30678. 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)
  30679. }
  30680. var dat map[string]interface{}
  30681. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30682. fmt.Println(dat)
  30683. } else {
  30684. fmt.Println(err)
  30685. }
  30686. saveLog(result, request_log, "2206", "预结算")
  30687. userJSONBytes, _ := json.Marshal(dat)
  30688. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30689. utils.ErrorLog("解析失败:%v", err)
  30690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30691. return
  30692. }
  30693. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30694. var result string
  30695. var request_log string
  30696. if his.IdCardType == 2 {
  30697. insutype = strconv.FormatInt(his.SocialType, 10)
  30698. 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, "")
  30699. } else if his.IdCardType == 1 {
  30700. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30701. bas := strings.Split(psn_info.CardInfo, "|")
  30702. basNumber := bas[0]
  30703. card_sn := ""
  30704. var rf []*ResultFive
  30705. json.Unmarshal([]byte(his.Iinfo), &rf)
  30706. var psn_type string
  30707. for _, item := range rf {
  30708. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30709. psn_type = item.PsnType
  30710. }
  30711. }
  30712. insutype = strconv.FormatInt(his.SocialType, 10)
  30713. 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)
  30714. } else {
  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. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  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, psn_info.VerifyNumber, "", "", his.PsnCertType, his.Certno, psn_type, his.PsnName)
  30729. }
  30730. var dat map[string]interface{}
  30731. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30732. fmt.Println(dat)
  30733. } else {
  30734. fmt.Println(err)
  30735. }
  30736. saveLog(result, request_log, "2206", "预结算")
  30737. userJSONBytes, _ := json.Marshal(dat)
  30738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30739. utils.ErrorLog("解析失败:%v", err)
  30740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30741. return
  30742. }
  30743. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30744. var result string
  30745. var request_log string
  30746. if his.IdCardType == 2 {
  30747. insutype = strconv.FormatInt(his.SocialType, 10)
  30748. 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, "")
  30749. } else if his.IdCardType == 1 {
  30750. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30751. bas := strings.Split(psn_info.CardInfo, "|")
  30752. basNumber := bas[0]
  30753. card_sn := ""
  30754. var rf []*ResultFive
  30755. json.Unmarshal([]byte(his.Iinfo), &rf)
  30756. var psn_type string
  30757. for _, item := range rf {
  30758. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30759. psn_type = item.PsnType
  30760. }
  30761. }
  30762. insutype = strconv.FormatInt(his.SocialType, 10)
  30763. 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)
  30764. } else {
  30765. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30766. //bas := strings.Split(psn_info.CardInfo, "|")
  30767. //basNumber := bas[2]
  30768. //card_sn := bas[3]
  30769. var rf []*ResultFive
  30770. json.Unmarshal([]byte(his.Iinfo), &rf)
  30771. var psn_type string
  30772. for _, item := range rf {
  30773. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30774. psn_type = item.PsnType
  30775. }
  30776. }
  30777. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30778. 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)
  30779. }
  30780. var dat map[string]interface{}
  30781. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30782. fmt.Println(dat)
  30783. } else {
  30784. fmt.Println(err)
  30785. }
  30786. saveLog(result, request_log, "2206", "预结算")
  30787. userJSONBytes, _ := json.Marshal(dat)
  30788. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30789. utils.ErrorLog("解析失败:%v", err)
  30790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30791. return
  30792. }
  30793. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30794. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30795. if his.IdCardType == 4 {
  30796. psn_info.VerifyNumber = psn_info.VerifyNumber
  30797. cert_no = psn_info.VerifyNumber
  30798. } else if his.IdCardType == 2 {
  30799. cert_no = psn_info.Certno
  30800. psn_info.VerifyNumber = psn_info.Certno
  30801. } else {
  30802. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30803. bas := strings.Split(psn_info.CardInfo, "|")
  30804. if his.IdCardType == 1 {
  30805. cert_no = bas[2]
  30806. } else {
  30807. cert_no = bas[1]
  30808. }
  30809. }
  30810. var api string
  30811. var med_type string
  30812. if his.Insutype == "390" {
  30813. if reg_type == 992102 {
  30814. med_type = "992102"
  30815. }
  30816. if reg_type == 140104 {
  30817. med_type = "140104"
  30818. }
  30819. if reg_type == 140201 {
  30820. med_type = "140201"
  30821. }
  30822. if reg_type == 14 {
  30823. med_type = "140104"
  30824. }
  30825. } else if his.Insutype == "310" {
  30826. if reg_type == 992102 {
  30827. med_type = "992102"
  30828. }
  30829. if reg_type == 140104 {
  30830. med_type = "140104"
  30831. }
  30832. if reg_type == 140201 {
  30833. med_type = "140201"
  30834. }
  30835. if reg_type == 14 {
  30836. med_type = "140104"
  30837. }
  30838. }
  30839. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30840. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30841. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30842. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30843. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30844. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30845. "&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
  30846. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30847. resp, requestErr := http.Get(api)
  30848. if requestErr != nil {
  30849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30850. return
  30851. }
  30852. body, ioErr := ioutil.ReadAll(resp.Body)
  30853. if ioErr != nil {
  30854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30856. return
  30857. }
  30858. var respJSON map[string]interface{}
  30859. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30862. return
  30863. }
  30864. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30865. if status == "0" {
  30866. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30867. c.ServeSuccessJSON(map[string]interface{}{
  30868. "failed_code": -10,
  30869. "msg": err_msg,
  30870. })
  30871. return
  30872. }
  30873. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30874. result, _ := json.Marshal(respJSON)
  30875. fmt.Println("log")
  30876. fmt.Println(string(result))
  30877. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30878. utils.ErrorLog("解析失败:%v", err)
  30879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30880. return
  30881. }
  30882. res.InfRefmsgid = ahres.InfRefmsgid
  30883. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30884. // 创建对应的Time类型
  30885. t := time.UnixMilli(timestamp)
  30886. // 格式化成指定的日期字符串
  30887. str := t.Format("2006-01-02 15:04:05")
  30888. res.Output.Setlinfo.SetlTime = str
  30889. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30890. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30891. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30892. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30893. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30894. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30895. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30896. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30897. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30898. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30899. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30900. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30901. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30902. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30903. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30904. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30905. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30906. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30907. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30908. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30909. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30910. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30911. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30912. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30913. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30914. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30915. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30916. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30917. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30918. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30919. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30920. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30921. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30922. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30923. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30924. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30925. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30926. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30927. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30928. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30929. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30930. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30931. //res.Output.Setldetail = ahres.Output.Setldetail
  30932. res.ErrMsg = ahres.ErrMsg
  30933. res.Cainfo = ahres.Cainfo
  30934. res.WarnMsg = ahres.WarnMsg
  30935. res.Infcode = ahres.Infcode
  30936. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30937. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30938. if his.IdCardType == 4 {
  30939. psn_info.VerifyNumber = psn_info.VerifyNumber
  30940. cert_no = psn_info.Certno
  30941. } else if his.IdCardType == 2 {
  30942. cert_no = psn_info.Certno
  30943. psn_info.VerifyNumber = psn_info.Certno
  30944. } else {
  30945. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30946. bas := strings.Split(psn_info.CardInfo, "|")
  30947. if his.IdCardType == 1 {
  30948. cert_no = bas[2]
  30949. } else {
  30950. cert_no = bas[1]
  30951. }
  30952. }
  30953. var api string
  30954. var med_type string
  30955. if his.Insutype == "390" {
  30956. if reg_type == 992102 {
  30957. med_type = "992102"
  30958. }
  30959. if reg_type == 140104 {
  30960. med_type = "140104"
  30961. }
  30962. if reg_type == 140201 {
  30963. med_type = "140201"
  30964. }
  30965. if reg_type == 14 {
  30966. med_type = "14"
  30967. }
  30968. } else if his.Insutype == "310" {
  30969. if reg_type == 992102 {
  30970. med_type = "992102"
  30971. }
  30972. if reg_type == 140104 {
  30973. med_type = "140104"
  30974. }
  30975. if reg_type == 140201 {
  30976. med_type = "140201"
  30977. }
  30978. if reg_type == 14 {
  30979. med_type = "14"
  30980. }
  30981. }
  30982. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30983. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30984. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30985. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30986. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30987. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30988. "&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
  30989. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30990. resp, requestErr := http.Get(api)
  30991. if requestErr != nil {
  30992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30993. return
  30994. }
  30995. body, ioErr := ioutil.ReadAll(resp.Body)
  30996. if ioErr != nil {
  30997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30999. return
  31000. }
  31001. var respJSON map[string]interface{}
  31002. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31005. return
  31006. }
  31007. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31008. if status == "0" {
  31009. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31010. c.ServeSuccessJSON(map[string]interface{}{
  31011. "failed_code": -10,
  31012. "msg": err_msg,
  31013. })
  31014. return
  31015. }
  31016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31017. result, _ := json.Marshal(respJSON)
  31018. fmt.Println("log")
  31019. fmt.Println(string(result))
  31020. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  31021. utils.ErrorLog("解析失败:%v", err)
  31022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31023. return
  31024. }
  31025. res.InfRefmsgid = ahres.InfRefmsgid
  31026. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31027. // 创建对应的Time类型
  31028. t := time.UnixMilli(timestamp)
  31029. // 格式化成指定的日期字符串
  31030. str := t.Format("2006-01-02 15:04:05")
  31031. res.Output.Setlinfo.SetlTime = str
  31032. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31033. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31034. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31035. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31036. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31037. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31038. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31039. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31040. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31041. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31042. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31043. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31044. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31045. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31046. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31047. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31048. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31049. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31050. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31051. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31052. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31053. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31054. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31055. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31056. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31057. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31058. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31059. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31060. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31061. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31062. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31063. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31064. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31065. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  31066. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31067. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  31068. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  31069. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  31070. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  31071. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31072. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  31073. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31074. //res.Output.Setldetail = ahres.Output.Setldetail
  31075. res.ErrMsg = ahres.ErrMsg
  31076. res.Cainfo = ahres.Cainfo
  31077. res.WarnMsg = ahres.WarnMsg
  31078. res.Infcode = ahres.Infcode
  31079. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31080. var result string
  31081. var request_log string
  31082. if his.IdCardType == 2 {
  31083. 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")
  31084. } else if his.IdCardType == 1 {
  31085. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31086. bas := strings.Split(psn_info.CardInfo, "|")
  31087. basNumber := bas[2]
  31088. card_sn := bas[3]
  31089. 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")
  31090. } else {
  31091. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31092. 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")
  31093. }
  31094. var dat map[string]interface{}
  31095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31096. fmt.Println(dat)
  31097. } else {
  31098. fmt.Println(err)
  31099. }
  31100. saveLog(result, request_log, "2206", "预结算")
  31101. userJSONBytes, _ := json.Marshal(dat)
  31102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31103. utils.ErrorLog("解析失败:%v", err)
  31104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31105. return
  31106. }
  31107. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31108. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31109. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31110. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31111. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31112. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31113. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31114. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31115. resp, requestErr := http.Get(api)
  31116. if requestErr != nil {
  31117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31118. return
  31119. }
  31120. body, ioErr := ioutil.ReadAll(resp.Body)
  31121. if ioErr != nil {
  31122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31124. return
  31125. }
  31126. var respJSON map[string]interface{}
  31127. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31130. return
  31131. }
  31132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31133. result, _ := json.Marshal(respJSON)
  31134. fmt.Println("log")
  31135. fmt.Println(string(result))
  31136. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31137. utils.ErrorLog("解析失败:%v", err)
  31138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31139. return
  31140. }
  31141. } else {
  31142. if miConfig.MdtrtareaAdmvs == "441202" {
  31143. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31144. if result3101.Infcode == 0 {
  31145. if len(result3101.Output.Result) > 0 {
  31146. c.ServeSuccessJSON(map[string]interface{}{
  31147. "failed_code": -10,
  31148. "failed_type": 100,
  31149. "msg": result3101.Output.Result,
  31150. })
  31151. return
  31152. } else {
  31153. var result string
  31154. var request_log string
  31155. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31156. allTotal = fmt.Sprintf("%.2f", total_two)
  31157. if his.IdCardType == 4 {
  31158. 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)
  31159. } else {
  31160. 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)
  31161. }
  31162. var dat map[string]interface{}
  31163. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31164. fmt.Println(dat)
  31165. } else {
  31166. fmt.Println(err)
  31167. }
  31168. saveLog(result, request_log, "2206", "预结算")
  31169. //userJSONBytes, _ := json.Marshal(dat)
  31170. //
  31171. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31172. // utils.ErrorLog("解析失败:%v", err)
  31173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31174. // return
  31175. //}
  31176. userJSONBytes, _ := json.Marshal(dat)
  31177. if miConfig.Code == "H15049901371" {
  31178. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  31179. utils.ErrorLog("解析失败:%v", err)
  31180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31181. return
  31182. }
  31183. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31184. res.Output = resSeven10265.Output
  31185. res.ErrMsg = resSeven10265.ErrMsg
  31186. res.Cainfo = resSeven10265.Cainfo
  31187. res.WarnMsg = resSeven10265.WarnMsg
  31188. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31189. res.Infcode = infocode
  31190. } else {
  31191. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31192. utils.ErrorLog("解析失败:%v", err)
  31193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31194. return
  31195. }
  31196. }
  31197. }
  31198. } else {
  31199. c.ServeSuccessJSON(map[string]interface{}{
  31200. "failed_code": -10,
  31201. "msg": result3101.ErrMsg,
  31202. })
  31203. return
  31204. }
  31205. } else if miConfig.MdtrtareaAdmvs == "440205" {
  31206. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31207. if result3101.Infcode == 0 {
  31208. if len(result3101.Output.Result) > 0 {
  31209. var errMsgs []string
  31210. for _, item := range result3101.Output.Result {
  31211. errMsgs = append(errMsgs, item.VolaCont)
  31212. }
  31213. c.ServeSuccessJSON(map[string]interface{}{
  31214. "failed_code": -10,
  31215. "msg": errMsgs,
  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 {
  31272. var result string
  31273. var request_log string
  31274. var dat map[string]interface{}
  31275. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31276. allTotal = fmt.Sprintf("%.2f", total_two)
  31277. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" {
  31278. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31279. if result3101.Infcode == 0 {
  31280. if len(result3101.Output.Result) > 0 {
  31281. c.ServeSuccessJSON(map[string]interface{}{
  31282. "failed_code": -10,
  31283. "failed_type": 100,
  31284. "warm_type": 2,
  31285. "msg": result3101,
  31286. })
  31287. return
  31288. } else {
  31289. var result string
  31290. var request_log string
  31291. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31292. allTotal = fmt.Sprintf("%.2f", total_two)
  31293. if his.IdCardType == 4 {
  31294. 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)
  31295. } else {
  31296. if his.IdCardType == 2 {
  31297. cert_no = psn_info.Certno
  31298. psn_info.VerifyNumber = psn_info.Certno
  31299. } else {
  31300. bas := strings.Split(psn_info.CardInfo, "|")
  31301. cert_no = bas[2]
  31302. }
  31303. 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)
  31304. }
  31305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31306. fmt.Println(dat)
  31307. } else {
  31308. fmt.Println(err)
  31309. }
  31310. saveLog(result, request_log, "2206", "预结算")
  31311. }
  31312. } else {
  31313. c.ServeSuccessJSON(map[string]interface{}{
  31314. "failed_code": -10,
  31315. "msg": result3101.ErrMsg,
  31316. })
  31317. return
  31318. }
  31319. } else {
  31320. if his.IdCardType == 4 {
  31321. 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)
  31322. } else {
  31323. if his.IdCardType == 2 {
  31324. cert_no = psn_info.Certno
  31325. psn_info.VerifyNumber = psn_info.Certno
  31326. } else {
  31327. bas := strings.Split(psn_info.CardInfo, "|")
  31328. cert_no = bas[2]
  31329. }
  31330. 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)
  31331. }
  31332. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31333. fmt.Println(dat)
  31334. } else {
  31335. fmt.Println(err)
  31336. }
  31337. saveLog(result, request_log, "2206", "预结算")
  31338. }
  31339. //userJSONBytes, _ := json.Marshal(dat)
  31340. //
  31341. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31342. // utils.ErrorLog("解析失败:%v", err)
  31343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31344. // return
  31345. //}
  31346. userJSONBytes, _ := json.Marshal(dat)
  31347. if miConfig.Code == "H15049901371" {
  31348. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  31349. utils.ErrorLog("解析失败:%v", err)
  31350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31351. return
  31352. }
  31353. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31354. res.Output = resSeven10265.Output
  31355. res.ErrMsg = resSeven10265.ErrMsg
  31356. res.Cainfo = resSeven10265.Cainfo
  31357. res.WarnMsg = resSeven10265.WarnMsg
  31358. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31359. res.Infcode = infocode
  31360. } else {
  31361. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31362. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  31363. utils.ErrorLog("解析失败:%v", err)
  31364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31365. return
  31366. }
  31367. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  31368. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  31369. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  31370. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  31371. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  31372. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  31373. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  31374. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31375. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  31376. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31377. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31378. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31379. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31380. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  31381. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31382. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  31383. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  31384. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  31385. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  31386. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  31387. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31388. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  31389. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  31390. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  31391. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  31392. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  31393. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  31394. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  31395. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  31396. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31397. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  31398. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  31399. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  31400. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31401. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31402. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31403. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31404. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  31405. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  31406. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  31407. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  31408. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  31409. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  31410. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  31411. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  31412. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  31413. res.ErrMsg = gzresSeven10265Two.ErrMsg
  31414. res.Cainfo = gzresSeven10265Two.Cainfo
  31415. res.WarnMsg = gzresSeven10265Two.WarnMsg
  31416. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31417. //res.Infcode = infocode
  31418. } else {
  31419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31420. utils.ErrorLog("解析失败:%v", err)
  31421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31422. return
  31423. }
  31424. }
  31425. }
  31426. }
  31427. }
  31428. utils.ErrorLog("解析失败:%v", res.Infcode)
  31429. if res.Infcode == -1 {
  31430. errlog := &models.HisOrderError{
  31431. UserOrgId: adminUser.CurrentOrgId,
  31432. Ctime: time.Now().Unix(),
  31433. Mtime: time.Now().Unix(),
  31434. Number: chrg_bchno,
  31435. ErrMsg: res.ErrMsg,
  31436. Status: 1,
  31437. PatientId: id,
  31438. RecordTime: recordDateTime,
  31439. Stage: 20,
  31440. }
  31441. service.CreateErrMsgLog(errlog)
  31442. c.ServeSuccessJSON(map[string]interface{}{
  31443. "failed_code": -10,
  31444. "msg": res.ErrMsg,
  31445. })
  31446. return
  31447. }
  31448. if res.Infcode != 0 {
  31449. errlog := &models.HisOrderError{
  31450. UserOrgId: adminUser.CurrentOrgId,
  31451. Ctime: time.Now().Unix(),
  31452. Mtime: time.Now().Unix(),
  31453. Number: chrg_bchno,
  31454. ErrMsg: res.ErrMsg,
  31455. Status: 1,
  31456. PatientId: id,
  31457. RecordTime: recordDateTime,
  31458. Stage: 20,
  31459. }
  31460. service.CreateErrMsgLog(errlog)
  31461. c.ServeSuccessJSON(map[string]interface{}{
  31462. "failed_code": -10,
  31463. "msg": res.ErrMsg,
  31464. })
  31465. return
  31466. } else {
  31467. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  31468. order.OrderStatus = 1
  31469. order.IsPre = 1
  31470. order.Status = 1
  31471. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  31472. order.SetlId = res.Output.Setlinfo.SetlID
  31473. order.PsnNo = res.Output.Setlinfo.PsnNo
  31474. order.PsnName = res.Output.Setlinfo.PsnName
  31475. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  31476. order.Certno = res.Output.Setlinfo.Certno
  31477. order.Gend = res.Output.Setlinfo.Gend
  31478. order.Naty = res.Output.Setlinfo.Naty
  31479. order.Age = res.Output.Setlinfo.Age
  31480. order.Insutype = res.Output.Setlinfo.Insutype
  31481. order.PsnType = res.Output.Setlinfo.PsnType
  31482. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  31483. order.SetlTime = res.Output.Setlinfo.SetlTime
  31484. order.AcctUsedFlag = acct_used_flag
  31485. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  31486. if res.Output.Setlinfo.MedType == "140101" {
  31487. order.MedType = "14"
  31488. } else {
  31489. if res.Output.Setlinfo.MedType == "110104" {
  31490. order.MedType = "11"
  31491. } else {
  31492. order.MedType = res.Output.Setlinfo.MedType
  31493. }
  31494. }
  31495. if res.Output.Setlinfo.MedType == "992102" {
  31496. order.MedType = "992102"
  31497. }
  31498. if res.Output.Setlinfo.MedType == "140104" {
  31499. order.MedType = "140104"
  31500. }
  31501. if res.Output.Setlinfo.MedType == "140201" {
  31502. order.MedType = "140201"
  31503. }
  31504. if res.Output.Setlinfo.MedType == "14" {
  31505. order.MedType = "14"
  31506. }
  31507. if reg_type == 1112 {
  31508. order.MedType = "1112"
  31509. }
  31510. if reg_type == 1111 {
  31511. order.MedType = "1111"
  31512. }
  31513. order.ClrType = res.Output.Setlinfo.ClrType
  31514. if adminUser.CurrentOrgId == 10480 {
  31515. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  31516. order.ClrType = "11"
  31517. } else {
  31518. order.ClrType = "9903"
  31519. }
  31520. }
  31521. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  31522. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  31523. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  31524. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  31525. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  31526. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  31527. order.HifpPay = res.Output.Setlinfo.HifpPay
  31528. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  31529. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  31530. order.HifesPay = res.Output.Setlinfo.HifesPay
  31531. order.HifobPay = res.Output.Setlinfo.HifobPay
  31532. order.MafPay = res.Output.Setlinfo.MafPay
  31533. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  31534. order.OthPay = res.Output.Setlinfo.OthPay
  31535. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  31536. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  31537. order.AcctPay = res.Output.Setlinfo.AcctPay
  31538. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  31539. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  31540. order.Balc = res.Output.Setlinfo.Balc
  31541. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  31542. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  31543. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  31544. order.ClrWay = res.Output.Setlinfo.ClrWay
  31545. order.Creator = order.Creator
  31546. order.Modify = roles.AdminUserId
  31547. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  31548. //detailStr := string(setlDetail)
  31549. //order.SetlDetail = detailStr
  31550. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  31551. err = service.UpDateOrder(order)
  31552. if err == nil {
  31553. c.ServeSuccessJSON(map[string]interface{}{
  31554. "msg": "预结算成功",
  31555. })
  31556. } else {
  31557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  31558. return
  31559. }
  31560. }
  31561. } else {
  31562. adminUser := c.GetAdminUserInfo()
  31563. errlog := &models.HisOrderError{
  31564. UserOrgId: adminUser.CurrentOrgId,
  31565. Ctime: time.Now().Unix(),
  31566. Mtime: time.Now().Unix(),
  31567. ErrMsg: res.ErrMsg,
  31568. Status: 1,
  31569. PatientId: id,
  31570. RecordTime: recordDateTime,
  31571. Stage: 4,
  31572. }
  31573. service.CreateErrMsgLog(errlog)
  31574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  31575. return
  31576. }
  31577. } else {
  31578. if miConfig.MdtrtareaAdmvs == "150499" {
  31579. order := &models.HisOrder{
  31580. UserOrgId: adminUser.CurrentOrgId,
  31581. HisPatientId: his.ID,
  31582. PatientId: his.PatientId,
  31583. SettleAccountsDate: recordDateTime,
  31584. Ctime: time.Now().Unix(),
  31585. Mtime: time.Now().Unix(),
  31586. MdtrtId: his.Number,
  31587. PsnNo: his.PsnNo,
  31588. MedType: strconv.FormatInt(reg_type, 10),
  31589. Status: 1,
  31590. Number: chrg_bchno,
  31591. Infcode: res.Infcode,
  31592. WarnMsg: res.WarnMsg,
  31593. Cainfo: res.Cainfo,
  31594. ErrMsg: res.ErrMsg,
  31595. RespondTime: res.RefmsgTime,
  31596. InfRefmsgid: res.InfRefmsgid,
  31597. OrderStatus: 1,
  31598. IsMedicineInsurance: 1,
  31599. SettleType: settle_accounts_type,
  31600. SettleStartTime: start_time,
  31601. SettleEndTime: end_time,
  31602. Creator: roles.AdminUserId,
  31603. Modify: roles.AdminUserId,
  31604. PType: 2,
  31605. Diagnosis: diagnosis_id,
  31606. }
  31607. err = service.CreateOrder(order)
  31608. if err != nil {
  31609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31610. return
  31611. }
  31612. }
  31613. adminUser := c.GetAdminUserInfo()
  31614. errlog := &models.HisOrderError{
  31615. UserOrgId: adminUser.CurrentOrgId,
  31616. Ctime: time.Now().Unix(),
  31617. Mtime: time.Now().Unix(),
  31618. ErrMsg: res.ErrMsg,
  31619. Status: 1,
  31620. PatientId: id,
  31621. RecordTime: recordDateTime,
  31622. Stage: 4,
  31623. }
  31624. service.CreateErrMsgLog(errlog)
  31625. c.ServeSuccessJSON(map[string]interface{}{
  31626. "failed_code": -10,
  31627. "msg": res.ErrMsg,
  31628. })
  31629. return
  31630. }
  31631. }
  31632. }
  31633. }
  31634. // 退款
  31635. func (c *HisApiController) Refund() {
  31636. order_id, _ := c.GetInt64("order_id")
  31637. admin_user_id, _ := c.GetInt64("admin_user_id")
  31638. adminUser := c.GetAdminUserInfo()
  31639. var order models.HisOrder
  31640. order, _ = service.GetHisOrderByID(order_id)
  31641. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  31642. if fapiao.ID > 0 {
  31643. c.ServeSuccessJSON(map[string]interface{}{
  31644. "failed_code": -10,
  31645. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  31646. })
  31647. return
  31648. }
  31649. return
  31650. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31651. if order.ID == 0 {
  31652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31653. return
  31654. }
  31655. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31656. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31657. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31658. if config.IsOpen == 1 { //对接了医保,走医保流程
  31659. var res ResultSixteen
  31660. var ahres ResultSevenAH
  31661. var resSixteen10265 ResultSixteen10265
  31662. var resSixteen10265Two ResultSixteen10265Two
  31663. var gz ResultgzSixteen10265Two
  31664. var src_resquest string
  31665. var result string
  31666. if miConfig.MdtrtareaAdmvs == "421300" {
  31667. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31668. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31669. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31670. resp3, requestErr3 := http.Get(api3)
  31671. if requestErr3 != nil {
  31672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31673. return
  31674. }
  31675. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31676. if ioErr3 != nil {
  31677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31679. return
  31680. }
  31681. var respJSON3 map[string]interface{}
  31682. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31685. return
  31686. }
  31687. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31688. userJSONBytes3, _ := json.Marshal(respJSON3)
  31689. fmt.Println("log")
  31690. fmt.Println(string(userJSONBytes3))
  31691. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31692. utils.ErrorLog("解析失败:%v", err)
  31693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31694. return
  31695. }
  31696. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31697. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31698. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31699. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31700. resp3, requestErr3 := http.Get(api3)
  31701. if requestErr3 != nil {
  31702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31703. return
  31704. }
  31705. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31706. if ioErr3 != nil {
  31707. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31709. return
  31710. }
  31711. var respJSON3 map[string]interface{}
  31712. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31713. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31715. return
  31716. }
  31717. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31718. userJSONBytes3, _ := json.Marshal(respJSON3)
  31719. fmt.Println("log")
  31720. fmt.Println(string(userJSONBytes3))
  31721. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31722. utils.ErrorLog("解析失败:%v", err)
  31723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31724. return
  31725. }
  31726. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31727. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31728. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31729. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31730. resp3, requestErr3 := http.Get(api3)
  31731. if requestErr3 != nil {
  31732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31733. return
  31734. }
  31735. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31736. if ioErr3 != nil {
  31737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31739. return
  31740. }
  31741. var respJSON3 map[string]interface{}
  31742. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31745. return
  31746. }
  31747. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31748. userJSONBytes3, _ := json.Marshal(respJSON3)
  31749. fmt.Println("log")
  31750. fmt.Println(string(userJSONBytes3))
  31751. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31752. utils.ErrorLog("解析失败:%v", err)
  31753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31754. return
  31755. }
  31756. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31757. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31758. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31759. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31760. resp3, requestErr3 := http.Get(api3)
  31761. if requestErr3 != nil {
  31762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31763. return
  31764. }
  31765. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31766. if ioErr3 != nil {
  31767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31769. return
  31770. }
  31771. var respJSON3 map[string]interface{}
  31772. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31775. return
  31776. }
  31777. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31778. userJSONBytes3, _ := json.Marshal(respJSON3)
  31779. fmt.Println("log")
  31780. fmt.Println(string(userJSONBytes3))
  31781. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31782. utils.ErrorLog("解析失败:%v", err)
  31783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31784. return
  31785. }
  31786. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31787. var api3 string
  31788. if miConfig.MdtrtareaAdmvs == "320921" {
  31789. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31790. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31791. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31792. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31793. } else {
  31794. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31795. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31796. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31797. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31798. }
  31799. resp3, requestErr3 := http.Get(api3)
  31800. if requestErr3 != nil {
  31801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31802. return
  31803. }
  31804. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31805. if ioErr3 != nil {
  31806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31808. return
  31809. }
  31810. var respJSON3 map[string]interface{}
  31811. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31814. return
  31815. }
  31816. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31817. userJSONBytes3, _ := json.Marshal(respJSON3)
  31818. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31819. utils.ErrorLog("解析失败:%v", err)
  31820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31821. return
  31822. }
  31823. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31824. res.Output = resSixteen10265.Output
  31825. res.ErrMsg = resSixteen10265.ErrMsg
  31826. res.Cainfo = resSixteen10265.Cainfo
  31827. res.WarnMsg = resSixteen10265.WarnMsg
  31828. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31829. res.Infcode = infocode
  31830. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31831. var api3 string
  31832. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31833. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31834. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31835. resp3, requestErr3 := http.Get(api3)
  31836. if requestErr3 != nil {
  31837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31838. return
  31839. }
  31840. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31841. if ioErr3 != nil {
  31842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31844. return
  31845. }
  31846. var respJSON3 map[string]interface{}
  31847. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31850. return
  31851. }
  31852. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31853. userJSONBytes3, _ := json.Marshal(respJSON3)
  31854. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31855. utils.ErrorLog("解析失败:%v", err)
  31856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31857. return
  31858. }
  31859. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31860. res.Output = resSixteen10265.Output
  31861. res.ErrMsg = resSixteen10265.ErrMsg
  31862. res.Cainfo = resSixteen10265.Cainfo
  31863. res.WarnMsg = resSixteen10265.WarnMsg
  31864. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31865. res.Infcode = infocode
  31866. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31867. 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)
  31868. var dat map[string]interface{}
  31869. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31870. fmt.Println(dat)
  31871. } else {
  31872. fmt.Println(err)
  31873. }
  31874. saveLog(result, src_resquest, "2208", "退费")
  31875. userJSONBytes, _ := json.Marshal(dat)
  31876. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31877. utils.ErrorLog("解析失败:%v", err)
  31878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31879. return
  31880. }
  31881. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31882. 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, "")
  31883. var dat map[string]interface{}
  31884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31885. fmt.Println(dat)
  31886. } else {
  31887. fmt.Println(err)
  31888. }
  31889. saveLog(result, src_resquest, "2208", "退费")
  31890. userJSONBytes, _ := json.Marshal(dat)
  31891. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31892. utils.ErrorLog("解析失败:%v", err)
  31893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31894. return
  31895. }
  31896. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31897. 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, "")
  31898. var dat map[string]interface{}
  31899. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31900. fmt.Println(dat)
  31901. } else {
  31902. fmt.Println(err)
  31903. }
  31904. saveLog(result, src_resquest, "2208", "退费")
  31905. userJSONBytes, _ := json.Marshal(dat)
  31906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31907. utils.ErrorLog("解析失败:%v", err)
  31908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31909. return
  31910. }
  31911. } else if miConfig.MdtrtareaAdmvs == "360100" {
  31912. 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, "")
  31913. var dat map[string]interface{}
  31914. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31915. fmt.Println(dat)
  31916. } else {
  31917. fmt.Println(err)
  31918. }
  31919. saveLog(result, src_resquest, "2208", "退费")
  31920. userJSONBytes, _ := json.Marshal(dat)
  31921. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31922. utils.ErrorLog("解析失败:%v", err)
  31923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31924. return
  31925. }
  31926. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31927. var api3 string
  31928. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31929. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31930. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31931. resp3, requestErr3 := http.Get(api3)
  31932. if requestErr3 != nil {
  31933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31934. return
  31935. }
  31936. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31937. if ioErr3 != nil {
  31938. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31940. return
  31941. }
  31942. var respJSON3 map[string]interface{}
  31943. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31944. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31946. return
  31947. }
  31948. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31949. if status == "0" {
  31950. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31951. c.ServeSuccessJSON(map[string]interface{}{
  31952. "failed_code": -10,
  31953. "msg": err_msg,
  31954. })
  31955. return
  31956. }
  31957. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31958. userJSONBytes3, _ := json.Marshal(respJSON3)
  31959. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31960. // utils.ErrorLog("解析失败:%v", err)
  31961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31962. // return
  31963. //}
  31964. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31965. utils.ErrorLog("解析失败:%v", err)
  31966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31967. return
  31968. }
  31969. res.InfRefmsgid = ahres.InfRefmsgid
  31970. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31971. // 创建对应的Time类型
  31972. t := time.UnixMilli(timestamp)
  31973. // 格式化成指定的日期字符串
  31974. str := t.Format("2006-01-02 15:04:05")
  31975. res.Output.Setlinfo.SetlTime = str
  31976. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31977. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31978. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31979. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31980. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31981. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31982. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31983. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31984. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31985. //
  31986. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31987. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31988. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31989. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31990. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31991. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31992. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31993. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31994. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31995. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31996. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31997. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31998. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31999. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32000. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32001. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32002. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32003. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32004. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32005. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32006. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32007. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32008. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32009. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32010. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32011. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32012. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32013. //res.Output.Setldetail = ahres.Output.Setldetail
  32014. res.ErrMsg = ahres.ErrMsg
  32015. res.Cainfo = ahres.Cainfo
  32016. res.WarnMsg = ahres.WarnMsg
  32017. res.Infcode = ahres.Infcode
  32018. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32019. var api3 string
  32020. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  32021. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32022. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32023. resp3, requestErr3 := http.Get(api3)
  32024. if requestErr3 != nil {
  32025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32026. return
  32027. }
  32028. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32029. if ioErr3 != nil {
  32030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32032. return
  32033. }
  32034. var respJSON3 map[string]interface{}
  32035. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32038. return
  32039. }
  32040. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32041. if status == "0" {
  32042. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32043. c.ServeSuccessJSON(map[string]interface{}{
  32044. "failed_code": -10,
  32045. "msg": err_msg,
  32046. })
  32047. return
  32048. }
  32049. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32050. userJSONBytes3, _ := json.Marshal(respJSON3)
  32051. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32052. // utils.ErrorLog("解析失败:%v", err)
  32053. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32054. // return
  32055. //}
  32056. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  32057. utils.ErrorLog("解析失败:%v", err)
  32058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32059. return
  32060. }
  32061. res.InfRefmsgid = ahres.InfRefmsgid
  32062. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32063. // 创建对应的Time类型
  32064. t := time.UnixMilli(timestamp)
  32065. // 格式化成指定的日期字符串
  32066. str := t.Format("2006-01-02 15:04:05")
  32067. res.Output.Setlinfo.SetlTime = str
  32068. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32069. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32070. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32071. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32072. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32073. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32074. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32075. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32076. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32077. //
  32078. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32079. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32080. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32081. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32082. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32083. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32084. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32085. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32086. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32087. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32088. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32089. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32090. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32091. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32092. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32093. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32094. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32095. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32096. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32097. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32098. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32099. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32100. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32101. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32102. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32103. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32104. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32105. //res.Output.Setldetail = ahres.Output.Setldetail
  32106. res.ErrMsg = ahres.ErrMsg
  32107. res.Cainfo = ahres.Cainfo
  32108. res.WarnMsg = ahres.WarnMsg
  32109. res.Infcode = ahres.Infcode
  32110. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32111. 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, "")
  32112. var dat map[string]interface{}
  32113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32114. fmt.Println(dat)
  32115. } else {
  32116. fmt.Println(err)
  32117. }
  32118. saveLog(result, src_resquest, "2208", "退费")
  32119. userJSONBytes, _ := json.Marshal(dat)
  32120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32121. utils.ErrorLog("解析失败:%v", err)
  32122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32123. return
  32124. }
  32125. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32126. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  32127. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32128. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32129. resp3, requestErr3 := http.Get(api3)
  32130. if requestErr3 != nil {
  32131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32132. return
  32133. }
  32134. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32135. if ioErr3 != nil {
  32136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32138. return
  32139. }
  32140. var respJSON3 map[string]interface{}
  32141. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32144. return
  32145. }
  32146. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32147. userJSONBytes3, _ := json.Marshal(respJSON3)
  32148. fmt.Println("log")
  32149. fmt.Println(string(userJSONBytes3))
  32150. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32151. utils.ErrorLog("解析失败:%v", err)
  32152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32153. return
  32154. }
  32155. } else {
  32156. if miConfig.Code == "H15049901371" {
  32157. 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)
  32158. var dat map[string]interface{}
  32159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32160. fmt.Println(dat)
  32161. } else {
  32162. fmt.Println(err)
  32163. }
  32164. saveLog(result, src_resquest, "2208", "退费")
  32165. if strings.Contains(result, "Post") {
  32166. res.Infcode = -1
  32167. res.ErrMsg = result
  32168. }
  32169. userJSONBytes, _ := json.Marshal(dat)
  32170. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  32171. utils.ErrorLog("解析失败:%v", err)
  32172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32173. return
  32174. }
  32175. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  32176. res.Output = resSixteen10265.Output
  32177. res.ErrMsg = resSixteen10265.ErrMsg
  32178. res.Cainfo = resSixteen10265.Cainfo
  32179. res.WarnMsg = resSixteen10265.WarnMsg
  32180. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  32181. res.Infcode = infocode
  32182. } else {
  32183. 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)
  32184. var dat map[string]interface{}
  32185. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32186. fmt.Println(dat)
  32187. } else {
  32188. fmt.Println(err)
  32189. }
  32190. saveLog(result, src_resquest, "2208", "退费")
  32191. userJSONBytes, _ := json.Marshal(dat)
  32192. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32193. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  32194. utils.ErrorLog("解析失败:%v", err)
  32195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32196. return
  32197. }
  32198. res.Infcode = gz.Infcode
  32199. } else {
  32200. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32201. utils.ErrorLog("解析失败:%v", err)
  32202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32203. return
  32204. }
  32205. }
  32206. if strings.Contains(result, "Post") {
  32207. res.Infcode = -1
  32208. res.ErrMsg = result
  32209. }
  32210. }
  32211. }
  32212. if res.Infcode == -1 {
  32213. c.ServeSuccessJSON(map[string]interface{}{
  32214. "failed_code": -10,
  32215. "msg": res.ErrMsg,
  32216. })
  32217. return
  32218. }
  32219. if res.Infcode != -1 {
  32220. var res2 ResultSix
  32221. var resSix10265 ResultSix10265
  32222. if miConfig.MdtrtareaAdmvs == "421300" {
  32223. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32224. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32225. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32226. resp3, requestErr3 := http.Get(api3)
  32227. if requestErr3 != nil {
  32228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32229. return
  32230. }
  32231. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32232. if ioErr3 != nil {
  32233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32235. return
  32236. }
  32237. var respJSON3 map[string]interface{}
  32238. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32241. return
  32242. }
  32243. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32244. userJSONBytes3, _ := json.Marshal(respJSON3)
  32245. fmt.Println("log")
  32246. fmt.Println(string(userJSONBytes3))
  32247. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32248. utils.ErrorLog("解析失败:%v", err)
  32249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32250. return
  32251. }
  32252. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32253. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32254. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32255. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32256. resp3, requestErr3 := http.Get(api3)
  32257. if requestErr3 != nil {
  32258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32259. return
  32260. }
  32261. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32262. if ioErr3 != nil {
  32263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32265. return
  32266. }
  32267. var respJSON3 map[string]interface{}
  32268. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32271. return
  32272. }
  32273. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32274. userJSONBytes3, _ := json.Marshal(respJSON3)
  32275. fmt.Println("log")
  32276. fmt.Println(string(userJSONBytes3))
  32277. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32278. utils.ErrorLog("解析失败:%v", err)
  32279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32280. return
  32281. }
  32282. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32283. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32284. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32285. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32286. resp3, requestErr3 := http.Get(api3)
  32287. if requestErr3 != nil {
  32288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32289. return
  32290. }
  32291. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32292. if ioErr3 != nil {
  32293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32295. return
  32296. }
  32297. var respJSON3 map[string]interface{}
  32298. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32301. return
  32302. }
  32303. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32304. userJSONBytes3, _ := json.Marshal(respJSON3)
  32305. fmt.Println("log")
  32306. fmt.Println(string(userJSONBytes3))
  32307. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32308. utils.ErrorLog("解析失败:%v", err)
  32309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32310. return
  32311. }
  32312. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32313. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32314. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32315. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32316. resp3, requestErr3 := http.Get(api3)
  32317. if requestErr3 != nil {
  32318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32319. return
  32320. }
  32321. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32322. if ioErr3 != nil {
  32323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32325. return
  32326. }
  32327. var respJSON3 map[string]interface{}
  32328. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32331. return
  32332. }
  32333. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32334. userJSONBytes3, _ := json.Marshal(respJSON3)
  32335. fmt.Println("log")
  32336. fmt.Println(string(userJSONBytes3))
  32337. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32338. utils.ErrorLog("解析失败:%v", err)
  32339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32340. return
  32341. }
  32342. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32343. var api3 string
  32344. if miConfig.MdtrtareaAdmvs == "320921" {
  32345. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32346. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32347. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32348. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32349. } else {
  32350. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32351. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32352. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32353. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32354. }
  32355. resp3, requestErr3 := http.Get(api3)
  32356. if requestErr3 != nil {
  32357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32358. return
  32359. }
  32360. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32361. if ioErr3 != nil {
  32362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32364. return
  32365. }
  32366. var respJSON3 map[string]interface{}
  32367. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32370. return
  32371. }
  32372. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32373. userJSONBytes3, _ := json.Marshal(respJSON3)
  32374. fmt.Println("log")
  32375. fmt.Println(string(userJSONBytes3))
  32376. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32377. utils.ErrorLog("解析失败:%v", err)
  32378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32379. return
  32380. }
  32381. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32382. res2.Output = resSix10265.Output
  32383. res2.ErrMsg = resSix10265.ErrMsg
  32384. res2.Cainfo = resSix10265.Cainfo
  32385. res2.WarnMsg = resSix10265.WarnMsg
  32386. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32387. res2.Infcode = infocode
  32388. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32389. var api3 string
  32390. new_chrg_bchno := order.Number
  32391. if adminUser.CurrentOrgId == 10265 {
  32392. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32393. new_chrg_bchno = "0000"
  32394. }
  32395. }
  32396. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32397. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32398. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32399. resp3, requestErr3 := http.Get(api3)
  32400. if requestErr3 != nil {
  32401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32402. return
  32403. }
  32404. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32405. if ioErr3 != nil {
  32406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32408. return
  32409. }
  32410. var respJSON3 map[string]interface{}
  32411. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32414. return
  32415. }
  32416. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32417. userJSONBytes3, _ := json.Marshal(respJSON3)
  32418. fmt.Println("log")
  32419. fmt.Println(string(userJSONBytes3))
  32420. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32421. utils.ErrorLog("解析失败:%v", err)
  32422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32423. return
  32424. }
  32425. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32426. res2.Output = resSix10265.Output
  32427. res2.ErrMsg = resSix10265.ErrMsg
  32428. res2.Cainfo = resSix10265.Cainfo
  32429. res2.WarnMsg = resSix10265.WarnMsg
  32430. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32431. res2.Infcode = infocode
  32432. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32433. 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)
  32434. var dat map[string]interface{}
  32435. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32436. fmt.Println(dat)
  32437. } else {
  32438. fmt.Println(err)
  32439. }
  32440. saveLog(result2, src_request, "2205", "撤销明细")
  32441. userJSONBytes, _ := json.Marshal(dat)
  32442. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32443. utils.ErrorLog("解析失败:%v", err)
  32444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32445. return
  32446. }
  32447. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32448. 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, "")
  32449. var dat map[string]interface{}
  32450. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32451. fmt.Println(dat)
  32452. } else {
  32453. fmt.Println(err)
  32454. }
  32455. saveLog(result2, src_request, "2205", "撤销明细")
  32456. userJSONBytes, _ := json.Marshal(dat)
  32457. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32458. utils.ErrorLog("解析失败:%v", err)
  32459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32460. return
  32461. }
  32462. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32463. 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, "")
  32464. var dat map[string]interface{}
  32465. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32466. fmt.Println(dat)
  32467. } else {
  32468. fmt.Println(err)
  32469. }
  32470. saveLog(result2, src_request, "2205", "撤销明细")
  32471. userJSONBytes, _ := json.Marshal(dat)
  32472. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32473. utils.ErrorLog("解析失败:%v", err)
  32474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32475. return
  32476. }
  32477. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32478. 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, "")
  32479. var dat map[string]interface{}
  32480. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32481. fmt.Println(dat)
  32482. } else {
  32483. fmt.Println(err)
  32484. }
  32485. saveLog(result2, src_request, "2205", "撤销明细")
  32486. userJSONBytes, _ := json.Marshal(dat)
  32487. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32488. utils.ErrorLog("解析失败:%v", err)
  32489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32490. return
  32491. }
  32492. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32493. var api3 string
  32494. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32495. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32496. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32497. resp3, requestErr3 := http.Get(api3)
  32498. if requestErr3 != nil {
  32499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32500. return
  32501. }
  32502. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32503. if ioErr3 != nil {
  32504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32506. return
  32507. }
  32508. var respJSON3 map[string]interface{}
  32509. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32512. return
  32513. }
  32514. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32515. if status == "0" {
  32516. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32517. c.ServeSuccessJSON(map[string]interface{}{
  32518. "failed_code": -10,
  32519. "msg": err_msg,
  32520. })
  32521. return
  32522. }
  32523. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32524. userJSONBytes3, _ := json.Marshal(respJSON3)
  32525. fmt.Println("log")
  32526. fmt.Println(string(userJSONBytes3))
  32527. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32528. utils.ErrorLog("解析失败:%v", err)
  32529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32530. return
  32531. }
  32532. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32533. 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, "")
  32534. var dat map[string]interface{}
  32535. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32536. fmt.Println(dat)
  32537. } else {
  32538. fmt.Println(err)
  32539. }
  32540. saveLog(result2, src_request, "2205", "撤销明细")
  32541. userJSONBytes, _ := json.Marshal(dat)
  32542. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32543. utils.ErrorLog("解析失败:%v", err)
  32544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32545. return
  32546. }
  32547. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32548. 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, "")
  32549. var dat map[string]interface{}
  32550. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32551. fmt.Println(dat)
  32552. } else {
  32553. fmt.Println(err)
  32554. }
  32555. saveLog(result2, src_request, "2205", "撤销明细")
  32556. userJSONBytes, _ := json.Marshal(dat)
  32557. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32558. utils.ErrorLog("解析失败:%v", err)
  32559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32560. return
  32561. }
  32562. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32563. 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, "")
  32564. var dat map[string]interface{}
  32565. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32566. fmt.Println(dat)
  32567. } else {
  32568. fmt.Println(err)
  32569. }
  32570. saveLog(result2, src_request, "2205", "撤销明细")
  32571. userJSONBytes, _ := json.Marshal(dat)
  32572. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32573. utils.ErrorLog("解析失败:%v", err)
  32574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32575. return
  32576. }
  32577. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32578. var api3 string
  32579. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32580. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32581. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32582. resp3, requestErr3 := http.Get(api3)
  32583. if requestErr3 != nil {
  32584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32585. return
  32586. }
  32587. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32588. if ioErr3 != nil {
  32589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32591. return
  32592. }
  32593. var respJSON3 map[string]interface{}
  32594. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32597. return
  32598. }
  32599. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32600. if status == "0" {
  32601. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32602. c.ServeSuccessJSON(map[string]interface{}{
  32603. "failed_code": -10,
  32604. "msg": err_msg,
  32605. })
  32606. return
  32607. }
  32608. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32609. userJSONBytes3, _ := json.Marshal(respJSON3)
  32610. fmt.Println("log")
  32611. fmt.Println(string(userJSONBytes3))
  32612. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32613. utils.ErrorLog("解析失败:%v", err)
  32614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32615. return
  32616. }
  32617. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32618. 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, "")
  32619. var dat map[string]interface{}
  32620. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32621. fmt.Println(dat)
  32622. } else {
  32623. fmt.Println(err)
  32624. }
  32625. saveLog(result2, src_request, "2205", "撤销明细")
  32626. userJSONBytes, _ := json.Marshal(dat)
  32627. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32628. utils.ErrorLog("解析失败:%v", err)
  32629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32630. return
  32631. }
  32632. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32633. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  32634. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32635. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32636. resp3, requestErr3 := http.Get(api3)
  32637. if requestErr3 != nil {
  32638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32639. return
  32640. }
  32641. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32642. if ioErr3 != nil {
  32643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32645. return
  32646. }
  32647. var respJSON3 map[string]interface{}
  32648. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32651. return
  32652. }
  32653. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32654. userJSONBytes3, _ := json.Marshal(respJSON3)
  32655. fmt.Println("log")
  32656. fmt.Println(string(userJSONBytes3))
  32657. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32658. utils.ErrorLog("解析失败:%v", err)
  32659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32660. return
  32661. }
  32662. } else {
  32663. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32664. res2.Infcode = 0
  32665. } else {
  32666. 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)
  32667. var dat map[string]interface{}
  32668. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32669. fmt.Println(dat)
  32670. } else {
  32671. fmt.Println(err)
  32672. }
  32673. saveLog(result2, src_request, "2205", "撤销明细")
  32674. userJSONBytes, _ := json.Marshal(dat)
  32675. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32676. utils.ErrorLog("解析失败:%v", err)
  32677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32678. return
  32679. }
  32680. }
  32681. }
  32682. if res2.Infcode == -1 {
  32683. c.ServeSuccessJSON(map[string]interface{}{
  32684. "failed_code": -10,
  32685. "msg": res2.ErrMsg,
  32686. })
  32687. return
  32688. }
  32689. if res2.Infcode == 0 {
  32690. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  32691. if err == nil {
  32692. //当押金不为零时产生退费记录
  32693. if order.Decimal != 0 {
  32694. tmp := strconv.FormatInt(order.ID, 10)
  32695. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  32696. if err != nil {
  32697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32698. return
  32699. }
  32700. }
  32701. c.ServeSuccessJSON(map[string]interface{}{
  32702. "msg": "退费成功",
  32703. })
  32704. } else {
  32705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32706. return
  32707. }
  32708. } else {
  32709. c.ServeSuccessJSON(map[string]interface{}{
  32710. "failed_code": -10,
  32711. "msg": res2.ErrMsg,
  32712. })
  32713. }
  32714. } else {
  32715. c.ServeSuccessJSON(map[string]interface{}{
  32716. "failed_code": -10,
  32717. "msg": res.ErrMsg,
  32718. })
  32719. }
  32720. }
  32721. }
  32722. func (c *HisApiController) RefundNumber() {
  32723. record_time := c.GetString("record_time")
  32724. //patient_id, _ := c.GetInt64("patient_id")
  32725. admin_user_id, _ := c.GetInt64("admin_user_id")
  32726. his_patient_id, _ := c.GetInt64("id")
  32727. timeLayout := "2006-01-02"
  32728. loc, _ := time.LoadLocation("Local")
  32729. adminUser := c.GetAdminUserInfo()
  32730. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32731. fmt.Println(err)
  32732. if err != nil {
  32733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32734. return
  32735. }
  32736. recordDateTime := theTime.Unix()
  32737. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32738. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32739. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32740. //order, _ := service.GetHisOrderByID(order_id)
  32741. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32742. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32743. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32744. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32745. if count > 0 {
  32746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32747. return
  32748. }
  32749. if config.IsOpen == 1 { //对接了医保,走医保流程
  32750. var res2 ResultSix
  32751. var res3 GZResultSix
  32752. var resSix10265 ResultSix10265
  32753. if miConfig.MdtrtareaAdmvs == "421300" {
  32754. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32755. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32756. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32757. resp3, requestErr3 := http.Get(api3)
  32758. if requestErr3 != nil {
  32759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32760. return
  32761. }
  32762. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32763. if ioErr3 != nil {
  32764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32766. return
  32767. }
  32768. var respJSON3 map[string]interface{}
  32769. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32772. return
  32773. }
  32774. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32775. userJSONBytes3, _ := json.Marshal(respJSON3)
  32776. fmt.Println("log")
  32777. fmt.Println(string(userJSONBytes3))
  32778. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32779. utils.ErrorLog("解析失败:%v", err)
  32780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32781. return
  32782. }
  32783. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32784. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32785. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32786. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32787. resp3, requestErr3 := http.Get(api3)
  32788. if requestErr3 != nil {
  32789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32790. return
  32791. }
  32792. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32793. if ioErr3 != nil {
  32794. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32796. return
  32797. }
  32798. var respJSON3 map[string]interface{}
  32799. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32802. return
  32803. }
  32804. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32805. userJSONBytes3, _ := json.Marshal(respJSON3)
  32806. fmt.Println("log")
  32807. fmt.Println(string(userJSONBytes3))
  32808. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32809. utils.ErrorLog("解析失败:%v", err)
  32810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32811. return
  32812. }
  32813. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32814. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32815. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32816. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32817. resp3, requestErr3 := http.Get(api3)
  32818. if requestErr3 != nil {
  32819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32820. return
  32821. }
  32822. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32823. if ioErr3 != nil {
  32824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32826. return
  32827. }
  32828. var respJSON3 map[string]interface{}
  32829. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32832. return
  32833. }
  32834. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32835. userJSONBytes3, _ := json.Marshal(respJSON3)
  32836. fmt.Println("log")
  32837. fmt.Println(string(userJSONBytes3))
  32838. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32839. utils.ErrorLog("解析失败:%v", err)
  32840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32841. return
  32842. }
  32843. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32844. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32845. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32846. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32847. resp3, requestErr3 := http.Get(api3)
  32848. if requestErr3 != nil {
  32849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32850. return
  32851. }
  32852. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32853. if ioErr3 != nil {
  32854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32856. return
  32857. }
  32858. var respJSON3 map[string]interface{}
  32859. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32862. return
  32863. }
  32864. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32865. userJSONBytes3, _ := json.Marshal(respJSON3)
  32866. fmt.Println("log")
  32867. fmt.Println(string(userJSONBytes3))
  32868. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32869. utils.ErrorLog("解析失败:%v", err)
  32870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32871. return
  32872. }
  32873. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32874. var api3 string
  32875. if miConfig.MdtrtareaAdmvs == "320921" {
  32876. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32877. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32878. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32879. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32880. } else {
  32881. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32882. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32883. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32884. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32885. }
  32886. resp3, requestErr3 := http.Get(api3)
  32887. if requestErr3 != nil {
  32888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32889. return
  32890. }
  32891. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32892. if ioErr3 != nil {
  32893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32895. return
  32896. }
  32897. var respJSON3 map[string]interface{}
  32898. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32901. return
  32902. }
  32903. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32904. userJSONBytes3, _ := json.Marshal(respJSON3)
  32905. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32906. utils.ErrorLog("解析失败:%v", err)
  32907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32908. return
  32909. }
  32910. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32911. res2.Output = resSix10265.Output
  32912. res2.ErrMsg = resSix10265.ErrMsg
  32913. res2.Cainfo = resSix10265.Cainfo
  32914. res2.WarnMsg = resSix10265.WarnMsg
  32915. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32916. res2.Infcode = infocode
  32917. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32918. var api3 string
  32919. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32920. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32921. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32922. resp3, requestErr3 := http.Get(api3)
  32923. if requestErr3 != nil {
  32924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32925. return
  32926. }
  32927. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32928. if ioErr3 != nil {
  32929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32931. return
  32932. }
  32933. var respJSON3 map[string]interface{}
  32934. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32937. return
  32938. }
  32939. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32940. userJSONBytes3, _ := json.Marshal(respJSON3)
  32941. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32942. utils.ErrorLog("解析失败:%v", err)
  32943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32944. return
  32945. }
  32946. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32947. res2.Output = resSix10265.Output
  32948. res2.ErrMsg = resSix10265.ErrMsg
  32949. res2.Cainfo = resSix10265.Cainfo
  32950. res2.WarnMsg = resSix10265.WarnMsg
  32951. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32952. res2.Infcode = infocode
  32953. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32954. 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)
  32955. var dat map[string]interface{}
  32956. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32957. fmt.Println(dat)
  32958. } else {
  32959. fmt.Println(err)
  32960. }
  32961. saveLog(result, request, "2202", "退号")
  32962. userJSONBytes, _ := json.Marshal(dat)
  32963. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32964. utils.ErrorLog("解析失败:%v", err)
  32965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32966. return
  32967. }
  32968. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32969. 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, "")
  32970. var dat map[string]interface{}
  32971. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32972. fmt.Println(dat)
  32973. } else {
  32974. fmt.Println(err)
  32975. }
  32976. saveLog(result, request, "2202", "退号")
  32977. userJSONBytes, _ := json.Marshal(dat)
  32978. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32979. utils.ErrorLog("解析失败:%v", err)
  32980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32981. return
  32982. }
  32983. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32984. 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, "")
  32985. var dat map[string]interface{}
  32986. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32987. fmt.Println(dat)
  32988. } else {
  32989. fmt.Println(err)
  32990. }
  32991. saveLog(result, request, "2202", "退号")
  32992. userJSONBytes, _ := json.Marshal(dat)
  32993. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32994. utils.ErrorLog("解析失败:%v", err)
  32995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32996. return
  32997. }
  32998. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32999. 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, "")
  33000. var dat map[string]interface{}
  33001. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33002. fmt.Println(dat)
  33003. } else {
  33004. fmt.Println(err)
  33005. }
  33006. saveLog(result, request, "2202", "退号")
  33007. userJSONBytes, _ := json.Marshal(dat)
  33008. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33009. utils.ErrorLog("解析失败:%v", err)
  33010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33011. return
  33012. }
  33013. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33014. var api3 string
  33015. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  33016. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33017. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33018. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33019. resp3, requestErr3 := http.Get(api3)
  33020. if requestErr3 != nil {
  33021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33022. return
  33023. }
  33024. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33025. if ioErr3 != nil {
  33026. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33028. return
  33029. }
  33030. var respJSON3 map[string]interface{}
  33031. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33034. return
  33035. }
  33036. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33037. if status == "0" {
  33038. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33039. c.ServeSuccessJSON(map[string]interface{}{
  33040. "failed_code": -10,
  33041. "msg": err_msg,
  33042. })
  33043. return
  33044. }
  33045. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33046. userJSONBytes3, _ := json.Marshal(respJSON3)
  33047. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33048. utils.ErrorLog("解析失败:%v", err)
  33049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33050. return
  33051. }
  33052. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  33053. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33054. var api3 string
  33055. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  33056. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33057. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33058. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33059. resp3, requestErr3 := http.Get(api3)
  33060. if requestErr3 != nil {
  33061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33062. return
  33063. }
  33064. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33065. if ioErr3 != nil {
  33066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33068. return
  33069. }
  33070. var respJSON3 map[string]interface{}
  33071. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33074. return
  33075. }
  33076. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33077. if status == "0" {
  33078. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33079. c.ServeSuccessJSON(map[string]interface{}{
  33080. "failed_code": -10,
  33081. "msg": err_msg,
  33082. })
  33083. return
  33084. }
  33085. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33086. userJSONBytes3, _ := json.Marshal(respJSON3)
  33087. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33088. utils.ErrorLog("解析失败:%v", err)
  33089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33090. return
  33091. }
  33092. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  33093. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33094. 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, "")
  33095. var dat map[string]interface{}
  33096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33097. fmt.Println(dat)
  33098. } else {
  33099. fmt.Println(err)
  33100. }
  33101. saveLog(result, request, "2202", "退号")
  33102. userJSONBytes, _ := json.Marshal(dat)
  33103. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33104. utils.ErrorLog("解析失败:%v", err)
  33105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33106. return
  33107. }
  33108. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33109. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  33110. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33111. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33112. resp3, requestErr3 := http.Get(api3)
  33113. if requestErr3 != nil {
  33114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33115. return
  33116. }
  33117. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33118. if ioErr3 != nil {
  33119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33121. return
  33122. }
  33123. var respJSON3 map[string]interface{}
  33124. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33127. return
  33128. }
  33129. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33130. userJSONBytes3, _ := json.Marshal(respJSON3)
  33131. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33132. utils.ErrorLog("解析失败:%v", err)
  33133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33134. return
  33135. }
  33136. } else {
  33137. var api3 string
  33138. if miConfig.Code == "H15049901371" {
  33139. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  33140. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33141. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33142. } else {
  33143. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  33144. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33145. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33146. }
  33147. resp3, requestErr3 := http.Get(api3)
  33148. if requestErr3 != nil {
  33149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33150. return
  33151. }
  33152. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33153. if ioErr3 != nil {
  33154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33156. return
  33157. }
  33158. var respJSON3 map[string]interface{}
  33159. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33162. return
  33163. }
  33164. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33165. userJSONBytes3, _ := json.Marshal(respJSON3)
  33166. if miConfig.Code == "H15049901371" {
  33167. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33168. utils.ErrorLog("解析失败:%v", err)
  33169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33170. return
  33171. }
  33172. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33173. res2.Output = resSix10265.Output
  33174. res2.ErrMsg = resSix10265.ErrMsg
  33175. res2.Cainfo = resSix10265.Cainfo
  33176. res2.WarnMsg = resSix10265.WarnMsg
  33177. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33178. res2.Infcode = infocode
  33179. } else {
  33180. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33181. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  33182. utils.ErrorLog("解析失败:%v", err)
  33183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33184. return
  33185. }
  33186. res2.Infcode = res3.Infcode
  33187. } else {
  33188. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33189. utils.ErrorLog("解析失败:%v", err)
  33190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33191. return
  33192. }
  33193. }
  33194. }
  33195. }
  33196. if res2.Infcode == -1 {
  33197. c.ServeSuccessJSON(map[string]interface{}{
  33198. "failed_code": -10,
  33199. "msg": res2.ErrMsg,
  33200. })
  33201. return
  33202. }
  33203. if res2.Infcode == 0 {
  33204. if err == nil {
  33205. c.ServeSuccessJSON(map[string]interface{}{
  33206. "msg": "退号成功",
  33207. })
  33208. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  33209. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  33210. } else {
  33211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33212. return
  33213. }
  33214. }
  33215. } else {
  33216. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  33217. //if err == nil {
  33218. // c.ServeSuccessJSON(map[string]interface{}{
  33219. // "msg": "退费成功",
  33220. // })
  33221. //} else {
  33222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33223. // return
  33224. //}
  33225. }
  33226. }
  33227. func (c *HisApiController) RefundDetail() {
  33228. order_id, _ := c.GetInt64("order_id")
  33229. admin_user_id, _ := c.GetInt64("admin_user_id")
  33230. //his_patient_id, _ := c.GetInt64("his_patient_id")
  33231. number := c.GetString("number")
  33232. record_time := c.GetString("record_time")
  33233. patient_id, _ := c.GetInt64("patient_id")
  33234. //med_type, _ := c.GetInt64("med_type")
  33235. timeLayout := "2006-01-02"
  33236. loc, _ := time.LoadLocation("Local")
  33237. adminUser := c.GetAdminUserInfo()
  33238. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33239. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33240. fmt.Println(err)
  33241. if err != nil {
  33242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33243. return
  33244. }
  33245. recordDateTime := theTime.Unix()
  33246. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  33247. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33248. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33249. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33250. var order models.HisOrder
  33251. order, _ = service.GetHisOrderByID(order_id)
  33252. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33253. if config.IsOpen == 1 { //对接了医保,走医保流程
  33254. var res2 ResultSix
  33255. if miConfig.MdtrtareaAdmvs == "421300" {
  33256. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33257. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33258. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33259. resp3, requestErr3 := http.Get(api3)
  33260. if requestErr3 != nil {
  33261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33262. return
  33263. }
  33264. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33265. if ioErr3 != nil {
  33266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33268. return
  33269. }
  33270. var respJSON3 map[string]interface{}
  33271. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33274. return
  33275. }
  33276. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33277. userJSONBytes3, _ := json.Marshal(respJSON3)
  33278. fmt.Println("log")
  33279. fmt.Println(string(userJSONBytes3))
  33280. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33281. utils.ErrorLog("解析失败:%v", err)
  33282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33283. return
  33284. }
  33285. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33286. if err == nil {
  33287. c.ServeSuccessJSON(map[string]interface{}{
  33288. "msg": "撤销明细成功",
  33289. })
  33290. return
  33291. } else {
  33292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33293. return
  33294. }
  33295. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33296. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33297. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33298. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33299. resp3, requestErr3 := http.Get(api3)
  33300. if requestErr3 != nil {
  33301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33302. return
  33303. }
  33304. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33305. if ioErr3 != nil {
  33306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33308. return
  33309. }
  33310. var respJSON3 map[string]interface{}
  33311. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33314. return
  33315. }
  33316. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33317. userJSONBytes3, _ := json.Marshal(respJSON3)
  33318. fmt.Println("log")
  33319. fmt.Println(string(userJSONBytes3))
  33320. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33321. utils.ErrorLog("解析失败:%v", err)
  33322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33323. return
  33324. }
  33325. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33326. if err == nil {
  33327. c.ServeSuccessJSON(map[string]interface{}{
  33328. "msg": "撤销明细成功",
  33329. })
  33330. return
  33331. } else {
  33332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33333. return
  33334. }
  33335. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33336. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33337. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33338. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33339. resp3, requestErr3 := http.Get(api3)
  33340. if requestErr3 != nil {
  33341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33342. return
  33343. }
  33344. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33345. if ioErr3 != nil {
  33346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33348. return
  33349. }
  33350. var respJSON3 map[string]interface{}
  33351. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33354. return
  33355. }
  33356. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33357. userJSONBytes3, _ := json.Marshal(respJSON3)
  33358. fmt.Println("log")
  33359. fmt.Println(string(userJSONBytes3))
  33360. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33361. utils.ErrorLog("解析失败:%v", err)
  33362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33363. return
  33364. }
  33365. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33366. if err == nil {
  33367. c.ServeSuccessJSON(map[string]interface{}{
  33368. "msg": "撤销明细成功",
  33369. })
  33370. return
  33371. } else {
  33372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33373. return
  33374. }
  33375. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33376. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33377. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33378. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33379. resp3, requestErr3 := http.Get(api3)
  33380. if requestErr3 != nil {
  33381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33382. return
  33383. }
  33384. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33385. if ioErr3 != nil {
  33386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33388. return
  33389. }
  33390. var respJSON3 map[string]interface{}
  33391. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33394. return
  33395. }
  33396. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33397. userJSONBytes3, _ := json.Marshal(respJSON3)
  33398. fmt.Println("log")
  33399. fmt.Println(string(userJSONBytes3))
  33400. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33401. utils.ErrorLog("解析失败:%v", err)
  33402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33403. return
  33404. }
  33405. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33406. if err == nil {
  33407. c.ServeSuccessJSON(map[string]interface{}{
  33408. "msg": "撤销明细成功",
  33409. })
  33410. return
  33411. } else {
  33412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33413. return
  33414. }
  33415. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33416. var resSix10265 ResultSix10265
  33417. var api3 string
  33418. if miConfig.MdtrtareaAdmvs == "320921" {
  33419. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33420. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33421. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33422. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33423. } else {
  33424. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33425. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33426. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33427. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33428. }
  33429. resp3, requestErr3 := http.Get(api3)
  33430. utils.ErrorLog("接口: %v", requestErr3)
  33431. if requestErr3 != nil {
  33432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33433. return
  33434. }
  33435. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33436. if ioErr3 != nil {
  33437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33439. return
  33440. }
  33441. var respJSON3 map[string]interface{}
  33442. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33445. return
  33446. }
  33447. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33448. userJSONBytes3, _ := json.Marshal(respJSON3)
  33449. fmt.Println("log")
  33450. fmt.Println(string(userJSONBytes3))
  33451. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33452. utils.ErrorLog("解析失败:%v", err)
  33453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33454. return
  33455. }
  33456. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33457. res2.Output = resSix10265.Output
  33458. res2.ErrMsg = resSix10265.ErrMsg
  33459. res2.Cainfo = resSix10265.Cainfo
  33460. res2.WarnMsg = resSix10265.WarnMsg
  33461. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33462. res2.Infcode = infocode
  33463. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33464. if err == nil {
  33465. c.ServeSuccessJSON(map[string]interface{}{
  33466. "msg": "撤销明细成功",
  33467. })
  33468. return
  33469. } else {
  33470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33471. return
  33472. }
  33473. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33474. var api3 string
  33475. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33476. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33477. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33478. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33479. resp3, requestErr3 := http.Get(api3)
  33480. utils.ErrorLog("接口: %v", requestErr3)
  33481. if requestErr3 != nil {
  33482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33483. return
  33484. }
  33485. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33486. if ioErr3 != nil {
  33487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33489. return
  33490. }
  33491. var respJSON3 map[string]interface{}
  33492. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33495. return
  33496. }
  33497. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33498. if status == "0" {
  33499. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33500. c.ServeSuccessJSON(map[string]interface{}{
  33501. "failed_code": -10,
  33502. "msg": err_msg,
  33503. })
  33504. return
  33505. }
  33506. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33507. userJSONBytes3, _ := json.Marshal(respJSON3)
  33508. fmt.Println("log")
  33509. fmt.Println(string(userJSONBytes3))
  33510. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33511. utils.ErrorLog("解析失败:%v", err)
  33512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33513. return
  33514. }
  33515. fmt.Println(res2.Infcode)
  33516. if res2.Infcode == -1 {
  33517. c.ServeSuccessJSON(map[string]interface{}{
  33518. "failed_code": -10,
  33519. "msg": res2.ErrMsg,
  33520. })
  33521. return
  33522. }
  33523. if res2.Infcode == 0 {
  33524. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33525. if err == nil {
  33526. c.ServeSuccessJSON(map[string]interface{}{
  33527. "msg": "撤销明细成功",
  33528. })
  33529. return
  33530. } else {
  33531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33532. return
  33533. }
  33534. } else {
  33535. c.ServeSuccessJSON(map[string]interface{}{
  33536. "failed_code": -10,
  33537. "msg": res2.ErrMsg,
  33538. })
  33539. }
  33540. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33541. if err == nil {
  33542. c.ServeSuccessJSON(map[string]interface{}{
  33543. "msg": "撤销明细成功",
  33544. })
  33545. return
  33546. } else {
  33547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33548. return
  33549. }
  33550. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33551. var api3 string
  33552. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33553. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33554. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33555. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33556. resp3, requestErr3 := http.Get(api3)
  33557. utils.ErrorLog("接口: %v", requestErr3)
  33558. if requestErr3 != nil {
  33559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33560. return
  33561. }
  33562. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33563. if ioErr3 != nil {
  33564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33566. return
  33567. }
  33568. var respJSON3 map[string]interface{}
  33569. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33572. return
  33573. }
  33574. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33575. if status == "0" {
  33576. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33577. c.ServeSuccessJSON(map[string]interface{}{
  33578. "failed_code": -10,
  33579. "msg": err_msg,
  33580. })
  33581. return
  33582. }
  33583. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33584. userJSONBytes3, _ := json.Marshal(respJSON3)
  33585. fmt.Println("log")
  33586. fmt.Println(string(userJSONBytes3))
  33587. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33588. utils.ErrorLog("解析失败:%v", err)
  33589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33590. return
  33591. }
  33592. fmt.Println(res2.Infcode)
  33593. if res2.Infcode == -1 {
  33594. c.ServeSuccessJSON(map[string]interface{}{
  33595. "failed_code": -10,
  33596. "msg": res2.ErrMsg,
  33597. })
  33598. return
  33599. }
  33600. if res2.Infcode == 0 {
  33601. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33602. if err == nil {
  33603. c.ServeSuccessJSON(map[string]interface{}{
  33604. "msg": "撤销明细成功",
  33605. })
  33606. return
  33607. } else {
  33608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33609. return
  33610. }
  33611. } else {
  33612. c.ServeSuccessJSON(map[string]interface{}{
  33613. "failed_code": -10,
  33614. "msg": res2.ErrMsg,
  33615. })
  33616. }
  33617. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33618. if err == nil {
  33619. c.ServeSuccessJSON(map[string]interface{}{
  33620. "msg": "撤销明细成功",
  33621. })
  33622. return
  33623. } else {
  33624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33625. return
  33626. }
  33627. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33628. var resSix10265 ResultSix10265
  33629. new_chrg_bchno := order.Number
  33630. if adminUser.CurrentOrgId == 10265 {
  33631. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33632. new_chrg_bchno = "0000"
  33633. }
  33634. }
  33635. var api3 string
  33636. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33637. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33638. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33639. resp3, requestErr3 := http.Get(api3)
  33640. if requestErr3 != nil {
  33641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33642. return
  33643. }
  33644. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33645. if ioErr3 != nil {
  33646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33648. return
  33649. }
  33650. var respJSON3 map[string]interface{}
  33651. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33654. return
  33655. }
  33656. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33657. userJSONBytes3, _ := json.Marshal(respJSON3)
  33658. fmt.Println("log")
  33659. fmt.Println(string(userJSONBytes3))
  33660. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33661. utils.ErrorLog("解析失败:%v", err)
  33662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33663. return
  33664. }
  33665. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33666. res2.Output = resSix10265.Output
  33667. res2.ErrMsg = resSix10265.ErrMsg
  33668. res2.Cainfo = resSix10265.Cainfo
  33669. res2.WarnMsg = resSix10265.WarnMsg
  33670. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33671. res2.Infcode = infocode
  33672. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33673. if err == nil {
  33674. c.ServeSuccessJSON(map[string]interface{}{
  33675. "msg": "撤销明细成功",
  33676. })
  33677. return
  33678. } else {
  33679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33680. return
  33681. }
  33682. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33683. 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)
  33684. var dat map[string]interface{}
  33685. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33686. fmt.Println(dat)
  33687. } else {
  33688. fmt.Println(err)
  33689. }
  33690. saveLog(result2, src_request, "2205", "撤销明细")
  33691. userJSONBytes, _ := json.Marshal(dat)
  33692. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33693. utils.ErrorLog("解析失败:%v", err)
  33694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33695. return
  33696. }
  33697. if res2.Infcode == 0 {
  33698. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33699. if err == nil {
  33700. c.ServeSuccessJSON(map[string]interface{}{
  33701. "msg": "撤销明细成功",
  33702. })
  33703. return
  33704. } else {
  33705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33706. return
  33707. }
  33708. } else {
  33709. c.ServeSuccessJSON(map[string]interface{}{
  33710. "failed_code": -10,
  33711. "msg": res2.ErrMsg,
  33712. })
  33713. }
  33714. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33715. 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, "")
  33716. var dat map[string]interface{}
  33717. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33718. fmt.Println(dat)
  33719. } else {
  33720. fmt.Println(err)
  33721. }
  33722. saveLog(result2, src_request, "2205", "撤销明细")
  33723. userJSONBytes, _ := json.Marshal(dat)
  33724. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33725. utils.ErrorLog("解析失败:%v", err)
  33726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33727. return
  33728. }
  33729. if res2.Infcode == 0 {
  33730. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33731. if err == nil {
  33732. c.ServeSuccessJSON(map[string]interface{}{
  33733. "msg": "撤销明细成功",
  33734. })
  33735. return
  33736. } else {
  33737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33738. return
  33739. }
  33740. } else {
  33741. c.ServeSuccessJSON(map[string]interface{}{
  33742. "failed_code": -10,
  33743. "msg": res2.ErrMsg,
  33744. })
  33745. }
  33746. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33747. 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, "")
  33748. var dat map[string]interface{}
  33749. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33750. fmt.Println(dat)
  33751. } else {
  33752. fmt.Println(err)
  33753. }
  33754. saveLog(result2, src_request, "2205", "撤销明细")
  33755. userJSONBytes, _ := json.Marshal(dat)
  33756. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33757. utils.ErrorLog("解析失败:%v", err)
  33758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33759. return
  33760. }
  33761. if res2.Infcode == 0 {
  33762. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33763. if err == nil {
  33764. c.ServeSuccessJSON(map[string]interface{}{
  33765. "msg": "撤销明细成功",
  33766. })
  33767. return
  33768. } else {
  33769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33770. return
  33771. }
  33772. } else {
  33773. c.ServeSuccessJSON(map[string]interface{}{
  33774. "failed_code": -10,
  33775. "msg": res2.ErrMsg,
  33776. })
  33777. }
  33778. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33779. 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, "")
  33780. var dat map[string]interface{}
  33781. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33782. fmt.Println(dat)
  33783. } else {
  33784. fmt.Println(err)
  33785. }
  33786. saveLog(result2, src_request, "2205", "撤销明细")
  33787. userJSONBytes, _ := json.Marshal(dat)
  33788. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33789. utils.ErrorLog("解析失败:%v", err)
  33790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33791. return
  33792. }
  33793. if res2.Infcode == 0 {
  33794. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33795. if err == nil {
  33796. c.ServeSuccessJSON(map[string]interface{}{
  33797. "msg": "撤销明细成功",
  33798. })
  33799. return
  33800. } else {
  33801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33802. return
  33803. }
  33804. } else {
  33805. c.ServeSuccessJSON(map[string]interface{}{
  33806. "failed_code": -10,
  33807. "msg": res2.ErrMsg,
  33808. })
  33809. }
  33810. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33811. 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, "")
  33812. var dat map[string]interface{}
  33813. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33814. fmt.Println(dat)
  33815. } else {
  33816. fmt.Println(err)
  33817. }
  33818. saveLog(result2, src_request, "2205", "撤销明细")
  33819. userJSONBytes, _ := json.Marshal(dat)
  33820. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33821. utils.ErrorLog("解析失败:%v", err)
  33822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33823. return
  33824. }
  33825. if res2.Infcode == 0 {
  33826. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33827. if err == nil {
  33828. c.ServeSuccessJSON(map[string]interface{}{
  33829. "msg": "撤销明细成功",
  33830. })
  33831. return
  33832. } else {
  33833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33834. return
  33835. }
  33836. } else {
  33837. c.ServeSuccessJSON(map[string]interface{}{
  33838. "failed_code": -10,
  33839. "msg": res2.ErrMsg,
  33840. })
  33841. }
  33842. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33843. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33844. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33845. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33846. resp2, requestErr2 := http.Get(api2)
  33847. if requestErr2 != nil {
  33848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33849. return
  33850. }
  33851. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33852. if ioErr2 != nil {
  33853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33855. return
  33856. }
  33857. var respJSON2 map[string]interface{}
  33858. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33861. return
  33862. }
  33863. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33864. userJSONBytes3, _ := json.Marshal(respJSON2)
  33865. fmt.Println("log")
  33866. fmt.Println(string(userJSONBytes3))
  33867. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33868. utils.ErrorLog("解析失败:%v", err)
  33869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33870. return
  33871. }
  33872. if res2.Infcode == 0 {
  33873. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33874. if err == nil {
  33875. c.ServeSuccessJSON(map[string]interface{}{
  33876. "msg": "撤销明细成功",
  33877. })
  33878. return
  33879. } else {
  33880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33881. return
  33882. }
  33883. } else {
  33884. c.ServeSuccessJSON(map[string]interface{}{
  33885. "failed_code": -10,
  33886. "msg": res2.ErrMsg,
  33887. })
  33888. }
  33889. } else {
  33890. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33891. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33892. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33893. resp2, requestErr2 := http.Get(api2)
  33894. if requestErr2 != nil {
  33895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33896. return
  33897. }
  33898. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33899. if ioErr2 != nil {
  33900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33902. return
  33903. }
  33904. var respJSON2 map[string]interface{}
  33905. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33908. return
  33909. }
  33910. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33911. userJSONBytes3, _ := json.Marshal(respJSON2)
  33912. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33913. utils.ErrorLog("解析失败:%v", err)
  33914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33915. return
  33916. }
  33917. if res2.Infcode == -1 {
  33918. c.ServeSuccessJSON(map[string]interface{}{
  33919. "failed_code": -10,
  33920. "msg": res2.ErrMsg,
  33921. })
  33922. return
  33923. } else {
  33924. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33925. if err == nil {
  33926. c.ServeSuccessJSON(map[string]interface{}{
  33927. "msg": "撤销明细成功",
  33928. })
  33929. return
  33930. } else {
  33931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33932. return
  33933. }
  33934. }
  33935. }
  33936. } else {
  33937. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33938. if err == nil {
  33939. c.ServeSuccessJSON(map[string]interface{}{
  33940. "msg": "退费成功",
  33941. })
  33942. } else {
  33943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33944. return
  33945. }
  33946. }
  33947. }
  33948. // 对账
  33949. func (c *HisApiController) GetCheckAccount() {
  33950. start_time := c.GetString("start_time")
  33951. end_time := c.GetString("end_time")
  33952. insutype := c.GetString("insutype")
  33953. clr_type := c.GetString("clr_type")
  33954. clr_org := c.GetString("clr_optins")
  33955. admin_user_id, _ := c.GetInt64("admin_user_id")
  33956. adminUser := c.GetAdminUserInfo()
  33957. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33958. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33959. if len(clr_org) == 0 {
  33960. clr_org = miConfig.InsuplcAdmdvs
  33961. }
  33962. timeLayout := "2006-01-02"
  33963. loc, _ := time.LoadLocation("Local")
  33964. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33965. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33966. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33967. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33968. fixmedins_setl_cnt := int64(len(orders))
  33969. var medfee_sumamt float64
  33970. var acct_pay float64
  33971. var fund_pay_sumamt float64
  33972. for _, item := range orders {
  33973. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33974. acct_pay = acct_pay + item.AcctPay
  33975. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  33976. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  33977. } else {
  33978. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33979. }
  33980. }
  33981. var user_name string
  33982. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33983. if role.ID == 0 {
  33984. user_name = "xxx"
  33985. } else {
  33986. user_name = role.UserName
  33987. }
  33988. var res ResultEight
  33989. var res10188 ResultEightFor10188
  33990. if config.IsOpen == 1 {
  33991. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33992. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33993. "insutype=" + insutype +
  33994. "&clr_type=" + clr_type +
  33995. "&setl_optins=" + clr_org +
  33996. "&stmt_begndate=" + start_time +
  33997. "&stm_enddate=" + end_time +
  33998. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33999. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34000. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34001. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34002. "&fixmedins_code=" + miConfig.Code +
  34003. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34004. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34005. "&secret_key=" + miConfig.SecretKey +
  34006. "&org_name=" + miConfig.OrgName +
  34007. "&doctor=" + user_name +
  34008. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34009. fmt.Println(api)
  34010. resp, requestErr := http.Get(api)
  34011. if requestErr != nil {
  34012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34013. return
  34014. }
  34015. body, ioErr := ioutil.ReadAll(resp.Body)
  34016. fmt.Println(body)
  34017. if ioErr != nil {
  34018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34020. return
  34021. }
  34022. var respJSON map[string]interface{}
  34023. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34026. return
  34027. }
  34028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34029. userJSONBytes, _ := json.Marshal(respJSON)
  34030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34031. utils.ErrorLog("解析失败:%v", err)
  34032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34033. return
  34034. }
  34035. res.InfRefmsgid = res10188.InfRefmsgid
  34036. res.Output = res10188.Output
  34037. res.ErrMsg = res10188.ErrMsg
  34038. res.Cainfo = res10188.Cainfo
  34039. res.WarnMsg = res10188.WarnMsg
  34040. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  34041. res.Infcode = infocode
  34042. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34043. if clr_type != "9903" {
  34044. clr_type = "99" // 就诊 ID(来自2201接口返回)
  34045. }
  34046. if clr_type == "9903" {
  34047. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  34048. }
  34049. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  34050. "insutype=" + insutype +
  34051. "&clr_type=" + clr_type +
  34052. "&setl_optins=" + clr_org +
  34053. "&stmt_begndate=" + start_time +
  34054. "&stm_enddate=" + end_time +
  34055. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34056. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34057. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34058. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34059. "&fixmedins_code=" + miConfig.Code +
  34060. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34061. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34062. "&secret_key=" + miConfig.SecretKey +
  34063. "&org_name=" + miConfig.OrgName +
  34064. "&doctor=" + user_name
  34065. resp, requestErr := http.Get(api)
  34066. if requestErr != nil {
  34067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34068. return
  34069. }
  34070. body, ioErr := ioutil.ReadAll(resp.Body)
  34071. if ioErr != nil {
  34072. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34074. return
  34075. }
  34076. var respJSON map[string]interface{}
  34077. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34078. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34080. return
  34081. }
  34082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34083. result, _ := json.Marshal(respJSON)
  34084. fmt.Println("log")
  34085. fmt.Println(string(result))
  34086. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  34087. utils.ErrorLog("解析失败:%v", err)
  34088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34089. return
  34090. }
  34091. res.InfRefmsgid = res10188.InfRefmsgid
  34092. res.Output = res10188.Output
  34093. res.ErrMsg = res10188.ErrMsg
  34094. res.Cainfo = res10188.Cainfo
  34095. res.WarnMsg = res10188.WarnMsg
  34096. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  34097. res.Infcode = infocode
  34098. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34099. var baseParams models.BaseParams
  34100. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34101. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34102. baseParams.SecretKey = miConfig.SecretKey
  34103. baseParams.OrgName = miConfig.OrgName
  34104. baseParams.FixmedinsCode = miConfig.Code
  34105. baseParams.EncKey = miConfig.EncKey
  34106. baseParams.AppSecret = miConfig.AppSecret
  34107. baseParams.SignKey = miConfig.SignKey
  34108. baseParams.AppID = miConfig.Code
  34109. baseParams.Doctor = role.UserName
  34110. baseParams.RequestUrl = miConfig.Url
  34111. businessParams := models.BusinessParams{
  34112. Insutype: insutype,
  34113. ClrType: clr_type,
  34114. SetlOptins: clr_org,
  34115. StmtBegndate: start_time,
  34116. StmtEnddate: end_time,
  34117. MedfeeSumamt: medfee_sumamt,
  34118. FundPaySumamt: fund_pay_sumamt,
  34119. AcctPay: acct_pay,
  34120. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34121. }
  34122. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  34123. fmt.Println(requestLog)
  34124. fmt.Println(result)
  34125. fmt.Println(err_msg)
  34126. var dat map[string]interface{}
  34127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34128. fmt.Println(dat)
  34129. } else {
  34130. fmt.Println(err)
  34131. }
  34132. userJSONBytes, _ := json.Marshal(dat)
  34133. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34134. utils.ErrorLog("解析失败:%v", err)
  34135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34136. return
  34137. }
  34138. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34139. var baseParams models.BaseParams
  34140. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34141. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34142. baseParams.SecretKey = miConfig.SecretKey
  34143. baseParams.OrgName = miConfig.OrgName
  34144. baseParams.FixmedinsCode = miConfig.Code
  34145. baseParams.EncKey = miConfig.EncKey
  34146. baseParams.AppSecret = miConfig.AppSecret
  34147. baseParams.SignKey = miConfig.SignKey
  34148. baseParams.AppID = miConfig.Code
  34149. baseParams.Doctor = role.UserName
  34150. baseParams.RequestUrl = miConfig.Url
  34151. baseParams.AccessKey = miConfig.AccessKey
  34152. businessParams := models.BusinessParams{
  34153. Insutype: insutype,
  34154. ClrType: clr_type,
  34155. SetlOptins: "430822",
  34156. StmtBegndate: start_time,
  34157. StmtEnddate: end_time,
  34158. MedfeeSumamt: medfee_sumamt,
  34159. FundPaySumamt: fund_pay_sumamt,
  34160. AcctPay: acct_pay,
  34161. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34162. }
  34163. 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)
  34164. fmt.Println(requestLog)
  34165. fmt.Println(result)
  34166. var dat map[string]interface{}
  34167. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34168. fmt.Println(dat)
  34169. } else {
  34170. fmt.Println(err)
  34171. }
  34172. userJSONBytes, _ := json.Marshal(dat)
  34173. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34174. utils.ErrorLog("解析失败:%v", err)
  34175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34176. return
  34177. }
  34178. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34179. var baseParams models.BaseParams
  34180. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34181. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34182. baseParams.SecretKey = miConfig.SecretKey
  34183. baseParams.OrgName = miConfig.OrgName
  34184. baseParams.FixmedinsCode = miConfig.Code
  34185. baseParams.EncKey = miConfig.EncKey
  34186. baseParams.AppSecret = miConfig.AppSecret
  34187. baseParams.SignKey = miConfig.SignKey
  34188. baseParams.AppID = miConfig.Code
  34189. baseParams.Doctor = role.UserName
  34190. baseParams.RequestUrl = miConfig.Url
  34191. businessParams := models.BusinessParams{
  34192. Insutype: insutype,
  34193. ClrType: clr_type,
  34194. SetlOptins: clr_org,
  34195. StmtBegndate: start_time,
  34196. StmtEnddate: end_time,
  34197. MedfeeSumamt: medfee_sumamt,
  34198. FundPaySumamt: fund_pay_sumamt,
  34199. AcctPay: acct_pay,
  34200. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34201. }
  34202. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  34203. fmt.Println(requestLog)
  34204. fmt.Println(result)
  34205. fmt.Println(err_msg)
  34206. var dat map[string]interface{}
  34207. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34208. fmt.Println(dat)
  34209. } else {
  34210. fmt.Println(err)
  34211. }
  34212. userJSONBytes, _ := json.Marshal(dat)
  34213. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34214. utils.ErrorLog("解析失败:%v", err)
  34215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34216. return
  34217. }
  34218. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34219. if len(clr_type) == 0 {
  34220. clr_type = "11"
  34221. }
  34222. api := miConfig.Url + "gdyb/ten?" +
  34223. "insutype=" + insutype +
  34224. "&clr_type=" + clr_type +
  34225. "&setl_optins=" + clr_org +
  34226. "&stmt_begndate=" + start_time +
  34227. "&stm_enddate=" + end_time +
  34228. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34229. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34230. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34231. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34232. "&fixmedins_code=" + miConfig.Code +
  34233. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34234. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34235. "&secret_key=" + miConfig.SecretKey +
  34236. "&org_name=" + miConfig.OrgName +
  34237. "&doctor=" + user_name
  34238. fmt.Println(api)
  34239. resp, requestErr := http.Get(api)
  34240. if requestErr != nil {
  34241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34242. return
  34243. }
  34244. body, ioErr := ioutil.ReadAll(resp.Body)
  34245. fmt.Println(body)
  34246. if ioErr != nil {
  34247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34249. return
  34250. }
  34251. var respJSON map[string]interface{}
  34252. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34255. return
  34256. }
  34257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34258. userJSONBytes, _ := json.Marshal(respJSON)
  34259. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34260. utils.ErrorLog("解析失败:%v", err)
  34261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34262. return
  34263. }
  34264. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34265. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34266. //fixmedins_setl_cnt := int64(len(orders_two))
  34267. //var medfee_sumamt float64
  34268. //var acct_pay float64
  34269. //var fund_pay_sumamt float64
  34270. //for _, item := range orders_two {
  34271. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34272. // acct_pay = acct_pay + item.AcctPay
  34273. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34274. //}
  34275. var baseParams models.BaseParams
  34276. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34277. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34278. baseParams.SecretKey = miConfig.SecretKey
  34279. baseParams.OrgName = miConfig.OrgName
  34280. baseParams.FixmedinsCode = miConfig.Code
  34281. baseParams.EncKey = miConfig.EncKey
  34282. baseParams.AppSecret = miConfig.AppSecret
  34283. baseParams.SignKey = miConfig.SignKey
  34284. baseParams.AppID = miConfig.Code
  34285. baseParams.Doctor = role.UserName
  34286. baseParams.RequestUrl = miConfig.Url
  34287. if clr_type == "9903" {
  34288. clr_type = "9901"
  34289. }
  34290. businessParams := models.BusinessParams{
  34291. Insutype: insutype,
  34292. ClrType: clr_type,
  34293. SetlOptins: "360302",
  34294. StmtBegndate: start_time,
  34295. StmtEnddate: end_time,
  34296. MedfeeSumamt: 0,
  34297. FundPaySumamt: 0,
  34298. AcctPay: 0,
  34299. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34300. }
  34301. 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))
  34302. fmt.Println(requestLog)
  34303. fmt.Println(result)
  34304. var dat map[string]interface{}
  34305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34306. fmt.Println(dat)
  34307. } else {
  34308. fmt.Println(err)
  34309. }
  34310. userJSONBytes, _ := json.Marshal(dat)
  34311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34312. utils.ErrorLog("解析失败:%v", err)
  34313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34314. return
  34315. }
  34316. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34317. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34318. //fixmedins_setl_cnt := int64(len(orders_two))
  34319. //var medfee_sumamt float64
  34320. //var acct_pay float64
  34321. //var fund_pay_sumamt float64
  34322. //for _, item := range orders_two {
  34323. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34324. // acct_pay = acct_pay + item.AcctPay
  34325. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34326. //}
  34327. var baseParams models.BaseParams
  34328. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34329. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34330. baseParams.SecretKey = miConfig.SecretKey
  34331. baseParams.OrgName = miConfig.OrgName
  34332. baseParams.FixmedinsCode = miConfig.Code
  34333. baseParams.EncKey = miConfig.EncKey
  34334. baseParams.AppSecret = miConfig.AppSecret
  34335. baseParams.SignKey = miConfig.SignKey
  34336. baseParams.AppID = miConfig.Code
  34337. baseParams.Doctor = role.UserName
  34338. baseParams.RequestUrl = miConfig.Url
  34339. if clr_type == "9903" {
  34340. clr_type = "9994"
  34341. }
  34342. businessParams := models.BusinessParams{
  34343. Insutype: insutype,
  34344. ClrType: clr_type,
  34345. SetlOptins: "361025",
  34346. StmtBegndate: start_time,
  34347. StmtEnddate: end_time,
  34348. MedfeeSumamt: 0,
  34349. FundPaySumamt: 0,
  34350. AcctPay: 0,
  34351. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34352. }
  34353. 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))
  34354. fmt.Println(requestLog)
  34355. fmt.Println(result)
  34356. var dat map[string]interface{}
  34357. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34358. fmt.Println(dat)
  34359. } else {
  34360. fmt.Println(err)
  34361. }
  34362. userJSONBytes, _ := json.Marshal(dat)
  34363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34364. utils.ErrorLog("解析失败:%v", err)
  34365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34366. return
  34367. }
  34368. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34369. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34370. //fixmedins_setl_cnt := int64(len(orders_two))
  34371. //var medfee_sumamt float64
  34372. //var acct_pay float64
  34373. //var fund_pay_sumamt float64
  34374. //for _, item := range orders_two {
  34375. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34376. // acct_pay = acct_pay + item.AcctPay
  34377. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34378. //}
  34379. var baseParams models.BaseParams
  34380. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34381. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34382. baseParams.SecretKey = miConfig.SecretKey
  34383. baseParams.OrgName = miConfig.OrgName
  34384. baseParams.FixmedinsCode = miConfig.Code
  34385. baseParams.EncKey = miConfig.EncKey
  34386. baseParams.AppSecret = miConfig.AppSecret
  34387. baseParams.SignKey = miConfig.SignKey
  34388. baseParams.AppID = miConfig.Code
  34389. baseParams.Doctor = role.UserName
  34390. baseParams.RequestUrl = miConfig.Url
  34391. if clr_type == "9903" {
  34392. clr_type = "9994"
  34393. }
  34394. businessParams := models.BusinessParams{
  34395. Insutype: insutype,
  34396. ClrType: clr_type,
  34397. SetlOptins: "360100",
  34398. StmtBegndate: start_time,
  34399. StmtEnddate: end_time,
  34400. MedfeeSumamt: 0,
  34401. FundPaySumamt: 0,
  34402. AcctPay: 0,
  34403. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34404. }
  34405. 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))
  34406. fmt.Println(requestLog)
  34407. fmt.Println(result)
  34408. var dat map[string]interface{}
  34409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34410. fmt.Println(dat)
  34411. } else {
  34412. fmt.Println(err)
  34413. }
  34414. userJSONBytes, _ := json.Marshal(dat)
  34415. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34416. utils.ErrorLog("解析失败:%v", err)
  34417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34418. return
  34419. }
  34420. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34421. var api string
  34422. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  34423. "&clr_type=" + clr_type +
  34424. "&setl_optins=" + clr_org +
  34425. "&stmt_begndate=" + start_time +
  34426. "&stm_enddate=" + end_time +
  34427. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34428. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34429. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34430. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34431. "&fixmedins_code=" + miConfig.Code +
  34432. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34433. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34434. "&secret_key=" + miConfig.SecretKey +
  34435. "&org_name=" + miConfig.OrgName +
  34436. "&doctor=" + user_name + "&url=" + miConfig.Url
  34437. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34438. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34439. resp, requestErr := http.Get(api)
  34440. if requestErr != nil {
  34441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34442. return
  34443. }
  34444. body, ioErr := ioutil.ReadAll(resp.Body)
  34445. if ioErr != nil {
  34446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34448. return
  34449. }
  34450. var respJSON map[string]interface{}
  34451. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34454. return
  34455. }
  34456. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34457. if status == "0" {
  34458. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34459. c.ServeSuccessJSON(map[string]interface{}{
  34460. "failed_code": -10,
  34461. "msg": err_msg,
  34462. })
  34463. return
  34464. }
  34465. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34466. userJSONBytes, _ := json.Marshal(respJSON)
  34467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34468. utils.ErrorLog("解析失败:%v", err)
  34469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34470. return
  34471. }
  34472. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34473. var api string
  34474. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  34475. "&clr_type=" + clr_type +
  34476. "&setl_optins=" + clr_org +
  34477. "&stmt_begndate=" + start_time +
  34478. "&stm_enddate=" + end_time +
  34479. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34480. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34481. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34482. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34483. "&fixmedins_code=" + miConfig.Code +
  34484. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34485. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34486. "&secret_key=" + miConfig.SecretKey +
  34487. "&org_name=" + miConfig.OrgName +
  34488. "&doctor=" + user_name + "&url=" + miConfig.Url
  34489. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34490. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34491. resp, requestErr := http.Get(api)
  34492. if requestErr != nil {
  34493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34494. return
  34495. }
  34496. body, ioErr := ioutil.ReadAll(resp.Body)
  34497. if ioErr != nil {
  34498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34500. return
  34501. }
  34502. var respJSON map[string]interface{}
  34503. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34506. return
  34507. }
  34508. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34509. if status == "0" {
  34510. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34511. c.ServeSuccessJSON(map[string]interface{}{
  34512. "failed_code": -10,
  34513. "msg": err_msg,
  34514. })
  34515. return
  34516. }
  34517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34518. userJSONBytes, _ := json.Marshal(respJSON)
  34519. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34520. utils.ErrorLog("解析失败:%v", err)
  34521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34522. return
  34523. }
  34524. } else {
  34525. if len(clr_type) == 0 {
  34526. clr_type = "11"
  34527. }
  34528. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34529. "insutype=" + insutype +
  34530. "&clr_type=" + clr_type +
  34531. "&setl_optins=" + clr_org +
  34532. "&stmt_begndate=" + start_time +
  34533. "&stm_enddate=" + end_time +
  34534. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34535. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34536. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34537. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34538. "&fixmedins_code=" + miConfig.Code +
  34539. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34540. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34541. "&secret_key=" + miConfig.SecretKey +
  34542. "&org_name=" + miConfig.OrgName +
  34543. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34544. fmt.Println(api)
  34545. resp, requestErr := http.Get(api)
  34546. if requestErr != nil {
  34547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34548. return
  34549. }
  34550. body, ioErr := ioutil.ReadAll(resp.Body)
  34551. fmt.Println(body)
  34552. if ioErr != nil {
  34553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34555. return
  34556. }
  34557. var respJSON map[string]interface{}
  34558. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34561. return
  34562. }
  34563. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34564. userJSONBytes, _ := json.Marshal(respJSON)
  34565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34566. utils.ErrorLog("解析失败:%v", err)
  34567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34568. return
  34569. }
  34570. }
  34571. if res.Infcode == 0 {
  34572. if res.Output.Stmtinfo.StmtRslt == "0" {
  34573. micc := &models.MedicalInsuranceCostCompare{
  34574. StartTime: startime.Unix(),
  34575. EndTime: endtime.Unix(),
  34576. Insutype: insutype,
  34577. CheckType: 1,
  34578. Num: fixmedins_setl_cnt,
  34579. Mtime: time.Now().Unix(),
  34580. Status: 1,
  34581. UserOrgId: adminUser.CurrentOrgId,
  34582. CostTotal: medfee_sumamt,
  34583. FuncTotal: fund_pay_sumamt,
  34584. PsnPay: acct_pay,
  34585. Creator: admin_user_id,
  34586. Ctime: time.Now().Unix(),
  34587. ClrType: clr_type,
  34588. }
  34589. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  34590. if err == nil {
  34591. c.ServeSuccessJSON(map[string]interface{}{
  34592. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  34593. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  34594. })
  34595. } else {
  34596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34597. }
  34598. } else {
  34599. c.ServeSuccessJSON(map[string]interface{}{
  34600. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  34601. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  34602. })
  34603. }
  34604. } else {
  34605. c.ServeSuccessJSON(map[string]interface{}{
  34606. "failed_code": -10,
  34607. "msg": res.ErrMsg,
  34608. })
  34609. }
  34610. }
  34611. }
  34612. func (c *HisApiController) Check310() {
  34613. adminUser := c.GetAdminUserInfo()
  34614. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34615. var user_name string
  34616. user_name = "高慧裕"
  34617. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34618. "insutype=" + "310" +
  34619. "&clr_type=" + "" +
  34620. "&setl_optins=" + "441202" +
  34621. "&stmt_begndate=" + "2022-03-01" +
  34622. "&stm_enddate=" + "2022-03-31" +
  34623. "&medfee_sumamt=" + "194930.12" +
  34624. "&fund_pay_sumamt=" + "188741.46" +
  34625. "&acct_pay=" + "0" +
  34626. "&fixmedins_setl_cnt=" + "452" +
  34627. "&fixmedins_code=" + miConfig.Code +
  34628. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34629. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34630. "&secret_key=" + miConfig.SecretKey +
  34631. "&org_name=" + miConfig.OrgName +
  34632. "&doctor=" + user_name
  34633. fmt.Println(api)
  34634. resp, requestErr := http.Get(api)
  34635. if requestErr != nil {
  34636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34637. return
  34638. }
  34639. body, ioErr := ioutil.ReadAll(resp.Body)
  34640. fmt.Println(body)
  34641. if ioErr != nil {
  34642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34644. return
  34645. }
  34646. var respJSON map[string]interface{}
  34647. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34650. return
  34651. }
  34652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34653. userJSONBytes, _ := json.Marshal(respJSON)
  34654. var res ResultEight
  34655. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34656. utils.ErrorLog("解析失败:%v", err)
  34657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34658. return
  34659. }
  34660. }
  34661. func (c *HisApiController) Check390() {
  34662. adminUser := c.GetAdminUserInfo()
  34663. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34664. var user_name string
  34665. user_name = "高慧裕"
  34666. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  34667. "insutype=" + "390" +
  34668. "&clr_type=" + "" +
  34669. "&setl_optins=" + "441202" +
  34670. "&stmt_begndate=" + "2022-03-01" +
  34671. "&stm_enddate=" + "2022-03-31" +
  34672. "&medfee_sumamt=" + "1068448.89" +
  34673. "&fund_pay_sumamt=" + "1014677.62" +
  34674. "&acct_pay=" + "0" +
  34675. "&fixmedins_setl_cnt=" + "1950" +
  34676. "&fixmedins_code=" + miConfig.Code +
  34677. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34678. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34679. "&secret_key=" + miConfig.SecretKey +
  34680. "&org_name=" + miConfig.OrgName +
  34681. "&doctor=" + user_name
  34682. fmt.Println(api)
  34683. resp, requestErr := http.Get(api)
  34684. if requestErr != nil {
  34685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34686. return
  34687. }
  34688. body, ioErr := ioutil.ReadAll(resp.Body)
  34689. fmt.Println(body)
  34690. if ioErr != nil {
  34691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34693. return
  34694. }
  34695. var respJSON map[string]interface{}
  34696. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34699. return
  34700. }
  34701. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34702. userJSONBytes, _ := json.Marshal(respJSON)
  34703. var res ResultEight
  34704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34705. utils.ErrorLog("解析失败:%v", err)
  34706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34707. return
  34708. }
  34709. }
  34710. // 对账明细
  34711. func (c *HisApiController) GetCheckDetailAccount() {
  34712. start_time := c.GetString("start_time")
  34713. end_time := c.GetString("end_time")
  34714. admin_user_id, _ := c.GetInt64("admin_user_id")
  34715. adminUser := c.GetAdminUserInfo()
  34716. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34717. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34718. timeLayout := "2006-01-02"
  34719. loc, _ := time.LoadLocation("Local")
  34720. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34721. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34722. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34723. rand.Seed(time.Now().UnixNano())
  34724. num := rand.Intn(30000)
  34725. Mkdir(miConfig.OrgName)
  34726. file := strconv.FormatInt(int64(num), 10)
  34727. file_name := file + ".txt"
  34728. zip_name := file + ".zip"
  34729. zip_path := miConfig.OrgName + "/" + zip_name
  34730. file_path := miConfig.OrgName + "/" + file_name
  34731. decimal.DivisionPrecision = 2
  34732. var medfee_sumamt float64
  34733. var psn_cash_pay float64
  34734. var fund_pay_sumamt float64
  34735. fixmedins_setl_cnt := int64(len(orders))
  34736. for _, item := range orders {
  34737. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34738. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  34739. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34740. }
  34741. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  34742. defer f.Close()
  34743. if err != nil {
  34744. fmt.Println(err.Error())
  34745. } else {
  34746. for _, item := range orders {
  34747. var refd_setl_flag string
  34748. if item.OrderStatus == 2 {
  34749. refd_setl_flag = "0"
  34750. var str string
  34751. str = item.SetlId + " " +
  34752. item.MdtrtId + " " +
  34753. item.PsnNo + " " +
  34754. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34755. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34756. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  34757. _, err = f.Write([]byte(str))
  34758. }
  34759. if item.OrderStatus == 3 {
  34760. var str string
  34761. str = item.SetlId + " " +
  34762. item.MdtrtId + " " +
  34763. item.PsnNo + " " +
  34764. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34765. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34766. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  34767. _, err = f.Write([]byte(str))
  34768. var str2 string
  34769. str2 = item.SetlId + " " +
  34770. item.MdtrtId + " " +
  34771. item.PsnNo + " " +
  34772. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  34773. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  34774. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  34775. _, err = f.Write([]byte(str2))
  34776. }
  34777. }
  34778. }
  34779. Zip(file_path, zip_path)
  34780. fmt.Println(ReadFile(zip_path))
  34781. fmt.Println(string(ReadFile(zip_path)))
  34782. if config.IsOpen == 1 {
  34783. var user_name string
  34784. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34785. if role.ID == 0 {
  34786. user_name = "管理员"
  34787. } else {
  34788. user_name = role.UserName
  34789. }
  34790. baseParams := models.BaseParams{
  34791. SecretKey: miConfig.SecretKey,
  34792. FixmedinsCode: miConfig.Code,
  34793. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34794. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34795. OrgName: miConfig.OrgName,
  34796. Doctor: user_name,
  34797. }
  34798. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  34799. var dat map[string]interface{}
  34800. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34801. fmt.Println(dat)
  34802. } else {
  34803. fmt.Println(err)
  34804. }
  34805. userJSONBytes, _ := json.Marshal(dat)
  34806. var res ResultNine
  34807. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34808. utils.ErrorLog("解析失败:%v", err)
  34809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34810. return
  34811. }
  34812. if res.Infcode == 0 {
  34813. fileNo := res.Output.FileQuryNo
  34814. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34815. "file_qury_no=" + fileNo +
  34816. "&setl_optins=" + "定点医保中心" +
  34817. "&stmt_begndate=" + start_time +
  34818. "&stm_enddate=" + end_time +
  34819. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34820. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34821. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34822. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34823. "&fixmedins_code=" + miConfig.Code +
  34824. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34825. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34826. "&secret_key=" + miConfig.SecretKey +
  34827. "&org_name=" + miConfig.OrgName +
  34828. "&doctor=" + user_name
  34829. resp, requestErr := http.Get(api)
  34830. if requestErr != nil {
  34831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34832. return
  34833. }
  34834. body, ioErr := ioutil.ReadAll(resp.Body)
  34835. if ioErr != nil {
  34836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34838. return
  34839. }
  34840. var respJSON map[string]interface{}
  34841. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34844. return
  34845. }
  34846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34847. userJSONBytes, _ := json.Marshal(respJSON)
  34848. var res ResultTen
  34849. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34850. utils.ErrorLog("解析失败:%v", err)
  34851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34852. return
  34853. }
  34854. if res.Infcode == 0 {
  34855. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34856. micc := &models.MedicalInsuranceCostCompare{
  34857. StartTime: startime.Unix(),
  34858. EndTime: endtime.Unix(),
  34859. Insutype: "0",
  34860. CheckType: 2,
  34861. Num: fixmedins_setl_cnt,
  34862. Mtime: time.Now().Unix(),
  34863. Status: 1,
  34864. UserOrgId: adminUser.CurrentOrgId,
  34865. CostTotal: medfee_sumamt,
  34866. FuncTotal: fund_pay_sumamt,
  34867. PsnPay: psn_cash_pay,
  34868. Creator: admin_user_id,
  34869. Ctime: time.Now().Unix(),
  34870. }
  34871. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34872. c.ServeSuccessJSON(map[string]interface{}{
  34873. "msg": "明细对账成功",
  34874. })
  34875. }
  34876. } else {
  34877. }
  34878. }
  34879. }
  34880. type CustomOrderInfo struct {
  34881. Name string
  34882. Spec string
  34883. Unit string
  34884. Count float64
  34885. Price float64
  34886. Total float64
  34887. }
  34888. func (c *HisApiController) GetBatchSettleAccounts() {
  34889. admin_user_id, _ := c.GetInt64("admin_user_id")
  34890. order_ids := c.GetString("order_ids")
  34891. order_ids_arr := strings.Split(order_ids, ",")
  34892. data3 := []map[string]interface{}{}
  34893. for _, item := range order_ids_arr {
  34894. id, _ := strconv.ParseInt(item, 10, 64)
  34895. order_id := id
  34896. adminUser := c.GetAdminUserInfo()
  34897. order, _ := service.GetHisOrderByID(order_id)
  34898. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34899. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34900. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34901. orderInfos = append(orderInfos, orderInfos_two...)
  34902. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34903. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34904. var diagnosis_ids []string
  34905. if his.ID > 0 {
  34906. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34907. } else {
  34908. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34909. }
  34910. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34911. var dia_config []*models.HisXtDiagnoseConfig
  34912. var name string
  34913. for _, item := range diagnosis_ids {
  34914. id, _ := strconv.ParseInt(item, 10, 64)
  34915. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34916. dia_config = append(dia_config, &diagnosisConfig)
  34917. if len(name) == 0 {
  34918. name = diagnosisConfig.ClassName
  34919. }
  34920. //} else {
  34921. // name = name + "," + diagnosisConfig.ClassName
  34922. //}
  34923. }
  34924. var bedCostTotal float64 = 0 //床位总费
  34925. var bedCostSelfTotal float64 = 0 //床位自费
  34926. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34927. var bedSelfTotal float64 = 0 //床位部分项目自费
  34928. var bedInscpTotal float64 = 0 //床位部分项目自费
  34929. var operationCostTotal float64 = 0 //手术费
  34930. var operationCostSelfTotal float64 = 0 //手术费
  34931. var operationCostPartSelfTotal float64 = 0 //手术费
  34932. var operationSelfTotal float64 = 0 //床位部分项目自费
  34933. var operationInscpTotal float64 = 0 //床位部分项目自费
  34934. var otherCostTotal float64 = 0 //其他费用
  34935. var otherCostSelfTotal float64 = 0 //其他费用
  34936. var otherCostPartSelfTotal float64 = 0 //其他费用
  34937. var otherSelfTotal float64 = 0 //床位部分项目自费
  34938. var otherInscpTotal float64 = 0 //床位部分项目自费
  34939. var materialCostTotal float64 = 0 //材料费
  34940. var materialCostSelfTotal float64 = 0 //材料费
  34941. var materialCostPartSelfTotal float64 = 0 //材料费
  34942. var materialSelfTotal float64 = 0 //床位部分项目自费
  34943. var materialInscpTotal float64 = 0 //床位部分项目自费
  34944. var westernMedicineCostTotal float64 = 0 //西药费
  34945. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34946. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34947. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34948. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34949. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34950. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34951. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34952. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34953. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34954. var checkCostTotal float64 = 0 //检查费
  34955. var checkCostSelfTotal float64 = 0 //检查费
  34956. var checkCostPartSelfTotal float64 = 0 //检查费
  34957. var checkSelfTotal float64 = 0 //床位部分项目自费
  34958. var checkInscpTotal float64 = 0 //床位部分项目自费
  34959. var laboratoryCostTotal float64 = 0 //化验费
  34960. var laboratoryCostSelfTotal float64 = 0 //化验费
  34961. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34962. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34963. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34964. var treatCostTotal float64 = 0 //治疗费用
  34965. var treatCostSelfTotal float64 = 0 //治疗费用
  34966. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34967. var treatSelfTotal float64 = 0 //床位部分项目自费
  34968. var treatInscpTotal float64 = 0 //床位部分项目自费
  34969. decimal.DivisionPrecision = 2
  34970. for _, item := range orderInfos {
  34971. if item.MedChrgitmType == "01" { //床位费
  34972. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34973. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34974. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34975. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34976. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34977. }
  34978. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34979. if item.MedChrgitmType == "03" { //检查费
  34980. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34981. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34982. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34983. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34984. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34985. }
  34986. } else {
  34987. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34988. fmt.Println("------------")
  34989. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34990. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34991. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34992. }
  34993. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34994. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34995. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34996. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34997. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34998. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34999. }
  35000. }
  35001. if item.MedChrgitmType == "04" { //化验费
  35002. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35003. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35004. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35005. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35006. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35007. }
  35008. if item.MedChrgitmType == "05" { //治疗费
  35009. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35010. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35011. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35012. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35013. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35014. }
  35015. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  35016. fmt.Println("------------")
  35017. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35018. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35019. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35020. }
  35021. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  35022. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35023. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35024. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35025. }
  35026. //if item.MedChrgitmType == "06" { //手术费
  35027. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35028. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35029. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35030. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35031. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35032. //
  35033. //}
  35034. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  35035. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35036. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35037. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35038. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35039. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35040. }
  35041. if item.MedChrgitmType == "09" { //西药费
  35042. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35043. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35044. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35045. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35046. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35047. }
  35048. if item.MedChrgitmType == "11" { //中成费
  35049. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35050. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35051. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35052. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35053. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35054. }
  35055. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  35056. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35057. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35058. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35059. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35060. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35061. }
  35062. }
  35063. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35064. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35065. var user_name string
  35066. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35067. if role.ID == 0 {
  35068. user_name = "管理员"
  35069. } else {
  35070. user_name = role.UserName
  35071. }
  35072. baseParams := models.BaseParams{
  35073. SecretKey: miConfig.SecretKey,
  35074. FixmedinsCode: miConfig.Code,
  35075. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35076. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35077. OrgName: miConfig.OrgName,
  35078. Doctor: user_name,
  35079. RequestUrl: miConfig.Url,
  35080. AccessKey: miConfig.AccessKey,
  35081. }
  35082. businessParams := models.BusinessParams{
  35083. PsnNo: order.PsnNo,
  35084. MdtrtId: order.MdtrtId,
  35085. SetlId: order.SetlId,
  35086. }
  35087. var res ResultEleven
  35088. var resEleven10265 ResultEleven10265
  35089. if config.IsOpen == 1 {
  35090. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35091. result := service.Gdyb5203(baseParams, businessParams)
  35092. service.Gdyb5204(baseParams, businessParams)
  35093. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35094. var dat map[string]interface{}
  35095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35096. fmt.Println(dat)
  35097. } else {
  35098. fmt.Println(err)
  35099. }
  35100. userJSONBytes, _ := json.Marshal(dat)
  35101. if miConfig.Code == "H15049901371" {
  35102. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35103. utils.ErrorLog("解析失败:%v", err)
  35104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35105. return
  35106. }
  35107. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35108. res.Output = resEleven10265.Output
  35109. res.ErrMsg = resEleven10265.ErrMsg
  35110. res.Cainfo = resEleven10265.Cainfo
  35111. res.WarnMsg = resEleven10265.WarnMsg
  35112. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35113. res.Infcode = infocode
  35114. } else {
  35115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35116. utils.ErrorLog("解析失败:%v", err)
  35117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35118. return
  35119. }
  35120. }
  35121. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35122. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35123. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35124. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35125. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35126. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35127. var doctor_name string
  35128. if roles.ID == 0 {
  35129. doctor_name = "管理员"
  35130. } else {
  35131. doctor_name = roles.UserName
  35132. }
  35133. yiliao_leibie := ""
  35134. switch order.MedType {
  35135. case "11":
  35136. yiliao_leibie = "普通门诊"
  35137. break
  35138. case "12":
  35139. yiliao_leibie = "门诊挂号"
  35140. break
  35141. case "13":
  35142. yiliao_leibie = "急诊"
  35143. break
  35144. case "14":
  35145. yiliao_leibie = "门诊特殊病"
  35146. break
  35147. case "15":
  35148. yiliao_leibie = "门诊统筹"
  35149. break
  35150. case "16":
  35151. yiliao_leibie = "门诊慢性病"
  35152. break
  35153. case "21":
  35154. yiliao_leibie = "普通住院"
  35155. break
  35156. }
  35157. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35158. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  35159. if res.Infcode == 0 {
  35160. data2 := map[string]interface{}{
  35161. "diagnosis": name,
  35162. "order_infos": orderInfos,
  35163. "number": order.MdtrtId,
  35164. "date": order.SettleAccountsDate,
  35165. "charge_admin": charge_admin,
  35166. "printor_admin": printor_admin,
  35167. "info": res.Output.Setlinfo,
  35168. "order": order,
  35169. "bedCostTotal": bedCostTotal,
  35170. "bedCostSelfTotal": bedCostSelfTotal,
  35171. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35172. "bedSelfTotal": bedSelfTotal,
  35173. "bedInscpTotal": bedInscpTotal,
  35174. "operationCostTotal": operationCostTotal,
  35175. "operationCostSelfTotal": operationCostSelfTotal,
  35176. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35177. "operationSelfTotal": operationSelfTotal,
  35178. "operationInscpTotal": operationInscpTotal,
  35179. "otherCostTotal": otherCostTotal,
  35180. "otherCostSelfTotal": otherCostSelfTotal,
  35181. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35182. "otherSelfTotal": otherSelfTotal,
  35183. "otherInscpTotal": otherInscpTotal,
  35184. "materialCostTotal": materialCostTotal,
  35185. "materialCostSelfTotal": materialCostSelfTotal,
  35186. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35187. "materialSelfTotal": materialSelfTotal,
  35188. "materialInscpTotal": materialInscpTotal,
  35189. "westernMedicineCostTotal": westernMedicineCostTotal,
  35190. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35191. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35192. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35193. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35194. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35195. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35196. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35197. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35198. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35199. "checkCostTotal": checkCostTotal,
  35200. "checkCostSelfTotal": checkCostSelfTotal,
  35201. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35202. "checkSelfTotal": checkSelfTotal,
  35203. "checkInscpTotal": checkInscpTotal,
  35204. "laboratoryCostTotal": laboratoryCostTotal,
  35205. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35206. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35207. "laboratorySelfTotal": laboratorySelfTotal,
  35208. "laboratoryInscpTotal": laboratoryInscpTotal,
  35209. "treatCostTotal": treatCostTotal,
  35210. "treatCostSelfTotal": treatCostSelfTotal,
  35211. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35212. "treatSelfTotal": treatSelfTotal,
  35213. "treatInscpTotal": treatInscpTotal,
  35214. "doctor_info": doctor_info,
  35215. "doctor_code": adminRole_two.DoctorCode,
  35216. "doctor_name": doctor_name,
  35217. "health_card_no": order.PsnNo,
  35218. "department": departments.Name,
  35219. "yiliao_leibie": yiliao_leibie,
  35220. "after_money": order.AccountPrice,
  35221. "patient": patient,
  35222. "org_name": miConfig.OrgName,
  35223. "org_code": miConfig.Code,
  35224. "order_number": order.Number,
  35225. "his_hospital": his_hospital,
  35226. "his": his,
  35227. "dia_config": dia_config,
  35228. "psn_cash_pay": order.PsnCashPay,
  35229. //"check_order_info": cus_slice,
  35230. }
  35231. data3 = append(data3, data2)
  35232. }
  35233. }
  35234. }
  35235. c.ServeSuccessJSON(map[string]interface{}{
  35236. "infos": data3,
  35237. })
  35238. }
  35239. func (c *HisApiController) GetSettleAccounts() {
  35240. //id, _ := c.GetInt64("id")
  35241. //record_time := c.GetString("record_time")
  35242. order_id, _ := c.GetInt64("order_id")
  35243. admin_user_id, _ := c.GetInt64("admin_user_id")
  35244. //timeLayout := "2006-01-02"
  35245. //loc, _ := time.LoadLocation("Local")
  35246. //
  35247. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35248. //if err != nil {
  35249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35250. // return
  35251. //}Hbyb5203
  35252. //recordDateTime := theTime.Unix()
  35253. adminUser := c.GetAdminUserInfo()
  35254. order, _ := service.GetHisOrderByID(order_id)
  35255. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35256. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  35257. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  35258. orderInfos = append(orderInfos, orderInfos_two...)
  35259. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  35260. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  35261. var diagnosis_ids []string
  35262. if his.ID > 0 {
  35263. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  35264. } else {
  35265. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  35266. }
  35267. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  35268. var dia_config []*models.HisXtDiagnoseConfig
  35269. var name string
  35270. for _, item := range diagnosis_ids {
  35271. id, _ := strconv.ParseInt(item, 10, 64)
  35272. diagnosisConfig, _ := service.FindDiagnoseById(id)
  35273. dia_config = append(dia_config, &diagnosisConfig)
  35274. if len(name) == 0 {
  35275. name = diagnosisConfig.ClassName
  35276. } else {
  35277. name = name + "," + diagnosisConfig.ClassName
  35278. }
  35279. }
  35280. if patient.UserOrgId == 10215 {
  35281. name = "慢性肾功能不全(血透治疗)"
  35282. }
  35283. var bedCostTotal float64 = 0 //床位总费
  35284. var bedCostSelfTotal float64 = 0 //床位自费
  35285. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  35286. var bedSelfTotal float64 = 0 //床位部分项目自费
  35287. var bedInscpTotal float64 = 0 //床位部分项目自费
  35288. var operationCostTotal float64 = 0 //手术费
  35289. var operationCostSelfTotal float64 = 0 //手术费
  35290. var operationCostPartSelfTotal float64 = 0 //手术费
  35291. var operationSelfTotal float64 = 0 //床位部分项目自费
  35292. var operationInscpTotal float64 = 0 //床位部分项目自费
  35293. var otherCostTotal float64 = 0 //其他费用
  35294. var otherCostSelfTotal float64 = 0 //其他费用
  35295. var otherCostPartSelfTotal float64 = 0 //其他费用
  35296. var otherSelfTotal float64 = 0 //床位部分项目自费
  35297. var otherInscpTotal float64 = 0 //床位部分项目自费
  35298. var materialCostTotal float64 = 0 //材料费
  35299. var materialCostSelfTotal float64 = 0 //材料费
  35300. var materialCostPartSelfTotal float64 = 0 //材料费
  35301. var materialSelfTotal float64 = 0 //床位部分项目自费
  35302. var materialInscpTotal float64 = 0 //床位部分项目自费
  35303. var westernMedicineCostTotal float64 = 0 //西药费
  35304. var westernMedicineCostSelfTotal float64 = 0 //西药费
  35305. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  35306. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  35307. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  35308. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  35309. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  35310. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  35311. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  35312. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  35313. var checkCostTotal float64 = 0 //检查费
  35314. var checkCostSelfTotal float64 = 0 //检查费
  35315. var checkCostPartSelfTotal float64 = 0 //检查费
  35316. var checkSelfTotal float64 = 0 //床位部分项目自费
  35317. var checkInscpTotal float64 = 0 //床位部分项目自费
  35318. var laboratoryCostTotal float64 = 0 //化验费
  35319. var laboratoryCostSelfTotal float64 = 0 //化验费
  35320. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  35321. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  35322. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  35323. var treatCostTotal float64 = 0 //治疗费用
  35324. var treatCostSelfTotal float64 = 0 //治疗费用
  35325. var treatCostPartSelfTotal float64 = 0 //治疗费用
  35326. var treatSelfTotal float64 = 0 //床位部分项目自费
  35327. var treatInscpTotal float64 = 0 //床位部分项目自费
  35328. var zcCostTotal float64 = 0 //治疗费用
  35329. var zcCostSelfTotal float64 = 0 //治疗费用
  35330. var zcCostPartSelfTotal float64 = 0 //治疗费用
  35331. var zcSelfTotal float64 = 0 //床位部分项目自费
  35332. var zcInscpTotal float64 = 0 //床位部分项目自费
  35333. var huliCostTotal float64 = 0 //治疗费用
  35334. var huliCostSelfTotal float64 = 0 //治疗费用
  35335. var huliCostPartSelfTotal float64 = 0 //治疗费用
  35336. var huliSelfTotal float64 = 0 //床位部分项目自费
  35337. var huliInscpTotal float64 = 0 //床位部分项目自费
  35338. decimal.DivisionPrecision = 2
  35339. for _, item := range orderInfos {
  35340. if item.MedChrgitmType == "01" { //床位费
  35341. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35342. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35343. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35344. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35345. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35346. }
  35347. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  35348. if item.MedChrgitmType == "03" { //检查费
  35349. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35350. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35351. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35352. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35353. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35354. }
  35355. } else {
  35356. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  35357. fmt.Println("------------")
  35358. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35359. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35360. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35361. }
  35362. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  35363. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35364. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35365. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35366. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35367. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35368. }
  35369. }
  35370. if item.MedChrgitmType == "04" { //化验费
  35371. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35372. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35373. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35374. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35375. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35376. }
  35377. if item.MedChrgitmType == "05" { //治疗费
  35378. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35379. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35380. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35381. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35382. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35383. }
  35384. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  35385. fmt.Println("------------")
  35386. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35387. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35388. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35389. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35390. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35391. }
  35392. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  35393. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35394. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35395. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35396. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35397. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35398. }
  35399. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  35400. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35401. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35402. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35403. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35404. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35405. }
  35406. if item.MedChrgitmType == "09" { //西药费
  35407. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35408. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35409. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35410. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35411. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35412. }
  35413. if item.MedChrgitmType == "11" { //中成费
  35414. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35415. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35416. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35417. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35418. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35419. }
  35420. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  35421. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35422. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35423. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35424. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35425. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35426. }
  35427. if item.MedChrgitmType == "02" { //其他费
  35428. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35429. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35430. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35431. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35432. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35433. }
  35434. if item.MedChrgitmType == "07" { //其他费
  35435. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35436. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35437. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35438. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35439. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35440. }
  35441. }
  35442. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35443. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35444. var user_name string
  35445. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35446. if role.ID == 0 {
  35447. user_name = "管理员"
  35448. } else {
  35449. user_name = role.UserName
  35450. }
  35451. baseParams := models.BaseParams{
  35452. SecretKey: miConfig.SecretKey,
  35453. FixmedinsCode: miConfig.Code,
  35454. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35455. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35456. OrgName: miConfig.OrgName,
  35457. Doctor: user_name,
  35458. RequestUrl: miConfig.Url,
  35459. AccessKey: miConfig.AccessKey,
  35460. }
  35461. businessParams := models.BusinessParams{
  35462. PsnNo: order.PsnNo,
  35463. MdtrtId: order.MdtrtId,
  35464. SetlId: order.SetlId,
  35465. }
  35466. var res ResultEleven
  35467. var resah ResultElevenah
  35468. var resEleven10265 ResultEleven10265
  35469. if config.IsOpen == 1 {
  35470. if miConfig.MdtrtareaAdmvs == "421300" {
  35471. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35472. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35473. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35474. resp, requestErr := http.Get(api)
  35475. if requestErr != nil {
  35476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35477. return
  35478. }
  35479. body, ioErr := ioutil.ReadAll(resp.Body)
  35480. if ioErr != nil {
  35481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35483. return
  35484. }
  35485. var respJSON map[string]interface{}
  35486. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35489. return
  35490. }
  35491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35492. result, _ := json.Marshal(respJSON)
  35493. fmt.Println("log")
  35494. fmt.Println(string(result))
  35495. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35496. utils.ErrorLog("解析失败:%v", err)
  35497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35498. return
  35499. }
  35500. } else if miConfig.MdtrtareaAdmvs == "420200" {
  35501. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35502. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35503. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35504. resp, requestErr := http.Get(api)
  35505. if requestErr != nil {
  35506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35507. return
  35508. }
  35509. body, ioErr := ioutil.ReadAll(resp.Body)
  35510. if ioErr != nil {
  35511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35513. return
  35514. }
  35515. var respJSON map[string]interface{}
  35516. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35519. return
  35520. }
  35521. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35522. result, _ := json.Marshal(respJSON)
  35523. fmt.Println("log")
  35524. fmt.Println(string(result))
  35525. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35526. utils.ErrorLog("解析失败:%v", err)
  35527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35528. return
  35529. }
  35530. } else if miConfig.MdtrtareaAdmvs == "420902" {
  35531. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35532. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35533. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35534. resp, requestErr := http.Get(api)
  35535. if requestErr != nil {
  35536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35537. return
  35538. }
  35539. body, ioErr := ioutil.ReadAll(resp.Body)
  35540. if ioErr != nil {
  35541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35543. return
  35544. }
  35545. var respJSON map[string]interface{}
  35546. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35549. return
  35550. }
  35551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35552. result, _ := json.Marshal(respJSON)
  35553. fmt.Println("log")
  35554. fmt.Println(string(result))
  35555. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35556. utils.ErrorLog("解析失败:%v", err)
  35557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35558. return
  35559. }
  35560. } else if miConfig.MdtrtareaAdmvs == "421182" {
  35561. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35562. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35563. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  35564. resp, requestErr := http.Get(api)
  35565. if requestErr != nil {
  35566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35567. return
  35568. }
  35569. body, ioErr := ioutil.ReadAll(resp.Body)
  35570. if ioErr != nil {
  35571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35573. return
  35574. }
  35575. var respJSON map[string]interface{}
  35576. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35579. return
  35580. }
  35581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35582. result, _ := json.Marshal(respJSON)
  35583. fmt.Println("log")
  35584. fmt.Println(string(result))
  35585. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35586. utils.ErrorLog("解析失败:%v", err)
  35587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35588. return
  35589. }
  35590. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  35591. var api string
  35592. if miConfig.MdtrtareaAdmvs == "320921" {
  35593. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35594. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35595. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35596. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35597. } else {
  35598. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35599. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35600. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35601. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35602. }
  35603. resp, requestErr := http.Get(api)
  35604. if requestErr != nil {
  35605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35606. return
  35607. }
  35608. body, ioErr := ioutil.ReadAll(resp.Body)
  35609. if ioErr != nil {
  35610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35612. return
  35613. }
  35614. var respJSON map[string]interface{}
  35615. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35618. return
  35619. }
  35620. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35621. result, _ := json.Marshal(respJSON)
  35622. fmt.Println("log")
  35623. fmt.Println(string(result))
  35624. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35625. utils.ErrorLog("解析失败:%v", err)
  35626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35627. return
  35628. }
  35629. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35630. res.Output = resEleven10265.Output
  35631. res.ErrMsg = resEleven10265.ErrMsg
  35632. res.Cainfo = resEleven10265.Cainfo
  35633. res.WarnMsg = resEleven10265.WarnMsg
  35634. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35635. res.Infcode = infocode
  35636. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35637. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  35638. saveLog(result, requestLog, "5203", "结算单")
  35639. var dat map[string]interface{}
  35640. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35641. fmt.Println(dat)
  35642. } else {
  35643. fmt.Println(err)
  35644. }
  35645. userJSONBytes, _ := json.Marshal(dat)
  35646. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35647. utils.ErrorLog("解析失败:%v", err)
  35648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35649. return
  35650. }
  35651. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35652. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35653. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35654. saveLog(result, requestLog, "5203", "结算单")
  35655. var dat map[string]interface{}
  35656. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35657. fmt.Println(dat)
  35658. } else {
  35659. fmt.Println(err)
  35660. }
  35661. userJSONBytes, _ := json.Marshal(dat)
  35662. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35663. utils.ErrorLog("解析失败:%v", err)
  35664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35665. return
  35666. }
  35667. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35668. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35669. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35670. saveLog(result, requestLog, "5203", "结算单")
  35671. var dat map[string]interface{}
  35672. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35673. fmt.Println(dat)
  35674. } else {
  35675. fmt.Println(err)
  35676. }
  35677. userJSONBytes, _ := json.Marshal(dat)
  35678. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35679. utils.ErrorLog("解析失败:%v", err)
  35680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35681. return
  35682. }
  35683. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35684. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35685. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  35686. saveLog(result, requestLog, "5203", "结算单")
  35687. var dat map[string]interface{}
  35688. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35689. fmt.Println(dat)
  35690. } else {
  35691. fmt.Println(err)
  35692. }
  35693. userJSONBytes, _ := json.Marshal(dat)
  35694. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35695. utils.ErrorLog("解析失败:%v", err)
  35696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35697. return
  35698. }
  35699. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35700. var api string
  35701. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35702. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35703. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35704. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35705. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35706. resp, requestErr := http.Get(api)
  35707. if requestErr != nil {
  35708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35709. return
  35710. }
  35711. body, ioErr := ioutil.ReadAll(resp.Body)
  35712. if ioErr != nil {
  35713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35715. return
  35716. }
  35717. var respJSON map[string]interface{}
  35718. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35721. return
  35722. }
  35723. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35724. if status == "0" {
  35725. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35726. c.ServeSuccessJSON(map[string]interface{}{
  35727. "failed_code": -10,
  35728. "msg": err_msg,
  35729. })
  35730. return
  35731. }
  35732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35733. result, _ := json.Marshal(respJSON)
  35734. fmt.Println("log")
  35735. fmt.Println(string(result))
  35736. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35737. utils.ErrorLog("解析失败:%v", err)
  35738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35739. return
  35740. }
  35741. res.InfRefmsgid = resah.InfRefmsgid
  35742. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35743. // 创建对应的Time类型
  35744. t := time.UnixMilli(timestamp)
  35745. // 格式化成指定的日期字符串
  35746. str := t.Format("2006-01-02 15:04:05")
  35747. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35748. // 创建对应的Time类型
  35749. t3 := time.UnixMilli(timestamp2)
  35750. // 格式化成指定的日期字符串
  35751. str2 := t3.Format("2006-01-02 15:04:05")
  35752. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35753. // 创建对应的Time类型
  35754. t4 := time.UnixMilli(timestamp3)
  35755. // 格式化成指定的日期字符串
  35756. str3 := t4.Format("2006-01-02 15:04:05")
  35757. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35758. // 创建对应的Time类型
  35759. t5 := time.UnixMilli(timestamp4)
  35760. // 格式化成指定的日期字符串
  35761. str5 := t5.Format("2006-01-02 15:04:05")
  35762. res.Output.Setlinfo.Brdy = str2
  35763. res.Output.Setlinfo.SetlTime = str
  35764. res.Output.Setlinfo.Begndate = str3
  35765. res.Output.Setlinfo.Enddate = str5
  35766. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35767. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35768. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35769. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35770. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35771. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35772. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35773. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35774. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35775. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35776. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35777. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35778. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35779. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35780. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35781. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35782. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35783. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35784. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35785. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35786. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35787. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35788. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35789. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35790. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35791. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35792. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35793. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35794. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35795. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35796. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35797. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35798. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35799. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35800. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35801. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35802. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35803. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35804. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35805. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35806. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35807. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35808. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35809. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35810. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35811. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35812. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35813. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35814. //res.Output.Setldetail = resah.Output.Setldetail
  35815. res.ErrMsg = resah.ErrMsg
  35816. res.Cainfo = resah.Cainfo
  35817. res.WarnMsg = resah.WarnMsg
  35818. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35819. var api string
  35820. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35821. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35822. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35823. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35824. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35825. resp, requestErr := http.Get(api)
  35826. if requestErr != nil {
  35827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35828. return
  35829. }
  35830. body, ioErr := ioutil.ReadAll(resp.Body)
  35831. if ioErr != nil {
  35832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35834. return
  35835. }
  35836. var respJSON map[string]interface{}
  35837. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35840. return
  35841. }
  35842. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35843. if status == "0" {
  35844. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35845. c.ServeSuccessJSON(map[string]interface{}{
  35846. "failed_code": -10,
  35847. "msg": err_msg,
  35848. })
  35849. return
  35850. }
  35851. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35852. result, _ := json.Marshal(respJSON)
  35853. fmt.Println("log")
  35854. fmt.Println(string(result))
  35855. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35856. utils.ErrorLog("解析失败:%v", err)
  35857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35858. return
  35859. }
  35860. res.InfRefmsgid = resah.InfRefmsgid
  35861. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35862. // 创建对应的Time类型
  35863. t := time.UnixMilli(timestamp)
  35864. // 格式化成指定的日期字符串
  35865. str := t.Format("2006-01-02 15:04:05")
  35866. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35867. // 创建对应的Time类型
  35868. t3 := time.UnixMilli(timestamp2)
  35869. // 格式化成指定的日期字符串
  35870. str2 := t3.Format("2006-01-02 15:04:05")
  35871. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35872. // 创建对应的Time类型
  35873. t4 := time.UnixMilli(timestamp3)
  35874. // 格式化成指定的日期字符串
  35875. str3 := t4.Format("2006-01-02 15:04:05")
  35876. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35877. // 创建对应的Time类型
  35878. t5 := time.UnixMilli(timestamp4)
  35879. // 格式化成指定的日期字符串
  35880. str5 := t5.Format("2006-01-02 15:04:05")
  35881. res.Output.Setlinfo.Brdy = str2
  35882. res.Output.Setlinfo.SetlTime = str
  35883. res.Output.Setlinfo.Begndate = str3
  35884. res.Output.Setlinfo.Enddate = str5
  35885. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35886. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35887. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35888. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35889. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35890. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35891. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35892. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35893. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35894. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35895. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35896. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35897. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35898. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35899. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35900. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35901. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35902. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35903. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35904. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35905. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35906. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35907. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35908. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35909. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35910. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35911. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35912. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35913. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35914. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35915. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35916. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35917. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35918. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35919. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35920. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35921. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35922. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35923. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35924. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35925. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35926. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35927. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35928. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35929. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35930. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35931. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35932. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35933. //res.Output.Setldetail = resah.Output.Setldetail
  35934. res.ErrMsg = resah.ErrMsg
  35935. res.Cainfo = resah.Cainfo
  35936. res.WarnMsg = resah.WarnMsg
  35937. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35938. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35939. saveLog(result, requestLog, "5203", "结算单")
  35940. var dat map[string]interface{}
  35941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35942. fmt.Println(dat)
  35943. } else {
  35944. fmt.Println(err)
  35945. }
  35946. userJSONBytes, _ := json.Marshal(dat)
  35947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35948. utils.ErrorLog("解析失败:%v", err)
  35949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35950. return
  35951. }
  35952. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35953. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35954. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35955. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35956. resp, requestErr := http.Get(api)
  35957. if requestErr != nil {
  35958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35959. return
  35960. }
  35961. body, ioErr := ioutil.ReadAll(resp.Body)
  35962. if ioErr != nil {
  35963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35965. return
  35966. }
  35967. var respJSON map[string]interface{}
  35968. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35971. return
  35972. }
  35973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35974. result, _ := json.Marshal(respJSON)
  35975. fmt.Println("log")
  35976. fmt.Println(string(result))
  35977. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35978. utils.ErrorLog("解析失败:%v", err)
  35979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35980. return
  35981. }
  35982. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35983. res.Output = resEleven10265.Output
  35984. res.ErrMsg = resEleven10265.ErrMsg
  35985. res.Cainfo = resEleven10265.Cainfo
  35986. res.WarnMsg = resEleven10265.WarnMsg
  35987. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35988. res.Infcode = infocode
  35989. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35990. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35991. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35992. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35993. resp, requestErr := http.Get(api)
  35994. if requestErr != nil {
  35995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35996. return
  35997. }
  35998. body, ioErr := ioutil.ReadAll(resp.Body)
  35999. if ioErr != nil {
  36000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36002. return
  36003. }
  36004. var respJSON map[string]interface{}
  36005. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36008. return
  36009. }
  36010. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36011. result, _ := json.Marshal(respJSON)
  36012. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36013. utils.ErrorLog("解析失败:%v", err)
  36014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36015. return
  36016. }
  36017. } else if miConfig.MdtrtareaAdmvs == "450721" {
  36018. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  36019. //return
  36020. } else {
  36021. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36022. if len(his.InsuplcAdmdvs) == 0 {
  36023. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  36024. } else {
  36025. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36026. }
  36027. result := service.Gdyb5203(baseParams, businessParams)
  36028. //service.Gdyb5204(baseParams, businessParams)
  36029. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36030. var dat map[string]interface{}
  36031. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36032. fmt.Println(dat)
  36033. } else {
  36034. fmt.Println(err)
  36035. }
  36036. userJSONBytes, _ := json.Marshal(dat)
  36037. if miConfig.Code == "H15049901371" {
  36038. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36039. utils.ErrorLog("解析失败:%v", err)
  36040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36041. return
  36042. }
  36043. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36044. res.Output = resEleven10265.Output
  36045. res.ErrMsg = resEleven10265.ErrMsg
  36046. res.Cainfo = resEleven10265.Cainfo
  36047. res.WarnMsg = resEleven10265.WarnMsg
  36048. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36049. res.Infcode = infocode
  36050. } else {
  36051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36052. utils.ErrorLog("解析失败:%v", err)
  36053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36054. return
  36055. }
  36056. }
  36057. }
  36058. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36059. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36060. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36061. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36062. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36063. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36064. var doctor_name string
  36065. if roles.ID == 0 {
  36066. doctor_name = "管理员"
  36067. } else {
  36068. doctor_name = roles.UserName
  36069. }
  36070. yiliao_leibie := ""
  36071. switch order.MedType {
  36072. case "11":
  36073. yiliao_leibie = "普通门诊"
  36074. break
  36075. case "12":
  36076. yiliao_leibie = "门诊挂号"
  36077. break
  36078. case "13":
  36079. yiliao_leibie = "急诊"
  36080. break
  36081. case "14":
  36082. yiliao_leibie = "门诊特殊病"
  36083. break
  36084. case "15":
  36085. yiliao_leibie = "门诊统筹"
  36086. break
  36087. case "16":
  36088. yiliao_leibie = "门诊慢性病"
  36089. break
  36090. case "21":
  36091. yiliao_leibie = "普通住院"
  36092. break
  36093. }
  36094. //var rf []CustomFundPay
  36095. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  36096. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36097. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  36098. if res.Infcode == 0 {
  36099. 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 || adminUser.CurrentOrgId == 10210{
  36100. c.ServeSuccessJSON(map[string]interface{}{
  36101. "diagnosis": name,
  36102. "order_infos": orderInfos,
  36103. "number": order.MdtrtId,
  36104. "date": order.SettleAccountsDate,
  36105. "charge_admin": charge_admin,
  36106. "printor_admin": printor_admin,
  36107. "info": res.Output.Setlinfo,
  36108. "order": order,
  36109. "bedCostTotal": bedCostTotal,
  36110. "bedCostSelfTotal": bedCostSelfTotal,
  36111. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36112. "bedSelfTotal": bedSelfTotal,
  36113. "bedInscpTotal": bedInscpTotal,
  36114. "operationCostTotal": operationCostTotal,
  36115. "operationCostSelfTotal": operationCostSelfTotal,
  36116. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36117. "operationSelfTotal": operationSelfTotal,
  36118. "operationInscpTotal": operationInscpTotal,
  36119. "otherCostTotal": otherCostTotal,
  36120. "otherCostSelfTotal": otherCostSelfTotal,
  36121. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36122. "otherSelfTotal": otherSelfTotal,
  36123. "otherInscpTotal": otherInscpTotal,
  36124. "materialCostTotal": materialCostTotal,
  36125. "materialCostSelfTotal": materialCostSelfTotal,
  36126. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36127. "materialSelfTotal": materialSelfTotal,
  36128. "materialInscpTotal": materialInscpTotal,
  36129. "westernMedicineCostTotal": westernMedicineCostTotal,
  36130. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36131. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36132. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36133. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36134. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36135. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36136. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36137. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36138. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36139. "checkCostTotal": checkCostTotal,
  36140. "checkCostSelfTotal": checkCostSelfTotal,
  36141. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36142. "checkSelfTotal": checkSelfTotal,
  36143. "checkInscpTotal": checkInscpTotal,
  36144. "laboratoryCostTotal": laboratoryCostTotal,
  36145. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36146. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36147. "laboratorySelfTotal": laboratorySelfTotal,
  36148. "laboratoryInscpTotal": laboratoryInscpTotal,
  36149. "treatCostTotal": treatCostTotal,
  36150. "treatCostSelfTotal": treatCostSelfTotal,
  36151. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36152. "treatSelfTotal": treatSelfTotal,
  36153. "treatInscpTotal": treatInscpTotal,
  36154. "doctor_info": doctor_info,
  36155. "doctor_code": adminRole_two.DoctorCode,
  36156. "doctor_name": doctor_name,
  36157. "health_card_no": order.PsnNo,
  36158. "department": departments.Name,
  36159. "yiliao_leibie": yiliao_leibie,
  36160. "after_money": order.AccountPrice,
  36161. "patient": patient,
  36162. "org_name": miConfig.OrgName,
  36163. "org_code": miConfig.Code,
  36164. "order_number": order.Number,
  36165. "his_hospital": his_hospital,
  36166. "his": his,
  36167. "dia_config": dia_config,
  36168. "psn_cash_pay": order.PsnCashPay,
  36169. "zcCostTotal": zcCostTotal,
  36170. "zcCostSelfTotal": zcCostSelfTotal,
  36171. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  36172. "zcSelfTotal": zcSelfTotal,
  36173. "zcInscpTotal": zcInscpTotal,
  36174. "huliCostTotal": huliCostTotal,
  36175. "huliCostSelfTotal": huliCostSelfTotal,
  36176. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  36177. "huliSelfTotal": huliSelfTotal,
  36178. "huliInscpTotal": huliInscpTotal,
  36179. //"funds": rf,
  36180. //"check_order_info": cus_slice,
  36181. })
  36182. } else {
  36183. c.ServeSuccessJSON(map[string]interface{}{
  36184. "diagnosis": name,
  36185. "order_infos": orderInfos,
  36186. "number": order.MdtrtId,
  36187. "date": order.SettleAccountsDate,
  36188. "charge_admin": charge_admin,
  36189. "printor_admin": printor_admin,
  36190. "info": order,
  36191. "order": order,
  36192. "bedCostTotal": bedCostTotal,
  36193. "bedCostSelfTotal": bedCostSelfTotal,
  36194. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36195. "bedSelfTotal": bedSelfTotal,
  36196. "bedInscpTotal": bedInscpTotal,
  36197. "operationCostTotal": operationCostTotal,
  36198. "operationCostSelfTotal": operationCostSelfTotal,
  36199. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36200. "operationSelfTotal": operationSelfTotal,
  36201. "operationInscpTotal": operationInscpTotal,
  36202. "otherCostTotal": otherCostTotal,
  36203. "otherCostSelfTotal": otherCostSelfTotal,
  36204. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36205. "otherSelfTotal": otherSelfTotal,
  36206. "otherInscpTotal": otherInscpTotal,
  36207. "materialCostTotal": materialCostTotal,
  36208. "materialCostSelfTotal": materialCostSelfTotal,
  36209. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36210. "materialSelfTotal": materialSelfTotal,
  36211. "materialInscpTotal": materialInscpTotal,
  36212. "westernMedicineCostTotal": westernMedicineCostTotal,
  36213. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36214. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36215. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36216. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36217. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36218. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36219. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36220. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36221. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36222. "checkCostTotal": checkCostTotal,
  36223. "checkCostSelfTotal": checkCostSelfTotal,
  36224. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36225. "checkSelfTotal": checkSelfTotal,
  36226. "checkInscpTotal": checkInscpTotal,
  36227. "laboratoryCostTotal": laboratoryCostTotal,
  36228. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36229. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36230. "laboratorySelfTotal": laboratorySelfTotal,
  36231. "laboratoryInscpTotal": laboratoryInscpTotal,
  36232. "treatCostTotal": treatCostTotal,
  36233. "treatCostSelfTotal": treatCostSelfTotal,
  36234. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36235. "treatSelfTotal": treatSelfTotal,
  36236. "treatInscpTotal": treatInscpTotal,
  36237. "doctor_info": doctor_info,
  36238. "doctor_code": adminRole_two.DoctorCode,
  36239. "doctor_name": doctor_name,
  36240. "health_card_no": order.PsnNo,
  36241. "department": departments.Name,
  36242. "yiliao_leibie": yiliao_leibie,
  36243. "after_money": order.AccountPrice,
  36244. "patient": patient,
  36245. "org_name": miConfig.OrgName,
  36246. "org_code": miConfig.Code,
  36247. "order_number": order.Number,
  36248. "his_hospital": his_hospital,
  36249. "his": his,
  36250. "dia_config": dia_config,
  36251. "psn_cash_pay": order.PsnCashPay,
  36252. "zcCostTotal": zcCostTotal,
  36253. "zcCostSelfTotal": zcCostSelfTotal,
  36254. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  36255. "zcSelfTotal": zcSelfTotal,
  36256. "zcInscpTotal": zcInscpTotal,
  36257. "huliCostTotal": huliCostTotal,
  36258. "huliCostSelfTotal": huliCostSelfTotal,
  36259. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  36260. "huliSelfTotal": huliSelfTotal,
  36261. "huliInscpTotal": huliInscpTotal,
  36262. //"funds": rf,
  36263. //"check_order_info": cus_slice,
  36264. })
  36265. }
  36266. }
  36267. }
  36268. }
  36269. //func (c *HisApiController) CheckTreatment() {
  36270. // patient_id, _ := c.GetInt64("patient_id")
  36271. // id_card_no := c.GetString("id_card_no")
  36272. // insutype := c.GetString("insutype")
  36273. // med_type := c.GetString("med_type")
  36274. // admin_user_id, _ := c.GetInt64("admin_user_id")
  36275. //
  36276. // adminUser := c.GetAdminUserInfo()
  36277. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36278. //
  36279. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36280. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36281. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36282. //
  36283. // if miConfig.MdtrtareaAdmvs == "421300" {
  36284. // var res ResultTwo
  36285. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  36286. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  36287. // "&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)
  36288. // resp, requestErr := http.Get(api)
  36289. // if requestErr != nil {
  36290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36291. // return
  36292. // }
  36293. //
  36294. // body, ioErr := ioutil.ReadAll(resp.Body)
  36295. // if ioErr != nil {
  36296. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36298. // return
  36299. // }
  36300. // var respJSON map[string]interface{}
  36301. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36302. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36304. // return
  36305. // }
  36306. //
  36307. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36308. // result, _ := json.Marshal(respJSON)
  36309. //
  36310. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  36311. // utils.ErrorLog("解析失败:%v", err)
  36312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36313. // return
  36314. // }
  36315. //
  36316. // if res.Infcode == 0 {
  36317. //
  36318. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  36319. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  36320. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  36321. // resp, requestErr := http.Get(api)
  36322. // if requestErr != nil {
  36323. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36324. // return
  36325. // }
  36326. //
  36327. // body, ioErr := ioutil.ReadAll(resp.Body)
  36328. // if ioErr != nil {
  36329. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36331. // return
  36332. // }
  36333. // var respJSON map[string]interface{}
  36334. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36335. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36337. // return
  36338. // }
  36339. // var res Result2001
  36340. //
  36341. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36342. // result2, _ := json.Marshal(respJSON)
  36343. //
  36344. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  36345. // utils.ErrorLog("解析失败:%v", err)
  36346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36347. // return
  36348. // }
  36349. //
  36350. // if res.Infcode == 0 {
  36351. // c.ServeSuccessJSON(map[string]interface{}{
  36352. // "msg": res.Output.Trtinfo,
  36353. // })
  36354. // }
  36355. //
  36356. // } else {
  36357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  36358. // return
  36359. // }
  36360. //
  36361. // } else {
  36362. //
  36363. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36364. // var dat map[string]interface{}
  36365. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36366. // fmt.Println(dat)
  36367. // } else {
  36368. // fmt.Println(err)
  36369. // }
  36370. // userJSONBytes, _ := json.Marshal(dat)
  36371. // var res ResultTwo
  36372. // var res10265 ResultTwo10265
  36373. // if miConfig.Code == "H15049901371" {
  36374. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36375. // utils.ErrorLog("解析失败:%v", err)
  36376. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36377. // return
  36378. // }
  36379. // res.ErrMsg = res10265.ErrMsg
  36380. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36381. // res.Infcode = infocode
  36382. // res.Output = res10265.Output
  36383. // res.InfRefmsgid = res10265.InfRefmsgid
  36384. // } else {
  36385. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36386. // utils.ErrorLog("解析失败:%v", err)
  36387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36388. // return
  36389. // }
  36390. // }
  36391. //
  36392. // var user_name string
  36393. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  36394. // if role.ID == 0 {
  36395. // user_name = "xxx"
  36396. // } else {
  36397. // user_name = role.UserName
  36398. // }
  36399. //
  36400. // baseParams := models.BaseParams{
  36401. // SecretKey: miConfig.SecretKey,
  36402. // FixmedinsCode: miConfig.Code,
  36403. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36404. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36405. // OrgName: miConfig.OrgName,
  36406. // Doctor: user_name,
  36407. // }
  36408. //
  36409. // if config.IsOpen == 1 {
  36410. // if miConfig.Code == "H15049901371" {
  36411. // if med_type == "14" {
  36412. // if insutype == "390" {
  36413. // med_type = "9933"
  36414. // } else if insutype == "310" {
  36415. // med_type = "990502"
  36416. // }
  36417. // } else if med_type == "11" {
  36418. // med_type = "11"
  36419. // }
  36420. // }
  36421. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  36422. // var dat map[string]interface{}
  36423. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36424. // fmt.Println(dat)
  36425. // } else {
  36426. // fmt.Println(err)
  36427. // }
  36428. // var res Result2001
  36429. // var res10265 Result2001Org10265
  36430. // if miConfig.Code == "H15049901371" {
  36431. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36432. // utils.ErrorLog("解析失败:%v", err)
  36433. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36434. // return
  36435. // }
  36436. // res.ErrMsg = res10265.ErrMsg
  36437. // res.Output = res10265.Output
  36438. // res.InfRefmsgid = res10265.InfRefmsgid
  36439. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36440. // res.Infcode = infocode
  36441. // } else {
  36442. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  36443. // utils.ErrorLog("解析失败:%v", err)
  36444. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36445. // return
  36446. // }
  36447. // }
  36448. // if res.Infcode == 0 {
  36449. // c.ServeSuccessJSON(map[string]interface{}{
  36450. // "msg": res.Output.Trtinfo,
  36451. // })
  36452. // }
  36453. // }
  36454. // }
  36455. //}
  36456. //func (c *HisApiController) PutRecord() {
  36457. // id, _ := c.GetInt64("id")
  36458. // record_time := c.GetString("record_time")
  36459. // timeLayout := "2006-01-02"
  36460. // loc, _ := time.LoadLocation("Local")
  36461. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36462. // if err != nil {
  36463. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36464. // return
  36465. // }
  36466. // recordDateTime := theTime.Unix()
  36467. //
  36468. // adminInfo := c.GetAdminUserInfo()
  36469. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  36470. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36471. //
  36472. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  36473. //
  36474. // fmt.Println(miConfig.SecretKey)
  36475. //
  36476. // if patient == nil {
  36477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36478. // return
  36479. // }
  36480. // if len(patient.IdCardNo) == 0 {
  36481. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  36482. // return
  36483. // }
  36484. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  36485. // if config.IsOpen == 1 {
  36486. // 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
  36487. // resp, requestErr := http.Get(api)
  36488. // if requestErr != nil {
  36489. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36490. // return
  36491. // }
  36492. // defer resp.Body.Close()
  36493. // body, ioErr := ioutil.ReadAll(resp.Body)
  36494. // if ioErr != nil {
  36495. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36497. // return
  36498. // }
  36499. // var respJSON map[string]interface{}
  36500. //
  36501. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36502. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36504. // return
  36505. // }
  36506. //
  36507. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36508. // userJSONBytes, _ := json.Marshal(userJSON)
  36509. // var res ResultTwo
  36510. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36511. // utils.ErrorLog("解析失败:%v", err)
  36512. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36513. // return
  36514. // }
  36515. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36516. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  36517. // infoStr := string(Iinfos)
  36518. // idetinfoStr := string(Idetinfos)
  36519. //
  36520. // if res.Infcode == 0 {
  36521. // his := models.VMHisPatient{
  36522. // Status: 1,
  36523. // Ctime: time.Now().Unix(),
  36524. // Mtime: time.Now().Unix(),
  36525. // PsnNo: res.Output.Baseinfo.PsnNo,
  36526. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  36527. // Certno: res.Output.Baseinfo.Certno,
  36528. // PsnName: res.Output.Baseinfo.PsnName,
  36529. // Gend: res.Output.Baseinfo.Gend,
  36530. // Naty: res.Output.Baseinfo.Naty,
  36531. // Brdy: res.Output.Baseinfo.Brdy,
  36532. // Age: res.Output.Baseinfo.Age,
  36533. // Iinfo: infoStr,
  36534. // Idetinfo: idetinfoStr,
  36535. // PatientId: patient.ID,
  36536. // RecordDate: theTime.Unix(),
  36537. // UserOrgId: adminInfo.CurrentOrgId,
  36538. // AdminUserId: adminInfo.AdminUser.Id,
  36539. // IsReturn: 1,
  36540. // }
  36541. //
  36542. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  36543. // //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")
  36544. // //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")
  36545. //
  36546. // //var dat map[string]interface{}
  36547. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36548. // // fmt.Println(dat)
  36549. // //} else {
  36550. // // fmt.Println(err)
  36551. // //}
  36552. //
  36553. // var dat2 map[string]interface{}
  36554. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36555. // fmt.Println(dat2)
  36556. // } else {
  36557. // fmt.Println(err)
  36558. // }
  36559. //
  36560. // } else {
  36561. // adminUser := c.GetAdminUserInfo()
  36562. // errlog := &models.HisOrderError{
  36563. // UserOrgId: adminUser.CurrentOrgId,
  36564. // Ctime: time.Now().Unix(),
  36565. // Mtime: time.Now().Unix(),
  36566. // ErrMsg: res.ErrMsg,
  36567. // Status: 1,
  36568. // PatientId: id,
  36569. // RecordTime: recordDateTime,
  36570. // Stage: 1,
  36571. // }
  36572. // service.CreateErrMsgLog(errlog)
  36573. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  36574. // return
  36575. // }
  36576. // }
  36577. //
  36578. //}
  36579. //func (c *HisApiController) GetUploadDiag() {
  36580. // id, _ := c.GetInt64("id")
  36581. // record_time := c.GetString("record_time")
  36582. //
  36583. // diagnosis_id, _ := c.GetInt64("diagnosis")
  36584. // sick_type, _ := c.GetInt64("sick_type")
  36585. // reg_type, _ := c.GetInt64("reg_type")
  36586. //
  36587. // timeLayout := "2006-01-02"
  36588. // loc, _ := time.LoadLocation("Local")
  36589. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36590. // if err != nil {
  36591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36592. // return
  36593. // }
  36594. //
  36595. // var patientPrescription models.HisPrescriptionInfo
  36596. // recordDateTime := theTime.Unix()
  36597. // adminInfo := c.GetAdminUserInfo()
  36598. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36599. //
  36600. // if patientPrescription.ID == 0 {
  36601. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36602. // }
  36603. //
  36604. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  36605. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  36606. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  36607. // sickConfig, _ := service.FindSickById(sick_type)
  36608. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36609. //
  36610. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  36611. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  36612. // "&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 +
  36613. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  36614. // resp2, requestErr2 := http.Get(api2)
  36615. // if requestErr2 != nil {
  36616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36617. // return
  36618. // }
  36619. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  36620. // if ioErr2 != nil {
  36621. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  36622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36623. // return
  36624. // }
  36625. // var respJSON2 map[string]interface{}
  36626. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  36627. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36629. // return
  36630. // }
  36631. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36632. // userJSONBytes2, _ := json.Marshal(respJSON2)
  36633. //
  36634. // var res2 ResultSix
  36635. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36636. // utils.ErrorLog("解析失败:%v", err)
  36637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36638. // return
  36639. // }
  36640. // if res2.Infcode != 0 {
  36641. // adminUser := c.GetAdminUserInfo()
  36642. // errlog := &models.HisOrderError{
  36643. // UserOrgId: adminUser.CurrentOrgId,
  36644. // Ctime: time.Now().Unix(),
  36645. // Mtime: time.Now().Unix(),
  36646. // ErrMsg: res2.ErrMsg,
  36647. // Status: 1,
  36648. // PatientId: id,
  36649. // RecordTime: recordDateTime,
  36650. // Stage: 3,
  36651. // }
  36652. // service.CreateErrMsgLog(errlog)
  36653. //
  36654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  36655. // return
  36656. // }
  36657. //
  36658. // c.ServeSuccessJSON(map[string]interface{}{
  36659. // "msg": "上传成功",
  36660. // })
  36661. //
  36662. //}
  36663. type QueryResult struct {
  36664. ID int64
  36665. Name string
  36666. Code string
  36667. List_type_code string
  36668. }
  36669. func (c *HisApiController) GetCheckCode() {
  36670. ids_str := c.GetString("ids")
  36671. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36672. ids_arr := strings.Split(ids_str, ",")
  36673. var queryResult []QueryResult
  36674. ids := make([]int64, 0)
  36675. for _, item := range ids_arr {
  36676. id, _ := strconv.ParseInt(item, 10, 64)
  36677. ids = append(ids, id)
  36678. }
  36679. if record_type == 1 {
  36680. drugs, _ := service.GetBatchDrugList(ids)
  36681. for _, item := range drugs {
  36682. result := QueryResult{
  36683. ID: item.ID,
  36684. Name: item.DrugName,
  36685. Code: item.MedicalInsuranceNumber,
  36686. List_type_code: "101",
  36687. }
  36688. queryResult = append(queryResult, result)
  36689. }
  36690. } else if record_type == 2 {
  36691. goods, _ := service.GetBatchGoodInformationList(ids)
  36692. fmt.Println(goods)
  36693. for _, item := range goods {
  36694. result := QueryResult{
  36695. ID: item.ID,
  36696. Name: item.GoodName,
  36697. Code: item.SocialSecurityDirectoryCode,
  36698. List_type_code: "301",
  36699. }
  36700. queryResult = append(queryResult, result)
  36701. }
  36702. } else if record_type == 3 {
  36703. projects, _ := service.GetBathchMyPorjecgList(ids)
  36704. for _, item := range projects {
  36705. result := QueryResult{
  36706. ID: item.ID,
  36707. Name: item.ProjectName,
  36708. Code: item.MedicalCode,
  36709. List_type_code: "201",
  36710. }
  36711. queryResult = append(queryResult, result)
  36712. }
  36713. }
  36714. admin_user_id, _ := c.GetInt64("admin_user_id")
  36715. adminUser := c.GetAdminUserInfo()
  36716. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36717. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36718. var user_name string
  36719. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36720. if role.ID == 0 {
  36721. user_name = "管理员"
  36722. } else {
  36723. user_name = role.UserName
  36724. }
  36725. baseParams := models.BaseParams{
  36726. SecretKey: miConfig.SecretKey,
  36727. FixmedinsCode: miConfig.Code,
  36728. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36729. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36730. OrgName: miConfig.OrgName,
  36731. Doctor: user_name,
  36732. }
  36733. var result string
  36734. if miConfig.MdtrtareaAdmvs == "430800" {
  36735. for _, item := range queryResult {
  36736. if record_type == 1 {
  36737. 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)
  36738. } else if record_type == 2 {
  36739. fmt.Println(item.Code)
  36740. 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)
  36741. } else if record_type == 3 {
  36742. 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)
  36743. }
  36744. var dat map[string]interface{}
  36745. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36746. fmt.Println(dat)
  36747. } else {
  36748. fmt.Println(err)
  36749. }
  36750. userJSONBytes, _ := json.Marshal(dat)
  36751. var res ResultSix
  36752. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36753. utils.ErrorLog("解析失败:%v", err)
  36754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36755. return
  36756. }
  36757. if res.Infcode == 0 {
  36758. if record_type == 1 {
  36759. service.UpdateBaseDrugById(item.ID)
  36760. } else if record_type == 2 {
  36761. service.UpdateGoodInformaitonByDetail(item.ID)
  36762. } else if record_type == 3 {
  36763. service.UpdateProjectById(item.ID)
  36764. }
  36765. c.ServeSuccessJSON(map[string]interface{}{
  36766. "failed_code": 0,
  36767. "msg": "目录对照成功",
  36768. })
  36769. } else {
  36770. c.ServeSuccessJSON(map[string]interface{}{
  36771. "failed_code": -10,
  36772. "msg": res.ErrMsg,
  36773. })
  36774. }
  36775. }
  36776. } else {
  36777. for _, item := range queryResult {
  36778. var result string
  36779. if record_type == 1 {
  36780. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36781. } else if record_type == 2 {
  36782. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36783. } else if record_type == 3 {
  36784. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36785. }
  36786. var dat map[string]interface{}
  36787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36788. fmt.Println(dat)
  36789. } else {
  36790. fmt.Println(err)
  36791. }
  36792. userJSONBytes, _ := json.Marshal(dat)
  36793. var res ResultSix
  36794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36795. utils.ErrorLog("解析失败:%v", err)
  36796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36797. return
  36798. }
  36799. if res.Infcode == 0 {
  36800. if record_type == 1 {
  36801. service.UpdateBaseDrugById(item.ID)
  36802. } else if record_type == 2 {
  36803. service.UpdateGoodInformaitonByDetail(item.ID)
  36804. } else if record_type == 3 {
  36805. service.UpdateProjectById(item.ID)
  36806. }
  36807. c.ServeSuccessJSON(map[string]interface{}{
  36808. "failed_code": 0,
  36809. "msg": "目录对照成功",
  36810. })
  36811. } else {
  36812. c.ServeSuccessJSON(map[string]interface{}{
  36813. "failed_code": -10,
  36814. "msg": res.ErrMsg,
  36815. })
  36816. }
  36817. }
  36818. }
  36819. }
  36820. func (c *HisApiController) UnCheckCode() {
  36821. ids_str := c.GetString("ids")
  36822. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36823. admin_user_id, _ := c.GetInt64("admin_user_id")
  36824. ids_arr := strings.Split(ids_str, ",")
  36825. var queryResult []QueryResult
  36826. ids := make([]int64, 0)
  36827. for _, item := range ids_arr {
  36828. id, _ := strconv.ParseInt(item, 10, 64)
  36829. ids = append(ids, id)
  36830. }
  36831. if record_type == 1 {
  36832. drugs, _ := service.GetBatchDrugList(ids)
  36833. for _, item := range drugs {
  36834. result := QueryResult{
  36835. ID: item.ID,
  36836. Name: item.DrugName,
  36837. Code: item.MedicalInsuranceNumber,
  36838. List_type_code: "101",
  36839. }
  36840. queryResult = append(queryResult, result)
  36841. }
  36842. } else if record_type == 2 {
  36843. goods, _ := service.GetBatchGoodInformationList(ids)
  36844. for _, item := range goods {
  36845. result := QueryResult{
  36846. ID: item.ID,
  36847. Name: item.GoodName,
  36848. Code: item.SocialSecurityDirectoryCode,
  36849. List_type_code: "301",
  36850. }
  36851. queryResult = append(queryResult, result)
  36852. }
  36853. } else if record_type == 3 {
  36854. projects, _ := service.GetBathchMyPorjecgList(ids)
  36855. for _, item := range projects {
  36856. result := QueryResult{
  36857. ID: item.ID,
  36858. Name: item.ProjectName,
  36859. Code: item.MedicalCode,
  36860. List_type_code: "201",
  36861. }
  36862. queryResult = append(queryResult, result)
  36863. }
  36864. }
  36865. adminUser := c.GetAdminUserInfo()
  36866. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36867. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36868. var user_name string
  36869. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36870. if role.ID == 0 {
  36871. user_name = "xxx"
  36872. } else {
  36873. user_name = role.UserName
  36874. }
  36875. baseParams := &models.BaseParams{
  36876. SecretKey: miConfig.SecretKey,
  36877. FixmedinsCode: miConfig.Code,
  36878. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36879. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36880. OrgName: miConfig.OrgName,
  36881. Doctor: user_name,
  36882. }
  36883. if config.IsOpen == 1 {
  36884. if miConfig.MdtrtareaAdmvs == "430800" {
  36885. for _, item := range queryResult {
  36886. var result string
  36887. if record_type == 1 {
  36888. 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)
  36889. } else if record_type == 2 {
  36890. fmt.Println(item.Code)
  36891. 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)
  36892. } else if record_type == 3 {
  36893. 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)
  36894. }
  36895. var dat map[string]interface{}
  36896. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36897. fmt.Println(dat)
  36898. } else {
  36899. fmt.Println(err)
  36900. }
  36901. userJSONBytes, _ := json.Marshal(dat)
  36902. var res ResultSix
  36903. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36904. utils.ErrorLog("解析失败:%v", err)
  36905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36906. return
  36907. }
  36908. if res.Infcode == 0 {
  36909. if record_type == 1 {
  36910. service.UpdateBaseDrugById(item.ID)
  36911. } else if record_type == 2 {
  36912. service.UpdateGoodInformaitonByDetail(item.ID)
  36913. } else if record_type == 3 {
  36914. service.UpdateProjectById(item.ID)
  36915. }
  36916. c.ServeSuccessJSON(map[string]interface{}{
  36917. "failed_code": 0,
  36918. "msg": "目录对照成功",
  36919. })
  36920. } else {
  36921. c.ServeSuccessJSON(map[string]interface{}{
  36922. "failed_code": -10,
  36923. "msg": res.ErrMsg,
  36924. })
  36925. }
  36926. }
  36927. } else {
  36928. for _, item := range queryResult {
  36929. var result string
  36930. if record_type == 1 {
  36931. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36932. } else if record_type == 2 {
  36933. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36934. } else if record_type == 3 {
  36935. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36936. }
  36937. var dat2 map[string]interface{}
  36938. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36939. fmt.Println(dat2)
  36940. } else {
  36941. fmt.Println(err)
  36942. }
  36943. userJSONBytes, _ := json.Marshal(dat2)
  36944. var res ResultSix
  36945. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36946. utils.ErrorLog("解析失败:%v", err)
  36947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36948. return
  36949. }
  36950. if res.Infcode == 0 {
  36951. if record_type == 1 {
  36952. service.UpdateDrugByIdDetail(item.ID)
  36953. } else if record_type == 2 {
  36954. service.UpdateGoodInfoById(item.ID)
  36955. } else if record_type == 3 {
  36956. service.UpdateMyProjectById(item.ID)
  36957. }
  36958. c.ServeSuccessJSON(map[string]interface{}{
  36959. "failed_code": 0,
  36960. "msg": "撤销目录对照成功",
  36961. })
  36962. } else {
  36963. c.ServeSuccessJSON(map[string]interface{}{
  36964. "failed_code": -10,
  36965. "msg": res.ErrMsg,
  36966. })
  36967. }
  36968. }
  36969. }
  36970. }
  36971. }
  36972. func (c *HisApiController) GetPatientInfo() {
  36973. id_card_no := c.GetString("id_card_no")
  36974. admin_user_id, _ := c.GetInt64("admin_user_id")
  36975. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36976. if patient.ID == 0 {
  36977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36978. return
  36979. }
  36980. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36981. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36982. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36983. var res ResultTwo
  36984. var res10265 ResultTwo10265
  36985. if config.IsOpen == 1 {
  36986. if miConfig.MdtrtareaAdmvs == "150499" {
  36987. //请求内网数据
  36988. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36989. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36990. "&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
  36991. resp, requestErr := http.Get(api)
  36992. if requestErr != nil {
  36993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36994. return
  36995. }
  36996. body, ioErr := ioutil.ReadAll(resp.Body)
  36997. if ioErr != nil {
  36998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37000. return
  37001. }
  37002. var respJSON map[string]interface{}
  37003. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37006. return
  37007. }
  37008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37009. result_byte, _ := json.Marshal(respJSON)
  37010. result := string(result_byte)
  37011. var dat map[string]interface{}
  37012. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37013. fmt.Println(dat)
  37014. } else {
  37015. fmt.Println(err)
  37016. }
  37017. userJSONBytes, _ := json.Marshal(dat)
  37018. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37019. utils.ErrorLog("解析失败:%v", err)
  37020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37021. return
  37022. }
  37023. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37024. res.Infcode = Infcode
  37025. res.ErrMsg = res10265.ErrMsg
  37026. res.Output = res10265.Output
  37027. res.InfRefmsgid = res10265.InfRefmsgid
  37028. res.RespondTime = res10265.RespondTime
  37029. res.WarnInfo = res10265.WarnInfo
  37030. } else {
  37031. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37032. var dat map[string]interface{}
  37033. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37034. fmt.Println(dat)
  37035. } else {
  37036. fmt.Println(err)
  37037. }
  37038. userJSONBytes, _ := json.Marshal(dat)
  37039. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37040. utils.ErrorLog("解析失败:%v", err)
  37041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37042. return
  37043. }
  37044. }
  37045. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37046. // utils.ErrorLog("解析失败:%v", err)
  37047. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37048. // return
  37049. //}
  37050. for index, item := range res.Output.Iinfo {
  37051. if item.PsnInsuStas == "2" {
  37052. fmt.Println("--------")
  37053. res.Output.Iinfo[index].Insutype = "300"
  37054. res.Output.Iinfo[index].PsnInsuStas = "1"
  37055. }
  37056. }
  37057. fmt.Println(res.Output.Iinfo)
  37058. if res.Infcode != 0 {
  37059. c.ServeSuccessJSON(map[string]interface{}{
  37060. "failed_code": -10,
  37061. "msg": res.ErrMsg,
  37062. })
  37063. } else {
  37064. c.ServeSuccessJSON(map[string]interface{}{
  37065. "failed_code": 0,
  37066. "info": res,
  37067. })
  37068. }
  37069. }
  37070. }
  37071. func (c *HisApiController) PsnPutOnRecord() {
  37072. record_type, _ := c.GetInt64("type")
  37073. patient_id, _ := c.GetInt64("patient_id")
  37074. admin_user_id, _ := c.GetInt64("admin_user_id")
  37075. start_time := c.GetString("start_time")
  37076. end_time := c.GetString("end_time")
  37077. adminUser := c.GetAdminUserInfo()
  37078. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37079. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37080. var patients []*models.Patients
  37081. if record_type == 1 { //全部备案
  37082. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  37083. patients = append(patients, patient...)
  37084. } else { //单个备案
  37085. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37086. patients = append(patients, patient)
  37087. }
  37088. var user_name string
  37089. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37090. if role.ID == 0 {
  37091. user_name = "xxx"
  37092. } else {
  37093. user_name = role.UserName
  37094. }
  37095. if config.IsOpen == 1 {
  37096. for _, item := range patients {
  37097. 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
  37098. resp, requestErr := http.Get(api)
  37099. if requestErr != nil {
  37100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37101. return
  37102. }
  37103. defer resp.Body.Close()
  37104. body, ioErr := ioutil.ReadAll(resp.Body)
  37105. if ioErr != nil {
  37106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37108. return
  37109. }
  37110. var respJSON map[string]interface{}
  37111. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37114. return
  37115. }
  37116. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37117. userJSONBytes, _ := json.Marshal(userJSON)
  37118. var res ResultTwo
  37119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37120. utils.ErrorLog("解析失败:%v", err)
  37121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37122. return
  37123. }
  37124. if res.Infcode == 0 {
  37125. 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)
  37126. var dat map[string]interface{}
  37127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37128. fmt.Println(dat)
  37129. } else {
  37130. fmt.Println(err)
  37131. }
  37132. userJSONBytes, _ := json.Marshal(dat)
  37133. var res2 ResultThirteen
  37134. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  37135. utils.ErrorLog("解析失败:%v", err)
  37136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37137. return
  37138. }
  37139. if res2.Infcode == 0 {
  37140. psnResult := &models.GdybPsnRecord{
  37141. UserOrgId: adminUser.CurrentOrgId,
  37142. PatientId: item.ID,
  37143. PsnNo: res.Output.Baseinfo.PsnNo,
  37144. Ctime: time.Now().Unix(),
  37145. Mtime: time.Now().Unix(),
  37146. Status: 1,
  37147. IsCancel: 1,
  37148. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  37149. }
  37150. service.CreatePsnRecord(psnResult)
  37151. } else {
  37152. c.ServeSuccessJSON(map[string]interface{}{
  37153. "failed_code": -10,
  37154. "msg": res2.ErrMsg,
  37155. })
  37156. return
  37157. }
  37158. }
  37159. }
  37160. }
  37161. }
  37162. func (c *HisApiController) PsnUnPutOnRecord() {
  37163. id, _ := c.GetInt64("id")
  37164. //record_type, _ := c.GetInt64("type")
  37165. admin_user_id, _ := c.GetInt64("admin_user_id")
  37166. adminUser := c.GetAdminUserInfo()
  37167. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37168. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37169. var user_name string
  37170. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37171. if role.ID == 0 {
  37172. user_name = "xxx"
  37173. } else {
  37174. user_name = role.UserName
  37175. }
  37176. psn_record, _ := service.GetPsnRecordById(id)
  37177. if psn_record.ID == 0 {
  37178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  37179. return
  37180. }
  37181. if config.IsOpen == 1 {
  37182. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  37183. var dat map[string]interface{}
  37184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37185. fmt.Println(dat)
  37186. } else {
  37187. fmt.Println(err)
  37188. }
  37189. userJSONBytes, _ := json.Marshal(dat)
  37190. var res ResultFourteen
  37191. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37192. utils.ErrorLog("解析失败:%v", err)
  37193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37194. return
  37195. }
  37196. if res.Infcode == 0 {
  37197. psn_record.IsCancel = 2
  37198. service.CreatePsnRecord(&psn_record)
  37199. } else {
  37200. c.ServeSuccessJSON(map[string]interface{}{
  37201. "failed_code": -10,
  37202. "msg": res.ErrMsg,
  37203. })
  37204. return
  37205. }
  37206. }
  37207. }
  37208. func (c *HisApiController) PsnPutNCDSOnRecord() {
  37209. patient_id, _ := c.GetInt64("patient_id")
  37210. insutype_two := c.GetString("insutype")
  37211. psn_no := c.GetString("psn_no")
  37212. doctor_id, _ := c.GetInt64("doctor_id")
  37213. sick_id, _ := c.GetInt64("sick_id")
  37214. department_id, _ := c.GetInt64("department_id")
  37215. start_time := c.GetString("start_time")
  37216. end_time := c.GetString("end_time")
  37217. check_time := c.GetString("check_time")
  37218. hospital_code := c.GetString("hospital_code")
  37219. hospital_name := c.GetString("hospital_name")
  37220. adminUser := c.GetAdminUserInfo()
  37221. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37222. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37223. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37224. sick, _ := service.FindSickById(sick_id)
  37225. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  37226. if len(hospital_code) == 0 {
  37227. hospital_code = miConfig.Code
  37228. }
  37229. if len(hospital_name) == 0 {
  37230. hospital_name = miConfig.OrgName
  37231. }
  37232. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  37233. var res ResultTwo
  37234. var res10265 ResultTwo10265
  37235. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37236. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  37237. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  37238. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  37239. "&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
  37240. resp, requestErr := http.Get(api)
  37241. if requestErr != nil {
  37242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37243. return
  37244. }
  37245. body, ioErr := ioutil.ReadAll(resp.Body)
  37246. if ioErr != nil {
  37247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37249. return
  37250. }
  37251. var respJSON map[string]interface{}
  37252. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37255. return
  37256. }
  37257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37258. result, _ := json.Marshal(respJSON)
  37259. fmt.Println("log")
  37260. fmt.Println(string(result))
  37261. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37262. utils.ErrorLog("解析失败:%v", err)
  37263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37264. return
  37265. }
  37266. res.ErrMsg = res10265.ErrMsg
  37267. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37268. res.Infcode = infocode
  37269. res.Output = res10265.Output
  37270. res.InfRefmsgid = res10265.InfRefmsgid
  37271. } else {
  37272. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  37273. if miConfig.Code == "H15049901371" {
  37274. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37275. utils.ErrorLog("解析失败:%v", err)
  37276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37277. return
  37278. }
  37279. res.ErrMsg = res10265.ErrMsg
  37280. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37281. res.Infcode = infocode
  37282. res.Output = res10265.Output
  37283. res.InfRefmsgid = res10265.InfRefmsgid
  37284. } else {
  37285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37286. utils.ErrorLog("解析失败:%v", err)
  37287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37288. return
  37289. }
  37290. }
  37291. }
  37292. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37293. infoStr := string(Iinfos)
  37294. var rf []*ResultFive
  37295. json.Unmarshal([]byte(infoStr), &rf)
  37296. var insuplc_admdvs string
  37297. var insutype string
  37298. var is390 int = 0
  37299. var is310 int = 0
  37300. var insutypes []*ResultFive
  37301. for _, item := range rf {
  37302. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  37303. insutypes = append(insutypes, item)
  37304. }
  37305. }
  37306. if len(insutypes) == 1 {
  37307. insutype = insutypes[0].Insutype
  37308. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  37309. } else {
  37310. for _, i := range insutypes {
  37311. if i.Insutype == "390" {
  37312. is390 = 1
  37313. }
  37314. if i.Insutype == "310" {
  37315. is310 = 1
  37316. }
  37317. }
  37318. }
  37319. if is390 == 1 {
  37320. insutype = "390"
  37321. }
  37322. if is310 == 1 {
  37323. insutype = "310"
  37324. }
  37325. if len(insutypes) == 2 {
  37326. insutype = insutype_two
  37327. }
  37328. if len(insutypes) == 0 {
  37329. insutype = "310"
  37330. }
  37331. insutype = insutype_two
  37332. fmt.Println(insutype)
  37333. for _, item := range rf {
  37334. fmt.Println(item.Insutype)
  37335. fmt.Println(insutype)
  37336. if item.Insutype == insutype {
  37337. fmt.Println(item.Insutype)
  37338. fmt.Println(insutype)
  37339. insuplc_admdvs = item.InsuplcAdmdvs
  37340. }
  37341. }
  37342. fmt.Println(insuplc_admdvs)
  37343. var res2 ResultThirteen
  37344. var res10265_2 ResultThirteen10265
  37345. if config.IsOpen == 1 {
  37346. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37347. } else {
  37348. if miConfig.MdtrtareaAdmvs == "150499" {
  37349. //
  37350. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  37351. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  37352. // "&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
  37353. //resp, requestErr := http.Get(api)
  37354. //if requestErr != nil {
  37355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37356. // return
  37357. //}
  37358. //
  37359. //body, ioErr := ioutil.ReadAll(resp.Body)
  37360. //if ioErr != nil {
  37361. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37363. // return
  37364. //}
  37365. //var respJSON map[string]interface{}
  37366. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37367. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37369. // return
  37370. //}
  37371. //
  37372. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37373. //result, _ := json.Marshal(respJSON)
  37374. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  37375. // utils.ErrorLog("解析失败:%v", err)
  37376. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37377. // return
  37378. //}
  37379. //infocode = resThree.Infcode
  37380. //result, _ := json.Marshal(respJSON)
  37381. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  37382. // utils.ErrorLog("解析失败:%v", err)
  37383. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37384. // return
  37385. //}
  37386. //
  37387. //resThree.ErrMsg = resThree10265.ErrMsg
  37388. //
  37389. //resThree.Output = resThree10265.Output
  37390. //
  37391. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  37392. //
  37393. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  37394. //
  37395. } else {
  37396. 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)
  37397. var dat map[string]interface{}
  37398. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37399. fmt.Println(dat)
  37400. } else {
  37401. fmt.Println(err)
  37402. }
  37403. userJSONBytes, _ := json.Marshal(dat)
  37404. if miConfig.Code == "H15049901371" {
  37405. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  37406. utils.ErrorLog("解析失败:%v", err)
  37407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37408. return
  37409. }
  37410. res2.ErrMsg = res10265_2.ErrMsg
  37411. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  37412. res2.Infcode = infocode
  37413. res2.Output = res10265_2.Output
  37414. res2.InfRefmsgid = res10265_2.InfRefmsgid
  37415. } else {
  37416. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  37417. utils.ErrorLog("解析失败:%v", err)
  37418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37419. return
  37420. }
  37421. }
  37422. }
  37423. }
  37424. if res2.Infcode == 0 {
  37425. psnResult := &models.GdybPsnNcdsRecord{
  37426. UserOrgId: adminUser.CurrentOrgId,
  37427. PatientId: patient.ID,
  37428. PsnNo: psn_no,
  37429. DoctorId: doctor.AdminUserId,
  37430. DepartmentId: department_id,
  37431. SickType: sick_id,
  37432. Insutype: insutype,
  37433. Ctime: time.Now().Unix(),
  37434. Mtime: time.Now().Unix(),
  37435. Status: 1,
  37436. IsCancel: 1,
  37437. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  37438. }
  37439. service.CreatePsnNCDSRecord(psnResult)
  37440. c.ServeSuccessJSON(map[string]interface{}{
  37441. "failed_code": 0,
  37442. "msg": "备案成功",
  37443. "result": psnResult,
  37444. })
  37445. } else {
  37446. c.ServeSuccessJSON(map[string]interface{}{
  37447. "failed_code": -10,
  37448. "msg": res2.ErrMsg,
  37449. })
  37450. return
  37451. }
  37452. }
  37453. }
  37454. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  37455. id, _ := c.GetInt64("id")
  37456. admin_user_id, _ := c.GetInt64("admin_user_id")
  37457. adminUser := c.GetAdminUserInfo()
  37458. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37459. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37460. //config, _ := service.Ge(adminUser.CurrentOrgId)
  37461. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  37462. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37463. //var user_name string
  37464. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37465. //if role.ID == 0 {
  37466. // user_name = "xxx"
  37467. //} else {
  37468. // user_name = role.UserName
  37469. //}
  37470. psn_record, _ := service.GetPsnNCDSRecordById(id)
  37471. if psn_record.ID == 0 {
  37472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  37473. return
  37474. }
  37475. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  37476. var res ResultTwo
  37477. var res10265 ResultTwo10265
  37478. if miConfig.Code == "H15049901371" {
  37479. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37480. utils.ErrorLog("解析失败:%v", err)
  37481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37482. return
  37483. }
  37484. res.ErrMsg = res10265.ErrMsg
  37485. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37486. res.Infcode = infocode
  37487. res.Output = res10265.Output
  37488. res.InfRefmsgid = res10265.InfRefmsgid
  37489. } else {
  37490. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37491. utils.ErrorLog("解析失败:%v", err)
  37492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37493. return
  37494. }
  37495. }
  37496. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37497. infoStr := string(Iinfos)
  37498. var rf []*ResultFive
  37499. json.Unmarshal([]byte(infoStr), &rf)
  37500. var insuplc_admdvs string
  37501. var insutype string
  37502. var is390 int = 0
  37503. var is310 int = 0
  37504. var insutypes []*ResultFive
  37505. for _, item := range rf {
  37506. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  37507. insutypes = append(insutypes, item)
  37508. }
  37509. }
  37510. if len(insutypes) == 1 {
  37511. insutype = insutypes[0].Insutype
  37512. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  37513. } else {
  37514. for _, i := range insutypes {
  37515. if i.Insutype == "390" {
  37516. is390 = 1
  37517. }
  37518. if i.Insutype == "310" {
  37519. is310 = 1
  37520. }
  37521. }
  37522. }
  37523. if is390 == 1 {
  37524. insutype = "390"
  37525. }
  37526. if is310 == 1 {
  37527. insutype = "310"
  37528. }
  37529. if len(insutypes) == 0 {
  37530. insutype = "310"
  37531. }
  37532. insutype = psn_record.Insutype
  37533. for _, item := range rf {
  37534. if item.Insutype == insutype {
  37535. insuplc_admdvs = item.InsuplcAdmdvs
  37536. }
  37537. }
  37538. if config.IsOpen == 1 {
  37539. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  37540. var dat map[string]interface{}
  37541. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37542. fmt.Println(dat)
  37543. } else {
  37544. fmt.Println(err)
  37545. }
  37546. userJSONBytes, _ := json.Marshal(dat)
  37547. var res ResultFourteen
  37548. var res10265 ResultFourteen10265
  37549. if miConfig.Code == "H15049901371" {
  37550. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37551. utils.ErrorLog("解析失败:%v", err)
  37552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37553. return
  37554. }
  37555. res.ErrMsg = res10265.ErrMsg
  37556. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37557. res.Infcode = infocode
  37558. res.Output = res10265.Output
  37559. res.InfRefmsgid = res10265.InfRefmsgid
  37560. } else {
  37561. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37562. utils.ErrorLog("解析失败:%v", err)
  37563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37564. return
  37565. }
  37566. }
  37567. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37568. // utils.ErrorLog("解析失败:%v", err)
  37569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37570. // return
  37571. //}
  37572. if res.Infcode == 0 {
  37573. psn_record.IsCancel = 2
  37574. service.CreatePsnNCDSRecord(&psn_record)
  37575. c.ServeSuccessJSON(map[string]interface{}{
  37576. "failed_code": 0,
  37577. "msg": "撤销备案成功",
  37578. })
  37579. } else {
  37580. c.ServeSuccessJSON(map[string]interface{}{
  37581. "failed_code": -10,
  37582. "msg": res.ErrMsg,
  37583. })
  37584. return
  37585. }
  37586. }
  37587. }
  37588. func (c *HisApiController) TestTest() {
  37589. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  37590. fmt.Println(patient.Iinfo)
  37591. }
  37592. type CustomData struct {
  37593. MsgId string
  37594. PsnNo string
  37595. Info string
  37596. }
  37597. func (c *HisApiController) ReversalData() {
  37598. var customData []*CustomData
  37599. custom := &CustomData{
  37600. MsgId: "H44022900158202103301714472004",
  37601. PsnNo: "44020000001101329945",
  37602. Info: "2207",
  37603. }
  37604. customData = append(customData, custom)
  37605. custom1 := &CustomData{
  37606. MsgId: "H4402290015820210330172057803",
  37607. PsnNo: "44020000001101161813",
  37608. Info: "2207",
  37609. }
  37610. customData = append(customData, custom1)
  37611. custom2 := &CustomData{
  37612. MsgId: "H44022900158202103301705198813",
  37613. PsnNo: "44190000133097375417",
  37614. Info: "2207",
  37615. }
  37616. customData = append(customData, custom2)
  37617. custom3 := &CustomData{
  37618. MsgId: "H44022900158202103301715524756",
  37619. PsnNo: "44020000001100187221",
  37620. Info: "2207",
  37621. }
  37622. customData = append(customData, custom3)
  37623. custom4 := &CustomData{
  37624. MsgId: "H44022900158202103301730376224",
  37625. PsnNo: "44020000001101959155",
  37626. Info: "2207",
  37627. }
  37628. customData = append(customData, custom4)
  37629. custom5 := &CustomData{
  37630. MsgId: "H44022900158202103301748008725",
  37631. PsnNo: "44020000001104246641",
  37632. Info: "2207",
  37633. }
  37634. customData = append(customData, custom5)
  37635. custom6 := &CustomData{
  37636. MsgId: "H44022900158202103301718096755",
  37637. PsnNo: "44020000001102211860",
  37638. Info: "2207",
  37639. }
  37640. customData = append(customData, custom6)
  37641. custom7 := &CustomData{
  37642. MsgId: "H44022900158202103301736551640",
  37643. PsnNo: "44020000001102687718",
  37644. Info: "2207",
  37645. }
  37646. customData = append(customData, custom7)
  37647. custom8 := &CustomData{
  37648. MsgId: "H44022900158202103301743097676",
  37649. PsnNo: "44020000001102127785",
  37650. Info: "2207",
  37651. }
  37652. customData = append(customData, custom8)
  37653. custom9 := &CustomData{
  37654. MsgId: "H44022900158202103301712304203",
  37655. PsnNo: "44020000001101518097",
  37656. Info: "2207",
  37657. }
  37658. customData = append(customData, custom9)
  37659. custom10 := &CustomData{
  37660. MsgId: "H44022900158202103301738448785",
  37661. PsnNo: "44020000001100500813",
  37662. Info: "2207",
  37663. }
  37664. customData = append(customData, custom10)
  37665. custom11 := &CustomData{
  37666. MsgId: "H44022900158202103301732455843",
  37667. PsnNo: "44020000001102690557",
  37668. Info: "2207",
  37669. }
  37670. customData = append(customData, custom11)
  37671. custom12 := &CustomData{
  37672. MsgId: "H44022900158202103301745421708",
  37673. PsnNo: "44020000001102211928",
  37674. Info: "2207",
  37675. }
  37676. customData = append(customData, custom12)
  37677. custom1212 := &CustomData{
  37678. MsgId: "H440229001582021033017351627",
  37679. PsnNo: "44020000001102481733",
  37680. Info: "2207",
  37681. }
  37682. customData = append(customData, custom1212)
  37683. custom13 := &CustomData{
  37684. MsgId: "H44022900158202103301740327951",
  37685. PsnNo: "44020000001103174866",
  37686. Info: "2207",
  37687. }
  37688. customData = append(customData, custom13)
  37689. custom14 := &CustomData{
  37690. MsgId: "H4402290015820210330174922668",
  37691. PsnNo: "44020000001102927272",
  37692. Info: "2207",
  37693. }
  37694. customData = append(customData, custom14)
  37695. custom15 := &CustomData{
  37696. MsgId: "H44022900158202103301752362273",
  37697. PsnNo: "44020000001102942890",
  37698. Info: "2207",
  37699. }
  37700. customData = append(customData, custom15)
  37701. custom16 := &CustomData{
  37702. MsgId: "H44022900158202103301751082917",
  37703. PsnNo: "44020000001101662162",
  37704. Info: "2207",
  37705. }
  37706. customData = append(customData, custom16)
  37707. custom17 := &CustomData{
  37708. MsgId: "H44022900158202103301754147728",
  37709. PsnNo: "44020000000229014511",
  37710. Info: "2207",
  37711. }
  37712. customData = append(customData, custom17)
  37713. adminUser := c.GetAdminUserInfo()
  37714. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37715. for _, item := range customData {
  37716. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37717. fmt.Println(result)
  37718. }
  37719. }
  37720. func (c *HisApiController) GetAllopatry() {
  37721. year := c.GetString("year")
  37722. month := c.GetString("month")
  37723. admin_user_id, _ := c.GetInt64("admin_user_id")
  37724. adminUser := c.GetAdminUserInfo()
  37725. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37726. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37727. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37728. var dat map[string]interface{}
  37729. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37730. fmt.Println(dat)
  37731. } else {
  37732. fmt.Println(err)
  37733. }
  37734. userJSONBytes, _ := json.Marshal(dat)
  37735. var res models.Result9001
  37736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37737. utils.ErrorLog("解析失败:%v", err)
  37738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37739. return
  37740. }
  37741. fmt.Println(res.Output.Signinoutb)
  37742. fmt.Println(res.Output.Signinoutb.SignNo)
  37743. fmt.Println(string(userJSONBytes))
  37744. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37745. var dat3 map[string]interface{}
  37746. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  37747. fmt.Println(dat3)
  37748. } else {
  37749. fmt.Println(err)
  37750. }
  37751. userJSONBytes3, _ := json.Marshal(dat3)
  37752. var res3 models.Result3260
  37753. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  37754. utils.ErrorLog("解析失败:%v", err)
  37755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37756. return
  37757. }
  37758. var curpage int
  37759. var pagesize int = 100
  37760. var start int = 1
  37761. //var stop int
  37762. //pagecount := 10
  37763. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  37764. var res22 []models.Result3260
  37765. for curpage = 1; curpage <= pagecount; curpage++ {
  37766. if curpage == 1 {
  37767. start = 0
  37768. } else {
  37769. start = (curpage-1)*pagesize + 1
  37770. }
  37771. fmt.Println(start)
  37772. //stop = curpage * pagesize
  37773. //if stop > int(res3.Output.Totalrow) {
  37774. // stop =int(res3.Output.Totalrow)
  37775. //}
  37776. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  37777. var dat2 map[string]interface{}
  37778. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37779. fmt.Println(dat)
  37780. } else {
  37781. fmt.Println(err)
  37782. }
  37783. userJSONBytes2, _ := json.Marshal(dat2)
  37784. var res2 models.Result3260
  37785. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37786. utils.ErrorLog("解析失败:%v", err)
  37787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37788. return
  37789. }
  37790. if res2.Infcode == 0 {
  37791. res22 = append(res22, res2)
  37792. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37793. //var dat2 map[string]interface{}
  37794. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37795. // fmt.Println(dat)
  37796. //} else {
  37797. // fmt.Println(err)
  37798. //}
  37799. //c.ServeSuccessJSON(map[string]interface{}{
  37800. // "list": res2.Output.Data,
  37801. //})
  37802. //continue
  37803. }
  37804. }
  37805. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37806. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37807. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  37808. //var dat2 map[string]interface{}
  37809. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37810. // fmt.Println(dat)
  37811. //} else {
  37812. // fmt.Println(err)
  37813. //}
  37814. //userJSONBytes2, _ := json.Marshal(dat2)
  37815. //var res2 models.Result3260
  37816. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37817. // utils.ErrorLog("解析失败:%v", err)
  37818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37819. // return
  37820. //}
  37821. //if res2.Infcode == 0 {
  37822. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37823. // var dat2 map[string]interface{}
  37824. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37825. // fmt.Println(dat)
  37826. // } else {
  37827. // fmt.Println(err)
  37828. // }
  37829. // c.ServeSuccessJSON(map[string]interface{}{
  37830. // "list": res2.Output.Data,
  37831. // })
  37832. //}
  37833. }
  37834. func (c *HisApiController) ComfirmAllopatry() {
  37835. year := c.GetString("year")
  37836. month := c.GetString("month")
  37837. admin_user_id, _ := c.GetInt64("admin_user_id")
  37838. adminUser := c.GetAdminUserInfo()
  37839. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37840. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37841. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37842. var dat map[string]interface{}
  37843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37844. fmt.Println(dat)
  37845. } else {
  37846. fmt.Println(err)
  37847. }
  37848. userJSONBytes, _ := json.Marshal(dat)
  37849. var res models.Result9001
  37850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37851. utils.ErrorLog("解析失败:%v", err)
  37852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37853. return
  37854. }
  37855. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37856. var dat2 map[string]interface{}
  37857. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37858. fmt.Println(dat)
  37859. } else {
  37860. fmt.Println(err)
  37861. }
  37862. userJSONBytes2, _ := json.Marshal(dat2)
  37863. var res2 models.Result3260
  37864. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37865. utils.ErrorLog("解析失败:%v", err)
  37866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37867. return
  37868. }
  37869. //if res2.Infcode == 0 {
  37870. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37871. // var dat map[string]interface{}
  37872. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37873. // fmt.Println(dat)
  37874. // } else {
  37875. // fmt.Println(err)
  37876. // }
  37877. // userJSONBytes, _ := json.Marshal(dat)
  37878. // var res3 models.Result3261
  37879. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37880. // utils.ErrorLog("解析失败:%v", err)
  37881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37882. // return
  37883. // }
  37884. //
  37885. // if res3.Infcode == 0 {
  37886. // record := &models.HisYidiClearRecord{
  37887. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37888. // Ctime: time.Now().Unix(),
  37889. // Mtime: time.Now().Unix(),
  37890. // Status: 1,
  37891. // MsgId: msgId,
  37892. // }
  37893. // service.SaveClearRecord(record)
  37894. // c.ServeSuccessJSON(map[string]interface{}{
  37895. // "msg": "提取成功",
  37896. // })
  37897. // }
  37898. //}
  37899. }
  37900. func (c *HisApiController) RefundAllopatry() {
  37901. year := c.GetString("year")
  37902. month := c.GetString("month")
  37903. //id, _ := c.GetInt64("id")
  37904. admin_user_id, _ := c.GetInt64("admin_user_id")
  37905. adminUser := c.GetAdminUserInfo()
  37906. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37907. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37908. //record, _ := service.GetClearRecordById(id)
  37909. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37910. var dat map[string]interface{}
  37911. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37912. fmt.Println(dat)
  37913. } else {
  37914. fmt.Println(err)
  37915. }
  37916. userJSONBytes, _ := json.Marshal(dat)
  37917. var res models.Result9001
  37918. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37919. utils.ErrorLog("解析失败:%v", err)
  37920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37921. return
  37922. }
  37923. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37924. var dat2 map[string]interface{}
  37925. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37926. fmt.Println(dat)
  37927. } else {
  37928. fmt.Println(err)
  37929. }
  37930. userJSONBytes2, _ := json.Marshal(dat2)
  37931. var empty ResultFourteen
  37932. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37933. utils.ErrorLog("解析失败:%v", err)
  37934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37935. return
  37936. }
  37937. if empty.Infcode == 0 {
  37938. c.ServeSuccessJSON(map[string]interface{}{
  37939. "msg": "撤销成功",
  37940. })
  37941. return
  37942. }
  37943. }
  37944. func (c *HisApiController) ReversalOtherData() {
  37945. var customData []*CustomData
  37946. custom := &CustomData{
  37947. MsgId: "H44022900158202103301714472004",
  37948. PsnNo: "44020000001101329945",
  37949. Info: "2208",
  37950. }
  37951. customData = append(customData, custom)
  37952. custom1 := &CustomData{
  37953. MsgId: "H4402290015820210330172057803",
  37954. PsnNo: "44020000001101161813",
  37955. Info: "2208",
  37956. }
  37957. customData = append(customData, custom1)
  37958. custom2 := &CustomData{
  37959. MsgId: "H44022900158202103301705198813",
  37960. PsnNo: "44190000133097375417",
  37961. Info: "2208",
  37962. }
  37963. customData = append(customData, custom2)
  37964. custom3 := &CustomData{
  37965. MsgId: "H44022900158202103301715524756",
  37966. PsnNo: "44020000001100187221",
  37967. Info: "2208",
  37968. }
  37969. customData = append(customData, custom3)
  37970. custom4 := &CustomData{
  37971. MsgId: "H44022900158202103301730376224",
  37972. PsnNo: "44020000001101959155",
  37973. Info: "2208",
  37974. }
  37975. customData = append(customData, custom4)
  37976. custom5 := &CustomData{
  37977. MsgId: "H44022900158202103301748008725",
  37978. PsnNo: "44020000001104246641",
  37979. Info: "2208",
  37980. }
  37981. customData = append(customData, custom5)
  37982. custom6 := &CustomData{
  37983. MsgId: "H44022900158202103301718096755",
  37984. PsnNo: "44020000001102211860",
  37985. Info: "2208",
  37986. }
  37987. customData = append(customData, custom6)
  37988. custom7 := &CustomData{
  37989. MsgId: "H44022900158202103301736551640",
  37990. PsnNo: "44020000001102687718",
  37991. Info: "2208",
  37992. }
  37993. customData = append(customData, custom7)
  37994. custom8 := &CustomData{
  37995. MsgId: "H44022900158202103301743097676",
  37996. PsnNo: "44020000001102127785",
  37997. Info: "2208",
  37998. }
  37999. customData = append(customData, custom8)
  38000. custom9 := &CustomData{
  38001. MsgId: "H44022900158202103301712304203",
  38002. PsnNo: "44020000001101518097",
  38003. Info: "2208",
  38004. }
  38005. customData = append(customData, custom9)
  38006. custom10 := &CustomData{
  38007. MsgId: "H44022900158202103301738448785",
  38008. PsnNo: "44020000001100500813",
  38009. Info: "2208",
  38010. }
  38011. customData = append(customData, custom10)
  38012. custom11 := &CustomData{
  38013. MsgId: "H44022900158202103301732455843",
  38014. PsnNo: "44020000001102690557",
  38015. Info: "2208",
  38016. }
  38017. customData = append(customData, custom11)
  38018. custom12 := &CustomData{
  38019. MsgId: "H44022900158202103301745421708",
  38020. PsnNo: "44020000001102211928",
  38021. Info: "2208",
  38022. }
  38023. customData = append(customData, custom12)
  38024. custom1212 := &CustomData{
  38025. MsgId: "H440229001582021033017351627",
  38026. PsnNo: "44020000001102481733",
  38027. Info: "2208",
  38028. }
  38029. customData = append(customData, custom1212)
  38030. custom13 := &CustomData{
  38031. MsgId: "H44022900158202103301740327951",
  38032. PsnNo: "44020000001103174866",
  38033. Info: "2208",
  38034. }
  38035. customData = append(customData, custom13)
  38036. custom14 := &CustomData{
  38037. MsgId: "H4402290015820210330174922668",
  38038. PsnNo: "44020000001102927272",
  38039. Info: "2208",
  38040. }
  38041. customData = append(customData, custom14)
  38042. custom15 := &CustomData{
  38043. MsgId: "H44022900158202103301752362273",
  38044. PsnNo: "44020000001102942890",
  38045. Info: "2208",
  38046. }
  38047. customData = append(customData, custom15)
  38048. custom16 := &CustomData{
  38049. MsgId: "H44022900158202103301751082917",
  38050. PsnNo: "44020000001101662162",
  38051. Info: "2208",
  38052. }
  38053. customData = append(customData, custom16)
  38054. custom17 := &CustomData{
  38055. MsgId: "H44022900158202103301754147728",
  38056. PsnNo: "44020000000229014511",
  38057. Info: "2208",
  38058. }
  38059. customData = append(customData, custom17)
  38060. adminUser := c.GetAdminUserInfo()
  38061. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38062. for _, item := range customData {
  38063. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  38064. fmt.Println(result)
  38065. }
  38066. }
  38067. func PathExists(path string) (bool, error) {
  38068. _, err := os.Stat(path)
  38069. if err == nil {
  38070. return true, nil
  38071. }
  38072. if os.IsNotExist(err) {
  38073. return false, nil
  38074. }
  38075. return false, err
  38076. }
  38077. // 创建文件夹
  38078. func Mkdir(dir string) {
  38079. // 创建文件夹
  38080. exist, err := PathExists(dir)
  38081. if err != nil {
  38082. fmt.Println(err.Error())
  38083. } else {
  38084. if exist {
  38085. fmt.Println(dir + "文件夹已存在!")
  38086. } else {
  38087. // 文件夹名称,权限
  38088. err := os.Mkdir(dir, os.ModePerm)
  38089. if err != nil {
  38090. fmt.Println(dir+"文件夹创建失败:", err.Error())
  38091. } else {
  38092. fmt.Println(dir + "文件夹创建成功!")
  38093. }
  38094. }
  38095. }
  38096. }
  38097. // 压缩文件
  38098. func Zip(srcFile string, destZip string) error {
  38099. zipfile, err := os.Create(destZip)
  38100. if err != nil {
  38101. return err
  38102. }
  38103. defer zipfile.Close()
  38104. archive := zip.NewWriter(zipfile)
  38105. defer archive.Close()
  38106. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  38107. if err != nil {
  38108. return err
  38109. }
  38110. header, err := zip.FileInfoHeader(info)
  38111. if err != nil {
  38112. return err
  38113. }
  38114. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  38115. // header.Name = path
  38116. if info.IsDir() {
  38117. header.Name += "/"
  38118. } else {
  38119. header.Method = zip.Deflate
  38120. }
  38121. writer, err := archive.CreateHeader(header)
  38122. if err != nil {
  38123. return err
  38124. }
  38125. if !info.IsDir() {
  38126. file, err := os.Open(path)
  38127. if err != nil {
  38128. return err
  38129. }
  38130. defer file.Close()
  38131. _, err = io.Copy(writer, file)
  38132. }
  38133. return err
  38134. })
  38135. return err
  38136. }
  38137. func ReadFile(filePath string) []byte {
  38138. f, err := os.Open(filePath)
  38139. if err != nil {
  38140. fmt.Println("read file fail", err)
  38141. return nil
  38142. }
  38143. defer f.Close()
  38144. fd, err := ioutil.ReadAll(f)
  38145. if err != nil {
  38146. fmt.Println("read to fd fail", err)
  38147. return nil
  38148. }
  38149. return fd
  38150. }
  38151. func saveLogq(result string, request string, infno string, desc string) {
  38152. dir := "日志"
  38153. utils.Mkdir(dir)
  38154. month := time.Unix(1557042972, 0).Format("1")
  38155. year := time.Now().Format("2006")
  38156. month = time.Now().Format("01")
  38157. day := time.Now().Format("02")
  38158. hour := time.Now().Format("15")
  38159. min := time.Now().Format("04")
  38160. sec := time.Now().Format("05")
  38161. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  38162. file := year + month + day + "_log"
  38163. file_name := file + ".txt"
  38164. file_path := "日志" + "/" + file_name
  38165. exist, _ := utils.PathExists(file_path)
  38166. if exist { //存在
  38167. fmt.Println("存在")
  38168. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  38169. if err != nil {
  38170. fmt.Println("read fail")
  38171. }
  38172. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  38173. n, _ := f.Seek(0, 2)
  38174. _, err = f.WriteAt([]byte(content), n)
  38175. } else { //不存在
  38176. fmt.Println("文件不存在,创建文件")
  38177. f, err := os.Create("日志" + "/" + file_name)
  38178. defer f.Close()
  38179. if err != nil {
  38180. } else {
  38181. _, err = f.Write([]byte("记录日志"))
  38182. }
  38183. }
  38184. }
  38185. func saveLog(result string, request string, infno string, desc string) {
  38186. org_id, _ := beego.AppConfig.Int64("org_id")
  38187. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38188. dir := miConfig.OrgName + "日志"
  38189. utils.Mkdir(dir)
  38190. month := time.Unix(1557042972, 0).Format("1")
  38191. year := time.Now().Format("2006")
  38192. month = time.Now().Format("01")
  38193. day := time.Now().Format("02")
  38194. hour := time.Now().Format("15")
  38195. min := time.Now().Format("04")
  38196. sec := time.Now().Format("05")
  38197. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  38198. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  38199. file_name := file + ".txt"
  38200. file_path := miConfig.OrgName + "日志" + "/" + file_name
  38201. exist, _ := utils.PathExists(file_path)
  38202. if exist { //存在
  38203. fmt.Println("存在")
  38204. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  38205. if err != nil {
  38206. fmt.Println("read fail")
  38207. }
  38208. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  38209. n, _ := f.Seek(0, 2)
  38210. _, err = f.WriteAt([]byte(content), n)
  38211. } else { //不存在
  38212. fmt.Println("文件不存在,创建文件")
  38213. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  38214. defer f.Close()
  38215. if err != nil {
  38216. } else {
  38217. _, err = f.Write([]byte("记录日志"))
  38218. }
  38219. }
  38220. }
  38221. type Charset string
  38222. const (
  38223. UTF8 = Charset("UTF-8")
  38224. GB18030 = Charset("GB18030")
  38225. )
  38226. func ConvertToString(src string, srcCode string, tagCode string) string {
  38227. srcCoder := mahonia.NewDecoder(srcCode)
  38228. srcResult := srcCoder.ConvertString(src)
  38229. tagCoder := mahonia.NewDecoder(tagCode)
  38230. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  38231. result := string(cdata)
  38232. return result
  38233. }
  38234. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  38235. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  38236. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38237. var token string
  38238. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  38239. var api string
  38240. if miConfig.MdtrtareaAdmvs == "320921" {
  38241. 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 +
  38242. "&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
  38243. fmt.Println(api)
  38244. } else {
  38245. 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 +
  38246. "&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
  38247. }
  38248. resp, requestErr := http.Get(api)
  38249. if requestErr != nil {
  38250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38251. return ""
  38252. }
  38253. body, ioErr := ioutil.ReadAll(resp.Body)
  38254. if ioErr != nil {
  38255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38257. return ""
  38258. }
  38259. var respJSON map[string]interface{}
  38260. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38263. return ""
  38264. }
  38265. var status string
  38266. status = respJSON["data"].(map[string]interface{})["status"].(string)
  38267. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  38268. var res ResultTwo //1101结果
  38269. var res10265 ResultTwo10265 //1101结果
  38270. if status == "0" { //读卡成功
  38271. var card_info string //卡信息
  38272. var busi_card_info string
  38273. token = respJSON["data"].(map[string]interface{})["token"].(string)
  38274. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  38275. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  38276. fmt.Println(card_info)
  38277. fmt.Println(busi_card_info)
  38278. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  38279. result, _ := json.Marshal(respJSON)
  38280. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38281. utils.ErrorLog("解析失败:%v", err)
  38282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38283. return ""
  38284. }
  38285. res.ErrMsg = res10265.ErrMsg
  38286. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38287. res.Infcode = infocode
  38288. res.Output = res10265.Output
  38289. res.InfRefmsgid = res10265.InfRefmsgid
  38290. if res.Infcode == 0 {
  38291. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  38292. if err == gorm.ErrRecordNotFound {
  38293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  38294. return ""
  38295. } else if err != nil {
  38296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  38297. return ""
  38298. } else {
  38299. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38300. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  38301. infoStr := string(Iinfos)
  38302. idetinfoStr := string(Idetinfos)
  38303. psn := &models.HisPsn{
  38304. PsnNo: res.Output.Baseinfo.PsnNo,
  38305. PatientId: patient.ID,
  38306. Certno: res.Output.Baseinfo.Certno,
  38307. Gend: res.Output.Baseinfo.Gend,
  38308. Naty: res.Output.Baseinfo.Naty,
  38309. PsnCertType: res.Output.Baseinfo.PsnCertType,
  38310. PsnName: res.Output.Baseinfo.PsnName,
  38311. Idetinfo: idetinfoStr,
  38312. Insuinfo: infoStr,
  38313. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  38314. CardInfo: card_info,
  38315. VerifyNumber: token,
  38316. }
  38317. service.CreateHisPsn(psn)
  38318. return token
  38319. }
  38320. }
  38321. } else {
  38322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38323. return ""
  38324. }
  38325. } else { //读卡失败
  38326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38327. return ""
  38328. }
  38329. return token
  38330. }
  38331. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  38332. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  38333. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38334. var token string
  38335. var api string
  38336. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  38337. "&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
  38338. fmt.Println(api)
  38339. resp, requestErr := http.Get(api)
  38340. if requestErr != nil {
  38341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38342. return ""
  38343. }
  38344. body, ioErr := ioutil.ReadAll(resp.Body)
  38345. if ioErr != nil {
  38346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38348. return ""
  38349. }
  38350. var respJSON map[string]interface{}
  38351. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38354. return ""
  38355. }
  38356. var status string
  38357. status = respJSON["data"].(map[string]interface{})["status"].(string)
  38358. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  38359. var res ResultTwo //1101结果
  38360. if status == "1" { //读卡成功
  38361. var card_info string //卡信息
  38362. var busi_card_info string
  38363. token = respJSON["data"].(map[string]interface{})["token"].(string)
  38364. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  38365. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  38366. fmt.Println(card_info)
  38367. fmt.Println(busi_card_info)
  38368. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  38369. result, _ := json.Marshal(respJSON)
  38370. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38371. utils.ErrorLog("解析失败:%v", err)
  38372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38373. return ""
  38374. }
  38375. if res.Infcode == 0 {
  38376. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  38377. if err == gorm.ErrRecordNotFound {
  38378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  38379. return ""
  38380. } else if err != nil {
  38381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  38382. return ""
  38383. } else {
  38384. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38385. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  38386. infoStr := string(Iinfos)
  38387. idetinfoStr := string(Idetinfos)
  38388. psn := &models.HisPsn{
  38389. PsnNo: res.Output.Baseinfo.PsnNo,
  38390. PatientId: patient.ID,
  38391. Certno: res.Output.Baseinfo.Certno,
  38392. Gend: res.Output.Baseinfo.Gend,
  38393. Naty: res.Output.Baseinfo.Naty,
  38394. PsnCertType: res.Output.Baseinfo.PsnCertType,
  38395. PsnName: res.Output.Baseinfo.PsnName,
  38396. Idetinfo: idetinfoStr,
  38397. Insuinfo: infoStr,
  38398. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  38399. CardInfo: card_info,
  38400. VerifyNumber: token,
  38401. }
  38402. service.CreateHisPsn(psn)
  38403. return token
  38404. }
  38405. }
  38406. } else {
  38407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38408. return ""
  38409. }
  38410. return token
  38411. }
  38412. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  38413. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  38414. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38415. var token string
  38416. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  38417. var api string
  38418. if miConfig.MdtrtareaAdmvs == "320921" {
  38419. 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 +
  38420. "&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
  38421. fmt.Println(api)
  38422. } else {
  38423. 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 +
  38424. "&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
  38425. }
  38426. resp, requestErr := http.Get(api)
  38427. if requestErr != nil {
  38428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38429. return ""
  38430. }
  38431. body, ioErr := ioutil.ReadAll(resp.Body)
  38432. if ioErr != nil {
  38433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38435. return ""
  38436. }
  38437. var respJSON map[string]interface{}
  38438. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38441. return ""
  38442. }
  38443. var status string
  38444. status = respJSON["data"].(map[string]interface{})["status"].(string)
  38445. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  38446. var res ResultTwo //1101结果
  38447. var res10265 ResultTwo10265 //1101结果
  38448. if status == "0" { //读卡成功
  38449. var card_info string //卡信息
  38450. var busi_card_info string
  38451. token = respJSON["data"].(map[string]interface{})["token"].(string)
  38452. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  38453. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  38454. fmt.Println(card_info)
  38455. fmt.Println(busi_card_info)
  38456. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  38457. result, _ := json.Marshal(respJSON)
  38458. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38459. utils.ErrorLog("解析失败:%v", err)
  38460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38461. return ""
  38462. }
  38463. res.ErrMsg = res10265.ErrMsg
  38464. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38465. res.Infcode = infocode
  38466. res.Output = res10265.Output
  38467. res.InfRefmsgid = res10265.InfRefmsgid
  38468. if res.Infcode == 0 {
  38469. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  38470. if err == gorm.ErrRecordNotFound {
  38471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  38472. return ""
  38473. } else if err != nil {
  38474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  38475. return ""
  38476. } else {
  38477. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38478. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  38479. infoStr := string(Iinfos)
  38480. idetinfoStr := string(Idetinfos)
  38481. psn := &models.HisPsn{
  38482. PsnNo: res.Output.Baseinfo.PsnNo,
  38483. PatientId: patient.ID,
  38484. Certno: res.Output.Baseinfo.Certno,
  38485. Gend: res.Output.Baseinfo.Gend,
  38486. Naty: res.Output.Baseinfo.Naty,
  38487. PsnCertType: res.Output.Baseinfo.PsnCertType,
  38488. PsnName: res.Output.Baseinfo.PsnName,
  38489. Idetinfo: idetinfoStr,
  38490. Insuinfo: infoStr,
  38491. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  38492. CardInfo: card_info,
  38493. VerifyNumber: token,
  38494. }
  38495. service.CreateHisPsn(psn)
  38496. return token
  38497. }
  38498. }
  38499. } else {
  38500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38501. return ""
  38502. }
  38503. } else { //读卡失败
  38504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  38505. return ""
  38506. }
  38507. return token
  38508. }
  38509. func DeleteExtraSpaceTwo(s string) string {
  38510. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  38511. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  38512. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  38513. reg, _ := regexp.Compile(regstr) //编译正则表达式
  38514. s2 := make([]byte, len(s1)) //定义字符数组切片
  38515. copy(s2, s1) //将字符串复制到切片
  38516. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  38517. for len(spc_index) > 0 { //找到适配项
  38518. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  38519. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  38520. }
  38521. return string(s2)
  38522. }
  38523. func Remove0000(s string) string {
  38524. str := make([]rune, 0, len(s))
  38525. for _, v := range []rune(s) {
  38526. if v == 0 {
  38527. continue
  38528. }
  38529. str = append(str, v)
  38530. }
  38531. return string(str)
  38532. }
  38533. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  38534. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  38535. readCard := DllDef.MustFindProc("EcQuery")
  38536. pCardInfo := make([]byte, 8192)
  38537. pBusiCardInfo := make([]byte, 8192)
  38538. data := make(map[string]interface{})
  38539. //pData := make(map[string]interface{})
  38540. inputData := make(map[string]interface{})
  38541. inputData["orgId"] = code
  38542. inputData["businessType"] = "01101"
  38543. inputData["operatorId"] = operator_id
  38544. inputData["operatorName"] = operator_name
  38545. inputData["officeId"] = "001"
  38546. inputData["officeName"] = "血透室"
  38547. //
  38548. data["data"] = inputData
  38549. data["transType"] = "ec.query"
  38550. data["orgId"] = code
  38551. bytesData, _ := json.Marshal(data)
  38552. pCardInfo = bytesData
  38553. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  38554. fmt.Println(ret2)
  38555. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  38556. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  38557. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  38558. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  38559. if ret2 != 0 {
  38560. return "", ""
  38561. }
  38562. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  38563. }
  38564. func DeleteExtraSpace(s string) string {
  38565. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  38566. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  38567. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  38568. reg, _ := regexp.Compile(regstr) //编译正则表达式
  38569. s2 := make([]byte, len(s1)) //定义字符数组切片
  38570. copy(s2, s1) //将字符串复制到切片
  38571. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  38572. for len(spc_index) > 0 { //找到适配项
  38573. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  38574. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  38575. }
  38576. return string(s2)
  38577. }
  38578. // 对账
  38579. func (c *HisApiController) Post3202() {
  38580. start_time := c.GetString("start_time")
  38581. end_time := c.GetString("end_time")
  38582. //insutype := c.GetString("insutype")
  38583. clr_type := c.GetString("clr_type")
  38584. clr_org := c.GetString("clr_optins")
  38585. admin_user_id, _ := c.GetInt64("admin_user_id")
  38586. adminUser := c.GetAdminUserInfo()
  38587. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38588. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38589. if len(clr_org) == 0 {
  38590. clr_org = miConfig.MdtrtareaAdmvs
  38591. }
  38592. timeLayout := "2006-01-02"
  38593. loc, _ := time.LoadLocation("Local")
  38594. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38595. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38596. var orders []*models.HisOrder
  38597. if clr_org == "421300" {
  38598. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38599. } else if clr_org == "420902" {
  38600. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38601. } else {
  38602. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38603. }
  38604. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38605. //fixmedins_setl_cnt := int64(len(orders))
  38606. var medfee_sumamt float64
  38607. var acct_pay float64
  38608. var fund_pay_sumamt float64
  38609. for _, item := range orders {
  38610. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38611. acct_pay = acct_pay + item.AcctPay
  38612. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38613. }
  38614. //var medfee_sumamt_two float64
  38615. //var acct_pay_two float64
  38616. //var fund_pay_sumamt_two float64
  38617. //for _, item := range orders_two {
  38618. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38619. // acct_pay_two = acct_pay_two + item.AcctPay
  38620. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38621. //}
  38622. //var user_name string
  38623. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38624. //if role.ID == 0 {
  38625. // user_name = "xxx"
  38626. //} else {
  38627. // user_name = role.UserName
  38628. //}
  38629. var res ResultSix
  38630. if config.IsOpen == 1 {
  38631. var bps []*models.BusinessParamsTwo
  38632. var bp models.BusinessParamsTwo
  38633. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38634. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38635. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38636. bp.MedfeeSumamt = medfee_sumamt_str
  38637. bp.AcctPay = acct_pay_str
  38638. bp.FundPaySumamt = fund_pay_sumamt_str
  38639. bp.Insutype = ""
  38640. bp.StmtBegndate = start_time
  38641. bp.ClrType = clr_type
  38642. bp.SetlOptins = clr_org
  38643. bp.StmtEnddate = end_time
  38644. bps = append(bps, &bp)
  38645. data := make(map[string]interface{})
  38646. data["bps"] = bps
  38647. data["org_name"] = miConfig.OrgName
  38648. data["doctor"] = role.UserName
  38649. data["fixmedins_code"] = miConfig.Code
  38650. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38651. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38652. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38653. if miConfig.MdtrtareaAdmvs == "421300" {
  38654. client := &http.Client{}
  38655. bytesData, _ := json.Marshal(data)
  38656. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  38657. resp, _ := client.Do(req)
  38658. defer resp.Body.Close()
  38659. body, ioErr := ioutil.ReadAll(resp.Body)
  38660. if ioErr != nil {
  38661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38663. return
  38664. }
  38665. var respJSON map[string]interface{}
  38666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38669. return
  38670. }
  38671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38672. userJSONBytes, _ := json.Marshal(respJSON)
  38673. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38674. utils.ErrorLog("解析失败:%v", err)
  38675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38676. return
  38677. }
  38678. }
  38679. if miConfig.MdtrtareaAdmvs == "420200" {
  38680. client := &http.Client{}
  38681. bytesData, _ := json.Marshal(data)
  38682. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  38683. resp, _ := client.Do(req)
  38684. defer resp.Body.Close()
  38685. body, ioErr := ioutil.ReadAll(resp.Body)
  38686. if ioErr != nil {
  38687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38689. return
  38690. }
  38691. var respJSON map[string]interface{}
  38692. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38695. return
  38696. }
  38697. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38698. userJSONBytes, _ := json.Marshal(respJSON)
  38699. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38700. utils.ErrorLog("解析失败:%v", err)
  38701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38702. return
  38703. }
  38704. }
  38705. if miConfig.MdtrtareaAdmvs == "421182" {
  38706. client := &http.Client{}
  38707. bytesData, _ := json.Marshal(data)
  38708. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38709. resp, _ := client.Do(req)
  38710. defer resp.Body.Close()
  38711. body, ioErr := ioutil.ReadAll(resp.Body)
  38712. if ioErr != nil {
  38713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38715. return
  38716. }
  38717. var respJSON map[string]interface{}
  38718. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38721. return
  38722. }
  38723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38724. userJSONBytes, _ := json.Marshal(respJSON)
  38725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38726. utils.ErrorLog("解析失败:%v", err)
  38727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38728. return
  38729. }
  38730. }
  38731. if miConfig.MdtrtareaAdmvs == "420902" {
  38732. client := &http.Client{}
  38733. bytesData, _ := json.Marshal(data)
  38734. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38735. resp, _ := client.Do(req)
  38736. defer resp.Body.Close()
  38737. body, ioErr := ioutil.ReadAll(resp.Body)
  38738. if ioErr != nil {
  38739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38741. return
  38742. }
  38743. var respJSON map[string]interface{}
  38744. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38747. return
  38748. }
  38749. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38750. userJSONBytes, _ := json.Marshal(respJSON)
  38751. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38752. utils.ErrorLog("解析失败:%v", err)
  38753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38754. return
  38755. }
  38756. }
  38757. if res.Infcode == 0 {
  38758. c.ServeSuccessJSON(map[string]interface{}{
  38759. "msg": "发起成功",
  38760. })
  38761. } else {
  38762. c.ServeSuccessJSON(map[string]interface{}{
  38763. "failed_code": -10,
  38764. "msg": res.ErrMsg,
  38765. })
  38766. }
  38767. }
  38768. }
  38769. func (c *HisApiController) Post3204a() {
  38770. start_time := c.GetString("start_time")
  38771. end_time := c.GetString("end_time")
  38772. //insutype := c.GetString("insutype")
  38773. clr_type := c.GetString("clr_type")
  38774. clr_org := c.GetString("clr_optins")
  38775. admin_user_id, _ := c.GetInt64("admin_user_id")
  38776. adminUser := c.GetAdminUserInfo()
  38777. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38778. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38779. if len(clr_org) == 0 {
  38780. clr_org = miConfig.MdtrtareaAdmvs
  38781. }
  38782. timeLayout := "2006-01-02"
  38783. loc, _ := time.LoadLocation("Local")
  38784. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38785. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38786. var orders []*models.HisOrder
  38787. if clr_org == "421300" {
  38788. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38789. } else if clr_org == "420902" {
  38790. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38791. } else {
  38792. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38793. }
  38794. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38795. //fixmedins_setl_cnt := int64(len(orders))
  38796. var medfee_sumamt float64
  38797. var acct_pay float64
  38798. var fund_pay_sumamt float64
  38799. for _, item := range orders {
  38800. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38801. acct_pay = acct_pay + item.AcctPay
  38802. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38803. }
  38804. //var medfee_sumamt_two float64
  38805. //var acct_pay_two float64
  38806. //var fund_pay_sumamt_two float64
  38807. //for _, item := range orders_two {
  38808. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38809. // acct_pay_two = acct_pay_two + item.AcctPay
  38810. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38811. //}
  38812. //var user_name string
  38813. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38814. //if role.ID == 0 {
  38815. // user_name = "xxx"
  38816. //} else {
  38817. // user_name = role.UserName
  38818. //}
  38819. var res ResultSix
  38820. if config.IsOpen == 1 {
  38821. var bps []*models.BusinessParamsTwo
  38822. var bp models.BusinessParamsTwo
  38823. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38824. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38825. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38826. bp.MedfeeSumamt = medfee_sumamt_str
  38827. bp.AcctPay = acct_pay_str
  38828. bp.FundPaySumamt = fund_pay_sumamt_str
  38829. bp.Insutype = ""
  38830. bp.StmtBegndate = start_time
  38831. bp.ClrType = clr_type
  38832. bp.SetlOptins = clr_org
  38833. bp.StmtEnddate = end_time
  38834. bps = append(bps, &bp)
  38835. data := make(map[string]interface{})
  38836. data["bps"] = bps
  38837. data["org_name"] = miConfig.OrgName
  38838. data["doctor"] = role.UserName
  38839. data["fixmedins_code"] = miConfig.Code
  38840. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38841. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38842. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38843. if miConfig.MdtrtareaAdmvs == "421300" {
  38844. client := &http.Client{}
  38845. bytesData, _ := json.Marshal(data)
  38846. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38847. resp, _ := client.Do(req)
  38848. defer resp.Body.Close()
  38849. body, ioErr := ioutil.ReadAll(resp.Body)
  38850. if ioErr != nil {
  38851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38853. return
  38854. }
  38855. var respJSON map[string]interface{}
  38856. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38859. return
  38860. }
  38861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38862. userJSONBytes, _ := json.Marshal(respJSON)
  38863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38864. utils.ErrorLog("解析失败:%v", err)
  38865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38866. return
  38867. }
  38868. }
  38869. if miConfig.MdtrtareaAdmvs == "420200" {
  38870. client := &http.Client{}
  38871. bytesData, _ := json.Marshal(data)
  38872. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38873. resp, _ := client.Do(req)
  38874. defer resp.Body.Close()
  38875. body, ioErr := ioutil.ReadAll(resp.Body)
  38876. if ioErr != nil {
  38877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38879. return
  38880. }
  38881. var respJSON map[string]interface{}
  38882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38885. return
  38886. }
  38887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38888. userJSONBytes, _ := json.Marshal(respJSON)
  38889. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38890. utils.ErrorLog("解析失败:%v", err)
  38891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38892. return
  38893. }
  38894. }
  38895. if miConfig.MdtrtareaAdmvs == "421182" {
  38896. client := &http.Client{}
  38897. bytesData, _ := json.Marshal(data)
  38898. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38899. resp, _ := client.Do(req)
  38900. defer resp.Body.Close()
  38901. body, ioErr := ioutil.ReadAll(resp.Body)
  38902. if ioErr != nil {
  38903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38905. return
  38906. }
  38907. var respJSON map[string]interface{}
  38908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38911. return
  38912. }
  38913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38914. userJSONBytes, _ := json.Marshal(respJSON)
  38915. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38916. utils.ErrorLog("解析失败:%v", err)
  38917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38918. return
  38919. }
  38920. }
  38921. if miConfig.MdtrtareaAdmvs == "420902" {
  38922. client := &http.Client{}
  38923. bytesData, _ := json.Marshal(data)
  38924. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38925. resp, _ := client.Do(req)
  38926. defer resp.Body.Close()
  38927. body, ioErr := ioutil.ReadAll(resp.Body)
  38928. if ioErr != nil {
  38929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38931. return
  38932. }
  38933. var respJSON map[string]interface{}
  38934. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38937. return
  38938. }
  38939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38940. userJSONBytes, _ := json.Marshal(respJSON)
  38941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38942. utils.ErrorLog("解析失败:%v", err)
  38943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38944. return
  38945. }
  38946. }
  38947. if res.Infcode == 0 {
  38948. c.ServeSuccessJSON(map[string]interface{}{
  38949. "msg": "撤销成功",
  38950. })
  38951. } else {
  38952. c.ServeSuccessJSON(map[string]interface{}{
  38953. "failed_code": -10,
  38954. "msg": res.ErrMsg,
  38955. })
  38956. }
  38957. }
  38958. }
  38959. func (c *HisApiController) Post3204() {
  38960. admin_user_id, _ := c.GetInt64("admin_user_id")
  38961. id := c.GetString("id")
  38962. adminUser := c.GetAdminUserInfo()
  38963. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38964. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38965. //clr_org := miConfig.MdtrtareaAdmvs
  38966. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38967. var res ResultSix
  38968. if config.IsOpen == 1 {
  38969. data := make(map[string]interface{})
  38970. data["id"] = id
  38971. data["org_name"] = miConfig.OrgName
  38972. data["doctor"] = role.UserName
  38973. data["fixmedins_code"] = miConfig.Code
  38974. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38975. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38976. client := &http.Client{}
  38977. bytesData, _ := json.Marshal(data)
  38978. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38979. resp, _ := client.Do(req)
  38980. defer resp.Body.Close()
  38981. body, ioErr := ioutil.ReadAll(resp.Body)
  38982. if ioErr != nil {
  38983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38985. return
  38986. }
  38987. var respJSON map[string]interface{}
  38988. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38991. return
  38992. }
  38993. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38994. userJSONBytes, _ := json.Marshal(respJSON)
  38995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38996. utils.ErrorLog("解析失败:%v", err)
  38997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38998. return
  38999. }
  39000. if res.Infcode == 0 {
  39001. c.ServeSuccessJSON(map[string]interface{}{
  39002. "msg": "发起成功",
  39003. })
  39004. } else {
  39005. c.ServeSuccessJSON(map[string]interface{}{
  39006. "failed_code": -10,
  39007. "msg": res.ErrMsg,
  39008. })
  39009. }
  39010. }
  39011. }
  39012. func (c *HisApiController) Post8404() {
  39013. admin_user_id, _ := c.GetInt64("admin_user_id")
  39014. month := c.GetString("month")
  39015. adminUser := c.GetAdminUserInfo()
  39016. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39017. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39018. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39019. var res ResultSix
  39020. if config.IsOpen == 1 {
  39021. data := make(map[string]interface{})
  39022. data["month"] = month
  39023. data["org_name"] = miConfig.OrgName
  39024. data["doctor"] = role.UserName
  39025. data["fixmedins_code"] = miConfig.Code
  39026. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39027. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39028. client := &http.Client{}
  39029. bytesData, _ := json.Marshal(data)
  39030. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  39031. resp, _ := client.Do(req)
  39032. defer resp.Body.Close()
  39033. body, ioErr := ioutil.ReadAll(resp.Body)
  39034. if ioErr != nil {
  39035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39037. return
  39038. }
  39039. var respJSON map[string]interface{}
  39040. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39043. return
  39044. }
  39045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39046. userJSONBytes, _ := json.Marshal(respJSON)
  39047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39048. utils.ErrorLog("解析失败:%v", err)
  39049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39050. return
  39051. }
  39052. if res.Infcode == 0 {
  39053. c.ServeSuccessJSON(map[string]interface{}{
  39054. "msg": "查询成功",
  39055. })
  39056. } else {
  39057. c.ServeSuccessJSON(map[string]interface{}{
  39058. "failed_code": -10,
  39059. "msg": res.ErrMsg,
  39060. })
  39061. }
  39062. }
  39063. }
  39064. func (c *HisApiController) Post3202b() {
  39065. start_time := c.GetString("start_time")
  39066. end_time := c.GetString("end_time")
  39067. //insutype := c.GetString("insutype")
  39068. clr_type := c.GetString("clr_type")
  39069. clr_org := c.GetString("clr_optins")
  39070. admin_user_id, _ := c.GetInt64("admin_user_id")
  39071. adminUser := c.GetAdminUserInfo()
  39072. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39073. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39074. if len(clr_org) == 0 {
  39075. clr_org = miConfig.MdtrtareaAdmvs
  39076. }
  39077. timeLayout := "2006-01-02"
  39078. loc, _ := time.LoadLocation("Local")
  39079. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39080. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39081. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39082. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39083. //fixmedins_setl_cnt := int64(len(orders))
  39084. var medfee_sumamt float64
  39085. var acct_pay float64
  39086. var fund_pay_sumamt float64
  39087. for _, item := range orders {
  39088. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39089. acct_pay = acct_pay + item.AcctPay
  39090. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39091. }
  39092. //var medfee_sumamt_two float64
  39093. //var acct_pay_two float64
  39094. //var fund_pay_sumamt_two float64
  39095. //for _, item := range orders_two {
  39096. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39097. // acct_pay_two = acct_pay_two + item.AcctPay
  39098. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39099. //}
  39100. //var user_name string
  39101. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39102. //if role.ID == 0 {
  39103. // user_name = "xxx"
  39104. //} else {
  39105. // user_name = role.UserName
  39106. //}
  39107. var res ResultSix
  39108. if config.IsOpen == 1 {
  39109. var bps []*models.BusinessParamsTwo
  39110. var bp models.BusinessParamsTwo
  39111. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39112. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39113. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39114. bp.MedfeeSumamt = medfee_sumamt_str
  39115. bp.AcctPay = acct_pay_str
  39116. bp.FundPaySumamt = fund_pay_sumamt_str
  39117. bp.Insutype = "390"
  39118. bp.StmtBegndate = start_time
  39119. bp.ClrType = clr_type
  39120. bp.SetlOptins = clr_org
  39121. bp.StmtEnddate = end_time
  39122. bps = append(bps, &bp)
  39123. data := make(map[string]interface{})
  39124. data["bps"] = bps
  39125. data["org_name"] = miConfig.OrgName
  39126. data["doctor"] = role.UserName
  39127. data["fixmedins_code"] = miConfig.Code
  39128. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39129. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39130. if miConfig.MdtrtareaAdmvs == "421300" {
  39131. client := &http.Client{}
  39132. bytesData, _ := json.Marshal(data)
  39133. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  39134. resp, _ := client.Do(req)
  39135. defer resp.Body.Close()
  39136. body, ioErr := ioutil.ReadAll(resp.Body)
  39137. if ioErr != nil {
  39138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39140. return
  39141. }
  39142. var respJSON map[string]interface{}
  39143. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39146. return
  39147. }
  39148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39149. userJSONBytes, _ := json.Marshal(respJSON)
  39150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39151. utils.ErrorLog("解析失败:%v", err)
  39152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39153. return
  39154. }
  39155. }
  39156. if miConfig.MdtrtareaAdmvs == "420200" {
  39157. client := &http.Client{}
  39158. bytesData, _ := json.Marshal(data)
  39159. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  39160. resp, _ := client.Do(req)
  39161. defer resp.Body.Close()
  39162. body, ioErr := ioutil.ReadAll(resp.Body)
  39163. if ioErr != nil {
  39164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39166. return
  39167. }
  39168. var respJSON map[string]interface{}
  39169. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39172. return
  39173. }
  39174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39175. userJSONBytes, _ := json.Marshal(respJSON)
  39176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39177. utils.ErrorLog("解析失败:%v", err)
  39178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39179. return
  39180. }
  39181. }
  39182. if miConfig.MdtrtareaAdmvs == "421182" {
  39183. client := &http.Client{}
  39184. bytesData, _ := json.Marshal(data)
  39185. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  39186. resp, _ := client.Do(req)
  39187. defer resp.Body.Close()
  39188. body, ioErr := ioutil.ReadAll(resp.Body)
  39189. if ioErr != nil {
  39190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39192. return
  39193. }
  39194. var respJSON map[string]interface{}
  39195. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39198. return
  39199. }
  39200. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39201. userJSONBytes, _ := json.Marshal(respJSON)
  39202. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39203. utils.ErrorLog("解析失败:%v", err)
  39204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39205. return
  39206. }
  39207. }
  39208. if res.Infcode == 0 {
  39209. c.ServeSuccessJSON(map[string]interface{}{
  39210. "msg": "发起成功",
  39211. })
  39212. } else {
  39213. c.ServeSuccessJSON(map[string]interface{}{
  39214. "failed_code": -10,
  39215. "msg": res.ErrMsg,
  39216. })
  39217. }
  39218. }
  39219. }
  39220. func (c *HisApiController) Post1608() {
  39221. start_time := c.GetString("start_time")
  39222. end_time := c.GetString("end_time")
  39223. admin_user_id, _ := c.GetInt64("admin_user_id")
  39224. adminUser := c.GetAdminUserInfo()
  39225. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39226. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39227. timeLayout := "2006-01-02"
  39228. loc, _ := time.LoadLocation("Local")
  39229. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39230. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39231. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39232. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39233. fixmedins_setl_cnt := int64(len(orders))
  39234. var medfee_sumamt float64
  39235. var func_smamt float64
  39236. for _, item := range orders {
  39237. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39238. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  39239. }
  39240. times := strings.Split(start_time, "-")
  39241. time_tows := strings.Split(end_time, "-")
  39242. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39243. var res ResultSix
  39244. if config.IsOpen == 1 {
  39245. //var bps []*models.BusinessParamsTwo
  39246. //var bp models.BusinessParamsTwo
  39247. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39248. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  39249. data := make(map[string]interface{})
  39250. data["org_name"] = miConfig.OrgName
  39251. data["doctor"] = role.UserName
  39252. data["func_smamt"] = func_smamt_str
  39253. data["fixmedins_code"] = miConfig.Code
  39254. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39255. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39256. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  39257. data["medfee_sumamt"] = medfee_sumamt_str
  39258. data["start_time"] = times[0] + times[1] + times[2]
  39259. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  39260. if miConfig.MdtrtareaAdmvs == "421300" {
  39261. client := &http.Client{}
  39262. bytesData, _ := json.Marshal(data)
  39263. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  39264. resp, _ := client.Do(req)
  39265. defer resp.Body.Close()
  39266. body, ioErr := ioutil.ReadAll(resp.Body)
  39267. if ioErr != nil {
  39268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39270. return
  39271. }
  39272. var respJSON map[string]interface{}
  39273. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39276. return
  39277. }
  39278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39279. userJSONBytes, _ := json.Marshal(respJSON)
  39280. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39281. utils.ErrorLog("解析失败:%v", err)
  39282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39283. return
  39284. }
  39285. }
  39286. if miConfig.MdtrtareaAdmvs == "420200" {
  39287. client := &http.Client{}
  39288. bytesData, _ := json.Marshal(data)
  39289. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  39290. resp, _ := client.Do(req)
  39291. defer resp.Body.Close()
  39292. body, ioErr := ioutil.ReadAll(resp.Body)
  39293. if ioErr != nil {
  39294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39296. return
  39297. }
  39298. var respJSON map[string]interface{}
  39299. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39302. return
  39303. }
  39304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39305. userJSONBytes, _ := json.Marshal(respJSON)
  39306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39307. utils.ErrorLog("解析失败:%v", err)
  39308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39309. return
  39310. }
  39311. }
  39312. if miConfig.MdtrtareaAdmvs == "421182" {
  39313. client := &http.Client{}
  39314. bytesData, _ := json.Marshal(data)
  39315. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  39316. resp, _ := client.Do(req)
  39317. defer resp.Body.Close()
  39318. body, ioErr := ioutil.ReadAll(resp.Body)
  39319. if ioErr != nil {
  39320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39322. return
  39323. }
  39324. var respJSON map[string]interface{}
  39325. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39328. return
  39329. }
  39330. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39331. userJSONBytes, _ := json.Marshal(respJSON)
  39332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39333. utils.ErrorLog("解析失败:%v", err)
  39334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39335. return
  39336. }
  39337. }
  39338. if res.Infcode == 0 {
  39339. c.ServeSuccessJSON(map[string]interface{}{
  39340. "msg": "发起成功",
  39341. })
  39342. } else {
  39343. c.ServeSuccessJSON(map[string]interface{}{
  39344. "failed_code": -10,
  39345. "msg": res.ErrMsg,
  39346. })
  39347. }
  39348. }
  39349. }
  39350. // 5.11.1.1【5262】结算信息按时间段查询
  39351. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  39352. admin_user_id, _ := c.GetInt64("admin_user_id")
  39353. adminUser := c.GetAdminUserInfo()
  39354. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39355. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39356. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39357. var res Result5262
  39358. if config.IsOpen == 1 {
  39359. if miConfig.MdtrtareaAdmvs == "421300" {
  39360. data := make(map[string]interface{})
  39361. data["bps"] = bp
  39362. data["org_name"] = miConfig.OrgName
  39363. data["doctor"] = role.UserName
  39364. data["fixmedins_code"] = miConfig.Code
  39365. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39366. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39367. data["page"] = strconv.FormatInt(page, 10)
  39368. data["limit"] = strconv.FormatInt(limit, 10)
  39369. fmt.Println(data)
  39370. client := &http.Client{}
  39371. bytesData, _ := json.Marshal(data)
  39372. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  39373. resp, _ := client.Do(req)
  39374. defer resp.Body.Close()
  39375. body, ioErr := ioutil.ReadAll(resp.Body)
  39376. if ioErr != nil {
  39377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39379. return
  39380. }
  39381. var respJSON map[string]interface{}
  39382. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39385. return
  39386. }
  39387. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39388. userJSONBytes, _ := json.Marshal(respJSON)
  39389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39390. utils.ErrorLog("解析失败:%v", err)
  39391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39392. return
  39393. }
  39394. }
  39395. if miConfig.MdtrtareaAdmvs == "420200" {
  39396. data := make(map[string]interface{})
  39397. data["bps"] = bp
  39398. data["org_name"] = miConfig.OrgName
  39399. data["doctor"] = role.UserName
  39400. data["fixmedins_code"] = miConfig.Code
  39401. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39402. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39403. data["page"] = strconv.FormatInt(page, 10)
  39404. data["limit"] = strconv.FormatInt(limit, 10)
  39405. fmt.Println(data)
  39406. client := &http.Client{}
  39407. bytesData, _ := json.Marshal(data)
  39408. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  39409. resp, _ := client.Do(req)
  39410. defer resp.Body.Close()
  39411. body, ioErr := ioutil.ReadAll(resp.Body)
  39412. if ioErr != nil {
  39413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39415. return
  39416. }
  39417. var respJSON map[string]interface{}
  39418. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39421. return
  39422. }
  39423. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39424. userJSONBytes, _ := json.Marshal(respJSON)
  39425. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39426. utils.ErrorLog("解析失败:%v", err)
  39427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39428. return
  39429. }
  39430. }
  39431. if miConfig.MdtrtareaAdmvs == "421182" {
  39432. data := make(map[string]interface{})
  39433. data["bps"] = bp
  39434. data["org_name"] = miConfig.OrgName
  39435. data["doctor"] = role.UserName
  39436. data["fixmedins_code"] = miConfig.Code
  39437. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39438. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39439. data["page"] = strconv.FormatInt(page, 10)
  39440. data["limit"] = strconv.FormatInt(limit, 10)
  39441. fmt.Println(data)
  39442. client := &http.Client{}
  39443. bytesData, _ := json.Marshal(data)
  39444. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  39445. resp, _ := client.Do(req)
  39446. defer resp.Body.Close()
  39447. body, ioErr := ioutil.ReadAll(resp.Body)
  39448. if ioErr != nil {
  39449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39451. return
  39452. }
  39453. var respJSON map[string]interface{}
  39454. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39457. return
  39458. }
  39459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39460. userJSONBytes, _ := json.Marshal(respJSON)
  39461. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39462. utils.ErrorLog("解析失败:%v", err)
  39463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39464. return
  39465. }
  39466. }
  39467. if miConfig.MdtrtareaAdmvs == "420902" {
  39468. data := make(map[string]interface{})
  39469. data["bps"] = bp
  39470. data["org_name"] = miConfig.OrgName
  39471. data["doctor"] = role.UserName
  39472. data["fixmedins_code"] = miConfig.Code
  39473. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39474. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39475. data["page"] = strconv.FormatInt(page, 10)
  39476. data["limit"] = strconv.FormatInt(limit, 10)
  39477. fmt.Println(data)
  39478. client := &http.Client{}
  39479. bytesData, _ := json.Marshal(data)
  39480. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  39481. resp, _ := client.Do(req)
  39482. defer resp.Body.Close()
  39483. body, ioErr := ioutil.ReadAll(resp.Body)
  39484. if ioErr != nil {
  39485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39487. return
  39488. }
  39489. var respJSON map[string]interface{}
  39490. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39493. return
  39494. }
  39495. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39496. userJSONBytes, _ := json.Marshal(respJSON)
  39497. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39498. utils.ErrorLog("解析失败:%v", err)
  39499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39500. return
  39501. }
  39502. }
  39503. if res.Infcode == 0 {
  39504. c.ServeSuccessJSON(map[string]interface{}{
  39505. "order": res.Output.Result,
  39506. "total": res.Output.PageInfo.RecordCounts,
  39507. })
  39508. } else {
  39509. c.ServeSuccessJSON(map[string]interface{}{
  39510. "failed_code": -10,
  39511. "msg": res.ErrMsg,
  39512. })
  39513. }
  39514. }
  39515. }
  39516. // 5.11.1.2【5267】异地结算信息时间段查询
  39517. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  39518. admin_user_id, _ := c.GetInt64("admin_user_id")
  39519. adminUser := c.GetAdminUserInfo()
  39520. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39521. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39522. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39523. var res Result5267
  39524. if config.IsOpen == 1 {
  39525. if miConfig.MdtrtareaAdmvs == "421300" {
  39526. data := make(map[string]interface{})
  39527. data["bps"] = bp
  39528. data["org_name"] = miConfig.OrgName
  39529. data["doctor"] = role.UserName
  39530. data["fixmedins_code"] = miConfig.Code
  39531. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39532. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39533. data["page"] = page
  39534. data["limit"] = limit
  39535. fmt.Println(data)
  39536. client := &http.Client{}
  39537. bytesData, _ := json.Marshal(data)
  39538. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  39539. resp, _ := client.Do(req)
  39540. defer resp.Body.Close()
  39541. body, ioErr := ioutil.ReadAll(resp.Body)
  39542. if ioErr != nil {
  39543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39545. return
  39546. }
  39547. var respJSON map[string]interface{}
  39548. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39551. return
  39552. }
  39553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39554. userJSONBytes, _ := json.Marshal(respJSON)
  39555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39556. utils.ErrorLog("解析失败:%v", err)
  39557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39558. return
  39559. }
  39560. }
  39561. if miConfig.MdtrtareaAdmvs == "420200" {
  39562. data := make(map[string]interface{})
  39563. data["bps"] = bp
  39564. data["org_name"] = miConfig.OrgName
  39565. data["doctor"] = role.UserName
  39566. data["fixmedins_code"] = miConfig.Code
  39567. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39568. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39569. data["page"] = page
  39570. data["limit"] = limit
  39571. fmt.Println(data)
  39572. client := &http.Client{}
  39573. bytesData, _ := json.Marshal(data)
  39574. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  39575. resp, _ := client.Do(req)
  39576. defer resp.Body.Close()
  39577. body, ioErr := ioutil.ReadAll(resp.Body)
  39578. if ioErr != nil {
  39579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39581. return
  39582. }
  39583. var respJSON map[string]interface{}
  39584. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39587. return
  39588. }
  39589. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39590. userJSONBytes, _ := json.Marshal(respJSON)
  39591. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39592. utils.ErrorLog("解析失败:%v", err)
  39593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39594. return
  39595. }
  39596. }
  39597. if miConfig.MdtrtareaAdmvs == "421182" {
  39598. data := make(map[string]interface{})
  39599. data["bps"] = bp
  39600. data["org_name"] = miConfig.OrgName
  39601. data["doctor"] = role.UserName
  39602. data["fixmedins_code"] = miConfig.Code
  39603. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39604. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39605. data["page"] = page
  39606. data["limit"] = limit
  39607. fmt.Println(data)
  39608. client := &http.Client{}
  39609. bytesData, _ := json.Marshal(data)
  39610. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  39611. resp, _ := client.Do(req)
  39612. defer resp.Body.Close()
  39613. body, ioErr := ioutil.ReadAll(resp.Body)
  39614. if ioErr != nil {
  39615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39617. return
  39618. }
  39619. var respJSON map[string]interface{}
  39620. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39623. return
  39624. }
  39625. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39626. userJSONBytes, _ := json.Marshal(respJSON)
  39627. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39628. utils.ErrorLog("解析失败:%v", err)
  39629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39630. return
  39631. }
  39632. }
  39633. if res.Infcode == 0 {
  39634. c.ServeSuccessJSON(map[string]interface{}{
  39635. "order": res.Output.Result,
  39636. "total": res.Output.PageInfo.RecordCounts,
  39637. })
  39638. } else {
  39639. c.ServeSuccessJSON(map[string]interface{}{
  39640. "failed_code": -10,
  39641. "msg": res.ErrMsg,
  39642. })
  39643. }
  39644. }
  39645. }
  39646. func (c *HisApiController) Post3501() {
  39647. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39648. data := make(map[string]interface{})
  39649. var struct3501s []models.Struct3501
  39650. var struct3501 models.Struct3501
  39651. struct3501.OrgName = miConfig.OrgName
  39652. struct3501.AccessKey = miConfig.AccessKey
  39653. struct3501.RequestUrl = miConfig.Url
  39654. struct3501.SecretKey = miConfig.SecretKey
  39655. struct3501.ManuDate = "2022-08-17"
  39656. struct3501.FixmedinsBchno = ""
  39657. struct3501.ManuLotnum = ""
  39658. struct3501.RxFlag = "0"
  39659. struct3501.ExpyEnd = "2022-08-17"
  39660. struct3501.Invdate = "2022-08-17"
  39661. struct3501.InvCnt = "20.25"
  39662. struct3501.Memo = ""
  39663. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39664. struct3501.FixmedinsHilistId = miConfig.Code
  39665. struct3501.FixmedinsHilistName = miConfig.OrgName
  39666. struct3501s = append(struct3501s, struct3501)
  39667. data["struct_3501s"] = struct3501s
  39668. client := &http.Client{}
  39669. bytesData, _ := json.Marshal(data)
  39670. var req *http.Request
  39671. if miConfig.MdtrtareaAdmvs == "320921" {
  39672. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39673. } else {
  39674. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39675. }
  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. var res ResultSix
  39691. var resSix10265 ResultSix10265 //1101结果
  39692. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39693. result, _ := json.Marshal(respJSON)
  39694. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39695. utils.ErrorLog("解析失败:%v", err)
  39696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39697. return
  39698. }
  39699. res.InfRefmsgid = resSix10265.InfRefmsgid
  39700. res.Output = resSix10265.Output
  39701. res.ErrMsg = resSix10265.ErrMsg
  39702. res.Cainfo = resSix10265.Cainfo
  39703. res.WarnMsg = resSix10265.WarnMsg
  39704. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39705. res.Infcode = infocode
  39706. if infocode == 0 {
  39707. c.ServeSuccessJSON(map[string]interface{}{
  39708. "msg": "上传成功",
  39709. })
  39710. return
  39711. } else {
  39712. c.ServeSuccessJSON(map[string]interface{}{
  39713. "failed_code": -10,
  39714. "msg": res.ErrMsg,
  39715. })
  39716. return
  39717. }
  39718. }
  39719. func (c *HisApiController) Post3502() {
  39720. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39721. data := make(map[string]interface{})
  39722. var struct3502s []models.Struct3502
  39723. var struct3502 models.Struct3502
  39724. struct3502.OrgName = miConfig.OrgName
  39725. struct3502.AccessKey = miConfig.AccessKey
  39726. struct3502.RequestUrl = miConfig.Url
  39727. struct3502.SecretKey = miConfig.SecretKey
  39728. struct3502.ManuDate = "2022-08-15"
  39729. struct3502.FixmedinsBchno = ""
  39730. struct3502.ManuLotnum = ""
  39731. struct3502.RxFlag = "0"
  39732. struct3502.ExpyEnd = "2022-08-15"
  39733. struct3502.Invdate = "2022-08-15"
  39734. struct3502.InvCnt = "20.25"
  39735. struct3502.Memo = ""
  39736. struct3502.MedListCodg = "XB01ABD056B002020200517"
  39737. struct3502.FixmedinsHilistId = miConfig.Code
  39738. struct3502.FixmedinsHilistName = miConfig.OrgName
  39739. struct3502s = append(struct3502s, struct3502)
  39740. data["struct_3502s"] = struct3502s
  39741. client := &http.Client{}
  39742. bytesData, _ := json.Marshal(data)
  39743. var req *http.Request
  39744. if miConfig.MdtrtareaAdmvs == "320921" {
  39745. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39746. } else {
  39747. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39748. }
  39749. resp, _ := client.Do(req)
  39750. defer resp.Body.Close()
  39751. body, ioErr := ioutil.ReadAll(resp.Body)
  39752. if ioErr != nil {
  39753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39755. return
  39756. }
  39757. var respJSON map[string]interface{}
  39758. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39761. return
  39762. }
  39763. var res ResultSix
  39764. var resSix10265 ResultSix10265 //1101结果
  39765. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39766. result, _ := json.Marshal(respJSON)
  39767. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39768. utils.ErrorLog("解析失败:%v", err)
  39769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39770. return
  39771. }
  39772. res.InfRefmsgid = resSix10265.InfRefmsgid
  39773. res.Output = resSix10265.Output
  39774. res.ErrMsg = resSix10265.ErrMsg
  39775. res.Cainfo = resSix10265.Cainfo
  39776. res.WarnMsg = resSix10265.WarnMsg
  39777. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39778. res.Infcode = infocode
  39779. if infocode == 0 {
  39780. c.ServeSuccessJSON(map[string]interface{}{
  39781. "msg": "上传成功",
  39782. })
  39783. return
  39784. } else {
  39785. c.ServeSuccessJSON(map[string]interface{}{
  39786. "failed_code": -10,
  39787. "msg": res.ErrMsg,
  39788. })
  39789. return
  39790. }
  39791. }
  39792. func (c *HisApiController) Post3503() {
  39793. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39794. data := make(map[string]interface{})
  39795. var struct3501s []models.Struct3501
  39796. var struct3501 models.Struct3501
  39797. struct3501.OrgName = miConfig.OrgName
  39798. struct3501.AccessKey = miConfig.AccessKey
  39799. struct3501.RequestUrl = miConfig.Url
  39800. struct3501.SecretKey = miConfig.SecretKey
  39801. struct3501.ManuDate = "2022-08-15"
  39802. struct3501.FixmedinsBchno = ""
  39803. struct3501.ManuLotnum = ""
  39804. struct3501.RxFlag = "0"
  39805. struct3501.ExpyEnd = "2022-08-15"
  39806. struct3501.Invdate = "2022-08-15"
  39807. struct3501.InvCnt = "20.25"
  39808. struct3501.Memo = ""
  39809. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39810. struct3501.FixmedinsHilistId = miConfig.Code
  39811. struct3501.FixmedinsHilistName = miConfig.OrgName
  39812. struct3501s = append(struct3501s, struct3501)
  39813. data["struct_3501s"] = struct3501s
  39814. client := &http.Client{}
  39815. bytesData, _ := json.Marshal(data)
  39816. var req *http.Request
  39817. if miConfig.MdtrtareaAdmvs == "320921" {
  39818. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39819. } else {
  39820. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39821. }
  39822. resp, _ := client.Do(req)
  39823. defer resp.Body.Close()
  39824. body, ioErr := ioutil.ReadAll(resp.Body)
  39825. if ioErr != nil {
  39826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39828. return
  39829. }
  39830. var respJSON map[string]interface{}
  39831. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39834. return
  39835. }
  39836. var res ResultSix
  39837. var resSix10265 ResultSix10265 //1101结果
  39838. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39839. result, _ := json.Marshal(respJSON)
  39840. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39841. utils.ErrorLog("解析失败:%v", err)
  39842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39843. return
  39844. }
  39845. res.InfRefmsgid = resSix10265.InfRefmsgid
  39846. res.Output = resSix10265.Output
  39847. res.ErrMsg = resSix10265.ErrMsg
  39848. res.Cainfo = resSix10265.Cainfo
  39849. res.WarnMsg = resSix10265.WarnMsg
  39850. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39851. res.Infcode = infocode
  39852. if infocode == 0 {
  39853. c.ServeSuccessJSON(map[string]interface{}{
  39854. "msg": "上传成功",
  39855. })
  39856. return
  39857. } else {
  39858. c.ServeSuccessJSON(map[string]interface{}{
  39859. "failed_code": -10,
  39860. "msg": res.ErrMsg,
  39861. })
  39862. return
  39863. }
  39864. }
  39865. func (c *HisApiController) Post3504() {
  39866. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39867. data := make(map[string]interface{})
  39868. var struct3501s []models.Struct3501
  39869. var struct3501 models.Struct3501
  39870. struct3501.OrgName = miConfig.OrgName
  39871. struct3501.AccessKey = miConfig.AccessKey
  39872. struct3501.RequestUrl = miConfig.Url
  39873. struct3501.SecretKey = miConfig.SecretKey
  39874. struct3501.ManuDate = "2022-08-15"
  39875. struct3501.FixmedinsBchno = ""
  39876. struct3501.ManuLotnum = ""
  39877. struct3501.RxFlag = "0"
  39878. struct3501.ExpyEnd = "2022-08-15"
  39879. struct3501.Invdate = "2022-08-15"
  39880. struct3501.InvCnt = "20.25"
  39881. struct3501.Memo = ""
  39882. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39883. struct3501.FixmedinsHilistId = miConfig.Code
  39884. struct3501.FixmedinsHilistName = miConfig.OrgName
  39885. struct3501s = append(struct3501s, struct3501)
  39886. data["struct_3501s"] = struct3501s
  39887. client := &http.Client{}
  39888. bytesData, _ := json.Marshal(data)
  39889. var req *http.Request
  39890. if miConfig.MdtrtareaAdmvs == "320921" {
  39891. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39892. } else {
  39893. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39894. }
  39895. resp, _ := client.Do(req)
  39896. defer resp.Body.Close()
  39897. body, ioErr := ioutil.ReadAll(resp.Body)
  39898. if ioErr != nil {
  39899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39901. return
  39902. }
  39903. var respJSON map[string]interface{}
  39904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39907. return
  39908. }
  39909. var res ResultSix
  39910. var resSix10265 ResultSix10265 //1101结果
  39911. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39912. result, _ := json.Marshal(respJSON)
  39913. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39914. utils.ErrorLog("解析失败:%v", err)
  39915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39916. return
  39917. }
  39918. res.InfRefmsgid = resSix10265.InfRefmsgid
  39919. res.Output = resSix10265.Output
  39920. res.ErrMsg = resSix10265.ErrMsg
  39921. res.Cainfo = resSix10265.Cainfo
  39922. res.WarnMsg = resSix10265.WarnMsg
  39923. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39924. res.Infcode = infocode
  39925. if infocode == 0 {
  39926. c.ServeSuccessJSON(map[string]interface{}{
  39927. "msg": "上传成功",
  39928. })
  39929. return
  39930. } else {
  39931. c.ServeSuccessJSON(map[string]interface{}{
  39932. "failed_code": -10,
  39933. "msg": res.ErrMsg,
  39934. })
  39935. return
  39936. }
  39937. }
  39938. func (c *HisApiController) Post3505() {
  39939. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39940. data := make(map[string]interface{})
  39941. var struct3501s []models.Struct3501
  39942. var struct3501 models.Struct3501
  39943. struct3501.OrgName = miConfig.OrgName
  39944. struct3501.AccessKey = miConfig.AccessKey
  39945. struct3501.RequestUrl = miConfig.Url
  39946. struct3501.SecretKey = miConfig.SecretKey
  39947. struct3501.ManuDate = "2022-08-15"
  39948. struct3501.FixmedinsBchno = ""
  39949. struct3501.ManuLotnum = ""
  39950. struct3501.RxFlag = "0"
  39951. struct3501.ExpyEnd = "2022-08-15"
  39952. struct3501.Invdate = "2022-08-15"
  39953. struct3501.InvCnt = "20.25"
  39954. struct3501.Memo = ""
  39955. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39956. struct3501.FixmedinsHilistId = miConfig.Code
  39957. struct3501.FixmedinsHilistName = miConfig.OrgName
  39958. struct3501s = append(struct3501s, struct3501)
  39959. data["struct_3501s"] = struct3501s
  39960. client := &http.Client{}
  39961. bytesData, _ := json.Marshal(data)
  39962. var req *http.Request
  39963. if miConfig.MdtrtareaAdmvs == "320921" {
  39964. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39965. } else {
  39966. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39967. }
  39968. resp, _ := client.Do(req)
  39969. defer resp.Body.Close()
  39970. body, ioErr := ioutil.ReadAll(resp.Body)
  39971. if ioErr != nil {
  39972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39974. return
  39975. }
  39976. var respJSON map[string]interface{}
  39977. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39980. return
  39981. }
  39982. var res ResultSix
  39983. var resSix10265 ResultSix10265 //1101结果
  39984. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39985. result, _ := json.Marshal(respJSON)
  39986. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39987. utils.ErrorLog("解析失败:%v", err)
  39988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39989. return
  39990. }
  39991. res.InfRefmsgid = resSix10265.InfRefmsgid
  39992. res.Output = resSix10265.Output
  39993. res.ErrMsg = resSix10265.ErrMsg
  39994. res.Cainfo = resSix10265.Cainfo
  39995. res.WarnMsg = resSix10265.WarnMsg
  39996. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39997. res.Infcode = infocode
  39998. if infocode == 0 {
  39999. c.ServeSuccessJSON(map[string]interface{}{
  40000. "msg": "上传成功",
  40001. })
  40002. return
  40003. } else {
  40004. c.ServeSuccessJSON(map[string]interface{}{
  40005. "failed_code": -10,
  40006. "msg": res.ErrMsg,
  40007. })
  40008. return
  40009. }
  40010. }
  40011. func (c *HisApiController) Post3506() {
  40012. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40013. data := make(map[string]interface{})
  40014. var struct3501s []models.Struct3501
  40015. var struct3501 models.Struct3501
  40016. struct3501.OrgName = miConfig.OrgName
  40017. struct3501.AccessKey = miConfig.AccessKey
  40018. struct3501.RequestUrl = miConfig.Url
  40019. struct3501.SecretKey = miConfig.SecretKey
  40020. struct3501.ManuDate = "2022-08-15"
  40021. struct3501.FixmedinsBchno = ""
  40022. struct3501.ManuLotnum = ""
  40023. struct3501.RxFlag = "0"
  40024. struct3501.ExpyEnd = "2022-08-15"
  40025. struct3501.Invdate = "2022-08-15"
  40026. struct3501.InvCnt = "20.25"
  40027. struct3501.Memo = ""
  40028. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40029. struct3501.FixmedinsHilistId = miConfig.Code
  40030. struct3501.FixmedinsHilistName = miConfig.OrgName
  40031. struct3501s = append(struct3501s, struct3501)
  40032. data["struct_3501s"] = struct3501s
  40033. client := &http.Client{}
  40034. bytesData, _ := json.Marshal(data)
  40035. var req *http.Request
  40036. if miConfig.MdtrtareaAdmvs == "320921" {
  40037. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40038. } else {
  40039. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40040. }
  40041. resp, _ := client.Do(req)
  40042. defer resp.Body.Close()
  40043. body, ioErr := ioutil.ReadAll(resp.Body)
  40044. if ioErr != nil {
  40045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40047. return
  40048. }
  40049. var respJSON map[string]interface{}
  40050. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40053. return
  40054. }
  40055. var res ResultSix
  40056. var resSix10265 ResultSix10265 //1101结果
  40057. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40058. result, _ := json.Marshal(respJSON)
  40059. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40060. utils.ErrorLog("解析失败:%v", err)
  40061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40062. return
  40063. }
  40064. res.InfRefmsgid = resSix10265.InfRefmsgid
  40065. res.Output = resSix10265.Output
  40066. res.ErrMsg = resSix10265.ErrMsg
  40067. res.Cainfo = resSix10265.Cainfo
  40068. res.WarnMsg = resSix10265.WarnMsg
  40069. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40070. res.Infcode = infocode
  40071. if infocode == 0 {
  40072. c.ServeSuccessJSON(map[string]interface{}{
  40073. "msg": "上传成功",
  40074. })
  40075. return
  40076. } else {
  40077. c.ServeSuccessJSON(map[string]interface{}{
  40078. "failed_code": -10,
  40079. "msg": res.ErrMsg,
  40080. })
  40081. return
  40082. }
  40083. }
  40084. func (c *HisApiController) Post3507() {
  40085. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40086. data := make(map[string]interface{})
  40087. var struct3501s []models.Struct3501
  40088. var struct3501 models.Struct3501
  40089. struct3501.OrgName = miConfig.OrgName
  40090. struct3501.AccessKey = miConfig.AccessKey
  40091. struct3501.RequestUrl = miConfig.Url
  40092. struct3501.SecretKey = miConfig.SecretKey
  40093. struct3501.ManuDate = "2022-08-15"
  40094. struct3501.FixmedinsBchno = ""
  40095. struct3501.ManuLotnum = ""
  40096. struct3501.RxFlag = "0"
  40097. struct3501.ExpyEnd = "2022-08-15"
  40098. struct3501.Invdate = "2022-08-15"
  40099. struct3501.InvCnt = "20.25"
  40100. struct3501.Memo = ""
  40101. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40102. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  40103. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  40104. struct3501s = append(struct3501s, struct3501)
  40105. data["struct_3501s"] = struct3501s
  40106. client := &http.Client{}
  40107. bytesData, _ := json.Marshal(data)
  40108. var req *http.Request
  40109. if miConfig.MdtrtareaAdmvs == "320921" {
  40110. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40111. } else {
  40112. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40113. }
  40114. resp, _ := client.Do(req)
  40115. defer resp.Body.Close()
  40116. body, ioErr := ioutil.ReadAll(resp.Body)
  40117. if ioErr != nil {
  40118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40120. return
  40121. }
  40122. var respJSON map[string]interface{}
  40123. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40126. return
  40127. }
  40128. var res ResultSix
  40129. var resSix10265 ResultSix10265 //1101结果
  40130. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40131. result, _ := json.Marshal(respJSON)
  40132. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40133. utils.ErrorLog("解析失败:%v", err)
  40134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40135. return
  40136. }
  40137. res.InfRefmsgid = resSix10265.InfRefmsgid
  40138. res.Output = resSix10265.Output
  40139. res.ErrMsg = resSix10265.ErrMsg
  40140. res.Cainfo = resSix10265.Cainfo
  40141. res.WarnMsg = resSix10265.WarnMsg
  40142. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40143. res.Infcode = infocode
  40144. if infocode == 0 {
  40145. c.ServeSuccessJSON(map[string]interface{}{
  40146. "msg": "上传成功",
  40147. })
  40148. return
  40149. } else {
  40150. c.ServeSuccessJSON(map[string]interface{}{
  40151. "failed_code": -10,
  40152. "msg": res.ErrMsg,
  40153. })
  40154. return
  40155. }
  40156. }
  40157. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  40158. // WebSocket服务器地址
  40159. serverURL := "ws://127.0.0.1:8899"
  40160. // 解析WebSocket服务器地址
  40161. u, err := url.Parse(serverURL)
  40162. if err != nil {
  40163. }
  40164. // 建立WebSocket连接
  40165. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40166. if err != nil {
  40167. }
  40168. defer conn.Close()
  40169. input2 := make(map[string]interface{})
  40170. input := make(map[string]interface{})
  40171. inputData := make(map[string]interface{})
  40172. inputData["orgId"] = code
  40173. inputData["businessType"] = "01101"
  40174. inputData["operatorId"] = operator_id
  40175. inputData["operatorName"] = operator_name
  40176. inputData["officeId"] = "001"
  40177. inputData["officeName"] = "血透室"
  40178. inputData["deviceType"] = ""
  40179. input["data"] = inputData
  40180. input["orgId"] = code
  40181. input["transType"] = "ec.query"
  40182. //if md == ""
  40183. if md[:4] == "4403" {
  40184. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40185. } else if md[:4] == "4401" {
  40186. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40187. } else {
  40188. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40189. }
  40190. input2["indata"] = input
  40191. fmt.Println(input2)
  40192. bytesData, _ := json.Marshal(input2)
  40193. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40194. if err != nil {
  40195. fmt.Println(err)
  40196. }
  40197. // 接收消息
  40198. _, receivedMessage, err := conn.ReadMessage()
  40199. if err != nil {
  40200. fmt.Println(err)
  40201. }
  40202. return "", string(receivedMessage)
  40203. }
  40204. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  40205. // WebSocket服务器地址
  40206. serverURL := "ws://127.0.0.1:8899"
  40207. // 解析WebSocket服务器地址
  40208. u, err := url.Parse(serverURL)
  40209. if err != nil {
  40210. }
  40211. // 建立WebSocket连接
  40212. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40213. if err != nil {
  40214. }
  40215. defer conn.Close()
  40216. input2 := make(map[string]interface{})
  40217. input := make(map[string]interface{})
  40218. inputData := make(map[string]interface{})
  40219. inputData["orgId"] = code
  40220. inputData["businessType"] = "01101"
  40221. inputData["operatorId"] = operator_id
  40222. inputData["operatorName"] = operator_name
  40223. inputData["officeId"] = "001"
  40224. inputData["officeName"] = "血透室"
  40225. inputData["deviceType"] = ""
  40226. input["data"] = inputData
  40227. input["orgId"] = code
  40228. input["transType"] = "ec.query"
  40229. //if md == ""
  40230. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  40231. input2["indata"] = input
  40232. fmt.Println(input2)
  40233. bytesData, _ := json.Marshal(input2)
  40234. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40235. if err != nil {
  40236. fmt.Println(err)
  40237. }
  40238. // 接收消息
  40239. _, receivedMessage, err := conn.ReadMessage()
  40240. if err != nil {
  40241. fmt.Println(err)
  40242. }
  40243. return "", string(receivedMessage)
  40244. }
  40245. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  40246. // WebSocket服务器地址
  40247. serverURL := "ws://127.0.0.1:8899"
  40248. // 解析WebSocket服务器地址
  40249. u, err := url.Parse(serverURL)
  40250. if err != nil {
  40251. }
  40252. // 建立WebSocket连接
  40253. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40254. if err != nil {
  40255. }
  40256. defer conn.Close()
  40257. input2 := make(map[string]interface{})
  40258. input := make(map[string]interface{})
  40259. inputData := make(map[string]interface{})
  40260. inputData["orgId"] = code
  40261. inputData["businessType"] = "01301"
  40262. inputData["operatorId"] = operator_id
  40263. inputData["operatorName"] = operator_name
  40264. inputData["officeId"] = "001"
  40265. inputData["officeName"] = "血透室"
  40266. inputData["deviceType"] = ""
  40267. input["data"] = inputData
  40268. input["orgId"] = code
  40269. input["transType"] = "ec.query"
  40270. //if md == ""
  40271. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  40272. input2["indata"] = input
  40273. fmt.Println(input2)
  40274. bytesData, _ := json.Marshal(input2)
  40275. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40276. if err != nil {
  40277. fmt.Println(err)
  40278. }
  40279. // 接收消息
  40280. _, receivedMessage, err := conn.ReadMessage()
  40281. if err != nil {
  40282. fmt.Println(err)
  40283. }
  40284. return "", string(receivedMessage)
  40285. }
  40286. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  40287. // WebSocket服务器地址
  40288. serverURL := "ws://127.0.0.1:8899"
  40289. // 解析WebSocket服务器地址
  40290. u, err := url.Parse(serverURL)
  40291. if err != nil {
  40292. }
  40293. // 建立WebSocket连接
  40294. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40295. if err != nil {
  40296. }
  40297. defer conn.Close()
  40298. input2 := make(map[string]interface{})
  40299. input := make(map[string]interface{})
  40300. inputData := make(map[string]interface{})
  40301. inputData["orgId"] = code
  40302. inputData["businessType"] = "01103"
  40303. inputData["operatorId"] = operator_id
  40304. inputData["operatorName"] = operator_name
  40305. inputData["officeId"] = "001"
  40306. inputData["officeName"] = "血透室"
  40307. inputData["deviceType"] = ""
  40308. input["data"] = inputData
  40309. input["orgId"] = code
  40310. input["transType"] = "ec.query"
  40311. //if md ==
  40312. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  40313. input2["indata"] = input
  40314. fmt.Println(input2)
  40315. bytesData, _ := json.Marshal(input2)
  40316. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40317. if err != nil {
  40318. fmt.Println(err)
  40319. }
  40320. // 接收消息
  40321. _, receivedMessage, err := conn.ReadMessage()
  40322. if err != nil {
  40323. fmt.Println(err)
  40324. }
  40325. return "", string(receivedMessage)
  40326. }
  40327. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  40328. // WebSocket服务器地址
  40329. serverURL := "ws://127.0.0.1:8899"
  40330. // 解析WebSocket服务器地址
  40331. u, err := url.Parse(serverURL)
  40332. if err != nil {
  40333. }
  40334. // 建立WebSocket连接
  40335. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40336. if err != nil {
  40337. }
  40338. defer conn.Close()
  40339. input2 := make(map[string]interface{})
  40340. input := make(map[string]interface{})
  40341. inputData := make(map[string]interface{})
  40342. inputData["orgId"] = code
  40343. inputData["businessType"] = "01101"
  40344. inputData["operatorId"] = operator_id
  40345. inputData["operatorName"] = operator_name
  40346. inputData["officeId"] = "001"
  40347. inputData["officeName"] = "血透室"
  40348. inputData["deviceType"] = ""
  40349. input["data"] = inputData
  40350. input["orgId"] = code
  40351. input["transType"] = "ec.query"
  40352. //if md == ""
  40353. if md[:4] == "4403" {
  40354. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40355. } else if md[:4] == "4401" {
  40356. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40357. } else {
  40358. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40359. }
  40360. input2["indata"] = input
  40361. fmt.Println(input2)
  40362. bytesData, _ := json.Marshal(input2)
  40363. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40364. if err != nil {
  40365. fmt.Println(err)
  40366. }
  40367. // 接收消息
  40368. _, receivedMessage, err := conn.ReadMessage()
  40369. if err != nil {
  40370. fmt.Println(err)
  40371. }
  40372. return "", string(receivedMessage)
  40373. }
  40374. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  40375. // WebSocket服务器地址
  40376. serverURL := "ws://127.0.0.1:8899"
  40377. // 解析WebSocket服务器地址
  40378. u, err := url.Parse(serverURL)
  40379. if err != nil {
  40380. }
  40381. // 建立WebSocket连接
  40382. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40383. if err != nil {
  40384. }
  40385. defer conn.Close()
  40386. input2 := make(map[string]interface{})
  40387. input := make(map[string]interface{})
  40388. inputData := make(map[string]interface{})
  40389. inputData["orgId"] = code
  40390. inputData["businessType"] = "01301"
  40391. inputData["operatorId"] = operator_id
  40392. inputData["operatorName"] = operator_name
  40393. inputData["officeId"] = "001"
  40394. inputData["officeName"] = "血透室"
  40395. inputData["deviceType"] = ""
  40396. input["data"] = inputData
  40397. input["orgId"] = code
  40398. input["transType"] = "ec.query"
  40399. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40400. input2["indata"] = input
  40401. bytesData, _ := json.Marshal(input2)
  40402. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40403. if err != nil {
  40404. fmt.Println(err)
  40405. }
  40406. // 接收消息
  40407. _, receivedMessage, err := conn.ReadMessage()
  40408. if err != nil {
  40409. fmt.Println(err)
  40410. }
  40411. return "", string(receivedMessage)
  40412. }
  40413. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  40414. newArr = make([]string, 0)
  40415. for i := 0; i < len(arr); i++ {
  40416. repeat := false
  40417. for j := i + 1; j < len(arr); j++ {
  40418. if arr[i] == arr[j] {
  40419. repeat = true
  40420. break
  40421. }
  40422. }
  40423. if !repeat {
  40424. newArr = append(newArr, arr[i])
  40425. }
  40426. }
  40427. return
  40428. }
  40429. func getBirthdateAndAge(idNumber string) (string, int, error) {
  40430. if len(idNumber) != 18 {
  40431. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  40432. }
  40433. // 提取出生日期
  40434. year, err := strconv.Atoi(idNumber[6:10])
  40435. if err != nil {
  40436. return "", 0, err
  40437. }
  40438. month, err := strconv.Atoi(idNumber[10:12])
  40439. if err != nil {
  40440. return "", 0, err
  40441. }
  40442. day, err := strconv.Atoi(idNumber[12:14])
  40443. if err != nil {
  40444. return "", 0, err
  40445. }
  40446. // 格式化生日字符串
  40447. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  40448. birthdateFormatted := birthdate.Format("2006-01-02")
  40449. // 计算年龄
  40450. today := time.Now()
  40451. age := today.Year() - birthdate.Year()
  40452. if today.YearDay() < birthdate.YearDay() {
  40453. age--
  40454. }
  40455. return birthdateFormatted, age, nil
  40456. }
  40457. // 从身份证号码中提取出生年月日
  40458. func getBirthDateFromIDCard(idCard string) (string, error) {
  40459. // 身份证号码长度应为18位
  40460. if len(idCard) != 18 {
  40461. return "", fmt.Errorf("身份证号码长度应为18位")
  40462. }
  40463. // 提取出生日期部分 (YYYYMMDD)
  40464. birthDateStr := idCard[6:14]
  40465. // 解析出生日期
  40466. birthDate, err := time.Parse("20060102", birthDateStr)
  40467. if err != nil {
  40468. return "", fmt.Errorf("解析出生日期失败: %v", err)
  40469. }
  40470. // 格式化出生日期为 YYYY-MM-DD
  40471. formattedDate := birthDate.Format("2006-01-02")
  40472. return formattedDate, nil
  40473. }