his_api_controller.go 1.6MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537
  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/comfirm/upload", &HisApiController{}, "get:Get4102")
  135. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  136. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  137. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  138. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  139. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  140. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  141. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  142. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  143. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  144. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  145. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  146. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  147. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  148. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  149. //库盘和变更
  150. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  151. //删除库盘和变更
  152. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  153. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  154. //药品变更
  155. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  156. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  157. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  158. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  159. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  160. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  161. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  162. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  163. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  164. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  165. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  166. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  167. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  168. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  169. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  170. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  171. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  172. }
  173. func (c *HisApiController) Get3201() {
  174. adminUser := c.GetAdminUserInfo()
  175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  176. 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)
  177. var response Response
  178. if err := json.Unmarshal([]byte(result), &response); err != nil {
  179. fmt.Println("Error decoding JSON:", err)
  180. return
  181. }
  182. }
  183. func (c *HisApiController) TestNet() {
  184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  185. return
  186. //c.ServeSuccessJSON(map[string]interface{}{
  187. // "msg": "成功",
  188. //})
  189. }
  190. func (c *HisApiController) Get3508() {
  191. admin_user_id, _ := c.GetInt64("admin_user_id")
  192. drug_id, _ := c.GetInt64("id")
  193. start_time := c.GetString("start_time")
  194. end_time := c.GetString("end_time")
  195. adminUser := c.GetAdminUserInfo()
  196. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  197. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  198. drug, _ := service.GetDrugByID(drug_id)
  199. var struct3508 models.Struct3508
  200. struct3508.OrgName = miConfig.OrgName
  201. struct3508.FixmedinsCode = miConfig.Code
  202. struct3508.AccessKey = miConfig.AccessKey
  203. struct3508.Opter = curRoles.UserName
  204. struct3508.RequestUrl = miConfig.Url
  205. struct3508.Url = miConfig.Url
  206. struct3508.AppId = miConfig.Cainfo
  207. struct3508.AppSecret = miConfig.AppSecret
  208. struct3508.Enckey = miConfig.EncKey
  209. struct3508.SignKey = miConfig.SignKey
  210. struct3508.SecretKey = miConfig.SecretKey
  211. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  212. struct3508.Begndate = start_time
  213. struct3508.Enddate = end_time
  214. result1, result2, _ := service.FJyb3508(struct3508)
  215. saveLog(result1, result2, "3508", "3508")
  216. var res models.Result3508
  217. var respJSON2 map[string]interface{}
  218. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. userJSONBytes2, _ := json.Marshal(respJSON2)
  224. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  225. utils.ErrorLog("解析失败:%v", err)
  226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  227. return
  228. }
  229. if res.Infcode == -1 {
  230. c.ServeSuccessJSON(map[string]interface{}{
  231. "failed_code": -10,
  232. "msg": res.ErrMsg,
  233. })
  234. } else {
  235. c.ServeSuccessJSON(map[string]interface{}{
  236. "info": res.Output,
  237. })
  238. }
  239. }
  240. func (c *HisApiController) Get3509() {
  241. admin_user_id, _ := c.GetInt64("admin_user_id")
  242. drug_id, _ := c.GetInt64("id")
  243. start_time := c.GetString("start_time")
  244. end_time := c.GetString("end_time")
  245. adminUser := c.GetAdminUserInfo()
  246. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  248. drug, _ := service.GetDrugByID(drug_id)
  249. var struct3508 models.Struct3509
  250. struct3508.OrgName = miConfig.OrgName
  251. struct3508.FixmedinsCode = miConfig.Code
  252. struct3508.AccessKey = miConfig.AccessKey
  253. struct3508.Opter = curRoles.UserName
  254. struct3508.RequestUrl = miConfig.Url
  255. struct3508.Url = miConfig.Url
  256. struct3508.AppId = miConfig.Cainfo
  257. struct3508.AppSecret = miConfig.AppSecret
  258. struct3508.Enckey = miConfig.EncKey
  259. struct3508.SignKey = miConfig.SignKey
  260. struct3508.SecretKey = miConfig.SecretKey
  261. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  262. struct3508.Begndate = start_time
  263. struct3508.Enddate = end_time
  264. result1, result2, _ := service.FJyb3509(struct3508)
  265. saveLog(result1, result2, "3509", "3509")
  266. var res models.Result3509
  267. var respJSON2 map[string]interface{}
  268. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  271. return
  272. }
  273. userJSONBytes2, _ := json.Marshal(respJSON2)
  274. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  275. utils.ErrorLog("解析失败:%v", err)
  276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  277. return
  278. }
  279. if res.Infcode == -1 {
  280. c.ServeSuccessJSON(map[string]interface{}{
  281. "failed_code": -10,
  282. "msg": res.ErrMsg,
  283. })
  284. } else {
  285. c.ServeSuccessJSON(map[string]interface{}{
  286. "info": res.Output,
  287. })
  288. }
  289. }
  290. func (c *HisApiController) Get3510() {
  291. admin_user_id, _ := c.GetInt64("admin_user_id")
  292. drug_id, _ := c.GetInt64("id")
  293. start_time := c.GetString("start_time")
  294. end_time := c.GetString("end_time")
  295. adminUser := c.GetAdminUserInfo()
  296. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  297. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  298. drug, _ := service.GetDrugByID(drug_id)
  299. var struct3508 models.Struct3510
  300. struct3508.FixmedinsCode = miConfig.Code
  301. struct3508.OrgName = miConfig.OrgName
  302. struct3508.AccessKey = miConfig.AccessKey
  303. struct3508.Opter = curRoles.UserName
  304. struct3508.RequestUrl = miConfig.Url
  305. struct3508.Url = miConfig.Url
  306. struct3508.AppId = miConfig.Cainfo
  307. struct3508.AppSecret = miConfig.AppSecret
  308. struct3508.Enckey = miConfig.EncKey
  309. struct3508.SignKey = miConfig.SignKey
  310. struct3508.SecretKey = miConfig.SecretKey
  311. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  312. struct3508.Begndate = start_time
  313. struct3508.Enddate = end_time
  314. result1, result2, _ := service.FJyb3510(struct3508)
  315. saveLog(result1, result2, "3510", "3510")
  316. var res models.Result3510
  317. var respJSON2 map[string]interface{}
  318. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  321. return
  322. }
  323. userJSONBytes2, _ := json.Marshal(respJSON2)
  324. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  325. utils.ErrorLog("解析失败:%v", err)
  326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  327. return
  328. }
  329. if res.Infcode == -1 {
  330. c.ServeSuccessJSON(map[string]interface{}{
  331. "failed_code": -10,
  332. "msg": res.ErrMsg,
  333. })
  334. } else {
  335. c.ServeSuccessJSON(map[string]interface{}{
  336. "info": res.Output,
  337. })
  338. }
  339. }
  340. func (c *HisApiController) Get3511() {
  341. admin_user_id, _ := c.GetInt64("admin_user_id")
  342. drug_id, _ := c.GetInt64("id")
  343. start_time := c.GetString("start_time")
  344. end_time := c.GetString("end_time")
  345. adminUser := c.GetAdminUserInfo()
  346. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  348. drug, _ := service.GetDrugByID(drug_id)
  349. var struct3508 models.Struct3511
  350. struct3508.FixmedinsCode = miConfig.Code
  351. struct3508.OrgName = miConfig.OrgName
  352. struct3508.AccessKey = miConfig.AccessKey
  353. struct3508.Opter = curRoles.UserName
  354. struct3508.RequestUrl = miConfig.Url
  355. struct3508.Url = miConfig.Url
  356. struct3508.AppId = miConfig.Cainfo
  357. struct3508.AppSecret = miConfig.AppSecret
  358. struct3508.Enckey = miConfig.EncKey
  359. struct3508.SignKey = miConfig.SignKey
  360. struct3508.SecretKey = miConfig.SecretKey
  361. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  362. struct3508.Begndate = start_time
  363. struct3508.Enddate = end_time
  364. result1, result2, _ := service.FJyb3511(struct3508)
  365. saveLog(result1, result2, "3511", "3511")
  366. var res models.Result3511
  367. var respJSON2 map[string]interface{}
  368. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  371. return
  372. }
  373. userJSONBytes2, _ := json.Marshal(respJSON2)
  374. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  375. utils.ErrorLog("解析失败:%v", err)
  376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  377. return
  378. }
  379. if res.Infcode == -1 {
  380. c.ServeSuccessJSON(map[string]interface{}{
  381. "failed_code": -10,
  382. "msg": res.ErrMsg,
  383. })
  384. } else {
  385. c.ServeSuccessJSON(map[string]interface{}{
  386. "info": res.Output,
  387. })
  388. }
  389. }
  390. func (c *HisApiController) Get3512() {
  391. admin_user_id, _ := c.GetInt64("admin_user_id")
  392. drug_id, _ := c.GetInt64("id")
  393. start_time := c.GetString("start_time")
  394. end_time := c.GetString("end_time")
  395. adminUser := c.GetAdminUserInfo()
  396. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  397. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  398. drug, _ := service.GetDrugByID(drug_id)
  399. var struct3508 models.Struct3512
  400. struct3508.FixmedinsCode = miConfig.Code
  401. struct3508.OrgName = miConfig.OrgName
  402. struct3508.AccessKey = miConfig.AccessKey
  403. struct3508.Opter = curRoles.UserName
  404. struct3508.RequestUrl = miConfig.Url
  405. struct3508.Url = miConfig.Url
  406. struct3508.AppId = miConfig.Cainfo
  407. struct3508.AppSecret = miConfig.AppSecret
  408. struct3508.Enckey = miConfig.EncKey
  409. struct3508.SignKey = miConfig.SignKey
  410. struct3508.SecretKey = miConfig.SecretKey
  411. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  412. struct3508.Begndate = start_time
  413. struct3508.Enddate = end_time
  414. result1, result2, _ := service.FJyb3512(struct3508)
  415. saveLog(result1, result2, "3512", "3512")
  416. var res models.Result3512
  417. var respJSON2 map[string]interface{}
  418. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  421. return
  422. }
  423. userJSONBytes2, _ := json.Marshal(respJSON2)
  424. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == -1 {
  430. c.ServeSuccessJSON(map[string]interface{}{
  431. "failed_code": -10,
  432. "msg": res.ErrMsg,
  433. })
  434. } else {
  435. c.ServeSuccessJSON(map[string]interface{}{
  436. "info": res.Output,
  437. })
  438. }
  439. }
  440. func (c *HisApiController) Get3513() {
  441. admin_user_id, _ := c.GetInt64("admin_user_id")
  442. drug_id, _ := c.GetInt64("id")
  443. start_time := c.GetString("start_time")
  444. end_time := c.GetString("end_time")
  445. adminUser := c.GetAdminUserInfo()
  446. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  447. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  448. drug, _ := service.GetDrugByID(drug_id)
  449. var struct3508 models.Struct3513
  450. struct3508.FixmedinsCode = miConfig.Code
  451. struct3508.OrgName = miConfig.OrgName
  452. struct3508.AccessKey = miConfig.AccessKey
  453. struct3508.Opter = curRoles.UserName
  454. struct3508.RequestUrl = miConfig.Url
  455. struct3508.Url = miConfig.Url
  456. struct3508.AppId = miConfig.Cainfo
  457. struct3508.AppSecret = miConfig.AppSecret
  458. struct3508.Enckey = miConfig.EncKey
  459. struct3508.SignKey = miConfig.SignKey
  460. struct3508.SecretKey = miConfig.SecretKey
  461. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  462. struct3508.Begndate = start_time
  463. struct3508.Enddate = end_time
  464. result1, result2, _ := service.FJyb3513(struct3508)
  465. saveLog(result1, result2, "3513", "3513")
  466. var res models.Result3513
  467. var respJSON2 map[string]interface{}
  468. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  471. return
  472. }
  473. userJSONBytes2, _ := json.Marshal(respJSON2)
  474. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  475. utils.ErrorLog("解析失败:%v", err)
  476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  477. return
  478. }
  479. if res.Infcode == -1 {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "failed_code": -10,
  482. "msg": res.ErrMsg,
  483. })
  484. } else {
  485. c.ServeSuccessJSON(map[string]interface{}{
  486. "info": res.Output,
  487. })
  488. }
  489. }
  490. func (c *HisApiController) Get35081() {
  491. admin_user_id, _ := c.GetInt64("admin_user_id")
  492. drug_id, _ := c.GetInt64("id")
  493. //start_time := c.GetString("start_time")
  494. //end_time := c.GetString("end_time")
  495. page, _ := c.GetInt("page")
  496. adminUser := c.GetAdminUserInfo()
  497. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  498. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  499. drug, _ := service.GetDrugByID(drug_id)
  500. var struct3508 models.Struct35081
  501. struct3508.FixmedinsCode = miConfig.Code
  502. struct3508.OrgName = miConfig.OrgName
  503. struct3508.AccessKey = miConfig.AccessKey
  504. struct3508.Opter = curRoles.UserName
  505. struct3508.RequestUrl = miConfig.Url
  506. struct3508.Url = miConfig.Url
  507. struct3508.AppId = miConfig.Cainfo
  508. struct3508.AppSecret = miConfig.AppSecret
  509. struct3508.Enckey = miConfig.EncKey
  510. struct3508.SignKey = miConfig.SignKey
  511. struct3508.SecretKey = miConfig.SecretKey
  512. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  513. struct3508.PageNum = page
  514. struct3508.PageSize = 10
  515. result1, result2, _ := service.FJyb35081(struct3508)
  516. saveLog(result1, result2, "35081", "35081")
  517. var res models.Result35081
  518. var respJSON2 map[string]interface{}
  519. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  522. return
  523. }
  524. userJSONBytes2, _ := json.Marshal(respJSON2)
  525. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  526. utils.ErrorLog("解析失败:%v", err)
  527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  528. return
  529. }
  530. if res.Infcode == -1 {
  531. c.ServeSuccessJSON(map[string]interface{}{
  532. "failed_code": -10,
  533. "msg": res.ErrMsg,
  534. })
  535. } else {
  536. c.ServeSuccessJSON(map[string]interface{}{
  537. "info": res.Output,
  538. })
  539. }
  540. }
  541. func (c *HisApiController) Get35082() {
  542. admin_user_id, _ := c.GetInt64("admin_user_id")
  543. drug_id, _ := c.GetInt64("id")
  544. //start_time := c.GetString("start_time")
  545. //end_time := c.GetString("end_time")
  546. page, _ := c.GetInt("page")
  547. adminUser := c.GetAdminUserInfo()
  548. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  550. drug, _ := service.GetDrugByID(drug_id)
  551. var struct3508 models.Struct35082
  552. struct3508.FixmedinsCode = miConfig.Code
  553. struct3508.OrgName = miConfig.OrgName
  554. struct3508.AccessKey = miConfig.AccessKey
  555. struct3508.Opter = curRoles.UserName
  556. struct3508.RequestUrl = miConfig.Url
  557. struct3508.Url = miConfig.Url
  558. struct3508.AppId = miConfig.Cainfo
  559. struct3508.AppSecret = miConfig.AppSecret
  560. struct3508.Enckey = miConfig.EncKey
  561. struct3508.SignKey = miConfig.SignKey
  562. struct3508.SecretKey = miConfig.SecretKey
  563. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  564. struct3508.PageNum = page
  565. struct3508.PageSize = 10
  566. result1, result2, _ := service.FJyb35082(struct3508)
  567. saveLog(result1, result2, "35082", "35082")
  568. var res models.Result35082
  569. var respJSON2 map[string]interface{}
  570. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  573. return
  574. }
  575. userJSONBytes2, _ := json.Marshal(respJSON2)
  576. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  577. utils.ErrorLog("解析失败:%v", err)
  578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  579. return
  580. }
  581. if res.Infcode == -1 {
  582. c.ServeSuccessJSON(map[string]interface{}{
  583. "failed_code": -10,
  584. "msg": res.ErrMsg,
  585. })
  586. } else {
  587. c.ServeSuccessJSON(map[string]interface{}{
  588. "info": res.Output,
  589. })
  590. }
  591. }
  592. func (c *HisApiController) FJ3501AND3502() {
  593. ids := c.GetString("ids")
  594. admin_user_id, _ := c.GetInt64("admin_user_id")
  595. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  596. id_arr := strings.Split(ids, ",")
  597. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  598. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  599. //库盘
  600. var errs []string
  601. for _, drug := range drugs {
  602. if drug.IsPc == 0 {
  603. var res2 ResultSix
  604. var res3 ResultSix
  605. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  606. var struct3501 models.Struct3501
  607. struct3501.Code = miConfig.Code
  608. struct3501.OrgName = miConfig.OrgName
  609. struct3501.AccessKey = miConfig.AccessKey
  610. struct3501.Opter = roles.UserName
  611. struct3501.RequestUrl = miConfig.Url
  612. struct3501.Url = miConfig.Url
  613. struct3501.AppId = miConfig.Cainfo
  614. struct3501.AppSecret = miConfig.AppSecret
  615. struct3501.Enckey = miConfig.EncKey
  616. struct3501.SignKey = miConfig.SignKey
  617. struct3501.SecretKey = miConfig.SecretKey
  618. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  619. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  620. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  621. struct3501.RxFlag = "1"
  622. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  623. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  624. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  625. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  626. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  627. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  628. struct3501.FixmedinsBchno = number
  629. struct3501.DrugTracCodg = drug.DrugCode
  630. memo := make(map[string]interface{})
  631. memo["pric"] = drug.Price
  632. bytesData, _ := json.Marshal(memo)
  633. struct3501.Memo = string(bytesData)
  634. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  635. result1, result2, _ := service.FJyb3501(struct3501)
  636. saveLog(result1, result2, "3501", "3501")
  637. //saveLog(result, requestLog, "2201", "挂号")
  638. var respJSON2 map[string]interface{}
  639. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  642. return
  643. }
  644. userJSONBytes2, _ := json.Marshal(respJSON2)
  645. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  646. utils.ErrorLog("解析失败:%v", err)
  647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  648. return
  649. }
  650. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  651. data := make(map[string]interface{})
  652. data["struct_3501s"] = struct3501
  653. client := &http.Client{}
  654. bytesData, _ := json.Marshal(data)
  655. var req *http.Request
  656. if miConfig.MdtrtareaAdmvs == "320921" {
  657. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  658. } else {
  659. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  660. }
  661. resp, _ := client.Do(req)
  662. defer resp.Body.Close()
  663. body, ioErr := ioutil.ReadAll(resp.Body)
  664. if ioErr != nil {
  665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  666. }
  667. var respJSON map[string]interface{}
  668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. var resSix10265 ResultSix10265 //1101结果
  674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  675. result, _ := json.Marshal(respJSON)
  676. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  677. utils.ErrorLog("解析失败:%v", err)
  678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  679. return
  680. }
  681. res2.InfRefmsgid = resSix10265.InfRefmsgid
  682. res2.Output = resSix10265.Output
  683. res2.ErrMsg = resSix10265.ErrMsg
  684. res2.Cainfo = resSix10265.Cainfo
  685. res2.WarnMsg = resSix10265.WarnMsg
  686. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  687. res2.Infcode = infocode
  688. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  689. data := make(map[string]interface{})
  690. data["struct_3501s"] = struct3501
  691. client := &http.Client{}
  692. bytesData, _ := json.Marshal(data)
  693. var req *http.Request
  694. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  695. resp, _ := client.Do(req)
  696. defer resp.Body.Close()
  697. body, ioErr := ioutil.ReadAll(resp.Body)
  698. if ioErr != nil {
  699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  700. }
  701. var respJSON map[string]interface{}
  702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  705. return
  706. }
  707. var resSix10265 ResultSix10265 //1101结果
  708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  709. result, _ := json.Marshal(respJSON)
  710. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  711. utils.ErrorLog("解析失败:%v", err)
  712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  713. return
  714. }
  715. res2.InfRefmsgid = resSix10265.InfRefmsgid
  716. res2.Output = resSix10265.Output
  717. res2.ErrMsg = resSix10265.ErrMsg
  718. res2.Cainfo = resSix10265.Cainfo
  719. res2.WarnMsg = resSix10265.WarnMsg
  720. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  721. res2.Infcode = infocode
  722. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  723. data := make(map[string]interface{})
  724. data["struct_3501s"] = struct3501
  725. client := &http.Client{}
  726. bytesData, _ := json.Marshal(data)
  727. var req *http.Request
  728. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  729. resp, _ := client.Do(req)
  730. defer resp.Body.Close()
  731. body, ioErr := ioutil.ReadAll(resp.Body)
  732. if ioErr != nil {
  733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  734. }
  735. var respJSON map[string]interface{}
  736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  739. return
  740. }
  741. var resSix10265 ResultSix10265 //1101结果
  742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  743. result, _ := json.Marshal(respJSON)
  744. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  745. utils.ErrorLog("解析失败:%v", err)
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. res2.InfRefmsgid = resSix10265.InfRefmsgid
  750. res2.Output = resSix10265.Output
  751. res2.ErrMsg = resSix10265.ErrMsg
  752. res2.Cainfo = resSix10265.Cainfo
  753. res2.WarnMsg = resSix10265.WarnMsg
  754. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  755. res2.Infcode = infocode
  756. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  757. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  758. saveLog(result1, result2, "3501", "3501")
  759. //saveLog(result, requestLog, "2201", "挂号")
  760. var respJSON2 map[string]interface{}
  761. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. return
  765. }
  766. userJSONBytes2, _ := json.Marshal(respJSON2)
  767. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  768. utils.ErrorLog("解析失败:%v", err)
  769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  770. return
  771. }
  772. }
  773. if res2.Infcode != -1 {
  774. drug.IsPc = 1
  775. drug.Bchno = number
  776. drug.PcDate = time.Now().Unix()
  777. err := service.SaveW(drug)
  778. if err == nil {
  779. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  780. var struct3502 models.Struct3502
  781. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  782. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  783. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  784. struct3502.FixmedinsCode = miConfig.Code
  785. struct3502.Code = miConfig.Code
  786. struct3502.RxFlag = "0"
  787. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  788. struct3502.OrgName = miConfig.OrgName
  789. struct3502.Opter = roles.UserName
  790. struct3502.AccessKey = miConfig.AccessKey
  791. struct3502.RequestUrl = miConfig.Url
  792. struct3502.SecretKey = miConfig.SecretKey
  793. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  794. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  795. struct3502.Url = miConfig.Url
  796. struct3502.AppId = miConfig.Cainfo
  797. struct3502.AppSecret = miConfig.AppSecret
  798. struct3502.Enckey = miConfig.EncKey
  799. struct3502.SignKey = miConfig.SignKey
  800. struct3502.SecretKey = miConfig.SecretKey
  801. struct3502.DrugTracCodg = drug.DrugCode
  802. struct3502.Memo = ""
  803. struct3502.InvChgType = "108"
  804. struct3502.FixmedinsBchno = bg_number
  805. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  806. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  807. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  808. result11, result22, _ := service.FJyb3502(struct3502)
  809. saveLog(result11, result22, "3502", "3502")
  810. var respJSON3 map[string]interface{}
  811. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  814. return
  815. }
  816. userJSONBytes3, _ := json.Marshal(respJSON3)
  817. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  818. utils.ErrorLog("解析失败:%v", err)
  819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  820. return
  821. }
  822. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  823. data := make(map[string]interface{})
  824. data["struct_3502s"] = struct3502
  825. client := &http.Client{}
  826. bytesData, _ := json.Marshal(data)
  827. var req *http.Request
  828. if miConfig.MdtrtareaAdmvs == "320921" {
  829. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  830. } else {
  831. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  832. }
  833. resp, _ := client.Do(req)
  834. defer resp.Body.Close()
  835. body, ioErr := ioutil.ReadAll(resp.Body)
  836. if ioErr != nil {
  837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  838. }
  839. var respJSON map[string]interface{}
  840. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  843. return
  844. }
  845. var resSix10265 ResultSix10265 //1101结果
  846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  847. result, _ := json.Marshal(respJSON)
  848. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  849. utils.ErrorLog("解析失败:%v", err)
  850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  851. return
  852. }
  853. res3.InfRefmsgid = resSix10265.InfRefmsgid
  854. res3.Output = resSix10265.Output
  855. res3.ErrMsg = resSix10265.ErrMsg
  856. res3.Cainfo = resSix10265.Cainfo
  857. res3.WarnMsg = resSix10265.WarnMsg
  858. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  859. res3.Infcode = infocode
  860. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  861. data := make(map[string]interface{})
  862. data["struct_3502s"] = struct3502
  863. client := &http.Client{}
  864. bytesData, _ := json.Marshal(data)
  865. var req *http.Request
  866. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  867. resp, _ := client.Do(req)
  868. defer resp.Body.Close()
  869. body, ioErr := ioutil.ReadAll(resp.Body)
  870. if ioErr != nil {
  871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  872. }
  873. var respJSON map[string]interface{}
  874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  877. return
  878. }
  879. var resSix10265 ResultSix10265 //1101结果
  880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  881. result, _ := json.Marshal(respJSON)
  882. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  883. utils.ErrorLog("解析失败:%v", err)
  884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  885. return
  886. }
  887. res3.InfRefmsgid = resSix10265.InfRefmsgid
  888. res3.Output = resSix10265.Output
  889. res3.ErrMsg = resSix10265.ErrMsg
  890. res3.Cainfo = resSix10265.Cainfo
  891. res3.WarnMsg = resSix10265.WarnMsg
  892. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  893. res3.Infcode = infocode
  894. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  895. data := make(map[string]interface{})
  896. data["struct_3501s"] = struct3501
  897. client := &http.Client{}
  898. bytesData, _ := json.Marshal(data)
  899. var req *http.Request
  900. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  901. resp, _ := client.Do(req)
  902. defer resp.Body.Close()
  903. body, ioErr := ioutil.ReadAll(resp.Body)
  904. if ioErr != nil {
  905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  906. }
  907. var respJSON map[string]interface{}
  908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. return
  912. }
  913. var resSix10265 ResultSix10265 //1101结果
  914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  915. result, _ := json.Marshal(respJSON)
  916. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  917. utils.ErrorLog("解析失败:%v", err)
  918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  919. return
  920. }
  921. res2.InfRefmsgid = resSix10265.InfRefmsgid
  922. res2.Output = resSix10265.Output
  923. res2.ErrMsg = resSix10265.ErrMsg
  924. res2.Cainfo = resSix10265.Cainfo
  925. res2.WarnMsg = resSix10265.WarnMsg
  926. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  927. res2.Infcode = infocode
  928. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  929. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  930. saveLog(result11, result22, "3502", "3502")
  931. var respJSON3 map[string]interface{}
  932. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  935. return
  936. }
  937. userJSONBytes3, _ := json.Marshal(respJSON3)
  938. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  939. utils.ErrorLog("解析失败:%v", err)
  940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  941. return
  942. }
  943. }
  944. if res3.Infcode == -1 {
  945. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  946. c.ServeSuccessJSON(map[string]interface{}{
  947. "failed_code": -10,
  948. "msg": res3.ErrMsg,
  949. })
  950. } else {
  951. drug.IsBg = 1
  952. drug.BgBchno = bg_number
  953. service.SaveW(drug)
  954. }
  955. }
  956. } else {
  957. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  958. }
  959. }
  960. //变更
  961. }
  962. if len(errs) == 0 {
  963. c.ServeSuccessJSON(map[string]interface{}{
  964. "msg": "盘存变更成功",
  965. })
  966. } else {
  967. c.ServeSuccessJSON(map[string]interface{}{
  968. "failed_code": -10,
  969. "msg": errs,
  970. })
  971. }
  972. }
  973. func (c *HisApiController) DeletePCandBG() {
  974. ids := c.GetString("ids")
  975. id_arr := strings.Split(ids, ",")
  976. admin_user_id, _ := c.GetInt64("admin_user_id")
  977. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  978. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  979. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  980. var err []string
  981. for _, item := range drugs {
  982. if item.IsPc == 1 && item.IsBg == 1 {
  983. var res FJ3507Result
  984. var res2 FJ3507Result
  985. var struct3507 models.Struct3507
  986. struct3507.FixmedinsBchno = item.Bchno
  987. struct3507.InvDataType = "1"
  988. struct3507.Opter = roles.UserName
  989. struct3507.OrgName = miConfig.OrgName
  990. struct3507.AccessKey = miConfig.AccessKey
  991. struct3507.RequestUrl = miConfig.Url
  992. struct3507.FixmedinsCode = miConfig.Code
  993. struct3507.Code = miConfig.Code
  994. struct3507.SecretKey = miConfig.SecretKey
  995. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  996. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  997. struct3507.Url = miConfig.Url
  998. struct3507.AppId = miConfig.Cainfo
  999. struct3507.AppSecret = miConfig.AppSecret
  1000. struct3507.Enckey = miConfig.EncKey
  1001. struct3507.SignKey = miConfig.SignKey
  1002. struct3507.SecretKey = miConfig.SecretKey
  1003. if miConfig.MdtrtareaAdmvs == "350500" {
  1004. result, result1, _ := service.FJyb3507(struct3507)
  1005. saveLog(result, result1, "3507", "3507")
  1006. var respJSON2 map[string]interface{}
  1007. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1010. return
  1011. }
  1012. userJSONBytes2, _ := json.Marshal(respJSON2)
  1013. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1014. utils.ErrorLog("解析失败:%v", err)
  1015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1016. return
  1017. }
  1018. } else {
  1019. data := make(map[string]interface{})
  1020. data["struct_3507s"] = struct3507
  1021. client := &http.Client{}
  1022. bytesData, _ := json.Marshal(data)
  1023. var req *http.Request
  1024. if miConfig.MdtrtareaAdmvs == "320921" {
  1025. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1026. } else {
  1027. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1028. }
  1029. resp, _ := client.Do(req)
  1030. defer resp.Body.Close()
  1031. body, ioErr := ioutil.ReadAll(resp.Body)
  1032. if ioErr != nil {
  1033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1034. }
  1035. var respJSON map[string]interface{}
  1036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. var resSix10265 ResultSix10265 //1101结果
  1042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1043. result, _ := json.Marshal(respJSON)
  1044. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1045. utils.ErrorLog("解析失败:%v", err)
  1046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1047. return
  1048. }
  1049. res.InfRefmsgid = resSix10265.InfRefmsgid
  1050. //res.Output = resSix10265.Output
  1051. res.ErrMsg = resSix10265.ErrMsg
  1052. res.Cainfo = resSix10265.Cainfo
  1053. res.WarnMsg = resSix10265.WarnMsg
  1054. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1055. res.Infcode = infocode
  1056. }
  1057. if res.Infcode == 0 {
  1058. item.IsPc = 0
  1059. err2 := service.SaveW(item)
  1060. if err2 == nil {
  1061. var struct3507_2 models.Struct3507
  1062. struct3507_2.OrgName = miConfig.OrgName
  1063. struct3507_2.AccessKey = miConfig.AccessKey
  1064. struct3507_2.RequestUrl = miConfig.Url
  1065. struct3507_2.Opter = roles.UserName
  1066. struct3507_2.FixmedinsCode = miConfig.Code
  1067. struct3507_2.Code = miConfig.Code
  1068. struct3507_2.SecretKey = miConfig.SecretKey
  1069. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1070. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1071. struct3507_2.Url = miConfig.Url
  1072. struct3507_2.AppId = miConfig.Cainfo
  1073. struct3507_2.AppSecret = miConfig.AppSecret
  1074. struct3507_2.Enckey = miConfig.EncKey
  1075. struct3507_2.SignKey = miConfig.SignKey
  1076. struct3507_2.SecretKey = miConfig.SecretKey
  1077. struct3507_2.FixmedinsBchno = item.BgBchno
  1078. struct3507_2.InvDataType = "2"
  1079. if miConfig.MdtrtareaAdmvs == "350500" {
  1080. result11, result22, _ := service.FJyb3507(struct3507_2)
  1081. saveLog(result11, result22, "3507", "3507")
  1082. var respJSON3 map[string]interface{}
  1083. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1086. return
  1087. }
  1088. userJSONBytes3, _ := json.Marshal(respJSON3)
  1089. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1090. utils.ErrorLog("解析失败:%v", err)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. } else {
  1095. data := make(map[string]interface{})
  1096. data["struct_3507s"] = struct3507_2
  1097. client := &http.Client{}
  1098. bytesData, _ := json.Marshal(data)
  1099. var req *http.Request
  1100. if miConfig.MdtrtareaAdmvs == "320921" {
  1101. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1102. } else {
  1103. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1104. }
  1105. resp, _ := client.Do(req)
  1106. defer resp.Body.Close()
  1107. body, ioErr := ioutil.ReadAll(resp.Body)
  1108. if ioErr != nil {
  1109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1110. }
  1111. var respJSON map[string]interface{}
  1112. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1115. return
  1116. }
  1117. var resSix10265 ResultSix10265 //1101结果
  1118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1119. result, _ := json.Marshal(respJSON)
  1120. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1121. utils.ErrorLog("解析失败:%v", err)
  1122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1123. return
  1124. }
  1125. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1126. //res2.Output = resSix10265.Output
  1127. res2.ErrMsg = resSix10265.ErrMsg
  1128. res2.Cainfo = resSix10265.Cainfo
  1129. res2.WarnMsg = resSix10265.WarnMsg
  1130. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1131. res2.Infcode = infocode
  1132. }
  1133. if res2.Infcode != -1 {
  1134. item.IsBg = 0
  1135. item.Bchno = ""
  1136. item.BgBchno = ""
  1137. item.PcDate = 0
  1138. service.SaveW(item)
  1139. } else {
  1140. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1141. }
  1142. }
  1143. } else {
  1144. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1145. }
  1146. }
  1147. if item.IsPc == 1 && item.IsBg == 0 {
  1148. var res FJ3507Result
  1149. var struct3507 models.Struct3507
  1150. struct3507.FixmedinsBchno = item.Bchno
  1151. struct3507.InvDataType = "1"
  1152. struct3507.Opter = roles.UserName
  1153. struct3507.FixmedinsCode = miConfig.Code
  1154. struct3507.Code = miConfig.Code
  1155. struct3507.OrgName = miConfig.OrgName
  1156. struct3507.AccessKey = miConfig.AccessKey
  1157. struct3507.RequestUrl = miConfig.Url
  1158. struct3507.SecretKey = miConfig.SecretKey
  1159. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1160. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1161. struct3507.Url = miConfig.Url
  1162. struct3507.AppId = miConfig.Cainfo
  1163. struct3507.AppSecret = miConfig.AppSecret
  1164. struct3507.Enckey = miConfig.EncKey
  1165. struct3507.SignKey = miConfig.SignKey
  1166. struct3507.SecretKey = miConfig.SecretKey
  1167. //result, result1, _ := service.FJyb3507(struct3507)
  1168. //saveLog(result, result1, "3507", "3507")
  1169. if miConfig.MdtrtareaAdmvs == "350500" {
  1170. result, result1, _ := service.FJyb3507(struct3507)
  1171. saveLog(result, result1, "3507", "3507")
  1172. var respJSON2 map[string]interface{}
  1173. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1176. return
  1177. }
  1178. userJSONBytes2, _ := json.Marshal(respJSON2)
  1179. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1180. utils.ErrorLog("解析失败:%v", err)
  1181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. return
  1183. }
  1184. } else {
  1185. data := make(map[string]interface{})
  1186. data["struct_3507s"] = struct3507
  1187. client := &http.Client{}
  1188. bytesData, _ := json.Marshal(data)
  1189. var req *http.Request
  1190. if miConfig.MdtrtareaAdmvs == "320921" {
  1191. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1192. } else {
  1193. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1194. }
  1195. resp, _ := client.Do(req)
  1196. defer resp.Body.Close()
  1197. body, ioErr := ioutil.ReadAll(resp.Body)
  1198. if ioErr != nil {
  1199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1200. }
  1201. var respJSON map[string]interface{}
  1202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1205. return
  1206. }
  1207. var resSix10265 ResultSix10265 //1101结果
  1208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1209. result, _ := json.Marshal(respJSON)
  1210. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1211. utils.ErrorLog("解析失败:%v", err)
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1213. return
  1214. }
  1215. res.InfRefmsgid = resSix10265.InfRefmsgid
  1216. //res.Output = resSix10265.Output
  1217. res.ErrMsg = resSix10265.ErrMsg
  1218. res.Cainfo = resSix10265.Cainfo
  1219. res.WarnMsg = resSix10265.WarnMsg
  1220. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1221. res.Infcode = infocode
  1222. }
  1223. if res.Infcode == 0 {
  1224. item.IsPc = 0
  1225. item.Bchno = ""
  1226. item.BgBchno = ""
  1227. item.PcDate = 0
  1228. service.SaveW(item)
  1229. } else {
  1230. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1231. }
  1232. }
  1233. if item.IsPc == 0 && item.IsBg == 1 {
  1234. var res FJ3507Result
  1235. var struct3507 models.Struct3507
  1236. struct3507.FixmedinsBchno = item.BgBchno
  1237. struct3507.InvDataType = "2"
  1238. struct3507.Opter = roles.UserName
  1239. struct3507.FixmedinsCode = miConfig.Code
  1240. struct3507.OrgName = miConfig.OrgName
  1241. struct3507.AccessKey = miConfig.AccessKey
  1242. struct3507.RequestUrl = miConfig.Url
  1243. struct3507.SecretKey = miConfig.SecretKey
  1244. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1245. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1246. struct3507.Url = miConfig.Url
  1247. struct3507.AppId = miConfig.Cainfo
  1248. struct3507.AppSecret = miConfig.AppSecret
  1249. struct3507.Enckey = miConfig.EncKey
  1250. struct3507.SignKey = miConfig.SignKey
  1251. struct3507.SecretKey = miConfig.SecretKey
  1252. //result, result1, _ := service.FJyb3507(struct3507)
  1253. //saveLog(result, result1, "3507", "3507")
  1254. if miConfig.MdtrtareaAdmvs == "350500" {
  1255. result, result1, _ := service.FJyb3507(struct3507)
  1256. saveLog(result, result1, "3507", "3507")
  1257. var respJSON2 map[string]interface{}
  1258. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1261. return
  1262. }
  1263. userJSONBytes2, _ := json.Marshal(respJSON2)
  1264. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1265. utils.ErrorLog("解析失败:%v", err)
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1267. return
  1268. }
  1269. } else {
  1270. data := make(map[string]interface{})
  1271. data["struct_3507s"] = struct3507
  1272. client := &http.Client{}
  1273. bytesData, _ := json.Marshal(data)
  1274. var req *http.Request
  1275. if miConfig.MdtrtareaAdmvs == "320921" {
  1276. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1277. } else {
  1278. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1279. }
  1280. resp, _ := client.Do(req)
  1281. defer resp.Body.Close()
  1282. body, ioErr := ioutil.ReadAll(resp.Body)
  1283. if ioErr != nil {
  1284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1285. }
  1286. var respJSON map[string]interface{}
  1287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1290. return
  1291. }
  1292. var resSix10265 ResultSix10265 //1101结果
  1293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1294. result, _ := json.Marshal(respJSON)
  1295. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1296. utils.ErrorLog("解析失败:%v", err)
  1297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1298. return
  1299. }
  1300. res.InfRefmsgid = resSix10265.InfRefmsgid
  1301. //res.Output = resSix10265.Output
  1302. res.ErrMsg = resSix10265.ErrMsg
  1303. res.Cainfo = resSix10265.Cainfo
  1304. res.WarnMsg = resSix10265.WarnMsg
  1305. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1306. res.Infcode = infocode
  1307. }
  1308. if res.Infcode == 0 {
  1309. item.IsBg = 0
  1310. item.Bchno = ""
  1311. item.BgBchno = ""
  1312. item.PcDate = 0
  1313. service.SaveW(item)
  1314. } else {
  1315. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1316. }
  1317. }
  1318. }
  1319. if len(err) == 0 {
  1320. c.ServeSuccessJSON(map[string]interface{}{
  1321. "msg": "删除盘存变更成功",
  1322. })
  1323. } else {
  1324. c.ServeSuccessJSON(map[string]interface{}{
  1325. "failed_code": -10,
  1326. "msg": err,
  1327. })
  1328. }
  1329. }
  1330. func (c *HisApiController) DeleteXSandBG() {
  1331. ids := c.GetString("ids")
  1332. id_arr := strings.Split(ids, ",")
  1333. admin_user_id, _ := c.GetInt64("admin_user_id")
  1334. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1335. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1337. var err []string
  1338. for _, item := range flows {
  1339. if item.IsSale == 1 && item.IsChange == 1 {
  1340. var res FJ3507Result
  1341. var res2 FJ3507Result
  1342. var struct3507 models.Struct3507
  1343. struct3507.FixmedinsBchno = item.Bchno
  1344. struct3507.InvDataType = "4"
  1345. struct3507.Opter = roles.UserName
  1346. struct3507.OrgName = miConfig.OrgName
  1347. struct3507.AccessKey = miConfig.AccessKey
  1348. struct3507.RequestUrl = miConfig.Url
  1349. struct3507.FixmedinsCode = miConfig.Code
  1350. struct3507.SecretKey = miConfig.SecretKey
  1351. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1352. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1353. struct3507.Url = miConfig.Url
  1354. struct3507.AppId = miConfig.Cainfo
  1355. struct3507.AppSecret = miConfig.AppSecret
  1356. struct3507.Enckey = miConfig.EncKey
  1357. struct3507.SignKey = miConfig.SignKey
  1358. struct3507.SecretKey = miConfig.SecretKey
  1359. //result, result1, _ := service.FJyb3507(struct3507)
  1360. //saveLog(result, result1, "3507", "3507")
  1361. if miConfig.MdtrtareaAdmvs == "350500" {
  1362. result, result1, _ := service.FJyb3507(struct3507)
  1363. saveLog(result, result1, "3507", "3507")
  1364. var respJSON2 map[string]interface{}
  1365. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1368. return
  1369. }
  1370. userJSONBytes2, _ := json.Marshal(respJSON2)
  1371. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1372. utils.ErrorLog("解析失败:%v", err)
  1373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1374. return
  1375. }
  1376. } else {
  1377. data := make(map[string]interface{})
  1378. data["struct_3507s"] = struct3507
  1379. client := &http.Client{}
  1380. bytesData, _ := json.Marshal(data)
  1381. var req *http.Request
  1382. if miConfig.MdtrtareaAdmvs == "320921" {
  1383. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1384. } else {
  1385. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1386. }
  1387. resp, _ := client.Do(req)
  1388. defer resp.Body.Close()
  1389. body, ioErr := ioutil.ReadAll(resp.Body)
  1390. if ioErr != nil {
  1391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1392. }
  1393. var respJSON map[string]interface{}
  1394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1397. return
  1398. }
  1399. var resSix10265 ResultSix10265 //1101结果
  1400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1401. result, _ := json.Marshal(respJSON)
  1402. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1403. utils.ErrorLog("解析失败:%v", err)
  1404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1405. return
  1406. }
  1407. res.InfRefmsgid = resSix10265.InfRefmsgid
  1408. //res.Output = resSix10265.Output
  1409. res.ErrMsg = resSix10265.ErrMsg
  1410. res.Cainfo = resSix10265.Cainfo
  1411. res.WarnMsg = resSix10265.WarnMsg
  1412. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1413. res.Infcode = infocode
  1414. }
  1415. if res.Infcode == 0 {
  1416. item.IsSale = 0
  1417. item.SaleDate = ""
  1418. item.Bchno = ""
  1419. err2 := service.SaveDF(item)
  1420. if err2 == nil {
  1421. var struct3507_2 models.Struct3507
  1422. struct3507_2.OrgName = miConfig.OrgName
  1423. struct3507_2.AccessKey = miConfig.AccessKey
  1424. struct3507_2.RequestUrl = miConfig.Url
  1425. struct3507_2.Opter = roles.UserName
  1426. struct3507_2.FixmedinsCode = miConfig.Code
  1427. struct3507_2.Code = miConfig.Code
  1428. struct3507_2.SecretKey = miConfig.SecretKey
  1429. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1430. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1431. struct3507_2.Url = miConfig.Url
  1432. struct3507_2.AppId = miConfig.Cainfo
  1433. struct3507_2.AppSecret = miConfig.AppSecret
  1434. struct3507_2.Enckey = miConfig.EncKey
  1435. struct3507_2.SignKey = miConfig.SignKey
  1436. struct3507_2.SecretKey = miConfig.SecretKey
  1437. struct3507_2.FixmedinsBchno = item.BgBchno
  1438. struct3507_2.InvDataType = "2"
  1439. if miConfig.MdtrtareaAdmvs == "350500" {
  1440. result11, result22, _ := service.FJyb3507(struct3507_2)
  1441. saveLog(result11, result22, "3507", "3507")
  1442. var respJSON3 map[string]interface{}
  1443. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1446. return
  1447. }
  1448. userJSONBytes3, _ := json.Marshal(respJSON3)
  1449. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1450. utils.ErrorLog("解析失败:%v", err)
  1451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1452. return
  1453. }
  1454. } else {
  1455. data := make(map[string]interface{})
  1456. data["struct_3507s"] = struct3507_2
  1457. client := &http.Client{}
  1458. bytesData, _ := json.Marshal(data)
  1459. var req *http.Request
  1460. if miConfig.MdtrtareaAdmvs == "320921" {
  1461. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1462. } else {
  1463. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1464. }
  1465. resp, _ := client.Do(req)
  1466. defer resp.Body.Close()
  1467. body, ioErr := ioutil.ReadAll(resp.Body)
  1468. if ioErr != nil {
  1469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1470. }
  1471. var respJSON map[string]interface{}
  1472. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1475. return
  1476. }
  1477. var resSix10265 ResultSix10265 //1101结果
  1478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1479. result, _ := json.Marshal(respJSON)
  1480. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1481. utils.ErrorLog("解析失败:%v", err)
  1482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1483. return
  1484. }
  1485. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1486. //res.Output = resSix10265.Output
  1487. res2.ErrMsg = resSix10265.ErrMsg
  1488. res2.Cainfo = resSix10265.Cainfo
  1489. res2.WarnMsg = resSix10265.WarnMsg
  1490. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1491. res2.Infcode = infocode
  1492. }
  1493. if res2.Infcode == 0 {
  1494. item.IsChange = 0
  1495. item.BgBchno = ""
  1496. service.SaveDF2(item)
  1497. } else {
  1498. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1499. }
  1500. }
  1501. } else {
  1502. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1503. }
  1504. }
  1505. if item.IsSale == 2 && item.IsChange == 1 {
  1506. var res FJ3507Result
  1507. var res2 FJ3507Result
  1508. var struct3507 models.Struct3507
  1509. struct3507.FixmedinsBchno = item.Bchno
  1510. struct3507.InvDataType = "4"
  1511. struct3507.Opter = roles.UserName
  1512. struct3507.OrgName = miConfig.OrgName
  1513. struct3507.AccessKey = miConfig.AccessKey
  1514. struct3507.RequestUrl = miConfig.Url
  1515. struct3507.FixmedinsCode = miConfig.Code
  1516. struct3507.Code = miConfig.Code
  1517. struct3507.SecretKey = miConfig.SecretKey
  1518. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1519. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1520. struct3507.Url = miConfig.Url
  1521. struct3507.AppId = miConfig.Cainfo
  1522. struct3507.AppSecret = miConfig.AppSecret
  1523. struct3507.Enckey = miConfig.EncKey
  1524. struct3507.SignKey = miConfig.SignKey
  1525. struct3507.SecretKey = miConfig.SecretKey
  1526. //result, result1, _ := service.FJyb3507(struct3507)
  1527. //saveLog(result, result1, "3507", "3507")
  1528. //
  1529. //var respJSON2 map[string]interface{}
  1530. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1531. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. // return
  1534. //}
  1535. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1536. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1537. // utils.ErrorLog("解析失败:%v", err)
  1538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. // return
  1540. //}
  1541. if miConfig.MdtrtareaAdmvs == "350500" {
  1542. result, result1, _ := service.FJyb3507(struct3507)
  1543. saveLog(result, result1, "3507", "3507")
  1544. var respJSON2 map[string]interface{}
  1545. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1548. return
  1549. }
  1550. userJSONBytes2, _ := json.Marshal(respJSON2)
  1551. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1552. utils.ErrorLog("解析失败:%v", err)
  1553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1554. return
  1555. }
  1556. } else {
  1557. data := make(map[string]interface{})
  1558. data["struct_3507s"] = struct3507
  1559. client := &http.Client{}
  1560. bytesData, _ := json.Marshal(data)
  1561. var req *http.Request
  1562. if miConfig.MdtrtareaAdmvs == "320921" {
  1563. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1564. } else {
  1565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1566. }
  1567. resp, _ := client.Do(req)
  1568. defer resp.Body.Close()
  1569. body, ioErr := ioutil.ReadAll(resp.Body)
  1570. if ioErr != nil {
  1571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1572. }
  1573. var respJSON map[string]interface{}
  1574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1577. return
  1578. }
  1579. var resSix10265 ResultSix10265 //1101结果
  1580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1581. result, _ := json.Marshal(respJSON)
  1582. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1583. utils.ErrorLog("解析失败:%v", err)
  1584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1585. return
  1586. }
  1587. res.InfRefmsgid = resSix10265.InfRefmsgid
  1588. //res.Output = resSix10265.Output
  1589. res.ErrMsg = resSix10265.ErrMsg
  1590. res.Cainfo = resSix10265.Cainfo
  1591. res.WarnMsg = resSix10265.WarnMsg
  1592. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1593. res.Infcode = infocode
  1594. }
  1595. if res.Infcode == 0 {
  1596. item.IsSale = 0
  1597. item.SaleDate = ""
  1598. item.Bchno = ""
  1599. err2 := service.SaveDF(item)
  1600. if err2 == nil {
  1601. var struct3507_2 models.Struct3507
  1602. struct3507_2.OrgName = miConfig.OrgName
  1603. struct3507_2.AccessKey = miConfig.AccessKey
  1604. struct3507_2.RequestUrl = miConfig.Url
  1605. struct3507_2.Opter = roles.UserName
  1606. struct3507_2.FixmedinsCode = miConfig.Code
  1607. struct3507_2.Code = miConfig.Code
  1608. struct3507_2.SecretKey = miConfig.SecretKey
  1609. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1610. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1611. struct3507_2.Url = miConfig.Url
  1612. struct3507_2.AppId = miConfig.Cainfo
  1613. struct3507_2.AppSecret = miConfig.AppSecret
  1614. struct3507_2.Enckey = miConfig.EncKey
  1615. struct3507_2.SignKey = miConfig.SignKey
  1616. struct3507_2.SecretKey = miConfig.SecretKey
  1617. struct3507_2.FixmedinsBchno = item.BgBchno
  1618. struct3507_2.InvDataType = "2"
  1619. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1620. //saveLog(result11, result22, "3507", "3507")
  1621. //var respJSON3 map[string]interface{}
  1622. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1623. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1625. // return
  1626. //}
  1627. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1628. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1629. // utils.ErrorLog("解析失败:%v", err)
  1630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1631. // return
  1632. //}
  1633. if miConfig.MdtrtareaAdmvs == "350500" {
  1634. result11, result22, _ := service.FJyb3507(struct3507_2)
  1635. saveLog(result11, result22, "3507", "3507")
  1636. var respJSON3 map[string]interface{}
  1637. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. userJSONBytes3, _ := json.Marshal(respJSON3)
  1643. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1644. utils.ErrorLog("解析失败:%v", err)
  1645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1646. return
  1647. }
  1648. } else {
  1649. data := make(map[string]interface{})
  1650. data["struct_3507s"] = struct3507_2
  1651. client := &http.Client{}
  1652. bytesData, _ := json.Marshal(data)
  1653. var req *http.Request
  1654. if miConfig.MdtrtareaAdmvs == "320921" {
  1655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1656. } else {
  1657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1658. }
  1659. resp, _ := client.Do(req)
  1660. defer resp.Body.Close()
  1661. body, ioErr := ioutil.ReadAll(resp.Body)
  1662. if ioErr != nil {
  1663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1664. }
  1665. var respJSON map[string]interface{}
  1666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1669. return
  1670. }
  1671. var resSix10265 ResultSix10265 //1101结果
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. result, _ := json.Marshal(respJSON)
  1674. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1675. utils.ErrorLog("解析失败:%v", err)
  1676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1677. return
  1678. }
  1679. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1680. //res.Output = resSix10265.Output
  1681. res2.ErrMsg = resSix10265.ErrMsg
  1682. res2.Cainfo = resSix10265.Cainfo
  1683. res2.WarnMsg = resSix10265.WarnMsg
  1684. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1685. res2.Infcode = infocode
  1686. }
  1687. if res2.Infcode == 0 {
  1688. item.IsChange = 0
  1689. item.BgBchno = ""
  1690. service.SaveDF2(item)
  1691. } else {
  1692. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1693. }
  1694. }
  1695. } else {
  1696. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1697. }
  1698. }
  1699. if item.IsSale == 1 && item.IsChange == 0 {
  1700. var res FJ3507Result
  1701. var struct3507 models.Struct3507
  1702. struct3507.FixmedinsBchno = item.Bchno
  1703. struct3507.InvDataType = "4"
  1704. struct3507.Opter = roles.UserName
  1705. struct3507.FixmedinsCode = miConfig.Code
  1706. struct3507.Code = miConfig.Code
  1707. struct3507.OrgName = miConfig.OrgName
  1708. struct3507.AccessKey = miConfig.AccessKey
  1709. struct3507.RequestUrl = miConfig.Url
  1710. struct3507.SecretKey = miConfig.SecretKey
  1711. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1712. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1713. struct3507.Url = miConfig.Url
  1714. struct3507.AppId = miConfig.Cainfo
  1715. struct3507.AppSecret = miConfig.AppSecret
  1716. struct3507.Enckey = miConfig.EncKey
  1717. struct3507.SignKey = miConfig.SignKey
  1718. struct3507.SecretKey = miConfig.SecretKey
  1719. //result, result1, _ := service.FJyb3507(struct3507)
  1720. //saveLog(result, result1, "3507", "3507")
  1721. //
  1722. //var respJSON3 map[string]interface{}
  1723. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1724. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1726. // return
  1727. //}
  1728. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1729. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1730. // utils.ErrorLog("解析失败:%v", err)
  1731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1732. // return
  1733. //}
  1734. if miConfig.MdtrtareaAdmvs == "350500" {
  1735. result, result1, _ := service.FJyb3507(struct3507)
  1736. saveLog(result, result1, "3507", "3507")
  1737. var respJSON2 map[string]interface{}
  1738. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1741. return
  1742. }
  1743. userJSONBytes2, _ := json.Marshal(respJSON2)
  1744. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1745. utils.ErrorLog("解析失败:%v", err)
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1747. return
  1748. }
  1749. } else {
  1750. data := make(map[string]interface{})
  1751. data["struct_3507s"] = struct3507
  1752. client := &http.Client{}
  1753. bytesData, _ := json.Marshal(data)
  1754. var req *http.Request
  1755. if miConfig.MdtrtareaAdmvs == "320921" {
  1756. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1757. } else {
  1758. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1759. }
  1760. resp, _ := client.Do(req)
  1761. defer resp.Body.Close()
  1762. body, ioErr := ioutil.ReadAll(resp.Body)
  1763. if ioErr != nil {
  1764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1765. }
  1766. var respJSON map[string]interface{}
  1767. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1770. return
  1771. }
  1772. var resSix10265 ResultSix10265 //1101结果
  1773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1774. result, _ := json.Marshal(respJSON)
  1775. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1776. utils.ErrorLog("解析失败:%v", err)
  1777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1778. return
  1779. }
  1780. res.InfRefmsgid = resSix10265.InfRefmsgid
  1781. //res.Output = resSix10265.Output
  1782. res.ErrMsg = resSix10265.ErrMsg
  1783. res.Cainfo = resSix10265.Cainfo
  1784. res.WarnMsg = resSix10265.WarnMsg
  1785. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1786. res.Infcode = infocode
  1787. }
  1788. if res.Infcode == 0 {
  1789. item.IsSale = 0
  1790. item.SaleDate = ""
  1791. service.SaveDF(item)
  1792. } else {
  1793. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1794. }
  1795. }
  1796. if item.IsSale == 2 && item.IsChange == 0 {
  1797. var res FJ3507Result
  1798. var struct3507 models.Struct3507
  1799. struct3507.FixmedinsBchno = item.Bchno
  1800. struct3507.InvDataType = "4"
  1801. struct3507.Opter = roles.UserName
  1802. struct3507.FixmedinsCode = miConfig.Code
  1803. struct3507.Code = miConfig.Code
  1804. struct3507.OrgName = miConfig.OrgName
  1805. struct3507.AccessKey = miConfig.AccessKey
  1806. struct3507.RequestUrl = miConfig.Url
  1807. struct3507.SecretKey = miConfig.SecretKey
  1808. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1809. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1810. struct3507.Url = miConfig.Url
  1811. struct3507.AppId = miConfig.Cainfo
  1812. struct3507.AppSecret = miConfig.AppSecret
  1813. struct3507.Enckey = miConfig.EncKey
  1814. struct3507.SignKey = miConfig.SignKey
  1815. struct3507.SecretKey = miConfig.SecretKey
  1816. //result, result1, _ := service.FJyb3507(struct3507)
  1817. //saveLog(result, result1, "3507", "3507")
  1818. //
  1819. //var respJSON3 map[string]interface{}
  1820. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1821. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1822. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. // return
  1824. //}
  1825. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1826. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1827. // utils.ErrorLog("解析失败:%v", err)
  1828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1829. // return
  1830. //}
  1831. if miConfig.MdtrtareaAdmvs == "350500" {
  1832. result, result1, _ := service.FJyb3507(struct3507)
  1833. saveLog(result, result1, "3507", "3507")
  1834. var respJSON2 map[string]interface{}
  1835. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1838. return
  1839. }
  1840. userJSONBytes2, _ := json.Marshal(respJSON2)
  1841. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1842. utils.ErrorLog("解析失败:%v", err)
  1843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1844. return
  1845. }
  1846. } else {
  1847. data := make(map[string]interface{})
  1848. data["struct_3507s"] = struct3507
  1849. client := &http.Client{}
  1850. bytesData, _ := json.Marshal(data)
  1851. var req *http.Request
  1852. if miConfig.MdtrtareaAdmvs == "320921" {
  1853. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1854. } else {
  1855. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1856. }
  1857. resp, _ := client.Do(req)
  1858. defer resp.Body.Close()
  1859. body, ioErr := ioutil.ReadAll(resp.Body)
  1860. if ioErr != nil {
  1861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1862. }
  1863. var respJSON map[string]interface{}
  1864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1867. return
  1868. }
  1869. var resSix10265 ResultSix10265 //1101结果
  1870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1871. result, _ := json.Marshal(respJSON)
  1872. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1873. utils.ErrorLog("解析失败:%v", err)
  1874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1875. return
  1876. }
  1877. res.InfRefmsgid = resSix10265.InfRefmsgid
  1878. //res.Output = resSix10265.Output
  1879. res.ErrMsg = resSix10265.ErrMsg
  1880. res.Cainfo = resSix10265.Cainfo
  1881. res.WarnMsg = resSix10265.WarnMsg
  1882. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1883. res.Infcode = infocode
  1884. }
  1885. if res.Infcode == 0 {
  1886. item.IsSale = 0
  1887. item.SaleDate = ""
  1888. item.Bchno = ""
  1889. service.SaveDF(item)
  1890. } else {
  1891. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1892. }
  1893. }
  1894. if item.IsSale == 0 && item.IsChange == 1 {
  1895. var res FJ3507Result
  1896. var struct3507 models.Struct3507
  1897. struct3507.FixmedinsBchno = item.BgBchno
  1898. struct3507.InvDataType = "2"
  1899. struct3507.Opter = roles.UserName
  1900. struct3507.FixmedinsCode = miConfig.Code
  1901. struct3507.Code = miConfig.Code
  1902. struct3507.OrgName = miConfig.OrgName
  1903. struct3507.AccessKey = miConfig.AccessKey
  1904. struct3507.RequestUrl = miConfig.Url
  1905. struct3507.SecretKey = miConfig.SecretKey
  1906. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1907. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1908. struct3507.Url = miConfig.Url
  1909. struct3507.AppId = miConfig.Cainfo
  1910. struct3507.AppSecret = miConfig.AppSecret
  1911. struct3507.Enckey = miConfig.EncKey
  1912. struct3507.SignKey = miConfig.SignKey
  1913. struct3507.SecretKey = miConfig.SecretKey
  1914. //result, result1, _ := service.FJyb3507(struct3507)
  1915. //saveLog(result, result1, "3507", "3507")
  1916. //
  1917. //var respJSON3 map[string]interface{}
  1918. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1919. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. // return
  1922. //}
  1923. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1924. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1925. // utils.ErrorLog("解析失败:%v", err)
  1926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1927. // return
  1928. //}
  1929. if miConfig.MdtrtareaAdmvs == "350500" {
  1930. result, result1, _ := service.FJyb3507(struct3507)
  1931. saveLog(result, result1, "3507", "3507")
  1932. var respJSON2 map[string]interface{}
  1933. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1936. return
  1937. }
  1938. userJSONBytes2, _ := json.Marshal(respJSON2)
  1939. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1940. utils.ErrorLog("解析失败:%v", err)
  1941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1942. return
  1943. }
  1944. } else {
  1945. data := make(map[string]interface{})
  1946. data["struct_3507s"] = struct3507
  1947. client := &http.Client{}
  1948. bytesData, _ := json.Marshal(data)
  1949. var req *http.Request
  1950. if miConfig.MdtrtareaAdmvs == "320921" {
  1951. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1952. } else {
  1953. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1954. }
  1955. resp, _ := client.Do(req)
  1956. defer resp.Body.Close()
  1957. body, ioErr := ioutil.ReadAll(resp.Body)
  1958. if ioErr != nil {
  1959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1960. }
  1961. var respJSON map[string]interface{}
  1962. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1965. return
  1966. }
  1967. var resSix10265 ResultSix10265 //1101结果
  1968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1969. result, _ := json.Marshal(respJSON)
  1970. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1971. utils.ErrorLog("解析失败:%v", err)
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1973. return
  1974. }
  1975. res.InfRefmsgid = resSix10265.InfRefmsgid
  1976. //res.Output = resSix10265.Output
  1977. res.ErrMsg = resSix10265.ErrMsg
  1978. res.Cainfo = resSix10265.Cainfo
  1979. res.WarnMsg = resSix10265.WarnMsg
  1980. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1981. res.Infcode = infocode
  1982. }
  1983. if res.Infcode == 0 {
  1984. item.IsChange = 0
  1985. item.BgBchno = ""
  1986. service.SaveDF2(item)
  1987. } else {
  1988. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1989. }
  1990. }
  1991. }
  1992. if len(err) == 0 {
  1993. c.ServeSuccessJSON(map[string]interface{}{
  1994. "msg": "删除销售变更成功",
  1995. })
  1996. } else {
  1997. c.ServeSuccessJSON(map[string]interface{}{
  1998. "failed_code": -10,
  1999. "msg": err,
  2000. })
  2001. }
  2002. }
  2003. //func (c *HisApiController) BatchFJ3501AND3502() {
  2004. // //ids := c.GetString("ids")
  2005. // start_time := c.GetString("start_time")
  2006. // end_time := c.GetString("end_time")
  2007. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2008. //
  2009. //
  2010. // timeLayout := "2006-01-02"
  2011. // loc, _ := time.LoadLocation("Local")
  2012. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2013. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2014. //
  2015. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2016. // //id_arr := strings.Split(ids, ",")
  2017. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2018. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2019. // //库盘
  2020. // var errs []string
  2021. // for _, drug := range drugs {
  2022. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2023. // var res2 ResultSix
  2024. // var res3 ResultSix
  2025. //
  2026. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2027. // var struct3501 models.Struct3501
  2028. // struct3501.Code = miConfig.Code
  2029. // struct3501.OrgName = miConfig.OrgName
  2030. // struct3501.AccessKey = miConfig.AccessKey
  2031. // struct3501.Opter = roles.UserName
  2032. // struct3501.RequestUrl = miConfig.Url
  2033. // struct3501.Url = miConfig.Url
  2034. // struct3501.AppId = miConfig.Cainfo
  2035. // struct3501.AppSecret = miConfig.AppSecret
  2036. // struct3501.Enckey = miConfig.EncKey
  2037. // struct3501.SignKey = miConfig.SignKey
  2038. // struct3501.SecretKey = miConfig.SecretKey
  2039. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2040. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2041. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2042. // struct3501.RxFlag = "1"
  2043. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2044. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2045. //
  2046. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2047. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2048. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2049. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2050. // struct3501.FixmedinsBchno = number
  2051. // struct3501.DrugTracCodg = drug.DrugCode
  2052. // memo := make(map[string]interface{})
  2053. // memo["pric"] = drug.Price
  2054. // bytesData, _ := json.Marshal(memo)
  2055. // struct3501.Memo = string(bytesData)
  2056. //
  2057. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2058. //
  2059. // result1, result2, _ := service.FJyb3501(struct3501)
  2060. // saveLog(result1, result2, "3501", "3501")
  2061. // //saveLog(result, requestLog, "2201", "挂号")
  2062. //
  2063. // var respJSON2 map[string]interface{}
  2064. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2065. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2067. // return
  2068. // }
  2069. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2070. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2071. // utils.ErrorLog("解析失败:%v", err)
  2072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. // return
  2074. // }
  2075. //
  2076. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2077. // data := make(map[string]interface{})
  2078. // data["struct_3501s"] = struct3501
  2079. // client := &http.Client{}
  2080. // bytesData, _ := json.Marshal(data)
  2081. // var req *http.Request
  2082. // if miConfig.MdtrtareaAdmvs == "320921" {
  2083. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2084. // } else {
  2085. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2086. // }
  2087. //
  2088. // resp, _ := client.Do(req)
  2089. // defer resp.Body.Close()
  2090. // body, ioErr := ioutil.ReadAll(resp.Body)
  2091. // if ioErr != nil {
  2092. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2093. // }
  2094. // var respJSON map[string]interface{}
  2095. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2096. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2098. // return
  2099. // }
  2100. // var resSix10265 ResultSix10265 //1101结果
  2101. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2102. // result, _ := json.Marshal(respJSON)
  2103. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2104. // utils.ErrorLog("解析失败:%v", err)
  2105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2106. // return
  2107. // }
  2108. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2109. // res2.Output = resSix10265.Output
  2110. // res2.ErrMsg = resSix10265.ErrMsg
  2111. // res2.Cainfo = resSix10265.Cainfo
  2112. // res2.WarnMsg = resSix10265.WarnMsg
  2113. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2114. // res2.Infcode = infocode
  2115. //
  2116. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2117. // data := make(map[string]interface{})
  2118. // data["struct_3501s"] = struct3501
  2119. // client := &http.Client{}
  2120. // bytesData, _ := json.Marshal(data)
  2121. // var req *http.Request
  2122. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2123. // resp, _ := client.Do(req)
  2124. // defer resp.Body.Close()
  2125. // body, ioErr := ioutil.ReadAll(resp.Body)
  2126. // if ioErr != nil {
  2127. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2128. // }
  2129. // var respJSON map[string]interface{}
  2130. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2131. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2133. // return
  2134. // }
  2135. // var resSix10265 ResultSix10265 //1101结果
  2136. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2137. // result, _ := json.Marshal(respJSON)
  2138. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2139. // utils.ErrorLog("解析失败:%v", err)
  2140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2141. // return
  2142. // }
  2143. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2144. // res2.Output = resSix10265.Output
  2145. // res2.ErrMsg = resSix10265.ErrMsg
  2146. // res2.Cainfo = resSix10265.Cainfo
  2147. // res2.WarnMsg = resSix10265.WarnMsg
  2148. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2149. // res2.Infcode = infocode
  2150. //
  2151. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2152. // data := make(map[string]interface{})
  2153. // data["struct_3501s"] = struct3501
  2154. // client := &http.Client{}
  2155. // bytesData, _ := json.Marshal(data)
  2156. // var req *http.Request
  2157. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2158. // resp, _ := client.Do(req)
  2159. // defer resp.Body.Close()
  2160. // body, ioErr := ioutil.ReadAll(resp.Body)
  2161. // if ioErr != nil {
  2162. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2163. // }
  2164. // var respJSON map[string]interface{}
  2165. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2166. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2168. // return
  2169. // }
  2170. // var resSix10265 ResultSix10265 //1101结果
  2171. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2172. // result, _ := json.Marshal(respJSON)
  2173. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2174. // utils.ErrorLog("解析失败:%v", err)
  2175. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2176. // return
  2177. // }
  2178. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2179. // res2.Output = resSix10265.Output
  2180. // res2.ErrMsg = resSix10265.ErrMsg
  2181. // res2.Cainfo = resSix10265.Cainfo
  2182. // res2.WarnMsg = resSix10265.WarnMsg
  2183. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2184. // res2.Infcode = infocode
  2185. //
  2186. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2187. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2188. // saveLog(result1, result2, "3501", "3501")
  2189. // //saveLog(result, requestLog, "2201", "挂号")
  2190. //
  2191. // var respJSON2 map[string]interface{}
  2192. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2195. // return
  2196. // }
  2197. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2198. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2199. // utils.ErrorLog("解析失败:%v", err)
  2200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2201. // return
  2202. // }
  2203. //
  2204. // }
  2205. //
  2206. // if res2.Infcode != -1 {
  2207. // drug.IsPc = 1
  2208. // drug.Bchno = number
  2209. // drug.PcDate = time.Now().Unix()
  2210. // err := service.SaveW(drug)
  2211. // if err == nil {
  2212. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2213. // var struct3502 models.Struct3502
  2214. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2215. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2216. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2217. // struct3502.FixmedinsCode = miConfig.Code
  2218. // struct3502.Code = miConfig.Code
  2219. //
  2220. // struct3502.RxFlag = "0"
  2221. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2222. // struct3502.OrgName = miConfig.OrgName
  2223. // struct3502.Opter = roles.UserName
  2224. // struct3502.AccessKey = miConfig.AccessKey
  2225. // struct3502.RequestUrl = miConfig.Url
  2226. // struct3502.SecretKey = miConfig.SecretKey
  2227. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2228. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2229. // struct3502.Url = miConfig.Url
  2230. // struct3502.AppId = miConfig.Cainfo
  2231. // struct3502.AppSecret = miConfig.AppSecret
  2232. // struct3502.Enckey = miConfig.EncKey
  2233. // struct3502.SignKey = miConfig.SignKey
  2234. // struct3502.SecretKey = miConfig.SecretKey
  2235. // struct3502.DrugTracCodg = drug.DrugCode
  2236. //
  2237. // struct3502.Memo = ""
  2238. // struct3502.InvChgType = "108"
  2239. // struct3502.FixmedinsBchno = bg_number
  2240. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2241. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2242. //
  2243. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2244. // result11, result22, _ := service.FJyb3502(struct3502)
  2245. // saveLog(result11, result22, "3502", "3502")
  2246. //
  2247. // var respJSON3 map[string]interface{}
  2248. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2249. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2251. // return
  2252. // }
  2253. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2254. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2255. // utils.ErrorLog("解析失败:%v", err)
  2256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2257. // return
  2258. // }
  2259. //
  2260. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2261. // data := make(map[string]interface{})
  2262. // data["struct_3502s"] = struct3502
  2263. // client := &http.Client{}
  2264. // bytesData, _ := json.Marshal(data)
  2265. // var req *http.Request
  2266. // if miConfig.MdtrtareaAdmvs == "320921" {
  2267. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2268. // } else {
  2269. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2270. // }
  2271. //
  2272. // resp, _ := client.Do(req)
  2273. // defer resp.Body.Close()
  2274. // body, ioErr := ioutil.ReadAll(resp.Body)
  2275. // if ioErr != nil {
  2276. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2277. // }
  2278. // var respJSON map[string]interface{}
  2279. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2280. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2282. // return
  2283. // }
  2284. // var resSix10265 ResultSix10265 //1101结果
  2285. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2286. // result, _ := json.Marshal(respJSON)
  2287. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2288. // utils.ErrorLog("解析失败:%v", err)
  2289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2290. // return
  2291. // }
  2292. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2293. // res3.Output = resSix10265.Output
  2294. // res3.ErrMsg = resSix10265.ErrMsg
  2295. // res3.Cainfo = resSix10265.Cainfo
  2296. // res3.WarnMsg = resSix10265.WarnMsg
  2297. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2298. // res3.Infcode = infocode
  2299. //
  2300. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2301. //
  2302. // data := make(map[string]interface{})
  2303. // data["struct_3502s"] = struct3502
  2304. // client := &http.Client{}
  2305. // bytesData, _ := json.Marshal(data)
  2306. // var req *http.Request
  2307. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2308. // resp, _ := client.Do(req)
  2309. // defer resp.Body.Close()
  2310. // body, ioErr := ioutil.ReadAll(resp.Body)
  2311. // if ioErr != nil {
  2312. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2313. // }
  2314. // var respJSON map[string]interface{}
  2315. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2316. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2318. // return
  2319. // }
  2320. // var resSix10265 ResultSix10265 //1101结果
  2321. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2322. // result, _ := json.Marshal(respJSON)
  2323. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2324. // utils.ErrorLog("解析失败:%v", err)
  2325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2326. // return
  2327. // }
  2328. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2329. // res3.Output = resSix10265.Output
  2330. // res3.ErrMsg = resSix10265.ErrMsg
  2331. // res3.Cainfo = resSix10265.Cainfo
  2332. // res3.WarnMsg = resSix10265.WarnMsg
  2333. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2334. // res3.Infcode = infocode
  2335. //
  2336. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2337. //
  2338. // data := make(map[string]interface{})
  2339. // data["struct_3501s"] = struct3501
  2340. // client := &http.Client{}
  2341. // bytesData, _ := json.Marshal(data)
  2342. // var req *http.Request
  2343. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2344. // resp, _ := client.Do(req)
  2345. // defer resp.Body.Close()
  2346. // body, ioErr := ioutil.ReadAll(resp.Body)
  2347. // if ioErr != nil {
  2348. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2349. // }
  2350. // var respJSON map[string]interface{}
  2351. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2352. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2354. // return
  2355. // }
  2356. // var resSix10265 ResultSix10265 //1101结果
  2357. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2358. // result, _ := json.Marshal(respJSON)
  2359. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2360. // utils.ErrorLog("解析失败:%v", err)
  2361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2362. // return
  2363. // }
  2364. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2365. // res2.Output = resSix10265.Output
  2366. // res2.ErrMsg = resSix10265.ErrMsg
  2367. // res2.Cainfo = resSix10265.Cainfo
  2368. // res2.WarnMsg = resSix10265.WarnMsg
  2369. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2370. // res2.Infcode = infocode
  2371. //
  2372. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2373. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2374. // saveLog(result11, result22, "3502", "3502")
  2375. //
  2376. // var respJSON3 map[string]interface{}
  2377. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. // return
  2381. // }
  2382. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2383. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2384. // utils.ErrorLog("解析失败:%v", err)
  2385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2386. // return
  2387. // }
  2388. // }
  2389. // if res3.Infcode == -1 {
  2390. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2391. // c.ServeSuccessJSON(map[string]interface{}{
  2392. // "failed_code": -10,
  2393. // "msg": res3.ErrMsg,
  2394. // })
  2395. // } else {
  2396. // drug.IsBg = 1
  2397. // drug.BgBchno = bg_number
  2398. // service.SaveW(drug)
  2399. // }
  2400. // }
  2401. // } else {
  2402. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2403. // }
  2404. // }
  2405. // //变更
  2406. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2407. // var res3 ResultSix
  2408. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2409. //
  2410. // var struct3502 models.Struct3502
  2411. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2412. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2413. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2414. // struct3502.FixmedinsCode = miConfig.Code
  2415. // struct3502.Code = miConfig.Code
  2416. //
  2417. // struct3502.Opter = roles.UserName
  2418. // struct3502.RxFlag = "0"
  2419. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2420. // struct3502.OrgName = miConfig.OrgName
  2421. // struct3502.AccessKey = miConfig.AccessKey
  2422. // struct3502.RequestUrl = miConfig.Url
  2423. // struct3502.SecretKey = miConfig.SecretKey
  2424. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2425. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2426. // struct3502.InvChgType = "108"
  2427. // struct3502.DrugTracCodg = drug.DrugCode
  2428. //
  2429. // struct3502.Url = miConfig.Url
  2430. // struct3502.AppId = miConfig.Cainfo
  2431. // struct3502.AppSecret = miConfig.AppSecret
  2432. // struct3502.Enckey = miConfig.EncKey
  2433. // struct3502.SignKey = miConfig.SignKey
  2434. // struct3502.SecretKey = miConfig.SecretKey
  2435. //
  2436. // struct3502.FixmedinsBchno = bg_number
  2437. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2438. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2439. //
  2440. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2441. // result1, result2, _ := service.FJyb3502(struct3502)
  2442. // saveLog(result1, result2, "3502", "3502")
  2443. // var respJSON3 map[string]interface{}
  2444. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2445. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2447. // return
  2448. // }
  2449. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2450. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2451. // utils.ErrorLog("解析失败:%v", err)
  2452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2453. // return
  2454. // }
  2455. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2456. // data := make(map[string]interface{})
  2457. // data["struct_3502s"] = struct3502
  2458. // client := &http.Client{}
  2459. // bytesData, _ := json.Marshal(data)
  2460. // var req *http.Request
  2461. // if miConfig.MdtrtareaAdmvs == "320921" {
  2462. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2463. // } else {
  2464. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2465. // }
  2466. // resp, _ := client.Do(req)
  2467. // defer resp.Body.Close()
  2468. // body, ioErr := ioutil.ReadAll(resp.Body)
  2469. // if ioErr != nil {
  2470. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2471. // }
  2472. // var respJSON map[string]interface{}
  2473. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2474. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2476. // return
  2477. // }
  2478. // var resSix10265 ResultSix10265 //1101结果
  2479. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2480. // result, _ := json.Marshal(respJSON)
  2481. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2482. // utils.ErrorLog("解析失败:%v", err)
  2483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2484. // return
  2485. // }
  2486. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2487. // res3.Output = resSix10265.Output
  2488. // res3.ErrMsg = resSix10265.ErrMsg
  2489. // res3.Cainfo = resSix10265.Cainfo
  2490. // res3.WarnMsg = resSix10265.WarnMsg
  2491. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2492. // res3.Infcode = infocode
  2493. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2494. //
  2495. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2496. //
  2497. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2498. //
  2499. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2500. //
  2501. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2502. // saveLog(result1, result2, "3501", "3501")
  2503. // //saveLog(result, requestLog, "2201", "挂号")
  2504. //
  2505. // var respJSON2 map[string]interface{}
  2506. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2507. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2509. // return
  2510. // }
  2511. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2512. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2513. // utils.ErrorLog("解析失败:%v", err)
  2514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2515. // return
  2516. // }
  2517. //
  2518. // }
  2519. // if res3.Infcode == -1 {
  2520. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2521. // } else {
  2522. // drug.IsBg = 1
  2523. // drug.BgBchno = bg_number
  2524. // service.SaveW(drug)
  2525. // }
  2526. // }
  2527. // }
  2528. //
  2529. // if len(errs) == 0 {
  2530. // c.ServeSuccessJSON(map[string]interface{}{
  2531. // "msg": "盘存变更成功",
  2532. // })
  2533. // } else {
  2534. // c.ServeSuccessJSON(map[string]interface{}{
  2535. // "failed_code": -10,
  2536. // "msg": errs,
  2537. // })
  2538. // }
  2539. //}
  2540. func (c *HisApiController) DeleteXSandBGTwo() {
  2541. patient_id, _ := c.GetInt64("patient_id")
  2542. admin_user_id, _ := c.GetInt64("admin_user_id")
  2543. times := c.GetString("time", "")
  2544. timeLayout := "2006-01-02"
  2545. loc, _ := time.LoadLocation("Local")
  2546. var stime, etime int64
  2547. if times == "" {
  2548. stime, etime = GetNowTime()
  2549. } else {
  2550. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2551. stime = stmp.Unix()
  2552. etime = stime + 86399
  2553. }
  2554. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2555. var flows []*models.DrugFlow
  2556. for _, item := range advicelist {
  2557. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2558. flows = append(flows, flow...)
  2559. }
  2560. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2561. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2562. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2563. var err []string
  2564. for _, item := range flows {
  2565. if item.IsSale == 1 {
  2566. var res FJ3507Result
  2567. var struct3507 models.Struct3507
  2568. struct3507.FixmedinsBchno = item.Bchno
  2569. struct3507.InvDataType = "4"
  2570. struct3507.Opter = roles.UserName
  2571. struct3507.OrgName = miConfig.OrgName
  2572. struct3507.AccessKey = miConfig.AccessKey
  2573. struct3507.RequestUrl = miConfig.Url
  2574. struct3507.FixmedinsCode = miConfig.Code
  2575. struct3507.SecretKey = miConfig.SecretKey
  2576. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2577. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2578. struct3507.Url = miConfig.Url
  2579. struct3507.AppId = miConfig.Cainfo
  2580. struct3507.AppSecret = miConfig.AppSecret
  2581. struct3507.Enckey = miConfig.EncKey
  2582. struct3507.SignKey = miConfig.SignKey
  2583. struct3507.SecretKey = miConfig.SecretKey
  2584. if miConfig.MdtrtareaAdmvs == "350500" {
  2585. result, result1, _ := service.FJyb3507(struct3507)
  2586. saveLog(result, result1, "3507", "3507")
  2587. var respJSON2 map[string]interface{}
  2588. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2591. return
  2592. }
  2593. userJSONBytes2, _ := json.Marshal(respJSON2)
  2594. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2595. utils.ErrorLog("解析失败:%v", err)
  2596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2597. return
  2598. }
  2599. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2600. data := make(map[string]interface{})
  2601. data["struct_3507s"] = struct3507
  2602. client := &http.Client{}
  2603. bytesData, _ := json.Marshal(data)
  2604. var req *http.Request
  2605. if miConfig.MdtrtareaAdmvs == "320921" {
  2606. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2607. } else {
  2608. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2609. }
  2610. resp, _ := client.Do(req)
  2611. defer resp.Body.Close()
  2612. body, ioErr := ioutil.ReadAll(resp.Body)
  2613. if ioErr != nil {
  2614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2615. }
  2616. var respJSON map[string]interface{}
  2617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2620. return
  2621. }
  2622. var resSix10265 ResultSix10265 //1101结果
  2623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2624. result, _ := json.Marshal(respJSON)
  2625. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2626. utils.ErrorLog("解析失败:%v", err)
  2627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. return
  2629. }
  2630. res.InfRefmsgid = resSix10265.InfRefmsgid
  2631. //res.Output = resSix10265.Output
  2632. res.ErrMsg = resSix10265.ErrMsg
  2633. res.Cainfo = resSix10265.Cainfo
  2634. res.WarnMsg = resSix10265.WarnMsg
  2635. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2636. res.Infcode = infocode
  2637. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2638. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2639. saveLog(result2, result1, "3507", "3507")
  2640. var respJSON2 map[string]interface{}
  2641. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2644. return
  2645. }
  2646. userJSONBytes2, _ := json.Marshal(respJSON2)
  2647. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2648. utils.ErrorLog("解析失败:%v", err)
  2649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2650. return
  2651. }
  2652. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2653. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2654. saveLog(result2, result1, "3507", "3507")
  2655. var respJSON2 map[string]interface{}
  2656. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2659. return
  2660. }
  2661. userJSONBytes2, _ := json.Marshal(respJSON2)
  2662. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2663. utils.ErrorLog("解析失败:%v", err)
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. return
  2666. }
  2667. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2668. result1, result2 := service.Jxyb3507(struct3507)
  2669. saveLog(result2, result1, "3507", "3507")
  2670. var respJSON2 map[string]interface{}
  2671. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2674. return
  2675. }
  2676. userJSONBytes2, _ := json.Marshal(respJSON2)
  2677. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2678. utils.ErrorLog("解析失败:%v", err)
  2679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2680. return
  2681. }
  2682. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2683. result1, result2 := service.AHyb3507(struct3507)
  2684. saveLog(result2, result1, "3507", "3507")
  2685. var respJSON2 map[string]interface{}
  2686. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2689. return
  2690. }
  2691. userJSONBytes2, _ := json.Marshal(respJSON2)
  2692. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2693. utils.ErrorLog("解析失败:%v", err)
  2694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2695. return
  2696. }
  2697. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2698. data := make(map[string]interface{})
  2699. data["struct_3507s"] = struct3507
  2700. client := &http.Client{}
  2701. bytesData, _ := json.Marshal(data)
  2702. var req *http.Request
  2703. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2704. resp, _ := client.Do(req)
  2705. defer resp.Body.Close()
  2706. body, ioErr := ioutil.ReadAll(resp.Body)
  2707. if ioErr != nil {
  2708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2709. }
  2710. var respJSON map[string]interface{}
  2711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2713. }
  2714. var resSix10265 ResultSix10265 //1101结果
  2715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2716. result, _ := json.Marshal(respJSON)
  2717. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2718. utils.ErrorLog("解析失败:%v", err)
  2719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2720. return
  2721. }
  2722. res.InfRefmsgid = resSix10265.InfRefmsgid
  2723. res.ErrMsg = resSix10265.ErrMsg
  2724. res.Cainfo = resSix10265.Cainfo
  2725. res.WarnMsg = resSix10265.WarnMsg
  2726. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2727. res.Infcode = infocode
  2728. }
  2729. if res.Infcode == 0 {
  2730. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2731. item.IsSale = 0
  2732. item.SaleDate = ""
  2733. item.Bchno = ""
  2734. service.SaveDF(item)
  2735. } else {
  2736. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2737. }
  2738. }
  2739. }
  2740. c.ServeSuccessJSON(map[string]interface{}{
  2741. "msg": "删除销售数据成功",
  2742. })
  2743. }
  2744. // 获取当天起止时间戳
  2745. func GetNowTime() (int64, int64) {
  2746. t := time.Now()
  2747. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2748. timesamp := addTime.Unix()
  2749. return timesamp, timesamp + 86399
  2750. }
  2751. func (c *HisApiController) ChangeDrugfour() {
  2752. patient_id, _ := c.GetInt64("patient_id")
  2753. admin_user_id, _ := c.GetInt64("admin_user_id")
  2754. times := c.GetString("time", "")
  2755. timeLayout := "2006-01-02"
  2756. loc, _ := time.LoadLocation("Local")
  2757. var stime, etime int64
  2758. if times == "" {
  2759. stime, etime = GetNowTime()
  2760. } else {
  2761. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2762. stime = stmp.Unix()
  2763. etime = stime + 86399
  2764. }
  2765. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2766. var flows []*models.DrugFlow
  2767. for _, item := range advicelist {
  2768. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2769. flows = append(flows, flow...)
  2770. }
  2771. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2772. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2773. var err []string
  2774. for _, item := range flows {
  2775. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2776. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2777. if prescription.OrderStatus == 2 {
  2778. if item.IsSale == 0 {
  2779. var res FJ3507Result
  2780. var res3507for10188 FJ3507ResultFor10188
  2781. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2782. //进行商品销售接口
  2783. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2784. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2785. var respJSON3 map[string]interface{}
  2786. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2789. return
  2790. }
  2791. userJSONBytes3, _ := json.Marshal(respJSON3)
  2792. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2793. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2794. utils.ErrorLog("解析失败:%v", err)
  2795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2796. return
  2797. }
  2798. //if res3507for10188.Infcode
  2799. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2800. //res.Output = resSix10265.Output
  2801. res.ErrMsg = res3507for10188.ErrMsg
  2802. res.Cainfo = res3507for10188.Cainfo
  2803. res.WarnMsg = res3507for10188.WarnMsg
  2804. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2805. res.Infcode = infocode
  2806. } else {
  2807. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2808. utils.ErrorLog("解析失败:%v", err)
  2809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2810. return
  2811. }
  2812. }
  2813. if res.Infcode == 0 {
  2814. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  2815. item.IsSale = 1
  2816. item.Bchno = number
  2817. item.SaleDate = time.Now().Format("2006-01-02")
  2818. service.SaveDF(item)
  2819. } else {
  2820. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2821. }
  2822. }
  2823. } else { //还没结,提示用户去结算,并药品追溯上传
  2824. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  2825. }
  2826. }
  2827. }
  2828. str := strings.Join(err, " ")
  2829. saveLog(str, str, "3505", "3505自动上传日志")
  2830. c.ServeSuccessJSON(map[string]interface{}{
  2831. "status": "1",
  2832. "msg": err,
  2833. })
  2834. }
  2835. //func (c *HisApiController) ChangeDrugfour() {
  2836. // patient_id, _ := c.GetInt64("patient_id")
  2837. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2838. // //id_arr := strings.Split(ids, ",")
  2839. // times := c.GetString("time", "")
  2840. // timeLayout := "2006-01-02"
  2841. // loc, _ := time.LoadLocation("Local")
  2842. // var stime, etime int64
  2843. // if times == "" {
  2844. // stime, etime = GetNowTime()
  2845. // } else {
  2846. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2847. // stime = stmp.Unix()
  2848. // etime = stime + 86399
  2849. // }
  2850. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2851. // var flows []*models.DrugFlow
  2852. // for _, item := range advicelist {
  2853. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  2854. // flows = append(flows, flow...)
  2855. // }
  2856. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2857. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2858. // var err []string
  2859. //
  2860. // for _, item := range flows {
  2861. // var res3 ResultSix
  2862. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2863. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2864. // if prescription.OrderStatus == 2 {
  2865. // //已经结算
  2866. // //判断是否已经销售
  2867. // if item.IsSale == 1 { //是否已经销售,1是 0否
  2868. // //是否已经变更 1是 0否
  2869. // if item.IsChange == 0 { //没变更,进行变更操作
  2870. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2871. //
  2872. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2873. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  2874. // var respJSON3 map[string]interface{}
  2875. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2876. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2877. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2878. // return
  2879. // }
  2880. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2881. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2882. // utils.ErrorLog("解析失败:%v", err)
  2883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2884. // return
  2885. // }
  2886. // if res3.Infcode == 0 {
  2887. // item.IsChange = 1
  2888. // item.BgBchno = bg_number
  2889. // service.SaveDF2(item)
  2890. // } else {
  2891. //
  2892. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2893. // }
  2894. // }
  2895. // } else { //没销售,
  2896. // var res FJ3507Result
  2897. // var res3507for10188 FJ3507ResultFor10188
  2898. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2899. //
  2900. // //进行商品销售接口
  2901. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2902. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2903. // var respJSON3 map[string]interface{}
  2904. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2905. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2906. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2907. // return
  2908. // }
  2909. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2910. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2911. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2912. // utils.ErrorLog("解析失败:%v", err)
  2913. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2914. // return
  2915. // }
  2916. // //if res3507for10188.Infcode
  2917. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  2918. // //res.Output = resSix10265.Output
  2919. // res.ErrMsg = res3507for10188.ErrMsg
  2920. // res.Cainfo = res3507for10188.Cainfo
  2921. // res.WarnMsg = res3507for10188.WarnMsg
  2922. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2923. // res.Infcode = infocode
  2924. // } else {
  2925. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2926. // utils.ErrorLog("解析失败:%v", err)
  2927. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2928. // return
  2929. // }
  2930. //
  2931. // }
  2932. // if res.Infcode == 0 {
  2933. // item.IsSale = 1
  2934. // item.Bchno = number
  2935. // item.SaleDate = time.Now().Format("2006-01-02")
  2936. //
  2937. // err5 := service.SaveDF(item)
  2938. // if err5 == nil {
  2939. // if item.IsChange == 0 { //没变更,进行变更操作
  2940. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2941. //
  2942. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2943. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  2944. //
  2945. // var respJSON3 map[string]interface{}
  2946. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2947. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2948. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2949. // return
  2950. // }
  2951. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2952. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2953. // utils.ErrorLog("解析失败:%v", err)
  2954. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2955. // return
  2956. // }
  2957. // //if res3507for10188.Infcode
  2958. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2959. // //res.Output = resSix10265.Output
  2960. // res3.ErrMsg = res3507for10188.ErrMsg
  2961. // res3.Cainfo = res3507for10188.Cainfo
  2962. // res3.WarnMsg = res3507for10188.WarnMsg
  2963. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2964. // res3.Infcode = infocode
  2965. // } else {
  2966. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2967. // utils.ErrorLog("解析失败:%v", err)
  2968. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2969. // return
  2970. // }
  2971. // }
  2972. // if res3.Infcode == 0 {
  2973. // item.IsChange = 1
  2974. // item.BgBchno = bg_number
  2975. // service.SaveDF2(item)
  2976. // } else {
  2977. //
  2978. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2979. // }
  2980. // }
  2981. // }
  2982. // } else {
  2983. //
  2984. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2985. // }
  2986. // }
  2987. //
  2988. // } else { //还没结,提示用户去结算,并药品追溯上传
  2989. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  2990. // }
  2991. // }
  2992. // }
  2993. // if len(err) == 0 {
  2994. // c.ServeSuccessJSON(map[string]interface{}{
  2995. // "msg": "销售变更成功",
  2996. // })
  2997. // } else {
  2998. // c.ServeSuccessJSON(map[string]interface{}{
  2999. // "failed_code": -10,
  3000. // "msg": err,
  3001. // })
  3002. // }
  3003. //}
  3004. func (c *HisApiController) ChangeDrug() {
  3005. ids := c.GetString("ids")
  3006. id_arr := strings.Split(ids, ",")
  3007. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3008. admin_user_id, _ := c.GetInt64("admin_user_id")
  3009. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3010. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3011. var err []string
  3012. for _, item := range flows {
  3013. var res3 ResultSix
  3014. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3015. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3016. if prescription.OrderStatus == 2 {
  3017. //已经结算
  3018. //判断是否已经销售
  3019. if item.IsSale == 1 { //是否已经销售,1是 0否
  3020. //是否已经变更 1是 0否
  3021. if item.IsChange == 0 { //没变更,进行变更操作
  3022. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3023. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3024. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3025. var respJSON3 map[string]interface{}
  3026. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3029. return
  3030. }
  3031. userJSONBytes3, _ := json.Marshal(respJSON3)
  3032. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3033. utils.ErrorLog("解析失败:%v", err)
  3034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3035. return
  3036. }
  3037. if res3.Infcode == 0 {
  3038. item.IsChange = 1
  3039. item.BgBchno = bg_number
  3040. service.SaveDF2(item)
  3041. } else {
  3042. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3043. }
  3044. }
  3045. } else { //没销售,
  3046. var res FJ3507Result
  3047. var res3507for10188 FJ3507ResultFor10188
  3048. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3049. //进行商品销售接口
  3050. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3051. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3052. var respJSON3 map[string]interface{}
  3053. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3056. return
  3057. }
  3058. userJSONBytes3, _ := json.Marshal(respJSON3)
  3059. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3060. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3061. utils.ErrorLog("解析失败:%v", err)
  3062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3063. return
  3064. }
  3065. //if res3507for10188.Infcode
  3066. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3067. //res.Output = resSix10265.Output
  3068. res.ErrMsg = res3507for10188.ErrMsg
  3069. res.Cainfo = res3507for10188.Cainfo
  3070. res.WarnMsg = res3507for10188.WarnMsg
  3071. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3072. res.Infcode = infocode
  3073. } else {
  3074. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3075. utils.ErrorLog("解析失败:%v", err)
  3076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3077. return
  3078. }
  3079. }
  3080. if res.Infcode == 0 {
  3081. item.IsSale = 1
  3082. item.Bchno = number
  3083. item.SaleDate = time.Now().Format("2006-01-02")
  3084. err5 := service.SaveDF(item)
  3085. if err5 == nil {
  3086. if item.IsChange == 0 { //没变更,进行变更操作
  3087. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3088. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3089. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3090. var respJSON3 map[string]interface{}
  3091. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3094. return
  3095. }
  3096. userJSONBytes3, _ := json.Marshal(respJSON3)
  3097. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3098. utils.ErrorLog("解析失败:%v", err)
  3099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3100. return
  3101. }
  3102. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3103. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3104. utils.ErrorLog("解析失败:%v", err)
  3105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3106. return
  3107. }
  3108. //if res3507for10188.Infcode
  3109. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3110. //res.Output = resSix10265.Output
  3111. res3.ErrMsg = res3507for10188.ErrMsg
  3112. res3.Cainfo = res3507for10188.Cainfo
  3113. res3.WarnMsg = res3507for10188.WarnMsg
  3114. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3115. res3.Infcode = infocode
  3116. } else {
  3117. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3118. utils.ErrorLog("解析失败:%v", err)
  3119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3120. return
  3121. }
  3122. }
  3123. if res3.Infcode == 0 {
  3124. item.IsChange = 1
  3125. item.BgBchno = bg_number
  3126. service.SaveDF2(item)
  3127. } else {
  3128. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3129. }
  3130. }
  3131. }
  3132. } else {
  3133. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3134. }
  3135. }
  3136. } else { //还没结算
  3137. var res3507for10188 FJ3507ResultFor10188
  3138. if item.IsChange == 0 { //没变更,进行变更操作
  3139. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  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 c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3150. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3151. utils.ErrorLog("解析失败:%v", err)
  3152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3153. return
  3154. }
  3155. //if res3507for10188.Infcode
  3156. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3157. //res.Output = resSix10265.Output
  3158. res3.ErrMsg = res3507for10188.ErrMsg
  3159. res3.Cainfo = res3507for10188.Cainfo
  3160. res3.WarnMsg = res3507for10188.WarnMsg
  3161. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3162. res3.Infcode = infocode
  3163. } else {
  3164. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3165. utils.ErrorLog("解析失败:%v", err)
  3166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3167. return
  3168. }
  3169. }
  3170. if res3.Infcode == 0 {
  3171. item.IsChange = 1
  3172. item.BgBchno = bg_number
  3173. service.SaveDF2(item)
  3174. } else {
  3175. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3176. }
  3177. }
  3178. }
  3179. } else if item.ConsumableType == 7 {
  3180. var res3507for10188 FJ3507ResultFor10188
  3181. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3182. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3183. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3184. //判断是否已经销售
  3185. if item.IsSale == 2 { //是否已经销售,1是 0否
  3186. //是否已经变更 1是 0否
  3187. if item.IsChange == 0 { //没变更,进行变更操作
  3188. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3189. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3190. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3191. var respJSON3 map[string]interface{}
  3192. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3195. return
  3196. }
  3197. userJSONBytes3, _ := json.Marshal(respJSON3)
  3198. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3199. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3200. utils.ErrorLog("解析失败:%v", err)
  3201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3202. return
  3203. }
  3204. //if res3507for10188.Infcode
  3205. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3206. //res.Output = resSix10265.Output
  3207. res3.ErrMsg = res3507for10188.ErrMsg
  3208. res3.Cainfo = res3507for10188.Cainfo
  3209. res3.WarnMsg = res3507for10188.WarnMsg
  3210. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3211. res3.Infcode = infocode
  3212. } else {
  3213. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3214. utils.ErrorLog("解析失败:%v", err)
  3215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3216. return
  3217. }
  3218. }
  3219. if res3.Infcode == 0 {
  3220. item.IsChange = 1
  3221. item.BgBchno = bg_number
  3222. service.SaveDF2(item)
  3223. } else {
  3224. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3225. }
  3226. }
  3227. } else { //没销售,
  3228. //进行商品销售退货接口
  3229. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3230. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3231. saveLog(result111, result222, "3506", "销售退货")
  3232. var res7 FJ3507Result
  3233. //进行商品销售接口
  3234. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3235. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3236. var respJSON3 map[string]interface{}
  3237. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3240. return
  3241. }
  3242. userJSONBytes3, _ := json.Marshal(respJSON3)
  3243. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3244. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3245. utils.ErrorLog("解析失败:%v", err)
  3246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3247. return
  3248. }
  3249. //if res3507for10188.Infcode
  3250. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3251. //res.Output = resSix10265.Output
  3252. res7.ErrMsg = res3507for10188.ErrMsg
  3253. res7.Cainfo = res3507for10188.Cainfo
  3254. res7.WarnMsg = res3507for10188.WarnMsg
  3255. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3256. res7.Infcode = infocode
  3257. } else {
  3258. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3259. utils.ErrorLog("解析失败:%v", err)
  3260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3261. return
  3262. }
  3263. }
  3264. if res7.Infcode == 0 {
  3265. item.IsSale = 2
  3266. item.SaleDate = item.SaleDate
  3267. item.Bchno = number
  3268. service.SaveDF(item)
  3269. if item.IsChange == 0 { //没变更,进行变更操作
  3270. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3271. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3272. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3273. var respJSON3 map[string]interface{}
  3274. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3277. return
  3278. }
  3279. userJSONBytes3, _ := json.Marshal(respJSON3)
  3280. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3281. // utils.ErrorLog("解析失败:%v", err)
  3282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3283. // return
  3284. //}
  3285. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3286. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3287. utils.ErrorLog("解析失败:%v", err)
  3288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3289. return
  3290. }
  3291. //if res3507for10188.Infcode
  3292. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3293. //res.Output = resSix10265.Output
  3294. res3.ErrMsg = res3507for10188.ErrMsg
  3295. res3.Cainfo = res3507for10188.Cainfo
  3296. res3.WarnMsg = res3507for10188.WarnMsg
  3297. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3298. res3.Infcode = infocode
  3299. } else {
  3300. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3301. utils.ErrorLog("解析失败:%v", err)
  3302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3303. return
  3304. }
  3305. }
  3306. if res3.Infcode == 0 {
  3307. item.IsChange = 1
  3308. item.BgBchno = bg_number
  3309. service.SaveDF2(item)
  3310. } else {
  3311. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3312. }
  3313. }
  3314. } else {
  3315. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3316. }
  3317. }
  3318. } else { //还没结算
  3319. if item.IsChange == 0 { //没变更,进行变更操作
  3320. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3321. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3322. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3323. var respJSON3 map[string]interface{}
  3324. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3327. return
  3328. }
  3329. userJSONBytes3, _ := json.Marshal(respJSON3)
  3330. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3331. // utils.ErrorLog("解析失败:%v", err)
  3332. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3333. // return
  3334. //}
  3335. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3336. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3337. utils.ErrorLog("解析失败:%v", err)
  3338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3339. return
  3340. }
  3341. //if res3507for10188.Infcode
  3342. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3343. //res.Output = resSix10265.Output
  3344. res3.ErrMsg = res3507for10188.ErrMsg
  3345. res3.Cainfo = res3507for10188.Cainfo
  3346. res3.WarnMsg = res3507for10188.WarnMsg
  3347. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3348. res3.Infcode = infocode
  3349. } else {
  3350. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3351. utils.ErrorLog("解析失败:%v", err)
  3352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3353. return
  3354. }
  3355. }
  3356. if res3.Infcode == 0 {
  3357. item.IsChange = 1
  3358. item.BgBchno = bg_number
  3359. service.SaveDF2(item)
  3360. } else {
  3361. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3362. }
  3363. }
  3364. }
  3365. }
  3366. }
  3367. if len(err) == 0 {
  3368. c.ServeSuccessJSON(map[string]interface{}{
  3369. "msg": "销售变更成功",
  3370. })
  3371. } else {
  3372. c.ServeSuccessJSON(map[string]interface{}{
  3373. "failed_code": -10,
  3374. "msg": err,
  3375. })
  3376. }
  3377. }
  3378. func (c *HisApiController) ChangeDrugtwo() {
  3379. //ids := c.GetString("ids")
  3380. //id_arr := strings.Split(ids, ",")
  3381. flows, _ := service.GetNewDrugFlowInfothree123()
  3382. admin_user_id, _ := c.GetInt64("admin_user_id")
  3383. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3384. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3385. var err []string
  3386. for _, item := range flows {
  3387. var res3 ResultSix
  3388. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3389. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3390. if prescription.OrderStatus == 2 {
  3391. //已经结算
  3392. //判断是否已经销售
  3393. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3394. // //是否已经变更 1是 0否
  3395. // if item.IsChange == 0 { //没变更,进行变更操作
  3396. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3397. //
  3398. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3399. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3400. // var respJSON3 map[string]interface{}
  3401. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3402. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3404. // return
  3405. // }
  3406. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3407. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3408. // utils.ErrorLog("解析失败:%v", err)
  3409. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3410. // return
  3411. // }
  3412. // if res3.Infcode == 0 {
  3413. // item.IsChange = 1
  3414. // item.BgBchno = bg_number
  3415. // service.SaveDF2(item)
  3416. // } else {
  3417. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3418. // }
  3419. // }
  3420. //}
  3421. //else
  3422. { //没销售,
  3423. var res FJ3507Result
  3424. var res3507for10188 FJ3507ResultFor10188
  3425. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3426. //进行商品销售接口
  3427. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3428. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3429. var respJSON3 map[string]interface{}
  3430. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3433. return
  3434. }
  3435. userJSONBytes3, _ := json.Marshal(respJSON3)
  3436. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3437. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3438. utils.ErrorLog("解析失败:%v", err)
  3439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3440. return
  3441. }
  3442. //if res3507for10188.Infcode
  3443. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3444. //res.Output = resSix10265.Output
  3445. res.ErrMsg = res3507for10188.ErrMsg
  3446. res.Cainfo = res3507for10188.Cainfo
  3447. res.WarnMsg = res3507for10188.WarnMsg
  3448. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3449. res.Infcode = infocode
  3450. } else {
  3451. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3452. utils.ErrorLog("解析失败:%v", err)
  3453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3454. return
  3455. }
  3456. }
  3457. if res.Infcode == 0 {
  3458. item.IsSale = 1
  3459. item.Bchno = number
  3460. item.SaleDate = time.Now().Format("2006-01-02")
  3461. service.SaveDF(item)
  3462. //if err5 == nil {
  3463. // if item.IsChange == 0 { //没变更,进行变更操作
  3464. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3465. //
  3466. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3467. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3468. //
  3469. // var respJSON3 map[string]interface{}
  3470. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3471. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3472. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3473. // return
  3474. // }
  3475. //
  3476. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3477. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3478. // utils.ErrorLog("解析失败:%v", err)
  3479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3480. // return
  3481. // }
  3482. // //if res3507for10188.Infcode
  3483. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3484. // //res.Output = resSix10265.Output
  3485. // res3.ErrMsg = res3507for10188.ErrMsg
  3486. // res3.Cainfo = res3507for10188.Cainfo
  3487. // res3.WarnMsg = res3507for10188.WarnMsg
  3488. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3489. // res3.Infcode = infocode
  3490. // } else {
  3491. //
  3492. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3493. // utils.ErrorLog("解析失败:%v", err)
  3494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3495. // return
  3496. // }
  3497. //
  3498. // }
  3499. //
  3500. // if res3.Infcode == 0 {
  3501. // item.IsChange = 1
  3502. // item.BgBchno = bg_number
  3503. // service.SaveDF2(item)
  3504. // } else {
  3505. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3506. // }
  3507. // }
  3508. //}
  3509. } else {
  3510. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3511. }
  3512. }
  3513. } else { //还没结算
  3514. var res3507for10188 FJ3507ResultFor10188
  3515. if item.IsChange == 0 { //没变更,进行变更操作
  3516. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3517. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3518. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3519. var respJSON3 map[string]interface{}
  3520. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3523. return
  3524. }
  3525. userJSONBytes3, _ := json.Marshal(respJSON3)
  3526. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3527. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3528. utils.ErrorLog("解析失败:%v", err)
  3529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3530. return
  3531. }
  3532. //if res3507for10188.Infcode
  3533. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3534. //res.Output = resSix10265.Output
  3535. res3.ErrMsg = res3507for10188.ErrMsg
  3536. res3.Cainfo = res3507for10188.Cainfo
  3537. res3.WarnMsg = res3507for10188.WarnMsg
  3538. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3539. res3.Infcode = infocode
  3540. } else {
  3541. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3542. utils.ErrorLog("解析失败:%v", err)
  3543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3544. return
  3545. }
  3546. }
  3547. if res3.Infcode == 0 {
  3548. item.IsChange = 1
  3549. item.BgBchno = bg_number
  3550. service.SaveDF2(item)
  3551. } else {
  3552. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3553. }
  3554. }
  3555. }
  3556. }
  3557. //if item.ConsumableType == 7 {
  3558. // var res3507for10188 FJ3507ResultFor10188
  3559. //
  3560. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3561. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3562. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3563. // //判断是否已经销售
  3564. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3565. // //是否已经变更 1是 0否
  3566. // if item.IsChange == 0 { //没变更,进行变更操作
  3567. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3568. //
  3569. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3570. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3571. //
  3572. // var respJSON3 map[string]interface{}
  3573. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3574. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3575. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3576. // return
  3577. // }
  3578. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3579. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3580. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3581. // utils.ErrorLog("解析失败:%v", err)
  3582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3583. // return
  3584. // }
  3585. // //if res3507for10188.Infcode
  3586. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3587. // //res.Output = resSix10265.Output
  3588. // res3.ErrMsg = res3507for10188.ErrMsg
  3589. // res3.Cainfo = res3507for10188.Cainfo
  3590. // res3.WarnMsg = res3507for10188.WarnMsg
  3591. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3592. // res3.Infcode = infocode
  3593. // } else {
  3594. //
  3595. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3596. // utils.ErrorLog("解析失败:%v", err)
  3597. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3598. // return
  3599. // }
  3600. //
  3601. // }
  3602. // if res3.Infcode == 0 {
  3603. // item.IsChange = 1
  3604. // item.BgBchno = bg_number
  3605. // service.SaveDF2(item)
  3606. // } else {
  3607. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3608. // }
  3609. // }
  3610. // } else { //没销售,
  3611. // //进行商品销售退货接口
  3612. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3613. //
  3614. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3615. // saveLog(result111, result222, "3506", "销售退货")
  3616. // var res7 FJ3507Result
  3617. //
  3618. // //进行商品销售接口
  3619. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3620. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3621. // var respJSON3 map[string]interface{}
  3622. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3623. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3625. // return
  3626. // }
  3627. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3628. //
  3629. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3630. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3631. // utils.ErrorLog("解析失败:%v", err)
  3632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3633. // return
  3634. // }
  3635. // //if res3507for10188.Infcode
  3636. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3637. // //res.Output = resSix10265.Output
  3638. // res7.ErrMsg = res3507for10188.ErrMsg
  3639. // res7.Cainfo = res3507for10188.Cainfo
  3640. // res7.WarnMsg = res3507for10188.WarnMsg
  3641. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3642. // res7.Infcode = infocode
  3643. // } else {
  3644. //
  3645. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3646. // utils.ErrorLog("解析失败:%v", err)
  3647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3648. // return
  3649. // }
  3650. //
  3651. // }
  3652. // if res7.Infcode == 0 {
  3653. // item.IsSale = 2
  3654. // item.SaleDate = item.SaleDate
  3655. // item.Bchno = number
  3656. // service.SaveDF(item)
  3657. // if item.IsChange == 0 { //没变更,进行变更操作
  3658. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3659. //
  3660. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3661. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3662. //
  3663. // var respJSON3 map[string]interface{}
  3664. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3665. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3666. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3667. // return
  3668. // }
  3669. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3670. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3671. // // utils.ErrorLog("解析失败:%v", err)
  3672. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3673. // // return
  3674. // //}
  3675. //
  3676. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3677. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3678. // utils.ErrorLog("解析失败:%v", err)
  3679. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3680. // return
  3681. // }
  3682. // //if res3507for10188.Infcode
  3683. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3684. // //res.Output = resSix10265.Output
  3685. // res3.ErrMsg = res3507for10188.ErrMsg
  3686. // res3.Cainfo = res3507for10188.Cainfo
  3687. // res3.WarnMsg = res3507for10188.WarnMsg
  3688. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3689. // res3.Infcode = infocode
  3690. // } else {
  3691. //
  3692. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3693. // utils.ErrorLog("解析失败:%v", err)
  3694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3695. // return
  3696. // }
  3697. //
  3698. // }
  3699. // if res3.Infcode == 0 {
  3700. // item.IsChange = 1
  3701. // item.BgBchno = bg_number
  3702. // service.SaveDF2(item)
  3703. // } else {
  3704. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3705. // }
  3706. // }
  3707. // } else {
  3708. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3709. // }
  3710. // }
  3711. // } else { //还没结算
  3712. // if item.IsChange == 0 { //没变更,进行变更操作
  3713. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3714. //
  3715. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3716. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3717. //
  3718. // var respJSON3 map[string]interface{}
  3719. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3720. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3722. // return
  3723. // }
  3724. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3725. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3726. // // utils.ErrorLog("解析失败:%v", err)
  3727. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3728. // // return
  3729. // //}
  3730. //
  3731. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3732. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3733. // utils.ErrorLog("解析失败:%v", err)
  3734. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3735. // return
  3736. // }
  3737. // //if res3507for10188.Infcode
  3738. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3739. // //res.Output = resSix10265.Output
  3740. // res3.ErrMsg = res3507for10188.ErrMsg
  3741. // res3.Cainfo = res3507for10188.Cainfo
  3742. // res3.WarnMsg = res3507for10188.WarnMsg
  3743. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3744. // res3.Infcode = infocode
  3745. // } else {
  3746. //
  3747. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3748. // utils.ErrorLog("解析失败:%v", err)
  3749. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3750. // return
  3751. // }
  3752. //
  3753. // }
  3754. // if res3.Infcode == 0 {
  3755. // item.IsChange = 1
  3756. // item.BgBchno = bg_number
  3757. // service.SaveDF2(item)
  3758. // } else {
  3759. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3760. // }
  3761. // }
  3762. // }
  3763. //}
  3764. }
  3765. if len(err) == 0 {
  3766. c.ServeSuccessJSON(map[string]interface{}{
  3767. "msg": "销售变更成功",
  3768. })
  3769. } else {
  3770. c.ServeSuccessJSON(map[string]interface{}{
  3771. "failed_code": -10,
  3772. "msg": err,
  3773. })
  3774. }
  3775. }
  3776. func (c *HisApiController) ChangeDrugthree() {
  3777. //ids := c.GetString("ids")
  3778. //id_arr := strings.Split(ids, ",")
  3779. flows, _ := service.GetNewDrugFlowInfothree()
  3780. admin_user_id, _ := c.GetInt64("admin_user_id")
  3781. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3782. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3783. var err []string
  3784. for _, item := range flows {
  3785. var res3 ResultSix
  3786. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3787. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3788. if prescription.OrderStatus == 2 {
  3789. //已经结算
  3790. //判断是否已经销售
  3791. if item.IsSale == 1 { //是否已经销售,1是 0否
  3792. //是否已经变更 1是 0否
  3793. if item.IsChange == 0 { //没变更,进行变更操作
  3794. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3795. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3796. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3797. var respJSON3 map[string]interface{}
  3798. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3801. return
  3802. }
  3803. userJSONBytes3, _ := json.Marshal(respJSON3)
  3804. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3805. utils.ErrorLog("解析失败:%v", err)
  3806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3807. return
  3808. }
  3809. if res3.Infcode == 0 {
  3810. item.IsChange = 1
  3811. item.BgBchno = bg_number
  3812. service.SaveDF2(item)
  3813. } else {
  3814. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3815. }
  3816. }
  3817. } else { //没销售,
  3818. var res FJ3507Result
  3819. var res3507for10188 FJ3507ResultFor10188
  3820. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3821. //进行商品销售接口
  3822. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3823. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3824. var respJSON3 map[string]interface{}
  3825. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3828. return
  3829. }
  3830. userJSONBytes3, _ := json.Marshal(respJSON3)
  3831. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3832. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3833. utils.ErrorLog("解析失败:%v", err)
  3834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3835. return
  3836. }
  3837. //if res3507for10188.Infcode
  3838. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3839. //res.Output = resSix10265.Output
  3840. res.ErrMsg = res3507for10188.ErrMsg
  3841. res.Cainfo = res3507for10188.Cainfo
  3842. res.WarnMsg = res3507for10188.WarnMsg
  3843. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3844. res.Infcode = infocode
  3845. } else {
  3846. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3847. utils.ErrorLog("解析失败:%v", err)
  3848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3849. return
  3850. }
  3851. }
  3852. if res.Infcode == 0 {
  3853. item.IsSale = 1
  3854. item.Bchno = number
  3855. item.SaleDate = time.Now().Format("2006-01-02")
  3856. err5 := service.SaveDF(item)
  3857. if err5 == nil {
  3858. if item.IsChange == 0 { //没变更,进行变更操作
  3859. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3860. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3861. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3862. var respJSON3 map[string]interface{}
  3863. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3866. return
  3867. }
  3868. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  3869. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3870. utils.ErrorLog("解析失败:%v", err)
  3871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3872. return
  3873. }
  3874. //if res3507for10188.Infcode
  3875. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3876. //res.Output = resSix10265.Output
  3877. res3.ErrMsg = res3507for10188.ErrMsg
  3878. res3.Cainfo = res3507for10188.Cainfo
  3879. res3.WarnMsg = res3507for10188.WarnMsg
  3880. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3881. res3.Infcode = infocode
  3882. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3883. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3884. utils.ErrorLog("解析失败:%v", err)
  3885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3886. return
  3887. }
  3888. //if res3507for10188.Infcode
  3889. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3890. //res.Output = resSix10265.Output
  3891. res3.ErrMsg = res3507for10188.ErrMsg
  3892. res3.Cainfo = res3507for10188.Cainfo
  3893. res3.WarnMsg = res3507for10188.WarnMsg
  3894. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3895. res3.Infcode = infocode
  3896. } else {
  3897. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3898. utils.ErrorLog("解析失败:%v", err)
  3899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3900. return
  3901. }
  3902. }
  3903. if res3.Infcode == 0 {
  3904. item.IsChange = 1
  3905. item.BgBchno = bg_number
  3906. service.SaveDF2(item)
  3907. } else {
  3908. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3909. }
  3910. }
  3911. }
  3912. } else {
  3913. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3914. }
  3915. }
  3916. } else { //还没结算
  3917. var res3507for10188 FJ3507ResultFor10188
  3918. if item.IsChange == 0 { //没变更,进行变更操作
  3919. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3920. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3921. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3922. var respJSON3 map[string]interface{}
  3923. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3926. return
  3927. }
  3928. userJSONBytes3, _ := json.Marshal(respJSON3)
  3929. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  3930. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3931. utils.ErrorLog("解析失败:%v", err)
  3932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3933. return
  3934. }
  3935. //if res3507for10188.Infcode
  3936. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3937. //res.Output = resSix10265.Output
  3938. res3.ErrMsg = res3507for10188.ErrMsg
  3939. res3.Cainfo = res3507for10188.Cainfo
  3940. res3.WarnMsg = res3507for10188.WarnMsg
  3941. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3942. res3.Infcode = infocode
  3943. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3944. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3945. utils.ErrorLog("解析失败:%v", err)
  3946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3947. return
  3948. }
  3949. //if res3507for10188.Infcode
  3950. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3951. //res.Output = resSix10265.Output
  3952. res3.ErrMsg = res3507for10188.ErrMsg
  3953. res3.Cainfo = res3507for10188.Cainfo
  3954. res3.WarnMsg = res3507for10188.WarnMsg
  3955. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3956. res3.Infcode = infocode
  3957. } else {
  3958. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3959. utils.ErrorLog("解析失败:%v", err)
  3960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3961. return
  3962. }
  3963. }
  3964. if res3.Infcode == 0 {
  3965. item.IsChange = 1
  3966. item.BgBchno = bg_number
  3967. service.SaveDF2(item)
  3968. } else {
  3969. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3970. }
  3971. }
  3972. }
  3973. } else if item.ConsumableType == 7 {
  3974. var res3507for10188 FJ3507ResultFor10188
  3975. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3976. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3977. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3978. //判断是否已经销售
  3979. if item.IsSale == 2 { //是否已经销售,1是 0否
  3980. //是否已经变更 1是 0否
  3981. if item.IsChange == 0 { //没变更,进行变更操作
  3982. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3983. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3984. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3985. var respJSON3 map[string]interface{}
  3986. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3989. return
  3990. }
  3991. userJSONBytes3, _ := json.Marshal(respJSON3)
  3992. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3993. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3994. utils.ErrorLog("解析失败:%v", err)
  3995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3996. return
  3997. }
  3998. //if res3507for10188.Infcode
  3999. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4000. //res.Output = resSix10265.Output
  4001. res3.ErrMsg = res3507for10188.ErrMsg
  4002. res3.Cainfo = res3507for10188.Cainfo
  4003. res3.WarnMsg = res3507for10188.WarnMsg
  4004. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4005. res3.Infcode = infocode
  4006. } else {
  4007. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4008. utils.ErrorLog("解析失败:%v", err)
  4009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4010. return
  4011. }
  4012. }
  4013. if res3.Infcode == 0 {
  4014. item.IsChange = 1
  4015. item.BgBchno = bg_number
  4016. service.SaveDF2(item)
  4017. } else {
  4018. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4019. }
  4020. }
  4021. } else { //没销售,
  4022. //进行商品销售退货接口
  4023. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4024. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4025. saveLog(result111, result222, "3506", "销售退货")
  4026. var res7 FJ3507Result
  4027. //进行商品销售接口
  4028. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4029. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4030. var respJSON3 map[string]interface{}
  4031. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4034. return
  4035. }
  4036. userJSONBytes3, _ := json.Marshal(respJSON3)
  4037. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4038. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4039. utils.ErrorLog("解析失败:%v", err)
  4040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4041. return
  4042. }
  4043. //if res3507for10188.Infcode
  4044. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4045. //res.Output = resSix10265.Output
  4046. res7.ErrMsg = res3507for10188.ErrMsg
  4047. res7.Cainfo = res3507for10188.Cainfo
  4048. res7.WarnMsg = res3507for10188.WarnMsg
  4049. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4050. res7.Infcode = infocode
  4051. } else {
  4052. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4053. utils.ErrorLog("解析失败:%v", err)
  4054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4055. return
  4056. }
  4057. }
  4058. if res7.Infcode == 0 {
  4059. item.IsSale = 2
  4060. item.SaleDate = item.SaleDate
  4061. item.Bchno = number
  4062. service.SaveDF(item)
  4063. if item.IsChange == 0 { //没变更,进行变更操作
  4064. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4065. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4066. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4067. var respJSON3 map[string]interface{}
  4068. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4071. return
  4072. }
  4073. userJSONBytes3, _ := json.Marshal(respJSON3)
  4074. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4075. // utils.ErrorLog("解析失败:%v", err)
  4076. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4077. // return
  4078. //}
  4079. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4080. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4081. utils.ErrorLog("解析失败:%v", err)
  4082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4083. return
  4084. }
  4085. //if res3507for10188.Infcode
  4086. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4087. //res.Output = resSix10265.Output
  4088. res3.ErrMsg = res3507for10188.ErrMsg
  4089. res3.Cainfo = res3507for10188.Cainfo
  4090. res3.WarnMsg = res3507for10188.WarnMsg
  4091. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4092. res3.Infcode = infocode
  4093. } else {
  4094. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4095. utils.ErrorLog("解析失败:%v", err)
  4096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4097. return
  4098. }
  4099. }
  4100. if res3.Infcode == 0 {
  4101. item.IsChange = 1
  4102. item.BgBchno = bg_number
  4103. service.SaveDF2(item)
  4104. } else {
  4105. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4106. }
  4107. }
  4108. } else {
  4109. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4110. }
  4111. }
  4112. } else { //还没结算
  4113. if item.IsChange == 0 { //没变更,进行变更操作
  4114. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4115. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4116. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4117. var respJSON3 map[string]interface{}
  4118. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4121. return
  4122. }
  4123. userJSONBytes3, _ := json.Marshal(respJSON3)
  4124. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4125. // utils.ErrorLog("解析失败:%v", err)
  4126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4127. // return
  4128. //}
  4129. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4130. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4131. utils.ErrorLog("解析失败:%v", err)
  4132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4133. return
  4134. }
  4135. //if res3507for10188.Infcode
  4136. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4137. //res.Output = resSix10265.Output
  4138. res3.ErrMsg = res3507for10188.ErrMsg
  4139. res3.Cainfo = res3507for10188.Cainfo
  4140. res3.WarnMsg = res3507for10188.WarnMsg
  4141. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4142. res3.Infcode = infocode
  4143. } else {
  4144. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4145. utils.ErrorLog("解析失败:%v", err)
  4146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4147. return
  4148. }
  4149. }
  4150. if res3.Infcode == 0 {
  4151. item.IsChange = 1
  4152. item.BgBchno = bg_number
  4153. service.SaveDF2(item)
  4154. } else {
  4155. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4156. }
  4157. }
  4158. }
  4159. }
  4160. }
  4161. if len(err) == 0 {
  4162. c.ServeSuccessJSON(map[string]interface{}{
  4163. "msg": "销售变更成功",
  4164. })
  4165. } else {
  4166. c.ServeSuccessJSON(map[string]interface{}{
  4167. "failed_code": -10,
  4168. "msg": err,
  4169. })
  4170. }
  4171. }
  4172. func (c *HisApiController) ChangeDrugTen() {
  4173. start_time_str := c.GetString("start_time")
  4174. end_time_str := c.GetString("end_time")
  4175. //ids := c.GetString("ids")
  4176. //id_arr := strings.Split(ids, ",")
  4177. timeLayout := "2006-01-02"
  4178. loc, _ := time.LoadLocation("Local")
  4179. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4180. recordStartTime := theStartTime.Unix()
  4181. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4182. recordEndTime := theEndTime.Unix()
  4183. //timestamp := int64(1729612800)
  4184. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4185. admin_user_id, _ := c.GetInt64("admin_user_id")
  4186. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4187. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4188. var err []string
  4189. for _, item := range flows {
  4190. var res3 ResultSix
  4191. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4192. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4193. continue
  4194. }
  4195. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4196. continue
  4197. }
  4198. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4199. if prescription.OrderStatus == 2 {
  4200. //已经结算
  4201. //判断 是否已经销售
  4202. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4203. ////是否已经变更 1是 0否
  4204. //if item.IsChange == 0 { //没变更,进行变更操作
  4205. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4206. //
  4207. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4208. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4209. // var respJSON3 map[string]interface{}
  4210. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4211. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4213. // return
  4214. // }
  4215. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4216. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4217. // utils.ErrorLog("解析失败:%v", err)
  4218. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4219. // return
  4220. // }
  4221. // if res3.Infcode == 0 {
  4222. // item.IsChange = 1
  4223. // item.BgBchno = bg_number
  4224. // service.SaveDF2(item)
  4225. // } else {
  4226. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4227. // }
  4228. //}
  4229. //} else
  4230. if item.IsSale == 0 { //没销售,
  4231. var res FJ3507Result
  4232. var res3507for10188 FJ3507ResultFor10188
  4233. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4234. //进行商品销售接口
  4235. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4236. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4237. var respJSON3 map[string]interface{}
  4238. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4241. return
  4242. }
  4243. userJSONBytes3, _ := json.Marshal(respJSON3)
  4244. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4245. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4246. utils.ErrorLog("解析失败:%v", err)
  4247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4248. return
  4249. }
  4250. //if res3507for10188.Infcode
  4251. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4252. //res.Output = resSix10265.Output
  4253. res.ErrMsg = res3507for10188.ErrMsg
  4254. res.Cainfo = res3507for10188.Cainfo
  4255. res.WarnMsg = res3507for10188.WarnMsg
  4256. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4257. res.Infcode = infocode
  4258. } else {
  4259. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4260. utils.ErrorLog("解析失败:%v", err)
  4261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4262. return
  4263. }
  4264. }
  4265. if res.Infcode == 0 {
  4266. item.IsSale = 1
  4267. item.Bchno = number
  4268. item.SaleDate = time.Now().Format("2006-01-02")
  4269. err5 := service.SaveDF(item)
  4270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4271. //if err5 == nil {
  4272. //
  4273. // if item.IsChange == 1 { //没变更,进行变更操作
  4274. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4275. //
  4276. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4277. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4278. //
  4279. // var respJSON3 map[string]interface{}
  4280. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4281. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4283. // return
  4284. // }
  4285. //
  4286. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4287. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4288. // utils.ErrorLog("解析失败:%v", err)
  4289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4290. // return
  4291. // }
  4292. // //if res3507for10188.Infcode
  4293. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4294. // //res.Output = resSix10265.Output
  4295. // res3.ErrMsg = res3507for10188.ErrMsg
  4296. // res3.Cainfo = res3507for10188.Cainfo
  4297. // res3.WarnMsg = res3507for10188.WarnMsg
  4298. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4299. // res3.Infcode = infocode
  4300. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4301. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4302. // utils.ErrorLog("解析失败:%v", err)
  4303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4304. // return
  4305. // }
  4306. // //if res3507for10188.Infcode
  4307. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4308. // //res.Output = resSix10265.Output
  4309. // res3.ErrMsg = res3507for10188.ErrMsg
  4310. // res3.Cainfo = res3507for10188.Cainfo
  4311. // res3.WarnMsg = res3507for10188.WarnMsg
  4312. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4313. // res3.Infcode = infocode
  4314. //
  4315. // } else {
  4316. //
  4317. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4318. // utils.ErrorLog("解析失败:%v", err)
  4319. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4320. // return
  4321. // }
  4322. //
  4323. // }
  4324. //
  4325. // if res3.Infcode == 0 {
  4326. // item.IsChange = 1
  4327. // item.BgBchno = bg_number
  4328. // service.SaveDF2(item)
  4329. // return
  4330. // } else {
  4331. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4332. // }
  4333. // }
  4334. //}
  4335. } else {
  4336. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4337. }
  4338. }
  4339. }
  4340. } else if item.ConsumableType == 7 {
  4341. var res3507for10188 FJ3507ResultFor10188
  4342. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4343. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4344. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4345. //判断是否已经销售
  4346. if item.IsSale == 2 { //是否已经销售,1是 0否
  4347. //是否已经变更 1是 0否
  4348. if item.IsChange == 0 { //没变更,进行变更操作
  4349. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4350. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4351. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4352. var respJSON3 map[string]interface{}
  4353. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4356. return
  4357. }
  4358. userJSONBytes3, _ := json.Marshal(respJSON3)
  4359. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4360. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4361. utils.ErrorLog("解析失败:%v", err)
  4362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4363. return
  4364. }
  4365. //if res3507for10188.Infcode
  4366. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4367. //res.Output = resSix10265.Output
  4368. res3.ErrMsg = res3507for10188.ErrMsg
  4369. res3.Cainfo = res3507for10188.Cainfo
  4370. res3.WarnMsg = res3507for10188.WarnMsg
  4371. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4372. res3.Infcode = infocode
  4373. } else {
  4374. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4375. utils.ErrorLog("解析失败:%v", err)
  4376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4377. return
  4378. }
  4379. }
  4380. if res3.Infcode == 0 {
  4381. item.IsChange = 1
  4382. item.BgBchno = bg_number
  4383. service.SaveDF2(item)
  4384. } else {
  4385. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4386. }
  4387. }
  4388. } else { //没销售,
  4389. //进行商品销售退货接口
  4390. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4391. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4392. saveLog(result111, result222, "3506", "销售退货")
  4393. var res7 FJ3507Result
  4394. //进行商品销售接口
  4395. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4396. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4397. var respJSON3 map[string]interface{}
  4398. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4401. return
  4402. }
  4403. userJSONBytes3, _ := json.Marshal(respJSON3)
  4404. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4405. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4406. utils.ErrorLog("解析失败:%v", err)
  4407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4408. return
  4409. }
  4410. //if res3507for10188.Infcode
  4411. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4412. //res.Output = resSix10265.Output
  4413. res7.ErrMsg = res3507for10188.ErrMsg
  4414. res7.Cainfo = res3507for10188.Cainfo
  4415. res7.WarnMsg = res3507for10188.WarnMsg
  4416. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4417. res7.Infcode = infocode
  4418. } else {
  4419. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4420. utils.ErrorLog("解析失败:%v", err)
  4421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4422. return
  4423. }
  4424. }
  4425. if res7.Infcode == 0 {
  4426. item.IsSale = 2
  4427. item.SaleDate = item.SaleDate
  4428. item.Bchno = number
  4429. service.SaveDF(item)
  4430. if item.IsChange == 0 { //没变更,进行变更操作
  4431. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4432. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4433. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4434. var respJSON3 map[string]interface{}
  4435. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4438. return
  4439. }
  4440. userJSONBytes3, _ := json.Marshal(respJSON3)
  4441. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4442. // utils.ErrorLog("解析失败:%v", err)
  4443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4444. // return
  4445. //}
  4446. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4447. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4448. utils.ErrorLog("解析失败:%v", err)
  4449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4450. return
  4451. }
  4452. //if res3507for10188.Infcode
  4453. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4454. //res.Output = resSix10265.Output
  4455. res3.ErrMsg = res3507for10188.ErrMsg
  4456. res3.Cainfo = res3507for10188.Cainfo
  4457. res3.WarnMsg = res3507for10188.WarnMsg
  4458. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4459. res3.Infcode = infocode
  4460. } else {
  4461. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4462. utils.ErrorLog("解析失败:%v", err)
  4463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4464. return
  4465. }
  4466. }
  4467. if res3.Infcode == 0 {
  4468. item.IsChange = 1
  4469. item.BgBchno = bg_number
  4470. service.SaveDF2(item)
  4471. } else {
  4472. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4473. }
  4474. }
  4475. } else {
  4476. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4477. }
  4478. }
  4479. } else { //还没结算
  4480. if item.IsChange == 0 { //没变更,进行变更操作
  4481. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4482. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4483. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4484. var respJSON3 map[string]interface{}
  4485. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4488. return
  4489. }
  4490. userJSONBytes3, _ := json.Marshal(respJSON3)
  4491. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4492. // utils.ErrorLog("解析失败:%v", err)
  4493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4494. // return
  4495. //}
  4496. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4497. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4498. utils.ErrorLog("解析失败:%v", err)
  4499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4500. return
  4501. }
  4502. //if res3507for10188.Infcode
  4503. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4504. //res.Output = resSix10265.Output
  4505. res3.ErrMsg = res3507for10188.ErrMsg
  4506. res3.Cainfo = res3507for10188.Cainfo
  4507. res3.WarnMsg = res3507for10188.WarnMsg
  4508. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4509. res3.Infcode = infocode
  4510. } else {
  4511. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4512. utils.ErrorLog("解析失败:%v", err)
  4513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4514. return
  4515. }
  4516. }
  4517. if res3.Infcode == 0 {
  4518. item.IsChange = 1
  4519. item.BgBchno = bg_number
  4520. service.SaveDF2(item)
  4521. } else {
  4522. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4523. }
  4524. }
  4525. }
  4526. }
  4527. }
  4528. if len(err) == 0 {
  4529. c.ServeSuccessJSON(map[string]interface{}{
  4530. "msg": "销售变更成功",
  4531. })
  4532. } else {
  4533. c.ServeSuccessJSON(map[string]interface{}{
  4534. "failed_code": -10,
  4535. "msg": err,
  4536. })
  4537. }
  4538. }
  4539. func ChangeDrugTenone() {
  4540. //ids := c.GetString("ids")
  4541. //id_arr := strings.Split(ids, ",")
  4542. now := time.Now()
  4543. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4544. //timestamp := int64(1729612800)
  4545. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4546. admin_user_id := int64(2463)
  4547. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4548. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4549. var err []string
  4550. for _, item := range flows {
  4551. var res3 ResultSix
  4552. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4553. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4554. continue
  4555. }
  4556. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4557. continue
  4558. }
  4559. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4560. if prescription.OrderStatus == 2 {
  4561. //已经结算
  4562. //判断是否已经销售
  4563. if item.IsSale == 1 { //是否已经销售,1是 0否
  4564. //是否已经变更 1是 0否
  4565. if item.IsChange == 0 { //没变更,进行变更操作
  4566. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4567. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4568. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4569. var respJSON3 map[string]interface{}
  4570. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4572. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4573. return
  4574. }
  4575. userJSONBytes3, _ := json.Marshal(respJSON3)
  4576. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4577. utils.ErrorLog("解析失败:%v", err)
  4578. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4579. return
  4580. }
  4581. if res3.Infcode == 0 {
  4582. item.IsChange = 1
  4583. item.BgBchno = bg_number
  4584. service.SaveDF2(item)
  4585. } else {
  4586. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4587. }
  4588. }
  4589. } else { //没销售,
  4590. var res FJ3507Result
  4591. var res3507for10188 FJ3507ResultFor10188
  4592. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4593. //进行商品销售接口
  4594. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4595. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4596. var respJSON3 map[string]interface{}
  4597. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4599. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4600. return
  4601. }
  4602. userJSONBytes3, _ := json.Marshal(respJSON3)
  4603. {
  4604. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4605. utils.ErrorLog("解析失败:%v", err)
  4606. return
  4607. }
  4608. //if res3507for10188.Infcode
  4609. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4610. //res.Output = resSix10265.Output
  4611. res.ErrMsg = res3507for10188.ErrMsg
  4612. res.Cainfo = res3507for10188.Cainfo
  4613. res.WarnMsg = res3507for10188.WarnMsg
  4614. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4615. res.Infcode = infocode
  4616. }
  4617. if res.Infcode == 0 {
  4618. item.IsSale = 1
  4619. item.Bchno = number
  4620. item.SaleDate = time.Now().Format("2006-01-02")
  4621. err5 := service.SaveDF(item)
  4622. if err5 == nil {
  4623. if item.IsChange == 1 { //没变更,进行变更操作
  4624. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4625. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4626. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4627. var respJSON3 map[string]interface{}
  4628. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4630. return
  4631. }
  4632. {
  4633. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4634. utils.ErrorLog("解析失败:%v", err)
  4635. return
  4636. }
  4637. //if res3507for10188.Infcode
  4638. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4639. //res.Output = resSix10265.Output
  4640. res3.ErrMsg = res3507for10188.ErrMsg
  4641. res3.Cainfo = res3507for10188.Cainfo
  4642. res3.WarnMsg = res3507for10188.WarnMsg
  4643. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4644. res3.Infcode = infocode
  4645. }
  4646. if res3.Infcode == 0 {
  4647. item.IsChange = 1
  4648. item.BgBchno = bg_number
  4649. service.SaveDF2(item)
  4650. } else {
  4651. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4652. }
  4653. }
  4654. }
  4655. } else {
  4656. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4657. }
  4658. }
  4659. }
  4660. }
  4661. }
  4662. }
  4663. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4664. var struct3502 models.Struct3502
  4665. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4666. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4667. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4668. struct3502.FixmedinsCode = miConfig.Code
  4669. struct3502.Code = miConfig.Code
  4670. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4671. struct3502.Opter = role.UserName
  4672. struct3502.RxFlag = "1"
  4673. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4674. struct3502.OrgName = miConfig.OrgName
  4675. struct3502.AccessKey = miConfig.AccessKey
  4676. struct3502.RequestUrl = miConfig.Url
  4677. struct3502.SecretKey = miConfig.SecretKey
  4678. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4679. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4680. struct3502.Url = miConfig.Url
  4681. struct3502.AppId = miConfig.Cainfo
  4682. struct3502.AppSecret = miConfig.AppSecret
  4683. struct3502.Enckey = miConfig.EncKey
  4684. struct3502.SignKey = miConfig.SignKey
  4685. struct3502.SecretKey = miConfig.SecretKey
  4686. struct3502.InvChgType = chgType
  4687. struct3502.FixmedinsBchno = number
  4688. struct3502.Cnt = strconv.FormatInt(count, 10)
  4689. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4690. //result1, result2, _ := service.FJyb3502(struct3502)
  4691. if miConfig.MdtrtareaAdmvs == "350500" {
  4692. result1, result2, _ := service.FJyb3502(struct3502)
  4693. //saveLog(result1, result2, "3502", "3502")
  4694. return result1, result2
  4695. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4696. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4697. return result1, result2
  4698. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4699. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4700. return result1, result2
  4701. } else {
  4702. data := make(map[string]interface{})
  4703. data["struct_3502s"] = struct3502
  4704. client := &http.Client{}
  4705. bytesData, _ := json.Marshal(data)
  4706. var req *http.Request
  4707. if miConfig.MdtrtareaAdmvs == "320921" {
  4708. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4709. } else {
  4710. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4711. }
  4712. resp, _ := client.Do(req)
  4713. defer resp.Body.Close()
  4714. body, ioErr := ioutil.ReadAll(resp.Body)
  4715. if ioErr != nil {
  4716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4717. }
  4718. var respJSON map[string]interface{}
  4719. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4721. }
  4722. //var resSix10265 ResultSix10265 //1101结果
  4723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4724. result, _ := json.Marshal(respJSON)
  4725. return string(result), ""
  4726. }
  4727. }
  4728. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4729. var struct3505 models.Struct3505
  4730. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4731. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4732. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4733. struct3505.FixmedinsBchno = number
  4734. struct3505.Opter = role.UserName
  4735. struct3505.Bchno = "---"
  4736. struct3505.FixmedinsCode = miConfig.Code
  4737. struct3505.Code = miConfig.Code
  4738. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  4739. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  4740. struct3505.PrscDrName = roles.UserName
  4741. if org_id == 10191 {
  4742. struct3505.PharName = "刘水山"
  4743. struct3505.PharPracCertNo = "2015026350260000002611351127"
  4744. }
  4745. if org_id == 10188 {
  4746. struct3505.PharName = "李汉清"
  4747. struct3505.PharPracCertNo = "30220200932022010034"
  4748. }
  4749. if org_id == 10217 {
  4750. struct3505.PharName = "张敏"
  4751. struct3505.PharPracCertNo = "30220230432090100108"
  4752. }
  4753. if org_id == 10318 {
  4754. struct3505.PharName = "邹刘阳"
  4755. struct3505.PharPracCertNo = "210441200001378"
  4756. }
  4757. if org_id == 10402 {
  4758. struct3505.PharName = "刘韶健"
  4759. struct3505.PharPracCertNo = "2015026440262015440501001198"
  4760. }
  4761. if org_id == 9919 {
  4762. struct3505.PharName = "周君权"
  4763. struct3505.PharPracCertNo = "089644396094401375"
  4764. }
  4765. if org_id == 10644 {
  4766. struct3505.PharName = "陈金娣"
  4767. struct3505.PharPracCertNo = "20181441500320100066"
  4768. }
  4769. if org_id == 10567 {
  4770. struct3505.PharName = "范小兰"
  4771. struct3505.PharPracCertNo = "0200102079485"
  4772. }
  4773. if org_id == 10721 {
  4774. struct3505.PharName = "孙莉侠"
  4775. struct3505.PharPracCertNo = "060399"
  4776. }
  4777. if org_id == 10726 {
  4778. struct3505.PharName = "彭建福"
  4779. struct3505.PharPracCertNo = "D445281006261"
  4780. }
  4781. if org_id == 10265 {
  4782. struct3505.PharName = "李彩星"
  4783. struct3505.PharPracCertNo = "20171110600110100019"
  4784. }
  4785. if org_id == 10028 {
  4786. struct3505.PharName = "曾细平"
  4787. struct3505.PharPracCertNo = "D440307022134"
  4788. }
  4789. if org_id == 10138 {
  4790. struct3505.PharName = "彭斯遥"
  4791. struct3505.PharPracCertNo = "30220200943042010052"
  4792. }
  4793. if org_id == 10278 {
  4794. struct3505.PharName = "彭斯遥"
  4795. struct3505.PharPracCertNo = "30220200943042010052"
  4796. }
  4797. if org_id == 10610 {
  4798. struct3505.PharName = "彭斯遥"
  4799. struct3505.PharPracCertNo = "30220200943042010052"
  4800. }
  4801. if org_id == 10537 {
  4802. struct3505.PharName = "彭斯遥"
  4803. struct3505.PharPracCertNo = "30220200943042010052"
  4804. }
  4805. if org_id == 9504 {
  4806. struct3505.PharName = "资美红"
  4807. struct3505.PharPracCertNo = "D440904006635"
  4808. }
  4809. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4810. struct3505.SetlId = order.SetlId
  4811. struct3505.MdtrtSn = order.MdtrtId
  4812. struct3505.ManuLotnum = drug.BatchNumber
  4813. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4814. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  4815. struct3505.RxFlag = "1"
  4816. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  4817. struct3505.TrdnFlag = "0"
  4818. } else {
  4819. struct3505.TrdnFlag = "1"
  4820. }
  4821. if drug.HisDoctorAdviceInfo.ZeroFlag == 1{
  4822. struct3505.TrdnFlag = "1"
  4823. }
  4824. if drug.HisDoctorAdviceInfo.ZeroFlag == 2{
  4825. struct3505.TrdnFlag = "0"
  4826. }
  4827. struct3505.RtalDocno = order.Number
  4828. struct3505.PsnCertType = "01"
  4829. struct3505.CertNo = order.Certno
  4830. struct3505.PsnNo = order.PsnNo
  4831. struct3505.PsnName = order.PsnName
  4832. struct3505.Url = miConfig.Url
  4833. struct3505.AppId = miConfig.Cainfo
  4834. struct3505.AppSecret = miConfig.AppSecret
  4835. struct3505.Enckey = miConfig.EncKey
  4836. struct3505.SignKey = miConfig.SignKey
  4837. struct3505.SecretKey = miConfig.SecretKey
  4838. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4839. struct3505.SelRetnCnt = strValue
  4840. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4841. struct3505.SelRetnOpterName = role.UserName
  4842. if order.IsMedicineInsurance == 1 {
  4843. struct3505.MdtrtSetlType = "1"
  4844. } else {
  4845. struct3505.MdtrtSetlType = "2"
  4846. }
  4847. struct3505.OrgName = miConfig.OrgName
  4848. struct3505.AccessKey = miConfig.AccessKey
  4849. struct3505.RequestUrl = miConfig.Url
  4850. struct3505.SecretKey = miConfig.SecretKey
  4851. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4852. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4853. struct3505.Cainfo = miConfig.Cainfo
  4854. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4855. if miConfig.MdtrtareaAdmvs == "350500" {
  4856. result1, result2, _ := service.FJyb3505(struct3505)
  4857. return result1, result2
  4858. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4859. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  4860. return result1, result2
  4861. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4862. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  4863. return result1, result2
  4864. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  4865. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  4866. return result1, result2
  4867. } else if miConfig.MdtrtareaAdmvs == "340699" {
  4868. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  4869. return result1, result2
  4870. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4871. data := make(map[string]interface{})
  4872. data["struct_3505s"] = struct3505
  4873. client := &http.Client{}
  4874. bytesData, _ := json.Marshal(data)
  4875. var req *http.Request
  4876. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  4877. resp, _ := client.Do(req)
  4878. defer resp.Body.Close()
  4879. body, ioErr := ioutil.ReadAll(resp.Body)
  4880. if ioErr != nil {
  4881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4882. }
  4883. var respJSON map[string]interface{}
  4884. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4886. }
  4887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4888. result, _ := json.Marshal(respJSON)
  4889. return string(result), ""
  4890. } else {
  4891. data := make(map[string]interface{})
  4892. data["struct_3505s"] = struct3505
  4893. client := &http.Client{}
  4894. bytesData, _ := json.Marshal(data)
  4895. var req *http.Request
  4896. if miConfig.MdtrtareaAdmvs == "320921" {
  4897. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4898. } else {
  4899. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4900. }
  4901. resp, _ := client.Do(req)
  4902. defer resp.Body.Close()
  4903. body, ioErr := ioutil.ReadAll(resp.Body)
  4904. if ioErr != nil {
  4905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4906. }
  4907. var respJSON map[string]interface{}
  4908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4910. }
  4911. //var resSix10265 ResultSix10265 //1101结果
  4912. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4913. result, _ := json.Marshal(respJSON)
  4914. return string(result), ""
  4915. }
  4916. }
  4917. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4918. var struct3505 models.Struct3505
  4919. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4920. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4921. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4922. struct3505.FixmedinsBchno = number
  4923. struct3505.Opter = role.UserName
  4924. struct3505.FixmedinsCode = miConfig.Code
  4925. struct3505.Code = miConfig.Code
  4926. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  4927. struct3505.PrscDrName = roles.UserName
  4928. if org_id == 10191 {
  4929. struct3505.PharName = "刘水山"
  4930. struct3505.PharPracCertNo = "2015026350260000002611351127"
  4931. }
  4932. if org_id == 10188 {
  4933. struct3505.PharName = "李汉清"
  4934. struct3505.PharPracCertNo = "30220200932022010034"
  4935. }
  4936. if org_id == 10217 {
  4937. struct3505.PharName = "张敏"
  4938. struct3505.PharPracCertNo = "30220230432090100108"
  4939. }
  4940. if org_id == 10318 {
  4941. struct3505.PharName = "邹刘阳"
  4942. struct3505.PharPracCertNo = "210441200001378"
  4943. }
  4944. if org_id == 10402 {
  4945. struct3505.PharName = "刘韶健"
  4946. struct3505.PharPracCertNo = "2015026440262015440501001198"
  4947. }
  4948. if org_id == 9919 {
  4949. struct3505.PharName = "周君权"
  4950. struct3505.PharPracCertNo = "089644396094401375"
  4951. }
  4952. if org_id == 10644 {
  4953. struct3505.PharName = "陈金娣"
  4954. struct3505.PharPracCertNo = "20181441500320100066"
  4955. }
  4956. if org_id == 10567 {
  4957. struct3505.PharName = "范小兰"
  4958. struct3505.PharPracCertNo = "0200102079485"
  4959. }
  4960. if org_id == 10721 {
  4961. struct3505.PharName = "孙莉侠"
  4962. struct3505.PharPracCertNo = "060399"
  4963. }
  4964. if org_id == 10726 {
  4965. struct3505.PharName = "彭建福"
  4966. struct3505.PharPracCertNo = "D445281006261"
  4967. }
  4968. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4969. struct3505.SetlId = order.SetlId
  4970. struct3505.MdtrtSn = order.MdtrtId
  4971. struct3505.ManuLotnum = drug.Number
  4972. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4973. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  4974. struct3505.RxFlag = "1"
  4975. struct3505.TrdnFlag = "0"
  4976. struct3505.RtalDocno = order.Number
  4977. struct3505.PsnCertType = "01"
  4978. struct3505.CertNo = order.Certno
  4979. struct3505.PsnNo = order.PsnNo
  4980. struct3505.PsnName = order.PsnName
  4981. struct3505.Url = miConfig.Url
  4982. struct3505.AppId = miConfig.Cainfo
  4983. struct3505.AppSecret = miConfig.AppSecret
  4984. struct3505.Enckey = miConfig.EncKey
  4985. struct3505.SignKey = miConfig.SignKey
  4986. struct3505.SecretKey = miConfig.SecretKey
  4987. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4988. struct3505.SelRetnCnt = strValue
  4989. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4990. struct3505.SelRetnOpterName = role.UserName
  4991. if order.IsMedicineInsurance == 1 {
  4992. struct3505.MdtrtSetlType = "1"
  4993. } else {
  4994. struct3505.MdtrtSetlType = "2"
  4995. }
  4996. struct3505.OrgName = miConfig.OrgName
  4997. struct3505.AccessKey = miConfig.AccessKey
  4998. struct3505.RequestUrl = miConfig.Url
  4999. struct3505.SecretKey = miConfig.SecretKey
  5000. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5001. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5002. struct3505.Cainfo = miConfig.Cainfo
  5003. struct3505.DrugTracCodg = drug.DrugCode
  5004. if miConfig.MdtrtareaAdmvs == "350500" {
  5005. result1, result2, _ := service.FJyb3505(struct3505)
  5006. return result1, result2
  5007. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5008. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5009. return result1, result2
  5010. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5011. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5012. return result1, result2
  5013. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5014. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5015. return result1, result2
  5016. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5017. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5018. return result1, result2
  5019. } else {
  5020. data := make(map[string]interface{})
  5021. data["struct_3505s"] = struct3505
  5022. client := &http.Client{}
  5023. bytesData, _ := json.Marshal(data)
  5024. var req *http.Request
  5025. if miConfig.MdtrtareaAdmvs == "320921" {
  5026. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5027. } else {
  5028. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5029. }
  5030. resp, _ := client.Do(req)
  5031. defer resp.Body.Close()
  5032. body, ioErr := ioutil.ReadAll(resp.Body)
  5033. if ioErr != nil {
  5034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5035. }
  5036. var respJSON map[string]interface{}
  5037. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5039. }
  5040. //var resSix10265 ResultSix10265 //1101结果
  5041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5042. result, _ := json.Marshal(respJSON)
  5043. return string(result), ""
  5044. }
  5045. }
  5046. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5047. var struct3506 models.Struct3506
  5048. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5049. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5050. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5051. struct3506.FixmedinsCode = miConfig.Code
  5052. struct3506.Code = miConfig.Code
  5053. struct3506.FixmedinsBchno = number
  5054. struct3506.Opter = role.UserName
  5055. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5056. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5057. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5058. struct3506.MdtrtSn = order.MdtrtId
  5059. struct3506.ExpyEnd = ""
  5060. struct3506.RxFlag = "0"
  5061. struct3506.TrdnFlag = "1"
  5062. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5063. struct3506.SelRetnCnt = strValue
  5064. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5065. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5066. struct3506.SelRetnOpterName = role.UserName
  5067. struct3506.OrgName = miConfig.OrgName
  5068. struct3506.AccessKey = miConfig.AccessKey
  5069. struct3506.RequestUrl = miConfig.Url
  5070. struct3506.SecretKey = miConfig.SecretKey
  5071. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5072. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5073. struct3506.Url = miConfig.Url
  5074. struct3506.AppId = miConfig.Cainfo
  5075. struct3506.AppSecret = miConfig.AppSecret
  5076. struct3506.Enckey = miConfig.EncKey
  5077. struct3506.SignKey = miConfig.SignKey
  5078. struct3506.SecretKey = miConfig.SecretKey
  5079. struct3506.DrugTracCodg = drug.DrugCode
  5080. if miConfig.MdtrtareaAdmvs == "350500" {
  5081. result1, result2, _ := service.FJyb3506(struct3506)
  5082. return result1, result2
  5083. } else {
  5084. data := make(map[string]interface{})
  5085. data["struct_3506s"] = struct3506
  5086. client := &http.Client{}
  5087. bytesData, _ := json.Marshal(data)
  5088. var req *http.Request
  5089. if miConfig.MdtrtareaAdmvs == "320921" {
  5090. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5091. } else {
  5092. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5093. }
  5094. resp, _ := client.Do(req)
  5095. defer resp.Body.Close()
  5096. body, ioErr := ioutil.ReadAll(resp.Body)
  5097. if ioErr != nil {
  5098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5099. }
  5100. var respJSON map[string]interface{}
  5101. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5103. }
  5104. //var resSix10265 ResultSix10265 //1101结果
  5105. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5106. result, _ := json.Marshal(respJSON)
  5107. return string(result), ""
  5108. }
  5109. }
  5110. func (c *HisApiController) Get1318() {
  5111. adminUser := c.GetAdminUserInfo()
  5112. admin_user_id, _ := c.GetInt64("admin_user_id")
  5113. code := c.GetString("code")
  5114. code = ""
  5115. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5116. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5117. api := ""
  5118. if miConfig.MdtrtareaAdmvs == "320921" {
  5119. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5120. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5121. } else {
  5122. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5123. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5124. }
  5125. resp, requestErr := http.Get(api)
  5126. if requestErr != nil {
  5127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5128. return
  5129. }
  5130. body, ioErr := ioutil.ReadAll(resp.Body)
  5131. if ioErr != nil {
  5132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5134. return
  5135. }
  5136. var respJSON map[string]interface{}
  5137. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5140. return
  5141. }
  5142. //var res Result2406
  5143. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5144. result, _ := json.Marshal(respJSON)
  5145. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5146. utils.ErrorLog("解析失败:%v", err)
  5147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5148. return
  5149. }
  5150. if res.Infcode == "0" {
  5151. c.ServeSuccessJSON(map[string]interface{}{
  5152. "result": "",
  5153. })
  5154. } else {
  5155. c.ServeSuccessJSON(map[string]interface{}{
  5156. "failed_code": -10,
  5157. "msg": res.ErrMsg,
  5158. })
  5159. */return
  5160. //}
  5161. }
  5162. func (c *HisApiController) Get2503() {
  5163. adminUser := c.GetAdminUserInfo()
  5164. admin_user_id, _ := c.GetInt64("admin_user_id")
  5165. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5166. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5167. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5168. }
  5169. func (c *HisApiController) Get2406() {
  5170. id, _ := c.GetInt64("id")
  5171. record_time := c.GetString("record_time")
  5172. his_patient_id, _ := c.GetInt64("his_patient_id")
  5173. admin_user_id, _ := c.GetInt64("admin_user_id")
  5174. diagnosis_id := c.GetString("diagnosis")
  5175. timeLayout := "2006-01-02"
  5176. loc, _ := time.LoadLocation("Local")
  5177. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5178. if err != nil {
  5179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5180. return
  5181. }
  5182. recordDateTime := theTime.Unix()
  5183. adminUser := c.GetAdminUserInfo()
  5184. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5185. var config []*models.HisXtDiagnoseConfig
  5186. for _, item := range diagnosis_ids {
  5187. id, _ := strconv.ParseInt(item, 10, 64)
  5188. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5189. config = append(config, &diagnosisConfig)
  5190. }
  5191. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5192. fmt.Println(his_patient_id)
  5193. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5194. //timestamp := time.Now().Unix()
  5195. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5196. var patientPrescription models.HisPrescriptionInfo
  5197. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5198. if patientPrescription.ID == 0 {
  5199. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5200. }
  5201. var res2 Result2406
  5202. if miConfig.MdtrtareaAdmvs == "341203" {
  5203. data := make(map[string]interface{})
  5204. client := &http.Client{}
  5205. data["psn_no"] = his.PsnNo
  5206. data["mdtrt_id"] = his.Number
  5207. data["operator"] = roles.UserName
  5208. data["cert_no"] = his.IdCardNo
  5209. data["org_name"] = miConfig.OrgName
  5210. data["psn_name"] = his.Name
  5211. data["ipt_otp_no"] = his.IptOtpNo
  5212. data["ipt_psn_sp_flag_type"] = "0901"
  5213. data["ipt_psn_sp_flag"] = "1"
  5214. data["fixmedins_code"] = miConfig.Code
  5215. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5216. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5217. data["url"] = miConfig.Url
  5218. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5219. bytesData, _ := json.Marshal(data)
  5220. var req *http.Request
  5221. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5222. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5223. resp, _ := client.Do(req)
  5224. defer resp.Body.Close()
  5225. body, ioErr := ioutil.ReadAll(resp.Body)
  5226. if ioErr != nil {
  5227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5229. return
  5230. }
  5231. var respJSON map[string]interface{}
  5232. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5235. return
  5236. }
  5237. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5238. if status == "0" {
  5239. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5240. c.ServeSuccessJSON(map[string]interface{}{
  5241. "failed_code": -10,
  5242. "msg": err_msg,
  5243. })
  5244. return
  5245. }
  5246. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5247. userJSONBytes, _ := json.Marshal(respJSON)
  5248. fmt.Println("log")
  5249. fmt.Println(string(userJSONBytes))
  5250. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5251. utils.ErrorLog("解析失败:%v", err)
  5252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5253. return
  5254. }
  5255. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5256. data := make(map[string]interface{})
  5257. client := &http.Client{}
  5258. data["psn_no"] = his.PsnNo
  5259. data["mdtrt_id"] = his.Number
  5260. data["operator"] = roles.UserName
  5261. data["cert_no"] = his.IdCardNo
  5262. data["org_name"] = miConfig.OrgName
  5263. data["psn_name"] = his.Name
  5264. data["ipt_otp_no"] = his.IptOtpNo
  5265. data["ipt_psn_sp_flag_type"] = "0901"
  5266. data["ipt_psn_sp_flag"] = "1"
  5267. data["fixmedins_code"] = miConfig.Code
  5268. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5269. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5270. data["url"] = miConfig.Url
  5271. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5272. bytesData, _ := json.Marshal(data)
  5273. var req *http.Request
  5274. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5275. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5276. resp, _ := client.Do(req)
  5277. defer resp.Body.Close()
  5278. body, ioErr := ioutil.ReadAll(resp.Body)
  5279. if ioErr != nil {
  5280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5282. return
  5283. }
  5284. var respJSON map[string]interface{}
  5285. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5288. return
  5289. }
  5290. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5291. if status == "0" {
  5292. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5293. c.ServeSuccessJSON(map[string]interface{}{
  5294. "failed_code": -10,
  5295. "msg": err_msg,
  5296. })
  5297. return
  5298. }
  5299. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5300. userJSONBytes, _ := json.Marshal(respJSON)
  5301. fmt.Println("log")
  5302. fmt.Println(string(userJSONBytes))
  5303. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5304. utils.ErrorLog("解析失败:%v", err)
  5305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5306. return
  5307. }
  5308. }
  5309. if res2.Infcode != 0 {
  5310. adminUser := c.GetAdminUserInfo()
  5311. errlog := &models.HisOrderError{
  5312. UserOrgId: adminUser.CurrentOrgId,
  5313. Ctime: time.Now().Unix(),
  5314. Mtime: time.Now().Unix(),
  5315. ErrMsg: res2.ErrMsg,
  5316. Status: 1,
  5317. PatientId: id,
  5318. RecordTime: recordDateTime,
  5319. Stage: 3,
  5320. }
  5321. service.CreateErrMsgLog(errlog)
  5322. c.ServeSuccessJSON(map[string]interface{}{
  5323. "failed_code": -10,
  5324. "msg": res2.ErrMsg,
  5325. })
  5326. return
  5327. } else {
  5328. c.ServeSuccessJSON(map[string]interface{}{
  5329. "msg": "上传成功",
  5330. })
  5331. return
  5332. }
  5333. }
  5334. func (c *HisApiController) Get4105() {
  5335. }
  5336. func (c *HisApiController) Post5302() {
  5337. patient_id, _ := c.GetInt64("id")
  5338. admin_user_id, _ := c.GetInt64("admin_user_id")
  5339. p, _ := service.GetHisPatientById(patient_id)
  5340. adminUser := c.GetAdminUserInfo()
  5341. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5342. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5343. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5344. }
  5345. func (c *HisApiController) Get4104() {
  5346. }
  5347. type Output struct {
  5348. CertNo string `json:"certno"`
  5349. PsnName string `json:"psn_name"`
  5350. CardNo string `json:"card_no"`
  5351. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5352. CardSN string `json:"card_sn"`
  5353. PsnCertType string `json:"psn_cert_type"`
  5354. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5355. MdtrtCertType string `json:"mdtrt_cert_type"`
  5356. QRCode string `json:"qrCode"`
  5357. EcToken string `json:"ecToken"`
  5358. }
  5359. type AHResponse struct {
  5360. Body AHBody `json:"body"`
  5361. Code int `json:"code"`
  5362. CSBCode int `json:"csbCode"`
  5363. Message string `json:"message"`
  5364. RequestID string `json:"requestId"`
  5365. State struct{} `json:"state"`
  5366. }
  5367. type AHBody struct {
  5368. ErrMsg string `json:"err_msg"`
  5369. InfRefMsgID string `json:"inf_refmsgid"`
  5370. InfCode int `json:"infcode"`
  5371. Output struct {
  5372. Result []struct {
  5373. BasMednFlag string `json:"bas_medn_flag"`
  5374. ChldMedcFlag string `json:"chld_medc_flag"`
  5375. ChrgitmLv string `json:"chrgitm_lv"`
  5376. Cnt float64 `json:"cnt"`
  5377. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5378. DrtReimFlag string `json:"drt_reim_flag"`
  5379. FeedetlSn string `json:"feedetl_sn"`
  5380. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5381. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5382. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5383. ListSpItemFlag string `json:"list_sp_item_flag"`
  5384. LmtUsedFlag string `json:"lmt_used_flag"`
  5385. MedChrgitmType string `json:"med_chrgitm_type"`
  5386. Memo string `json:"memo"`
  5387. OverlmtAmt float64 `json:"overlmt_amt"`
  5388. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5389. Pric float64 `json:"pric"`
  5390. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5391. SelfpayProp float64 `json:"selfpay_prop"`
  5392. } `json:"result"`
  5393. } `json:"output"`
  5394. }
  5395. type Response struct {
  5396. Output Output `json:"output"`
  5397. Infcode int `json:"infcode"`
  5398. InfRefMsgID string `json:"inf_refmsgid"`
  5399. RefMsgTime string `json:"refmsg_time"`
  5400. RespondTime string `json:"respond_time"`
  5401. ErrMsg string `json:"err_msg"`
  5402. WarnMsg string `json:"warn_msg"`
  5403. SignType string `json:"signtype"`
  5404. CAInfo string `json:"cainfo"`
  5405. }
  5406. func (c *HisApiController) Getquerydata() {
  5407. query_type, _ := c.GetInt64("type")
  5408. refd_setl_flag := c.GetString("refd_setl_flag")
  5409. med_type := c.GetString("med_type")
  5410. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5411. cert_no := c.GetString("cert_no")
  5412. psn_no := c.GetString("psn_no")
  5413. start_time := c.GetString("start_time")
  5414. end_time := c.GetString("end_time")
  5415. page, _ := c.GetInt64("page")
  5416. limit, _ := c.GetInt64("limit")
  5417. var bp models.BusinessParams5262
  5418. bp.RefdSetlFlag = refd_setl_flag
  5419. bp.MedType = med_type
  5420. bp.Certno = cert_no
  5421. bp.Psnno = psn_no
  5422. bp.QBegntime = start_time
  5423. bp.QEndtime = end_time
  5424. if query_type == 1 { //本地
  5425. Post5262(c, bp, page, limit)
  5426. } else { //异地
  5427. Post5267(c, bp, page, limit)
  5428. }
  5429. }
  5430. func (c *HisApiController) Drugscheck() {
  5431. admin_user_id, _ := c.GetInt64("admin_user_id")
  5432. adminUser := c.GetAdminUserInfo()
  5433. var queryResult []QueryResult
  5434. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5435. for _, item := range drugs {
  5436. result := QueryResult{
  5437. ID: item.ID,
  5438. Name: item.DrugName,
  5439. Code: item.MedicalInsuranceNumber,
  5440. List_type_code: "101",
  5441. }
  5442. queryResult = append(queryResult, result)
  5443. }
  5444. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5445. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5446. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5447. for _, item := range queryResult {
  5448. 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)
  5449. }
  5450. }
  5451. func (c *HisApiController) Goodcheck() {
  5452. admin_user_id, _ := c.GetInt64("admin_user_id")
  5453. adminUser := c.GetAdminUserInfo()
  5454. var queryResult []QueryResult
  5455. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5456. for _, item := range goods {
  5457. result := QueryResult{
  5458. ID: item.ID,
  5459. Name: item.GoodName,
  5460. Code: item.SocialSecurityDirectoryCode,
  5461. List_type_code: "301",
  5462. }
  5463. queryResult = append(queryResult, result)
  5464. }
  5465. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5466. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5467. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5468. for _, item := range queryResult {
  5469. 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)
  5470. //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)
  5471. }
  5472. }
  5473. func (c *HisApiController) Projectcheck() {
  5474. admin_user_id, _ := c.GetInt64("admin_user_id")
  5475. adminUser := c.GetAdminUserInfo()
  5476. var queryResult []QueryResult
  5477. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5478. for _, item := range projects {
  5479. result := QueryResult{
  5480. ID: item.ID,
  5481. Name: item.ProjectName,
  5482. Code: item.MedicalCode,
  5483. List_type_code: "201",
  5484. }
  5485. queryResult = append(queryResult, result)
  5486. }
  5487. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5488. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5489. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5490. for _, item := range queryResult {
  5491. 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)
  5492. }
  5493. }
  5494. //func (c *HisApiController)CancleDia(){
  5495. //
  5496. // id, _ := c.GetInt64("id")
  5497. // record_time := c.GetString("record_time")
  5498. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5499. //
  5500. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5501. //
  5502. // diagnosis_id := c.GetString("diagnosis")
  5503. // sick_type, _ := c.GetInt64("sick_type")
  5504. // reg_type, _ := c.GetInt64("p_type")
  5505. // begin_time := c.GetString("begin_time")
  5506. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5507. //
  5508. //
  5509. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5510. //
  5511. // fmt.Println(acct_used_flag)
  5512. //
  5513. //
  5514. // timeLayout := "2006-01-02"
  5515. // loc, _ := time.LoadLocation("Local")
  5516. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5517. // if err != nil {
  5518. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5519. // return
  5520. // }
  5521. // recordDateTime := theTime.Unix()
  5522. // adminUser := c.GetAdminUserInfo()
  5523. //
  5524. //
  5525. //
  5526. //
  5527. //
  5528. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5529. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5530. // var patientPrescription models.HisPrescriptionInfo
  5531. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5532. // if patientPrescription.ID == 0 {
  5533. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5534. // }
  5535. // //if patientPrescription.Do
  5536. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5537. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5538. //
  5539. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5540. //
  5541. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5542. //
  5543. // var config []*models.HisXtDiagnoseConfig
  5544. // for _, item := range diagnosis_ids {
  5545. // id, _ := strconv.ParseInt(item, 10, 64)
  5546. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5547. // config = append(config, &diagnosisConfig)
  5548. // }
  5549. //
  5550. // sickConfig, _ := service.FindSickById(sick_type)
  5551. //
  5552. //
  5553. // data := make(map[string]interface{})
  5554. // client := &http.Client{}
  5555. // data["psn_no"] = his.PsnNo
  5556. // data["mdtrt_id"] = his.Number
  5557. // data["doctor"] = roles.UserName
  5558. // data["department"] = department.Name
  5559. // data["org_name"] = miConfig.OrgName
  5560. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5561. // data["doctor_id"] = doctor_info.DoctorNumber
  5562. // data["new_doctor_name"] = doctor_info.UserName
  5563. // data["fixmedins_code"] = miConfig.Code
  5564. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5565. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5566. // data["secret_key"] = miConfig.SecretKey
  5567. // data["sick_code"] = sickConfig.CountryCode
  5568. // data["sick_name"] = sickConfig.ClassName
  5569. // data["url"] = miConfig.Url
  5570. // data["ak"] = miConfig.AccessKey
  5571. // data["begin_time"] = begin_time
  5572. // data["cainfo"] = miConfig.Cainfo
  5573. // data["is_vaild"] = "0"
  5574. //
  5575. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5576. // data["config"] = config
  5577. // bytesData, _ := json.Marshal(data)
  5578. //
  5579. // var req *http.Request
  5580. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5581. // resp, _ := client.Do(req)
  5582. // defer resp.Body.Close()
  5583. // body, ioErr := ioutil.ReadAll(resp.Body)
  5584. // if ioErr != nil {
  5585. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5587. // return
  5588. // }
  5589. // var respJSON map[string]interface{}
  5590. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5591. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5593. // return
  5594. // }
  5595. //
  5596. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5597. // userJSONBytes, _ := json.Marshal(respJSON)
  5598. // fmt.Println("log")
  5599. // fmt.Println(string(userJSONBytes))
  5600. //
  5601. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5602. // utils.ErrorLog("解析失败:%v", err)
  5603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5604. // return
  5605. // }
  5606. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5607. // res2.Output = ressix10265.Output
  5608. // res2.ErrMsg = ressix10265.ErrMsg
  5609. // res2.Cainfo = ressix10265.Cainfo
  5610. // res2.WarnMsg = ressix10265.WarnMsg
  5611. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5612. // res2.Infcode = infocode
  5613. //
  5614. //}
  5615. func (c *HisApiController) Get4102() {
  5616. order_id, _ := c.GetInt64("order_id")
  5617. admin_user_id, _ := c.GetInt64("admin_user_id")
  5618. stas_type := c.GetString("stas_type")
  5619. order, _ := service.GetHisOrderByIDTwo(order_id)
  5620. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5621. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5622. var pp models.PublicParams
  5623. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5624. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5625. pp.FixmedinsName = miConfig.OrgName
  5626. pp.FixmedinsCode = miConfig.Code
  5627. pp.RequestUrl = miConfig.Url
  5628. pp.Cainfo = miConfig.Cainfo
  5629. pp.SecretKey = miConfig.SecretKey
  5630. pp.AccessKey = miConfig.AccessKey
  5631. pp.OpterName = curRoles.UserName
  5632. if miConfig.MdtrtareaAdmvs == "350500" {
  5633. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5634. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5635. saveLog(result, request, "4102", "清单确认")
  5636. var dat map[string]interface{}
  5637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5638. fmt.Println(dat)
  5639. } else {
  5640. fmt.Println(err)
  5641. }
  5642. var empty ResultFourteen
  5643. userJSONBytes, _ := json.Marshal(dat)
  5644. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5645. utils.ErrorLog("解析失败:%v", err)
  5646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5647. return
  5648. }
  5649. if empty.Infcode == 0 {
  5650. c.ServeSuccessJSON(map[string]interface{}{
  5651. "msg": "确认成功",
  5652. })
  5653. return
  5654. }
  5655. } else {
  5656. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5657. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5658. result3, request3 := service.Jxyb4105(pp)
  5659. saveLog(result, request, "4102", "清单确认")
  5660. saveLog(result2, request2, "4103", "清单确认")
  5661. saveLog(result3, request3, "4105", "清单统计")
  5662. var dat map[string]interface{}
  5663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5664. fmt.Println(dat)
  5665. } else {
  5666. fmt.Println(err)
  5667. }
  5668. var empty ResultFourteen
  5669. userJSONBytes, _ := json.Marshal(dat)
  5670. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5671. utils.ErrorLog("解析失败:%v", err)
  5672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5673. return
  5674. }
  5675. if empty.Infcode == 0 {
  5676. c.ServeSuccessJSON(map[string]interface{}{
  5677. "msg": "确认成功",
  5678. })
  5679. return
  5680. }
  5681. }
  5682. }
  5683. // 对账权限查询
  5684. func (c *HisApiController) Get3260() {
  5685. admin_user_id, _ := c.GetInt64("admin_user_id")
  5686. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5687. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5688. var api string
  5689. var res models.JSResult3260
  5690. if miConfig.MdtrtareaAdmvs == "320921" {
  5691. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5692. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5693. } else {
  5694. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5695. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5696. }
  5697. resp, requestErr := http.Get(api)
  5698. if requestErr != nil {
  5699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5700. return
  5701. }
  5702. body, ioErr := ioutil.ReadAll(resp.Body)
  5703. if ioErr != nil {
  5704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5706. return
  5707. }
  5708. var respJSON map[string]interface{}
  5709. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5712. return
  5713. }
  5714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5715. result, _ := json.Marshal(respJSON)
  5716. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5717. utils.ErrorLog("解析失败:%v", err)
  5718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5719. return
  5720. }
  5721. if res.Infcode == "0" {
  5722. c.ServeSuccessJSON(map[string]interface{}{
  5723. "result": res.Output.Data,
  5724. })
  5725. } else {
  5726. c.ServeSuccessJSON(map[string]interface{}{
  5727. "failed_code": -10,
  5728. "msg": res.ErrMsg,
  5729. })
  5730. return
  5731. }
  5732. }
  5733. func (c *HisApiController) Get3261() {
  5734. admin_user_id, _ := c.GetInt64("admin_user_id")
  5735. //month := c.GetString("month")
  5736. startTime := c.GetString("start_time")
  5737. //endTime, _ := c.GetString("end_time")
  5738. times := strings.Split(startTime, "-")
  5739. stmt_mon := times[0] + times[1]
  5740. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5741. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5742. var api string
  5743. var res models.JSResult3261
  5744. //var res10265 Result5301For10265
  5745. if miConfig.MdtrtareaAdmvs == "320921" {
  5746. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5747. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5748. } else {
  5749. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5750. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5751. }
  5752. resp, requestErr := http.Get(api)
  5753. if requestErr != nil {
  5754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5755. return
  5756. }
  5757. body, ioErr := ioutil.ReadAll(resp.Body)
  5758. if ioErr != nil {
  5759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5761. return
  5762. }
  5763. var respJSON map[string]interface{}
  5764. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5767. return
  5768. }
  5769. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5770. result, _ := json.Marshal(respJSON)
  5771. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5772. utils.ErrorLog("解析失败:%v", err)
  5773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5774. return
  5775. }
  5776. if res.Infcode == "0" {
  5777. c.ServeSuccessJSON(map[string]interface{}{
  5778. "result": res.Output,
  5779. })
  5780. } else {
  5781. c.ServeSuccessJSON(map[string]interface{}{
  5782. "failed_code": -10,
  5783. "msg": res.ErrMsg,
  5784. })
  5785. return
  5786. }
  5787. }
  5788. type TempFun struct {
  5789. FundKey string
  5790. FundCode string
  5791. }
  5792. func (c *HisApiController) Get3262() {
  5793. admin_user_id, _ := c.GetInt64("admin_user_id")
  5794. startTime := c.GetString("start_time")
  5795. endTime := c.GetString("end_time")
  5796. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5797. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5798. //timeLayout := "2006-01-02"
  5799. //loc, _ := time.LoadLocation("Local")
  5800. //var theStartTIme int64
  5801. //if len(startTime) > 0 {
  5802. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  5803. // if err != nil {
  5804. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5805. // return
  5806. // }
  5807. // theStartTIme = theTime.Unix()
  5808. //}
  5809. //var theEndtTIme int64
  5810. //if len(endTime) > 0 {
  5811. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  5812. // if err != nil {
  5813. // utils.ErrorLog(err.Error())
  5814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5815. // return
  5816. // }
  5817. // theEndtTIme = theTime.Unix()
  5818. //}
  5819. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5820. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5821. for _, team := range datas {
  5822. fmt.Println(team.PsnTime)
  5823. for _, team_two := range datas_two {
  5824. fmt.Println(team_two.PsnTime)
  5825. if team.FundKey == team_two.FundKey {
  5826. fmt.Println(team_two.PsnTime)
  5827. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  5828. fmt.Println(team.PsnTime)
  5829. }
  5830. }
  5831. }
  5832. fmt.Println("1111")
  5833. fmt.Println(datas)
  5834. fmt.Println("1111")
  5835. var twos []models.FixMonRecDetailFileInTwo
  5836. for _, team := range datas {
  5837. var two models.FixMonRecDetailFileInTwo
  5838. two.MedType = team.MedType
  5839. two.Insutype = team.Insutype
  5840. two.PsnType = team.PsnType
  5841. two.MedType = team.MedType
  5842. two.FixBlngAdmdvs = "999999"
  5843. two.InsuAdmdvs = "555555"
  5844. two.PsnTime = team.PsnTime
  5845. two.PsnCnt = team.PsnCnt
  5846. two.FundKey = team.FundKey
  5847. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  5848. fps, _ := strconv.ParseFloat(team.Fund, 64)
  5849. ia, _ := strconv.ParseFloat(team.Amt, 64)
  5850. two.MedfeeSumAmt = ms
  5851. two.InscpAmt = ia
  5852. two.FundPaySumAmt = fps
  5853. twos = append(twos, two)
  5854. }
  5855. //startTime := c.GetString("start_time")
  5856. //endTime, _ := c.GetString("end_time")
  5857. times := strings.Split(startTime, "-")
  5858. stmt_mon := times[0] + times[1]
  5859. var funs []models.FundDetail
  5860. for _, item := range datas {
  5861. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  5862. funs = append(funs, fun...)
  5863. }
  5864. var funInfos []models.Fund
  5865. //for _, item := range funs {
  5866. // var rf []models.FundInfo
  5867. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  5868. // for _, subitem := range rf {
  5869. // var fund models.Fund
  5870. // fund.FundCode = subitem.FundPayType
  5871. // fund.FundName = subitem.FundPayTypeName
  5872. // fund.FundAmt = subitem.FundPayAmt
  5873. // fund.FundKey = item.FundKey
  5874. // fund.InsuAdmdvs = "555555"
  5875. // fund.FixBlngAdmdvs = "999999"
  5876. // funInfos = append(funInfos, fund)
  5877. // }
  5878. //}
  5879. var tempFuns []TempFun
  5880. for _, funInfo := range funInfos {
  5881. var tempFun TempFun
  5882. tempFun.FundKey = funInfo.FundKey
  5883. tempFun.FundCode = funInfo.FundCode
  5884. tempFuns = append(tempFuns, tempFun)
  5885. }
  5886. tempFuns = RemoveRepeatedFunElement(tempFuns)
  5887. fmt.Println(tempFuns)
  5888. var funInfosTwo []models.Fund
  5889. decimal.DivisionPrecision = 2
  5890. for _, item := range tempFuns {
  5891. var fund models.Fund
  5892. for _, subItem := range funInfos {
  5893. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  5894. fund.FundKey = subItem.FundKey
  5895. fund.InsuAdmdvs = subItem.InsuAdmdvs
  5896. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  5897. fund.FundName = subItem.FundName
  5898. fund.FundCode = subItem.FundCode
  5899. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  5900. }
  5901. }
  5902. funInfosTwo = append(funInfosTwo, fund)
  5903. }
  5904. fmt.Println("funInfosTwo")
  5905. fmt.Println(funInfosTwo)
  5906. var upld_btch string
  5907. var empty models.JSResultEmpty
  5908. data := make(map[string]interface{})
  5909. data["org_name"] = miConfig.OrgName
  5910. data["doctor"] = curRoles.UserName
  5911. data["doctor_name"] = curRoles.UserName
  5912. data["fixmedins_code"] = miConfig.Code
  5913. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5914. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5915. data["secret_key"] = miConfig.SecretKey
  5916. data["url"] = miConfig.Url
  5917. data["ak"] = miConfig.AccessKey
  5918. data["cainfo"] = miConfig.Cainfo
  5919. data["datas"] = twos
  5920. data["fund"] = funInfosTwo
  5921. fmt.Println(twos)
  5922. month := time.Unix(1557042972, 0).Format("1")
  5923. year := time.Now().Format("2006")
  5924. month = time.Now().Format("01")
  5925. day := time.Now().Format("02")
  5926. hour := time.Now().Format("15")
  5927. min := time.Now().Format("04")
  5928. sec := time.Now().Format("05")
  5929. fix_fill_date := year + month + day + hour + min + sec
  5930. data["fix_fill_dept"] = miConfig.OrgName
  5931. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5932. data["fix_fill_psn"] = curRoles.UserName
  5933. data["fix_fill_date"] = fix_fill_date
  5934. data["stmt_loc"] = "2"
  5935. data["setl_mon"] = stmt_mon
  5936. upld_btch = "0"
  5937. data["upld_btch"] = upld_btch
  5938. //fmt.Println(data)
  5939. client := &http.Client{}
  5940. bytesData, _ := json.Marshal(data)
  5941. var req *http.Request
  5942. if miConfig.MdtrtareaAdmvs == "320921" {
  5943. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5944. } else {
  5945. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5946. }
  5947. resp, _ := client.Do(req)
  5948. defer resp.Body.Close()
  5949. body, ioErr := ioutil.ReadAll(resp.Body)
  5950. if ioErr != nil {
  5951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5953. }
  5954. var respJSON map[string]interface{}
  5955. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5958. }
  5959. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5960. //fmt.Println(respJSON)
  5961. result, _ := json.Marshal(respJSON)
  5962. //fmt.Println(result)
  5963. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  5964. utils.ErrorLog("解析失败:%v", err)
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5966. }
  5967. if empty.Infcode != "0" {
  5968. c.ServeSuccessJSON(map[string]interface{}{
  5969. "failed_code": -10,
  5970. "msg": empty.ErrMsg,
  5971. })
  5972. return
  5973. } else {
  5974. c.ServeSuccessJSON(map[string]interface{}{
  5975. "msg": "上传成功",
  5976. })
  5977. return
  5978. }
  5979. }
  5980. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  5981. newArr = make([]TempFun, 0)
  5982. for i := 0; i < len(arr); i++ {
  5983. repeat := false
  5984. for j := i + 1; j < len(arr); j++ {
  5985. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  5986. repeat = true
  5987. break
  5988. }
  5989. }
  5990. if !repeat {
  5991. newArr = append(newArr, arr[i])
  5992. }
  5993. }
  5994. return
  5995. }
  5996. func (c *HisApiController) Get3263() {
  5997. admin_user_id, _ := c.GetInt64("admin_user_id")
  5998. startTime := c.GetString("start_time")
  5999. //endTime, _ := c.GetString("end_time")
  6000. times := strings.Split(startTime, "-")
  6001. setl_mon := times[0] + times[1]
  6002. upld_btch := "0"
  6003. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6004. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6005. var result3263 models.JSResult3263
  6006. data := make(map[string]interface{})
  6007. data["org_name"] = miConfig.OrgName
  6008. data["doctor"] = curRoles.UserName
  6009. data["doctor_name"] = curRoles.UserName
  6010. data["fixmedins_code"] = miConfig.Code
  6011. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6012. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6013. data["secret_key"] = miConfig.SecretKey
  6014. data["url"] = miConfig.Url
  6015. data["ak"] = miConfig.AccessKey
  6016. data["cainfo"] = miConfig.Cainfo
  6017. data["setl_mon"] = setl_mon
  6018. data["stmt_loc"] = "2"
  6019. data["upld_btch"] = upld_btch
  6020. client := &http.Client{}
  6021. bytesData, _ := json.Marshal(data)
  6022. var req *http.Request
  6023. if miConfig.MdtrtareaAdmvs == "320921" {
  6024. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6025. } else {
  6026. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6027. }
  6028. resp, _ := client.Do(req)
  6029. defer resp.Body.Close()
  6030. body, ioErr := ioutil.ReadAll(resp.Body)
  6031. if ioErr != nil {
  6032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6034. }
  6035. var respJSON map[string]interface{}
  6036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6039. }
  6040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6041. fmt.Println(respJSON)
  6042. result, _ := json.Marshal(respJSON)
  6043. fmt.Println(result)
  6044. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6045. utils.ErrorLog("解析失败:%v", err)
  6046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6047. }
  6048. if result3263.Infcode != "0" {
  6049. c.ServeSuccessJSON(map[string]interface{}{
  6050. "failed_code": -10,
  6051. "msg": result3263.ErrMsg,
  6052. })
  6053. return
  6054. } else {
  6055. c.ServeSuccessJSON(map[string]interface{}{
  6056. "list": result3263.Output,
  6057. })
  6058. return
  6059. }
  6060. }
  6061. func (c *HisApiController) Get3264() {
  6062. admin_user_id, _ := c.GetInt64("admin_user_id")
  6063. startTime := c.GetString("start_time")
  6064. //endTime, _ := c.GetString("end_time")
  6065. times := strings.Split(startTime, "-")
  6066. setl_mon := times[0] + times[1]
  6067. upld_btch := "0"
  6068. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6069. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6070. //solidify_id := []
  6071. var result3263 models.JSResult3263
  6072. data := make(map[string]interface{})
  6073. data["org_name"] = miConfig.OrgName
  6074. data["doctor"] = curRoles.UserName
  6075. data["doctor_name"] = curRoles.UserName
  6076. data["fixmedins_code"] = miConfig.Code
  6077. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6078. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6079. data["secret_key"] = miConfig.SecretKey
  6080. data["url"] = miConfig.Url
  6081. data["ak"] = miConfig.AccessKey
  6082. data["cainfo"] = miConfig.Cainfo
  6083. data["setl_mon"] = setl_mon
  6084. data["stmt_loc"] = "2"
  6085. data["upld_btch"] = upld_btch
  6086. client := &http.Client{}
  6087. bytesData, _ := json.Marshal(data)
  6088. var req3263 *http.Request
  6089. if miConfig.MdtrtareaAdmvs == "320921" {
  6090. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6091. } else {
  6092. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6093. }
  6094. resp, _ := client.Do(req3263)
  6095. defer resp.Body.Close()
  6096. body, ioErr := ioutil.ReadAll(resp.Body)
  6097. if ioErr != nil {
  6098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6100. }
  6101. var respJSON3263 map[string]interface{}
  6102. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6105. }
  6106. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6107. fmt.Println(respJSON3263)
  6108. result, _ := json.Marshal(respJSON3263)
  6109. fmt.Println(result)
  6110. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6111. utils.ErrorLog("解析失败:%v", err)
  6112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6113. }
  6114. var ids []string
  6115. for _, item := range result3263.Output {
  6116. ids = append(ids, item.SolidifyID)
  6117. }
  6118. var empty models.JSResultEmpty
  6119. data2 := make(map[string]interface{})
  6120. data2["org_name"] = miConfig.OrgName
  6121. data2["doctor"] = curRoles.UserName
  6122. data2["doctor_name"] = curRoles.UserName
  6123. data2["fixmedins_code"] = miConfig.Code
  6124. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6125. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6126. data2["secret_key"] = miConfig.SecretKey
  6127. data2["url"] = miConfig.Url
  6128. data2["ak"] = miConfig.AccessKey
  6129. data2["cainfo"] = miConfig.Cainfo
  6130. data2["setl_mon"] = setl_mon
  6131. data2["stmt_loc"] = "2"
  6132. data2["upld_btch"] = upld_btch
  6133. data2["solidify_id"] = ids
  6134. client2 := &http.Client{}
  6135. bytesData2, _ := json.Marshal(data2)
  6136. var req *http.Request
  6137. if miConfig.MdtrtareaAdmvs == "320921" {
  6138. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6139. } else {
  6140. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6141. }
  6142. resp2, _ := client2.Do(req)
  6143. defer resp.Body.Close()
  6144. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6145. if ioErr2 != nil {
  6146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6148. }
  6149. var respJSON map[string]interface{}
  6150. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6153. }
  6154. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6155. fmt.Println(respJSON)
  6156. result2, _ := json.Marshal(respJSON)
  6157. fmt.Println(result2)
  6158. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6159. utils.ErrorLog("解析失败:%v", err)
  6160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6161. }
  6162. if empty.Infcode != "0" {
  6163. c.ServeSuccessJSON(map[string]interface{}{
  6164. "failed_code": -10,
  6165. "msg": empty.ErrMsg,
  6166. })
  6167. return
  6168. } else {
  6169. c.ServeSuccessJSON(map[string]interface{}{
  6170. "msg": "",
  6171. })
  6172. return
  6173. }
  6174. }
  6175. func (c *HisApiController) Get3265() {
  6176. admin_user_id, _ := c.GetInt64("admin_user_id")
  6177. startTime := c.GetString("start_time")
  6178. //endTime, _ := c.GetString("end_time")
  6179. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6180. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6181. times := strings.Split(startTime, "-")
  6182. setl_mon := times[0] + times[1]
  6183. var upld_btch string
  6184. upld_btch = "0"
  6185. //var empty models.JSResultEmpty
  6186. var result3265 models.JSResult3264
  6187. var result3263 models.JSResult3263
  6188. data2 := make(map[string]interface{})
  6189. data2["org_name"] = miConfig.OrgName
  6190. data2["doctor"] = curRoles.UserName
  6191. data2["doctor_name"] = curRoles.UserName
  6192. data2["fixmedins_code"] = miConfig.Code
  6193. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6194. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6195. data2["secret_key"] = miConfig.SecretKey
  6196. data2["url"] = miConfig.Url
  6197. data2["ak"] = miConfig.AccessKey
  6198. data2["cainfo"] = miConfig.Cainfo
  6199. data2["setl_mon"] = setl_mon
  6200. data2["stmt_loc"] = "2"
  6201. data2["upld_btch"] = upld_btch
  6202. client2 := &http.Client{}
  6203. bytesData2, _ := json.Marshal(data2)
  6204. var req3263 *http.Request
  6205. if miConfig.MdtrtareaAdmvs == "320921" {
  6206. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6207. } else {
  6208. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6209. }
  6210. resp2, _ := client2.Do(req3263)
  6211. defer resp2.Body.Close()
  6212. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6213. if ioErr2 != nil {
  6214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6216. }
  6217. var respJSON3263 map[string]interface{}
  6218. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6221. }
  6222. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6223. fmt.Println(respJSON3263)
  6224. result2, _ := json.Marshal(respJSON3263)
  6225. fmt.Println(result2)
  6226. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6227. utils.ErrorLog("解析失败:%v", err)
  6228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6229. }
  6230. var ids []string
  6231. for _, item := range result3263.Output {
  6232. ids = append(ids, item.SolidifyID)
  6233. }
  6234. data := make(map[string]interface{})
  6235. data["org_name"] = miConfig.OrgName
  6236. data["doctor"] = curRoles.UserName
  6237. data["doctor_name"] = curRoles.UserName
  6238. data["fixmedins_code"] = miConfig.Code
  6239. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6240. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6241. data["secret_key"] = miConfig.SecretKey
  6242. data["url"] = miConfig.Url
  6243. data["ak"] = miConfig.AccessKey
  6244. data["cainfo"] = miConfig.Cainfo
  6245. data["setl_mon"] = setl_mon
  6246. data["solidify_id"] = ids
  6247. month := time.Unix(1557042972, 0).Format("1")
  6248. year := time.Now().Format("2006")
  6249. month = time.Now().Format("01")
  6250. day := time.Now().Format("02")
  6251. hour := time.Now().Format("15")
  6252. min := time.Now().Format("04")
  6253. sec := time.Now().Format("05")
  6254. fix_fill_date := year + month + day + hour + min + sec
  6255. data["fix_fill_dept"] = miConfig.OrgName
  6256. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6257. data["fix_fill_psn"] = curRoles.UserName
  6258. data["fix_fill_date"] = fix_fill_date
  6259. data["stmt_loc"] = "2"
  6260. data["upld_btch"] = upld_btch
  6261. client := &http.Client{}
  6262. bytesData, _ := json.Marshal(data)
  6263. var req *http.Request
  6264. if miConfig.MdtrtareaAdmvs == "320921" {
  6265. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6266. } else {
  6267. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6268. }
  6269. resp, _ := client.Do(req)
  6270. defer resp.Body.Close()
  6271. body, ioErr := ioutil.ReadAll(resp.Body)
  6272. if ioErr != nil {
  6273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6275. }
  6276. var respJSON map[string]interface{}
  6277. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6280. }
  6281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6282. fmt.Println(respJSON)
  6283. result, _ := json.Marshal(respJSON)
  6284. fmt.Println(result)
  6285. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6286. utils.ErrorLog("解析失败:%v", err)
  6287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6288. }
  6289. if result3265.Infcode != "0" {
  6290. c.ServeSuccessJSON(map[string]interface{}{
  6291. "failed_code": -10,
  6292. "msg": result3265.ErrMsg,
  6293. })
  6294. return
  6295. } else {
  6296. c.ServeSuccessJSON(map[string]interface{}{
  6297. "info": result3265.Output,
  6298. })
  6299. return
  6300. }
  6301. }
  6302. func (c *HisApiController) Get3266() {
  6303. admin_user_id, _ := c.GetInt64("admin_user_id")
  6304. startTime := c.GetString("start_time")
  6305. //endTime, _ := c.GetString("end_time")
  6306. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6307. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6308. times := strings.Split(startTime, "-")
  6309. stmt_mon := times[0] + times[1]
  6310. var upld_btch string
  6311. //var empty models.JSResultEmpty
  6312. var result3265 models.JSResult3264
  6313. data := make(map[string]interface{})
  6314. data["org_name"] = miConfig.OrgName
  6315. data["doctor"] = curRoles.UserName
  6316. data["doctor_name"] = curRoles.UserName
  6317. data["fixmedins_code"] = miConfig.Code
  6318. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6319. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6320. data["secret_key"] = miConfig.SecretKey
  6321. data["url"] = miConfig.Url
  6322. data["ak"] = miConfig.AccessKey
  6323. data["cainfo"] = miConfig.Cainfo
  6324. data["setl_mon"] = stmt_mon
  6325. month := time.Unix(1557042972, 0).Format("1")
  6326. year := time.Now().Format("2006")
  6327. month = time.Now().Format("01")
  6328. day := time.Now().Format("02")
  6329. hour := time.Now().Format("15")
  6330. min := time.Now().Format("04")
  6331. sec := time.Now().Format("05")
  6332. fix_fill_date := year + month + day + hour + min + sec
  6333. data["fix_fill_dept"] = miConfig.OrgName
  6334. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6335. data["fix_fill_psn"] = curRoles.UserName
  6336. data["fix_fill_date"] = fix_fill_date
  6337. data["stmt_loc"] = "2"
  6338. upld_btch = "0"
  6339. data["upld_btch"] = upld_btch
  6340. client := &http.Client{}
  6341. bytesData, _ := json.Marshal(data)
  6342. var req *http.Request
  6343. if miConfig.MdtrtareaAdmvs == "320921" {
  6344. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6345. } else {
  6346. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6347. }
  6348. resp, _ := client.Do(req)
  6349. defer resp.Body.Close()
  6350. body, ioErr := ioutil.ReadAll(resp.Body)
  6351. if ioErr != nil {
  6352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6354. }
  6355. var respJSON map[string]interface{}
  6356. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6359. }
  6360. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6361. fmt.Println(respJSON)
  6362. result, _ := json.Marshal(respJSON)
  6363. fmt.Println(result)
  6364. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6365. utils.ErrorLog("解析失败:%v", err)
  6366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6367. }
  6368. if result3265.Infcode != "0" {
  6369. c.ServeSuccessJSON(map[string]interface{}{
  6370. "failed_code": -10,
  6371. "msg": result3265.ErrMsg,
  6372. })
  6373. return
  6374. } else {
  6375. c.ServeSuccessJSON(map[string]interface{}{
  6376. "info": result3265.Output,
  6377. })
  6378. return
  6379. }
  6380. }
  6381. func (c *HisApiController) Get3267() {
  6382. admin_user_id, _ := c.GetInt64("admin_user_id")
  6383. startTime := c.GetString("start_time")
  6384. //endTime, _ := c.GetString("end_time")
  6385. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6386. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6387. times := strings.Split(startTime, "-")
  6388. setl_mon := times[0] + times[1]
  6389. var upld_btch string
  6390. //var empty models.JSResultEmpty
  6391. var result3265 models.JSResult3264
  6392. upld_btch = "0"
  6393. data := make(map[string]interface{})
  6394. data["org_name"] = miConfig.OrgName
  6395. data["doctor"] = curRoles.UserName
  6396. data["doctor_name"] = curRoles.UserName
  6397. data["fixmedins_code"] = miConfig.Code
  6398. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6399. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6400. data["secret_key"] = miConfig.SecretKey
  6401. data["url"] = miConfig.Url
  6402. data["ak"] = miConfig.AccessKey
  6403. data["cainfo"] = miConfig.Cainfo
  6404. data["setl_mon"] = setl_mon
  6405. data["stmt_loc"] = "2"
  6406. data["upld_btch"] = upld_btch
  6407. client := &http.Client{}
  6408. bytesData, _ := json.Marshal(data)
  6409. var req *http.Request
  6410. if miConfig.MdtrtareaAdmvs == "320921" {
  6411. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6412. } else {
  6413. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6414. }
  6415. resp, _ := client.Do(req)
  6416. defer resp.Body.Close()
  6417. body, ioErr := ioutil.ReadAll(resp.Body)
  6418. if ioErr != nil {
  6419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6421. }
  6422. var respJSON map[string]interface{}
  6423. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6426. }
  6427. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6428. fmt.Println(respJSON)
  6429. result, _ := json.Marshal(respJSON)
  6430. fmt.Println(result)
  6431. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6432. utils.ErrorLog("解析失败:%v", err)
  6433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6434. }
  6435. if result3265.Infcode != "0" {
  6436. c.ServeSuccessJSON(map[string]interface{}{
  6437. "failed_code": -10,
  6438. "msg": result3265.ErrMsg,
  6439. })
  6440. return
  6441. } else {
  6442. c.ServeSuccessJSON(map[string]interface{}{
  6443. "info": result3265.Output.Data,
  6444. })
  6445. return
  6446. }
  6447. }
  6448. func (c *HisApiController) Get3268() {
  6449. admin_user_id, _ := c.GetInt64("admin_user_id")
  6450. startTime := c.GetString("start_time")
  6451. endTime := c.GetString("end_time")
  6452. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6453. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6454. times := strings.Split(startTime, "-")
  6455. setl_mon := times[0] + times[1]
  6456. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6457. var twos []models.FixMonRecDetailFileInTwo
  6458. var funs []models.FundDetail
  6459. for _, item := range datas {
  6460. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6461. funs = append(funs, fun...)
  6462. }
  6463. var funInfos []models.Fund
  6464. //for _, item := range funs {
  6465. // var rf []models.FundInfo
  6466. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6467. // for _, subitem := range rf {
  6468. // var fund models.Fund
  6469. // fund.FundCode = subitem.FundPayType
  6470. // fund.FundName = subitem.FundPayTypeName
  6471. // fund.FundAmt = subitem.FundPayAmt
  6472. // fund.FundKey = item.FundKey
  6473. // fund.InsuAdmdvs = "555555"
  6474. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6475. // funInfos = append(funInfos, fund)
  6476. // }
  6477. //}
  6478. for _, team := range datas {
  6479. var two models.FixMonRecDetailFileInTwo
  6480. two.SetlDate = time.Now().Format("2006-01-02")
  6481. two.MedType = team.MedType
  6482. two.Insutype = team.Insutype
  6483. two.PsnType = team.PsnType
  6484. two.MedType = team.MedType
  6485. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6486. two.InsuAdmdvs = team.InsuAdmdvs
  6487. two.PsnTime = team.PsnTime
  6488. two.PsnCnt = team.PsnCnt
  6489. two.FundKey = team.FundKey
  6490. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6491. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6492. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6493. two.MedfeeSumAmt = ms
  6494. two.InscpAmt = ia
  6495. two.FundPaySumAmt = fps
  6496. twos = append(twos, two)
  6497. }
  6498. var upld_btch string
  6499. upld_btch = "0"
  6500. var empty models.JSResultEmpty
  6501. data := make(map[string]interface{})
  6502. data["org_name"] = miConfig.OrgName
  6503. data["doctor"] = curRoles.UserName
  6504. data["doctor_name"] = curRoles.UserName
  6505. data["fixmedins_code"] = miConfig.Code
  6506. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6507. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6508. data["secret_key"] = miConfig.SecretKey
  6509. data["url"] = miConfig.Url
  6510. data["ak"] = miConfig.AccessKey
  6511. data["cainfo"] = miConfig.Cainfo
  6512. data["datas"] = twos
  6513. data["fund"] = funInfos
  6514. data["setl_mon"] = setl_mon
  6515. month := time.Unix(1557042972, 0).Format("1")
  6516. year := time.Now().Format("2006")
  6517. month = time.Now().Format("01")
  6518. day := time.Now().Format("02")
  6519. hour := time.Now().Format("15")
  6520. min := time.Now().Format("04")
  6521. sec := time.Now().Format("05")
  6522. fix_fill_date := year + month + day + hour + min + sec
  6523. data["fix_fill_dept"] = miConfig.OrgName
  6524. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6525. data["fix_fill_psn"] = curRoles.UserName
  6526. data["fix_fill_date"] = fix_fill_date
  6527. data["stmt_loc"] = "2"
  6528. data["upld_btch"] = upld_btch
  6529. client := &http.Client{}
  6530. bytesData, _ := json.Marshal(data)
  6531. var req *http.Request
  6532. if miConfig.MdtrtareaAdmvs == "320921" {
  6533. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6534. } else {
  6535. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6536. }
  6537. resp, _ := client.Do(req)
  6538. defer resp.Body.Close()
  6539. body, ioErr := ioutil.ReadAll(resp.Body)
  6540. if ioErr != nil {
  6541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6543. }
  6544. var respJSON map[string]interface{}
  6545. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6548. }
  6549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6550. fmt.Println(respJSON)
  6551. result, _ := json.Marshal(respJSON)
  6552. fmt.Println(result)
  6553. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6554. utils.ErrorLog("解析失败:%v", err)
  6555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6556. }
  6557. if empty.Infcode != "0" {
  6558. c.ServeSuccessJSON(map[string]interface{}{
  6559. "failed_code": -10,
  6560. "msg": empty.ErrMsg,
  6561. })
  6562. return
  6563. } else {
  6564. c.ServeSuccessJSON(map[string]interface{}{
  6565. "msg": "上传成功",
  6566. })
  6567. return
  6568. }
  6569. }
  6570. func (c *HisApiController) Get3269() {
  6571. admin_user_id, _ := c.GetInt64("admin_user_id")
  6572. startTime := c.GetString("start_time")
  6573. //endTime, _ := c.GetString("end_time")
  6574. times := strings.Split(startTime, "-")
  6575. setl_mon := times[0] + times[1]
  6576. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6577. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6578. var result3263 models.JSResult3263
  6579. data := make(map[string]interface{})
  6580. data["org_name"] = miConfig.OrgName
  6581. data["doctor"] = curRoles.UserName
  6582. data["doctor_name"] = curRoles.UserName
  6583. data["fixmedins_code"] = miConfig.Code
  6584. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6585. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6586. data["secret_key"] = miConfig.SecretKey
  6587. data["url"] = miConfig.Url
  6588. data["ak"] = miConfig.AccessKey
  6589. data["cainfo"] = miConfig.Cainfo
  6590. data["setl_mon"] = setl_mon
  6591. data["stmt_loc"] = "2"
  6592. client := &http.Client{}
  6593. bytesData, _ := json.Marshal(data)
  6594. var req *http.Request
  6595. if miConfig.MdtrtareaAdmvs == "320921" {
  6596. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6597. } else {
  6598. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6599. }
  6600. resp, _ := client.Do(req)
  6601. defer resp.Body.Close()
  6602. body, ioErr := ioutil.ReadAll(resp.Body)
  6603. if ioErr != nil {
  6604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6606. }
  6607. var respJSON map[string]interface{}
  6608. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6611. }
  6612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6613. fmt.Println(respJSON)
  6614. result, _ := json.Marshal(respJSON)
  6615. fmt.Println(result)
  6616. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6617. utils.ErrorLog("解析失败:%v", err)
  6618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6619. }
  6620. if result3263.Infcode != "0" {
  6621. c.ServeSuccessJSON(map[string]interface{}{
  6622. "failed_code": -10,
  6623. "msg": result3263.ErrMsg,
  6624. })
  6625. return
  6626. } else {
  6627. c.ServeSuccessJSON(map[string]interface{}{
  6628. "msg": "上传成功",
  6629. })
  6630. return
  6631. }
  6632. }
  6633. func (c *HisApiController) Get3270() {
  6634. admin_user_id, _ := c.GetInt64("admin_user_id")
  6635. startTime := c.GetString("start_time")
  6636. //endTime, _ := c.GetString("end_time")
  6637. times := strings.Split(startTime, "-")
  6638. setl_mon := times[0] + times[1]
  6639. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6640. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6641. var result3263 models.JSResult3263
  6642. data2 := make(map[string]interface{})
  6643. data2["org_name"] = miConfig.OrgName
  6644. data2["doctor"] = curRoles.UserName
  6645. data2["doctor_name"] = curRoles.UserName
  6646. data2["fixmedins_code"] = miConfig.Code
  6647. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6648. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6649. data2["secret_key"] = miConfig.SecretKey
  6650. data2["url"] = miConfig.Url
  6651. data2["ak"] = miConfig.AccessKey
  6652. data2["cainfo"] = miConfig.Cainfo
  6653. data2["setl_mon"] = setl_mon
  6654. data2["stmt_loc"] = "2"
  6655. client2 := &http.Client{}
  6656. bytesData2, _ := json.Marshal(data2)
  6657. var req3263 *http.Request
  6658. if miConfig.MdtrtareaAdmvs == "320921" {
  6659. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6660. } else {
  6661. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6662. }
  6663. resp2, _ := client2.Do(req3263)
  6664. defer resp2.Body.Close()
  6665. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6666. if ioErr2 != nil {
  6667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6669. }
  6670. var respJSON3263 map[string]interface{}
  6671. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6674. }
  6675. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6676. fmt.Println(respJSON3263)
  6677. result2, _ := json.Marshal(respJSON3263)
  6678. fmt.Println(result2)
  6679. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6680. utils.ErrorLog("解析失败:%v", err)
  6681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6682. }
  6683. var ids []string
  6684. for _, item := range result3263.Output {
  6685. ids = append(ids, item.SolidifyID)
  6686. }
  6687. var result3264 models.JSResult3264
  6688. data := make(map[string]interface{})
  6689. data["org_name"] = miConfig.OrgName
  6690. data["doctor"] = curRoles.UserName
  6691. data["doctor_name"] = curRoles.UserName
  6692. data["fixmedins_code"] = miConfig.Code
  6693. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6694. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6695. data["secret_key"] = miConfig.SecretKey
  6696. data["url"] = miConfig.Url
  6697. data["ak"] = miConfig.AccessKey
  6698. data["cainfo"] = miConfig.Cainfo
  6699. data["setl_mon"] = setl_mon
  6700. data["stmt_loc"] = "2"
  6701. data["solidify_id"] = ids
  6702. client := &http.Client{}
  6703. bytesData, _ := json.Marshal(data)
  6704. var req *http.Request
  6705. if miConfig.MdtrtareaAdmvs == "320921" {
  6706. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6707. } else {
  6708. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6709. }
  6710. resp, _ := client.Do(req)
  6711. defer resp.Body.Close()
  6712. body, ioErr := ioutil.ReadAll(resp.Body)
  6713. if ioErr != nil {
  6714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6716. }
  6717. var respJSON map[string]interface{}
  6718. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6721. }
  6722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6723. fmt.Println(respJSON)
  6724. result, _ := json.Marshal(respJSON)
  6725. fmt.Println(result)
  6726. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  6727. utils.ErrorLog("解析失败:%v", err)
  6728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6729. }
  6730. if result3264.Infcode != "0" {
  6731. c.ServeSuccessJSON(map[string]interface{}{
  6732. "failed_code": -10,
  6733. "msg": result3264.ErrMsg,
  6734. })
  6735. return
  6736. } else {
  6737. c.ServeSuccessJSON(map[string]interface{}{
  6738. "info": result3264.Output,
  6739. })
  6740. return
  6741. }
  6742. }
  6743. func (c *HisApiController) Get3271() {
  6744. admin_user_id, _ := c.GetInt64("admin_user_id")
  6745. startTime := c.GetString("start_time")
  6746. //endTime, _ := c.GetString("end_time")
  6747. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6748. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6749. times := strings.Split(startTime, "-")
  6750. setl_mon := times[0] + times[1]
  6751. //var empty models.JSResultEmpty
  6752. var result3265 models.JSResult3264
  6753. var result3263 models.JSResult3263
  6754. data2 := make(map[string]interface{})
  6755. data2["org_name"] = miConfig.OrgName
  6756. data2["doctor"] = curRoles.UserName
  6757. data2["doctor_name"] = curRoles.UserName
  6758. data2["fixmedins_code"] = miConfig.Code
  6759. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6760. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6761. data2["secret_key"] = miConfig.SecretKey
  6762. data2["url"] = miConfig.Url
  6763. data2["ak"] = miConfig.AccessKey
  6764. data2["cainfo"] = miConfig.Cainfo
  6765. data2["setl_mon"] = setl_mon
  6766. data2["stmt_loc"] = "2"
  6767. client2 := &http.Client{}
  6768. bytesData2, _ := json.Marshal(data2)
  6769. var req3263 *http.Request
  6770. if miConfig.MdtrtareaAdmvs == "320921" {
  6771. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6772. } else {
  6773. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6774. }
  6775. resp2, _ := client2.Do(req3263)
  6776. defer resp2.Body.Close()
  6777. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6778. if ioErr2 != nil {
  6779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6781. }
  6782. var respJSON3263 map[string]interface{}
  6783. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6786. }
  6787. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6788. fmt.Println(respJSON3263)
  6789. result2, _ := json.Marshal(respJSON3263)
  6790. fmt.Println(result2)
  6791. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6792. utils.ErrorLog("解析失败:%v", err)
  6793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6794. }
  6795. var ids []string
  6796. for _, item := range result3263.Output {
  6797. ids = append(ids, item.SolidifyID)
  6798. }
  6799. data := make(map[string]interface{})
  6800. data["org_name"] = miConfig.OrgName
  6801. data["doctor"] = curRoles.UserName
  6802. data["doctor_name"] = curRoles.UserName
  6803. data["fixmedins_code"] = miConfig.Code
  6804. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6805. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6806. data["secret_key"] = miConfig.SecretKey
  6807. data["url"] = miConfig.Url
  6808. data["ak"] = miConfig.AccessKey
  6809. data["cainfo"] = miConfig.Cainfo
  6810. data["setl_mon"] = setl_mon
  6811. data["solidify_id"] = ids
  6812. month := time.Unix(1557042972, 0).Format("1")
  6813. year := time.Now().Format("2006")
  6814. month = time.Now().Format("01")
  6815. day := time.Now().Format("02")
  6816. hour := time.Now().Format("15")
  6817. min := time.Now().Format("04")
  6818. sec := time.Now().Format("05")
  6819. fix_fill_date := year + month + day + hour + min + sec
  6820. data["fix_fill_dept"] = miConfig.OrgName
  6821. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6822. data["fix_fill_psn"] = curRoles.UserName
  6823. data["fix_fill_date"] = fix_fill_date
  6824. data["stmt_loc"] = "2"
  6825. client := &http.Client{}
  6826. bytesData, _ := json.Marshal(data)
  6827. var req *http.Request
  6828. if miConfig.MdtrtareaAdmvs == "320921" {
  6829. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6830. } else {
  6831. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6832. }
  6833. resp, _ := client.Do(req)
  6834. defer resp.Body.Close()
  6835. body, ioErr := ioutil.ReadAll(resp.Body)
  6836. if ioErr != nil {
  6837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6839. }
  6840. var respJSON map[string]interface{}
  6841. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6844. }
  6845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6846. fmt.Println(respJSON)
  6847. result, _ := json.Marshal(respJSON)
  6848. fmt.Println(result)
  6849. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6850. utils.ErrorLog("解析失败:%v", err)
  6851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6852. }
  6853. if result3265.Infcode != "0" {
  6854. c.ServeSuccessJSON(map[string]interface{}{
  6855. "failed_code": -10,
  6856. "msg": result3265.ErrMsg,
  6857. })
  6858. return
  6859. } else {
  6860. c.ServeSuccessJSON(map[string]interface{}{
  6861. "info": result3265.Output.Data,
  6862. })
  6863. return
  6864. }
  6865. }
  6866. func (c *HisApiController) Get3272() {
  6867. admin_user_id, _ := c.GetInt64("admin_user_id")
  6868. startTime := c.GetString("start_time")
  6869. //endTime, _ := c.GetString("end_time")
  6870. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6871. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6872. times := strings.Split(startTime, "-")
  6873. setl_mon := times[0] + times[1]
  6874. var upld_btch string
  6875. //var empty models.JSResultEmpty
  6876. var result3265 models.JSResult3264
  6877. data := make(map[string]interface{})
  6878. data["org_name"] = miConfig.OrgName
  6879. data["doctor"] = curRoles.UserName
  6880. data["doctor_name"] = curRoles.UserName
  6881. data["fixmedins_code"] = miConfig.Code
  6882. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6883. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6884. data["secret_key"] = miConfig.SecretKey
  6885. data["url"] = miConfig.Url
  6886. data["ak"] = miConfig.AccessKey
  6887. data["cainfo"] = miConfig.Cainfo
  6888. data["setl_mon"] = setl_mon
  6889. month := time.Unix(1557042972, 0).Format("1")
  6890. year := time.Now().Format("2006")
  6891. month = time.Now().Format("01")
  6892. day := time.Now().Format("02")
  6893. hour := time.Now().Format("15")
  6894. min := time.Now().Format("04")
  6895. sec := time.Now().Format("05")
  6896. fix_fill_date := year + month + day + hour + min + sec
  6897. data["fix_fill_dept"] = miConfig.OrgName
  6898. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6899. data["fix_fill_psn"] = curRoles.UserName
  6900. data["fix_fill_date"] = fix_fill_date
  6901. data["stmt_loc"] = "2"
  6902. data["upld_btch"] = upld_btch
  6903. client := &http.Client{}
  6904. bytesData, _ := json.Marshal(data)
  6905. var req *http.Request
  6906. if miConfig.MdtrtareaAdmvs == "320921" {
  6907. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6908. } else {
  6909. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6910. }
  6911. resp, _ := client.Do(req)
  6912. defer resp.Body.Close()
  6913. body, ioErr := ioutil.ReadAll(resp.Body)
  6914. if ioErr != nil {
  6915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6917. }
  6918. var respJSON map[string]interface{}
  6919. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6922. }
  6923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6924. fmt.Println(respJSON)
  6925. result, _ := json.Marshal(respJSON)
  6926. fmt.Println(result)
  6927. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6928. utils.ErrorLog("解析失败:%v", err)
  6929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6930. }
  6931. if result3265.Infcode != "0" {
  6932. c.ServeSuccessJSON(map[string]interface{}{
  6933. "failed_code": -10,
  6934. "msg": result3265.ErrMsg,
  6935. })
  6936. return
  6937. } else {
  6938. c.ServeSuccessJSON(map[string]interface{}{
  6939. "info": result3265.Output,
  6940. })
  6941. return
  6942. }
  6943. }
  6944. func (c *HisApiController) Get3273() {
  6945. admin_user_id, _ := c.GetInt64("admin_user_id")
  6946. startTime := c.GetString("start_time")
  6947. //endTime, _ := c.GetString("end_time")
  6948. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6949. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6950. times := strings.Split(startTime, "-")
  6951. setl_mon := times[0] + times[1]
  6952. var result3265 models.JSResult3264
  6953. data := make(map[string]interface{})
  6954. data["org_name"] = miConfig.OrgName
  6955. data["doctor"] = curRoles.UserName
  6956. data["doctor_name"] = curRoles.UserName
  6957. data["fixmedins_code"] = miConfig.Code
  6958. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6959. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6960. data["secret_key"] = miConfig.SecretKey
  6961. data["url"] = miConfig.Url
  6962. data["ak"] = miConfig.AccessKey
  6963. data["cainfo"] = miConfig.Cainfo
  6964. data["setl_mon"] = setl_mon
  6965. data["stmt_loc"] = "2"
  6966. client := &http.Client{}
  6967. bytesData, _ := json.Marshal(data)
  6968. var req *http.Request
  6969. if miConfig.MdtrtareaAdmvs == "320921" {
  6970. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  6971. } else {
  6972. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  6973. }
  6974. resp, _ := client.Do(req)
  6975. defer resp.Body.Close()
  6976. body, ioErr := ioutil.ReadAll(resp.Body)
  6977. if ioErr != nil {
  6978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6980. }
  6981. var respJSON map[string]interface{}
  6982. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6985. }
  6986. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6987. fmt.Println(respJSON)
  6988. result, _ := json.Marshal(respJSON)
  6989. fmt.Println(result)
  6990. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6991. utils.ErrorLog("解析失败:%v", err)
  6992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6993. }
  6994. if result3265.Infcode != "0" {
  6995. c.ServeSuccessJSON(map[string]interface{}{
  6996. "failed_code": -10,
  6997. "msg": result3265.ErrMsg,
  6998. })
  6999. return
  7000. } else {
  7001. c.ServeSuccessJSON(map[string]interface{}{
  7002. "info": result3265.Output.Data,
  7003. })
  7004. return
  7005. }
  7006. }
  7007. func (c *HisApiController) Get3274() {
  7008. //if miConfig.MdtrtareaAdmvs == "320921" {
  7009. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7010. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7011. // "&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
  7012. //
  7013. //} else {
  7014. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7015. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7016. // "&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
  7017. //
  7018. //}
  7019. }
  7020. func (c *HisApiController) Get3275() {
  7021. //if miConfig.MdtrtareaAdmvs == "320921" {
  7022. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7023. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7024. // "&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
  7025. //
  7026. //} else {
  7027. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7028. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7029. // "&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
  7030. //
  7031. //}
  7032. }
  7033. func (c *HisApiController) Get3276() {
  7034. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7035. //month := c.GetString("month")
  7036. //
  7037. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7038. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7039. //var api string
  7040. //var res Result5301
  7041. //
  7042. //if miConfig.MdtrtareaAdmvs == "320921" {
  7043. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7044. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7045. //} else {
  7046. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7047. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7048. //}
  7049. //
  7050. //resp, requestErr := http.Get(api)
  7051. //if requestErr != nil {
  7052. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7053. // return
  7054. //}
  7055. //
  7056. //body, ioErr := ioutil.ReadAll(resp.Body)
  7057. //if ioErr != nil {
  7058. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7060. // return
  7061. //}
  7062. //var respJSON map[string]interface{}
  7063. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7064. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7066. // return
  7067. //}
  7068. //
  7069. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7070. //result, _ := json.Marshal(respJSON)
  7071. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7072. // utils.ErrorLog("解析失败:%v", err)
  7073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7074. // return
  7075. //}
  7076. }
  7077. func (c *HisApiController) Get3277() {
  7078. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7079. //month := c.GetString("month")
  7080. //
  7081. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7082. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7083. //var api string
  7084. //var res Result5301
  7085. //
  7086. //if miConfig.MdtrtareaAdmvs == "320921" {
  7087. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7088. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7089. //} else {
  7090. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7091. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7092. //}
  7093. //
  7094. //resp, requestErr := http.Get(api)
  7095. //if requestErr != nil {
  7096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7097. // return
  7098. //}
  7099. //
  7100. //body, ioErr := ioutil.ReadAll(resp.Body)
  7101. //if ioErr != nil {
  7102. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7103. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7104. // return
  7105. //}
  7106. //var respJSON map[string]interface{}
  7107. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7108. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7109. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7110. // return
  7111. //}
  7112. //
  7113. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7114. //result, _ := json.Marshal(respJSON)
  7115. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7116. // utils.ErrorLog("解析失败:%v", err)
  7117. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7118. // return
  7119. //}
  7120. }
  7121. func (c *HisApiController) GetCFYLJG001() {
  7122. admin_user_id, _ := c.GetInt64("admin_user_id")
  7123. patient_id, _ := c.GetInt64("patient_id")
  7124. his_patient_id, _ := c.GetInt64("his_patient_id")
  7125. record_time := c.GetString("record_time")
  7126. admin_user_id = 3626
  7127. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7128. psn, _ := service.GetPsnByPatientId(patient_id)
  7129. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7130. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7131. var cFYLJG001 models.CFYLJG001
  7132. timeLayout := "2006-01-02"
  7133. loc, _ := time.LoadLocation("Local")
  7134. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7135. if err != nil {
  7136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7137. return
  7138. }
  7139. recordDateTime := theTime.Unix()
  7140. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7141. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7142. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7143. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7144. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7145. for _, item := range prescriptions {
  7146. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7147. if his.IdCardType == 1 {
  7148. bas := strings.Split(psn.CardInfo, "|")
  7149. basNumber := bas[1]
  7150. fmt.Println(basNumber)
  7151. card_sn := bas[3]
  7152. card_no := bas[2]
  7153. cFYLJG001.MdtrtCertType = "03"
  7154. cFYLJG001.CardSn = card_sn
  7155. cFYLJG001.MdtrtCertNo = card_no
  7156. cFYLJG001.EcToken = ""
  7157. cFYLJG001.AuthNo = ""
  7158. } else if his.IdCardType == 2 {
  7159. cFYLJG001.MdtrtCertType = "02"
  7160. cFYLJG001.CardSn = ""
  7161. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7162. cFYLJG001.EcToken = ""
  7163. cFYLJG001.AuthNo = ""
  7164. } else if his.IdCardType == 4 {
  7165. cFYLJG001.MdtrtCertType = "01"
  7166. cFYLJG001.CardSn = ""
  7167. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7168. cFYLJG001.EcToken = psn.VerifyNumber
  7169. cFYLJG001.AuthNo = ""
  7170. }
  7171. cFYLJG001.BizTypeCode = "01"
  7172. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7173. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7174. cFYLJG001.RxTypeCode = "1"
  7175. tempTime := time.Unix(item.PreTime, 0)
  7176. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7177. cFYLJG001.PrscTime = timeFormatOne
  7178. var count float64
  7179. if item.Type == 1 {
  7180. for _, sumItem := range item.HisDoctorAdviceInfo {
  7181. count = count + sumItem.PrescribingNumber
  7182. }
  7183. }
  7184. cFYLJG001.RxDrugCnt = count
  7185. cFYLJG001.ValiDays = "5"
  7186. ts := time.Unix(item.PreTime, 0)
  7187. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7188. tempTime3 := time.Unix(record_time2, 0)
  7189. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7190. cFYLJG001.ValiEndTime = timeFormat3
  7191. cFYLJG001.RxCotnFlag = "0"
  7192. for _, subItem := range item.HisDoctorAdviceInfo {
  7193. var drug models.RxDrug
  7194. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7195. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7196. drug.RxItemTypeCode = "11"
  7197. drug.DrugDosform = "乳膏剂" //TODO
  7198. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7199. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7200. }
  7201. drug.MedcWayDscr = subItem.DeliveryWay
  7202. tempTime2 := time.Unix(subItem.StartTime, 0)
  7203. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7204. drug.MedcBegntime = timeFormatTwo
  7205. if subItem.Day > 0 {
  7206. ts := time.Unix(subItem.StartTime, 0)
  7207. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7208. tempTime4 := time.Unix(record_time, 0)
  7209. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7210. drug.MedcEndtime = timeFormat5
  7211. } else {
  7212. tempTime2 := time.Unix(subItem.StartTime, 0)
  7213. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7214. drug.MedcEndtime = timeFormatTwo
  7215. }
  7216. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7217. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7218. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7219. drug.DrugCnt = subItem.PrescribingNumber
  7220. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7221. drug.DrugGenname = subItem.AdviceName
  7222. drug.MedcWayCodg = subItem.DeliveryWay
  7223. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7224. drug.SinDoscnt = subItem.SingleDose
  7225. drug.SinDosunt = subItem.SingleDoseUnit
  7226. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7227. drug.UsedFrquName = subItem.ExecutionFrequency
  7228. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7229. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7230. drug.HospApprFlag = "1"
  7231. cFYLJG001.List = append(cFYLJG001.List, drug)
  7232. }
  7233. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7234. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7235. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7236. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7237. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7238. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7239. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7240. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7241. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7242. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7243. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7244. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7245. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7246. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7247. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7248. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7249. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7250. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7251. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7252. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7253. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7254. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7255. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7256. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7257. tempTime2 := time.Now().Unix()
  7258. tempTime6 := time.Unix(tempTime2, 0)
  7259. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7260. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7261. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7262. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7263. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7264. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7265. //memo := make(map[string]interface{})
  7266. //inputData := make(map[string]interface{}, 0)
  7267. //type MyData struct {
  7268. // Insutype string `json:"insutype"`
  7269. //}
  7270. //
  7271. // data := MyData{
  7272. // Insutype: his.Insutype,
  7273. //}
  7274. //
  7275. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7276. var config []*models.HisXtDiagnoseConfig
  7277. for _, item := range diagnosis_ids {
  7278. id, _ := strconv.ParseInt(item, 10, 64)
  7279. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7280. config = append(config, &diagnosisConfig)
  7281. }
  7282. for index, subitem := range config {
  7283. if index == 0 {
  7284. var dia models.DiseInfo
  7285. dia.DiagType = "1"
  7286. dia.MaindiagFlag = "1"
  7287. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7288. dia.DiagCode = subitem.CountryCode
  7289. dia.DiagName = subitem.ClassName
  7290. dia.DiagDept = "肾内科"
  7291. dia.DiagDrNo = doctor.DoctorNumber
  7292. dia.DiagDrName = doctor.UserName
  7293. tempTime3 := time.Unix(item.PreTime, 0)
  7294. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7295. dia.DiagTime = timeFormatTwo
  7296. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7297. } else {
  7298. var dia models.DiseInfo
  7299. dia.DiagType = "1"
  7300. dia.MaindiagFlag = "0"
  7301. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7302. dia.DiagCode = subitem.CountryCode
  7303. dia.DiagName = subitem.ClassName
  7304. dia.DiagDept = "肾内科"
  7305. dia.DiagDrNo = doctor.DoctorNumber
  7306. dia.DiagDrName = doctor.UserName
  7307. tempTime3 := time.Unix(item.PreTime, 0)
  7308. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7309. dia.DiagTime = timeFormatTwo
  7310. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7311. }
  7312. }
  7313. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7314. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7315. var res ResultCFYLJG001
  7316. var respJSON2 map[string]interface{}
  7317. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7320. return
  7321. }
  7322. userJSONBytes2, _ := json.Marshal(respJSON2)
  7323. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7324. utils.ErrorLog("解析失败:%v", err)
  7325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7326. return
  7327. }
  7328. if res.Infcode == -1 {
  7329. c.ServeSuccessJSON(map[string]interface{}{
  7330. "failed_code": -10,
  7331. "msg": res.ErrMsg,
  7332. })
  7333. return
  7334. } else {
  7335. var flow models.HisPrescriptionFlow
  7336. flow.Ctime = time.Now().Unix()
  7337. flow.SignDigest = ""
  7338. flow.RxTraceCode = res.Output.RxTraceCode
  7339. flow.HiRxno = res.Output.HiRxno
  7340. flow.MID = his.Number
  7341. flow.Status = 1
  7342. flow.DCode = doctor_info.DoctorNumber
  7343. flow.OriginalRxFile = ""
  7344. flow.OriginalValue = ""
  7345. flow.SignCertDn = ""
  7346. flow.UserOrgId = 10454
  7347. flow.SignCertSn = ""
  7348. flow.Mtime = time.Now().Unix()
  7349. service.Createflow(&flow)
  7350. c.ServeSuccessJSON(map[string]interface{}{
  7351. "msg": "上传成功",
  7352. })
  7353. }
  7354. }
  7355. }
  7356. func (c *HisApiController) GetCFYLJG002() {
  7357. admin_user_id, _ := c.GetInt64("admin_user_id")
  7358. his_patient_id, _ := c.GetInt64("his_patient_id")
  7359. record_time := c.GetString("record_time")
  7360. admin_user_id = 3626
  7361. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7362. //id, _ := c.GetInt64("id")
  7363. admin_user_id = 3626
  7364. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7365. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7366. flow, _ := service.Getflowtwo(his.Number)
  7367. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7368. //record_time := c.GetString("record_time")
  7369. patient_id, _ := c.GetInt64("patient_id")
  7370. //patient_id = 23834
  7371. //record_time = "2023-09-18"
  7372. timeLayout := "2006-01-02"
  7373. loc, _ := time.LoadLocation("Local")
  7374. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7375. if err != nil {
  7376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7377. return
  7378. }
  7379. recordDateTime := theTime.Unix()
  7380. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7381. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7382. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7383. dept, _ := service.GetDepartMentDetail(info.Departments)
  7384. inputData := make(map[string]interface{})
  7385. inputData["rxTraceCode"] = flow.RxTraceCode
  7386. inputData["hiRxno"] = flow.HiRxno
  7387. inputData["mdtrtId"] = flow.MID
  7388. inputData["patnName"] = his.PsnName
  7389. inputData["psnCertType"] = his.PsnCertType
  7390. inputData["certno"] = his.Certno
  7391. inputData["fixmedinsName"] = miConfig.OrgName
  7392. inputData["fixmedinsCode"] = miConfig.Code
  7393. inputData["drCode"] = doctor_info.DoctorNumber
  7394. inputData["prscDrName"] = doctor_info.UserName
  7395. inputData["pharDeptName"] = dept.Name
  7396. inputData["pharDeptCode"] = dept.Number
  7397. inputData["pharProfttlCodg"] = dept.Name
  7398. inputData["pharProfttlName"] = ""
  7399. inputData["pharCode"] = "HY440309002107"
  7400. inputData["pharCertType"] = "01"
  7401. inputData["pharCertno"] = "430482199408260023"
  7402. inputData["pharName"] = "彭斯遥"
  7403. inputData["pharPracCertNo"] = ""
  7404. tempTime2 := time.Unix(info.Ctime, 0)
  7405. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7406. inputData["pharChkTime"] = timeFormatTwo
  7407. bytesData, _ := json.Marshal(inputData)
  7408. fmt.Println(string(bytesData))
  7409. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7410. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7411. if err != nil {
  7412. fmt.Println("Error reading PDF file:", err)
  7413. return
  7414. }
  7415. // 将 PDF 文件内容进行 Base64 编码
  7416. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7417. fmt.Println(err)
  7418. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7419. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7420. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7421. var res2 Result002
  7422. var respJSON2 map[string]interface{}
  7423. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7426. return
  7427. }
  7428. userJSONBytes2, _ := json.Marshal(respJSON2)
  7429. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7430. utils.ErrorLog("解析失败:%v", err)
  7431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7432. return
  7433. }
  7434. if res2.Infcode == 0 {
  7435. flow.Ctime = time.Now().Unix()
  7436. flow.SignDigest = res2.Output.SignDigest
  7437. flow.RxFile = res2.Output.RxFile
  7438. flow.MID = his.Number
  7439. flow.Status = 1
  7440. flow.DCode = doctor_info.DoctorNumber
  7441. flow.OriginalRxFile = rx_encoded
  7442. flow.OriginalValue = encoded
  7443. flow.SignCertDn = res2.Output.SignCertDn
  7444. flow.SignCertSn = res2.Output.SignCertSn
  7445. flow.Mtime = time.Now().Unix()
  7446. service.Saveflow(flow)
  7447. c.ServeSuccessJSON(map[string]interface{}{
  7448. "msg": "预签名成功",
  7449. })
  7450. } else {
  7451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7452. return
  7453. }
  7454. }
  7455. func (c *HisApiController) GetCFYLJG003() {
  7456. admin_user_id, _ := c.GetInt64("admin_user_id")
  7457. his_patient_id, _ := c.GetInt64("his_patient_id")
  7458. record_time := c.GetString("record_time")
  7459. admin_user_id = 3626
  7460. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7461. //id, _ := c.GetInt64("id")
  7462. admin_user_id = 3626
  7463. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7464. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7465. flow, _ := service.Getflowtwo(his.Number)
  7466. //id = 3
  7467. patient_id, _ := c.GetInt64("patient_id")
  7468. //patient_id = 23834
  7469. //record_time = "2023-09-18"
  7470. timeLayout := "2006-01-02"
  7471. loc, _ := time.LoadLocation("Local")
  7472. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7473. if err != nil {
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7475. return
  7476. }
  7477. recordDateTime := theTime.Unix()
  7478. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7479. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7480. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7481. dept, _ := service.GetDepartMentDetail(info.Departments)
  7482. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7483. var cFYLJG003 models.CFYLJG003
  7484. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7485. cFYLJG003.HiRxno = flow.HiRxno
  7486. cFYLJG003.MdtrtID = flow.MID
  7487. cFYLJG003.PatnName = his.Name
  7488. cFYLJG003.Certno = his.Certno
  7489. cFYLJG003.FixmedinsName = miConfig.OrgName
  7490. cFYLJG003.FixmedinsCode = miConfig.Code
  7491. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7492. cFYLJG003.PrscDrName = doctor_info.UserName
  7493. cFYLJG003.PharDeptName = dept.Name
  7494. cFYLJG003.PharDeptCode = dept.Number
  7495. cFYLJG003.PharCode = "HY440309002107"
  7496. cFYLJG003.PharCertType = "01"
  7497. cFYLJG003.PharCertno = "430482199408260023"
  7498. cFYLJG003.PharName = "彭斯遥"
  7499. cFYLJG003.PsnCertType = "01"
  7500. cFYLJG003.RxFile = flow.RxFile
  7501. cFYLJG003.SignDigest = flow.SignDigest
  7502. cFYLJG003.FixmedinsCode = miConfig.Code
  7503. cFYLJG003.PsnCertType = "01"
  7504. cFYLJG003.PharProfttlCodg = dept.Name
  7505. //inputData["pharProfttlCodg"] =dept.Name
  7506. tempTime2 := time.Unix(info.Ctime, 0)
  7507. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7508. cFYLJG003.PharChkTime = timeFormatTwo
  7509. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7510. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7511. var res ResultCFYLJG003
  7512. var respJSON2 map[string]interface{}
  7513. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7516. return
  7517. }
  7518. userJSONBytes2, _ := json.Marshal(respJSON2)
  7519. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7520. utils.ErrorLog("解析失败:%v", err)
  7521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7522. return
  7523. }
  7524. if res.Infcode == -1 {
  7525. c.ServeSuccessJSON(map[string]interface{}{
  7526. "failed_code": -10,
  7527. "msg": res.ErrMsg,
  7528. })
  7529. return
  7530. } else {
  7531. c.ServeSuccessJSON(map[string]interface{}{
  7532. "info": res.Output,
  7533. })
  7534. }
  7535. }
  7536. func (c *HisApiController) GetCFYLJG004() {
  7537. admin_user_id, _ := c.GetInt64("admin_user_id")
  7538. his_patient_id, _ := c.GetInt64("his_patient_id")
  7539. record_time := c.GetString("record_time")
  7540. admin_user_id = 3626
  7541. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7542. //id, _ := c.GetInt64("id")
  7543. admin_user_id = 3626
  7544. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7545. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7546. flow, _ := service.Getflowtwo(his.Number)
  7547. //id = 3
  7548. patient_id, _ := c.GetInt64("patient_id")
  7549. //patient_id = 23834
  7550. //record_time = "2023-09-18"
  7551. timeLayout := "2006-01-02"
  7552. loc, _ := time.LoadLocation("Local")
  7553. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7554. if err != nil {
  7555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7556. return
  7557. }
  7558. recordDateTime := theTime.Unix()
  7559. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7560. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7561. var cFYLJG004 models.CFYLJG004
  7562. cFYLJG004.HiRxno = flow.HiRxno
  7563. cFYLJG004.FixmedinsCode = miConfig.Code
  7564. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7565. cFYLJG004.UndoDrCertType = "01"
  7566. cFYLJG004.UndoRea = "撤销处方"
  7567. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7568. cFYLJG004.UndoDrName = doctor_info.UserName
  7569. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7570. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7571. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7572. var res ResultCFYLJG004
  7573. var respJSON2 map[string]interface{}
  7574. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7577. return
  7578. }
  7579. userJSONBytes2, _ := json.Marshal(respJSON2)
  7580. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7581. utils.ErrorLog("解析失败:%v", err)
  7582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7583. return
  7584. }
  7585. if res.Infcode == -1 {
  7586. c.ServeSuccessJSON(map[string]interface{}{
  7587. "failed_code": -10,
  7588. "msg": res.ErrMsg,
  7589. })
  7590. return
  7591. } else {
  7592. flow.Status = 0
  7593. service.Saveflow(flow)
  7594. c.ServeSuccessJSON(map[string]interface{}{
  7595. "msg": "撤销成功",
  7596. })
  7597. return
  7598. }
  7599. }
  7600. func (c *HisApiController) GetCFYLJG005() {
  7601. admin_user_id, _ := c.GetInt64("admin_user_id")
  7602. his_patient_id, _ := c.GetInt64("his_patient_id")
  7603. //record_time := c.GetString("record_time")
  7604. admin_user_id = 3626
  7605. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7606. //id, _ := c.GetInt64("id")
  7607. admin_user_id = 3626
  7608. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7609. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7610. flow, _ := service.Getflowtwo(his.Number)
  7611. //id = 3
  7612. var cFYLJG005 models.CFYLJG005
  7613. //patient_id, _ := c.GetInt64("patient_id")
  7614. cFYLJG005.HiRxno = flow.HiRxno
  7615. cFYLJG005.MdtrtID = flow.MID
  7616. cFYLJG005.EcToken = ""
  7617. cFYLJG005.PsnName = his.Name
  7618. cFYLJG005.PsnCertType = "01"
  7619. cFYLJG005.Certno = his.IdCardNo
  7620. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7621. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7622. var res ResultCFYLJG005
  7623. var respJSON2 map[string]interface{}
  7624. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7627. return
  7628. }
  7629. userJSONBytes2, _ := json.Marshal(respJSON2)
  7630. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7631. utils.ErrorLog("解析失败:%v", err)
  7632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7633. return
  7634. }
  7635. if res.Infcode == -1 {
  7636. c.ServeSuccessJSON(map[string]interface{}{
  7637. "failed_code": -10,
  7638. "msg": res.ErrMsg,
  7639. })
  7640. return
  7641. } else {
  7642. c.ServeSuccessJSON(map[string]interface{}{
  7643. "info": res.Output,
  7644. })
  7645. return
  7646. }
  7647. }
  7648. func (c *HisApiController) GetCFYLJG006() {
  7649. admin_user_id, _ := c.GetInt64("admin_user_id")
  7650. his_patient_id, _ := c.GetInt64("his_patient_id")
  7651. admin_user_id = 3626
  7652. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7653. //id, _ := c.GetInt64("id")
  7654. admin_user_id = 3626
  7655. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7656. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7657. flow, _ := service.Getflowtwo(his.Number)
  7658. //id = 3
  7659. patient_id, _ := c.GetInt64("patient_id")
  7660. var cFYLJG006 models.CFYLJG006
  7661. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7662. cFYLJG006.HiRxno = flow.HiRxno
  7663. cFYLJG006.MdtrtID = flow.MID
  7664. cFYLJG006.PsnName = patient.Name
  7665. cFYLJG006.PsnCertType = "01"
  7666. cFYLJG006.Certno = patient.IdCardNo
  7667. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7668. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7669. var res ResultCFYLJG006
  7670. var respJSON2 map[string]interface{}
  7671. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7674. return
  7675. }
  7676. userJSONBytes2, _ := json.Marshal(respJSON2)
  7677. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7678. utils.ErrorLog("解析失败:%v", err)
  7679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7680. return
  7681. }
  7682. if res.Infcode == -1 {
  7683. c.ServeSuccessJSON(map[string]interface{}{
  7684. "failed_code": -10,
  7685. "msg": res.ErrMsg,
  7686. })
  7687. return
  7688. } else {
  7689. c.ServeSuccessJSON(map[string]interface{}{
  7690. "info": res.Output,
  7691. })
  7692. return
  7693. }
  7694. }
  7695. func (c *HisApiController) GetCFYLJG007() {
  7696. admin_user_id, _ := c.GetInt64("admin_user_id")
  7697. his_patient_id, _ := c.GetInt64("his_patient_id")
  7698. admin_user_id = 3626
  7699. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7700. //id, _ := c.GetInt64("id")
  7701. admin_user_id = 3626
  7702. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7703. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7704. flow, _ := service.Getflowtwo(his.Number)
  7705. //id = 3
  7706. patient_id, _ := c.GetInt64("patient_id")
  7707. var cFYLJG007 models.CFYLJG007
  7708. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7709. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7710. cFYLJG007.HiRxno = flow.HiRxno
  7711. cFYLJG007.MdtrtID = flow.MID
  7712. cFYLJG007.PsnNo = his.PsnNo
  7713. cFYLJG007.PsnCertType = "01"
  7714. cFYLJG007.Certno = patient.IdCardNo
  7715. cFYLJG007.PsnName = patient.Name
  7716. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  7717. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  7718. var res ResultCFYLJG007
  7719. var respJSON2 map[string]interface{}
  7720. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7723. return
  7724. }
  7725. userJSONBytes2, _ := json.Marshal(respJSON2)
  7726. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7727. utils.ErrorLog("解析失败:%v", err)
  7728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7729. return
  7730. }
  7731. if res.Infcode == -1 {
  7732. c.ServeSuccessJSON(map[string]interface{}{
  7733. "failed_code": -10,
  7734. "msg": res.ErrMsg,
  7735. })
  7736. return
  7737. } else {
  7738. c.ServeSuccessJSON(map[string]interface{}{
  7739. "info": res,
  7740. })
  7741. return
  7742. }
  7743. }
  7744. func (c *HisApiController) GetCFYLJG008() {
  7745. admin_user_id, _ := c.GetInt64("admin_user_id")
  7746. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7747. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7748. var cFYLJG008 models.CFYLJG008
  7749. //id, _ := c.GetInt64("id")
  7750. patient_id, _ := c.GetInt64("patient_id")
  7751. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7752. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7753. //id = 3
  7754. //flow, _ := service.Getflow(id)
  7755. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7756. //
  7757. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7758. //patient_id, _ := c.GetInt64("patient_id")
  7759. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7760. record_time := c.GetString("record_time")
  7761. admin_user_id = 3626
  7762. patient_id = 19424
  7763. //his_patient_id = 263947
  7764. record_time = "2023-08-29"
  7765. timeLayout := "2006-01-02"
  7766. loc, _ := time.LoadLocation("Local")
  7767. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7768. if err != nil {
  7769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7770. return
  7771. }
  7772. recordDateTime := theTime.Unix()
  7773. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7774. cFYLJG008.FixmedinsName = ""
  7775. cFYLJG008.Lat = ""
  7776. cFYLJG008.Lng = ""
  7777. cFYLJG008.OrderType = "1"
  7778. cFYLJG008.PoolareaNo = ""
  7779. cFYLJG008.Lng = ""
  7780. cFYLJG008.PageNum = 1
  7781. cFYLJG008.PageSize = 10
  7782. var MPI models.MedinsProdInvChgDDTO
  7783. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  7784. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  7785. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  7786. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  7787. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  7788. var res ResultCFYLJG008
  7789. var respJSON2 map[string]interface{}
  7790. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7793. return
  7794. }
  7795. userJSONBytes2, _ := json.Marshal(respJSON2)
  7796. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7797. utils.ErrorLog("解析失败:%v", err)
  7798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7799. return
  7800. }
  7801. if res.Infcode == -1 {
  7802. c.ServeSuccessJSON(map[string]interface{}{
  7803. "failed_code": -10,
  7804. "msg": res.ErrMsg,
  7805. })
  7806. return
  7807. } else {
  7808. c.ServeSuccessJSON(map[string]interface{}{
  7809. "info": res.Output,
  7810. })
  7811. return
  7812. }
  7813. }
  7814. func (c *HisApiController) GetBL4201A() {
  7815. order_id, _ := c.GetInt64("order_id")
  7816. admin_user_id, _ := c.GetInt64("admin_user_id")
  7817. order, _ := service.GetHisOrderByIDTwo(order_id)
  7818. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7819. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7820. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7821. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7822. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7823. department, _ := service.GetDepartMentDetail(his.Departments)
  7824. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7825. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7826. if order.ID == 0 {
  7827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7828. return
  7829. }
  7830. var struct4201A models.Struct4201A
  7831. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7832. for _, items := range order_info {
  7833. memo := make(map[string]interface{})
  7834. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7835. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7836. fsiOPFLD.MedType = "14"
  7837. fsiOPFLD.BkkpSn = items.FeedetlSn
  7838. fsiOPFLD.FixmedinsCode = miConfig.Code
  7839. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7840. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7841. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7842. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7843. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7844. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7845. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7846. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7847. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7848. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7849. fsiOPFLD.BilgDeptName = department.Name
  7850. fsiOPFLD.BilgDeptCodg = department.Number
  7851. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7852. fsiOPFLD.BilgDrName = doctor.UserName
  7853. fsiOPFLD.MedChrgitmType = "09"
  7854. memo["hosp_appr_flag"] = "1"
  7855. memo["invoice_no"] = order.MdtrtId
  7856. memo["memo"] = "自费"
  7857. bytesData, _ := json.Marshal(memo)
  7858. fsiOPFLD.Memo = string(bytesData)
  7859. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7860. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7861. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7862. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7863. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7864. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7865. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7866. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7867. fsiOPFLD.BilgDeptName = department.Name
  7868. fsiOPFLD.BilgDeptCodg = department.Number
  7869. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7870. fsiOPFLD.BilgDrName = doctor.UserName
  7871. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7872. case 0:
  7873. break
  7874. case 1:
  7875. fsiOPFLD.MedChrgitmType = "14"
  7876. break
  7877. case 2:
  7878. fsiOPFLD.MedChrgitmType = "05"
  7879. break
  7880. case 3:
  7881. fsiOPFLD.MedChrgitmType = "03"
  7882. break
  7883. case 4:
  7884. fsiOPFLD.MedChrgitmType = "03"
  7885. break
  7886. case 5:
  7887. fsiOPFLD.MedChrgitmType = "08"
  7888. break
  7889. case 6:
  7890. fsiOPFLD.MedChrgitmType = "14"
  7891. break
  7892. case 7:
  7893. fsiOPFLD.MedChrgitmType = "14"
  7894. break
  7895. case 8:
  7896. fsiOPFLD.MedChrgitmType = "03"
  7897. break
  7898. case 9:
  7899. fsiOPFLD.MedChrgitmType = "14"
  7900. break
  7901. case 10:
  7902. fsiOPFLD.MedChrgitmType = "14"
  7903. break
  7904. case 11:
  7905. fsiOPFLD.MedChrgitmType = "06"
  7906. break
  7907. case 12:
  7908. fsiOPFLD.MedChrgitmType = "12"
  7909. break
  7910. case 13:
  7911. fsiOPFLD.MedChrgitmType = "01"
  7912. break
  7913. case 14:
  7914. fsiOPFLD.MedChrgitmType = "04"
  7915. break
  7916. case 15:
  7917. fsiOPFLD.MedChrgitmType = "14"
  7918. break
  7919. }
  7920. memo["hosp_appr_flag"] = "1"
  7921. memo["invoice_no"] = order.MdtrtId
  7922. memo["memo"] = "自费"
  7923. bytesData, _ := json.Marshal(memo)
  7924. fsiOPFLD.Memo = string(bytesData)
  7925. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7926. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  7927. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7928. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7929. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7930. fsiOPFLD.BilgDeptName = department.Name
  7931. fsiOPFLD.BilgDeptCodg = department.Number
  7932. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7933. fsiOPFLD.BilgDrName = doctor.UserName
  7934. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7935. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7936. fsiOPFLD.MedChrgitmType = "08"
  7937. memo["hosp_appr_flag"] = "1"
  7938. memo["invoice_no"] = order.MdtrtId
  7939. memo["memo"] = "自费"
  7940. bytesData, _ := json.Marshal(memo)
  7941. fsiOPFLD.Memo = string(bytesData)
  7942. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7943. }
  7944. }
  7945. }
  7946. for _, items := range order_info_two {
  7947. memo := make(map[string]interface{})
  7948. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7949. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7950. fsiOPFLD.MedType = "14"
  7951. fsiOPFLD.BkkpSn = items.FeedetlSn
  7952. fsiOPFLD.FixmedinsCode = miConfig.Code
  7953. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7954. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7955. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7956. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7957. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7958. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7959. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7960. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7961. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7962. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7963. fsiOPFLD.BilgDeptName = department.Name
  7964. fsiOPFLD.BilgDeptCodg = department.Number
  7965. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7966. fsiOPFLD.BilgDrName = doctor.UserName
  7967. fsiOPFLD.MedChrgitmType = "09"
  7968. memo["hosp_appr_flag"] = "1"
  7969. memo["invoice_no"] = order.MdtrtId
  7970. memo["memo"] = "自费"
  7971. bytesData, _ := json.Marshal(memo)
  7972. fsiOPFLD.Memo = string(bytesData)
  7973. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7974. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7975. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7976. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7977. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7978. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7979. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7980. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7981. fsiOPFLD.BilgDeptName = department.Name
  7982. fsiOPFLD.BilgDeptCodg = department.Number
  7983. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7984. fsiOPFLD.BilgDrName = doctor.UserName
  7985. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7986. case 0:
  7987. break
  7988. case 1:
  7989. fsiOPFLD.MedChrgitmType = "14"
  7990. break
  7991. case 2:
  7992. fsiOPFLD.MedChrgitmType = "05"
  7993. break
  7994. case 3:
  7995. fsiOPFLD.MedChrgitmType = "03"
  7996. break
  7997. case 4:
  7998. fsiOPFLD.MedChrgitmType = "03"
  7999. break
  8000. case 5:
  8001. fsiOPFLD.MedChrgitmType = "08"
  8002. break
  8003. case 6:
  8004. fsiOPFLD.MedChrgitmType = "14"
  8005. break
  8006. case 7:
  8007. fsiOPFLD.MedChrgitmType = "14"
  8008. break
  8009. case 8:
  8010. fsiOPFLD.MedChrgitmType = "03"
  8011. break
  8012. case 9:
  8013. fsiOPFLD.MedChrgitmType = "14"
  8014. break
  8015. case 10:
  8016. fsiOPFLD.MedChrgitmType = "14"
  8017. break
  8018. case 11:
  8019. fsiOPFLD.MedChrgitmType = "06"
  8020. break
  8021. case 12:
  8022. fsiOPFLD.MedChrgitmType = "12"
  8023. break
  8024. case 13:
  8025. fsiOPFLD.MedChrgitmType = "01"
  8026. break
  8027. case 14:
  8028. fsiOPFLD.MedChrgitmType = "04"
  8029. break
  8030. case 15:
  8031. fsiOPFLD.MedChrgitmType = "14"
  8032. break
  8033. }
  8034. memo["hosp_appr_flag"] = "1"
  8035. memo["invoice_no"] = order.MdtrtId
  8036. memo["memo"] = "自费"
  8037. bytesData, _ := json.Marshal(memo)
  8038. fsiOPFLD.Memo = string(bytesData)
  8039. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8040. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8041. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8042. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8043. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8044. fsiOPFLD.BilgDeptName = department.Name
  8045. fsiOPFLD.BilgDeptCodg = department.Number
  8046. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8047. fsiOPFLD.BilgDrName = doctor.UserName
  8048. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8049. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8050. fsiOPFLD.MedChrgitmType = "08"
  8051. memo["hosp_appr_flag"] = "1"
  8052. memo["invoice_no"] = order.MdtrtId
  8053. memo["memo"] = "自费"
  8054. bytesData, _ := json.Marshal(memo)
  8055. fsiOPFLD.Memo = string(bytesData)
  8056. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8057. }
  8058. }
  8059. }
  8060. fmt.Println(fsiOPFLDs)
  8061. struct4201A.Fopfd = fsiOPFLDs
  8062. fmt.Println(struct4201A.Fopfd)
  8063. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8064. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8065. var res2 ResultSix
  8066. var respJSON2 map[string]interface{}
  8067. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8068. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8070. return
  8071. }
  8072. userJSONBytes2, _ := json.Marshal(respJSON2)
  8073. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8074. utils.ErrorLog("解析失败:%v", err)
  8075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8076. return
  8077. }
  8078. if res2.Infcode != 0 {
  8079. c.ServeSuccessJSON(map[string]interface{}{
  8080. "failed_code": -10,
  8081. "msg": res2.ErrMsg,
  8082. })
  8083. return
  8084. } else {
  8085. order.IsUploadOrderInfo = 1
  8086. service.UpdateOrder(order)
  8087. c.ServeSuccessJSON(map[string]interface{}{
  8088. "msg": "上传成功",
  8089. })
  8090. }
  8091. }
  8092. func (c *HisApiController) Get2505() {
  8093. admin_user_id, _ := c.GetInt64("admin_user_id")
  8094. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8095. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8096. service.Gdyb2505("45000000000008100145868008", curRoles.UserName, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2024-01-12 09:00:00", "2026-12-31 23:00:00", admin_user_id)
  8097. }
  8098. func (c *HisApiController) Get4201A() {
  8099. order_id, _ := c.GetInt64("order_id")
  8100. admin_user_id, _ := c.GetInt64("admin_user_id")
  8101. order, _ := service.GetHisOrderByIDTwo(order_id)
  8102. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8103. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8104. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8105. //order_info = append(order_info, order_info_two...)
  8106. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8107. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8108. department, _ := service.GetDepartMentDetail(his.Departments)
  8109. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8110. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8111. if order.ID == 0 {
  8112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8113. return
  8114. }
  8115. var struct4201A models.Struct4201A
  8116. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8117. for _, items := range order_info {
  8118. memo := make(map[string]interface{})
  8119. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8120. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8121. fsiOPFLD.MedType = "14"
  8122. fsiOPFLD.BkkpSn = items.FeedetlSn
  8123. fsiOPFLD.FixmedinsCode = miConfig.Code
  8124. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8125. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8126. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8127. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8128. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8129. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8130. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8131. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8132. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8133. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8134. fsiOPFLD.BilgDeptName = department.Name
  8135. fsiOPFLD.BilgDeptCodg = department.Number
  8136. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8137. fsiOPFLD.BilgDrName = doctor.UserName
  8138. fsiOPFLD.MedChrgitmType = "09"
  8139. memo["hosp_appr_flag"] = "1"
  8140. memo["invoice_no"] = order.MdtrtId
  8141. memo["memo"] = "自费"
  8142. bytesData, _ := json.Marshal(memo)
  8143. fsiOPFLD.Memo = string(bytesData)
  8144. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8145. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8146. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8147. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8148. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8149. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8150. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8151. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8152. fsiOPFLD.BilgDeptName = department.Name
  8153. fsiOPFLD.BilgDeptCodg = department.Number
  8154. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8155. fsiOPFLD.BilgDrName = doctor.UserName
  8156. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8157. case 0:
  8158. break
  8159. case 1:
  8160. fsiOPFLD.MedChrgitmType = "14"
  8161. break
  8162. case 2:
  8163. fsiOPFLD.MedChrgitmType = "05"
  8164. break
  8165. case 3:
  8166. fsiOPFLD.MedChrgitmType = "03"
  8167. break
  8168. case 4:
  8169. fsiOPFLD.MedChrgitmType = "03"
  8170. break
  8171. case 5:
  8172. fsiOPFLD.MedChrgitmType = "08"
  8173. break
  8174. case 6:
  8175. fsiOPFLD.MedChrgitmType = "14"
  8176. break
  8177. case 7:
  8178. fsiOPFLD.MedChrgitmType = "14"
  8179. break
  8180. case 8:
  8181. fsiOPFLD.MedChrgitmType = "03"
  8182. break
  8183. case 9:
  8184. fsiOPFLD.MedChrgitmType = "14"
  8185. break
  8186. case 10:
  8187. fsiOPFLD.MedChrgitmType = "14"
  8188. break
  8189. case 11:
  8190. fsiOPFLD.MedChrgitmType = "06"
  8191. break
  8192. case 12:
  8193. fsiOPFLD.MedChrgitmType = "12"
  8194. break
  8195. case 13:
  8196. fsiOPFLD.MedChrgitmType = "01"
  8197. break
  8198. case 14:
  8199. fsiOPFLD.MedChrgitmType = "04"
  8200. break
  8201. case 15:
  8202. fsiOPFLD.MedChrgitmType = "14"
  8203. break
  8204. }
  8205. memo["hosp_appr_flag"] = "1"
  8206. memo["invoice_no"] = order.MdtrtId
  8207. memo["memo"] = "自费"
  8208. bytesData, _ := json.Marshal(memo)
  8209. fsiOPFLD.Memo = string(bytesData)
  8210. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8211. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8212. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8213. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8214. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8215. fsiOPFLD.BilgDeptName = department.Name
  8216. fsiOPFLD.BilgDeptCodg = department.Number
  8217. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8218. fsiOPFLD.BilgDrName = doctor.UserName
  8219. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8220. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8221. fsiOPFLD.MedChrgitmType = "08"
  8222. memo["hosp_appr_flag"] = "1"
  8223. memo["invoice_no"] = order.MdtrtId
  8224. memo["memo"] = "自费"
  8225. bytesData, _ := json.Marshal(memo)
  8226. fsiOPFLD.Memo = string(bytesData)
  8227. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8228. }
  8229. }
  8230. }
  8231. for _, items := range order_info_two {
  8232. memo := make(map[string]interface{})
  8233. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8234. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8235. fsiOPFLD.MedType = "14"
  8236. fsiOPFLD.BkkpSn = items.FeedetlSn
  8237. fsiOPFLD.FixmedinsCode = miConfig.Code
  8238. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8239. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8240. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8241. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8242. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8243. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8244. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8245. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8246. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8247. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8248. fsiOPFLD.BilgDeptName = department.Name
  8249. fsiOPFLD.BilgDeptCodg = department.Number
  8250. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8251. fsiOPFLD.BilgDrName = doctor.UserName
  8252. fsiOPFLD.MedChrgitmType = "09"
  8253. memo["hosp_appr_flag"] = "1"
  8254. memo["invoice_no"] = order.MdtrtId
  8255. memo["memo"] = "自费"
  8256. bytesData, _ := json.Marshal(memo)
  8257. fsiOPFLD.Memo = string(bytesData)
  8258. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8259. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8260. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8261. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8262. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8263. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8264. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8265. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8266. fsiOPFLD.BilgDeptName = department.Name
  8267. fsiOPFLD.BilgDeptCodg = department.Number
  8268. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8269. fsiOPFLD.BilgDrName = doctor.UserName
  8270. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8271. case 0:
  8272. break
  8273. case 1:
  8274. fsiOPFLD.MedChrgitmType = "14"
  8275. break
  8276. case 2:
  8277. fsiOPFLD.MedChrgitmType = "05"
  8278. break
  8279. case 3:
  8280. fsiOPFLD.MedChrgitmType = "03"
  8281. break
  8282. case 4:
  8283. fsiOPFLD.MedChrgitmType = "03"
  8284. break
  8285. case 5:
  8286. fsiOPFLD.MedChrgitmType = "08"
  8287. break
  8288. case 6:
  8289. fsiOPFLD.MedChrgitmType = "14"
  8290. break
  8291. case 7:
  8292. fsiOPFLD.MedChrgitmType = "14"
  8293. break
  8294. case 8:
  8295. fsiOPFLD.MedChrgitmType = "03"
  8296. break
  8297. case 9:
  8298. fsiOPFLD.MedChrgitmType = "14"
  8299. break
  8300. case 10:
  8301. fsiOPFLD.MedChrgitmType = "14"
  8302. break
  8303. case 11:
  8304. fsiOPFLD.MedChrgitmType = "06"
  8305. break
  8306. case 12:
  8307. fsiOPFLD.MedChrgitmType = "12"
  8308. break
  8309. case 13:
  8310. fsiOPFLD.MedChrgitmType = "01"
  8311. break
  8312. case 14:
  8313. fsiOPFLD.MedChrgitmType = "04"
  8314. break
  8315. case 15:
  8316. fsiOPFLD.MedChrgitmType = "14"
  8317. break
  8318. }
  8319. memo["hosp_appr_flag"] = "1"
  8320. memo["invoice_no"] = order.MdtrtId
  8321. memo["memo"] = "自费"
  8322. bytesData, _ := json.Marshal(memo)
  8323. fsiOPFLD.Memo = string(bytesData)
  8324. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8325. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8326. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8327. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8328. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8329. fsiOPFLD.BilgDeptName = department.Name
  8330. fsiOPFLD.BilgDeptCodg = department.Number
  8331. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8332. fsiOPFLD.BilgDrName = doctor.UserName
  8333. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8334. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8335. fsiOPFLD.MedChrgitmType = "08"
  8336. memo["hosp_appr_flag"] = "1"
  8337. memo["invoice_no"] = order.MdtrtId
  8338. memo["memo"] = "自费"
  8339. bytesData, _ := json.Marshal(memo)
  8340. fsiOPFLD.Memo = string(bytesData)
  8341. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8342. }
  8343. }
  8344. }
  8345. fmt.Println(fsiOPFLDs)
  8346. struct4201A.Fopfd = fsiOPFLDs
  8347. fmt.Println(struct4201A.Fopfd)
  8348. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8349. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8350. var res2 ResultSix
  8351. var respJSON2 map[string]interface{}
  8352. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8355. return
  8356. }
  8357. userJSONBytes2, _ := json.Marshal(respJSON2)
  8358. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8359. utils.ErrorLog("解析失败:%v", err)
  8360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8361. return
  8362. }
  8363. if res2.Infcode != 0 {
  8364. c.ServeSuccessJSON(map[string]interface{}{
  8365. "failed_code": -10,
  8366. "msg": res2.ErrMsg,
  8367. })
  8368. return
  8369. } else {
  8370. order.IsUploadOrderInfo = 1
  8371. service.UpdateOrder(order)
  8372. c.ServeSuccessJSON(map[string]interface{}{
  8373. "msg": "上传成功",
  8374. })
  8375. }
  8376. }
  8377. func (c *HisApiController) Get4202() {
  8378. order_id, _ := c.GetInt64("order_id")
  8379. admin_user_id, _ := c.GetInt64("admin_user_id")
  8380. order, _ := service.GetHisOrderByIDTwo(order_id)
  8381. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8382. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8383. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8384. if order.ID == 0 {
  8385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8386. return
  8387. }
  8388. var struct4202 models.Struct4202
  8389. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8390. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8391. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8392. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8393. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8394. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8395. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8396. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8397. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8398. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8399. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8400. var config []*models.HisXtDiagnoseConfig
  8401. for _, item := range diagnosis_ids {
  8402. id, _ := strconv.ParseInt(item, 10, 64)
  8403. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8404. config = append(config, &diagnosisConfig)
  8405. }
  8406. var tempDiaginfos []models.OwnPayPatnDiagListD
  8407. for index, item := range config {
  8408. if index == 0 {
  8409. var tempDiaginfo models.OwnPayPatnDiagListD
  8410. tempDiaginfo.InoutDiagType = "1"
  8411. tempDiaginfo.DiagCode = item.CountryCode
  8412. tempDiaginfo.DiagName = item.CountryContentName
  8413. tempDiaginfo.DiagType = "1"
  8414. tempDiaginfo.DiagSrtNo = "1"
  8415. tempDiaginfo.MaindiagFlag = "1"
  8416. tempDiaginfo.ValiFlag = "1"
  8417. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8418. } else {
  8419. var tempDiaginfo models.OwnPayPatnDiagListD
  8420. tempDiaginfo.DiagCode = item.CountryCode
  8421. tempDiaginfo.DiagName = item.CountryContentName
  8422. tempDiaginfo.DiagType = "2"
  8423. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8424. tempDiaginfo.MaindiagFlag = "0"
  8425. tempDiaginfo.ValiFlag = "1"
  8426. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8427. }
  8428. }
  8429. struct4202.ODiagListD = tempDiaginfos
  8430. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8431. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8432. var res2 ResultSix
  8433. var respJSON2 map[string]interface{}
  8434. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8437. return
  8438. }
  8439. userJSONBytes2, _ := json.Marshal(respJSON2)
  8440. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8441. utils.ErrorLog("解析失败:%v", err)
  8442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8443. return
  8444. }
  8445. if res2.Infcode != 0 {
  8446. c.ServeSuccessJSON(map[string]interface{}{
  8447. "failed_code": -10,
  8448. "msg": res2.ErrMsg,
  8449. })
  8450. return
  8451. } else {
  8452. order.IsUploadDiagnose = 1
  8453. service.UpdateOrder(order)
  8454. c.ServeSuccessJSON(map[string]interface{}{
  8455. "msg": "上传成功",
  8456. })
  8457. }
  8458. }
  8459. func (c *HisApiController) Get4203() {
  8460. admin_user_id, _ := c.GetInt64("admin_user_id")
  8461. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8462. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8463. order_id, _ := c.GetInt64("order_id")
  8464. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8465. number := ""
  8466. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8467. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8468. if his.ID == 0 {
  8469. number = hospital.Number
  8470. } else {
  8471. number = his.Number
  8472. }
  8473. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8474. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8475. var res2 ResultSix
  8476. var respJSON2 map[string]interface{}
  8477. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8480. return
  8481. }
  8482. userJSONBytes2, _ := json.Marshal(respJSON2)
  8483. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8484. utils.ErrorLog("解析失败:%v", err)
  8485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8486. return
  8487. }
  8488. if res2.Infcode != 0 {
  8489. c.ServeSuccessJSON(map[string]interface{}{
  8490. "failed_code": -10,
  8491. "msg": res2.ErrMsg,
  8492. })
  8493. return
  8494. } else {
  8495. order.IsUploadSuccess = 1
  8496. service.UpdateOrderTwo(order)
  8497. c.ServeSuccessJSON(map[string]interface{}{
  8498. "msg": "上传成功",
  8499. })
  8500. }
  8501. }
  8502. func (c *HisApiController) Get4205() {
  8503. order_id, _ := c.GetInt64("order_id")
  8504. admin_user_id, _ := c.GetInt64("admin_user_id")
  8505. fapiao_code := c.GetString("fapiao_code")
  8506. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8507. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8508. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8509. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8510. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8511. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8512. //order_info = append(order_info, order_info_two...)
  8513. department, _ := service.GetDepartMentDetail(his.Departments)
  8514. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8515. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8516. if order.ID == 0 {
  8517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8518. return
  8519. }
  8520. var struct4201A models.Struct4201A
  8521. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8522. for _, items := range order_info {
  8523. memo := make(map[string]interface{})
  8524. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8525. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8526. fsiOPFLD.MedType = pre.MedType
  8527. fsiOPFLD.FixmedinsCode = miConfig.Code
  8528. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8529. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8530. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8531. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8532. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8533. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8534. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8535. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8536. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8537. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8538. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8539. fsiOPFLD.BilgDeptName = department.Name
  8540. fsiOPFLD.BilgDeptCodg = department.Number
  8541. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8542. fsiOPFLD.BilgDrName = doctor.UserName
  8543. fsiOPFLD.MedChrgitmType = "09"
  8544. memo["hosp_appr_flag"] = "1"
  8545. memo["invoice_no"] = fapiao_code
  8546. memo["memo"] = "自费"
  8547. bytesData, _ := json.Marshal(memo)
  8548. fsiOPFLD.Memo = string(bytesData)
  8549. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8550. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8551. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8552. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8553. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8554. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8555. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8556. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8557. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8558. fsiOPFLD.BilgDeptName = department.Name
  8559. fsiOPFLD.BilgDeptCodg = department.Number
  8560. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8561. fsiOPFLD.BilgDrName = doctor.UserName
  8562. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8563. case 0:
  8564. break
  8565. case 1:
  8566. fsiOPFLD.MedChrgitmType = "14"
  8567. break
  8568. case 2:
  8569. fsiOPFLD.MedChrgitmType = "05"
  8570. break
  8571. case 3:
  8572. fsiOPFLD.MedChrgitmType = "03"
  8573. break
  8574. case 4:
  8575. fsiOPFLD.MedChrgitmType = "03"
  8576. break
  8577. case 5:
  8578. fsiOPFLD.MedChrgitmType = "08"
  8579. break
  8580. case 6:
  8581. fsiOPFLD.MedChrgitmType = "14"
  8582. break
  8583. case 7:
  8584. fsiOPFLD.MedChrgitmType = "14"
  8585. break
  8586. case 8:
  8587. fsiOPFLD.MedChrgitmType = "03"
  8588. break
  8589. case 9:
  8590. fsiOPFLD.MedChrgitmType = "14"
  8591. break
  8592. case 10:
  8593. fsiOPFLD.MedChrgitmType = "14"
  8594. break
  8595. case 11:
  8596. fsiOPFLD.MedChrgitmType = "06"
  8597. break
  8598. case 12:
  8599. fsiOPFLD.MedChrgitmType = "12"
  8600. break
  8601. case 13:
  8602. fsiOPFLD.MedChrgitmType = "01"
  8603. break
  8604. case 14:
  8605. fsiOPFLD.MedChrgitmType = "04"
  8606. break
  8607. case 15:
  8608. fsiOPFLD.MedChrgitmType = "14"
  8609. break
  8610. }
  8611. memo["hosp_appr_flag"] = "1"
  8612. memo["invoice_no"] = fapiao_code
  8613. memo["memo"] = "自费"
  8614. bytesData, _ := json.Marshal(memo)
  8615. fsiOPFLD.Memo = string(bytesData)
  8616. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8617. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8618. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8619. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8620. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8621. fsiOPFLD.BilgDeptName = department.Name
  8622. fsiOPFLD.BilgDeptCodg = department.Number
  8623. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8624. fsiOPFLD.BilgDrName = doctor.UserName
  8625. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8626. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8627. fsiOPFLD.MedChrgitmType = "08"
  8628. memo["hosp_appr_flag"] = "1"
  8629. memo["invoice_no"] = fapiao_code
  8630. memo["memo"] = "自费"
  8631. bytesData, _ := json.Marshal(memo)
  8632. fsiOPFLD.Memo = string(bytesData)
  8633. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8634. }
  8635. }
  8636. }
  8637. for _, items := range order_info_two {
  8638. memo := make(map[string]interface{})
  8639. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8640. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8641. fsiOPFLD.MedType = pre.MedType
  8642. fsiOPFLD.BkkpSn = items.FeedetlSn
  8643. fsiOPFLD.FixmedinsCode = miConfig.Code
  8644. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8645. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8646. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8647. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8648. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8649. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8650. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8651. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8652. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8653. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8654. fsiOPFLD.BilgDeptName = department.Name
  8655. fsiOPFLD.BilgDeptCodg = department.Number
  8656. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8657. fsiOPFLD.BilgDrName = doctor.UserName
  8658. fsiOPFLD.MedChrgitmType = "09"
  8659. memo["hosp_appr_flag"] = "1"
  8660. memo["invoice_no"] = fapiao_code
  8661. memo["memo"] = "自费"
  8662. bytesData, _ := json.Marshal(memo)
  8663. fsiOPFLD.Memo = string(bytesData)
  8664. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8665. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8666. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8667. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8668. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8669. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8670. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8671. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8672. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8673. fsiOPFLD.BilgDeptName = department.Name
  8674. fsiOPFLD.BilgDeptCodg = department.Number
  8675. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8676. fsiOPFLD.BilgDrName = doctor.UserName
  8677. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8678. case 0:
  8679. break
  8680. case 1:
  8681. fsiOPFLD.MedChrgitmType = "14"
  8682. break
  8683. case 2:
  8684. fsiOPFLD.MedChrgitmType = "05"
  8685. break
  8686. case 3:
  8687. fsiOPFLD.MedChrgitmType = "03"
  8688. break
  8689. case 4:
  8690. fsiOPFLD.MedChrgitmType = "03"
  8691. break
  8692. case 5:
  8693. fsiOPFLD.MedChrgitmType = "08"
  8694. break
  8695. case 6:
  8696. fsiOPFLD.MedChrgitmType = "14"
  8697. break
  8698. case 7:
  8699. fsiOPFLD.MedChrgitmType = "14"
  8700. break
  8701. case 8:
  8702. fsiOPFLD.MedChrgitmType = "03"
  8703. break
  8704. case 9:
  8705. fsiOPFLD.MedChrgitmType = "14"
  8706. break
  8707. case 10:
  8708. fsiOPFLD.MedChrgitmType = "14"
  8709. break
  8710. case 11:
  8711. fsiOPFLD.MedChrgitmType = "06"
  8712. break
  8713. case 12:
  8714. fsiOPFLD.MedChrgitmType = "12"
  8715. break
  8716. case 13:
  8717. fsiOPFLD.MedChrgitmType = "01"
  8718. break
  8719. case 14:
  8720. fsiOPFLD.MedChrgitmType = "04"
  8721. break
  8722. case 15:
  8723. fsiOPFLD.MedChrgitmType = "14"
  8724. break
  8725. }
  8726. memo["hosp_appr_flag"] = "1"
  8727. memo["invoice_no"] = fapiao_code
  8728. memo["memo"] = "自费"
  8729. bytesData, _ := json.Marshal(memo)
  8730. fsiOPFLD.Memo = string(bytesData)
  8731. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8732. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8733. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8734. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8735. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8736. fsiOPFLD.BilgDeptName = department.Name
  8737. fsiOPFLD.BilgDeptCodg = department.Number
  8738. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8739. fsiOPFLD.BilgDrName = doctor.UserName
  8740. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8741. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8742. fsiOPFLD.MedChrgitmType = "08"
  8743. memo["hosp_appr_flag"] = "1"
  8744. memo["invoice_no"] = fapiao_code
  8745. memo["memo"] = "自费"
  8746. bytesData, _ := json.Marshal(memo)
  8747. fsiOPFLD.Memo = string(bytesData)
  8748. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8749. }
  8750. }
  8751. }
  8752. fmt.Println(fsiOPFLDs)
  8753. struct4201A.Fopfd = fsiOPFLDs
  8754. fmt.Println(struct4201A.Fopfd)
  8755. var struct4202 models.Struct4202
  8756. timeLayout := "2006-01-02 15:04:05"
  8757. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  8758. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8759. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8760. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8761. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8762. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8763. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8764. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  8765. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  8766. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8767. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8768. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8769. var config []*models.HisXtDiagnoseConfig
  8770. for _, item := range diagnosis_ids {
  8771. id, _ := strconv.ParseInt(item, 10, 64)
  8772. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8773. config = append(config, &diagnosisConfig)
  8774. }
  8775. var tempDiaginfos []models.OwnPayPatnDiagListD
  8776. for index, item := range config {
  8777. if index == 0 {
  8778. var tempDiaginfo models.OwnPayPatnDiagListD
  8779. tempDiaginfo.InoutDiagType = "1"
  8780. tempDiaginfo.DiagCode = item.CountryCode
  8781. tempDiaginfo.DiagName = item.CountryContentName
  8782. tempDiaginfo.DiagType = "1"
  8783. tempDiaginfo.DiagSrtNo = "1"
  8784. tempDiaginfo.MaindiagFlag = "1"
  8785. tempDiaginfo.ValiFlag = "1"
  8786. tempDiaginfo.DiagDrName = doctor.UserName
  8787. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8788. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8789. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8790. } else {
  8791. var tempDiaginfo models.OwnPayPatnDiagListD
  8792. tempDiaginfo.DiagCode = item.CountryCode
  8793. tempDiaginfo.DiagName = item.CountryContentName
  8794. tempDiaginfo.DiagType = "2"
  8795. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8796. tempDiaginfo.MaindiagFlag = "0"
  8797. tempDiaginfo.ValiFlag = "1"
  8798. tempDiaginfo.DiagDrName = doctor.UserName
  8799. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8800. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8801. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8802. }
  8803. }
  8804. struct4202.ODiagListD = tempDiaginfos
  8805. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  8806. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  8807. var res2 ResultSix
  8808. var respJSON2 map[string]interface{}
  8809. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8812. return
  8813. }
  8814. userJSONBytes2, _ := json.Marshal(respJSON2)
  8815. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8816. utils.ErrorLog("解析失败:%v", err)
  8817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8818. return
  8819. }
  8820. if res2.Infcode != 0 {
  8821. c.ServeSuccessJSON(map[string]interface{}{
  8822. "failed_code": -10,
  8823. "msg": res2.ErrMsg,
  8824. })
  8825. return
  8826. } else {
  8827. order.IsUploadDiagnose = 1
  8828. order.IsUploadOrderInfo = 1
  8829. service.UpdateOrderTwo(order)
  8830. c.ServeSuccessJSON(map[string]interface{}{
  8831. "msg": "上传成功",
  8832. })
  8833. }
  8834. }
  8835. func (c *HisApiController) Get4207() {
  8836. admin_user_id, _ := c.GetInt64("admin_user_id")
  8837. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8838. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8839. order_id, _ := c.GetInt64("order_id")
  8840. order, _ := service.GetHisOrderByIDTwo(order_id)
  8841. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8842. var struct4207 models.Struct4207
  8843. struct4207.PageNum = "1"
  8844. struct4207.PageSize = "1000"
  8845. struct4207.FixmedinsCode = miConfig.Code
  8846. struct4207.FixmedinsMdtrtID = order.Number
  8847. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  8848. saveLog(result, requestLog, "4207", "查询")
  8849. var res2 ResultSix
  8850. var respJSON2 map[string]interface{}
  8851. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8854. return
  8855. }
  8856. userJSONBytes2, _ := json.Marshal(respJSON2)
  8857. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8858. utils.ErrorLog("解析失败:%v", err)
  8859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8860. return
  8861. }
  8862. if res2.Infcode != 0 {
  8863. c.ServeSuccessJSON(map[string]interface{}{
  8864. "failed_code": -10,
  8865. "msg": res2.ErrMsg,
  8866. })
  8867. return
  8868. } else {
  8869. c.ServeSuccessJSON(map[string]interface{}{
  8870. "msg": "查询成功",
  8871. })
  8872. }
  8873. }
  8874. func (c *HisApiController) Get4208() {
  8875. admin_user_id, _ := c.GetInt64("admin_user_id")
  8876. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8877. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8878. order_id, _ := c.GetInt64("order_id")
  8879. order, _ := service.GetHisOrderByIDTwo(order_id)
  8880. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8881. var struct4208 models.Struct4208
  8882. struct4208.PageNum = "1"
  8883. struct4208.PageSize = "1000"
  8884. struct4208.PsnCertType = "01"
  8885. struct4208.Certno = his.Certno
  8886. struct4208.MedType = order.MedType
  8887. struct4208.PsnName = his.Name
  8888. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  8889. saveLog(result, requestLog, "4208", "查询")
  8890. var res2 ResultSix
  8891. var respJSON2 map[string]interface{}
  8892. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8895. return
  8896. }
  8897. userJSONBytes2, _ := json.Marshal(respJSON2)
  8898. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8899. utils.ErrorLog("解析失败:%v", err)
  8900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8901. return
  8902. }
  8903. if res2.Infcode != 0 {
  8904. c.ServeSuccessJSON(map[string]interface{}{
  8905. "failed_code": -10,
  8906. "msg": res2.ErrMsg,
  8907. })
  8908. return
  8909. } else {
  8910. c.ServeSuccessJSON(map[string]interface{}{
  8911. "msg": "查询成功",
  8912. })
  8913. }
  8914. }
  8915. func (c *HisApiController) Get4209() {
  8916. admin_user_id, _ := c.GetInt64("admin_user_id")
  8917. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8918. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8919. order_id, _ := c.GetInt64("order_id")
  8920. order, _ := service.GetHisOrderByIDTwo(order_id)
  8921. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8922. var struct4209 models.Struct4209
  8923. struct4209.FixmedinsMdtrtID = order.Number
  8924. struct4209.FixmedinsCode = miConfig.Code
  8925. struct4209.PageSize = "1000"
  8926. struct4209.PageNum = "1"
  8927. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  8928. saveLog(result, requestLog, "4209", "查询")
  8929. var res2 ResultSix
  8930. var respJSON2 map[string]interface{}
  8931. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8934. return
  8935. }
  8936. userJSONBytes2, _ := json.Marshal(respJSON2)
  8937. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8938. utils.ErrorLog("解析失败:%v", err)
  8939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8940. return
  8941. }
  8942. if res2.Infcode != 0 {
  8943. c.ServeSuccessJSON(map[string]interface{}{
  8944. "failed_code": -10,
  8945. "msg": res2.ErrMsg,
  8946. })
  8947. return
  8948. } else {
  8949. c.ServeSuccessJSON(map[string]interface{}{
  8950. "msg": "查询成功",
  8951. })
  8952. }
  8953. }
  8954. type Result3101 struct {
  8955. Infcode string `json:"infcode"`
  8956. InfRefmsgid string `json:"inf_refmsgid"`
  8957. RefmsgTime string `json:"refmsg_time"`
  8958. RespondTime string `json:"respond_time"`
  8959. Enctype string `json:"enctype"`
  8960. Signtype string `json:"signtype"`
  8961. ErrMsg string `json:"err_msg"`
  8962. Output struct {
  8963. Result []struct {
  8964. JudgeResultDetailDtos []struct {
  8965. VolaItemType string `json:"vola_item_type"`
  8966. MdtrtID string `json:"mdtrt_id"`
  8967. JrdID string `json:"jrd_id"`
  8968. PatnID string `json:"patn_id"`
  8969. RxID string `json:"rx_id"`
  8970. VolaAmt interface{} `json:"vola_amt"`
  8971. } `json:"judge_result_detail_dtos"`
  8972. RuleID string `json:"rule_id"`
  8973. VolaEvid string `json:"vola_evid"`
  8974. MdtrtID string `json:"mdtrt_id"`
  8975. RuleName string `json:"rule_name"`
  8976. VolaAmtStas string `json:"vola_amt_stas"`
  8977. JrID string `json:"jr_id"`
  8978. PatnID string `json:"patn_id"`
  8979. SevDeg string `json:"sev_deg"`
  8980. VolaAmt float64 `json:"vola_amt"`
  8981. VolaBhvrType string `json:"vola_bhvr_type"`
  8982. VolaCont string `json:"vola_cont"`
  8983. } `json:"result"`
  8984. } `json:"output"`
  8985. }
  8986. type Resultgd3101 struct {
  8987. Infcode int64 `json:"infcode"`
  8988. InfRefmsgid string `json:"inf_refmsgid"`
  8989. RefmsgTime string `json:"refmsg_time"`
  8990. RespondTime string `json:"respond_time"`
  8991. Enctype string `json:"enctype"`
  8992. Signtype string `json:"signtype"`
  8993. ErrMsg string `json:"err_msg"`
  8994. Output struct {
  8995. Result []struct {
  8996. JudgeResultDetailDtos []struct {
  8997. VolaItemType string `json:"vola_item_type"`
  8998. MdtrtID string `json:"mdtrt_id"`
  8999. JrdID string `json:"jrd_id"`
  9000. PatnID string `json:"patn_id"`
  9001. RxID string `json:"rx_id"`
  9002. VolaAmt interface{} `json:"vola_amt"`
  9003. } `json:"judge_result_detail_dtos"`
  9004. RuleID string `json:"rule_id"`
  9005. VolaEvid string `json:"vola_evid"`
  9006. MdtrtID string `json:"mdtrt_id"`
  9007. RuleName string `json:"rule_name"`
  9008. VolaAmtStas string `json:"vola_amt_stas"`
  9009. JrID string `json:"jr_id"`
  9010. PatnID string `json:"patn_id"`
  9011. SevDeg string `json:"sev_deg"`
  9012. VolaAmt float64 `json:"vola_amt"`
  9013. VolaBhvrType string `json:"vola_bhvr_type"`
  9014. VolaCont string `json:"vola_cont"`
  9015. } `json:"result"`
  9016. } `json:"output"`
  9017. }
  9018. func (c *HisApiController) ReadEleToken() {
  9019. admin_user_id, _ := c.GetInt64("admin_user_id")
  9020. his_patient_id, _ := c.GetInt64("his_patient_id")
  9021. adminUser := c.GetAdminUserInfo()
  9022. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9023. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9024. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9025. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9026. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9027. if len(tokens) > 0 {
  9028. c.ServeSuccessJSON(map[string]interface{}{
  9029. "msg": "读取成功",
  9030. })
  9031. } else {
  9032. c.ServeSuccessJSON(map[string]interface{}{
  9033. "failed_code": -10,
  9034. "msg": "读取失败",
  9035. })
  9036. }
  9037. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9038. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9039. if len(tokens) > 0 {
  9040. c.ServeSuccessJSON(map[string]interface{}{
  9041. "msg": "读取成功",
  9042. })
  9043. } else {
  9044. c.ServeSuccessJSON(map[string]interface{}{
  9045. "failed_code": -10,
  9046. "msg": "读取失败",
  9047. })
  9048. }
  9049. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9050. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9051. if len(tokens) > 0 {
  9052. c.ServeSuccessJSON(map[string]interface{}{
  9053. "msg": "读取成功",
  9054. })
  9055. } else {
  9056. c.ServeSuccessJSON(map[string]interface{}{
  9057. "failed_code": -10,
  9058. "msg": "读取失败",
  9059. })
  9060. }
  9061. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9062. var api string
  9063. 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 +
  9064. "&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"
  9065. resp, requestErr := http.Get(api)
  9066. if requestErr != nil {
  9067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9068. }
  9069. body, ioErr := ioutil.ReadAll(resp.Body)
  9070. if ioErr != nil {
  9071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9073. }
  9074. var respJSON map[string]interface{}
  9075. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9078. return
  9079. }
  9080. var status string
  9081. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9082. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9083. var token string
  9084. var res ResultTwo //1101结果
  9085. var res10265 ResultTwo10265 //1101结果
  9086. if status == "0" { //读卡成功
  9087. var card_info string //卡信息
  9088. var busi_card_info string
  9089. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9090. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9091. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9092. fmt.Println(card_info)
  9093. fmt.Println(busi_card_info)
  9094. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9095. result, _ := json.Marshal(respJSON)
  9096. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9097. utils.ErrorLog("解析失败:%v", err)
  9098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9099. return
  9100. }
  9101. res.ErrMsg = res10265.ErrMsg
  9102. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9103. res.Infcode = infocode
  9104. res.Output = res10265.Output
  9105. res.InfRefmsgid = res10265.InfRefmsgid
  9106. if res.Infcode == 0 {
  9107. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9108. if err == gorm.ErrRecordNotFound {
  9109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9110. return
  9111. } else if err != nil {
  9112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9113. return
  9114. } else {
  9115. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9116. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9117. infoStr := string(Iinfos)
  9118. idetinfoStr := string(Idetinfos)
  9119. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9120. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9121. psn := &models.HisPsn{
  9122. PsnNo: res.Output.Baseinfo.PsnNo,
  9123. PatientId: patient.ID,
  9124. Certno: res.Output.Baseinfo.Certno,
  9125. Gend: res.Output.Baseinfo.Gend,
  9126. Naty: res.Output.Baseinfo.Naty,
  9127. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9128. PsnName: res.Output.Baseinfo.PsnName,
  9129. Age: float64(age),
  9130. Brdy: b,
  9131. Idetinfo: idetinfoStr,
  9132. Insuinfo: infoStr,
  9133. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9134. CardInfo: card_info,
  9135. VerifyNumber: token,
  9136. IdCardType: 4,
  9137. }
  9138. var rf []*ResultFive
  9139. json.Unmarshal([]byte(infoStr), &rf)
  9140. var insutypes []*ResultFive
  9141. var insutype string
  9142. var is390 int = 0
  9143. var is310 int = 0
  9144. for _, item := range rf {
  9145. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9146. insutypes = append(insutypes, item)
  9147. }
  9148. }
  9149. if len(insutypes) == 1 {
  9150. insutype = insutypes[0].Insutype
  9151. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9152. } else {
  9153. for _, i := range insutypes {
  9154. if i.Insutype == "390" {
  9155. is390 = 1
  9156. }
  9157. if i.Insutype == "310" {
  9158. is310 = 1
  9159. }
  9160. }
  9161. }
  9162. if is390 == 1 {
  9163. insutype = "390"
  9164. }
  9165. if is310 == 1 {
  9166. insutype = "310"
  9167. }
  9168. if len(insutypes) == 0 {
  9169. insutype = "310"
  9170. }
  9171. service.CreateHisPsn(psn)
  9172. c.ServeSuccessJSON(map[string]interface{}{
  9173. "patient": patient,
  9174. "number": token,
  9175. "insutype": insutype,
  9176. })
  9177. }
  9178. } else {
  9179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9180. return
  9181. }
  9182. } else { //读卡失败
  9183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9184. return
  9185. }
  9186. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9187. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9188. if len(errMsg) == 0 {
  9189. type ELeData struct {
  9190. Data struct {
  9191. IdNo string `json:"idNo"`
  9192. IdType string `json:"idType"`
  9193. UserName string `json:"userName"`
  9194. EcToken string `json:"ecToken"`
  9195. InsuOrg string `json:"insuOrg"`
  9196. Gender string `json:"gender"`
  9197. Birthday string `json:"birthday"`
  9198. Nationality string `json:"nationality"`
  9199. Email string `json:"email"`
  9200. Extra string `json:"extra"`
  9201. } `json:"data"`
  9202. Code int `json:"code"`
  9203. Message string `json:"message"`
  9204. }
  9205. var ele ELeData
  9206. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9207. if err != nil {
  9208. utils.ErrorLog("解析失败:%v", err)
  9209. }
  9210. token := ele.Data.EcToken
  9211. if len(token) > 0 {
  9212. psn := &models.HisPsn{
  9213. PsnNo: his.PsnNo,
  9214. Age: 0,
  9215. PatientId: his.PatientId,
  9216. Certno: his.Certno,
  9217. Brdy: his.Brdy,
  9218. Gend: his.Gend,
  9219. Naty: his.Naty,
  9220. PsnCertType: his.PsnCertType,
  9221. PsnName: his.PsnName,
  9222. Idetinfo: his.Idetinfo,
  9223. Insuinfo: his.Iinfo,
  9224. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9225. CardInfo: outPutInfo,
  9226. VerifyNumber: token,
  9227. }
  9228. service.CreateHisPsn(psn)
  9229. }
  9230. if len(token) > 0 {
  9231. c.ServeSuccessJSON(map[string]interface{}{
  9232. "msg": "读取成功",
  9233. })
  9234. } else {
  9235. c.ServeSuccessJSON(map[string]interface{}{
  9236. "failed_code": -10,
  9237. "msg": "读取失败",
  9238. })
  9239. }
  9240. }
  9241. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9242. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9243. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9244. type ELeData struct {
  9245. Data struct {
  9246. IdNo string `json:"idNo"`
  9247. IdType string `json:"idType"`
  9248. UserName string `json:"userName"`
  9249. EcToken string `json:"ecToken"`
  9250. InsuOrg string `json:"insuOrg"`
  9251. Gender string `json:"gender"`
  9252. Birthday string `json:"birthday"`
  9253. Nationality string `json:"nationality"`
  9254. Email string `json:"email"`
  9255. Extra string `json:"extra"`
  9256. } `json:"data"`
  9257. Code int `json:"code"`
  9258. Message string `json:"message"`
  9259. }
  9260. var ele ELeData
  9261. err := json.Unmarshal([]byte(result), &ele)
  9262. if err != nil {
  9263. utils.ErrorLog("解析失败:%v", err)
  9264. }
  9265. token := ele.Data.EcToken
  9266. token = Remove0000(token)
  9267. fmt.Println(ele.Data.UserName)
  9268. 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)
  9269. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9270. var res ResultTwo
  9271. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9272. utils.ErrorLog("解析失败:%v", err)
  9273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9274. return
  9275. }
  9276. if res.Infcode == 0 {
  9277. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9278. if err == gorm.ErrRecordNotFound {
  9279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9280. return
  9281. } else if err != nil {
  9282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9283. return
  9284. } else {
  9285. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9286. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9287. infoStr := string(Iinfos)
  9288. idetinfoStr := string(Idetinfos)
  9289. psn := &models.HisPsn{
  9290. PsnNo: res.Output.Baseinfo.PsnNo,
  9291. PatientId: patient.ID,
  9292. Certno: res.Output.Baseinfo.Certno,
  9293. Gend: res.Output.Baseinfo.Gend,
  9294. Naty: res.Output.Baseinfo.Naty,
  9295. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9296. PsnName: res.Output.Baseinfo.PsnName,
  9297. Idetinfo: idetinfoStr,
  9298. Insuinfo: infoStr,
  9299. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9300. CardInfo: "",
  9301. VerifyNumber: token,
  9302. }
  9303. service.CreateHisPsn(psn)
  9304. c.ServeSuccessJSON(map[string]interface{}{
  9305. "patient": patient,
  9306. "number": token,
  9307. })
  9308. }
  9309. } else {
  9310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9311. return
  9312. }
  9313. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9314. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9315. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9316. type ELeData struct {
  9317. Data struct {
  9318. IdNo string `json:"idNo"`
  9319. IdType string `json:"idType"`
  9320. UserName string `json:"userName"`
  9321. EcToken string `json:"ecToken"`
  9322. InsuOrg string `json:"insuOrg"`
  9323. Gender string `json:"gender"`
  9324. Birthday string `json:"birthday"`
  9325. Nationality string `json:"nationality"`
  9326. Email string `json:"email"`
  9327. Extra string `json:"extra"`
  9328. } `json:"data"`
  9329. Code int `json:"code"`
  9330. Message string `json:"message"`
  9331. }
  9332. var ele ELeData
  9333. err := json.Unmarshal([]byte(result), &ele)
  9334. if err != nil {
  9335. utils.ErrorLog("解析失败:%v", err)
  9336. }
  9337. token := ele.Data.EcToken
  9338. token = Remove0000(token)
  9339. fmt.Println(ele.Data.UserName)
  9340. 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)
  9341. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9342. var res ResultTwo
  9343. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9344. utils.ErrorLog("解析失败:%v", err)
  9345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9346. return
  9347. }
  9348. if res.Infcode == 0 {
  9349. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9350. if err == gorm.ErrRecordNotFound {
  9351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9352. return
  9353. } else if err != nil {
  9354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9355. return
  9356. } else {
  9357. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9358. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9359. infoStr := string(Iinfos)
  9360. idetinfoStr := string(Idetinfos)
  9361. psn := &models.HisPsn{
  9362. PsnNo: res.Output.Baseinfo.PsnNo,
  9363. PatientId: patient.ID,
  9364. Certno: res.Output.Baseinfo.Certno,
  9365. Gend: res.Output.Baseinfo.Gend,
  9366. Naty: res.Output.Baseinfo.Naty,
  9367. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9368. PsnName: res.Output.Baseinfo.PsnName,
  9369. Idetinfo: idetinfoStr,
  9370. Insuinfo: infoStr,
  9371. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9372. CardInfo: "",
  9373. VerifyNumber: token,
  9374. }
  9375. service.CreateHisPsn(psn)
  9376. c.ServeSuccessJSON(map[string]interface{}{
  9377. "patient": patient,
  9378. "number": token,
  9379. })
  9380. }
  9381. } else {
  9382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9383. return
  9384. }
  9385. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9386. //if initFlag == 0 {
  9387. //c.TestGetJiangXiBasBaseInit()
  9388. //}
  9389. //if initEleFlag == 0 {
  9390. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9391. //}
  9392. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9393. utils.ErrorLog("解析失败:%v", json_result)
  9394. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9395. type ELeData struct {
  9396. Data struct {
  9397. IdNo string `json:"idNo"`
  9398. IdType string `json:"idType"`
  9399. UserName string `json:"userName"`
  9400. EcToken string `json:"ecToken"`
  9401. InsuOrg string `json:"insuOrg"`
  9402. Gender string `json:"gender"`
  9403. Birthday string `json:"birthday"`
  9404. Nationality string `json:"nationality"`
  9405. Email string `json:"email"`
  9406. Extra string `json:"extra"`
  9407. } `json:"data"`
  9408. Code int `json:"code"`
  9409. Message string `json:"message"`
  9410. }
  9411. var ele ELeData
  9412. err := json.Unmarshal([]byte(json_result), &ele)
  9413. if err != nil {
  9414. utils.ErrorLog("解析失败:%v", err)
  9415. }
  9416. token := ele.Data.EcToken
  9417. token = Remove0000(token)
  9418. //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)
  9419. 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)
  9420. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9421. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9422. var res ResultTwo
  9423. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9424. utils.ErrorLog("解析失败:%v", err)
  9425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9426. return
  9427. }
  9428. if res.Infcode == 0 {
  9429. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9430. if err == gorm.ErrRecordNotFound {
  9431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9432. return
  9433. } else if err != nil {
  9434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9435. return
  9436. } else {
  9437. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9438. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9439. infoStr := string(Iinfos)
  9440. idetinfoStr := string(Idetinfos)
  9441. psn := &models.HisPsn{
  9442. PsnNo: res.Output.Baseinfo.PsnNo,
  9443. PatientId: patient.ID,
  9444. Certno: res.Output.Baseinfo.Certno,
  9445. Gend: res.Output.Baseinfo.Gend,
  9446. Naty: res.Output.Baseinfo.Naty,
  9447. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9448. PsnName: res.Output.Baseinfo.PsnName,
  9449. Idetinfo: idetinfoStr,
  9450. Insuinfo: infoStr,
  9451. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9452. CardInfo: "",
  9453. VerifyNumber: token,
  9454. InsuplcAdmdvs: ele.Data.InsuOrg,
  9455. }
  9456. service.CreateHisPsn(psn)
  9457. c.ServeSuccessJSON(map[string]interface{}{
  9458. "patient": patient,
  9459. "number": token,
  9460. })
  9461. }
  9462. } else {
  9463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9464. return
  9465. }
  9466. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9467. res := c.GetoleInfo()
  9468. if res.Infcode == 0 {
  9469. var result string
  9470. if res.Output.MdtrtCertType == "01" {
  9471. 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)
  9472. } else if res.Output.MdtrtCertType == "02" {
  9473. 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)
  9474. } else if res.Output.MdtrtCertType == "03" {
  9475. 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)
  9476. }
  9477. var dat map[string]interface{}
  9478. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9479. fmt.Println(dat)
  9480. } else {
  9481. fmt.Println(err)
  9482. }
  9483. userJSONBytes, _ := json.Marshal(dat)
  9484. var res2 ResultTwo
  9485. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9486. utils.ErrorLog("解析失败:%v", err)
  9487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9488. return
  9489. }
  9490. if res2.Infcode == 0 {
  9491. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9492. if err == gorm.ErrRecordNotFound {
  9493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9494. return
  9495. } else if err != nil {
  9496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9497. return
  9498. } else {
  9499. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9500. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9501. infoStr := string(Iinfos)
  9502. idetinfoStr := string(Idetinfos)
  9503. var rf []*ResultFive
  9504. json.Unmarshal([]byte(infoStr), &rf)
  9505. var insutypes []*ResultFive
  9506. var insutype string
  9507. var is390 int = 0
  9508. var is310 int = 0
  9509. //var insuplc_admdvs string
  9510. for _, item := range rf {
  9511. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9512. insutypes = append(insutypes, item)
  9513. }
  9514. }
  9515. if len(insutypes) == 1 {
  9516. insutype = insutypes[0].Insutype
  9517. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9518. } else {
  9519. for _, i := range insutypes {
  9520. if i.Insutype == "390" {
  9521. is390 = 1
  9522. }
  9523. if i.Insutype == "310" {
  9524. is310 = 1
  9525. }
  9526. }
  9527. }
  9528. if is390 == 1 {
  9529. insutype = "390"
  9530. }
  9531. if is310 == 1 {
  9532. insutype = "310"
  9533. }
  9534. if len(insutypes) == 0 {
  9535. insutype = "310"
  9536. }
  9537. psn := &models.HisPsn{
  9538. PsnNo: res2.Output.Baseinfo.PsnNo,
  9539. PatientId: patient.ID,
  9540. Certno: res2.Output.Baseinfo.Certno,
  9541. Gend: res2.Output.Baseinfo.Gend,
  9542. Naty: res2.Output.Baseinfo.Naty,
  9543. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9544. PsnName: res2.Output.Baseinfo.PsnName,
  9545. Idetinfo: idetinfoStr,
  9546. Insuinfo: infoStr,
  9547. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9548. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9549. VerifyNumber: res.Output.EcToken,
  9550. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9551. }
  9552. service.CreateHisPsn(psn)
  9553. c.ServeSuccessJSON(map[string]interface{}{
  9554. "patient": patient,
  9555. "number": res.Output.CardNo,
  9556. "insutype": insutype,
  9557. })
  9558. }
  9559. } else {
  9560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9561. return
  9562. }
  9563. } else {
  9564. c.ServeSuccessJSON(map[string]interface{}{
  9565. "failed_code": -10,
  9566. "msg": res.ErrMsg,
  9567. })
  9568. }
  9569. } else {
  9570. //if initFlag == 0 {
  9571. // c.TestGetBasBaseInit()
  9572. //}
  9573. //token := c.GetEleBaseInfo()
  9574. //token = Remove0000(token)
  9575. type ELeData struct {
  9576. Code string `json:"code"`
  9577. Data struct {
  9578. Aac002 string `json:"aac002"`
  9579. Aaz500 string `json:"aaz500"`
  9580. ActCardNo string `json:"actCardNo"`
  9581. Bab520 string `json:"bab520"`
  9582. Bkz543 string `json:"bkz543"`
  9583. BusinessType string `json:"businessType"`
  9584. CertfCodg string `json:"certfCodg"`
  9585. EcIndexNo string `json:"ecIndexNo"`
  9586. EcToken string `json:"ecToken"`
  9587. ID0000 string `json:"id0000"`
  9588. IDNo string `json:"idNo"`
  9589. IDType string `json:"idType"`
  9590. Idcode string `json:"idcode"`
  9591. IdentityToken string `json:"identity_token"`
  9592. InsuOrg string `json:"insuOrg"`
  9593. OfficeID string `json:"officeId"`
  9594. OfficeName string `json:"officeName"`
  9595. OperatorID string `json:"operatorId"`
  9596. OperatorName string `json:"operatorName"`
  9597. OrgID string `json:"orgId"`
  9598. UserName string `json:"userName"`
  9599. } `json:"data"`
  9600. Infno interface{} `json:"infno"`
  9601. Message string `json:"message"`
  9602. OrgID string `json:"orgId"`
  9603. TransType string `json:"transType"`
  9604. }
  9605. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9606. fmt.Println(result)
  9607. outPutInfo := Remove0000(result)
  9608. fmt.Println(outPutInfo)
  9609. var ele ELeData
  9610. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9611. if err != nil {
  9612. utils.ErrorLog("解析失败:%v", err)
  9613. }
  9614. token := ele.Data.EcToken
  9615. var result2 string
  9616. var requestLog2 string
  9617. if len(token) > 0 {
  9618. if strings.Contains(ele.Data.IDNo, "HKG") {
  9619. 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)
  9620. } else {
  9621. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9622. }
  9623. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9624. var res ResultTwo
  9625. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9626. utils.ErrorLog("解析失败:%v", err)
  9627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9628. return
  9629. }
  9630. if res.Infcode == 0 {
  9631. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9632. if err == gorm.ErrRecordNotFound {
  9633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9634. return
  9635. } else if err != nil {
  9636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9637. return
  9638. } else {
  9639. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9640. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9641. infoStr := string(Iinfos)
  9642. idetinfoStr := string(Idetinfos)
  9643. psn := &models.HisPsn{
  9644. PsnNo: res.Output.Baseinfo.PsnNo,
  9645. PatientId: patient.ID,
  9646. Certno: res.Output.Baseinfo.Certno,
  9647. Gend: res.Output.Baseinfo.Gend,
  9648. Naty: res.Output.Baseinfo.Naty,
  9649. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9650. PsnName: res.Output.Baseinfo.PsnName,
  9651. Idetinfo: idetinfoStr,
  9652. Insuinfo: infoStr,
  9653. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9654. CardInfo: "",
  9655. VerifyNumber: token,
  9656. }
  9657. service.CreateHisPsn(psn)
  9658. c.ServeSuccessJSON(map[string]interface{}{
  9659. "msg": "读取成功",
  9660. })
  9661. }
  9662. } else {
  9663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9664. return
  9665. }
  9666. } else {
  9667. c.ServeSuccessJSON(map[string]interface{}{
  9668. "failed_code": -10,
  9669. "msg": "读取失败",
  9670. })
  9671. }
  9672. }
  9673. }
  9674. func (c *HisApiController) ReadEleFace() {
  9675. admin_user_id, _ := c.GetInt64("admin_user_id")
  9676. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9677. adminUser := c.GetAdminUserInfo()
  9678. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9679. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9680. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9681. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9682. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9683. if len(tokens) > 0 {
  9684. c.ServeSuccessJSON(map[string]interface{}{
  9685. "msg": "读取成功",
  9686. })
  9687. } else {
  9688. c.ServeSuccessJSON(map[string]interface{}{
  9689. "failed_code": -10,
  9690. "msg": "读取失败",
  9691. })
  9692. }
  9693. }
  9694. }
  9695. func (c *HisApiController) Get9001() {
  9696. adminUser := c.GetAdminUserInfo()
  9697. admin_user_id, _ := c.GetInt64("admin_user_id")
  9698. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9699. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9700. if miConfig.MdtrtareaAdmvs == "350500" {
  9701. service.GetFjAuthorizationInfo(miConfig.Code)
  9702. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9703. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9704. var dat map[string]interface{}
  9705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9706. fmt.Println(dat)
  9707. } else {
  9708. fmt.Println(err)
  9709. }
  9710. userJSONBytes, _ := json.Marshal(dat)
  9711. var res models.Result9001
  9712. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9713. utils.ErrorLog("解析失败:%v", err)
  9714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9715. return
  9716. }
  9717. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9718. fmt.Println(miConfig.SecretKey)
  9719. var res models.Result9001Two
  9720. 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 +
  9721. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9722. resp, requestErr := http.Get(api)
  9723. if requestErr != nil {
  9724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9725. return
  9726. }
  9727. body, ioErr := ioutil.ReadAll(resp.Body)
  9728. if ioErr != nil {
  9729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9731. return
  9732. }
  9733. var respJSON map[string]interface{}
  9734. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9737. return
  9738. }
  9739. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9740. if status == "0" {
  9741. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9742. c.ServeSuccessJSON(map[string]interface{}{
  9743. "failed_code": -10,
  9744. "msg": err_msg,
  9745. })
  9746. return
  9747. }
  9748. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9749. result, _ := json.Marshal(respJSON)
  9750. fmt.Println("log")
  9751. fmt.Println(string(result))
  9752. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9753. utils.ErrorLog("解析失败:%v", err)
  9754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9755. return
  9756. }
  9757. if res.Infcode == 0 {
  9758. sign := models.HisSignIn{
  9759. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9760. SignNo: res.Output.Signinoutb.SignNo,
  9761. SignTime: "",
  9762. Ctime: time.Now().Unix(),
  9763. Mtime: time.Now().Unix(),
  9764. Status: 1,
  9765. InputLog: "",
  9766. OutputLog: "",
  9767. FixmedinsCode: miConfig.Code,
  9768. }
  9769. err := service.CreateSignIn(&sign)
  9770. if err == nil {
  9771. c.ServeSuccessJSON(map[string]interface{}{
  9772. "msg": "签到成功",
  9773. })
  9774. }
  9775. } else {
  9776. c.ServeSuccessJSON(map[string]interface{}{
  9777. "failed_code": -10,
  9778. "msg": res.ErrMsg,
  9779. })
  9780. return
  9781. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9782. //return
  9783. }
  9784. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9785. fmt.Println(miConfig.SecretKey)
  9786. var res models.Result9001Two
  9787. 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 +
  9788. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9789. resp, requestErr := http.Get(api)
  9790. if requestErr != nil {
  9791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9792. return
  9793. }
  9794. body, ioErr := ioutil.ReadAll(resp.Body)
  9795. if ioErr != nil {
  9796. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9798. return
  9799. }
  9800. var respJSON map[string]interface{}
  9801. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9804. return
  9805. }
  9806. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9807. if status == "0" {
  9808. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9809. c.ServeSuccessJSON(map[string]interface{}{
  9810. "failed_code": -10,
  9811. "msg": err_msg,
  9812. })
  9813. return
  9814. }
  9815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9816. result, _ := json.Marshal(respJSON)
  9817. fmt.Println("log")
  9818. fmt.Println(string(result))
  9819. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9820. utils.ErrorLog("解析失败:%v", err)
  9821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9822. return
  9823. }
  9824. if res.Infcode == 0 {
  9825. sign := models.HisSignIn{
  9826. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9827. SignNo: res.Output.Signinoutb.SignNo,
  9828. SignTime: "",
  9829. Ctime: time.Now().Unix(),
  9830. Mtime: time.Now().Unix(),
  9831. Status: 1,
  9832. InputLog: "",
  9833. OutputLog: "",
  9834. FixmedinsCode: miConfig.Code,
  9835. }
  9836. err := service.CreateSignIn(&sign)
  9837. if err == nil {
  9838. c.ServeSuccessJSON(map[string]interface{}{
  9839. "msg": "签到成功",
  9840. })
  9841. }
  9842. } else {
  9843. c.ServeSuccessJSON(map[string]interface{}{
  9844. "failed_code": -10,
  9845. "msg": res.ErrMsg,
  9846. })
  9847. return
  9848. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9849. //return
  9850. }
  9851. } else {
  9852. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  9853. var dat map[string]interface{}
  9854. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9855. fmt.Println(dat)
  9856. } else {
  9857. fmt.Println(err)
  9858. }
  9859. userJSONBytes, _ := json.Marshal(dat)
  9860. var res models.Result9001
  9861. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9862. utils.ErrorLog("解析失败:%v", err)
  9863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9864. return
  9865. }
  9866. if res.Infcode == 0 {
  9867. sign := models.HisSignIn{
  9868. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9869. SignNo: res.Output.Signinoutb.SignNo,
  9870. SignTime: res.Output.Signinoutb.SignTime,
  9871. Ctime: time.Now().Unix(),
  9872. Mtime: time.Now().Unix(),
  9873. Status: 1,
  9874. InputLog: "",
  9875. OutputLog: "",
  9876. FixmedinsCode: miConfig.Code,
  9877. }
  9878. err := service.CreateSignIn(&sign)
  9879. if err == nil {
  9880. c.ServeSuccessJSON(map[string]interface{}{
  9881. "msg": "签到成功",
  9882. })
  9883. }
  9884. }
  9885. }
  9886. }
  9887. 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) {
  9888. var res Result3101
  9889. adminUser := c.GetAdminUserInfo()
  9890. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9891. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9892. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9893. //record_time := c.GetString("record_time")
  9894. //trig_scen := c.GetString("trig_scen")
  9895. timeLayout := "2006-01-02"
  9896. loc, _ := time.LoadLocation("Local")
  9897. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9898. if err != nil {
  9899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9900. return res
  9901. }
  9902. recordDateTime := theTime.Unix()
  9903. var patientPrescription models.HisPrescriptionInfo
  9904. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9905. //if patientPrescription.ID == 0 {
  9906. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9907. //}
  9908. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9909. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9910. //
  9911. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9912. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9913. var pp models.PublicParams
  9914. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9915. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9916. pp.FixmedinsName = miConfig.OrgName
  9917. pp.FixmedinsCode = miConfig.Code
  9918. pp.RequestUrl = miConfig.Url
  9919. pp.Cainfo = miConfig.Cainfo
  9920. pp.SecretKey = miConfig.SecretKey
  9921. pp.AccessKey = miConfig.AccessKey
  9922. pp.OpterName = roles.UserName
  9923. var config []*models.HisXtDiagnoseConfig
  9924. for _, item := range diagnosis_ids {
  9925. id, _ := strconv.ParseInt(item, 10, 64)
  9926. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9927. config = append(config, &diagnosisConfig)
  9928. }
  9929. var pd models.PatientDtos
  9930. pd.PatnID = his.PsnNo
  9931. pd.PatnName = his.Name
  9932. pd.Gend = his.Gend
  9933. pd.Brdy = his.Brdy
  9934. pd.Poolarea = miConfig.MdtrtareaAdmvs
  9935. pd.CurrMdtrtID = his.Number
  9936. var fed models.FsiEncounterDtos
  9937. fed.MdtrtID = his.Number
  9938. fed.MedinsID = miConfig.Code
  9939. fed.MedinsName = miConfig.OrgName
  9940. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9941. fed.MedMdtrtType = "1"
  9942. fed.MedinsType = "1"
  9943. fed.MedinsLv = "11"
  9944. tm := time.Unix(his.RecordDate, 0)
  9945. s_tm := tm.Format("2006-01-02 15:04:05")
  9946. fed.AdmDate = s_tm
  9947. fed.DscgDate = s_tm
  9948. fed.DscgMainDiseCodg = config[0].CountryCode
  9949. fed.DscgMainDiseName = config[0].CountryContentName
  9950. //诊断信息
  9951. var fdds []*models.FsiDiagnoseDtos
  9952. for index, item := range config {
  9953. if index == 0 {
  9954. var fdd models.FsiDiagnoseDtos
  9955. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9956. fdd.InoutDiseType = "1"
  9957. fdd.MaindiseFlag = "1"
  9958. fdd.DiseDate = s_tm
  9959. fdd.DiasSrtNo = "1"
  9960. fdd.DiseName = item.CountryContentName
  9961. fdd.DiseCodg = item.CountryCode
  9962. fdds = append(fdds, &fdd)
  9963. } else {
  9964. var fdd models.FsiDiagnoseDtos
  9965. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9966. fdd.InoutDiseType = "1"
  9967. fdd.MaindiseFlag = "1"
  9968. fdd.DiseDate = s_tm
  9969. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9970. fdd.DiseName = item.CountryContentName
  9971. fdd.DiseCodg = item.CountryCode
  9972. fdds = append(fdds, &fdd)
  9973. }
  9974. }
  9975. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9976. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  9977. fed.AdmDeptName = de.Name
  9978. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  9979. fed.DscgDeptName = de.Name
  9980. fed.MedMdtrtType = "1"
  9981. fed.MedType = "11"
  9982. //if his.Insutype == "390" {
  9983. // fed.MedType = "1402"
  9984. //} else {
  9985. // fed.MedType = "9933"
  9986. //}
  9987. var orders []*models.FsiOrderDtos
  9988. if trig_scen == "2" {
  9989. //处方医嘱信息
  9990. for _, item := range prescriptions {
  9991. for _, subItem := range item.HisDoctorAdviceInfo {
  9992. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9993. var order models.FsiOrderDtos
  9994. order.RxID = strconv.FormatInt(item.ID, 10)
  9995. order.Rxno = strconv.FormatInt(item.ID, 10)
  9996. order.LongDrordFlag = "0"
  9997. order.HilistType = "1"
  9998. order.ChrgType = "1"
  9999. order.DrordBhvr = "-"
  10000. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10001. order.HosplistName = subItem.BaseDrugLib.DrugName
  10002. order.HilistLv = "1"
  10003. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10004. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10005. order.HosplistName = subItem.BaseDrugLib.DrugName
  10006. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10007. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10008. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10009. order.OwnpayAmt = ""
  10010. order.SelfpayAmt = ""
  10011. order.Spec = ""
  10012. order.SpecUnt = ""
  10013. order.DrordBegnDate = s_tm
  10014. order.DrordStopDate = ""
  10015. order.DrordDrCodg = doctor_info.DoctorNumber
  10016. order.DrordDeptName = department.Name
  10017. order.DrordDeptCodg = department.Number
  10018. order.DrordDrName = doctor_info.UserName
  10019. order.DrordDrProfttl = "234"
  10020. order.CurrDrordFlag = "1"
  10021. orders = append(orders, &order)
  10022. }
  10023. }
  10024. for _, subItem := range item.HisPrescriptionProject {
  10025. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10026. var order models.FsiOrderDtos
  10027. order.RxID = strconv.FormatInt(item.ID, 10)
  10028. order.Rxno = strconv.FormatInt(item.ID, 10)
  10029. order.LongDrordFlag = "0"
  10030. order.HilistType = "1"
  10031. order.ChrgType = "1"
  10032. order.DrordBhvr = "-"
  10033. order.HilistCode = subItem.HisProject.MedicalCode
  10034. order.HosplistName = subItem.HisProject.ProjectName
  10035. order.HilistLv = "1"
  10036. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10037. order.HosplistCode = subItem.HisProject.MedicalCode
  10038. order.HosplistName = subItem.HisProject.ProjectName
  10039. order.Cnt = subItem.Count
  10040. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10041. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10042. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10043. order.OwnpayAmt = ""
  10044. order.SelfpayAmt = ""
  10045. order.Spec = ""
  10046. order.SpecUnt = ""
  10047. order.DrordBegnDate = s_tm
  10048. order.DrordStopDate = ""
  10049. order.DrordDrCodg = doctor_info.DoctorNumber
  10050. order.DrordDeptName = department.Name
  10051. order.DrordDeptCodg = department.Number
  10052. order.DrordDrName = doctor_info.UserName
  10053. order.DrordDrProfttl = "234"
  10054. order.CurrDrordFlag = "1"
  10055. orders = append(orders, &order)
  10056. }
  10057. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10058. var order models.FsiOrderDtos
  10059. order.RxID = strconv.FormatInt(item.ID, 10)
  10060. order.Rxno = strconv.FormatInt(item.ID, 10)
  10061. order.LongDrordFlag = "0"
  10062. order.HilistType = "1"
  10063. order.ChrgType = "1"
  10064. order.DrordBhvr = "-"
  10065. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10066. order.HosplistName = subItem.GoodInfo.GoodName
  10067. order.HilistLv = "1"
  10068. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10069. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10070. order.HosplistName = subItem.GoodInfo.GoodName
  10071. order.Cnt = subItem.Count
  10072. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10073. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10074. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10075. order.OwnpayAmt = ""
  10076. order.SelfpayAmt = ""
  10077. order.Spec = ""
  10078. order.SpecUnt = ""
  10079. order.DrordBegnDate = s_tm
  10080. order.DrordStopDate = ""
  10081. order.DrordDrCodg = doctor_info.DoctorNumber
  10082. order.DrordDeptName = department.Name
  10083. order.DrordDeptCodg = department.Number
  10084. order.DrordDrName = doctor_info.UserName
  10085. order.DrordDrProfttl = "234"
  10086. order.CurrDrordFlag = "1"
  10087. orders = append(orders, &order)
  10088. }
  10089. }
  10090. }
  10091. //处方医嘱信息
  10092. }
  10093. fed.MatnStas = "0"
  10094. fed.MedfeeSumamt = "0"
  10095. fed.OwnpayAmt = "0"
  10096. fed.SelfpayAmt = "0"
  10097. fed.AcctPayamt = "0"
  10098. fed.MaAmt = "0"
  10099. fed.HifpPayamt = "0"
  10100. fed.SetlTotlnum = "1"
  10101. fed.Insutype = his.Insutype
  10102. fed.ReimFlag = "0"
  10103. fed.OutSetlFlag = "0"
  10104. var fopd []*models.FsiOperationDtosData
  10105. data := make(map[string]interface{})
  10106. data["fed"] = fed
  10107. data["fdd"] = fdds
  10108. data["fod"] = orders
  10109. data["pd"] = pd
  10110. data["pp"] = pp
  10111. data["fopd"] = fopd
  10112. data["trig_scen"] = trig_scen
  10113. fmt.Println(data)
  10114. fmt.Println(fed)
  10115. fmt.Println(fdds)
  10116. fmt.Println(orders)
  10117. fmt.Println(pd)
  10118. fmt.Println(pp)
  10119. fmt.Println(fopd)
  10120. client := &http.Client{}
  10121. bytesData, _ := json.Marshal(data)
  10122. var req *http.Request
  10123. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10124. if miConfig.MdtrtareaAdmvs == "320921" {
  10125. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10126. } else {
  10127. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10128. }
  10129. resp, _ := client.Do(req)
  10130. defer resp.Body.Close()
  10131. body, ioErr := ioutil.ReadAll(resp.Body)
  10132. if ioErr != nil {
  10133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10135. return res
  10136. }
  10137. var respJSON map[string]interface{}
  10138. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10141. return res
  10142. }
  10143. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10144. fmt.Println(respJSON)
  10145. result, _ := json.Marshal(respJSON)
  10146. fmt.Println(result)
  10147. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10148. utils.ErrorLog("解析失败:%v", err)
  10149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10150. return res
  10151. }
  10152. return res
  10153. } else {
  10154. //if miConfig.MdtrtareaAdmvs == "441202" {
  10155. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10156. saveLog(output, input, "3101", "事前")
  10157. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10158. utils.ErrorLog("解析失败:%v", err)
  10159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10160. return
  10161. }
  10162. return res
  10163. //}
  10164. }
  10165. }
  10166. 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) {
  10167. adminUser := c.GetAdminUserInfo()
  10168. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10169. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10170. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10171. //record_time := c.GetString("record_time")
  10172. //trig_scen := c.GetString("trig_scen")
  10173. timeLayout := "2006-01-02"
  10174. loc, _ := time.LoadLocation("Local")
  10175. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10176. if err != nil {
  10177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10178. return res
  10179. }
  10180. recordDateTime := theTime.Unix()
  10181. var patientPrescription models.HisPrescriptionInfo
  10182. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10183. if patientPrescription.ID == 0 {
  10184. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10185. }
  10186. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10187. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10188. //
  10189. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10190. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10191. var pp models.PublicParams
  10192. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10193. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10194. pp.FixmedinsName = miConfig.OrgName
  10195. pp.FixmedinsCode = miConfig.Code
  10196. pp.RequestUrl = miConfig.Url
  10197. pp.Cainfo = miConfig.Cainfo
  10198. pp.SecretKey = miConfig.SecretKey
  10199. pp.AccessKey = miConfig.AccessKey
  10200. pp.OpterName = roles.UserName
  10201. var config []*models.HisXtDiagnoseConfig
  10202. for _, item := range diagnosis_ids {
  10203. id, _ := strconv.ParseInt(item, 10, 64)
  10204. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10205. config = append(config, &diagnosisConfig)
  10206. }
  10207. var pd models.PatientDtos
  10208. pd.PatnID = his.PsnNo
  10209. pd.PatnName = his.Name
  10210. pd.Gend = his.Gend
  10211. pd.Brdy = his.Brdy
  10212. pd.Poolarea = his.InsuplcAdmdvs
  10213. pd.CurrMdtrtID = his.Number
  10214. var fed models.FsiEncounterDtos
  10215. fed.MdtrtID = his.Number
  10216. fed.MedinsID = miConfig.Code
  10217. fed.MedinsName = miConfig.OrgName
  10218. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10219. fed.MedMdtrtType = "1"
  10220. fed.MedinsType = "1"
  10221. fed.MedinsLv = "11"
  10222. tm := time.Unix(his.RecordDate, 0)
  10223. s_tm := tm.Format("2006-01-02 15:04:05")
  10224. fed.AdmDate = s_tm
  10225. fed.DscgDate = s_tm
  10226. fed.DscgMainDiseCodg = config[0].CountryCode
  10227. fed.DscgMainDiseName = config[0].CountryContentName
  10228. //诊断信息
  10229. var fdds []*models.FsiDiagnoseDtos
  10230. for index, item := range config {
  10231. if index == 0 {
  10232. var fdd models.FsiDiagnoseDtos
  10233. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10234. fdd.InoutDiseType = "1"
  10235. fdd.MaindiseFlag = "1"
  10236. fdd.DiseDate = s_tm
  10237. fdd.DiasSrtNo = "1"
  10238. fdd.DiseName = item.CountryContentName
  10239. fdd.DiseCodg = item.CountryCode
  10240. fdds = append(fdds, &fdd)
  10241. } else {
  10242. var fdd models.FsiDiagnoseDtos
  10243. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10244. fdd.InoutDiseType = "1"
  10245. fdd.MaindiseFlag = "1"
  10246. fdd.DiseDate = s_tm
  10247. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10248. fdd.DiseName = item.CountryContentName
  10249. fdd.DiseCodg = item.CountryCode
  10250. fdds = append(fdds, &fdd)
  10251. }
  10252. }
  10253. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10254. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10255. fed.AdmDeptName = department.Name
  10256. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10257. fed.DscgDeptName = department.Name
  10258. fed.MedMdtrtType = "1"
  10259. fed.MedType = "11"
  10260. //if his.Insutype == "390" {
  10261. // fed.MedType = "1402"
  10262. //} else {
  10263. // fed.MedType = "9933"
  10264. //}
  10265. var orders []*models.FsiOrderDtos
  10266. if trig_scen == "2" {
  10267. //处方医嘱信息
  10268. for _, item := range prescriptions {
  10269. for _, subItem := range item.HisDoctorAdviceInfo {
  10270. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10271. var order models.FsiOrderDtos
  10272. order.RxID = strconv.FormatInt(item.ID, 10)
  10273. order.Rxno = strconv.FormatInt(item.ID, 10)
  10274. order.LongDrordFlag = "0"
  10275. order.HilistType = "1"
  10276. order.ChrgType = "1"
  10277. order.DrordBhvr = "-"
  10278. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10279. order.HosplistName = subItem.BaseDrugLib.DrugName
  10280. order.HilistLv = "1"
  10281. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10282. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10283. order.HosplistName = subItem.BaseDrugLib.DrugName
  10284. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10285. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10286. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10287. order.OwnpayAmt = ""
  10288. order.SelfpayAmt = ""
  10289. order.Spec = ""
  10290. order.SpecUnt = ""
  10291. order.DrordBegnDate = s_tm
  10292. order.DrordStopDate = ""
  10293. order.DrordDrCodg = doctor_info.DoctorNumber
  10294. order.DrordDeptName = department.Name
  10295. order.DrordDeptCodg = department.Number
  10296. order.DrordDrName = doctor_info.UserName
  10297. order.DrordDrProfttl = "234"
  10298. order.CurrDrordFlag = "1"
  10299. orders = append(orders, &order)
  10300. }
  10301. }
  10302. for _, subItem := range item.HisPrescriptionProject {
  10303. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10304. var order models.FsiOrderDtos
  10305. order.RxID = strconv.FormatInt(item.ID, 10)
  10306. order.Rxno = strconv.FormatInt(item.ID, 10)
  10307. order.LongDrordFlag = "0"
  10308. order.HilistType = "1"
  10309. order.ChrgType = "1"
  10310. order.DrordBhvr = "-"
  10311. order.HilistCode = subItem.HisProject.MedicalCode
  10312. order.HosplistName = subItem.HisProject.ProjectName
  10313. order.HilistLv = "1"
  10314. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10315. order.HosplistCode = subItem.HisProject.MedicalCode
  10316. order.HosplistName = subItem.HisProject.ProjectName
  10317. order.Cnt = subItem.Count
  10318. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10319. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10320. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10321. order.OwnpayAmt = ""
  10322. order.SelfpayAmt = ""
  10323. order.Spec = ""
  10324. order.SpecUnt = ""
  10325. order.DrordBegnDate = s_tm
  10326. order.DrordStopDate = ""
  10327. order.DrordDrCodg = doctor_info.DoctorNumber
  10328. order.DrordDeptName = department.Name
  10329. order.DrordDeptCodg = department.Number
  10330. order.DrordDrName = doctor_info.UserName
  10331. order.DrordDrProfttl = "234"
  10332. order.CurrDrordFlag = "1"
  10333. orders = append(orders, &order)
  10334. }
  10335. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10336. var order models.FsiOrderDtos
  10337. order.RxID = strconv.FormatInt(item.ID, 10)
  10338. order.Rxno = strconv.FormatInt(item.ID, 10)
  10339. order.LongDrordFlag = "0"
  10340. order.HilistType = "1"
  10341. order.ChrgType = "1"
  10342. order.DrordBhvr = "-"
  10343. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10344. order.HosplistName = subItem.GoodInfo.GoodName
  10345. order.HilistLv = "1"
  10346. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10347. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10348. order.HosplistName = subItem.GoodInfo.GoodName
  10349. order.Cnt = subItem.Count
  10350. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10351. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10352. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10353. order.OwnpayAmt = ""
  10354. order.SelfpayAmt = ""
  10355. order.Spec = ""
  10356. order.SpecUnt = ""
  10357. order.DrordBegnDate = s_tm
  10358. order.DrordStopDate = ""
  10359. order.DrordDrCodg = doctor_info.DoctorNumber
  10360. order.DrordDeptName = department.Name
  10361. order.DrordDeptCodg = department.Number
  10362. order.DrordDrName = doctor_info.UserName
  10363. order.DrordDrProfttl = "234"
  10364. order.CurrDrordFlag = "1"
  10365. orders = append(orders, &order)
  10366. }
  10367. }
  10368. }
  10369. //处方医嘱信息
  10370. }
  10371. fed.MatnStas = "0"
  10372. fed.MedfeeSumamt = "0"
  10373. fed.OwnpayAmt = "0"
  10374. fed.SelfpayAmt = "0"
  10375. fed.AcctPayamt = "0"
  10376. fed.MaAmt = "0"
  10377. fed.HifpPayamt = "0"
  10378. fed.SetlTotlnum = "1"
  10379. fed.Insutype = his.Insutype
  10380. fed.ReimFlag = "0"
  10381. fed.OutSetlFlag = "0"
  10382. var fopd []*models.FsiOperationDtosData
  10383. data := make(map[string]interface{})
  10384. data["fed"] = fed
  10385. data["fdd"] = fdds
  10386. data["fod"] = orders
  10387. data["pd"] = pd
  10388. data["pp"] = pp
  10389. data["fopd"] = fopd
  10390. data["trig_scen"] = trig_scen
  10391. fmt.Println(data)
  10392. fmt.Println(fed)
  10393. fmt.Println(fdds)
  10394. fmt.Println(orders)
  10395. fmt.Println(pd)
  10396. fmt.Println(pp)
  10397. fmt.Println(fopd)
  10398. client := &http.Client{}
  10399. bytesData, _ := json.Marshal(data)
  10400. var req *http.Request
  10401. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10402. if miConfig.MdtrtareaAdmvs == "320921" {
  10403. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10404. } else {
  10405. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10406. }
  10407. resp, _ := client.Do(req)
  10408. defer resp.Body.Close()
  10409. body, ioErr := ioutil.ReadAll(resp.Body)
  10410. if ioErr != nil {
  10411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10413. return res
  10414. }
  10415. var respJSON map[string]interface{}
  10416. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10419. return res
  10420. }
  10421. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10422. fmt.Println(respJSON)
  10423. result, _ := json.Marshal(respJSON)
  10424. fmt.Println(result)
  10425. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10426. utils.ErrorLog("解析失败:%v", err)
  10427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10428. return res
  10429. }
  10430. return res
  10431. } else {
  10432. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10433. saveLog(output, input, "3101", "事前")
  10434. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10435. utils.ErrorLog("解析失败:%v", err)
  10436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10437. return
  10438. }
  10439. return res
  10440. }
  10441. return res
  10442. }
  10443. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10444. ////patient_id, _ := c.GetInt64("patient_id")
  10445. //order_id, _ := c.GetInt64("order_id")
  10446. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10447. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10448. //trig_scen := c.GetString("trig_scen")
  10449. adminUser := c.GetAdminUserInfo()
  10450. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10451. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10452. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10453. record_time := c.GetString("record_time")
  10454. order, _ := service.GetHisOrderByID(order_id)
  10455. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10456. timeLayout := "2006-01-02"
  10457. loc, _ := time.LoadLocation("Local")
  10458. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10459. if err != nil {
  10460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10461. return
  10462. }
  10463. recordDateTime := theTime.Unix()
  10464. var patientPrescription models.HisPrescriptionInfo
  10465. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10466. if patientPrescription.ID == 0 {
  10467. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10468. }
  10469. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10470. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10471. //
  10472. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10473. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10474. var pp models.PublicParams
  10475. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10476. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10477. pp.FixmedinsName = miConfig.OrgName
  10478. pp.FixmedinsCode = miConfig.Code
  10479. pp.RequestUrl = miConfig.Url
  10480. pp.Cainfo = miConfig.Cainfo
  10481. pp.SecretKey = miConfig.SecretKey
  10482. pp.AccessKey = miConfig.AccessKey
  10483. pp.OpterName = roles.UserName
  10484. var config []*models.HisXtDiagnoseConfig
  10485. for _, item := range diagnosis_ids {
  10486. id, _ := strconv.ParseInt(item, 10, 64)
  10487. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10488. config = append(config, &diagnosisConfig)
  10489. }
  10490. var pd models.PatientDtos
  10491. pd.PatnID = his.PsnNo
  10492. pd.PatnName = his.Name
  10493. pd.Gend = his.Gend
  10494. pd.Brdy = psn_info.Brdy
  10495. pd.Poolarea = his.InsuplcAdmdvs
  10496. pd.CurrMdtrtID = his.Number
  10497. var fed models.FsiEncounterDtos
  10498. fed.MdtrtID = his.Number
  10499. fed.MedinsID = miConfig.Code
  10500. fed.MedinsName = miConfig.OrgName
  10501. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10502. fed.MedMdtrtType = "1"
  10503. fed.MedinsType = "1"
  10504. fed.MedinsLv = "11"
  10505. tm := time.Unix(his.RecordDate, 0)
  10506. s_tm := tm.Format("2006-01-02 15:04:05")
  10507. fed.AdmDate = s_tm
  10508. fed.DscgDate = s_tm
  10509. fed.DscgMainDiseCodg = config[0].CountryCode
  10510. fed.DscgMainDiseName = config[0].CountryContentName
  10511. //诊断信息
  10512. var fdds []*models.FsiDiagnoseDtos
  10513. for index, item := range config {
  10514. if index == 0 {
  10515. var fdd models.FsiDiagnoseDtos
  10516. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10517. fdd.InoutDiseType = "1"
  10518. fdd.MaindiseFlag = "1"
  10519. fdd.DiseDate = s_tm
  10520. fdd.DiasSrtNo = "1"
  10521. fdd.DiseName = item.CountryContentName
  10522. fdd.DiseCodg = item.CountryCode
  10523. fdds = append(fdds, &fdd)
  10524. } else {
  10525. var fdd models.FsiDiagnoseDtos
  10526. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10527. fdd.InoutDiseType = "1"
  10528. fdd.MaindiseFlag = "1"
  10529. fdd.DiseDate = s_tm
  10530. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10531. fdd.DiseName = item.CountryContentName
  10532. fdd.DiseCodg = item.CountryCode
  10533. fdds = append(fdds, &fdd)
  10534. }
  10535. }
  10536. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10537. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10538. fed.AdmDeptName = department.Name
  10539. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10540. fed.DscgDeptName = department.Name
  10541. fed.MedType = order.MedType
  10542. //处方医嘱信息
  10543. var orders []*models.FsiOrderDtos
  10544. //for _, item := range prescriptions {
  10545. // for _, subItem := range item.HisDoctorAdviceInfo {
  10546. // var order models.FsiOrderDtos
  10547. // order.RxID = strconv.FormatInt(item.ID, 10)
  10548. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10549. // order.LongDrordFlag = "0"
  10550. // order.HilistType = "1"
  10551. // order.ChrgType = "1"
  10552. // order.DrordBhvr = "-"
  10553. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10554. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10555. // order.HilistLv = "1"
  10556. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10557. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10558. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10559. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10560. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10561. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10562. // order.OwnpayAmt = ""
  10563. // order.SelfpayAmt = ""
  10564. // order.Spec = ""
  10565. // order.SpecUnt = ""
  10566. // order.DrordBegnDate = s_tm
  10567. // order.DrordStopDate = ""
  10568. // order.DrordDrCodg = "1"
  10569. // order.DrordDeptName = department.Name
  10570. // order.DrordDrCodg = "1"
  10571. // order.DrordDrName = doctor_info.UserName
  10572. // order.DrordDrProfttl = ""
  10573. // order.CurrDrordFlag = "1"
  10574. // orders = append(orders, &order)
  10575. // }
  10576. // for _, subItem := range item.HisPrescriptionProject {
  10577. // if subItem.Type == 2 {
  10578. // var order models.FsiOrderDtos
  10579. // order.RxID = strconv.FormatInt(item.ID, 10)
  10580. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10581. // order.LongDrordFlag = "0"
  10582. // order.HilistType = "1"
  10583. // order.ChrgType = "1"
  10584. // order.DrordBhvr = "-"
  10585. // order.HilistCode = subItem.HisProject.MedicalCode
  10586. // order.HosplistName = subItem.HisProject.ProjectName
  10587. // order.HilistLv = "1"
  10588. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10589. // order.HosplistCode = subItem.HisProject.MedicalCode
  10590. // order.HosplistName = subItem.HisProject.ProjectName
  10591. // order.Cnt = subItem.Count
  10592. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10593. //
  10594. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10595. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10596. // order.OwnpayAmt = ""
  10597. // order.SelfpayAmt = ""
  10598. // order.Spec = ""
  10599. // order.SpecUnt = ""
  10600. // order.DrordBegnDate = s_tm
  10601. // order.DrordStopDate = ""
  10602. // order.DrordDrCodg = "1"
  10603. // order.DrordDeptName = department.Name
  10604. // order.DrordDrCodg = "1"
  10605. // order.DrordDrName = doctor_info.UserName
  10606. // order.DrordDrProfttl = ""
  10607. // order.CurrDrordFlag = "1"
  10608. // orders = append(orders, &order)
  10609. //
  10610. // }
  10611. // if subItem.Type == 3 {
  10612. //
  10613. // var order models.FsiOrderDtos
  10614. // order.RxID = strconv.FormatInt(item.ID, 10)
  10615. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10616. // order.LongDrordFlag = "0"
  10617. // order.HilistType = "1"
  10618. // order.ChrgType = "1"
  10619. // order.DrordBhvr = "-"
  10620. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10621. // order.HosplistName = subItem.GoodInfo.GoodName
  10622. // order.HilistLv = "1"
  10623. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10624. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10625. // order.HosplistName = subItem.GoodInfo.GoodName
  10626. // order.Cnt = subItem.Count
  10627. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10628. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10629. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10630. // order.OwnpayAmt = ""
  10631. // order.SelfpayAmt = ""
  10632. // order.Spec = ""
  10633. // order.SpecUnt = ""
  10634. // order.DrordBegnDate = s_tm
  10635. // order.DrordStopDate = ""
  10636. // order.DrordDrCodg = "1"
  10637. // order.DrordDeptName = department.Name
  10638. // order.DrordDrCodg = "1"
  10639. // order.DrordDrName = doctor_info.UserName
  10640. // order.DrordDrProfttl = ""
  10641. // order.CurrDrordFlag = "1"
  10642. // orders = append(orders, &order)
  10643. //
  10644. // }
  10645. // }
  10646. //}
  10647. for _, item := range prescriptions {
  10648. for _, subItem := range item.HisDoctorAdviceInfo {
  10649. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10650. var order models.FsiOrderDtos
  10651. order.RxID = strconv.FormatInt(item.ID, 10)
  10652. order.Rxno = strconv.FormatInt(item.ID, 10)
  10653. order.LongDrordFlag = "0"
  10654. order.HilistType = "1"
  10655. order.ChrgType = "1"
  10656. order.DrordBhvr = "-"
  10657. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10658. order.HosplistName = subItem.BaseDrugLib.DrugName
  10659. order.HilistLv = "1"
  10660. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10661. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10662. order.HosplistName = subItem.BaseDrugLib.DrugName
  10663. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10664. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10665. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10666. order.OwnpayAmt = ""
  10667. order.SelfpayAmt = ""
  10668. order.Spec = ""
  10669. order.SpecUnt = ""
  10670. order.DrordBegnDate = s_tm
  10671. order.DrordStopDate = ""
  10672. order.DrordDrCodg = doctor_info.DoctorNumber
  10673. order.DrordDeptName = department.Name
  10674. order.DrordDeptCodg = department.Number
  10675. order.DrordDrName = doctor_info.UserName
  10676. order.DrordDrProfttl = "234"
  10677. order.CurrDrordFlag = "1"
  10678. orders = append(orders, &order)
  10679. }
  10680. }
  10681. for _, subItem := range item.HisPrescriptionProject {
  10682. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10683. var order models.FsiOrderDtos
  10684. order.RxID = strconv.FormatInt(item.ID, 10)
  10685. order.Rxno = strconv.FormatInt(item.ID, 10)
  10686. order.LongDrordFlag = "0"
  10687. order.HilistType = "1"
  10688. order.ChrgType = "1"
  10689. order.DrordBhvr = "-"
  10690. order.HilistCode = subItem.HisProject.MedicalCode
  10691. order.HosplistName = subItem.HisProject.ProjectName
  10692. order.HilistLv = "1"
  10693. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10694. order.HosplistCode = subItem.HisProject.MedicalCode
  10695. order.HosplistName = subItem.HisProject.ProjectName
  10696. order.Cnt = subItem.Count
  10697. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10698. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10699. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10700. order.OwnpayAmt = ""
  10701. order.SelfpayAmt = ""
  10702. order.Spec = ""
  10703. order.SpecUnt = ""
  10704. order.DrordBegnDate = s_tm
  10705. order.DrordStopDate = ""
  10706. order.DrordDrCodg = doctor_info.DoctorNumber
  10707. order.DrordDeptName = department.Name
  10708. order.DrordDeptCodg = department.Number
  10709. order.DrordDrName = doctor_info.UserName
  10710. order.DrordDrProfttl = "234"
  10711. order.CurrDrordFlag = "1"
  10712. orders = append(orders, &order)
  10713. }
  10714. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10715. var order models.FsiOrderDtos
  10716. order.RxID = strconv.FormatInt(item.ID, 10)
  10717. order.Rxno = strconv.FormatInt(item.ID, 10)
  10718. order.LongDrordFlag = "0"
  10719. order.HilistType = "1"
  10720. order.ChrgType = "1"
  10721. order.DrordBhvr = "0"
  10722. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10723. order.HosplistName = subItem.GoodInfo.GoodName
  10724. order.HilistLv = "1"
  10725. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10726. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10727. order.HosplistName = subItem.GoodInfo.GoodName
  10728. order.Cnt = subItem.Count
  10729. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10730. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10731. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10732. order.OwnpayAmt = ""
  10733. order.SelfpayAmt = ""
  10734. order.Spec = ""
  10735. order.SpecUnt = ""
  10736. order.DrordBegnDate = s_tm
  10737. order.DrordStopDate = ""
  10738. order.DrordDrCodg = doctor_info.DoctorNumber
  10739. order.DrordDeptName = department.Name
  10740. order.DrordDeptCodg = department.Number
  10741. order.DrordDrName = doctor_info.UserName
  10742. order.DrordDrProfttl = "234"
  10743. order.CurrDrordFlag = "1"
  10744. orders = append(orders, &order)
  10745. }
  10746. }
  10747. }
  10748. //处方医嘱信息
  10749. fed.MatnStas = "0"
  10750. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  10751. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  10752. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  10753. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  10754. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  10755. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  10756. fed.SetlTotlnum = "1"
  10757. fed.Insutype = his.Insutype
  10758. fed.ReimFlag = "0"
  10759. fed.OutSetlFlag = "0"
  10760. var fopd []*models.FsiOperationDtosData
  10761. data := make(map[string]interface{})
  10762. data["fed"] = fed
  10763. data["fdd"] = fdds
  10764. data["fod"] = orders
  10765. data["pd"] = pd
  10766. data["pp"] = pp
  10767. data["fopd"] = fopd
  10768. data["trig_scen"] = trig_scen
  10769. client := &http.Client{}
  10770. bytesData, _ := json.Marshal(data)
  10771. var req *http.Request
  10772. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10773. if miConfig.MdtrtareaAdmvs == "320921" {
  10774. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10775. } else {
  10776. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10777. }
  10778. resp, _ := client.Do(req)
  10779. defer resp.Body.Close()
  10780. body, ioErr := ioutil.ReadAll(resp.Body)
  10781. if ioErr != nil {
  10782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10784. return res
  10785. }
  10786. var respJSON map[string]interface{}
  10787. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10790. return res
  10791. }
  10792. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10793. result, _ := json.Marshal(respJSON)
  10794. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10795. utils.ErrorLog("解析失败:%v", err)
  10796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10797. return res
  10798. }
  10799. return res
  10800. } else {
  10801. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10802. saveLog(output, input, "3102", "事中")
  10803. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10804. utils.ErrorLog("解析失败:%v", err)
  10805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10806. return
  10807. }
  10808. return res
  10809. }
  10810. return res
  10811. }
  10812. 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) {
  10813. var res Resultgd3101
  10814. adminUser := c.GetAdminUserInfo()
  10815. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10816. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10817. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10818. //record_time := c.GetString("record_time")
  10819. //trig_scen := c.GetString("trig_scen")
  10820. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10821. //psn_info, _ := service.GetPatientId(patient_id)
  10822. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10823. timeLayout := "2006-01-02"
  10824. loc, _ := time.LoadLocation("Local")
  10825. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10826. if err != nil {
  10827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10828. return res
  10829. }
  10830. recordDateTime := theTime.Unix()
  10831. var patientPrescription models.HisPrescriptionInfo
  10832. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10833. //if patientPrescription.ID == 0 {
  10834. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10835. //}
  10836. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10837. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10838. //
  10839. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10840. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10841. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10842. var pp models.PublicParams
  10843. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10844. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10845. pp.FixmedinsName = miConfig.OrgName
  10846. pp.FixmedinsCode = miConfig.Code
  10847. pp.RequestUrl = miConfig.Url
  10848. pp.Cainfo = miConfig.Cainfo
  10849. pp.SecretKey = miConfig.SecretKey
  10850. pp.AccessKey = miConfig.AccessKey
  10851. pp.OpterName = roles.UserName
  10852. var config []*models.HisXtDiagnoseConfig
  10853. for _, item := range diagnosis_ids {
  10854. id, _ := strconv.ParseInt(item, 10, 64)
  10855. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10856. config = append(config, &diagnosisConfig)
  10857. }
  10858. var pd models.PatientDtos
  10859. pd.PatnID = his.PsnNo
  10860. pd.PatnName = his.Name
  10861. pd.Gend = his.Gend
  10862. pd.Brdy = str
  10863. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10864. pd.CurrMdtrtID = his.Number
  10865. var fed models.FsiEncounterDtos
  10866. fed.MdtrtID = his.Number
  10867. fed.MedinsID = miConfig.Code
  10868. fed.MedinsName = miConfig.OrgName
  10869. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10870. fed.MedMdtrtType = "1"
  10871. fed.MedinsType = "1"
  10872. fed.MedinsLv = "11"
  10873. tm := time.Unix(his.RecordDate, 0)
  10874. s_tm := tm.Format("2006-01-02 15:04:05")
  10875. fed.AdmDate = s_tm
  10876. fed.DscgDate = s_tm
  10877. fed.DscgMainDiseCodg = config[0].CountryCode
  10878. fed.DscgMainDiseName = config[0].CountryContentName
  10879. //诊断信息
  10880. var fdds []*models.FsiDiagnoseDtos
  10881. for index, item := range config {
  10882. if index == 0 {
  10883. var fdd models.FsiDiagnoseDtos
  10884. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10885. fdd.InoutDiseType = "1"
  10886. fdd.MaindiseFlag = "1"
  10887. fdd.DiseDate = s_tm
  10888. fdd.DiasSrtNo = "1"
  10889. fdd.DiseName = item.CountryContentName
  10890. fdd.DiseCodg = item.CountryCode
  10891. fdds = append(fdds, &fdd)
  10892. } else {
  10893. var fdd models.FsiDiagnoseDtos
  10894. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10895. fdd.InoutDiseType = "1"
  10896. fdd.MaindiseFlag = "1"
  10897. fdd.DiseDate = s_tm
  10898. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10899. fdd.DiseName = item.CountryContentName
  10900. fdd.DiseCodg = item.CountryCode
  10901. fdds = append(fdds, &fdd)
  10902. }
  10903. }
  10904. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10905. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10906. fed.AdmDeptName = de.Name
  10907. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10908. fed.DscgDeptName = de.Name
  10909. fed.MedMdtrtType = "1"
  10910. fed.MedType = "11"
  10911. //if his.Insutype == "390" {
  10912. // fed.MedType = "1402"
  10913. //} else {
  10914. // fed.MedType = "9933"
  10915. //}
  10916. var orders []*models.FsiOrderDtos
  10917. if trig_scen == "2" {
  10918. //处方医嘱信息
  10919. for _, item := range prescriptions {
  10920. for _, subItem := range item.HisDoctorAdviceInfo {
  10921. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10922. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10923. var order models.FsiOrderDtos
  10924. order.RxID = strconv.FormatInt(item.ID, 10)
  10925. order.Rxno = strconv.FormatInt(item.ID, 10)
  10926. order.LongDrordFlag = "0"
  10927. order.HilistType = "1"
  10928. order.ChrgType = "1"
  10929. order.DrordBhvr = "0"
  10930. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10931. order.HosplistName = subItem.BaseDrugLib.DrugName
  10932. order.HilistLv = "1"
  10933. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10934. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10935. order.HosplistName = subItem.BaseDrugLib.DrugName
  10936. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10937. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10938. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10939. order.OwnpayAmt = ""
  10940. order.SelfpayAmt = ""
  10941. order.Spec = spec
  10942. order.SpecUnt = subItem.PrescribingNumberUnit
  10943. order.DrordBegnDate = s_tm
  10944. order.DrordStopDate = ""
  10945. order.DrordDrCodg = doctor_info.DoctorNumber
  10946. order.DrordDeptName = department.Name
  10947. order.DrordDeptCodg = department.Number
  10948. order.DrordDrName = doctor_info.UserName
  10949. order.DrordDrProfttl = "234"
  10950. order.CurrDrordFlag = "1"
  10951. orders = append(orders, &order)
  10952. }
  10953. }
  10954. for _, subItem := range item.HisPrescriptionProject {
  10955. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10956. var order models.FsiOrderDtos
  10957. order.RxID = strconv.FormatInt(item.ID, 10)
  10958. order.Rxno = strconv.FormatInt(item.ID, 10)
  10959. order.LongDrordFlag = "0"
  10960. order.HilistType = "1"
  10961. order.ChrgType = "1"
  10962. order.DrordBhvr = "0"
  10963. order.HilistCode = subItem.HisProject.MedicalCode
  10964. order.HosplistName = subItem.HisProject.ProjectName
  10965. order.HilistLv = "1"
  10966. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10967. order.HosplistCode = subItem.HisProject.MedicalCode
  10968. order.HosplistName = subItem.HisProject.ProjectName
  10969. order.Cnt = subItem.Count
  10970. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10971. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10972. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10973. order.OwnpayAmt = ""
  10974. order.SelfpayAmt = ""
  10975. order.Spec = subItem.Unit
  10976. order.SpecUnt = subItem.Unit
  10977. order.DrordBegnDate = s_tm
  10978. order.DrordStopDate = ""
  10979. order.DrordDrCodg = doctor_info.DoctorNumber
  10980. order.DrordDeptName = department.Name
  10981. order.DrordDeptCodg = department.Number
  10982. order.DrordDrName = doctor_info.UserName
  10983. order.DrordDrProfttl = "234"
  10984. order.CurrDrordFlag = "1"
  10985. orders = append(orders, &order)
  10986. }
  10987. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10988. var order models.FsiOrderDtos
  10989. order.RxID = strconv.FormatInt(item.ID, 10)
  10990. order.Rxno = strconv.FormatInt(item.ID, 10)
  10991. order.LongDrordFlag = "0"
  10992. order.HilistType = "1"
  10993. order.ChrgType = "1"
  10994. order.DrordBhvr = "0"
  10995. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10996. order.HosplistName = subItem.GoodInfo.GoodName
  10997. order.HilistLv = "1"
  10998. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10999. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11000. order.HosplistName = subItem.GoodInfo.GoodName
  11001. order.Cnt = subItem.Count
  11002. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11003. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11004. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11005. order.OwnpayAmt = ""
  11006. order.SelfpayAmt = ""
  11007. order.Spec = subItem.GoodInfo.SpecificationName
  11008. order.SpecUnt = subItem.Unit
  11009. order.DrordBegnDate = s_tm
  11010. order.DrordStopDate = ""
  11011. order.DrordDrCodg = doctor_info.DoctorNumber
  11012. order.DrordDeptName = department.Name
  11013. order.DrordDeptCodg = department.Number
  11014. order.DrordDrName = doctor_info.UserName
  11015. order.DrordDrProfttl = "234"
  11016. order.CurrDrordFlag = "1"
  11017. orders = append(orders, &order)
  11018. }
  11019. }
  11020. }
  11021. //处方医嘱信息
  11022. }
  11023. fed.MatnStas = "0"
  11024. fed.MedfeeSumamt = "0"
  11025. fed.OwnpayAmt = "0"
  11026. fed.SelfpayAmt = "0"
  11027. fed.AcctPayamt = "0"
  11028. fed.MaAmt = "0"
  11029. fed.HifpPayamt = "0"
  11030. fed.SetlTotlnum = "1"
  11031. fed.Insutype = his.Insutype
  11032. fed.ReimFlag = "0"
  11033. fed.OutSetlFlag = "0"
  11034. var fopd []*models.FsiOperationDtosData
  11035. data := make(map[string]interface{})
  11036. data["fed"] = fed
  11037. data["fdd"] = fdds
  11038. data["fod"] = orders
  11039. data["pd"] = pd
  11040. data["pp"] = pp
  11041. data["fopd"] = fopd
  11042. data["trig_scen"] = trig_scen
  11043. fmt.Println(data)
  11044. fmt.Println(fed)
  11045. fmt.Println(fdds)
  11046. fmt.Println(orders)
  11047. fmt.Println(pd)
  11048. fmt.Println(pp)
  11049. fmt.Println(fopd)
  11050. client := &http.Client{}
  11051. bytesData, _ := json.Marshal(data)
  11052. var req *http.Request
  11053. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11054. if miConfig.MdtrtareaAdmvs == "320921" {
  11055. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11056. } else {
  11057. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11058. }
  11059. resp, _ := client.Do(req)
  11060. defer resp.Body.Close()
  11061. body, ioErr := ioutil.ReadAll(resp.Body)
  11062. if ioErr != nil {
  11063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11065. return res
  11066. }
  11067. var respJSON map[string]interface{}
  11068. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11071. return res
  11072. }
  11073. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11074. fmt.Println(respJSON)
  11075. result, _ := json.Marshal(respJSON)
  11076. fmt.Println(result)
  11077. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11078. utils.ErrorLog("解析失败:%v", err)
  11079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11080. return res
  11081. }
  11082. return res
  11083. } else {
  11084. //if miConfig.MdtrtareaAdmvs == "441202" {
  11085. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11086. saveLog(output, input, "3101", "事前")
  11087. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11088. utils.ErrorLog("解析失败:%v", err)
  11089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11090. return
  11091. }
  11092. return res
  11093. //}
  11094. }
  11095. }
  11096. 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) {
  11097. adminUser := c.GetAdminUserInfo()
  11098. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11099. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11100. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11101. //record_time := c.GetString("record_time")
  11102. //trig_scen := c.GetString("trig_scen")
  11103. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11104. timeLayout := "2006-01-02"
  11105. loc, _ := time.LoadLocation("Local")
  11106. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11107. if err != nil {
  11108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11109. return res
  11110. }
  11111. recordDateTime := theTime.Unix()
  11112. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11113. var patientPrescription models.HisPrescriptionInfo
  11114. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11115. if patientPrescription.ID == 0 {
  11116. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11117. }
  11118. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11119. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11120. //
  11121. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11122. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11123. var pp models.PublicParams
  11124. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11125. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11126. pp.FixmedinsName = miConfig.OrgName
  11127. pp.FixmedinsCode = miConfig.Code
  11128. pp.RequestUrl = miConfig.Url
  11129. pp.Cainfo = miConfig.Cainfo
  11130. pp.SecretKey = miConfig.SecretKey
  11131. pp.AccessKey = miConfig.AccessKey
  11132. pp.OpterName = roles.UserName
  11133. var config []*models.HisXtDiagnoseConfig
  11134. for _, item := range diagnosis_ids {
  11135. id, _ := strconv.ParseInt(item, 10, 64)
  11136. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11137. config = append(config, &diagnosisConfig)
  11138. }
  11139. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11140. var pd models.PatientDtos
  11141. pd.PatnID = his.PsnNo
  11142. pd.PatnName = his.Name
  11143. pd.Gend = his.Gend
  11144. pd.Brdy = str
  11145. pd.Poolarea = his.InsuplcAdmdvs
  11146. pd.CurrMdtrtID = his.Number
  11147. var fed models.FsiEncounterDtos
  11148. fed.MdtrtID = his.Number
  11149. fed.MedinsID = miConfig.Code
  11150. fed.MedinsName = miConfig.OrgName
  11151. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11152. fed.MedMdtrtType = "1"
  11153. fed.MedinsType = "1"
  11154. fed.MedinsLv = "11"
  11155. tm := time.Unix(his.RecordDate, 0)
  11156. s_tm := tm.Format("2006-01-02 15:04:05")
  11157. fed.AdmDate = s_tm
  11158. fed.DscgDate = s_tm
  11159. fed.DscgMainDiseCodg = config[0].CountryCode
  11160. fed.DscgMainDiseName = config[0].CountryContentName
  11161. //诊断信息
  11162. var fdds []*models.FsiDiagnoseDtos
  11163. for index, item := range config {
  11164. if index == 0 {
  11165. var fdd models.FsiDiagnoseDtos
  11166. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11167. fdd.InoutDiseType = "1"
  11168. fdd.MaindiseFlag = "1"
  11169. fdd.DiseDate = s_tm
  11170. fdd.DiasSrtNo = "1"
  11171. fdd.DiseName = item.CountryContentName
  11172. fdd.DiseCodg = item.CountryCode
  11173. fdds = append(fdds, &fdd)
  11174. } else {
  11175. var fdd models.FsiDiagnoseDtos
  11176. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11177. fdd.InoutDiseType = "1"
  11178. fdd.MaindiseFlag = "1"
  11179. fdd.DiseDate = s_tm
  11180. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11181. fdd.DiseName = item.CountryContentName
  11182. fdd.DiseCodg = item.CountryCode
  11183. fdds = append(fdds, &fdd)
  11184. }
  11185. }
  11186. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11187. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11188. fed.AdmDeptName = department.Name
  11189. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11190. fed.DscgDeptName = department.Name
  11191. fed.MedMdtrtType = "1"
  11192. fed.MedType = "11"
  11193. //if his.Insutype == "390" {
  11194. // fed.MedType = "1402"
  11195. //} else {
  11196. // fed.MedType = "9933"
  11197. //}
  11198. var orders []*models.FsiOrderDtos
  11199. if trig_scen == "2" {
  11200. //处方医嘱信息
  11201. for _, item := range prescriptions {
  11202. for _, subItem := range item.HisDoctorAdviceInfo {
  11203. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11204. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11205. var order models.FsiOrderDtos
  11206. order.RxID = strconv.FormatInt(item.ID, 10)
  11207. order.Rxno = strconv.FormatInt(item.ID, 10)
  11208. order.LongDrordFlag = "0"
  11209. order.HilistType = "1"
  11210. order.ChrgType = "1"
  11211. order.DrordBhvr = "0"
  11212. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11213. order.HosplistName = subItem.BaseDrugLib.DrugName
  11214. order.HilistLv = "1"
  11215. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11216. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11217. order.HosplistName = subItem.BaseDrugLib.DrugName
  11218. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11219. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11220. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11221. order.OwnpayAmt = ""
  11222. order.SelfpayAmt = ""
  11223. order.Spec = spec
  11224. order.SpecUnt = subItem.PrescribingNumberUnit
  11225. order.DrordBegnDate = s_tm
  11226. order.DrordStopDate = ""
  11227. order.DrordDrCodg = doctor_info.DoctorNumber
  11228. order.DrordDeptName = department.Name
  11229. order.DrordDeptCodg = department.Number
  11230. order.DrordDrName = doctor_info.UserName
  11231. order.DrordDrProfttl = "234"
  11232. order.CurrDrordFlag = "1"
  11233. orders = append(orders, &order)
  11234. }
  11235. }
  11236. for _, subItem := range item.HisPrescriptionProject {
  11237. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11238. var order models.FsiOrderDtos
  11239. order.RxID = strconv.FormatInt(item.ID, 10)
  11240. order.Rxno = strconv.FormatInt(item.ID, 10)
  11241. order.LongDrordFlag = "0"
  11242. order.HilistType = "1"
  11243. order.ChrgType = "1"
  11244. order.DrordBhvr = "0"
  11245. order.HilistCode = subItem.HisProject.MedicalCode
  11246. order.HosplistName = subItem.HisProject.ProjectName
  11247. order.HilistLv = "1"
  11248. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11249. order.HosplistCode = subItem.HisProject.MedicalCode
  11250. order.HosplistName = subItem.HisProject.ProjectName
  11251. order.Cnt = subItem.Count
  11252. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11253. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11254. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11255. order.OwnpayAmt = ""
  11256. order.SelfpayAmt = ""
  11257. order.Spec = subItem.Unit
  11258. order.SpecUnt = subItem.Unit
  11259. order.DrordBegnDate = s_tm
  11260. order.DrordStopDate = ""
  11261. order.DrordDrCodg = doctor_info.DoctorNumber
  11262. order.DrordDeptName = department.Name
  11263. order.DrordDeptCodg = department.Number
  11264. order.DrordDrName = doctor_info.UserName
  11265. order.DrordDrProfttl = "234"
  11266. order.CurrDrordFlag = "1"
  11267. orders = append(orders, &order)
  11268. }
  11269. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11270. var order models.FsiOrderDtos
  11271. order.RxID = strconv.FormatInt(item.ID, 10)
  11272. order.Rxno = strconv.FormatInt(item.ID, 10)
  11273. order.LongDrordFlag = "0"
  11274. order.HilistType = "1"
  11275. order.ChrgType = "1"
  11276. order.DrordBhvr = "0"
  11277. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11278. order.HosplistName = subItem.GoodInfo.GoodName
  11279. order.HilistLv = "1"
  11280. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11281. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11282. order.HosplistName = subItem.GoodInfo.GoodName
  11283. order.Cnt = subItem.Count
  11284. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11285. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11286. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11287. order.OwnpayAmt = ""
  11288. order.SelfpayAmt = ""
  11289. order.Spec = subItem.GoodInfo.SpecificationName
  11290. order.SpecUnt = subItem.Unit
  11291. order.DrordBegnDate = s_tm
  11292. order.DrordStopDate = ""
  11293. order.DrordDrCodg = doctor_info.DoctorNumber
  11294. order.DrordDeptName = department.Name
  11295. order.DrordDeptCodg = department.Number
  11296. order.DrordDrName = doctor_info.UserName
  11297. order.DrordDrProfttl = "234"
  11298. order.CurrDrordFlag = "1"
  11299. orders = append(orders, &order)
  11300. }
  11301. }
  11302. }
  11303. //处方医嘱信息
  11304. }
  11305. fed.MatnStas = "0"
  11306. fed.MedfeeSumamt = "0"
  11307. fed.OwnpayAmt = "0"
  11308. fed.SelfpayAmt = "0"
  11309. fed.AcctPayamt = "0"
  11310. fed.MaAmt = "0"
  11311. fed.HifpPayamt = "0"
  11312. fed.SetlTotlnum = "1"
  11313. fed.Insutype = his.Insutype
  11314. fed.ReimFlag = "0"
  11315. fed.OutSetlFlag = "0"
  11316. var fopd []*models.FsiOperationDtosData
  11317. data := make(map[string]interface{})
  11318. data["fed"] = fed
  11319. data["fdd"] = fdds
  11320. data["fod"] = orders
  11321. data["pd"] = pd
  11322. data["pp"] = pp
  11323. data["fopd"] = fopd
  11324. data["trig_scen"] = trig_scen
  11325. fmt.Println(data)
  11326. fmt.Println(fed)
  11327. fmt.Println(fdds)
  11328. fmt.Println(orders)
  11329. fmt.Println(pd)
  11330. fmt.Println(pp)
  11331. fmt.Println(fopd)
  11332. client := &http.Client{}
  11333. bytesData, _ := json.Marshal(data)
  11334. var req *http.Request
  11335. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11336. if miConfig.MdtrtareaAdmvs == "320921" {
  11337. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11338. } else {
  11339. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11340. }
  11341. resp, _ := client.Do(req)
  11342. defer resp.Body.Close()
  11343. body, ioErr := ioutil.ReadAll(resp.Body)
  11344. if ioErr != nil {
  11345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11347. return res
  11348. }
  11349. var respJSON map[string]interface{}
  11350. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11353. return res
  11354. }
  11355. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11356. fmt.Println(respJSON)
  11357. result, _ := json.Marshal(respJSON)
  11358. fmt.Println(result)
  11359. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11360. utils.ErrorLog("解析失败:%v", err)
  11361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11362. return res
  11363. }
  11364. return res
  11365. } else {
  11366. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11367. saveLog(output, input, "3101", "事前")
  11368. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11369. utils.ErrorLog("解析失败:%v", err)
  11370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11371. return
  11372. }
  11373. return res
  11374. }
  11375. return res
  11376. }
  11377. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11378. ////patient_id, _ := c.GetInt64("patient_id")
  11379. //order_id, _ := c.GetInt64("order_id")
  11380. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11381. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11382. //trig_scen := c.GetString("trig_scen")
  11383. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11384. //utils.ErrorLog("解析失败:%v", psn_info)
  11385. adminUser := c.GetAdminUserInfo()
  11386. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11387. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11388. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11389. record_time := c.GetString("record_time")
  11390. order, _ := service.GetHisOrderByID(order_id)
  11391. timeLayout := "2006-01-02"
  11392. loc, _ := time.LoadLocation("Local")
  11393. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11394. if err != nil {
  11395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11396. return
  11397. }
  11398. recordDateTime := theTime.Unix()
  11399. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11400. var patientPrescription models.HisPrescriptionInfo
  11401. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11402. if patientPrescription.ID == 0 {
  11403. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11404. }
  11405. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11406. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11407. //
  11408. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11409. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11410. var pp models.PublicParams
  11411. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11412. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11413. pp.FixmedinsName = miConfig.OrgName
  11414. pp.FixmedinsCode = miConfig.Code
  11415. pp.RequestUrl = miConfig.Url
  11416. pp.Cainfo = miConfig.Cainfo
  11417. pp.SecretKey = miConfig.SecretKey
  11418. pp.AccessKey = miConfig.AccessKey
  11419. pp.OpterName = roles.UserName
  11420. var config []*models.HisXtDiagnoseConfig
  11421. for _, item := range diagnosis_ids {
  11422. id, _ := strconv.ParseInt(item, 10, 64)
  11423. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11424. config = append(config, &diagnosisConfig)
  11425. }
  11426. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11427. var pd models.PatientDtos
  11428. pd.PatnID = his.PsnNo
  11429. pd.PatnName = his.Name
  11430. pd.Gend = his.Gend
  11431. pd.Brdy = str
  11432. pd.Poolarea = his.InsuplcAdmdvs
  11433. pd.CurrMdtrtID = his.Number
  11434. var fed models.FsiEncounterDtos
  11435. fed.MdtrtID = his.Number
  11436. fed.MedinsID = miConfig.Code
  11437. fed.MedinsName = miConfig.OrgName
  11438. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11439. fed.MedMdtrtType = "1"
  11440. fed.MedinsType = "1"
  11441. fed.MedinsLv = "11"
  11442. tm := time.Unix(his.RecordDate, 0)
  11443. s_tm := tm.Format("2006-01-02 15:04:05")
  11444. fed.AdmDate = s_tm
  11445. fed.DscgDate = s_tm
  11446. fed.DscgMainDiseCodg = config[0].CountryCode
  11447. fed.DscgMainDiseName = config[0].CountryContentName
  11448. //诊断信息
  11449. var fdds []*models.FsiDiagnoseDtos
  11450. for index, item := range config {
  11451. if index == 0 {
  11452. var fdd models.FsiDiagnoseDtos
  11453. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11454. fdd.InoutDiseType = "1"
  11455. fdd.MaindiseFlag = "1"
  11456. fdd.DiseDate = s_tm
  11457. fdd.DiasSrtNo = "1"
  11458. fdd.DiseName = item.CountryContentName
  11459. fdd.DiseCodg = item.CountryCode
  11460. fdds = append(fdds, &fdd)
  11461. } else {
  11462. var fdd models.FsiDiagnoseDtos
  11463. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11464. fdd.InoutDiseType = "1"
  11465. fdd.MaindiseFlag = "1"
  11466. fdd.DiseDate = s_tm
  11467. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11468. fdd.DiseName = item.CountryContentName
  11469. fdd.DiseCodg = item.CountryCode
  11470. fdds = append(fdds, &fdd)
  11471. }
  11472. }
  11473. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11474. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11475. fed.AdmDeptName = department.Name
  11476. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11477. fed.DscgDeptName = department.Name
  11478. fed.MedType = order.MedType
  11479. //处方医嘱信息
  11480. var orders []*models.FsiOrderDtos
  11481. //for _, item := range prescriptions {
  11482. // for _, subItem := range item.HisDoctorAdviceInfo {
  11483. // var order models.FsiOrderDtos
  11484. // order.RxID = strconv.FormatInt(item.ID, 10)
  11485. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11486. // order.LongDrordFlag = "0"
  11487. // order.HilistType = "1"
  11488. // order.ChrgType = "1"
  11489. // order.DrordBhvr = "-"
  11490. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11491. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11492. // order.HilistLv = "1"
  11493. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11494. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11495. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11496. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11497. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11498. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11499. // order.OwnpayAmt = ""
  11500. // order.SelfpayAmt = ""
  11501. // order.Spec = ""
  11502. // order.SpecUnt = ""
  11503. // order.DrordBegnDate = s_tm
  11504. // order.DrordStopDate = ""
  11505. // order.DrordDrCodg = "1"
  11506. // order.DrordDeptName = department.Name
  11507. // order.DrordDrCodg = "1"
  11508. // order.DrordDrName = doctor_info.UserName
  11509. // order.DrordDrProfttl = ""
  11510. // order.CurrDrordFlag = "1"
  11511. // orders = append(orders, &order)
  11512. // }
  11513. // for _, subItem := range item.HisPrescriptionProject {
  11514. // if subItem.Type == 2 {
  11515. // var order models.FsiOrderDtos
  11516. // order.RxID = strconv.FormatInt(item.ID, 10)
  11517. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11518. // order.LongDrordFlag = "0"
  11519. // order.HilistType = "1"
  11520. // order.ChrgType = "1"
  11521. // order.DrordBhvr = "-"
  11522. // order.HilistCode = subItem.HisProject.MedicalCode
  11523. // order.HosplistName = subItem.HisProject.ProjectName
  11524. // order.HilistLv = "1"
  11525. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11526. // order.HosplistCode = subItem.HisProject.MedicalCode
  11527. // order.HosplistName = subItem.HisProject.ProjectName
  11528. // order.Cnt = subItem.Count
  11529. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11530. //
  11531. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11532. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11533. // order.OwnpayAmt = ""
  11534. // order.SelfpayAmt = ""
  11535. // order.Spec = ""
  11536. // order.SpecUnt = ""
  11537. // order.DrordBegnDate = s_tm
  11538. // order.DrordStopDate = ""
  11539. // order.DrordDrCodg = "1"
  11540. // order.DrordDeptName = department.Name
  11541. // order.DrordDrCodg = "1"
  11542. // order.DrordDrName = doctor_info.UserName
  11543. // order.DrordDrProfttl = ""
  11544. // order.CurrDrordFlag = "1"
  11545. // orders = append(orders, &order)
  11546. //
  11547. // }
  11548. // if subItem.Type == 3 {
  11549. //
  11550. // var order models.FsiOrderDtos
  11551. // order.RxID = strconv.FormatInt(item.ID, 10)
  11552. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11553. // order.LongDrordFlag = "0"
  11554. // order.HilistType = "1"
  11555. // order.ChrgType = "1"
  11556. // order.DrordBhvr = "-"
  11557. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11558. // order.HosplistName = subItem.GoodInfo.GoodName
  11559. // order.HilistLv = "1"
  11560. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11561. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11562. // order.HosplistName = subItem.GoodInfo.GoodName
  11563. // order.Cnt = subItem.Count
  11564. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11565. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11566. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11567. // order.OwnpayAmt = ""
  11568. // order.SelfpayAmt = ""
  11569. // order.Spec = ""
  11570. // order.SpecUnt = ""
  11571. // order.DrordBegnDate = s_tm
  11572. // order.DrordStopDate = ""
  11573. // order.DrordDrCodg = "1"
  11574. // order.DrordDeptName = department.Name
  11575. // order.DrordDrCodg = "1"
  11576. // order.DrordDrName = doctor_info.UserName
  11577. // order.DrordDrProfttl = ""
  11578. // order.CurrDrordFlag = "1"
  11579. // orders = append(orders, &order)
  11580. //
  11581. // }
  11582. // }
  11583. //}
  11584. for _, item := range prescriptions {
  11585. for _, subItem := range item.HisDoctorAdviceInfo {
  11586. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11587. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11588. var order models.FsiOrderDtos
  11589. order.RxID = strconv.FormatInt(item.ID, 10)
  11590. order.Rxno = strconv.FormatInt(item.ID, 10)
  11591. order.LongDrordFlag = "0"
  11592. order.HilistType = "1"
  11593. order.ChrgType = "1"
  11594. order.DrordBhvr = "0"
  11595. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11596. order.HosplistName = subItem.BaseDrugLib.DrugName
  11597. order.HilistLv = "1"
  11598. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11599. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11600. order.HosplistName = subItem.BaseDrugLib.DrugName
  11601. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11602. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11603. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11604. order.OwnpayAmt = ""
  11605. order.SelfpayAmt = ""
  11606. order.Spec = spec
  11607. order.SpecUnt = subItem.PrescribingNumberUnit
  11608. order.DrordBegnDate = s_tm
  11609. order.DrordStopDate = ""
  11610. order.DrordDrCodg = doctor_info.DoctorNumber
  11611. order.DrordDeptName = department.Name
  11612. order.DrordDeptCodg = department.Number
  11613. order.DrordDrName = doctor_info.UserName
  11614. order.DrordDrProfttl = "234"
  11615. order.CurrDrordFlag = "1"
  11616. orders = append(orders, &order)
  11617. }
  11618. }
  11619. for _, subItem := range item.HisPrescriptionProject {
  11620. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11621. var order models.FsiOrderDtos
  11622. order.RxID = strconv.FormatInt(item.ID, 10)
  11623. order.Rxno = strconv.FormatInt(item.ID, 10)
  11624. order.LongDrordFlag = "0"
  11625. order.HilistType = "1"
  11626. order.ChrgType = "1"
  11627. order.DrordBhvr = "0"
  11628. order.HilistCode = subItem.HisProject.MedicalCode
  11629. order.HosplistName = subItem.HisProject.ProjectName
  11630. order.HilistLv = "1"
  11631. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11632. order.HosplistCode = subItem.HisProject.MedicalCode
  11633. order.HosplistName = subItem.HisProject.ProjectName
  11634. order.Cnt = subItem.Count
  11635. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11636. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11637. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11638. order.OwnpayAmt = ""
  11639. order.SelfpayAmt = ""
  11640. order.Spec = subItem.Unit
  11641. order.SpecUnt = subItem.Unit
  11642. order.DrordBegnDate = s_tm
  11643. order.DrordStopDate = ""
  11644. order.DrordDrCodg = doctor_info.DoctorNumber
  11645. order.DrordDeptName = department.Name
  11646. order.DrordDeptCodg = department.Number
  11647. order.DrordDrName = doctor_info.UserName
  11648. order.DrordDrProfttl = "234"
  11649. order.CurrDrordFlag = "1"
  11650. orders = append(orders, &order)
  11651. }
  11652. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11653. var order models.FsiOrderDtos
  11654. order.RxID = strconv.FormatInt(item.ID, 10)
  11655. order.Rxno = strconv.FormatInt(item.ID, 10)
  11656. order.LongDrordFlag = "0"
  11657. order.HilistType = "1"
  11658. order.ChrgType = "1"
  11659. order.DrordBhvr = "0"
  11660. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11661. order.HosplistName = subItem.GoodInfo.GoodName
  11662. order.HilistLv = "1"
  11663. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11664. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11665. order.HosplistName = subItem.GoodInfo.GoodName
  11666. order.Cnt = subItem.Count
  11667. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11668. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11669. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11670. order.OwnpayAmt = ""
  11671. order.SelfpayAmt = ""
  11672. order.Spec = subItem.GoodInfo.SpecificationName
  11673. order.SpecUnt = subItem.Unit
  11674. order.DrordBegnDate = s_tm
  11675. order.DrordStopDate = ""
  11676. order.DrordDrCodg = doctor_info.DoctorNumber
  11677. order.DrordDeptName = department.Name
  11678. order.DrordDeptCodg = department.Number
  11679. order.DrordDrName = doctor_info.UserName
  11680. order.DrordDrProfttl = "234"
  11681. order.CurrDrordFlag = "1"
  11682. orders = append(orders, &order)
  11683. }
  11684. }
  11685. }
  11686. //处方医嘱信息
  11687. fed.MatnStas = "0"
  11688. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11689. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11690. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11691. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11692. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11693. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11694. fed.SetlTotlnum = "1"
  11695. fed.Insutype = his.Insutype
  11696. fed.ReimFlag = "0"
  11697. fed.OutSetlFlag = "0"
  11698. var fopd []*models.FsiOperationDtosData
  11699. data := make(map[string]interface{})
  11700. data["fed"] = fed
  11701. data["fdd"] = fdds
  11702. data["fod"] = orders
  11703. data["pd"] = pd
  11704. data["pp"] = pp
  11705. data["fopd"] = fopd
  11706. data["trig_scen"] = trig_scen
  11707. client := &http.Client{}
  11708. bytesData, _ := json.Marshal(data)
  11709. var req *http.Request
  11710. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11711. if miConfig.MdtrtareaAdmvs == "320921" {
  11712. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11713. } else {
  11714. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11715. }
  11716. resp, _ := client.Do(req)
  11717. defer resp.Body.Close()
  11718. body, ioErr := ioutil.ReadAll(resp.Body)
  11719. if ioErr != nil {
  11720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11722. return res
  11723. }
  11724. var respJSON map[string]interface{}
  11725. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11728. return res
  11729. }
  11730. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11731. result, _ := json.Marshal(respJSON)
  11732. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11733. utils.ErrorLog("解析失败:%v", err)
  11734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11735. return res
  11736. }
  11737. return res
  11738. } else {
  11739. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11740. saveLog(output, input, "3102", "事中")
  11741. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11742. utils.ErrorLog("解析失败:%v", err)
  11743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11744. return
  11745. }
  11746. return res
  11747. }
  11748. return res
  11749. }
  11750. func (c *HisApiController) Check() {
  11751. psn_no := c.GetString("psn_no")
  11752. in := c.GetString("in")
  11753. mt := c.GetString("mt")
  11754. baseParams := models.BaseParams{
  11755. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  11756. FixmedinsCode: "H15049901371",
  11757. InsuplcAdmdvs: "150499",
  11758. MdtrtareaAdmvs: "150499",
  11759. OrgName: "赤峰费森血液透析中心",
  11760. Doctor: "1111",
  11761. }
  11762. service.Gdyb2001(baseParams, psn_no, in, mt)
  11763. }
  11764. func (c *HisApiController) GetPsnNcdsInfo() {
  11765. admin_user_id, _ := c.GetInt64("admin_user_id")
  11766. patient_id, _ := c.GetInt64("patient_id")
  11767. //id, _ := c.GetInt64("id")
  11768. adminUser := c.GetAdminUserInfo()
  11769. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11770. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11771. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  11772. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11773. //psn_record, _ := service.GetP(id)
  11774. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11775. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  11776. //
  11777. //if psn_record.ID == 0 {
  11778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11779. // return
  11780. //}
  11781. var res Result5301
  11782. var res10265 Result5301For10265
  11783. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11784. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11785. var api string
  11786. if miConfig.MdtrtareaAdmvs == "320921" {
  11787. 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 +
  11788. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11789. } else {
  11790. 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 +
  11791. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11792. }
  11793. resp, requestErr := http.Get(api)
  11794. if requestErr != nil {
  11795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11796. return
  11797. }
  11798. body, ioErr := ioutil.ReadAll(resp.Body)
  11799. if ioErr != nil {
  11800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11802. return
  11803. }
  11804. var respJSON map[string]interface{}
  11805. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11808. return
  11809. }
  11810. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11811. result, _ := json.Marshal(respJSON)
  11812. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11813. utils.ErrorLog("解析失败:%v", err)
  11814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11815. return
  11816. }
  11817. res.ErrMsg = res10265.ErrMsg
  11818. res.Output = res10265.Output
  11819. res.InfRefmsgid = res10265.InfRefmsgid
  11820. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11821. res.Infcode = infocode
  11822. } else if miConfig.MdtrtareaAdmvs == "341203" {
  11823. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11824. var api string
  11825. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11826. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11827. resp, requestErr := http.Get(api)
  11828. if requestErr != nil {
  11829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11830. return
  11831. }
  11832. body, ioErr := ioutil.ReadAll(resp.Body)
  11833. if ioErr != nil {
  11834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11836. return
  11837. }
  11838. var respJSON map[string]interface{}
  11839. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11842. return
  11843. }
  11844. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11845. if status == "0" {
  11846. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11847. c.ServeSuccessJSON(map[string]interface{}{
  11848. "failed_code": -10,
  11849. "msg": err_msg,
  11850. })
  11851. return
  11852. }
  11853. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11854. result, _ := json.Marshal(respJSON)
  11855. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11856. utils.ErrorLog("解析失败:%v", err)
  11857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11858. return
  11859. }
  11860. } else if miConfig.MdtrtareaAdmvs == "340699" {
  11861. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  11862. var api string
  11863. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11864. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11865. resp, requestErr := http.Get(api)
  11866. if requestErr != nil {
  11867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11868. return
  11869. }
  11870. body, ioErr := ioutil.ReadAll(resp.Body)
  11871. if ioErr != nil {
  11872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11874. return
  11875. }
  11876. var respJSON map[string]interface{}
  11877. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11880. return
  11881. }
  11882. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11883. if status == "0" {
  11884. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11885. c.ServeSuccessJSON(map[string]interface{}{
  11886. "failed_code": -10,
  11887. "msg": err_msg,
  11888. })
  11889. return
  11890. }
  11891. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11892. result, _ := json.Marshal(respJSON)
  11893. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11894. utils.ErrorLog("解析失败:%v", err)
  11895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11896. return
  11897. }
  11898. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11899. p, _ := service.GetHisPatientById(patient_id)
  11900. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11901. var dat map[string]interface{}
  11902. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11903. fmt.Println(dat)
  11904. } else {
  11905. fmt.Println(err)
  11906. }
  11907. userJSONBytes, _ := json.Marshal(dat)
  11908. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11909. utils.ErrorLog("解析失败:%v", err)
  11910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11911. return
  11912. }
  11913. } else if miConfig.MdtrtareaAdmvs == "361025" {
  11914. p, _ := service.GetHisPatientById(patient_id)
  11915. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11916. var dat map[string]interface{}
  11917. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11918. fmt.Println(dat)
  11919. } else {
  11920. fmt.Println(err)
  11921. }
  11922. userJSONBytes, _ := json.Marshal(dat)
  11923. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11924. utils.ErrorLog("解析失败:%v", err)
  11925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11926. return
  11927. }
  11928. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11929. p, _ := service.GetHisPatientById(patient_id)
  11930. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11931. var dat map[string]interface{}
  11932. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11933. fmt.Println(dat)
  11934. } else {
  11935. fmt.Println(err)
  11936. }
  11937. userJSONBytes, _ := json.Marshal(dat)
  11938. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11939. utils.ErrorLog("解析失败:%v", err)
  11940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11941. return
  11942. }
  11943. } else if miConfig.MdtrtareaAdmvs == "420200" {
  11944. p, _ := service.GetHisPatientById(patient_id)
  11945. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  11946. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11947. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11948. resp, requestErr := http.Get(api)
  11949. if requestErr != nil {
  11950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11951. return
  11952. }
  11953. body, ioErr := ioutil.ReadAll(resp.Body)
  11954. if ioErr != nil {
  11955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11957. return
  11958. }
  11959. var respJSON map[string]interface{}
  11960. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11963. return
  11964. }
  11965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11966. result, _ := json.Marshal(respJSON)
  11967. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11968. utils.ErrorLog("解析失败:%v", err)
  11969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11970. return
  11971. }
  11972. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11973. p, _ := service.GetHisPatientById(patient_id)
  11974. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  11975. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11976. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11977. resp, requestErr := http.Get(api)
  11978. if requestErr != nil {
  11979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11980. return
  11981. }
  11982. body, ioErr := ioutil.ReadAll(resp.Body)
  11983. if ioErr != nil {
  11984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11986. return
  11987. }
  11988. var respJSON map[string]interface{}
  11989. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11992. return
  11993. }
  11994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11995. result, _ := json.Marshal(respJSON)
  11996. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11997. utils.ErrorLog("解析失败:%v", err)
  11998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11999. return
  12000. }
  12001. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12002. p, _ := service.GetHisPatientById(patient_id)
  12003. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12004. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12005. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12006. resp, requestErr := http.Get(api)
  12007. if requestErr != nil {
  12008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12009. return
  12010. }
  12011. body, ioErr := ioutil.ReadAll(resp.Body)
  12012. if ioErr != nil {
  12013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12015. return
  12016. }
  12017. var respJSON map[string]interface{}
  12018. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12021. return
  12022. }
  12023. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12024. result, _ := json.Marshal(respJSON)
  12025. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12026. utils.ErrorLog("解析失败:%v", err)
  12027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12028. return
  12029. }
  12030. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12031. p, _ := service.GetHisPatientById(patient_id)
  12032. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12033. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12034. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12035. resp, requestErr := http.Get(api)
  12036. if requestErr != nil {
  12037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12038. return
  12039. }
  12040. body, ioErr := ioutil.ReadAll(resp.Body)
  12041. if ioErr != nil {
  12042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12044. return
  12045. }
  12046. var respJSON map[string]interface{}
  12047. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12050. return
  12051. }
  12052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12053. result, _ := json.Marshal(respJSON)
  12054. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12055. utils.ErrorLog("解析失败:%v", err)
  12056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12057. return
  12058. }
  12059. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12060. p, _ := service.GetHisPatientById(patient_id)
  12061. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12062. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12063. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12064. resp, requestErr := http.Get(api)
  12065. if requestErr != nil {
  12066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12067. return
  12068. }
  12069. body, ioErr := ioutil.ReadAll(resp.Body)
  12070. if ioErr != nil {
  12071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12073. return
  12074. }
  12075. var respJSON map[string]interface{}
  12076. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12079. return
  12080. }
  12081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12082. result, _ := json.Marshal(respJSON)
  12083. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12084. utils.ErrorLog("解析失败:%v", err)
  12085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12086. return
  12087. }
  12088. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12089. p, _ := service.GetHisPatientById(patient_id)
  12090. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12091. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12092. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12093. resp, requestErr := http.Get(api)
  12094. if requestErr != nil {
  12095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12096. return
  12097. }
  12098. body, ioErr := ioutil.ReadAll(resp.Body)
  12099. if ioErr != nil {
  12100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12102. return
  12103. }
  12104. var respJSON map[string]interface{}
  12105. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12108. return
  12109. }
  12110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12111. result, _ := json.Marshal(respJSON)
  12112. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12113. utils.ErrorLog("解析失败:%v", err)
  12114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12115. return
  12116. }
  12117. } else {
  12118. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12119. var dat map[string]interface{}
  12120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12121. fmt.Println(dat)
  12122. } else {
  12123. fmt.Println(err)
  12124. }
  12125. userJSONBytes, _ := json.Marshal(dat)
  12126. if miConfig.Code == "H15049901371" {
  12127. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12128. utils.ErrorLog("解析失败:%v", err)
  12129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12130. return
  12131. }
  12132. res.InfRefmsgid = res10265.InfRefmsgid
  12133. res.Output = res10265.Output
  12134. res.ErrMsg = res10265.ErrMsg
  12135. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12136. res.Infcode = infocode
  12137. } else {
  12138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12139. utils.ErrorLog("解析失败:%v", err)
  12140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12141. return
  12142. }
  12143. }
  12144. }
  12145. if res.Infcode == 0 {
  12146. c.ServeSuccessJSON(map[string]interface{}{
  12147. "result": res.Output.Result,
  12148. })
  12149. }
  12150. }
  12151. func (c *HisApiController) CheckInsutype() {
  12152. his_patient_id, _ := c.GetInt64("his_patient_id")
  12153. admin_user_id, _ := c.GetInt64("admin_user_id")
  12154. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12155. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12156. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12157. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12158. var dat map[string]interface{}
  12159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12160. fmt.Println(dat)
  12161. } else {
  12162. fmt.Println(err)
  12163. }
  12164. userJSONBytes, _ := json.Marshal(dat)
  12165. var res Result90100
  12166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12167. utils.ErrorLog("解析失败:%v", err)
  12168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12169. return
  12170. }
  12171. if res.Infcode != 0 {
  12172. c.ServeSuccessJSON(map[string]interface{}{
  12173. "failed_code": -10,
  12174. "msg": res.ErrMsg,
  12175. })
  12176. return
  12177. } else {
  12178. fmt.Println(res)
  12179. }
  12180. }
  12181. func (c *HisApiController) CheckCardPWD() {
  12182. card_pwd := c.GetString("card_pwd")
  12183. his_patient_id, _ := c.GetInt64("his_patient_id")
  12184. admin_user_id, _ := c.GetInt64("admin_user_id")
  12185. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12186. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12187. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12188. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12189. bas := strings.Split(psn.CardInfo, "|")
  12190. basNumber := bas[2]
  12191. if psn.InsuplcAdmdvs[:4] == "4403" {
  12192. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12193. var dat map[string]interface{}
  12194. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12195. fmt.Println(dat)
  12196. } else {
  12197. fmt.Println(err)
  12198. }
  12199. userJSONBytes, _ := json.Marshal(dat)
  12200. var res Result90991
  12201. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12202. utils.ErrorLog("解析失败:%v", err)
  12203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12204. return
  12205. }
  12206. if res.Infcode != 0 {
  12207. c.ServeSuccessJSON(map[string]interface{}{
  12208. "failed_code": -10,
  12209. "msg": res.ErrMsg,
  12210. })
  12211. return
  12212. } else {
  12213. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12214. var msg string
  12215. switch res.Output.Result.CardStat {
  12216. case "00":
  12217. msg = "未激活"
  12218. break
  12219. case "10":
  12220. msg = "激活"
  12221. break
  12222. case "20":
  12223. msg = "窗口挂失"
  12224. break
  12225. case "21":
  12226. msg = "电话挂失"
  12227. break
  12228. case "22":
  12229. msg = "单位网上申报挂失"
  12230. break
  12231. case "23":
  12232. msg = "保健办挂失"
  12233. break
  12234. case "24":
  12235. msg = "个人网上挂失"
  12236. break
  12237. case "25":
  12238. msg = "网上服务大厅挂失"
  12239. break
  12240. case "30":
  12241. msg = "注销"
  12242. break
  12243. case "40":
  12244. msg = "回收"
  12245. break
  12246. case "99":
  12247. msg = "制卡中(无效卡)"
  12248. break
  12249. }
  12250. c.ServeSuccessJSON(map[string]interface{}{
  12251. "failed_code": -10,
  12252. "msg": msg,
  12253. })
  12254. return
  12255. } else {
  12256. c.ServeSuccessJSON(map[string]interface{}{
  12257. "msg": "校验成功",
  12258. })
  12259. return
  12260. }
  12261. }
  12262. } else {
  12263. c.ServeSuccessJSON(map[string]interface{}{
  12264. "msg": "校验成功",
  12265. })
  12266. return
  12267. }
  12268. }
  12269. func (c *HisApiController) CheckCardPWDTwo() {
  12270. //card_pwd := c.GetString("card_pwd")
  12271. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12272. admin_user_id, _ := c.GetInt64("admin_user_id")
  12273. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12274. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12275. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12276. var dat map[string]interface{}
  12277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12278. fmt.Println(dat)
  12279. } else {
  12280. fmt.Println(err)
  12281. }
  12282. userJSONBytes, _ := json.Marshal(dat)
  12283. var res Result90991
  12284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12285. utils.ErrorLog("解析失败:%v", err)
  12286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12287. return
  12288. }
  12289. if res.Infcode != 0 {
  12290. c.ServeSuccessJSON(map[string]interface{}{
  12291. "failed_code": -10,
  12292. "msg": res.ErrMsg,
  12293. })
  12294. return
  12295. } else {
  12296. if res.Output.Result.SscnoCheckStat == "0" {
  12297. var msg string
  12298. switch res.Output.Result.CardStat {
  12299. case "00":
  12300. msg = "未激活"
  12301. break
  12302. case "10":
  12303. msg = "激活"
  12304. break
  12305. case "20":
  12306. msg = "窗口挂失"
  12307. break
  12308. case "21":
  12309. msg = "电话挂失"
  12310. break
  12311. case "22":
  12312. msg = "单位网上申报挂失"
  12313. break
  12314. case "23":
  12315. msg = "保健办挂失"
  12316. break
  12317. case "24":
  12318. msg = "个人网上挂失"
  12319. break
  12320. case "25":
  12321. msg = "网上服务大厅挂失"
  12322. break
  12323. case "30":
  12324. msg = "注销"
  12325. break
  12326. case "40":
  12327. msg = "回收"
  12328. break
  12329. case "99":
  12330. msg = "制卡中(无效卡)"
  12331. break
  12332. }
  12333. c.ServeSuccessJSON(map[string]interface{}{
  12334. "failed_code": -10,
  12335. "msg": msg,
  12336. })
  12337. return
  12338. } else {
  12339. c.ServeSuccessJSON(map[string]interface{}{
  12340. "msg": "校验成功",
  12341. })
  12342. return
  12343. }
  12344. }
  12345. }
  12346. type ELeCertData struct {
  12347. Data struct {
  12348. Extra string `json:"extra"`
  12349. IDNo string `json:"idNo"`
  12350. IDType string `json:"idType"`
  12351. EcToken string `json:"ecToken"`
  12352. InsuOrg string `json:"insuOrg"`
  12353. UserName string `json:"userName"`
  12354. EcIndexNo string `json:"ecIndexNo"`
  12355. Gender string `json:"gender"`
  12356. Birthday string `json:"birthday"`
  12357. Nationality string `json:"nationality"`
  12358. Email string `json:"email"`
  12359. } `json:"OutData"`
  12360. }
  12361. func (c *HisApiController) ReadCard() {
  12362. id_card_type, _ := c.GetInt64("id_card_type")
  12363. admin_user_id, _ := c.GetInt64("admin_user_id")
  12364. certificates, _ := c.GetInt64("certificates")
  12365. //
  12366. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12367. id_card_no := c.GetString("id_card_no")
  12368. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12369. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12370. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12371. switch id_card_type {
  12372. case 1:
  12373. if miConfig.MdtrtareaAdmvs == "421300" {
  12374. var res ResultTwo
  12375. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12376. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12377. "&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)
  12378. resp, requestErr := http.Get(api)
  12379. if requestErr != nil {
  12380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12381. return
  12382. }
  12383. body, ioErr := ioutil.ReadAll(resp.Body)
  12384. if ioErr != nil {
  12385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12387. return
  12388. }
  12389. var respJSON map[string]interface{}
  12390. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12393. return
  12394. }
  12395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12396. result, _ := json.Marshal(respJSON)
  12397. fmt.Println("log")
  12398. fmt.Println(string(result))
  12399. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12400. utils.ErrorLog("解析失败:%v", err)
  12401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12402. return
  12403. }
  12404. if res.Infcode == 0 {
  12405. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12406. if err == gorm.ErrRecordNotFound {
  12407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12408. return
  12409. } else if err != nil {
  12410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12411. return
  12412. } else {
  12413. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12414. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12415. infoStr := string(Iinfos)
  12416. idetinfoStr := string(Idetinfos)
  12417. var rf []*ResultFive
  12418. json.Unmarshal([]byte(infoStr), &rf)
  12419. var insutypes []*ResultFive
  12420. var insutype string
  12421. var is390 int = 0
  12422. var is310 int = 0
  12423. for _, item := range rf {
  12424. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12425. insutypes = append(insutypes, item)
  12426. }
  12427. }
  12428. if len(insutypes) == 1 {
  12429. insutype = insutypes[0].Insutype
  12430. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12431. } else {
  12432. for _, i := range insutypes {
  12433. if i.Insutype == "390" {
  12434. is390 = 1
  12435. }
  12436. if i.Insutype == "310" {
  12437. is310 = 1
  12438. }
  12439. }
  12440. }
  12441. if is390 == 1 {
  12442. insutype = "390"
  12443. }
  12444. if is310 == 1 {
  12445. insutype = "310"
  12446. }
  12447. if len(insutypes) == 0 {
  12448. insutype = "390"
  12449. }
  12450. var insuplc_admdvs string
  12451. for _, item := range rf {
  12452. if item.Insutype == insutype {
  12453. insuplc_admdvs = item.InsuplcAdmdvs
  12454. }
  12455. }
  12456. if strings.Contains(insuplc_admdvs, "4213") {
  12457. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12458. }
  12459. psn := &models.HisPsn{
  12460. PsnNo: res.Output.Baseinfo.PsnNo,
  12461. PatientId: patient.ID,
  12462. Certno: res.Output.Baseinfo.Certno,
  12463. Gend: res.Output.Baseinfo.Gend,
  12464. Naty: res.Output.Baseinfo.Naty,
  12465. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12466. PsnName: res.Output.Baseinfo.PsnName,
  12467. Idetinfo: idetinfoStr,
  12468. Insuinfo: infoStr,
  12469. InsuplcAdmdvs: insuplc_admdvs,
  12470. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12471. }
  12472. service.CreateHisPsn(psn)
  12473. c.ServeSuccessJSON(map[string]interface{}{
  12474. "patient": patient,
  12475. "number": res.Output.Baseinfo.Certno,
  12476. })
  12477. }
  12478. } else {
  12479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12480. return
  12481. }
  12482. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12483. var res ResultTwo
  12484. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12485. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12486. "&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)
  12487. resp, requestErr := http.Get(api)
  12488. if requestErr != nil {
  12489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12490. return
  12491. }
  12492. body, ioErr := ioutil.ReadAll(resp.Body)
  12493. if ioErr != nil {
  12494. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12496. return
  12497. }
  12498. var respJSON map[string]interface{}
  12499. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12500. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12502. return
  12503. }
  12504. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12505. result, _ := json.Marshal(respJSON)
  12506. fmt.Println("log")
  12507. fmt.Println(string(result))
  12508. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12509. utils.ErrorLog("解析失败:%v", err)
  12510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12511. return
  12512. }
  12513. if res.Infcode == 0 {
  12514. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12515. if err == gorm.ErrRecordNotFound {
  12516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12517. return
  12518. } else if err != nil {
  12519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12520. return
  12521. } else {
  12522. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12523. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12524. infoStr := string(Iinfos)
  12525. idetinfoStr := string(Idetinfos)
  12526. psn := &models.HisPsn{
  12527. PsnNo: res.Output.Baseinfo.PsnNo,
  12528. PatientId: patient.ID,
  12529. Certno: res.Output.Baseinfo.Certno,
  12530. Gend: res.Output.Baseinfo.Gend,
  12531. Naty: res.Output.Baseinfo.Naty,
  12532. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12533. PsnName: res.Output.Baseinfo.PsnName,
  12534. Idetinfo: idetinfoStr,
  12535. Insuinfo: infoStr,
  12536. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12537. }
  12538. service.CreateHisPsn(psn)
  12539. var rf []*ResultFive
  12540. json.Unmarshal([]byte(infoStr), &rf)
  12541. var insutypes []*ResultFive
  12542. var insutype string
  12543. var is390 int = 0
  12544. var is310 int = 0
  12545. for _, item := range rf {
  12546. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12547. insutypes = append(insutypes, item)
  12548. }
  12549. }
  12550. if len(insutypes) == 1 {
  12551. insutype = insutypes[0].Insutype
  12552. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12553. } else {
  12554. for _, i := range insutypes {
  12555. if i.Insutype == "390" {
  12556. is390 = 1
  12557. }
  12558. if i.Insutype == "310" {
  12559. is310 = 1
  12560. }
  12561. }
  12562. }
  12563. if is390 == 1 {
  12564. insutype = "390"
  12565. }
  12566. if is310 == 1 {
  12567. insutype = "310"
  12568. }
  12569. if len(insutypes) == 0 {
  12570. insutype = "310"
  12571. }
  12572. c.ServeSuccessJSON(map[string]interface{}{
  12573. "patient": patient,
  12574. "number": res.Output.Baseinfo.Certno,
  12575. "insutype": insutype,
  12576. })
  12577. }
  12578. } else {
  12579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12580. return
  12581. }
  12582. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12583. var res ResultTwo
  12584. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12585. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12586. "&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)
  12587. resp, requestErr := http.Get(api)
  12588. if requestErr != nil {
  12589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12590. return
  12591. }
  12592. body, ioErr := ioutil.ReadAll(resp.Body)
  12593. if ioErr != nil {
  12594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12596. return
  12597. }
  12598. var respJSON map[string]interface{}
  12599. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12602. return
  12603. }
  12604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12605. result, _ := json.Marshal(respJSON)
  12606. fmt.Println("log")
  12607. fmt.Println(string(result))
  12608. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12609. utils.ErrorLog("解析失败:%v", err)
  12610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12611. return
  12612. }
  12613. if res.Infcode == 0 {
  12614. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12615. if err == gorm.ErrRecordNotFound {
  12616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12617. return
  12618. } else if err != nil {
  12619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12620. return
  12621. } else {
  12622. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12623. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12624. infoStr := string(Iinfos)
  12625. idetinfoStr := string(Idetinfos)
  12626. var rf []*ResultFive
  12627. json.Unmarshal([]byte(infoStr), &rf)
  12628. var insutypes []*ResultFive
  12629. var insutype string
  12630. var is390 int = 0
  12631. var is310 int = 0
  12632. for _, item := range rf {
  12633. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12634. insutypes = append(insutypes, item)
  12635. }
  12636. }
  12637. if len(insutypes) == 1 {
  12638. insutype = insutypes[0].Insutype
  12639. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12640. } else {
  12641. for _, i := range insutypes {
  12642. if i.Insutype == "390" {
  12643. is390 = 1
  12644. }
  12645. if i.Insutype == "310" {
  12646. is310 = 1
  12647. }
  12648. }
  12649. }
  12650. if is390 == 1 {
  12651. insutype = "390"
  12652. }
  12653. if is310 == 1 {
  12654. insutype = "310"
  12655. }
  12656. if len(insutypes) == 0 {
  12657. insutype = "390"
  12658. }
  12659. var insuplc_admdvs string
  12660. for _, item := range rf {
  12661. if item.Insutype == insutype {
  12662. insuplc_admdvs = item.InsuplcAdmdvs
  12663. }
  12664. }
  12665. psn := &models.HisPsn{
  12666. PsnNo: res.Output.Baseinfo.PsnNo,
  12667. PatientId: patient.ID,
  12668. Certno: res.Output.Baseinfo.Certno,
  12669. Gend: res.Output.Baseinfo.Gend,
  12670. Naty: res.Output.Baseinfo.Naty,
  12671. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12672. PsnName: res.Output.Baseinfo.PsnName,
  12673. Idetinfo: idetinfoStr,
  12674. Insuinfo: infoStr,
  12675. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12676. InsuplcAdmdvs: insuplc_admdvs,
  12677. }
  12678. service.CreateHisPsn(psn)
  12679. for _, item := range rf {
  12680. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12681. insutypes = append(insutypes, item)
  12682. }
  12683. }
  12684. if len(insutypes) == 1 {
  12685. insutype = insutypes[0].Insutype
  12686. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12687. } else {
  12688. for _, i := range insutypes {
  12689. if i.Insutype == "390" {
  12690. is390 = 1
  12691. }
  12692. if i.Insutype == "310" {
  12693. is310 = 1
  12694. }
  12695. }
  12696. }
  12697. if is390 == 1 {
  12698. insutype = "390"
  12699. }
  12700. if is310 == 1 {
  12701. insutype = "310"
  12702. }
  12703. if len(insutypes) == 0 {
  12704. insutype = "310"
  12705. }
  12706. c.ServeSuccessJSON(map[string]interface{}{
  12707. "patient": patient,
  12708. "number": res.Output.Baseinfo.Certno,
  12709. "insutype": insutype,
  12710. })
  12711. }
  12712. } else {
  12713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12714. return
  12715. }
  12716. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12717. var res ResultTwo
  12718. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  12719. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12720. "&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)
  12721. resp, requestErr := http.Get(api)
  12722. if requestErr != nil {
  12723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12724. return
  12725. }
  12726. body, ioErr := ioutil.ReadAll(resp.Body)
  12727. if ioErr != nil {
  12728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12730. return
  12731. }
  12732. var respJSON map[string]interface{}
  12733. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12736. return
  12737. }
  12738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12739. result, _ := json.Marshal(respJSON)
  12740. fmt.Println("log")
  12741. fmt.Println(string(result))
  12742. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12743. utils.ErrorLog("解析失败:%v", err)
  12744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12745. return
  12746. }
  12747. if res.Infcode == 0 {
  12748. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12749. if err == gorm.ErrRecordNotFound {
  12750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12751. return
  12752. } else if err != nil {
  12753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12754. return
  12755. } else {
  12756. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12757. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12758. infoStr := string(Iinfos)
  12759. idetinfoStr := string(Idetinfos)
  12760. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12761. psn := &models.HisPsn{
  12762. PsnNo: res.Output.Baseinfo.PsnNo,
  12763. PatientId: patient.ID,
  12764. Certno: res.Output.Baseinfo.Certno,
  12765. Brdy: b,
  12766. Age: float64(age),
  12767. Gend: res.Output.Baseinfo.Gend,
  12768. Naty: res.Output.Baseinfo.Naty,
  12769. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12770. PsnName: res.Output.Baseinfo.PsnName,
  12771. Idetinfo: idetinfoStr,
  12772. Insuinfo: infoStr,
  12773. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12774. }
  12775. service.CreateHisPsn(psn)
  12776. var rf []*ResultFive
  12777. json.Unmarshal([]byte(infoStr), &rf)
  12778. var insutypes []*ResultFive
  12779. var insutype string
  12780. var is390 int = 0
  12781. var is310 int = 0
  12782. for _, item := range rf {
  12783. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12784. insutypes = append(insutypes, item)
  12785. }
  12786. }
  12787. if len(insutypes) == 1 {
  12788. insutype = insutypes[0].Insutype
  12789. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12790. } else {
  12791. for _, i := range insutypes {
  12792. if i.Insutype == "390" {
  12793. is390 = 1
  12794. }
  12795. if i.Insutype == "310" {
  12796. is310 = 1
  12797. }
  12798. }
  12799. }
  12800. if is390 == 1 {
  12801. insutype = "390"
  12802. }
  12803. if is310 == 1 {
  12804. insutype = "310"
  12805. }
  12806. if len(insutypes) == 0 {
  12807. insutype = "310"
  12808. }
  12809. c.ServeSuccessJSON(map[string]interface{}{
  12810. "patient": patient,
  12811. "number": res.Output.Baseinfo.Certno,
  12812. "insutype": insutype,
  12813. })
  12814. }
  12815. } else {
  12816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12817. return
  12818. }
  12819. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12820. var api string
  12821. if miConfig.MdtrtareaAdmvs == "320921" {
  12822. 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 +
  12823. "&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
  12824. fmt.Println(api)
  12825. } else {
  12826. 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 +
  12827. "&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)
  12828. }
  12829. resp, requestErr := http.Get(api)
  12830. if requestErr != nil {
  12831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12832. return
  12833. }
  12834. body, ioErr := ioutil.ReadAll(resp.Body)
  12835. if ioErr != nil {
  12836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12838. return
  12839. }
  12840. var respJSON map[string]interface{}
  12841. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12844. return
  12845. }
  12846. var status string
  12847. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12848. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12849. //console.log()
  12850. fmt.Println("type===")
  12851. fmt.Println(card_type)
  12852. var token string
  12853. var res ResultTwo //1101结果
  12854. var res10265 ResultTwo10265 //1101结果
  12855. var card_info string //卡信息
  12856. var busi_card_info string
  12857. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12858. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12859. if status == "0" { //读卡成功
  12860. if card_type == "1" {
  12861. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12862. result, _ := json.Marshal(respJSON)
  12863. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12864. utils.ErrorLog("解析失败:%v", err)
  12865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12866. return
  12867. }
  12868. res.ErrMsg = res10265.ErrMsg
  12869. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12870. res.Infcode = infocode
  12871. res.Output = res10265.Output
  12872. res.InfRefmsgid = res10265.InfRefmsgid
  12873. } else {
  12874. //var card_info string //卡信息
  12875. //var busi_card_info string
  12876. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12877. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12878. //fmt.Println(card_info)
  12879. //fmt.Println(busi_card_info)
  12880. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12881. result, _ := json.Marshal(respJSON)
  12882. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12883. utils.ErrorLog("解析失败:%v", err)
  12884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12885. return
  12886. }
  12887. res.ErrMsg = res10265.ErrMsg
  12888. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12889. res.Infcode = infocode
  12890. res.Output = res10265.Output
  12891. res.InfRefmsgid = res10265.InfRefmsgid
  12892. }
  12893. if res.Infcode == 0 {
  12894. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12895. if err == gorm.ErrRecordNotFound {
  12896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12897. return
  12898. } else if err != nil {
  12899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12900. return
  12901. } else {
  12902. if card_type == "1" {
  12903. bas := strings.Split(card_info, "|")
  12904. basNumber := bas[2]
  12905. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12906. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12907. infoStr := string(Iinfos)
  12908. idetinfoStr := string(Idetinfos)
  12909. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12910. psn := &models.HisPsn{
  12911. PsnNo: res.Output.Baseinfo.PsnNo,
  12912. PatientId: patient.ID,
  12913. Certno: res.Output.Baseinfo.Certno,
  12914. Brdy: b,
  12915. Age: float64(age),
  12916. Gend: res.Output.Baseinfo.Gend,
  12917. Naty: res.Output.Baseinfo.Naty,
  12918. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12919. PsnName: res.Output.Baseinfo.PsnName,
  12920. Idetinfo: idetinfoStr,
  12921. Insuinfo: infoStr,
  12922. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12923. CardInfo: card_info,
  12924. VerifyNumber: busi_card_info,
  12925. }
  12926. service.CreateHisPsn(psn)
  12927. var rf []*ResultFive
  12928. json.Unmarshal([]byte(infoStr), &rf)
  12929. var insutypes []*ResultFive
  12930. var insutype string
  12931. var is390 int = 0
  12932. var is310 int = 0
  12933. for _, item := range rf {
  12934. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12935. insutypes = append(insutypes, item)
  12936. }
  12937. }
  12938. if len(insutypes) == 1 {
  12939. insutype = insutypes[0].Insutype
  12940. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12941. } else {
  12942. for _, i := range insutypes {
  12943. if i.Insutype == "390" {
  12944. is390 = 1
  12945. }
  12946. if i.Insutype == "310" {
  12947. is310 = 1
  12948. }
  12949. }
  12950. }
  12951. if is390 == 1 {
  12952. insutype = "390"
  12953. }
  12954. if is310 == 1 {
  12955. insutype = "310"
  12956. }
  12957. if len(insutypes) == 0 {
  12958. insutype = "310"
  12959. }
  12960. c.ServeSuccessJSON(map[string]interface{}{
  12961. "patient": patient,
  12962. "number": basNumber,
  12963. "insutype": insutype,
  12964. })
  12965. } else {
  12966. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12967. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12968. infoStr := string(Iinfos)
  12969. idetinfoStr := string(Idetinfos)
  12970. psn := &models.HisPsn{
  12971. PsnNo: res.Output.Baseinfo.PsnNo,
  12972. PatientId: patient.ID,
  12973. Certno: res.Output.Baseinfo.Certno,
  12974. Gend: res.Output.Baseinfo.Gend,
  12975. Naty: res.Output.Baseinfo.Naty,
  12976. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12977. PsnName: res.Output.Baseinfo.PsnName,
  12978. Idetinfo: idetinfoStr,
  12979. Insuinfo: infoStr,
  12980. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12981. CardInfo: card_info,
  12982. VerifyNumber: token,
  12983. }
  12984. service.CreateHisPsn(psn)
  12985. c.ServeSuccessJSON(map[string]interface{}{
  12986. "patient": patient,
  12987. "number": token,
  12988. })
  12989. }
  12990. }
  12991. } else {
  12992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12993. return
  12994. }
  12995. } else { //读卡失败
  12996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12997. return
  12998. }
  12999. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13000. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13001. cardnum = DeleteExtraSpaceTwo(cardnum)
  13002. cardCode = DeleteExtraSpaceTwo(cardCode)
  13003. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13004. name = DeleteExtraSpaceTwo(name)
  13005. errmsg = DeleteExtraSpaceTwo(errmsg)
  13006. cardnum = Remove0000(cardnum)
  13007. cardCode = Remove0000(cardCode)
  13008. id_card_no = Remove0000(id_card_no)
  13009. name = Remove0000(name)
  13010. errmsg = Remove0000(errmsg)
  13011. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13012. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13013. //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)
  13014. //fmt.Println(result2)
  13015. //fmt.Println(requestLog2)
  13016. //fmt.Println(errMsgLog2)
  13017. 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)
  13018. saveLog(result, requestLog, "1101", "获取人员信息")
  13019. fmt.Println(errMsgLog)
  13020. if len(errMsgLog) > 0 {
  13021. } else {
  13022. var dat map[string]interface{}
  13023. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13024. fmt.Println(dat)
  13025. } else {
  13026. fmt.Println(err)
  13027. }
  13028. userJSONBytes, _ := json.Marshal(dat)
  13029. var res ResultTwo
  13030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13031. utils.ErrorLog("解析失败:%v", err)
  13032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13033. return
  13034. }
  13035. res.ErrMsg = errMsgLog
  13036. if res.Infcode == 0 {
  13037. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13038. if err == gorm.ErrRecordNotFound {
  13039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13040. return
  13041. } else if err != nil {
  13042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13043. return
  13044. } else {
  13045. fmt.Println(res)
  13046. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13047. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13048. infoStr := string(Iinfos)
  13049. idetinfoStr := string(Idetinfos)
  13050. var rf []*ResultFive
  13051. json.Unmarshal([]byte(infoStr), &rf)
  13052. var insutypes []*ResultFive
  13053. var insutype string
  13054. var is390 int = 0
  13055. var is310 int = 0
  13056. for _, item := range rf {
  13057. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13058. insutypes = append(insutypes, item)
  13059. }
  13060. }
  13061. if len(insutypes) == 1 {
  13062. insutype = insutypes[0].Insutype
  13063. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13064. } else {
  13065. for _, i := range insutypes {
  13066. if i.Insutype == "390" {
  13067. is390 = 1
  13068. }
  13069. if i.Insutype == "310" {
  13070. is310 = 1
  13071. }
  13072. }
  13073. }
  13074. if is390 == 1 {
  13075. insutype = "390"
  13076. }
  13077. if is310 == 1 {
  13078. insutype = "310"
  13079. }
  13080. if len(insutypes) == 0 {
  13081. insutype = "390"
  13082. }
  13083. var insuplc_admdvs string
  13084. for _, item := range rf {
  13085. if item.Insutype == insutype {
  13086. insuplc_admdvs = item.InsuplcAdmdvs
  13087. }
  13088. }
  13089. psn := &models.HisPsn{
  13090. PsnNo: res.Output.Baseinfo.PsnNo,
  13091. PatientId: patient.ID,
  13092. Certno: res.Output.Baseinfo.Certno,
  13093. Gend: res.Output.Baseinfo.Gend,
  13094. Naty: res.Output.Baseinfo.Naty,
  13095. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13096. PsnName: res.Output.Baseinfo.PsnName,
  13097. Idetinfo: idetinfoStr,
  13098. Insuinfo: infoStr,
  13099. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13100. CardInfo: basStr,
  13101. VerifyNumber: "",
  13102. InsuplcAdmdvs: insuplc_admdvs,
  13103. }
  13104. service.CreateHisPsn(psn)
  13105. c.ServeSuccessJSON(map[string]interface{}{
  13106. "patient": patient,
  13107. "number": cardnum,
  13108. "insutype": insutype,
  13109. })
  13110. }
  13111. } else {
  13112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13113. return
  13114. }
  13115. }
  13116. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13117. fmt.Println(initFlag)
  13118. fmt.Println("initFlag")
  13119. if initFlag == 0 {
  13120. c.TestGetJiangXiBasBaseInit()
  13121. }
  13122. basStr := c.GetBasBaseInfo()
  13123. if len(basStr) == 0 {
  13124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13125. return
  13126. }
  13127. fmt.Println(basStr)
  13128. bas := strings.Split(basStr, "|")
  13129. basNumber := bas[1]
  13130. fmt.Println(basNumber)
  13131. card_sn := bas[3]
  13132. fmt.Println(card_sn)
  13133. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13134. 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)
  13135. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13136. var dat map[string]interface{}
  13137. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13138. fmt.Println(dat)
  13139. } else {
  13140. fmt.Println(err)
  13141. }
  13142. userJSONBytes, _ := json.Marshal(dat)
  13143. var res ResultTwo
  13144. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13145. utils.ErrorLog("解析失败:%v", err)
  13146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13147. return
  13148. }
  13149. if res.Infcode == 0 {
  13150. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13151. if err == gorm.ErrRecordNotFound {
  13152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13153. return
  13154. } else if err != nil {
  13155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13156. return
  13157. } else {
  13158. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13159. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13160. infoStr := string(Iinfos)
  13161. idetinfoStr := string(Idetinfos)
  13162. var rf []*ResultFive
  13163. json.Unmarshal([]byte(infoStr), &rf)
  13164. var insutypes []*ResultFive
  13165. var insutype string
  13166. var is390 int = 0
  13167. var is310 int = 0
  13168. var insuplc_admdvs string
  13169. for _, item := range rf {
  13170. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13171. insutypes = append(insutypes, item)
  13172. }
  13173. }
  13174. if len(insutypes) == 1 {
  13175. insutype = insutypes[0].Insutype
  13176. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13177. } else {
  13178. for _, i := range insutypes {
  13179. if i.Insutype == "390" {
  13180. is390 = 1
  13181. }
  13182. if i.Insutype == "310" {
  13183. is310 = 1
  13184. }
  13185. }
  13186. }
  13187. if is390 == 1 {
  13188. insutype = "390"
  13189. }
  13190. if is310 == 1 {
  13191. insutype = "310"
  13192. }
  13193. if len(insutypes) == 0 {
  13194. insutype = "310"
  13195. }
  13196. for _, item := range rf {
  13197. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13198. insuplc_admdvs = item.InsuplcAdmdvs
  13199. }
  13200. }
  13201. psn := &models.HisPsn{
  13202. PsnNo: res.Output.Baseinfo.PsnNo,
  13203. PatientId: patient.ID,
  13204. Certno: res.Output.Baseinfo.Certno,
  13205. Gend: res.Output.Baseinfo.Gend,
  13206. Naty: res.Output.Baseinfo.Naty,
  13207. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13208. PsnName: res.Output.Baseinfo.PsnName,
  13209. Idetinfo: idetinfoStr,
  13210. Insuinfo: infoStr,
  13211. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13212. CardInfo: basStr,
  13213. InsuplcAdmdvs: insuplc_admdvs,
  13214. VerifyNumber: "",
  13215. }
  13216. service.CreateHisPsn(psn)
  13217. c.ServeSuccessJSON(map[string]interface{}{
  13218. "patient": patient,
  13219. "number": basNumber,
  13220. "insutype": insutype,
  13221. })
  13222. }
  13223. } else {
  13224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13225. return
  13226. }
  13227. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13228. basStr := c.GetBasBaseInfo22222()
  13229. fmt.Println(basStr)
  13230. if len(basStr) == 0 {
  13231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13232. return
  13233. }
  13234. fmt.Println(basStr)
  13235. bas := strings.Split(basStr, "|")
  13236. basNumber := bas[2] //卡号
  13237. card_sn := bas[3] //
  13238. id_card_No := bas[1] //卡号
  13239. fmt.Println(basNumber)
  13240. fmt.Println(card_sn)
  13241. fmt.Println(id_card_No)
  13242. var patient service.Patients
  13243. if len(id_card_No) == 0 {
  13244. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13245. } else {
  13246. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13247. }
  13248. 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)
  13249. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13250. var dat map[string]interface{}
  13251. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13252. fmt.Println(dat)
  13253. } else {
  13254. fmt.Println(err)
  13255. }
  13256. userJSONBytes, _ := json.Marshal(dat)
  13257. var res ResultTwo
  13258. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13259. utils.ErrorLog("解析失败:%v", err)
  13260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13261. return
  13262. }
  13263. if res.Infcode == 0 {
  13264. var pateint2 service.Patients
  13265. var err error
  13266. if len(id_card_No) == 0 {
  13267. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13268. } else {
  13269. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13270. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13271. }
  13272. if err == gorm.ErrRecordNotFound {
  13273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13274. return
  13275. } else if err != nil {
  13276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13277. return
  13278. } else {
  13279. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13280. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13281. infoStr := string(Iinfos)
  13282. idetinfoStr := string(Idetinfos)
  13283. var rf []*ResultFive
  13284. json.Unmarshal([]byte(infoStr), &rf)
  13285. var insutypes []*ResultFive
  13286. var insutype string
  13287. var is390 int = 0
  13288. var is310 int = 0
  13289. var insuplc_admdvs string
  13290. for _, item := range rf {
  13291. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13292. insutypes = append(insutypes, item)
  13293. }
  13294. }
  13295. if len(insutypes) == 1 {
  13296. insutype = insutypes[0].Insutype
  13297. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13298. } else {
  13299. for _, i := range insutypes {
  13300. if i.Insutype == "390" {
  13301. is390 = 1
  13302. }
  13303. if i.Insutype == "310" {
  13304. is310 = 1
  13305. }
  13306. }
  13307. }
  13308. if is390 == 1 {
  13309. insutype = "390"
  13310. }
  13311. if is310 == 1 {
  13312. insutype = "310"
  13313. }
  13314. if len(insutypes) == 0 {
  13315. insutype = "310"
  13316. }
  13317. for _, item := range rf {
  13318. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13319. insuplc_admdvs = item.InsuplcAdmdvs
  13320. }
  13321. }
  13322. psn := &models.HisPsn{
  13323. PsnNo: res.Output.Baseinfo.PsnNo,
  13324. PatientId: pateint2.ID,
  13325. Certno: res.Output.Baseinfo.Certno,
  13326. Gend: res.Output.Baseinfo.Gend,
  13327. Naty: res.Output.Baseinfo.Naty,
  13328. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13329. PsnName: res.Output.Baseinfo.PsnName,
  13330. Idetinfo: idetinfoStr,
  13331. Insuinfo: infoStr,
  13332. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13333. CardInfo: basStr,
  13334. InsuplcAdmdvs: insuplc_admdvs,
  13335. VerifyNumber: "",
  13336. }
  13337. service.CreateHisPsn(psn)
  13338. c.ServeSuccessJSON(map[string]interface{}{
  13339. "patient": patient,
  13340. "number": basNumber,
  13341. "insutype": insutype,
  13342. })
  13343. }
  13344. } else {
  13345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13346. return
  13347. }
  13348. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13349. fmt.Println(initFlag)
  13350. fmt.Println("initFlag")
  13351. if initFlag == 0 {
  13352. c.TestGetHnBasBaseInit()
  13353. }
  13354. basStr := c.GetBasBaseInfo()
  13355. if len(basStr) == 0 {
  13356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13357. return
  13358. }
  13359. fmt.Println(basStr)
  13360. bas := strings.Split(basStr, "|")
  13361. basNumber := bas[1]
  13362. fmt.Println(basNumber)
  13363. card_sn := bas[3]
  13364. card_no := bas[2]
  13365. fmt.Println(card_sn)
  13366. name := bas[4]
  13367. name = ConvertToString(name, "gbk", "utf-8")
  13368. 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)
  13369. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13370. var dat map[string]interface{}
  13371. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13372. fmt.Println(dat)
  13373. } else {
  13374. fmt.Println(err)
  13375. }
  13376. userJSONBytes, _ := json.Marshal(dat)
  13377. var res ResultTwo
  13378. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13379. utils.ErrorLog("解析失败:%v", err)
  13380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13381. return
  13382. }
  13383. if res.Infcode == 0 {
  13384. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13385. if err == gorm.ErrRecordNotFound {
  13386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13387. return
  13388. } else if err != nil {
  13389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13390. return
  13391. } else {
  13392. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13393. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13394. infoStr := string(Iinfos)
  13395. idetinfoStr := string(Idetinfos)
  13396. psn := &models.HisPsn{
  13397. PsnNo: res.Output.Baseinfo.PsnNo,
  13398. PatientId: patient.ID,
  13399. Certno: res.Output.Baseinfo.Certno,
  13400. Gend: res.Output.Baseinfo.Gend,
  13401. Naty: res.Output.Baseinfo.Naty,
  13402. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13403. PsnName: res.Output.Baseinfo.PsnName,
  13404. Idetinfo: idetinfoStr,
  13405. Insuinfo: infoStr,
  13406. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13407. CardInfo: basStr,
  13408. VerifyNumber: "",
  13409. }
  13410. service.CreateHisPsn(psn)
  13411. var rf []*ResultFive
  13412. json.Unmarshal([]byte(infoStr), &rf)
  13413. var insutypes []*ResultFive
  13414. var insutype string
  13415. var is390 int = 0
  13416. var is310 int = 0
  13417. for _, item := range rf {
  13418. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13419. insutypes = append(insutypes, item)
  13420. }
  13421. }
  13422. if len(insutypes) == 1 {
  13423. insutype = insutypes[0].Insutype
  13424. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13425. } else {
  13426. for _, i := range insutypes {
  13427. if i.Insutype == "390" {
  13428. is390 = 1
  13429. }
  13430. if i.Insutype == "310" {
  13431. is310 = 1
  13432. }
  13433. }
  13434. }
  13435. if is390 == 1 {
  13436. insutype = "390"
  13437. }
  13438. if is310 == 1 {
  13439. insutype = "310"
  13440. }
  13441. if len(insutypes) == 0 {
  13442. insutype = "310"
  13443. }
  13444. c.ServeSuccessJSON(map[string]interface{}{
  13445. "patient": patient,
  13446. "number": basNumber,
  13447. "insutype": insutype,
  13448. })
  13449. }
  13450. } else {
  13451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13452. return
  13453. }
  13454. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13455. var api string
  13456. 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 +
  13457. "&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
  13458. fmt.Println(api)
  13459. resp, requestErr := http.Get(api)
  13460. if requestErr != nil {
  13461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13462. return
  13463. }
  13464. body, ioErr := ioutil.ReadAll(resp.Body)
  13465. if ioErr != nil {
  13466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13468. return
  13469. }
  13470. var respJSON map[string]interface{}
  13471. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13474. return
  13475. }
  13476. var res ResultTwo //1101结果
  13477. var res10265 ResultTwo10265 //1101结果
  13478. var card_info string //卡信息
  13479. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13480. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13481. result, _ := json.Marshal(respJSON)
  13482. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13483. utils.ErrorLog("解析失败:%v", err)
  13484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13485. return
  13486. }
  13487. res.ErrMsg = res10265.ErrMsg
  13488. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13489. res.Infcode = infocode
  13490. res.Output = res10265.Output
  13491. res.InfRefmsgid = res10265.InfRefmsgid
  13492. if res.Infcode == 0 {
  13493. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13494. if err == gorm.ErrRecordNotFound {
  13495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13496. return
  13497. } else if err != nil {
  13498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13499. return
  13500. } else {
  13501. bas := strings.Split(card_info, "|")
  13502. basNumber := bas[2]
  13503. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13504. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13505. infoStr := string(Iinfos)
  13506. idetinfoStr := string(Idetinfos)
  13507. psn := &models.HisPsn{
  13508. PsnNo: res.Output.Baseinfo.PsnNo,
  13509. PatientId: patient.ID,
  13510. Certno: res.Output.Baseinfo.Certno,
  13511. Gend: res.Output.Baseinfo.Gend,
  13512. Naty: res.Output.Baseinfo.Naty,
  13513. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13514. PsnName: res.Output.Baseinfo.PsnName,
  13515. Idetinfo: idetinfoStr,
  13516. Insuinfo: infoStr,
  13517. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13518. CardInfo: card_info,
  13519. VerifyNumber: token,
  13520. }
  13521. service.CreateHisPsn(psn)
  13522. var rf []*ResultFive
  13523. json.Unmarshal([]byte(infoStr), &rf)
  13524. var insutypes []*ResultFive
  13525. var insutype string
  13526. var is390 int = 0
  13527. var is310 int = 0
  13528. for _, item := range rf {
  13529. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13530. insutypes = append(insutypes, item)
  13531. }
  13532. }
  13533. if len(insutypes) == 1 {
  13534. insutype = insutypes[0].Insutype
  13535. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13536. } else {
  13537. for _, i := range insutypes {
  13538. if i.Insutype == "390" {
  13539. is390 = 1
  13540. }
  13541. if i.Insutype == "310" {
  13542. is310 = 1
  13543. }
  13544. }
  13545. }
  13546. if is390 == 1 {
  13547. insutype = "390"
  13548. }
  13549. if is310 == 1 {
  13550. insutype = "310"
  13551. }
  13552. if len(insutypes) == 0 {
  13553. insutype = "310"
  13554. }
  13555. c.ServeSuccessJSON(map[string]interface{}{
  13556. "patient": patient,
  13557. "number": basNumber,
  13558. "insutype": insutype,
  13559. })
  13560. }
  13561. } else {
  13562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13563. return
  13564. }
  13565. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13566. res := c.GetoleInfo()
  13567. if res.Infcode == 0 {
  13568. var result string
  13569. if res.Output.MdtrtCertType == "01" {
  13570. 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)
  13571. } else if res.Output.MdtrtCertType == "02" {
  13572. 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)
  13573. } else if res.Output.MdtrtCertType == "03" {
  13574. 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)
  13575. }
  13576. var dat map[string]interface{}
  13577. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13578. fmt.Println(dat)
  13579. } else {
  13580. fmt.Println(err)
  13581. }
  13582. userJSONBytes, _ := json.Marshal(dat)
  13583. var res2 ResultTwo
  13584. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13585. utils.ErrorLog("解析失败:%v", err)
  13586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13587. return
  13588. }
  13589. if res2.Infcode == 0 {
  13590. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13591. if err == gorm.ErrRecordNotFound {
  13592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13593. return
  13594. } else if err != nil {
  13595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13596. return
  13597. } else {
  13598. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13599. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13600. infoStr := string(Iinfos)
  13601. idetinfoStr := string(Idetinfos)
  13602. var rf []*ResultFive
  13603. json.Unmarshal([]byte(infoStr), &rf)
  13604. var insutypes []*ResultFive
  13605. var insutype string
  13606. var is390 int = 0
  13607. var is310 int = 0
  13608. //var insuplc_admdvs string
  13609. for _, item := range rf {
  13610. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13611. insutypes = append(insutypes, item)
  13612. }
  13613. }
  13614. if len(insutypes) == 1 {
  13615. insutype = insutypes[0].Insutype
  13616. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13617. } else {
  13618. for _, i := range insutypes {
  13619. if i.Insutype == "390" {
  13620. is390 = 1
  13621. }
  13622. if i.Insutype == "310" {
  13623. is310 = 1
  13624. }
  13625. }
  13626. }
  13627. if is390 == 1 {
  13628. insutype = "390"
  13629. }
  13630. if is310 == 1 {
  13631. insutype = "310"
  13632. }
  13633. if len(insutypes) == 0 {
  13634. insutype = "310"
  13635. }
  13636. psn := &models.HisPsn{
  13637. PsnNo: res2.Output.Baseinfo.PsnNo,
  13638. PatientId: patient.ID,
  13639. Certno: res2.Output.Baseinfo.Certno,
  13640. Gend: res2.Output.Baseinfo.Gend,
  13641. Naty: res2.Output.Baseinfo.Naty,
  13642. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13643. PsnName: res2.Output.Baseinfo.PsnName,
  13644. Idetinfo: idetinfoStr,
  13645. Insuinfo: infoStr,
  13646. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13647. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13648. VerifyNumber: res.Output.EcToken,
  13649. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13650. }
  13651. if res.Output.MdtrtCertType == "01" {
  13652. psn.VerifyNumber = res.Output.EcToken
  13653. //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)
  13654. } else if res.Output.MdtrtCertType == "02" {
  13655. psn.VerifyNumber = res.Output.MdtrtCertNo
  13656. //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)
  13657. } else if res.Output.MdtrtCertType == "03" {
  13658. psn.VerifyNumber = res.Output.MdtrtCertNo
  13659. //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)
  13660. }
  13661. var balc float64
  13662. for _, item := range rf {
  13663. if item.Insutype == insutype {
  13664. balc = item.Balc
  13665. }
  13666. }
  13667. service.CreateHisPsn(psn)
  13668. c.ServeSuccessJSON(map[string]interface{}{
  13669. "patient": patient,
  13670. "number": res.Output.CardNo,
  13671. "insutype": insutype,
  13672. "blac": balc,
  13673. "desc": idetinfoStr,
  13674. })
  13675. }
  13676. } else {
  13677. c.ServeSuccessJSON(map[string]interface{}{
  13678. "failed_code": -10,
  13679. "msg": res2.ErrMsg,
  13680. })
  13681. }
  13682. } else {
  13683. c.ServeSuccessJSON(map[string]interface{}{
  13684. "failed_code": -10,
  13685. "msg": res.ErrMsg,
  13686. })
  13687. }
  13688. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13689. var api string
  13690. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13691. "&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
  13692. fmt.Println(api)
  13693. resp, requestErr := http.Get(api)
  13694. if requestErr != nil {
  13695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13696. return
  13697. }
  13698. body, ioErr := ioutil.ReadAll(resp.Body)
  13699. if ioErr != nil {
  13700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13702. return
  13703. }
  13704. var respJSON map[string]interface{}
  13705. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13708. return
  13709. }
  13710. var status string
  13711. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13712. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13713. //console.log()
  13714. fmt.Println("type===")
  13715. fmt.Println(card_type)
  13716. var token string
  13717. var res ResultTwo //1101结果
  13718. //var res10265 ResultTwoesultTwo10265 //1101结果
  13719. var card_info string //卡信息
  13720. var busi_card_info string
  13721. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13722. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13723. if status == "0" { //读卡成功
  13724. if card_type == "1" {
  13725. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13726. result, _ := json.Marshal(respJSON)
  13727. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13728. utils.ErrorLog("解析失败:%v", err)
  13729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13730. return
  13731. }
  13732. } else {
  13733. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13734. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13735. result, _ := json.Marshal(respJSON)
  13736. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13737. utils.ErrorLog("解析失败:%v", err)
  13738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13739. return
  13740. }
  13741. }
  13742. if res.Infcode == 0 {
  13743. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13744. if err == gorm.ErrRecordNotFound {
  13745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13746. return
  13747. } else if err != nil {
  13748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13749. return
  13750. } else {
  13751. if card_type == "1" {
  13752. bas := strings.Split(card_info, "|")
  13753. basNumber := bas[2]
  13754. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13755. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13756. infoStr := string(Iinfos)
  13757. idetinfoStr := string(Idetinfos)
  13758. psn := &models.HisPsn{
  13759. PsnNo: res.Output.Baseinfo.PsnNo,
  13760. PatientId: patient.ID,
  13761. Certno: res.Output.Baseinfo.Certno,
  13762. Gend: res.Output.Baseinfo.Gend,
  13763. Naty: res.Output.Baseinfo.Naty,
  13764. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13765. PsnName: res.Output.Baseinfo.PsnName,
  13766. Idetinfo: idetinfoStr,
  13767. Insuinfo: infoStr,
  13768. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13769. CardInfo: card_info,
  13770. VerifyNumber: busi_card_info,
  13771. }
  13772. service.CreateHisPsn(psn)
  13773. var rf []*ResultFive
  13774. json.Unmarshal([]byte(infoStr), &rf)
  13775. var insutypes []*ResultFive
  13776. var insutype string
  13777. var is390 int = 0
  13778. var is310 int = 0
  13779. for _, item := range rf {
  13780. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13781. insutypes = append(insutypes, item)
  13782. }
  13783. }
  13784. if len(insutypes) == 1 {
  13785. insutype = insutypes[0].Insutype
  13786. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13787. } else {
  13788. for _, i := range insutypes {
  13789. if i.Insutype == "390" {
  13790. is390 = 1
  13791. }
  13792. if i.Insutype == "310" {
  13793. is310 = 1
  13794. }
  13795. }
  13796. }
  13797. if is390 == 1 {
  13798. insutype = "390"
  13799. }
  13800. if is310 == 1 {
  13801. insutype = "310"
  13802. }
  13803. if len(insutypes) == 0 {
  13804. insutype = "310"
  13805. }
  13806. c.ServeSuccessJSON(map[string]interface{}{
  13807. "patient": patient,
  13808. "number": basNumber,
  13809. "insutype": insutype,
  13810. })
  13811. } else {
  13812. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13813. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13814. infoStr := string(Iinfos)
  13815. idetinfoStr := string(Idetinfos)
  13816. psn := &models.HisPsn{
  13817. PsnNo: res.Output.Baseinfo.PsnNo,
  13818. PatientId: patient.ID,
  13819. Certno: res.Output.Baseinfo.Certno,
  13820. Gend: res.Output.Baseinfo.Gend,
  13821. Naty: res.Output.Baseinfo.Naty,
  13822. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13823. PsnName: res.Output.Baseinfo.PsnName,
  13824. Idetinfo: idetinfoStr,
  13825. Insuinfo: infoStr,
  13826. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13827. CardInfo: card_info,
  13828. VerifyNumber: token,
  13829. }
  13830. service.CreateHisPsn(psn)
  13831. c.ServeSuccessJSON(map[string]interface{}{
  13832. "patient": patient,
  13833. "number": token,
  13834. })
  13835. }
  13836. }
  13837. } else {
  13838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13839. return
  13840. }
  13841. } else { //读卡失败
  13842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13843. return
  13844. }
  13845. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13846. var api string
  13847. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13848. "&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
  13849. fmt.Println(api)
  13850. resp, requestErr := http.Get(api)
  13851. if requestErr != nil {
  13852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13853. return
  13854. }
  13855. body, ioErr := ioutil.ReadAll(resp.Body)
  13856. if ioErr != nil {
  13857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13859. return
  13860. }
  13861. var respJSON map[string]interface{}
  13862. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13865. return
  13866. }
  13867. var status string
  13868. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13869. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13870. //console.log()
  13871. fmt.Println("type===")
  13872. fmt.Println(card_type)
  13873. var token string
  13874. var res ResultTwo //1101结果
  13875. //var res10265 ResultTwoesultTwo10265 //1101结果
  13876. var card_info string //卡信息
  13877. //var busi_card_info string
  13878. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13879. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13880. if status == "0" { //读卡成功
  13881. if card_type == "1" {
  13882. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13883. result, _ := json.Marshal(respJSON)
  13884. fmt.Println(result)
  13885. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13886. utils.ErrorLog("解析失败:%v", err)
  13887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13888. return
  13889. }
  13890. fmt.Println(res)
  13891. } else {
  13892. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13893. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13894. result, _ := json.Marshal(respJSON)
  13895. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13896. utils.ErrorLog("解析失败:%v", err)
  13897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13898. return
  13899. }
  13900. }
  13901. if res.Infcode == 0 {
  13902. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13903. if err == gorm.ErrRecordNotFound {
  13904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13905. return
  13906. } else if err != nil {
  13907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13908. return
  13909. } else {
  13910. if card_type == "1" {
  13911. bas := strings.Split(card_info, "|")
  13912. basNumber := bas[2]
  13913. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13914. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13915. infoStr := string(Iinfos)
  13916. idetinfoStr := string(Idetinfos)
  13917. psn := &models.HisPsn{
  13918. PsnNo: res.Output.Baseinfo.PsnNo,
  13919. PatientId: patient.ID,
  13920. Certno: res.Output.Baseinfo.Certno,
  13921. Gend: res.Output.Baseinfo.Gend,
  13922. Naty: res.Output.Baseinfo.Naty,
  13923. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13924. PsnName: res.Output.Baseinfo.PsnName,
  13925. Idetinfo: idetinfoStr,
  13926. Insuinfo: infoStr,
  13927. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13928. CardInfo: card_info,
  13929. //VerifyNumber: busi_card_info,
  13930. }
  13931. service.CreateHisPsn(psn)
  13932. var rf []*ResultFive
  13933. json.Unmarshal([]byte(infoStr), &rf)
  13934. var insutypes []*ResultFive
  13935. var insutype string
  13936. var is390 int = 0
  13937. var is310 int = 0
  13938. for _, item := range rf {
  13939. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13940. insutypes = append(insutypes, item)
  13941. }
  13942. }
  13943. if len(insutypes) == 1 {
  13944. insutype = insutypes[0].Insutype
  13945. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13946. } else {
  13947. for _, i := range insutypes {
  13948. if i.Insutype == "390" {
  13949. is390 = 1
  13950. }
  13951. if i.Insutype == "310" {
  13952. is310 = 1
  13953. }
  13954. }
  13955. }
  13956. if is390 == 1 {
  13957. insutype = "390"
  13958. }
  13959. if is310 == 1 {
  13960. insutype = "310"
  13961. }
  13962. if len(insutypes) == 0 {
  13963. insutype = "310"
  13964. }
  13965. c.ServeSuccessJSON(map[string]interface{}{
  13966. "patient": patient,
  13967. "number": basNumber,
  13968. "insutype": insutype,
  13969. })
  13970. } else {
  13971. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13972. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13973. infoStr := string(Iinfos)
  13974. idetinfoStr := string(Idetinfos)
  13975. psn := &models.HisPsn{
  13976. PsnNo: res.Output.Baseinfo.PsnNo,
  13977. PatientId: patient.ID,
  13978. Certno: res.Output.Baseinfo.Certno,
  13979. Gend: res.Output.Baseinfo.Gend,
  13980. Naty: res.Output.Baseinfo.Naty,
  13981. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13982. PsnName: res.Output.Baseinfo.PsnName,
  13983. Idetinfo: idetinfoStr,
  13984. Insuinfo: infoStr,
  13985. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13986. CardInfo: card_info,
  13987. VerifyNumber: token,
  13988. }
  13989. service.CreateHisPsn(psn)
  13990. c.ServeSuccessJSON(map[string]interface{}{
  13991. "patient": patient,
  13992. "number": token,
  13993. })
  13994. }
  13995. }
  13996. } else {
  13997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13998. return
  13999. }
  14000. } else { //读卡失败
  14001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14002. return
  14003. }
  14004. } else {
  14005. if initFlag == 0 {
  14006. c.TestGetBasBaseInit()
  14007. }
  14008. basStr := c.GetBasBaseInfo()
  14009. if len(basStr) == 0 {
  14010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14011. return
  14012. }
  14013. fmt.Println(basStr)
  14014. bas := strings.Split(basStr, "|")
  14015. basNumber := bas[1]
  14016. fmt.Println(basNumber)
  14017. card_sn := bas[3]
  14018. fmt.Println(card_sn)
  14019. cardNumber := bas[2]
  14020. fmt.Println(cardNumber)
  14021. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14022. var result string
  14023. if bas[0][:2] == "44" {
  14024. 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)
  14025. } else {
  14026. 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)
  14027. }
  14028. var dat map[string]interface{}
  14029. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14030. fmt.Println(dat)
  14031. } else {
  14032. fmt.Println(err)
  14033. }
  14034. userJSONBytes, _ := json.Marshal(dat)
  14035. var res ResultTwo
  14036. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14037. utils.ErrorLog("解析失败:%v", err)
  14038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14039. return
  14040. }
  14041. if res.Infcode == 0 {
  14042. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14043. if err == gorm.ErrRecordNotFound {
  14044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14045. return
  14046. } else if err != nil {
  14047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14048. return
  14049. } else {
  14050. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14051. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14052. infoStr := string(Iinfos)
  14053. idetinfoStr := string(Idetinfos)
  14054. var rf []*ResultFive
  14055. json.Unmarshal([]byte(infoStr), &rf)
  14056. var insutypes []*ResultFive
  14057. var insutype string
  14058. var is390 int = 0
  14059. var is310 int = 0
  14060. var insuplc_admdvs string
  14061. for _, item := range rf {
  14062. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14063. insutypes = append(insutypes, item)
  14064. }
  14065. }
  14066. if len(insutypes) == 1 {
  14067. insutype = insutypes[0].Insutype
  14068. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14069. } else {
  14070. for _, i := range insutypes {
  14071. if i.Insutype == "390" {
  14072. is390 = 1
  14073. }
  14074. if i.Insutype == "310" {
  14075. is310 = 1
  14076. }
  14077. }
  14078. }
  14079. if is390 == 1 {
  14080. insutype = "390"
  14081. }
  14082. if is310 == 1 {
  14083. insutype = "310"
  14084. }
  14085. if len(insutypes) == 0 {
  14086. insutype = "310"
  14087. }
  14088. for _, item := range rf {
  14089. if item.Insutype == insutype {
  14090. insuplc_admdvs = item.InsuplcAdmdvs
  14091. }
  14092. }
  14093. psn := &models.HisPsn{
  14094. PsnNo: res.Output.Baseinfo.PsnNo,
  14095. PatientId: patient.ID,
  14096. Certno: res.Output.Baseinfo.Certno,
  14097. Gend: res.Output.Baseinfo.Gend,
  14098. Naty: res.Output.Baseinfo.Naty,
  14099. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14100. PsnName: res.Output.Baseinfo.PsnName,
  14101. Idetinfo: idetinfoStr,
  14102. Insuinfo: infoStr,
  14103. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14104. CardInfo: basStr,
  14105. VerifyNumber: "",
  14106. InsuplcAdmdvs: insuplc_admdvs,
  14107. }
  14108. service.CreateHisPsn(psn)
  14109. c.ServeSuccessJSON(map[string]interface{}{
  14110. "patient": patient,
  14111. "number": basNumber,
  14112. })
  14113. }
  14114. } else {
  14115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14116. return
  14117. }
  14118. break
  14119. }
  14120. case 2:
  14121. if miConfig.MdtrtareaAdmvs == "430800" {
  14122. if initFlag == 0 {
  14123. c.TestGetHnBasBaseInit()
  14124. }
  14125. SFZStr := c.GetSFZBaseInfo()
  14126. if len(SFZStr) == 0 {
  14127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14128. return
  14129. }
  14130. fmt.Println(SFZStr)
  14131. id_card_str := strings.Split(SFZStr, "^")
  14132. card_no := id_card_str[0]
  14133. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14134. //name := id_card_str[1]
  14135. //name = ConvertToString(name, "gbk", "utf-8")
  14136. 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)
  14137. var dat map[string]interface{}
  14138. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14139. fmt.Println(dat)
  14140. } else {
  14141. fmt.Println(err)
  14142. }
  14143. userJSONBytes, _ := json.Marshal(dat)
  14144. var res ResultTwo
  14145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14146. utils.ErrorLog("解析失败:%v", err)
  14147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14148. return
  14149. }
  14150. if res.Infcode == 0 {
  14151. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14152. if err == gorm.ErrRecordNotFound {
  14153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14154. return
  14155. } else if err != nil {
  14156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14157. return
  14158. } else {
  14159. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14160. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14161. infoStr := string(Iinfos)
  14162. idetinfoStr := string(Idetinfos)
  14163. var rf []*ResultFive
  14164. json.Unmarshal([]byte(infoStr), &rf)
  14165. var insutypes []*ResultFive
  14166. var insutype string
  14167. var is390 int = 0
  14168. var is310 int = 0
  14169. for _, item := range rf {
  14170. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14171. insutypes = append(insutypes, item)
  14172. }
  14173. }
  14174. if len(insutypes) == 1 {
  14175. insutype = insutypes[0].Insutype
  14176. } else {
  14177. for _, i := range insutypes {
  14178. if i.Insutype == "390" {
  14179. is390 = 1
  14180. }
  14181. if i.Insutype == "310" {
  14182. is310 = 1
  14183. }
  14184. }
  14185. }
  14186. if is390 == 1 {
  14187. insutype = "390"
  14188. }
  14189. if is310 == 1 {
  14190. insutype = "310"
  14191. }
  14192. if len(insutypes) == 0 {
  14193. insutype = "310"
  14194. }
  14195. var InsuplcAdmdvs string
  14196. for _, item := range rf {
  14197. if item.Insutype == insutype {
  14198. InsuplcAdmdvs = item.InsuplcAdmdvs
  14199. }
  14200. }
  14201. psn := &models.HisPsn{
  14202. PsnNo: res.Output.Baseinfo.PsnNo,
  14203. PatientId: patient.ID,
  14204. Certno: res.Output.Baseinfo.Certno,
  14205. Gend: res.Output.Baseinfo.Gend,
  14206. Naty: res.Output.Baseinfo.Naty,
  14207. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14208. PsnName: res.Output.Baseinfo.PsnName,
  14209. Idetinfo: idetinfoStr,
  14210. Insuinfo: infoStr,
  14211. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14212. CardInfo: SFZStr,
  14213. VerifyNumber: "",
  14214. InsuplcAdmdvs: InsuplcAdmdvs,
  14215. }
  14216. service.CreateHisPsn(psn)
  14217. c.ServeSuccessJSON(map[string]interface{}{
  14218. "patient": patient,
  14219. "number": card_no,
  14220. "insutype": insutype,
  14221. })
  14222. }
  14223. } else {
  14224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14225. return
  14226. }
  14227. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14228. var res ResultTwo
  14229. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14230. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14231. "&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)
  14232. resp, requestErr := http.Get(api)
  14233. if requestErr != nil {
  14234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14235. return
  14236. }
  14237. body, ioErr := ioutil.ReadAll(resp.Body)
  14238. if ioErr != nil {
  14239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14241. return
  14242. }
  14243. var respJSON map[string]interface{}
  14244. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14247. return
  14248. }
  14249. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14250. result, _ := json.Marshal(respJSON)
  14251. fmt.Println("log")
  14252. fmt.Println(string(result))
  14253. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14254. utils.ErrorLog("解析失败:%v", err)
  14255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14256. return
  14257. }
  14258. if res.Infcode == 0 {
  14259. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14260. if err == gorm.ErrRecordNotFound {
  14261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14262. return
  14263. } else if err != nil {
  14264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14265. return
  14266. } else {
  14267. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14268. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14269. infoStr := string(Iinfos)
  14270. idetinfoStr := string(Idetinfos)
  14271. psn := &models.HisPsn{
  14272. PsnNo: res.Output.Baseinfo.PsnNo,
  14273. PatientId: patient.ID,
  14274. Certno: res.Output.Baseinfo.Certno,
  14275. Gend: res.Output.Baseinfo.Gend,
  14276. Naty: res.Output.Baseinfo.Naty,
  14277. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14278. PsnName: res.Output.Baseinfo.PsnName,
  14279. Idetinfo: idetinfoStr,
  14280. Insuinfo: infoStr,
  14281. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14282. }
  14283. service.CreateHisPsn(psn)
  14284. c.ServeSuccessJSON(map[string]interface{}{
  14285. "patient": patient,
  14286. "number": res.Output.Baseinfo.Certno,
  14287. })
  14288. }
  14289. } else {
  14290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14291. return
  14292. }
  14293. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14294. var res ResultTwo
  14295. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14296. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14297. "&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)
  14298. resp, requestErr := http.Get(api)
  14299. if requestErr != nil {
  14300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14301. return
  14302. }
  14303. body, ioErr := ioutil.ReadAll(resp.Body)
  14304. if ioErr != nil {
  14305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14307. return
  14308. }
  14309. var respJSON map[string]interface{}
  14310. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14313. return
  14314. }
  14315. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14316. result, _ := json.Marshal(respJSON)
  14317. fmt.Println("log")
  14318. fmt.Println(string(result))
  14319. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14320. utils.ErrorLog("解析失败:%v", err)
  14321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14322. return
  14323. }
  14324. if res.Infcode == 0 {
  14325. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14326. if err == gorm.ErrRecordNotFound {
  14327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14328. return
  14329. } else if err != nil {
  14330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14331. return
  14332. } else {
  14333. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14334. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14335. infoStr := string(Iinfos)
  14336. idetinfoStr := string(Idetinfos)
  14337. psn := &models.HisPsn{
  14338. PsnNo: res.Output.Baseinfo.PsnNo,
  14339. PatientId: patient.ID,
  14340. Certno: res.Output.Baseinfo.Certno,
  14341. Gend: res.Output.Baseinfo.Gend,
  14342. Naty: res.Output.Baseinfo.Naty,
  14343. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14344. PsnName: res.Output.Baseinfo.PsnName,
  14345. Idetinfo: idetinfoStr,
  14346. Insuinfo: infoStr,
  14347. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14348. }
  14349. service.CreateHisPsn(psn)
  14350. c.ServeSuccessJSON(map[string]interface{}{
  14351. "patient": patient,
  14352. "number": res.Output.Baseinfo.Certno,
  14353. })
  14354. }
  14355. } else {
  14356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14357. return
  14358. }
  14359. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14360. var res ResultTwo
  14361. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14362. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14363. "&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)
  14364. resp, requestErr := http.Get(api)
  14365. if requestErr != nil {
  14366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14367. return
  14368. }
  14369. body, ioErr := ioutil.ReadAll(resp.Body)
  14370. if ioErr != nil {
  14371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14373. return
  14374. }
  14375. var respJSON map[string]interface{}
  14376. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14379. return
  14380. }
  14381. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14382. result, _ := json.Marshal(respJSON)
  14383. fmt.Println("log")
  14384. fmt.Println(string(result))
  14385. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14386. utils.ErrorLog("解析失败:%v", err)
  14387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14388. return
  14389. }
  14390. if res.Infcode == 0 {
  14391. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14392. if err == gorm.ErrRecordNotFound {
  14393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14394. return
  14395. } else if err != nil {
  14396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14397. return
  14398. } else {
  14399. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14400. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14401. infoStr := string(Iinfos)
  14402. idetinfoStr := string(Idetinfos)
  14403. var rf []*ResultFive
  14404. json.Unmarshal([]byte(infoStr), &rf)
  14405. var insutypes []*ResultFive
  14406. var insutype string
  14407. var is390 int = 0
  14408. var is310 int = 0
  14409. for _, item := range rf {
  14410. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14411. insutypes = append(insutypes, item)
  14412. }
  14413. }
  14414. if len(insutypes) == 1 {
  14415. insutype = insutypes[0].Insutype
  14416. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14417. } else {
  14418. for _, i := range insutypes {
  14419. if i.Insutype == "390" {
  14420. is390 = 1
  14421. }
  14422. if i.Insutype == "310" {
  14423. is310 = 1
  14424. }
  14425. }
  14426. }
  14427. if is390 == 1 {
  14428. insutype = "390"
  14429. }
  14430. if is310 == 1 {
  14431. insutype = "310"
  14432. }
  14433. if len(insutypes) == 0 {
  14434. insutype = "390"
  14435. }
  14436. var insuplc_admdvs string
  14437. for _, item := range rf {
  14438. if item.Insutype == insutype {
  14439. insuplc_admdvs = item.InsuplcAdmdvs
  14440. }
  14441. }
  14442. psn := &models.HisPsn{
  14443. PsnNo: res.Output.Baseinfo.PsnNo,
  14444. PatientId: patient.ID,
  14445. Certno: res.Output.Baseinfo.Certno,
  14446. Gend: res.Output.Baseinfo.Gend,
  14447. Naty: res.Output.Baseinfo.Naty,
  14448. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14449. PsnName: res.Output.Baseinfo.PsnName,
  14450. Idetinfo: idetinfoStr,
  14451. Insuinfo: infoStr,
  14452. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14453. InsuplcAdmdvs: insuplc_admdvs,
  14454. }
  14455. service.CreateHisPsn(psn)
  14456. c.ServeSuccessJSON(map[string]interface{}{
  14457. "patient": patient,
  14458. "number": res.Output.Baseinfo.Certno,
  14459. })
  14460. }
  14461. } else {
  14462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14463. return
  14464. }
  14465. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14466. res := c.GetoleInfo()
  14467. if res.Infcode == 0 {
  14468. var result string
  14469. if res.Output.MdtrtCertType == "01" {
  14470. 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)
  14471. } else if res.Output.MdtrtCertType == "02" {
  14472. 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)
  14473. } else if res.Output.MdtrtCertType == "03" {
  14474. 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)
  14475. }
  14476. var dat map[string]interface{}
  14477. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14478. fmt.Println(dat)
  14479. } else {
  14480. fmt.Println(err)
  14481. }
  14482. userJSONBytes, _ := json.Marshal(dat)
  14483. var res2 ResultTwo
  14484. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14485. utils.ErrorLog("解析失败:%v", err)
  14486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14487. return
  14488. }
  14489. if res2.Infcode == 0 {
  14490. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14491. if err == gorm.ErrRecordNotFound {
  14492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14493. return
  14494. } else if err != nil {
  14495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14496. return
  14497. } else {
  14498. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14499. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14500. infoStr := string(Iinfos)
  14501. idetinfoStr := string(Idetinfos)
  14502. var rf []*ResultFive
  14503. json.Unmarshal([]byte(infoStr), &rf)
  14504. var insutypes []*ResultFive
  14505. var insutype string
  14506. var is390 int = 0
  14507. var is310 int = 0
  14508. //var insuplc_admdvs string
  14509. for _, item := range rf {
  14510. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14511. insutypes = append(insutypes, item)
  14512. }
  14513. }
  14514. if len(insutypes) == 1 {
  14515. insutype = insutypes[0].Insutype
  14516. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14517. } else {
  14518. for _, i := range insutypes {
  14519. if i.Insutype == "390" {
  14520. is390 = 1
  14521. }
  14522. if i.Insutype == "310" {
  14523. is310 = 1
  14524. }
  14525. }
  14526. }
  14527. if is390 == 1 {
  14528. insutype = "390"
  14529. }
  14530. if is310 == 1 {
  14531. insutype = "310"
  14532. }
  14533. if len(insutypes) == 0 {
  14534. insutype = "310"
  14535. }
  14536. psn := &models.HisPsn{
  14537. PsnNo: res2.Output.Baseinfo.PsnNo,
  14538. PatientId: patient.ID,
  14539. //Brdy: res2.Output.Baseinfo.Brdy,
  14540. Certno: res2.Output.Baseinfo.Certno,
  14541. Gend: res2.Output.Baseinfo.Gend,
  14542. Naty: res2.Output.Baseinfo.Naty,
  14543. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14544. PsnName: res2.Output.Baseinfo.PsnName,
  14545. Idetinfo: idetinfoStr,
  14546. Insuinfo: infoStr,
  14547. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14548. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14549. VerifyNumber: res.Output.EcToken,
  14550. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14551. }
  14552. service.CreateHisPsn(psn)
  14553. var balc float64
  14554. for _, item := range rf {
  14555. if item.Insutype == insutype {
  14556. balc = item.Balc
  14557. }
  14558. }
  14559. c.ServeSuccessJSON(map[string]interface{}{
  14560. "patient": patient,
  14561. "number": res.Output.CardNo,
  14562. "insutype": insutype,
  14563. "blac": balc,
  14564. "desc": idetinfoStr,
  14565. })
  14566. }
  14567. } else {
  14568. c.ServeSuccessJSON(map[string]interface{}{
  14569. "failed_code": -10,
  14570. "msg": res2.ErrMsg,
  14571. })
  14572. }
  14573. } else {
  14574. c.ServeSuccessJSON(map[string]interface{}{
  14575. "failed_code": -10,
  14576. "msg": res.ErrMsg,
  14577. })
  14578. }
  14579. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14580. var insuplc_admdvs string
  14581. if len(patient.InsuplcAdmdvs) > 0 {
  14582. insuplc_admdvs = patient.InsuplcAdmdvs
  14583. } else {
  14584. if len(insuplc_admdvs_str) > 0 {
  14585. insuplc_admdvs = insuplc_admdvs_str
  14586. } else {
  14587. insuplc_admdvs = miConfig.InsuplcAdmdvs
  14588. }
  14589. }
  14590. //请求内网数据
  14591. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  14592. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14593. "&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=" + ""
  14594. resp, requestErr := http.Get(api)
  14595. if requestErr != nil {
  14596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14597. return
  14598. }
  14599. body, ioErr := ioutil.ReadAll(resp.Body)
  14600. if ioErr != nil {
  14601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14603. return
  14604. }
  14605. var respJSON map[string]interface{}
  14606. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14609. return
  14610. }
  14611. status := respJSON["data"].(map[string]interface{})["status"].(string)
  14612. if status == "0" {
  14613. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  14614. c.ServeSuccessJSON(map[string]interface{}{
  14615. "failed_code": -10,
  14616. "msg": err_msg,
  14617. })
  14618. return
  14619. }
  14620. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14621. var res ResultTwo
  14622. result, _ := json.Marshal(respJSON)
  14623. fmt.Println("log")
  14624. fmt.Println(string(result))
  14625. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14626. utils.ErrorLog("解析失败:%v", err)
  14627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14628. return
  14629. }
  14630. if res.Infcode == 0 {
  14631. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14632. if err == gorm.ErrRecordNotFound {
  14633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14634. return
  14635. } else if err != nil {
  14636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14637. return
  14638. } else {
  14639. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14640. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14641. infoStr := string(Iinfos)
  14642. idetinfoStr := string(Idetinfos)
  14643. psn := &models.HisPsn{
  14644. PsnNo: res.Output.Baseinfo.PsnNo,
  14645. PatientId: patient.ID,
  14646. Certno: res.Output.Baseinfo.Certno,
  14647. Gend: res.Output.Baseinfo.Gend,
  14648. Naty: res.Output.Baseinfo.Naty,
  14649. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14650. PsnName: res.Output.Baseinfo.PsnName,
  14651. Idetinfo: idetinfoStr,
  14652. Insuinfo: infoStr,
  14653. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14654. }
  14655. service.CreateHisPsn(psn)
  14656. var rf []*ResultFive
  14657. json.Unmarshal([]byte(infoStr), &rf)
  14658. var insutypes []*ResultFive
  14659. var is390 int = 0
  14660. var is310 int = 0
  14661. var insutype string
  14662. for _, item := range rf {
  14663. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14664. insutypes = append(insutypes, item)
  14665. }
  14666. }
  14667. if len(insutypes) == 1 {
  14668. insutype = insutypes[0].Insutype
  14669. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14670. } else {
  14671. for _, i := range insutypes {
  14672. if i.Insutype == "390" {
  14673. is390 = 1
  14674. }
  14675. if i.Insutype == "310" {
  14676. is310 = 1
  14677. }
  14678. }
  14679. }
  14680. if is390 == 1 {
  14681. insutype = "390"
  14682. }
  14683. if is310 == 1 {
  14684. insutype = "310"
  14685. }
  14686. if len(insutypes) == 0 {
  14687. insutype = "390"
  14688. }
  14689. c.ServeSuccessJSON(map[string]interface{}{
  14690. "patient": patient,
  14691. "insutype": insutype,
  14692. "number": res.Output.Baseinfo.Certno,
  14693. "info": res,
  14694. })
  14695. }
  14696. } else {
  14697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14698. return
  14699. }
  14700. } else {
  14701. SFZStr := c.GetSFZBaseInfo()
  14702. id_card_str := strings.Split(SFZStr, "^")
  14703. id_card_number := id_card_str[0]
  14704. card_sn := ""
  14705. 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)
  14706. var dat map[string]interface{}
  14707. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14708. fmt.Println(dat)
  14709. } else {
  14710. fmt.Println(err)
  14711. }
  14712. userJSONBytes, _ := json.Marshal(dat)
  14713. var res ResultTwo
  14714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14715. utils.ErrorLog("解析失败:%v", err)
  14716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14717. return
  14718. }
  14719. if res.Infcode == 0 {
  14720. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  14721. if err == gorm.ErrRecordNotFound {
  14722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14723. return
  14724. } else if err != nil {
  14725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14726. return
  14727. } else {
  14728. c.ServeSuccessJSON(map[string]interface{}{
  14729. "patient": patient,
  14730. "number": id_card_number,
  14731. })
  14732. }
  14733. } else {
  14734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14735. return
  14736. }
  14737. }
  14738. break
  14739. case 3:
  14740. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14741. var api string
  14742. if miConfig.MdtrtareaAdmvs == "320921" {
  14743. 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 +
  14744. "&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
  14745. fmt.Println(api)
  14746. } else {
  14747. 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 +
  14748. "&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)
  14749. }
  14750. resp, requestErr := http.Get(api)
  14751. if requestErr != nil {
  14752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14753. return
  14754. }
  14755. body, ioErr := ioutil.ReadAll(resp.Body)
  14756. if ioErr != nil {
  14757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14759. return
  14760. }
  14761. var respJSON map[string]interface{}
  14762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14765. return
  14766. }
  14767. var status string
  14768. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14769. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14770. var token string
  14771. var res ResultTwo //1101结果
  14772. var res10265 ResultTwo10265 //1101结果
  14773. var card_info string //卡信息
  14774. var busi_card_info string
  14775. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14776. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14777. if status == "0" { //读卡成功
  14778. if card_type == "1" {
  14779. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14780. result, _ := json.Marshal(respJSON)
  14781. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14782. utils.ErrorLog("解析失败:%v", err)
  14783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14784. return
  14785. }
  14786. res.ErrMsg = res10265.ErrMsg
  14787. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14788. res.Infcode = infocode
  14789. res.Output = res10265.Output
  14790. res.InfRefmsgid = res10265.InfRefmsgid
  14791. } else {
  14792. //var card_info string //卡信息
  14793. //var busi_card_info string
  14794. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14795. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14796. //fmt.Println(card_info)
  14797. //fmt.Println(busi_card_info)
  14798. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14799. result, _ := json.Marshal(respJSON)
  14800. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14801. utils.ErrorLog("解析失败:%v", err)
  14802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14803. return
  14804. }
  14805. res.ErrMsg = res10265.ErrMsg
  14806. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14807. res.Infcode = infocode
  14808. res.Output = res10265.Output
  14809. res.InfRefmsgid = res10265.InfRefmsgid
  14810. }
  14811. if res.Infcode == 0 {
  14812. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14813. if err == gorm.ErrRecordNotFound {
  14814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14815. return
  14816. } else if err != nil {
  14817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14818. return
  14819. } else {
  14820. if card_type == "1" {
  14821. bas := strings.Split(card_info, "|")
  14822. basNumber := bas[2]
  14823. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14824. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14825. infoStr := string(Iinfos)
  14826. idetinfoStr := string(Idetinfos)
  14827. psn := &models.HisPsn{
  14828. PsnNo: res.Output.Baseinfo.PsnNo,
  14829. PatientId: patient.ID,
  14830. Certno: res.Output.Baseinfo.Certno,
  14831. //Brdy: res.Output.Baseinfo.Brdy,
  14832. Gend: res.Output.Baseinfo.Gend,
  14833. Naty: res.Output.Baseinfo.Naty,
  14834. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14835. PsnName: res.Output.Baseinfo.PsnName,
  14836. Idetinfo: idetinfoStr,
  14837. Insuinfo: infoStr,
  14838. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14839. CardInfo: card_info,
  14840. VerifyNumber: busi_card_info,
  14841. }
  14842. service.CreateHisPsn(psn)
  14843. c.ServeSuccessJSON(map[string]interface{}{
  14844. "patient": patient,
  14845. "number": basNumber,
  14846. })
  14847. } else {
  14848. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14849. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14850. infoStr := string(Iinfos)
  14851. idetinfoStr := string(Idetinfos)
  14852. psn := &models.HisPsn{
  14853. PsnNo: res.Output.Baseinfo.PsnNo,
  14854. PatientId: patient.ID,
  14855. Certno: res.Output.Baseinfo.Certno,
  14856. Gend: res.Output.Baseinfo.Gend,
  14857. Naty: res.Output.Baseinfo.Naty,
  14858. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14859. PsnName: res.Output.Baseinfo.PsnName,
  14860. Idetinfo: idetinfoStr,
  14861. Insuinfo: infoStr,
  14862. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14863. CardInfo: card_info,
  14864. VerifyNumber: token,
  14865. }
  14866. service.CreateHisPsn(psn)
  14867. var rf []*ResultFive
  14868. json.Unmarshal([]byte(infoStr), &rf)
  14869. var insutypes []*ResultFive
  14870. var insutype string
  14871. var is390 int = 0
  14872. var is310 int = 0
  14873. for _, item := range rf {
  14874. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14875. insutypes = append(insutypes, item)
  14876. }
  14877. }
  14878. if len(insutypes) == 1 {
  14879. insutype = insutypes[0].Insutype
  14880. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14881. } else {
  14882. for _, i := range insutypes {
  14883. if i.Insutype == "390" {
  14884. is390 = 1
  14885. }
  14886. if i.Insutype == "310" {
  14887. is310 = 1
  14888. }
  14889. }
  14890. }
  14891. if is390 == 1 {
  14892. insutype = "390"
  14893. }
  14894. if is310 == 1 {
  14895. insutype = "310"
  14896. }
  14897. if len(insutypes) == 0 {
  14898. insutype = "310"
  14899. }
  14900. c.ServeSuccessJSON(map[string]interface{}{
  14901. "patient": patient,
  14902. "number": token,
  14903. "insutype": insutype,
  14904. })
  14905. }
  14906. }
  14907. } else {
  14908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14909. return
  14910. }
  14911. } else { //读卡失败
  14912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14913. return
  14914. }
  14915. }
  14916. break
  14917. case 4:
  14918. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14919. var api string
  14920. if miConfig.MdtrtareaAdmvs == "320921" {
  14921. 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 +
  14922. "&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
  14923. fmt.Println(api)
  14924. } else {
  14925. 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 +
  14926. "&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)
  14927. }
  14928. resp, requestErr := http.Get(api)
  14929. if requestErr != nil {
  14930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14931. return
  14932. }
  14933. body, ioErr := ioutil.ReadAll(resp.Body)
  14934. if ioErr != nil {
  14935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14937. return
  14938. }
  14939. var respJSON map[string]interface{}
  14940. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14943. return
  14944. }
  14945. var status string
  14946. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14947. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14948. var token string
  14949. var res ResultTwo //1101结果
  14950. var res10265 ResultTwo10265 //1101结果
  14951. if status == "0" { //读卡成功
  14952. var card_info string //卡信息
  14953. var busi_card_info string
  14954. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14955. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14956. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14957. fmt.Println(card_info)
  14958. fmt.Println(busi_card_info)
  14959. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14960. result, _ := json.Marshal(respJSON)
  14961. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14962. utils.ErrorLog("解析失败:%v", err)
  14963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14964. return
  14965. }
  14966. res.ErrMsg = res10265.ErrMsg
  14967. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14968. res.Infcode = infocode
  14969. res.Output = res10265.Output
  14970. res.InfRefmsgid = res10265.InfRefmsgid
  14971. if res.Infcode == 0 {
  14972. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14973. if err == gorm.ErrRecordNotFound {
  14974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14975. return
  14976. } else if err != nil {
  14977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14978. return
  14979. } else {
  14980. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14981. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14982. infoStr := string(Iinfos)
  14983. idetinfoStr := string(Idetinfos)
  14984. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14985. psn := &models.HisPsn{
  14986. PsnNo: res.Output.Baseinfo.PsnNo,
  14987. PatientId: patient.ID,
  14988. Certno: res.Output.Baseinfo.Certno,
  14989. Brdy: b,
  14990. Age: float64(age),
  14991. //Brdy: res.Output.Baseinfo.Brdy,
  14992. Gend: res.Output.Baseinfo.Gend,
  14993. Naty: res.Output.Baseinfo.Naty,
  14994. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14995. PsnName: res.Output.Baseinfo.PsnName,
  14996. Idetinfo: idetinfoStr,
  14997. Insuinfo: infoStr,
  14998. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14999. CardInfo: card_info,
  15000. VerifyNumber: token,
  15001. }
  15002. var rf []*ResultFive
  15003. json.Unmarshal([]byte(infoStr), &rf)
  15004. var insutypes []*ResultFive
  15005. var insutype string
  15006. var is390 int = 0
  15007. var is310 int = 0
  15008. for _, item := range rf {
  15009. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15010. insutypes = append(insutypes, item)
  15011. }
  15012. }
  15013. if len(insutypes) == 1 {
  15014. insutype = insutypes[0].Insutype
  15015. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15016. } else {
  15017. for _, i := range insutypes {
  15018. if i.Insutype == "390" {
  15019. is390 = 1
  15020. }
  15021. if i.Insutype == "310" {
  15022. is310 = 1
  15023. }
  15024. }
  15025. }
  15026. if is390 == 1 {
  15027. insutype = "390"
  15028. }
  15029. if is310 == 1 {
  15030. insutype = "310"
  15031. }
  15032. if len(insutypes) == 0 {
  15033. insutype = "310"
  15034. }
  15035. service.CreateHisPsn(psn)
  15036. c.ServeSuccessJSON(map[string]interface{}{
  15037. "patient": patient,
  15038. "number": token,
  15039. "insutype": insutype,
  15040. })
  15041. }
  15042. } else {
  15043. c.ServeSuccessJSON(map[string]interface{}{
  15044. "failed_code": -10,
  15045. "msg": res.ErrMsg,
  15046. })
  15047. }
  15048. } else { //读卡失败
  15049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15050. return
  15051. }
  15052. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15053. var api string
  15054. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15055. "&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
  15056. resp, requestErr := http.Get(api)
  15057. if requestErr != nil {
  15058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15059. return
  15060. }
  15061. body, ioErr := ioutil.ReadAll(resp.Body)
  15062. if ioErr != nil {
  15063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15065. return
  15066. }
  15067. var respJSON map[string]interface{}
  15068. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15071. return
  15072. }
  15073. var status string
  15074. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15075. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15076. var token string
  15077. var res ResultTwo //1101结果
  15078. if status == "1" { //读卡成功
  15079. var card_info string //卡信息
  15080. var busi_card_info string
  15081. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15082. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15083. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15084. fmt.Println(card_info)
  15085. fmt.Println(busi_card_info)
  15086. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15087. result, _ := json.Marshal(respJSON)
  15088. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15089. utils.ErrorLog("解析失败:%v", err)
  15090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15091. return
  15092. }
  15093. if res.Infcode == 0 {
  15094. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15095. if err == gorm.ErrRecordNotFound {
  15096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15097. return
  15098. } else if err != nil {
  15099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15100. return
  15101. } else {
  15102. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15103. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15104. infoStr := string(Iinfos)
  15105. idetinfoStr := string(Idetinfos)
  15106. psn := &models.HisPsn{
  15107. PsnNo: res.Output.Baseinfo.PsnNo,
  15108. PatientId: patient.ID,
  15109. Certno: res.Output.Baseinfo.Certno,
  15110. Gend: res.Output.Baseinfo.Gend,
  15111. Naty: res.Output.Baseinfo.Naty,
  15112. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15113. PsnName: res.Output.Baseinfo.PsnName,
  15114. Idetinfo: idetinfoStr,
  15115. Insuinfo: infoStr,
  15116. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15117. CardInfo: card_info,
  15118. VerifyNumber: token,
  15119. }
  15120. var rf []*ResultFive
  15121. json.Unmarshal([]byte(infoStr), &rf)
  15122. var insutypes []*ResultFive
  15123. var insutype string
  15124. var is390 int = 0
  15125. var is310 int = 0
  15126. for _, item := range rf {
  15127. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15128. insutypes = append(insutypes, item)
  15129. }
  15130. }
  15131. if len(insutypes) == 1 {
  15132. insutype = insutypes[0].Insutype
  15133. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15134. } else {
  15135. for _, i := range insutypes {
  15136. if i.Insutype == "390" {
  15137. is390 = 1
  15138. }
  15139. if i.Insutype == "310" {
  15140. is310 = 1
  15141. }
  15142. }
  15143. }
  15144. if is390 == 1 {
  15145. insutype = "390"
  15146. }
  15147. if is310 == 1 {
  15148. insutype = "310"
  15149. }
  15150. if len(insutypes) == 0 {
  15151. insutype = "310"
  15152. }
  15153. service.CreateHisPsn(psn)
  15154. c.ServeSuccessJSON(map[string]interface{}{
  15155. "patient": patient,
  15156. "number": token,
  15157. "insutype": insutype,
  15158. })
  15159. }
  15160. } else {
  15161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15162. return
  15163. }
  15164. } else { //读卡失败
  15165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15166. return
  15167. }
  15168. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15169. var api string
  15170. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15171. "&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
  15172. resp, requestErr := http.Get(api)
  15173. if requestErr != nil {
  15174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15175. return
  15176. }
  15177. body, ioErr := ioutil.ReadAll(resp.Body)
  15178. if ioErr != nil {
  15179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15181. return
  15182. }
  15183. var respJSON map[string]interface{}
  15184. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15187. return
  15188. }
  15189. var status string
  15190. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15191. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15192. var token string
  15193. var res ResultTwo //1101结果
  15194. if status == "1" { //读卡成功
  15195. var card_info string //卡信息
  15196. var busi_card_info string
  15197. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15198. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15199. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15200. fmt.Println(card_info)
  15201. fmt.Println(busi_card_info)
  15202. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15203. result, _ := json.Marshal(respJSON)
  15204. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15205. utils.ErrorLog("解析失败:%v", err)
  15206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15207. return
  15208. }
  15209. if res.Infcode == 0 {
  15210. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15211. if err == gorm.ErrRecordNotFound {
  15212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15213. return
  15214. } else if err != nil {
  15215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15216. return
  15217. } else {
  15218. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15219. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15220. infoStr := string(Iinfos)
  15221. idetinfoStr := string(Idetinfos)
  15222. psn := &models.HisPsn{
  15223. PsnNo: res.Output.Baseinfo.PsnNo,
  15224. PatientId: patient.ID,
  15225. Certno: res.Output.Baseinfo.Certno,
  15226. Gend: res.Output.Baseinfo.Gend,
  15227. Naty: res.Output.Baseinfo.Naty,
  15228. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15229. PsnName: res.Output.Baseinfo.PsnName,
  15230. Idetinfo: idetinfoStr,
  15231. Insuinfo: infoStr,
  15232. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15233. CardInfo: card_info,
  15234. VerifyNumber: token,
  15235. }
  15236. var rf []*ResultFive
  15237. json.Unmarshal([]byte(infoStr), &rf)
  15238. var insutypes []*ResultFive
  15239. var insutype string
  15240. var is390 int = 0
  15241. var is310 int = 0
  15242. for _, item := range rf {
  15243. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15244. insutypes = append(insutypes, item)
  15245. }
  15246. }
  15247. if len(insutypes) == 1 {
  15248. insutype = insutypes[0].Insutype
  15249. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15250. } else {
  15251. for _, i := range insutypes {
  15252. if i.Insutype == "390" {
  15253. is390 = 1
  15254. }
  15255. if i.Insutype == "310" {
  15256. is310 = 1
  15257. }
  15258. }
  15259. }
  15260. if is390 == 1 {
  15261. insutype = "390"
  15262. }
  15263. if is310 == 1 {
  15264. insutype = "310"
  15265. }
  15266. if len(insutypes) == 0 {
  15267. insutype = "310"
  15268. }
  15269. service.CreateHisPsn(psn)
  15270. c.ServeSuccessJSON(map[string]interface{}{
  15271. "patient": patient,
  15272. "number": token,
  15273. "insutype": insutype,
  15274. })
  15275. }
  15276. } else {
  15277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15278. return
  15279. }
  15280. } else { //读卡失败
  15281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15282. return
  15283. }
  15284. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15285. //idNo := c.GetString("idNo")
  15286. //userName := c.GetString("userName")
  15287. //ecToken := c.GetString("ecToken")
  15288. //insuOrg := c.GetString("insuOrg")
  15289. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15290. utils.ErrorLog("解析失败:%v", json_result)
  15291. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15292. type ELeData struct {
  15293. Data struct {
  15294. IdNo string `json:"idNo"`
  15295. IdType string `json:"idType"`
  15296. UserName string `json:"userName"`
  15297. EcToken string `json:"ecToken"`
  15298. InsuOrg string `json:"insuOrg"`
  15299. Gender string `json:"gender"`
  15300. Birthday string `json:"birthday"`
  15301. Nationality string `json:"nationality"`
  15302. Email string `json:"email"`
  15303. Extra string `json:"extra"`
  15304. } `json:"data"`
  15305. Code int `json:"code"`
  15306. Message string `json:"message"`
  15307. }
  15308. var ele ELeData
  15309. err := json.Unmarshal([]byte(json_result), &ele)
  15310. if err != nil {
  15311. utils.ErrorLog("解析失败:%v", err)
  15312. }
  15313. token := ele.Data.EcToken
  15314. token = Remove0000(token)
  15315. 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)
  15316. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15317. var res ResultTwo
  15318. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15319. utils.ErrorLog("解析失败:%v", err)
  15320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15321. return
  15322. }
  15323. if res.Infcode == 0 {
  15324. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15325. if err == gorm.ErrRecordNotFound {
  15326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15327. return
  15328. } else if err != nil {
  15329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15330. return
  15331. } else {
  15332. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15333. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15334. infoStr := string(Iinfos)
  15335. idetinfoStr := string(Idetinfos)
  15336. psn := &models.HisPsn{
  15337. PsnNo: res.Output.Baseinfo.PsnNo,
  15338. PatientId: patient.ID,
  15339. Certno: res.Output.Baseinfo.Certno,
  15340. Gend: res.Output.Baseinfo.Gend,
  15341. Naty: res.Output.Baseinfo.Naty,
  15342. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15343. PsnName: res.Output.Baseinfo.PsnName,
  15344. Idetinfo: idetinfoStr,
  15345. Insuinfo: infoStr,
  15346. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15347. CardInfo: "",
  15348. Stage: "1",
  15349. VerifyNumber: token,
  15350. InsuplcAdmdvs: ele.Data.InsuOrg,
  15351. }
  15352. service.CreateHisPsn(psn)
  15353. var rf []*ResultFive
  15354. json.Unmarshal([]byte(infoStr), &rf)
  15355. var insutypes []*ResultFive
  15356. var insutype string
  15357. var is390 int = 0
  15358. var is310 int = 0
  15359. for _, item := range rf {
  15360. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15361. insutypes = append(insutypes, item)
  15362. }
  15363. }
  15364. if len(insutypes) == 1 {
  15365. insutype = insutypes[0].Insutype
  15366. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15367. } else {
  15368. for _, i := range insutypes {
  15369. if i.Insutype == "390" {
  15370. is390 = 1
  15371. }
  15372. if i.Insutype == "310" {
  15373. is310 = 1
  15374. }
  15375. }
  15376. }
  15377. if is390 == 1 {
  15378. insutype = "390"
  15379. }
  15380. if is310 == 1 {
  15381. insutype = "310"
  15382. }
  15383. if len(insutypes) == 0 {
  15384. insutype = "310"
  15385. }
  15386. c.ServeSuccessJSON(map[string]interface{}{
  15387. "patient": patient,
  15388. "number": token,
  15389. "insutype": insutype,
  15390. })
  15391. }
  15392. } else {
  15393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15394. return
  15395. }
  15396. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15397. //if initFlag == 0 {
  15398. //c.TestGetJiangXiBasBaseInit()
  15399. //}
  15400. //if initEleFlag == 0 {
  15401. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15402. //}
  15403. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15404. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15405. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15406. type ELeData struct {
  15407. Data struct {
  15408. IdNo string `json:"idNo"`
  15409. IdType string `json:"idType"`
  15410. UserName string `json:"userName"`
  15411. EcToken string `json:"ecToken"`
  15412. InsuOrg string `json:"insuOrg"`
  15413. Gender string `json:"gender"`
  15414. Birthday string `json:"birthday"`
  15415. Nationality string `json:"nationality"`
  15416. Email string `json:"email"`
  15417. Extra string `json:"extra"`
  15418. } `json:"data"`
  15419. Code int `json:"code"`
  15420. Message string `json:"message"`
  15421. }
  15422. var ele ELeData
  15423. err := json.Unmarshal([]byte(result), &ele)
  15424. if err != nil {
  15425. utils.ErrorLog("解析失败:%v", err)
  15426. }
  15427. token := ele.Data.EcToken
  15428. token = Remove0000(token)
  15429. 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)
  15430. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15431. var res ResultTwo
  15432. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15433. utils.ErrorLog("解析失败:%v", err)
  15434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15435. return
  15436. }
  15437. if res.Infcode == 0 {
  15438. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15439. if err == gorm.ErrRecordNotFound {
  15440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15441. return
  15442. } else if err != nil {
  15443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15444. return
  15445. } else {
  15446. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15447. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15448. infoStr := string(Iinfos)
  15449. idetinfoStr := string(Idetinfos)
  15450. psn := &models.HisPsn{
  15451. PsnNo: res.Output.Baseinfo.PsnNo,
  15452. PatientId: patient.ID,
  15453. Certno: res.Output.Baseinfo.Certno,
  15454. Gend: res.Output.Baseinfo.Gend,
  15455. Naty: res.Output.Baseinfo.Naty,
  15456. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15457. PsnName: res.Output.Baseinfo.PsnName,
  15458. Idetinfo: idetinfoStr,
  15459. Insuinfo: infoStr,
  15460. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15461. CardInfo: "",
  15462. VerifyNumber: token,
  15463. InsuplcAdmdvs: ele.Data.InsuOrg,
  15464. }
  15465. service.CreateHisPsn(psn)
  15466. var rf []*ResultFive
  15467. json.Unmarshal([]byte(infoStr), &rf)
  15468. var insutypes []*ResultFive
  15469. var insutype string
  15470. var is390 int = 0
  15471. var is310 int = 0
  15472. for _, item := range rf {
  15473. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15474. insutypes = append(insutypes, item)
  15475. }
  15476. }
  15477. if len(insutypes) == 1 {
  15478. insutype = insutypes[0].Insutype
  15479. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15480. } else {
  15481. for _, i := range insutypes {
  15482. if i.Insutype == "390" {
  15483. is390 = 1
  15484. }
  15485. if i.Insutype == "310" {
  15486. is310 = 1
  15487. }
  15488. }
  15489. }
  15490. if is390 == 1 {
  15491. insutype = "390"
  15492. }
  15493. if is310 == 1 {
  15494. insutype = "310"
  15495. }
  15496. if len(insutypes) == 0 {
  15497. insutype = "310"
  15498. }
  15499. c.ServeSuccessJSON(map[string]interface{}{
  15500. "patient": patient,
  15501. "number": token,
  15502. "insutype": insutype,
  15503. })
  15504. }
  15505. } else {
  15506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15507. return
  15508. }
  15509. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15510. //if initFlag == 0 {
  15511. //c.TestGetJiangXiBasBaseInit()
  15512. //}
  15513. //if initEleFlag == 0 {
  15514. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15515. //}
  15516. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15517. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15518. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15519. type ELeData struct {
  15520. Data struct {
  15521. IdNo string `json:"idNo"`
  15522. IdType string `json:"idType"`
  15523. UserName string `json:"userName"`
  15524. EcToken string `json:"ecToken"`
  15525. InsuOrg string `json:"insuOrg"`
  15526. Gender string `json:"gender"`
  15527. Birthday string `json:"birthday"`
  15528. Nationality string `json:"nationality"`
  15529. Email string `json:"email"`
  15530. Extra string `json:"extra"`
  15531. } `json:"data"`
  15532. Code int `json:"code"`
  15533. Message string `json:"message"`
  15534. }
  15535. var ele ELeData
  15536. err := json.Unmarshal([]byte(result), &ele)
  15537. if err != nil {
  15538. utils.ErrorLog("解析失败:%v", err)
  15539. }
  15540. token := ele.Data.EcToken
  15541. token = Remove0000(token)
  15542. 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)
  15543. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15544. var res ResultTwo
  15545. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15546. utils.ErrorLog("解析失败:%v", err)
  15547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15548. return
  15549. }
  15550. if res.Infcode == 0 {
  15551. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15552. if err == gorm.ErrRecordNotFound {
  15553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15554. return
  15555. } else if err != nil {
  15556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15557. return
  15558. } else {
  15559. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15560. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15561. infoStr := string(Iinfos)
  15562. idetinfoStr := string(Idetinfos)
  15563. psn := &models.HisPsn{
  15564. PsnNo: res.Output.Baseinfo.PsnNo,
  15565. PatientId: patient.ID,
  15566. Certno: res.Output.Baseinfo.Certno,
  15567. Gend: res.Output.Baseinfo.Gend,
  15568. Naty: res.Output.Baseinfo.Naty,
  15569. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15570. PsnName: res.Output.Baseinfo.PsnName,
  15571. Idetinfo: idetinfoStr,
  15572. Insuinfo: infoStr,
  15573. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15574. CardInfo: "",
  15575. VerifyNumber: token,
  15576. InsuplcAdmdvs: ele.Data.InsuOrg,
  15577. }
  15578. service.CreateHisPsn(psn)
  15579. var rf []*ResultFive
  15580. json.Unmarshal([]byte(infoStr), &rf)
  15581. var insutypes []*ResultFive
  15582. var insutype string
  15583. var is390 int = 0
  15584. var is310 int = 0
  15585. for _, item := range rf {
  15586. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15587. insutypes = append(insutypes, item)
  15588. }
  15589. }
  15590. if len(insutypes) == 1 {
  15591. insutype = insutypes[0].Insutype
  15592. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15593. } else {
  15594. for _, i := range insutypes {
  15595. if i.Insutype == "390" {
  15596. is390 = 1
  15597. }
  15598. if i.Insutype == "310" {
  15599. is310 = 1
  15600. }
  15601. }
  15602. }
  15603. if is390 == 1 {
  15604. insutype = "390"
  15605. }
  15606. if is310 == 1 {
  15607. insutype = "310"
  15608. }
  15609. if len(insutypes) == 0 {
  15610. insutype = "310"
  15611. }
  15612. c.ServeSuccessJSON(map[string]interface{}{
  15613. "patient": patient,
  15614. "number": token,
  15615. "insutype": insutype,
  15616. })
  15617. }
  15618. } else {
  15619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15620. return
  15621. }
  15622. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15623. //if initFlag == 0 {
  15624. c.TestGetJiangXiBasBaseInit()
  15625. //}
  15626. //if initEleFlag == 0 {
  15627. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15628. //}
  15629. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15630. type ELeData struct {
  15631. Data struct {
  15632. IdNo string `json:"idNo"`
  15633. IdType string `json:"idType"`
  15634. UserName string `json:"userName"`
  15635. EcToken string `json:"ecToken"`
  15636. InsuOrg string `json:"insuOrg"`
  15637. Gender string `json:"gender"`
  15638. Birthday string `json:"birthday"`
  15639. Nationality string `json:"nationality"`
  15640. Email string `json:"email"`
  15641. Extra string `json:"extra"`
  15642. } `json:"data"`
  15643. Code int `json:"code"`
  15644. Message string `json:"message"`
  15645. }
  15646. var ele ELeData
  15647. err := json.Unmarshal([]byte(json_result), &ele)
  15648. if err != nil {
  15649. utils.ErrorLog("解析失败:%v", err)
  15650. }
  15651. token := ele.Data.EcToken
  15652. token = Remove0000(token)
  15653. 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)
  15654. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15655. var res ResultTwo
  15656. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15657. utils.ErrorLog("解析失败:%v", err)
  15658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15659. return
  15660. }
  15661. if res.Infcode == 0 {
  15662. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15663. if err == gorm.ErrRecordNotFound {
  15664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15665. return
  15666. } else if err != nil {
  15667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15668. return
  15669. } else {
  15670. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15671. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15672. infoStr := string(Iinfos)
  15673. idetinfoStr := string(Idetinfos)
  15674. psn := &models.HisPsn{
  15675. PsnNo: res.Output.Baseinfo.PsnNo,
  15676. PatientId: patient.ID,
  15677. Certno: res.Output.Baseinfo.Certno,
  15678. Gend: res.Output.Baseinfo.Gend,
  15679. Naty: res.Output.Baseinfo.Naty,
  15680. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15681. PsnName: res.Output.Baseinfo.PsnName,
  15682. Idetinfo: idetinfoStr,
  15683. Insuinfo: infoStr,
  15684. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15685. CardInfo: "",
  15686. VerifyNumber: token,
  15687. }
  15688. service.CreateHisPsn(psn)
  15689. var rf []*ResultFive
  15690. json.Unmarshal([]byte(infoStr), &rf)
  15691. var insutypes []*ResultFive
  15692. var insutype string
  15693. var is390 int = 0
  15694. var is310 int = 0
  15695. for _, item := range rf {
  15696. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15697. insutypes = append(insutypes, item)
  15698. }
  15699. }
  15700. if len(insutypes) == 1 {
  15701. insutype = insutypes[0].Insutype
  15702. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15703. } else {
  15704. for _, i := range insutypes {
  15705. if i.Insutype == "390" {
  15706. is390 = 1
  15707. }
  15708. if i.Insutype == "310" {
  15709. is310 = 1
  15710. }
  15711. }
  15712. }
  15713. if is390 == 1 {
  15714. insutype = "390"
  15715. }
  15716. if is310 == 1 {
  15717. insutype = "310"
  15718. }
  15719. if len(insutypes) == 0 {
  15720. insutype = "310"
  15721. }
  15722. c.ServeSuccessJSON(map[string]interface{}{
  15723. "patient": patient,
  15724. "number": token,
  15725. "insutype": insutype,
  15726. })
  15727. }
  15728. } else {
  15729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15730. return
  15731. }
  15732. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15733. type ELeData struct {
  15734. Code string `json:"code"`
  15735. Data struct {
  15736. Aac002 string `json:"aac002"`
  15737. Aaz500 string `json:"aaz500"`
  15738. ActCardNo string `json:"actCardNo"`
  15739. Bab520 string `json:"bab520"`
  15740. Bkz543 string `json:"bkz543"`
  15741. BusinessType string `json:"businessType"`
  15742. CertfCodg string `json:"certfCodg"`
  15743. EcIndexNo string `json:"ecIndexNo"`
  15744. EcToken string `json:"ecToken"`
  15745. ID0000 string `json:"id0000"`
  15746. IDNo string `json:"idNo"`
  15747. IDType string `json:"idType"`
  15748. Idcode string `json:"idcode"`
  15749. IdentityToken string `json:"identity_token"`
  15750. InsuOrg string `json:"insuOrg"`
  15751. OfficeID string `json:"officeId"`
  15752. OfficeName string `json:"officeName"`
  15753. OperatorID string `json:"operatorId"`
  15754. OperatorName string `json:"operatorName"`
  15755. OrgID string `json:"orgId"`
  15756. UserName string `json:"userName"`
  15757. } `json:"data"`
  15758. Infno interface{} `json:"infno"`
  15759. Message string `json:"message"`
  15760. OrgID string `json:"orgId"`
  15761. TransType string `json:"transType"`
  15762. }
  15763. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  15764. outPutInfo = Remove0000(outPutInfo)
  15765. if len(outPutInfo) > 0 {
  15766. var ele ELeData
  15767. err := json.Unmarshal([]byte(outPutInfo), &ele)
  15768. if err != nil {
  15769. utils.ErrorLog("解析失败:%v", err)
  15770. }
  15771. token := ele.Data.EcToken
  15772. fmt.Println(inputInfo)
  15773. fmt.Println(outPutInfo)
  15774. 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)
  15775. saveLog(result, requestLog, "1101", "获取人员信息")
  15776. var dat map[string]interface{}
  15777. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15778. fmt.Println(dat)
  15779. } else {
  15780. fmt.Println(err)
  15781. }
  15782. userJSONBytes, _ := json.Marshal(dat)
  15783. var res ResultTwo
  15784. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15785. utils.ErrorLog("解析失败:%v", err)
  15786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15787. return
  15788. }
  15789. res.ErrMsg = errMsgLog
  15790. if res.Infcode == 0 {
  15791. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  15792. if err == gorm.ErrRecordNotFound {
  15793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15794. return
  15795. } else if err != nil {
  15796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15797. return
  15798. } else {
  15799. fmt.Println(res)
  15800. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15801. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15802. infoStr := string(Iinfos)
  15803. idetinfoStr := string(Idetinfos)
  15804. psn := &models.HisPsn{
  15805. PsnNo: res.Output.Baseinfo.PsnNo,
  15806. PatientId: patient.ID,
  15807. Certno: res.Output.Baseinfo.Certno,
  15808. Gend: res.Output.Baseinfo.Gend,
  15809. Naty: res.Output.Baseinfo.Naty,
  15810. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15811. PsnName: res.Output.Baseinfo.PsnName,
  15812. Idetinfo: idetinfoStr,
  15813. Insuinfo: infoStr,
  15814. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15815. CardInfo: outPutInfo,
  15816. VerifyNumber: token,
  15817. InsuplcAdmdvs: ele.Data.InsuOrg,
  15818. }
  15819. service.CreateHisPsn(psn)
  15820. var rf []*ResultFive
  15821. json.Unmarshal([]byte(infoStr), &rf)
  15822. var insutypes []*ResultFive
  15823. var insutype string
  15824. var is390 int = 0
  15825. var is310 int = 0
  15826. for _, item := range rf {
  15827. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15828. insutypes = append(insutypes, item)
  15829. }
  15830. }
  15831. if len(insutypes) == 1 {
  15832. insutype = insutypes[0].Insutype
  15833. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15834. } else {
  15835. for _, i := range insutypes {
  15836. if i.Insutype == "390" {
  15837. is390 = 1
  15838. }
  15839. if i.Insutype == "310" {
  15840. is310 = 1
  15841. }
  15842. }
  15843. }
  15844. if is390 == 1 {
  15845. insutype = "390"
  15846. }
  15847. if is310 == 1 {
  15848. insutype = "310"
  15849. }
  15850. if len(insutypes) == 0 {
  15851. insutype = "310"
  15852. }
  15853. c.ServeSuccessJSON(map[string]interface{}{
  15854. "patient": patient,
  15855. "number": token,
  15856. "insutype": insutype,
  15857. })
  15858. }
  15859. } else {
  15860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15861. return
  15862. }
  15863. }
  15864. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15865. var api string
  15866. 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 +
  15867. "&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
  15868. resp, requestErr := http.Get(api)
  15869. if requestErr != nil {
  15870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15871. return
  15872. }
  15873. body, ioErr := ioutil.ReadAll(resp.Body)
  15874. if ioErr != nil {
  15875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15877. return
  15878. }
  15879. var respJSON map[string]interface{}
  15880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15883. return
  15884. }
  15885. var status string
  15886. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15887. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15888. var token string
  15889. var res ResultTwo //1101结果
  15890. var res10265 ResultTwo10265 //1101结果
  15891. if status == "0" { //读卡成功
  15892. var card_info string //卡信息
  15893. var busi_card_info string
  15894. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15895. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15896. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15897. fmt.Println(card_info)
  15898. fmt.Println(busi_card_info)
  15899. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15900. result, _ := json.Marshal(respJSON)
  15901. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15902. utils.ErrorLog("解析失败:%v", err)
  15903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15904. return
  15905. }
  15906. res.ErrMsg = res10265.ErrMsg
  15907. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15908. res.Infcode = infocode
  15909. res.Output = res10265.Output
  15910. res.InfRefmsgid = res10265.InfRefmsgid
  15911. if res.Infcode == 0 {
  15912. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15913. if err == gorm.ErrRecordNotFound {
  15914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15915. return
  15916. } else if err != nil {
  15917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15918. return
  15919. } else {
  15920. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15921. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15922. infoStr := string(Iinfos)
  15923. idetinfoStr := string(Idetinfos)
  15924. psn := &models.HisPsn{
  15925. PsnNo: res.Output.Baseinfo.PsnNo,
  15926. PatientId: patient.ID,
  15927. Certno: res.Output.Baseinfo.Certno,
  15928. Gend: res.Output.Baseinfo.Gend,
  15929. Naty: res.Output.Baseinfo.Naty,
  15930. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15931. PsnName: res.Output.Baseinfo.PsnName,
  15932. Idetinfo: idetinfoStr,
  15933. Insuinfo: infoStr,
  15934. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15935. CardInfo: card_info,
  15936. VerifyNumber: token,
  15937. }
  15938. var rf []*ResultFive
  15939. json.Unmarshal([]byte(infoStr), &rf)
  15940. var insutypes []*ResultFive
  15941. var insutype string
  15942. var is390 int = 0
  15943. var is310 int = 0
  15944. for _, item := range rf {
  15945. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15946. insutypes = append(insutypes, item)
  15947. }
  15948. }
  15949. if len(insutypes) == 1 {
  15950. insutype = insutypes[0].Insutype
  15951. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15952. } else {
  15953. for _, i := range insutypes {
  15954. if i.Insutype == "390" {
  15955. is390 = 1
  15956. }
  15957. if i.Insutype == "310" {
  15958. is310 = 1
  15959. }
  15960. }
  15961. }
  15962. if is390 == 1 {
  15963. insutype = "390"
  15964. }
  15965. if is310 == 1 {
  15966. insutype = "310"
  15967. }
  15968. if len(insutypes) == 0 {
  15969. insutype = "310"
  15970. }
  15971. service.CreateHisPsn(psn)
  15972. c.ServeSuccessJSON(map[string]interface{}{
  15973. "patient": patient,
  15974. "number": token,
  15975. "insutype": insutype,
  15976. })
  15977. }
  15978. } else {
  15979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15980. return
  15981. }
  15982. } else { //读卡失败
  15983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15984. return
  15985. }
  15986. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15987. res := c.GetoleInfo()
  15988. if res.Infcode == 0 {
  15989. var result string
  15990. if res.Output.MdtrtCertType == "01" {
  15991. 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)
  15992. } else if res.Output.MdtrtCertType == "02" {
  15993. 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)
  15994. } else if res.Output.MdtrtCertType == "03" {
  15995. 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)
  15996. }
  15997. var dat map[string]interface{}
  15998. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15999. fmt.Println(dat)
  16000. } else {
  16001. fmt.Println(err)
  16002. }
  16003. userJSONBytes, _ := json.Marshal(dat)
  16004. var res2 ResultTwo
  16005. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16006. utils.ErrorLog("解析失败:%v", err)
  16007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16008. return
  16009. }
  16010. if res2.Infcode == 0 {
  16011. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16012. if err == gorm.ErrRecordNotFound {
  16013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16014. return
  16015. } else if err != nil {
  16016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16017. return
  16018. } else {
  16019. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16020. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16021. infoStr := string(Iinfos)
  16022. idetinfoStr := string(Idetinfos)
  16023. var rf []*ResultFive
  16024. json.Unmarshal([]byte(infoStr), &rf)
  16025. var insutypes []*ResultFive
  16026. var insutype string
  16027. var is390 int = 0
  16028. var is310 int = 0
  16029. //var insuplc_admdvs string
  16030. for _, item := range rf {
  16031. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16032. insutypes = append(insutypes, item)
  16033. }
  16034. }
  16035. if len(insutypes) == 1 {
  16036. insutype = insutypes[0].Insutype
  16037. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16038. } else {
  16039. for _, i := range insutypes {
  16040. if i.Insutype == "390" {
  16041. is390 = 1
  16042. }
  16043. if i.Insutype == "310" {
  16044. is310 = 1
  16045. }
  16046. }
  16047. }
  16048. if is390 == 1 {
  16049. insutype = "390"
  16050. }
  16051. if is310 == 1 {
  16052. insutype = "310"
  16053. }
  16054. if len(insutypes) == 0 {
  16055. insutype = "310"
  16056. }
  16057. psn := &models.HisPsn{
  16058. PsnNo: res2.Output.Baseinfo.PsnNo,
  16059. PatientId: patient.ID,
  16060. Certno: res2.Output.Baseinfo.Certno,
  16061. Gend: res2.Output.Baseinfo.Gend,
  16062. Naty: res2.Output.Baseinfo.Naty,
  16063. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16064. PsnName: res2.Output.Baseinfo.PsnName,
  16065. Idetinfo: idetinfoStr,
  16066. Insuinfo: infoStr,
  16067. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16068. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16069. VerifyNumber: res.Output.EcToken,
  16070. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16071. }
  16072. if res.Output.MdtrtCertType == "01" {
  16073. psn.VerifyNumber = res.Output.EcToken
  16074. //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)
  16075. } else if res.Output.MdtrtCertType == "02" {
  16076. psn.VerifyNumber = res.Output.CardNo
  16077. //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)
  16078. } else if res.Output.MdtrtCertType == "03" {
  16079. psn.VerifyNumber = res.Output.MdtrtCertNo
  16080. //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)
  16081. }
  16082. service.CreateHisPsn(psn)
  16083. var balc float64
  16084. for _, item := range rf {
  16085. if item.Insutype == insutype {
  16086. balc = item.Balc
  16087. }
  16088. }
  16089. c.ServeSuccessJSON(map[string]interface{}{
  16090. "patient": patient,
  16091. "number": res.Output.CardNo,
  16092. "insutype": insutype,
  16093. "blac": balc,
  16094. "desc": idetinfoStr,
  16095. })
  16096. }
  16097. } else {
  16098. c.ServeSuccessJSON(map[string]interface{}{
  16099. "failed_code": -10,
  16100. "msg": res2.ErrMsg,
  16101. })
  16102. }
  16103. } else {
  16104. c.ServeSuccessJSON(map[string]interface{}{
  16105. "failed_code": -10,
  16106. "msg": res.ErrMsg,
  16107. })
  16108. }
  16109. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16110. var res ResultTwo
  16111. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16112. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16113. "&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)
  16114. resp, requestErr := http.Get(api)
  16115. if requestErr != nil {
  16116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16117. return
  16118. }
  16119. body, ioErr := ioutil.ReadAll(resp.Body)
  16120. if ioErr != nil {
  16121. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16123. return
  16124. }
  16125. var respJSON map[string]interface{}
  16126. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16129. return
  16130. }
  16131. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16132. result, _ := json.Marshal(respJSON)
  16133. fmt.Println("log")
  16134. fmt.Println(string(result))
  16135. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16136. utils.ErrorLog("解析失败:%v", err)
  16137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16138. return
  16139. }
  16140. if res.Infcode == 0 {
  16141. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16142. if err == gorm.ErrRecordNotFound {
  16143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16144. return
  16145. } else if err != nil {
  16146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16147. return
  16148. } else {
  16149. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16150. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16151. infoStr := string(Iinfos)
  16152. idetinfoStr := string(Idetinfos)
  16153. var rf []*ResultFive
  16154. json.Unmarshal([]byte(infoStr), &rf)
  16155. var insutypes []*ResultFive
  16156. var insutype string
  16157. var is390 int = 0
  16158. var is310 int = 0
  16159. for _, item := range rf {
  16160. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16161. insutypes = append(insutypes, item)
  16162. }
  16163. }
  16164. if len(insutypes) == 1 {
  16165. insutype = insutypes[0].Insutype
  16166. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16167. } else {
  16168. for _, i := range insutypes {
  16169. if i.Insutype == "390" {
  16170. is390 = 1
  16171. }
  16172. if i.Insutype == "310" {
  16173. is310 = 1
  16174. }
  16175. }
  16176. }
  16177. if is390 == 1 {
  16178. insutype = "390"
  16179. }
  16180. if is310 == 1 {
  16181. insutype = "310"
  16182. }
  16183. if len(insutypes) == 0 {
  16184. insutype = "390"
  16185. }
  16186. var insuplc_admdvs string
  16187. for _, item := range rf {
  16188. if item.Insutype == insutype {
  16189. insuplc_admdvs = item.InsuplcAdmdvs
  16190. }
  16191. }
  16192. psn := &models.HisPsn{
  16193. PsnNo: res.Output.Baseinfo.PsnNo,
  16194. PatientId: patient.ID,
  16195. Certno: res.Output.Baseinfo.Certno,
  16196. Gend: res.Output.Baseinfo.Gend,
  16197. Naty: res.Output.Baseinfo.Naty,
  16198. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16199. PsnName: res.Output.Baseinfo.PsnName,
  16200. Idetinfo: idetinfoStr,
  16201. Insuinfo: infoStr,
  16202. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16203. InsuplcAdmdvs: insuplc_admdvs,
  16204. }
  16205. service.CreateHisPsn(psn)
  16206. c.ServeSuccessJSON(map[string]interface{}{
  16207. "patient": patient,
  16208. "number": res.Output.Baseinfo.Certno,
  16209. })
  16210. }
  16211. } else {
  16212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16213. return
  16214. }
  16215. } else {
  16216. type ELeData struct {
  16217. Code string `json:"code"`
  16218. Data struct {
  16219. Aac002 string `json:"aac002"`
  16220. Aaz500 string `json:"aaz500"`
  16221. ActCardNo string `json:"actCardNo"`
  16222. Bab520 string `json:"bab520"`
  16223. Bkz543 string `json:"bkz543"`
  16224. BusinessType string `json:"businessType"`
  16225. CertfCodg string `json:"certfCodg"`
  16226. EcIndexNo string `json:"ecIndexNo"`
  16227. EcToken string `json:"ecToken"`
  16228. ID0000 string `json:"id0000"`
  16229. IDNo string `json:"idNo"`
  16230. IDType string `json:"idType"`
  16231. Idcode string `json:"idcode"`
  16232. IdentityToken string `json:"identity_token"`
  16233. InsuOrg string `json:"insuOrg"`
  16234. OfficeID string `json:"officeId"`
  16235. OfficeName string `json:"officeName"`
  16236. OperatorID string `json:"operatorId"`
  16237. OperatorName string `json:"operatorName"`
  16238. OrgID string `json:"orgId"`
  16239. UserName string `json:"userName"`
  16240. } `json:"data"`
  16241. Infno interface{} `json:"infno"`
  16242. Message string `json:"message"`
  16243. OrgID string `json:"orgId"`
  16244. TransType string `json:"transType"`
  16245. }
  16246. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16247. fmt.Println(result)
  16248. outPutInfo := Remove0000(result)
  16249. fmt.Println(outPutInfo)
  16250. if len(outPutInfo) > 0 {
  16251. var ele ELeData
  16252. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16253. if err != nil {
  16254. utils.ErrorLog("解析失败:%v", err)
  16255. }
  16256. token := ele.Data.EcToken
  16257. fmt.Println(outPutInfo)
  16258. 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)
  16259. saveLog(result, requestLog, "1101", "获取人员信息")
  16260. var dat map[string]interface{}
  16261. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16262. fmt.Println(dat)
  16263. } else {
  16264. fmt.Println(err)
  16265. }
  16266. userJSONBytes, _ := json.Marshal(dat)
  16267. var res ResultTwo
  16268. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16269. utils.ErrorLog("解析失败:%v", err)
  16270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16271. return
  16272. }
  16273. if res.Infcode == 0 {
  16274. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16275. if err == gorm.ErrRecordNotFound {
  16276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16277. return
  16278. } else if err != nil {
  16279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16280. return
  16281. } else {
  16282. fmt.Println(res)
  16283. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16284. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16285. infoStr := string(Iinfos)
  16286. idetinfoStr := string(Idetinfos)
  16287. psn := &models.HisPsn{
  16288. PsnNo: res.Output.Baseinfo.PsnNo,
  16289. PatientId: patient.ID,
  16290. Certno: res.Output.Baseinfo.Certno,
  16291. Gend: res.Output.Baseinfo.Gend,
  16292. Naty: res.Output.Baseinfo.Naty,
  16293. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16294. PsnName: res.Output.Baseinfo.PsnName,
  16295. Idetinfo: idetinfoStr,
  16296. Insuinfo: infoStr,
  16297. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16298. CardInfo: outPutInfo,
  16299. VerifyNumber: token,
  16300. InsuplcAdmdvs: ele.Data.InsuOrg,
  16301. }
  16302. service.CreateHisPsn(psn)
  16303. var rf []*ResultFive
  16304. json.Unmarshal([]byte(infoStr), &rf)
  16305. var insutypes []*ResultFive
  16306. var insutype string
  16307. var is390 int = 0
  16308. var is310 int = 0
  16309. for _, item := range rf {
  16310. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16311. insutypes = append(insutypes, item)
  16312. }
  16313. }
  16314. if len(insutypes) == 1 {
  16315. insutype = insutypes[0].Insutype
  16316. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16317. } else {
  16318. for _, i := range insutypes {
  16319. if i.Insutype == "390" {
  16320. is390 = 1
  16321. }
  16322. if i.Insutype == "310" {
  16323. is310 = 1
  16324. }
  16325. }
  16326. }
  16327. if is390 == 1 {
  16328. insutype = "390"
  16329. }
  16330. if is310 == 1 {
  16331. insutype = "310"
  16332. }
  16333. if len(insutypes) == 0 {
  16334. insutype = "310"
  16335. }
  16336. c.ServeSuccessJSON(map[string]interface{}{
  16337. "patient": patient,
  16338. "number": token,
  16339. "insutype": insutype,
  16340. })
  16341. }
  16342. } else {
  16343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16344. return
  16345. }
  16346. }
  16347. //fmt.Println(result)
  16348. //
  16349. //if initFlag == 0 {
  16350. // c.TestGetBasBaseInit()
  16351. //}
  16352. //token := c.GetEleBaseInfo()
  16353. //
  16354. //token = Remove0000(token)
  16355. //
  16356. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16357. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16358. ////
  16359. //var res ResultTwo
  16360. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16361. // utils.ErrorLog("解析失败:%v", err)
  16362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16363. // return
  16364. //}
  16365. //
  16366. //if res.Infcode == 0 {
  16367. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16368. // if err == gorm.ErrRecordNotFound {
  16369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16370. // return
  16371. // } else if err != nil {
  16372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16373. // return
  16374. //
  16375. // } else {
  16376. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16377. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16378. // infoStr := string(Iinfos)
  16379. // idetinfoStr := string(Idetinfos)
  16380. //
  16381. //
  16382. //
  16383. //
  16384. // var rf []*ResultFive
  16385. // json.Unmarshal([]byte(infoStr), &rf)
  16386. //
  16387. // var insutypes []*ResultFive
  16388. // var insutype string
  16389. // var is390 int = 0
  16390. // var is310 int = 0
  16391. // var insuplc_admdvs string
  16392. //
  16393. // for _, item := range rf {
  16394. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16395. // insutypes = append(insutypes, item)
  16396. // }
  16397. // }
  16398. //
  16399. // if len(insutypes) == 1 {
  16400. // insutype = insutypes[0].Insutype
  16401. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16402. // } else {
  16403. // for _, i := range insutypes {
  16404. // if i.Insutype == "390" {
  16405. // is390 = 1
  16406. // }
  16407. //
  16408. // if i.Insutype == "310" {
  16409. // is310 = 1
  16410. // }
  16411. // }
  16412. // }
  16413. // if is390 == 1 {
  16414. // insutype = "390"
  16415. // }
  16416. //
  16417. // if is310 == 1 {
  16418. // insutype = "310"
  16419. // }
  16420. // if len(insutypes) == 0 {
  16421. // insutype = "310"
  16422. // }
  16423. // for _, item := range rf {
  16424. // if item.Insutype == insutype {
  16425. // insuplc_admdvs = item.InsuplcAdmdvs
  16426. // }
  16427. // }
  16428. // psn := &models.HisPsn{
  16429. // PsnNo: res.Output.Baseinfo.PsnNo,
  16430. // Age: res.Output.Baseinfo.Age,
  16431. // PatientId: patient.ID,
  16432. // Certno: res.Output.Baseinfo.Certno,
  16433. // Brdy: res.Output.Baseinfo.Brdy,
  16434. // Gend: res.Output.Baseinfo.Gend,
  16435. // Naty: res.Output.Baseinfo.Naty,
  16436. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16437. // PsnName: res.Output.Baseinfo.PsnName,
  16438. // Idetinfo: idetinfoStr,
  16439. // Insuinfo: infoStr,
  16440. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16441. // CardInfo: "",
  16442. // VerifyNumber: token,
  16443. // InsuplcAdmdvs: insuplc_admdvs,
  16444. // }
  16445. // service.CreateHisPsn(psn)
  16446. //
  16447. // c.ServeSuccessJSON(map[string]interface{}{
  16448. // "patient": patient,
  16449. // "number": token,
  16450. // })
  16451. // }
  16452. //} else {
  16453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16454. // return
  16455. //}
  16456. }
  16457. break
  16458. case 5:
  16459. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16460. var api string
  16461. if miConfig.MdtrtareaAdmvs == "320921" {
  16462. 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 +
  16463. "&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
  16464. fmt.Println(api)
  16465. } else {
  16466. 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 +
  16467. "&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)
  16468. }
  16469. resp, requestErr := http.Get(api)
  16470. if requestErr != nil {
  16471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16472. return
  16473. }
  16474. body, ioErr := ioutil.ReadAll(resp.Body)
  16475. if ioErr != nil {
  16476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16478. return
  16479. }
  16480. var respJSON map[string]interface{}
  16481. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16484. return
  16485. }
  16486. var status string
  16487. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16488. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16489. var token string
  16490. var res ResultTwo //1101结果
  16491. var res10265 ResultTwo10265 //1101结果
  16492. if status == "0" { //读卡成功
  16493. var card_info string //卡信息
  16494. //var busi_card_info string
  16495. var auth_info string
  16496. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16497. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16498. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16499. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16500. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16501. result, _ := json.Marshal(respJSON)
  16502. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16503. utils.ErrorLog("解析失败:%v", err)
  16504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16505. return
  16506. }
  16507. res.ErrMsg = res10265.ErrMsg
  16508. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16509. res.Infcode = infocode
  16510. res.Output = res10265.Output
  16511. res.InfRefmsgid = res10265.InfRefmsgid
  16512. if res.Infcode == 0 {
  16513. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16514. if err == gorm.ErrRecordNotFound {
  16515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16516. return
  16517. } else if err != nil {
  16518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16519. return
  16520. } else {
  16521. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16522. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16523. infoStr := string(Iinfos)
  16524. idetinfoStr := string(Idetinfos)
  16525. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16526. psn := &models.HisPsn{
  16527. PsnNo: res.Output.Baseinfo.PsnNo,
  16528. PatientId: patient.ID,
  16529. Certno: res.Output.Baseinfo.Certno,
  16530. Gend: res.Output.Baseinfo.Gend,
  16531. Brdy: b,
  16532. Age: float64(age),
  16533. Naty: res.Output.Baseinfo.Naty,
  16534. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16535. PsnName: res.Output.Baseinfo.PsnName,
  16536. Idetinfo: idetinfoStr,
  16537. Insuinfo: infoStr,
  16538. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16539. CardInfo: card_info,
  16540. VerifyNumber: token,
  16541. AuthInfo: auth_info,
  16542. }
  16543. var rf []*ResultFive
  16544. json.Unmarshal([]byte(infoStr), &rf)
  16545. var insutypes []*ResultFive
  16546. var insutype string
  16547. var is390 int = 0
  16548. var is310 int = 0
  16549. for _, item := range rf {
  16550. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16551. insutypes = append(insutypes, item)
  16552. }
  16553. }
  16554. if len(insutypes) == 1 {
  16555. insutype = insutypes[0].Insutype
  16556. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16557. } else {
  16558. for _, i := range insutypes {
  16559. if i.Insutype == "390" {
  16560. is390 = 1
  16561. }
  16562. if i.Insutype == "310" {
  16563. is310 = 1
  16564. }
  16565. }
  16566. }
  16567. if is390 == 1 {
  16568. insutype = "390"
  16569. }
  16570. if is310 == 1 {
  16571. insutype = "310"
  16572. }
  16573. if len(insutypes) == 0 {
  16574. insutype = "310"
  16575. }
  16576. service.CreateHisPsn(psn)
  16577. c.ServeSuccessJSON(map[string]interface{}{
  16578. "patient": patient,
  16579. "number": token,
  16580. "insutype": insutype,
  16581. })
  16582. }
  16583. } else {
  16584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16585. return
  16586. }
  16587. } else { //读卡失败
  16588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16589. return
  16590. }
  16591. }
  16592. break
  16593. }
  16594. }
  16595. var initFlag int64 = 0
  16596. var initEleFlag int64 = 0
  16597. func (c *HisApiController) TestGetBasBaseInit() {
  16598. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16599. Iinit := DllDef.MustFindProc("Init")
  16600. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16601. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  16602. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  16603. if ret != 0 {
  16604. fmt.Println("SSCard的报错原因:", err)
  16605. fmt.Println("SSCard的运算结果为:", ret)
  16606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16607. return
  16608. }
  16609. result := int(ret)
  16610. fmt.Println("SSCard的运算结果为1:", result)
  16611. initFlag = 1
  16612. return
  16613. }
  16614. func (c *HisApiController) HandleJiangXiReadCard() {
  16615. fmt.Println("~~~~~~")
  16616. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16617. admin_user_id, _ := c.GetInt64("admin_user_id")
  16618. id_card_type, _ := c.GetInt64("id_card_type")
  16619. //certificates, _ := c.GetInt64("certificates")
  16620. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16621. if initFlag == 0 {
  16622. c.TestGetJiangXiBasBaseInit()
  16623. }
  16624. basStr := c.GetBasBaseInfo()
  16625. if len(basStr) == 0 {
  16626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16627. return
  16628. }
  16629. fmt.Println(basStr)
  16630. bas := strings.Split(basStr, "|")
  16631. basNumber := bas[1]
  16632. fmt.Println(basNumber)
  16633. card_sn := bas[3]
  16634. fmt.Println(card_sn)
  16635. 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, "")
  16636. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  16637. var dat map[string]interface{}
  16638. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16639. fmt.Println(dat)
  16640. } else {
  16641. fmt.Println(err)
  16642. }
  16643. userJSONBytes, _ := json.Marshal(dat)
  16644. var res ResultTwo
  16645. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16646. utils.ErrorLog("解析失败:%v", err)
  16647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16648. return
  16649. }
  16650. if res.Infcode == 0 {
  16651. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  16652. if err == gorm.ErrRecordNotFound {
  16653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16654. return
  16655. } else if err != nil {
  16656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16657. return
  16658. } else {
  16659. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16660. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16661. infoStr := string(Iinfos)
  16662. idetinfoStr := string(Idetinfos)
  16663. psn := &models.HisPsn{
  16664. PsnNo: res.Output.Baseinfo.PsnNo,
  16665. PatientId: patient.ID,
  16666. Certno: res.Output.Baseinfo.Certno,
  16667. Gend: res.Output.Baseinfo.Gend,
  16668. Naty: res.Output.Baseinfo.Naty,
  16669. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16670. PsnName: res.Output.Baseinfo.PsnName,
  16671. Idetinfo: idetinfoStr,
  16672. Insuinfo: infoStr,
  16673. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16674. CardInfo: basStr,
  16675. VerifyNumber: "",
  16676. }
  16677. service.CreateHisPsn(psn)
  16678. c.ServeSuccessJSON(map[string]interface{}{
  16679. "patient": patient,
  16680. "number": basNumber,
  16681. })
  16682. }
  16683. } else {
  16684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16685. return
  16686. }
  16687. }
  16688. func (c *HisApiController) TestGetHnBasBaseInit() {
  16689. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16690. Iinit := DllDef.MustFindProc("Init")
  16691. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16692. //http://10.77.211.236/CSB/hsa-fsi-1303
  16693. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  16694. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  16695. // 调用 Init 函数
  16696. 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"))))
  16697. //if ret != 0 {
  16698. fmt.Println("SSCard的报错原因:", err)
  16699. fmt.Println("SSCard的运算结果为:", ret)
  16700. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16701. // return
  16702. //}
  16703. result := int(ret)
  16704. fmt.Println("SSCard的运算结果为1:", result)
  16705. initFlag = 1
  16706. return
  16707. }
  16708. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  16709. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16710. Iinit := DllDef.MustFindProc("Init")
  16711. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16712. //http://10.77.211.236/CSB/hsa-fsi-1303
  16713. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  16714. if ret != 0 {
  16715. fmt.Println("SSCard的报错原因:", err)
  16716. fmt.Println("SSCard的运算结果为:", ret)
  16717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16718. return
  16719. }
  16720. result := int(ret)
  16721. fmt.Println("SSCard的运算结果为1:", result)
  16722. initFlag = 1
  16723. return
  16724. }
  16725. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  16726. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16727. Iinit := DllDef.MustFindProc("Init")
  16728. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16729. //http://10.77.211.236/CSB/hsa-fsi-1303
  16730. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  16731. if ret != 0 {
  16732. fmt.Println("SSCard的报错原因:", err)
  16733. fmt.Println("SSCard的运算结果为:", ret)
  16734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  16735. return
  16736. }
  16737. result := int(ret)
  16738. fmt.Println("SSCard的运算结果为1:", result)
  16739. initFlag = 1
  16740. return
  16741. }
  16742. func (c *HisApiController) GetSFZBaseInfo() string {
  16743. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16744. readCard := DllDef.MustFindProc("ReadSFZ")
  16745. if readCard == nil {
  16746. fmt.Println("readcard is nil")
  16747. readCard = DllDef.MustFindProc("ReadSFZ")
  16748. }
  16749. str := make([]byte, 8096)
  16750. str1 := make([]byte, 8096)
  16751. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  16752. fmt.Println(r)
  16753. return Remove0000(string(str))
  16754. }
  16755. func (c *HisApiController) GetEleBaseInfo() string {
  16756. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16757. readCard := DllDef.MustFindProc("GetQRBase")
  16758. fmt.Println(readCard)
  16759. if readCard == nil {
  16760. fmt.Println("readcard is nil")
  16761. readCard = DllDef.MustFindProc("GetQRBase")
  16762. }
  16763. str := make([]byte, 1024)
  16764. str1 := make([]byte, 1024)
  16765. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  16766. fmt.Println(ret2)
  16767. fmt.Println(string(str1))
  16768. fmt.Println(string(str))
  16769. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16770. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16771. if ret2 != 0 {
  16772. return ""
  16773. }
  16774. return string(str)
  16775. }
  16776. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  16777. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16778. readCard := DllDef.MustFindProc("NationEcTrans")
  16779. fmt.Println(readCard)
  16780. fmt.Println("!!!!!")
  16781. pBusiCardInfo := make([]byte, 2048)
  16782. input := make(map[string]interface{})
  16783. inputData := make(map[string]interface{})
  16784. inputData["orgId"] = code
  16785. inputData["businessType"] = "01101"
  16786. inputData["operatorId"] = "1"
  16787. inputData["operatorName"] = "admin"
  16788. inputData["officeId"] = "001"
  16789. inputData["officeName"] = "血透室"
  16790. inputData["deviceType"] = ""
  16791. input["data"] = inputData
  16792. input["orgId"] = code
  16793. input["transType"] = "ec.query"
  16794. bytesData, _ := json.Marshal(input)
  16795. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  16796. fmt.Println(ret2)
  16797. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16798. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16799. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  16800. }
  16801. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  16802. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16803. readCard := DllDef.MustFindProc("NationEcTrans")
  16804. fmt.Println(readCard)
  16805. fmt.Println("!!!!!")
  16806. pBusiCardInfo := make([]byte, 2048)
  16807. input := make(map[string]interface{})
  16808. inputData := make(map[string]interface{})
  16809. inputData["orgId"] = code
  16810. inputData["businessType"] = "01101"
  16811. inputData["operatorId"] = "9"
  16812. inputData["operatorName"] = "admin"
  16813. inputData["officeId"] = "001"
  16814. inputData["officeName"] = "血透室"
  16815. inputData["deviceType"] = ""
  16816. input["data"] = inputData
  16817. input["orgId"] = code
  16818. input["transType"] = "ec.query"
  16819. bytesData, _ := json.Marshal(input)
  16820. 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])))
  16821. fmt.Println(ret2)
  16822. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16823. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16824. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  16825. }
  16826. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  16827. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  16828. readCard := DllDef.MustFindProc("NationEcTrans")
  16829. fmt.Println(readCard)
  16830. fmt.Println("!!!!!")
  16831. pBusiCardInfo := make([]byte, 2048)
  16832. input := make(map[string]interface{})
  16833. inputData := make(map[string]interface{})
  16834. inputData["orgId"] = code
  16835. inputData["businessType"] = "01301"
  16836. inputData["operatorId"] = "9"
  16837. inputData["operatorName"] = "admin"
  16838. inputData["officeId"] = "001"
  16839. inputData["officeName"] = "血透室"
  16840. inputData["deviceType"] = ""
  16841. input["data"] = inputData
  16842. input["orgId"] = code
  16843. input["transType"] = "ec.query"
  16844. bytesData, _ := json.Marshal(input)
  16845. 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])))
  16846. fmt.Println(ret2)
  16847. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16848. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16849. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  16850. }
  16851. func GetJxEleBaseInfo(org_id int64) string {
  16852. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16853. readCard := DllDef.MustFindProc("NationEcTrans")
  16854. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16855. if readCard == nil {
  16856. fmt.Println("readcard is nil")
  16857. readCard = DllDef.MustFindProc("NationEcTrans")
  16858. }
  16859. str1 := make([]byte, 1024)
  16860. data := make(map[string]interface{})
  16861. inputData := make(map[string]interface{})
  16862. inputData["orgId"] = miConfig.Code
  16863. inputData["businessType"] = "01101"
  16864. inputData["operatorId"] = "test001"
  16865. inputData["operatorName"] = "cn"
  16866. inputData["officeId"] = "32760"
  16867. inputData["officeName"] = "waike"
  16868. inputData["deviceType"] = ""
  16869. data["data"] = inputData
  16870. data["transType"] = "ec.query"
  16871. data["extra "] = ""
  16872. data["orgId"] = miConfig.Code
  16873. bytesData, _ := json.Marshal(data)
  16874. //bytesData, _ := json.Marshal(data)
  16875. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16876. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16877. fmt.Println(ret2)
  16878. fmt.Println(string(str1))
  16879. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16880. if ret2 != 0 {
  16881. return ""
  16882. }
  16883. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16884. }
  16885. //func GetJxEleBaseInfoTWO(org_id int64) string {
  16886. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  16887. // readCard := DllDef.MustFindProc("NationEcTrans")
  16888. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16889. //
  16890. // if readCard == nil {
  16891. // fmt.Println("readcard is nil")
  16892. // readCard = DllDef.MustFindProc("NationEcTrans")
  16893. // }
  16894. // str1 := make([]byte, 1024)
  16895. //
  16896. // data := make(map[string]interface{})
  16897. //
  16898. // inputData := make(map[string]interface{})
  16899. // inputData["orgId"] = miConfig.Code
  16900. // inputData["businessType"] = "01101"
  16901. // inputData["operatorId"] = "test001"
  16902. // inputData["operatorName"] = "cn"
  16903. // inputData["officeId"] = "32760"
  16904. // inputData["officeName"] = "waike"
  16905. // inputData["deviceType"] = ""
  16906. //
  16907. // data["data"] = inputData
  16908. // data["transType"] = "ec.query"
  16909. // data["extra "] = ""
  16910. // data["orgId"] = miConfig.Code
  16911. // bytesData, _ := json.Marshal(data)
  16912. // //bytesData, _ := json.Marshal(data)
  16913. //
  16914. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16915. //
  16916. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16917. // fmt.Println(ret2)
  16918. // fmt.Println(string(str1))
  16919. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16920. //
  16921. // if ret2 != 0 {
  16922. // return ""
  16923. // }
  16924. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16925. //}
  16926. func GetJxEleBaseInitInfo(org_id int64) string {
  16927. DllDef := syscall.MustLoadDLL("SSCard.dll")
  16928. readCard := DllDef.MustFindProc("NationEcTrans")
  16929. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16930. if readCard == nil {
  16931. fmt.Println("readcard is nil")
  16932. readCard = DllDef.MustFindProc("NationEcTrans")
  16933. }
  16934. str1 := make([]byte, 2048)
  16935. data := make(map[string]interface{})
  16936. inputData := make(map[string]interface{})
  16937. inputData["orgId"] = miConfig.Code
  16938. inputData["businessType"] = "01101"
  16939. inputData["operatorId"] = "1"
  16940. inputData["operatorName"] = "huangchuang"
  16941. inputData["officeId"] = "101"
  16942. inputData["officeName"] = "xuetou"
  16943. inputData["deviceType"] = ""
  16944. data["data"] = inputData
  16945. data["transType"] = "ec.query"
  16946. data["orgId"] = miConfig.Code
  16947. bytesData, _ := json.Marshal(data)
  16948. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  16949. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  16950. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  16951. fmt.Println(ret2)
  16952. fmt.Println(string(str1))
  16953. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16954. if ret2 != 0 {
  16955. return ""
  16956. }
  16957. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  16958. initEleFlag = 1
  16959. }
  16960. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  16961. }
  16962. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  16963. // // 构建命令
  16964. // cmd := exec.Command("python", "b.py")
  16965. //
  16966. // // 执行命令并等待完成
  16967. // output, err := cmd.CombinedOutput()
  16968. // if err != nil {
  16969. // fmt.Println("Error executing Python script:", err)
  16970. // return
  16971. // }
  16972. //
  16973. // // 打印Python脚本的输出
  16974. // fmt.Println(string(output))
  16975. //}
  16976. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  16977. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  16978. readCard := DllDef.MustFindProc("gxyb_call")
  16979. if readCard == nil {
  16980. fmt.Println("readcard is nil")
  16981. readCard = DllDef.MustFindProc("gxyb_call")
  16982. }
  16983. str := make([]byte, 1024)
  16984. str1 := make([]byte, 1024)
  16985. //data := make(map[string]interface{})
  16986. currentTime := time.Now()
  16987. // 格式化时间为 "YYYYMMDDHH24MISS"
  16988. formattedTime := currentTime.Format("20060102150405")
  16989. inputData := make(map[string]interface{})
  16990. inputData2 := make(map[string]interface{})
  16991. inputData["transNo"] = "1401"
  16992. inputData["transType"] = "passwordCheck"
  16993. inputData["timestamp"] = formattedTime
  16994. inputData2["fixmedinsCode"] = code
  16995. inputData2["psnNo"] = ""
  16996. inputData["data"] = inputData2
  16997. jsonBytes, err := json.Marshal(inputData)
  16998. if err != nil {
  16999. fmt.Println("Error encoding map to JSON:", err)
  17000. }
  17001. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17002. fmt.Println(string(str1))
  17003. fmt.Println(string(str))
  17004. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17005. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17006. if ret2 != 0 {
  17007. return ""
  17008. }
  17009. return string(str)
  17010. }
  17011. func (c *HisApiController) GetoleInfo() Response {
  17012. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17013. defer ole.CoUninitialize()
  17014. // Replace with the ProgID or CLSID of your COM object
  17015. progID := "YinHai.XJ.Actual.Interface.New"
  17016. // Create COM object
  17017. unknown, err := oleutil.CreateObject(progID)
  17018. if err != nil {
  17019. fmt.Println("Unable to create COM object:", err)
  17020. }
  17021. defer unknown.Release()
  17022. // Query for the IDispatch interface
  17023. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17024. if err != nil {
  17025. fmt.Println("Unable to get IDispatch interface:", err)
  17026. }
  17027. defer dispatch.Release()
  17028. // Prepare parameters
  17029. transNo := "1401"
  17030. transType := "passwordCheck"
  17031. timestamp := time.Now().Unix()
  17032. fixmedinsCode := "H45072101171"
  17033. psnNo := ""
  17034. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17035. result2 := ""
  17036. // Call COM object's method using the IDispatch interface
  17037. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17038. fmt.Println(resulr)
  17039. fmt.Println(result2)
  17040. if err != nil {
  17041. fmt.Println("调用COM对象方法失败:", err)
  17042. }
  17043. var response Response
  17044. err2 := json.Unmarshal([]byte(result2), &response)
  17045. if err2 != nil {
  17046. fmt.Println("解析JSON失败:", err)
  17047. }
  17048. return response
  17049. }
  17050. func (c *HisApiController) GetBasBaseInfo() string {
  17051. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17052. readCard := DllDef.MustFindProc("ReadCardBas")
  17053. if readCard == nil {
  17054. fmt.Println("readcard is nil")
  17055. readCard = DllDef.MustFindProc("ReadCardBas")
  17056. }
  17057. str := make([]byte, 1024)
  17058. str1 := make([]byte, 1024)
  17059. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17060. fmt.Println(string(str1))
  17061. fmt.Println(string(str))
  17062. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17063. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17064. if ret2 != 0 {
  17065. return ""
  17066. }
  17067. return string(str)
  17068. }
  17069. type Program struct {
  17070. FunctionID string `xml:"function_id"`
  17071. CardInfo string `xml:"cardinfo"`
  17072. User string `xml:"user"`
  17073. }
  17074. func (c *HisApiController) GetBasBaseInfo1111() string {
  17075. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17076. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17077. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17078. if readCard == nil {
  17079. fmt.Println("readcard is nil")
  17080. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17081. }
  17082. if readCard2 == nil {
  17083. fmt.Println("readcard is nil")
  17084. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17085. }
  17086. str := make([]byte, 1024)
  17087. str1 := make([]byte, 1024)
  17088. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17089. str3 := make([]byte, 1024)
  17090. str4 := make([]byte, 1024)
  17091. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17092. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17093. //if err != nil {
  17094. // fmt.Println("Error opening file:", err)
  17095. //}
  17096. //defer file.Close()
  17097. //
  17098. //var lastProgram Program
  17099. //scanner := bufio.NewScanner(file)
  17100. //inProgram := false
  17101. //
  17102. //for scanner.Scan() {
  17103. // line := scanner.Text()
  17104. // if strings.Contains(line, "<program>") {
  17105. // inProgram = true
  17106. // programXML := "<program>"
  17107. // for scanner.Scan() {
  17108. // line = scanner.Text()
  17109. // programXML += line
  17110. // if strings.Contains(line, "</program>") {
  17111. // programXML += "</program>"
  17112. // break
  17113. // }
  17114. // }
  17115. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17116. // // 解析成功,更新最后的 Program
  17117. // }
  17118. // inProgram = false
  17119. // }
  17120. //}
  17121. //
  17122. // fmt.Println("Error reading file:", inProgram)
  17123. //
  17124. //if err := scanner.Err(); err != nil {
  17125. // fmt.Println("Error reading file:", err)
  17126. //}
  17127. // 输出最后一次的 Program
  17128. //fmt.Printf("最后一次的 <program>:\n")
  17129. //fmt.Printf("<program>\n")
  17130. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17131. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17132. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17133. //fmt.Printf("</program>\n")
  17134. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17135. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17136. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17137. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17138. return ConvertToString(string(str), "gbk", "utf-8")
  17139. }
  17140. func (c *HisApiController) GetBasBaseInfo22222() string {
  17141. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17142. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17143. if readCard == nil {
  17144. fmt.Println("readcard is nil")
  17145. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17146. }
  17147. str := make([]byte, 1024)
  17148. str1 := make([]byte, 1024)
  17149. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17150. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17151. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17152. //if err != nil {
  17153. // fmt.Println("Error opening file:", err)
  17154. //}
  17155. //defer file.Close()
  17156. //
  17157. //var lastProgram Program
  17158. //scanner := bufio.NewScanner(file)
  17159. //inProgram := false
  17160. //
  17161. //for scanner.Scan() {
  17162. // line := scanner.Text()
  17163. // if strings.Contains(line, "<program>") {
  17164. // inProgram = true
  17165. // programXML := "<program>"
  17166. // for scanner.Scan() {
  17167. // line = scanner.Text()
  17168. // programXML += line
  17169. // if strings.Contains(line, "</program>") {
  17170. // programXML += "</program>"
  17171. // break
  17172. // }
  17173. // }
  17174. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17175. // // 解析成功,更新最后的 Program
  17176. // }
  17177. // inProgram = false
  17178. // }
  17179. //}
  17180. //
  17181. // fmt.Println("Error reading file:", inProgram)
  17182. //
  17183. //if err := scanner.Err(); err != nil {
  17184. // fmt.Println("Error reading file:", err)
  17185. //}
  17186. // 输出最后一次的 Program
  17187. //fmt.Printf("最后一次的 <program>:\n")
  17188. //fmt.Printf("<program>\n")
  17189. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17190. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17191. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17192. //fmt.Printf("</program>\n")
  17193. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17194. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17195. return ConvertToString(string(str1), "gbk", "utf-8")
  17196. }
  17197. func (c *HisApiController) GetahBasBaseInfo() string {
  17198. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17199. readCard := DllDef.MustFindProc("iReadCardBas")
  17200. if readCard == nil {
  17201. fmt.Println("readcard is nil")
  17202. readCard = DllDef.MustFindProc("iReadCardBas")
  17203. }
  17204. //str := make([]byte, 1024)
  17205. str1 := make([]byte, 1024)
  17206. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17207. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17208. //if err != nil {
  17209. // fmt.Println("Error opening file:", err)
  17210. //}
  17211. //defer file.Close()
  17212. //
  17213. //var lastProgram Program
  17214. //scanner := bufio.NewScanner(file)
  17215. //inProgram := false
  17216. //
  17217. //for scanner.Scan() {
  17218. // line := scanner.Text()
  17219. // if strings.Contains(line, "<program>") {
  17220. // inProgram = true
  17221. // programXML := "<program>"
  17222. // for scanner.Scan() {
  17223. // line = scanner.Text()
  17224. // programXML += line
  17225. // if strings.Contains(line, "</program>") {
  17226. // programXML += "</program>"
  17227. // break
  17228. // }
  17229. // }
  17230. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17231. // // 解析成功,更新最后的 Program
  17232. // }
  17233. // inProgram = false
  17234. // }
  17235. //}
  17236. //
  17237. // fmt.Println("Error reading file:", inProgram)
  17238. //
  17239. //if err := scanner.Err(); err != nil {
  17240. // fmt.Println("Error reading file:", err)
  17241. //}
  17242. // 输出最后一次的 Program
  17243. //fmt.Printf("最后一次的 <program>:\n")
  17244. //fmt.Printf("<program>\n")
  17245. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17246. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17247. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17248. //fmt.Printf("</program>\n")
  17249. fmt.Println(string(str1))
  17250. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17251. if ret2 != 0 {
  17252. return ""
  17253. }
  17254. return string(str1)
  17255. }
  17256. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17257. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17258. readCard := DllDef.MustFindProc("read_cardinfo")
  17259. if readCard == nil {
  17260. fmt.Println("readcard is nil")
  17261. readCard = DllDef.MustFindProc("read_cardinfo")
  17262. }
  17263. str := make([]byte, 1024) //卡号
  17264. str1 := make([]byte, 1024) //卡识别码
  17265. str2 := make([]byte, 1024) //身份证号
  17266. str3 := make([]byte, 1024) //姓名
  17267. str4 := make([]byte, 1024) //错误信息
  17268. 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])))
  17269. fmt.Println(string(str1))
  17270. fmt.Println(string(str))
  17271. fmt.Println(string(str2))
  17272. fmt.Println(string(str3))
  17273. fmt.Println(string(str4))
  17274. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17275. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17276. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17277. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17278. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17279. if ret2 != 0 {
  17280. return "", "", "", "", ""
  17281. }
  17282. return string(str), string(str1), string(str2), string(str3), string(str4)
  17283. }
  17284. type CustomFundPay struct {
  17285. FundPayType string `json:"fund_pay_type"`
  17286. FundPayamt float64 `json:"fund_payamt"`
  17287. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17288. }
  17289. //func (c *HisApiController) GetBatchSettleList() {
  17290. // start_time_str := c.GetString("start_time")
  17291. // //end_time_str := c.GetString("end_time")
  17292. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17293. //
  17294. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17295. //
  17296. // for _, item := range orders {
  17297. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17298. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17299. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17300. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17301. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17302. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17303. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17304. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17305. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17306. //
  17307. // if order.ID == 0 {
  17308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17309. // return
  17310. // }
  17311. //
  17312. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17313. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17314. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17315. // //fmt.Println(count)
  17316. // //var zero string
  17317. // //number := count + 1
  17318. // //if number >= 1000 {
  17319. // // zero = "0000" + strconv.FormatInt(number, 10)
  17320. // //} else if number >= 10000 {
  17321. // // zero = "000" + strconv.FormatInt(number, 10)
  17322. // //} else if number >= 100000 {
  17323. // // zero = "00" + strconv.FormatInt(number, 10)
  17324. // //} else if number >= 1000000 {
  17325. // // zero = "0" + strconv.FormatInt(number, 10)
  17326. // //} else {
  17327. // // zero = strconv.FormatInt(number, 10)
  17328. // //}
  17329. // //fmt.Println(zero)
  17330. //
  17331. // struct4101 := service.Struct4101{
  17332. // PsnNo: order.PsnNo,
  17333. // MdtrtId: order.MdtrtId,
  17334. // SetlId: order.SetlId,
  17335. // PsnName: order.PsnName,
  17336. // Gend: order.Gend,
  17337. // Brdy: his.Brdy,
  17338. // Age: his.Age,
  17339. // Naty: order.Naty,
  17340. // PatnCertType: "01",
  17341. // Certno: order.Certno,
  17342. // Prfs: "90",
  17343. // ConerName: roles[0].UserName,
  17344. // PatnRlts: "99",
  17345. // ConerAddr: miConfig.OrgName,
  17346. // ConerTel: admin.Mobile,
  17347. // HiType: order.Insutype,
  17348. // Insuplc: miConfig.InsuplcAdmdvs,
  17349. // MaindiagFlag: "1",
  17350. // BillCode: order.SetlId,
  17351. // BillNo: order.SetlId,
  17352. // BizSn: order.Number,
  17353. // PsnSelfPay: order.PsnPartAmt,
  17354. // PsnOwnPay: order.PsnPartAmt,
  17355. // AcctPay: order.AcctPay,
  17356. // PsnCashpay: order.PsnCashPay,
  17357. // HiPaymtd: "1",
  17358. // Hsorg: miConfig.InsuplcAdmdvs,
  17359. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17360. // MedinsFillPsn: curRoles.UserName,
  17361. // MedinsFillDept: miConfig.OrgName,
  17362. // IptMedType: "2",
  17363. // }
  17364. // struct4101.SetlBegnDate = order.SetlTime
  17365. // struct4101.SetlEndDate = order.SetlTime
  17366. // time_arr := strings.Split(order.SetlTime, " ")
  17367. // struct4101.AdmTime = time_arr[0]
  17368. // struct4101.AdmEndTime = time_arr[0]
  17369. //
  17370. // var rf []CustomFundPay
  17371. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17372. //
  17373. // var tempFunPays []service.CustomStruct
  17374. // for _, item := range rf {
  17375. // var tempFunPay service.CustomStruct
  17376. // tempFunPay.FundPayamt = item.FundPayamt
  17377. // tempFunPay.FundPayType = item.FundPayType
  17378. // tempFunPays = append(tempFunPays, tempFunPay)
  17379. // }
  17380. // struct4101.CustomStruct = tempFunPays
  17381. //
  17382. // var tempDiaginfos []service.DiaginfoStructTwo
  17383. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17384. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17385. //
  17386. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17387. // var config []*models.HisXtDiagnoseConfig
  17388. // for _, item := range diagnosis_ids {
  17389. // id, _ := strconv.ParseInt(item, 10, 64)
  17390. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17391. // config = append(config, &diagnosisConfig)
  17392. // }
  17393. //
  17394. // for index, item := range config {
  17395. // if index == 0 {
  17396. // var tempDiaginfo service.DiaginfoStructTwo
  17397. // tempDiaginfo.DiagCode = item.CountryCode
  17398. // tempDiaginfo.DiagName = item.CountryContentName
  17399. // tempDiaginfo.DiagType = "1"
  17400. // tempDiaginfo.MaindiagFlag = "1"
  17401. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17402. // } else {
  17403. // var tempDiaginfo service.DiaginfoStructTwo
  17404. // tempDiaginfo.DiagCode = item.CountryCode
  17405. // tempDiaginfo.DiagName = item.CountryContentName
  17406. // tempDiaginfo.DiagType = "1"
  17407. // tempDiaginfo.MaindiagFlag = "0"
  17408. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17409. // }
  17410. // }
  17411. // struct4101.Diseinfo = tempDiaginfos
  17412. //
  17413. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17414. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17415. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17416. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17417. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17418. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17419. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17420. //
  17421. // var iteminfo service.IteminfoStruct
  17422. //
  17423. // var bedCostTotal float64 = 0 //床位总费
  17424. // var bedCostSelfTotal float64 = 0 //床位自费
  17425. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17426. //
  17427. // var operationCostTotal float64 = 0 //手术费
  17428. // var operationCostSelfTotal float64 = 0 //手术费
  17429. // var operationCostPartSelfTotal float64 = 0 //手术费
  17430. //
  17431. // var otherCostTotal float64 = 0 //其他费用
  17432. // var otherCostSelfTotal float64 = 0 //其他费用
  17433. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17434. //
  17435. // var materialCostTotal float64 = 0 //材料费
  17436. // var materialCostSelfTotal float64 = 0 //材料费
  17437. // var materialCostPartSelfTotal float64 = 0 //材料费
  17438. //
  17439. // var westernMedicineCostTotal float64 = 0 //西药费
  17440. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17441. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17442. //
  17443. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17444. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17445. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17446. //
  17447. // var checkCostTotal float64 = 0 //检查费
  17448. // var checkCostSelfTotal float64 = 0 //检查费
  17449. // var checkCostPartSelfTotal float64 = 0 //检查费
  17450. //
  17451. // var laboratoryCostTotal float64 = 0 //化验费
  17452. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17453. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17454. //
  17455. // var treatCostTotal float64 = 0 //治疗费用
  17456. // var treatCostSelfTotal float64 = 0 //治疗费用
  17457. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17458. //
  17459. // decimal.DivisionPrecision = 2
  17460. //
  17461. // var bed_fulamt_ownpay_amt float64 = 0
  17462. // var operation_fulamt_ownpay_amt float64 = 0
  17463. // var other_fulamt_ownpay_amt float64 = 0
  17464. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17465. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17466. // var check_fulamt_ownpay_amt float64 = 0
  17467. // var material_fulamt_ownpay_amt float64 = 0
  17468. // var laboratory_fulamt_ownpay_amt float64 = 0
  17469. // var treat_fulamt_ownpay_amt float64 = 0
  17470. //
  17471. // var bed_claa_sunmfee float64 = 0
  17472. // var bed_clab_amt float64 = 0
  17473. // var bed_other_amt float64 = 0
  17474. //
  17475. // var operation_claa_sunmfee float64 = 0
  17476. // var operation_clab_amt float64 = 0
  17477. // var operation_other_amt float64 = 0
  17478. //
  17479. // var other_claa_sunmfee float64 = 0
  17480. // var other_clab_amt float64 = 0
  17481. // var other_other_amt float64 = 0
  17482. //
  17483. // var westernMedicine_claa_sunmfee float64 = 0
  17484. // var westernMedicine_clab_amt float64 = 0
  17485. // var westernMedicine_other_amt float64 = 0
  17486. //
  17487. // var chineseTraditional_claa_sunmfee float64 = 0
  17488. // var chineseTraditional_clab_amt float64 = 0
  17489. // var chineseTraditional_other_amt float64 = 0
  17490. //
  17491. // var check_claa_sunmfee float64 = 0
  17492. // var check_clab_amt float64 = 0
  17493. // var check_other_amt float64 = 0
  17494. //
  17495. // var material_claa_sunmfee float64 = 0
  17496. // var material_clab_amt float64 = 0
  17497. // var material_other_amt float64 = 0
  17498. //
  17499. // var laboratory_claa_sunmfee float64 = 0
  17500. // var laboratory_clab_amt float64 = 0
  17501. // var laboratory_other_amt float64 = 0
  17502. //
  17503. // var treat_claa_sunmfee float64 = 0
  17504. // var treat_clab_amt float64 = 0
  17505. // var treat_other_amt float64 = 0
  17506. //
  17507. // for _, item := range order.HisOrderInfo {
  17508. // if item.MedChrgitmType == "01" { //床位费
  17509. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17510. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17511. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17512. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17513. // if item.ChrgitmLv == "1" {
  17514. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17515. // }
  17516. // if item.ChrgitmLv == "2" {
  17517. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17518. //
  17519. // }
  17520. // if item.ChrgitmLv == "3" {
  17521. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17522. // }
  17523. //
  17524. // }
  17525. //
  17526. // if item.MedChrgitmType == "03" { //检查费
  17527. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17528. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17529. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17530. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17531. // if item.ChrgitmLv == "1" {
  17532. //
  17533. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17534. //
  17535. // }
  17536. // if item.ChrgitmLv == "2" {
  17537. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17538. //
  17539. // }
  17540. // if item.ChrgitmLv == "3" {
  17541. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17542. // }
  17543. // }
  17544. //
  17545. // if item.MedChrgitmType == "04" { //化验费
  17546. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17547. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17548. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17549. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17550. // if item.ChrgitmLv == "1" {
  17551. //
  17552. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17553. //
  17554. // }
  17555. // if item.ChrgitmLv == "2" {
  17556. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17557. //
  17558. // }
  17559. // if item.ChrgitmLv == "3" {
  17560. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17561. // }
  17562. // }
  17563. //
  17564. // if item.MedChrgitmType == "05" { //治疗费
  17565. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17566. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17567. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17568. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17569. // if item.ChrgitmLv == "1" {
  17570. //
  17571. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17572. //
  17573. // }
  17574. // if item.ChrgitmLv == "2" {
  17575. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17576. //
  17577. // }
  17578. // if item.ChrgitmLv == "3" {
  17579. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17580. // }
  17581. // }
  17582. //
  17583. // if item.MedChrgitmType == "06" { //手术费
  17584. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17585. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17586. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17587. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17588. //
  17589. // if item.ChrgitmLv == "1" {
  17590. //
  17591. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17592. //
  17593. // }
  17594. // if item.ChrgitmLv == "2" {
  17595. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17596. //
  17597. // }
  17598. // if item.ChrgitmLv == "3" {
  17599. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17600. // }
  17601. // }
  17602. //
  17603. // if item.MedChrgitmType == "08" { //材料费
  17604. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17605. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17606. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17607. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17608. // if item.ChrgitmLv == "1" {
  17609. //
  17610. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17611. //
  17612. // }
  17613. // if item.ChrgitmLv == "2" {
  17614. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17615. //
  17616. // }
  17617. // if item.ChrgitmLv == "3" {
  17618. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17619. // }
  17620. // }
  17621. //
  17622. // if item.MedChrgitmType == "09" { //西药费
  17623. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17624. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17625. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17626. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17627. // if item.ChrgitmLv == "1" {
  17628. //
  17629. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17630. //
  17631. // }
  17632. // if item.ChrgitmLv == "2" {
  17633. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17634. //
  17635. // }
  17636. // if item.ChrgitmLv == "3" {
  17637. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17638. // }
  17639. // }
  17640. //
  17641. // if item.MedChrgitmType == "11" { //中成费
  17642. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17643. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17644. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17645. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17646. // if item.ChrgitmLv == "1" {
  17647. //
  17648. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17649. //
  17650. // }
  17651. // if item.ChrgitmLv == "2" {
  17652. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17653. //
  17654. // }
  17655. // if item.ChrgitmLv == "3" {
  17656. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17657. // }
  17658. // }
  17659. //
  17660. // if item.MedChrgitmType == "14" { //其他费
  17661. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17662. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17663. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17664. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17665. // if item.ChrgitmLv == "1" {
  17666. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17667. //
  17668. // }
  17669. // if item.ChrgitmLv == "2" {
  17670. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17671. //
  17672. // }
  17673. // if item.ChrgitmLv == "3" {
  17674. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17675. // }
  17676. // }
  17677. //
  17678. // }
  17679. //
  17680. // var iteminfoStructs []service.IteminfoStruct
  17681. //
  17682. // if bedCostTotal != 0 {
  17683. // iteminfo.MedChrgitm = "01"
  17684. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17685. // iteminfo.Amt = bedCostTotal
  17686. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  17687. // iteminfo.ClabAmt = bed_clab_amt
  17688. // iteminfo.OthAmt = bed_other_amt
  17689. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17690. // }
  17691. //
  17692. // if checkCostTotal != 0 {
  17693. // iteminfo.MedChrgitm = "03"
  17694. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17695. // iteminfo.Amt = checkCostTotal
  17696. // iteminfo.ClaaSumfee = check_claa_sunmfee
  17697. // iteminfo.ClabAmt = check_clab_amt
  17698. // iteminfo.OthAmt = check_other_amt
  17699. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17700. //
  17701. // }
  17702. //
  17703. // if laboratoryCostTotal != 0 {
  17704. // iteminfo.MedChrgitm = "04"
  17705. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17706. // iteminfo.Amt = laboratoryCostTotal
  17707. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17708. // iteminfo.ClabAmt = laboratory_clab_amt
  17709. // iteminfo.OthAmt = laboratory_other_amt
  17710. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17711. //
  17712. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17713. //
  17714. // }
  17715. //
  17716. // if treatCostTotal != 0 {
  17717. // iteminfo.MedChrgitm = "05"
  17718. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17719. // iteminfo.Amt = treatCostTotal
  17720. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  17721. // iteminfo.ClabAmt = treat_clab_amt
  17722. // iteminfo.OthAmt = treat_other_amt
  17723. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17724. // //(struct4101.IteminfoStruct, iteminfo)
  17725. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17726. // }
  17727. //
  17728. // if operationCostTotal != 0 {
  17729. // iteminfo.MedChrgitm = "06"
  17730. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17731. // iteminfo.Amt = operationCostTotal
  17732. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  17733. // iteminfo.ClabAmt = operation_clab_amt
  17734. // iteminfo.OthAmt = operation_other_amt
  17735. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17736. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17737. // }
  17738. //
  17739. // if materialCostTotal != 0 {
  17740. // iteminfo.MedChrgitm = "08"
  17741. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  17742. // iteminfo.Amt = materialCostTotal
  17743. // iteminfo.ClaaSumfee = material_claa_sunmfee
  17744. // iteminfo.ClabAmt = material_clab_amt
  17745. // iteminfo.OthAmt = material_other_amt
  17746. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17747. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17748. // }
  17749. //
  17750. // if westernMedicineCostTotal != 0 {
  17751. // iteminfo.MedChrgitm = "09"
  17752. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17753. // iteminfo.Amt = westernMedicineCostTotal
  17754. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17755. // iteminfo.ClabAmt = westernMedicine_clab_amt
  17756. // iteminfo.OthAmt = westernMedicine_other_amt
  17757. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17758. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17759. //
  17760. // }
  17761. // if chineseTraditionalMedicineCostTotal != 0 {
  17762. // iteminfo.MedChrgitm = "11"
  17763. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17764. // iteminfo.Amt = westernMedicineCostTotal
  17765. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17766. // iteminfo.ClabAmt = westernMedicine_clab_amt
  17767. // iteminfo.OthAmt = westernMedicine_other_amt
  17768. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17769. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17770. //
  17771. // }
  17772. // if otherCostTotal != 0 {
  17773. // iteminfo.MedChrgitm = "14"
  17774. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  17775. // iteminfo.Amt = otherCostTotal
  17776. // iteminfo.ClaaSumfee = other_claa_sunmfee
  17777. // iteminfo.ClabAmt = other_clab_amt
  17778. // iteminfo.OthAmt = other_other_amt
  17779. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17780. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  17781. //
  17782. // }
  17783. // struct4101.IteminfoStruct = iteminfoStructs
  17784. // struct4101.Ntly = "中国"
  17785. // struct4101.AdmCaty = "A03.06"
  17786. //
  17787. // struct4101.DoctorName = doctor.UserName
  17788. // struct4101.DoctorCode = doctor.DoctorNumber
  17789. //
  17790. // var res ResultSeventeen
  17791. //
  17792. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17793. // struct4101.BillCode = order.Number
  17794. // struct4101.BillNo = order.SetlId
  17795. // var resOther ResultSeventeenOther
  17796. // var pp models.PublicParams
  17797. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17798. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17799. // pp.FixmedinsName = miConfig.OrgName
  17800. // pp.FixmedinsCode = miConfig.Code
  17801. // pp.RequestUrl = miConfig.Url
  17802. // pp.Cainfo = miConfig.Cainfo
  17803. // pp.SecretKey = miConfig.SecretKey
  17804. // pp.AccessKey = miConfig.AccessKey
  17805. // pp.OpterName = curRoles.UserName
  17806. //
  17807. // client := &http.Client{}
  17808. // var req *http.Request
  17809. // data := make(map[string]interface{})
  17810. // data["struct4101"] = struct4101
  17811. // data["pp"] = pp
  17812. // bytesData, _ := json.Marshal(data)
  17813. // if miConfig.MdtrtareaAdmvs == "320921" {
  17814. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17815. // } else {
  17816. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17817. // }
  17818. // resp, _ := client.Do(req)
  17819. // defer resp.Body.Close()
  17820. // body, ioErr := ioutil.ReadAll(resp.Body)
  17821. // if ioErr != nil {
  17822. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17824. // return
  17825. // }
  17826. // var respJSON map[string]interface{}
  17827. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17828. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17829. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17830. // return
  17831. // }
  17832. //
  17833. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17834. // userJSONBytes, _ := json.Marshal(respJSON)
  17835. // fmt.Println("log")
  17836. // fmt.Println(string(userJSONBytes))
  17837. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17838. // utils.ErrorLog("解析失败:%v", err)
  17839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17840. // return
  17841. // }
  17842. // res.InfRefmsgid = resOther.InfRefmsgid
  17843. // res.Output = resOther.Output
  17844. // res.ErrMsg = resOther.ErrMsg
  17845. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17846. // res.Infcode = infocode
  17847. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  17848. //
  17849. // var pp models.PublicParams
  17850. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17851. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17852. // pp.FixmedinsName = miConfig.OrgName
  17853. // pp.FixmedinsCode = miConfig.Code
  17854. // pp.RequestUrl = miConfig.Url
  17855. // pp.Cainfo = miConfig.Cainfo
  17856. // pp.SecretKey = miConfig.SecretKey
  17857. // pp.AccessKey = miConfig.AccessKey
  17858. // pp.OpterName = curRoles.UserName
  17859. // result, _ := service.Jxyb4101(struct4101, pp)
  17860. // var dat map[string]interface{}
  17861. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17862. // fmt.Println(dat)
  17863. // } else {
  17864. // fmt.Println(err)
  17865. // }
  17866. // userJSONBytes, _ := json.Marshal(dat)
  17867. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17868. // utils.ErrorLog("解析失败:%v", err)
  17869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17870. // return
  17871. // }
  17872. //
  17873. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  17874. // var pp models.PublicParams
  17875. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17876. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17877. // pp.FixmedinsName = miConfig.OrgName
  17878. // pp.FixmedinsCode = miConfig.Code
  17879. // pp.RequestUrl = miConfig.Url
  17880. // pp.Cainfo = miConfig.Cainfo
  17881. // pp.SecretKey = miConfig.SecretKey
  17882. // pp.AccessKey = miConfig.AccessKey
  17883. // pp.OpterName = curRoles.UserName
  17884. // result, _ := service.Hnyb4101(struct4101, pp)
  17885. // var dat map[string]interface{}
  17886. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17887. // fmt.Println(dat)
  17888. // } else {
  17889. // fmt.Println(err)
  17890. // }
  17891. // userJSONBytes, _ := json.Marshal(dat)
  17892. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17893. // utils.ErrorLog("解析失败:%v", err)
  17894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17895. // return
  17896. // }
  17897. //
  17898. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  17899. // var resOther ResultSeventeenOther
  17900. //
  17901. // var pp models.PublicParams
  17902. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17903. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17904. // pp.FixmedinsName = miConfig.OrgName
  17905. // pp.FixmedinsCode = miConfig.Code
  17906. // pp.RequestUrl = miConfig.Url
  17907. // pp.Cainfo = miConfig.Cainfo
  17908. // pp.SecretKey = miConfig.SecretKey
  17909. // pp.AccessKey = miConfig.AccessKey
  17910. // pp.OpterName = curRoles.UserName
  17911. // client := &http.Client{}
  17912. // var req *http.Request
  17913. // data := make(map[string]interface{})
  17914. // data["struct4101"] = struct4101
  17915. // data["pp"] = pp
  17916. // bytesData, _ := json.Marshal(data)
  17917. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17918. // resp, _ := client.Do(req)
  17919. // defer resp.Body.Close()
  17920. // body, ioErr := ioutil.ReadAll(resp.Body)
  17921. // if ioErr != nil {
  17922. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17923. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17924. // return
  17925. // }
  17926. // var respJSON map[string]interface{}
  17927. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17928. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17929. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17930. // return
  17931. // }
  17932. //
  17933. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17934. // userJSONBytes, _ := json.Marshal(respJSON)
  17935. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17936. // utils.ErrorLog("解析失败:%v", err)
  17937. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17938. // return
  17939. // }
  17940. // res.InfRefmsgid = resOther.InfRefmsgid
  17941. // res.Output = resOther.Output
  17942. // res.ErrMsg = resOther.ErrMsg
  17943. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17944. // res.Infcode = infocode
  17945. //
  17946. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  17947. // var pp models.PublicParams
  17948. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17949. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17950. // pp.FixmedinsName = miConfig.OrgName
  17951. // pp.FixmedinsCode = miConfig.Code
  17952. // pp.RequestUrl = miConfig.Url
  17953. // pp.Cainfo = miConfig.Cainfo
  17954. // pp.SecretKey = miConfig.SecretKey
  17955. // pp.AccessKey = miConfig.AccessKey
  17956. // pp.OpterName = curRoles.UserName
  17957. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  17958. // fmt.Println(requestLog)
  17959. // fmt.Println(errMsgLog)
  17960. //
  17961. // saveLog(result, requestLog, "4101a", "上传清单")
  17962. //
  17963. // var dat map[string]interface{}
  17964. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17965. // fmt.Println(dat)
  17966. // } else {
  17967. // fmt.Println(err)
  17968. // }
  17969. // userJSONBytes, _ := json.Marshal(dat)
  17970. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17971. // utils.ErrorLog("解析失败:%v", err)
  17972. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17973. // return
  17974. // }
  17975. //
  17976. // } else {
  17977. //
  17978. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  17979. // var dat map[string]interface{}
  17980. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17981. // fmt.Println(dat)
  17982. // } else {
  17983. // fmt.Println(err)
  17984. // }
  17985. // userJSONBytes, _ := json.Marshal(dat)
  17986. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17987. // utils.ErrorLog("解析失败:%v", err)
  17988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17989. // return
  17990. // }
  17991. // }
  17992. //
  17993. // if res.Infcode != 0 {
  17994. // adminUser := c.GetAdminUserInfo()
  17995. // errlog := &models.HisOrderError{
  17996. // UserOrgId: adminUser.CurrentOrgId,
  17997. // Ctime: time.Now().Unix(),
  17998. // Mtime: time.Now().Unix(),
  17999. // ErrMsg: res.ErrMsg,
  18000. // Status: 1,
  18001. // PatientId: order.ID,
  18002. // Stage: 10265,
  18003. // }
  18004. // service.CreateErrMsgLog(errlog)
  18005. // continue
  18006. // } else {
  18007. // //order.FaPiaoNumber = zero
  18008. // //order.FaPiaoCode = last_order.FaPiaoCode
  18009. // //service.UpdateOrder(order)
  18010. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18011. // Number: res.Output.SetlListId,
  18012. // Status: 1,
  18013. // Ctime: time.Now().Unix(),
  18014. // Mtime: time.Now().Unix(),
  18015. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18016. // IsUpload: 1,
  18017. // OrderId: order.ID,
  18018. // }
  18019. // service.CreateUploadRecord(hisFundSettleListResult)
  18020. // c.ServeSuccessJSON(map[string]interface{}{
  18021. // "msg": "上传成功",
  18022. // "result": hisFundSettleListResult,
  18023. // })
  18024. // continue
  18025. // }
  18026. // }
  18027. //}
  18028. func (c *HisApiController) GetbatchSettleList() {
  18029. //order_id, _ := c.GetInt64("order_id")
  18030. admin_user_id, _ := c.GetInt64("admin_user_id")
  18031. orders, _ := service.GetAllHisOrderTwo10485()
  18032. for _, item := range orders {
  18033. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18034. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18035. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18036. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18037. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18038. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18039. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18040. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18041. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18042. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18043. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18044. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18045. //fmt.Println(count)
  18046. //var zero string
  18047. //number := count + 1
  18048. //if number >= 1000 {
  18049. // zero = "0000" + strconv.FormatInt(number, 10)
  18050. //} else if number >= 10000 {
  18051. // zero = "000" + strconv.FormatInt(number, 10)
  18052. //} else if number >= 100000 {
  18053. // zero = "00" + strconv.FormatInt(number, 10)
  18054. //} else if number >= 1000000 {
  18055. // zero = "0" + strconv.FormatInt(number, 10)
  18056. //} else {
  18057. // zero = strconv.FormatInt(number, 10)
  18058. //}
  18059. //fmt.Println(zero)
  18060. struct4101 := service.Struct4101{
  18061. PsnNo: order.PsnNo,
  18062. MdtrtId: order.MdtrtId,
  18063. SetlId: order.SetlId,
  18064. PsnName: order.PsnName,
  18065. Gend: order.Gend,
  18066. Brdy: his.Brdy,
  18067. Age: his.Age,
  18068. Naty: order.Naty,
  18069. PatnCertType: "01",
  18070. Certno: order.Certno,
  18071. Prfs: "90",
  18072. ConerName: roles[0].UserName,
  18073. PatnRlts: "99",
  18074. ConerAddr: miConfig.OrgName,
  18075. ConerTel: admin.Mobile,
  18076. HiType: order.Insutype,
  18077. Insuplc: miConfig.InsuplcAdmdvs,
  18078. MaindiagFlag: "1",
  18079. BillCode: order.SetlId,
  18080. BillNo: order.SetlId,
  18081. BizSn: order.Number,
  18082. PsnSelfPay: order.PsnPartAmt,
  18083. PsnOwnPay: order.PsnPartAmt,
  18084. AcctPay: order.AcctPay,
  18085. PsnCashpay: order.PsnCashPay,
  18086. HiPaymtd: "1",
  18087. Hsorg: miConfig.InsuplcAdmdvs,
  18088. HsorgOpter: miConfig.InsuplcAdmdvs,
  18089. MedinsFillPsn: curRoles.UserName,
  18090. MedinsFillDept: miConfig.OrgName,
  18091. IptMedType: "2",
  18092. }
  18093. struct4101.SetlBegnDate = order.SetlTime
  18094. struct4101.SetlEndDate = order.SetlTime
  18095. time_arr := strings.Split(order.SetlTime, " ")
  18096. struct4101.AdmTime = time_arr[0]
  18097. struct4101.AdmEndTime = time_arr[0]
  18098. //var rf []CustomFundPay
  18099. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18100. //
  18101. //var tempFunPays []service.CustomStruct
  18102. //for _, item := range rf {
  18103. // var tempFunPay service.CustomStruct
  18104. // tempFunPay.FundPayamt = item.FundPayamt
  18105. // tempFunPay.FundPayType = item.FundPayType
  18106. // tempFunPays = append(tempFunPays, tempFunPay)
  18107. //}
  18108. //struct4101.CustomStruct = tempFunPays
  18109. var tempDiaginfos []service.DiaginfoStructTwo
  18110. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18111. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18112. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18113. var config []*models.HisXtDiagnoseConfig
  18114. for _, item := range diagnosis_ids {
  18115. id, _ := strconv.ParseInt(item, 10, 64)
  18116. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18117. config = append(config, &diagnosisConfig)
  18118. }
  18119. for index, item := range config {
  18120. if index == 0 {
  18121. var tempDiaginfo service.DiaginfoStructTwo
  18122. tempDiaginfo.DiagCode = item.CountryCode
  18123. tempDiaginfo.DiagName = item.CountryContentName
  18124. tempDiaginfo.DiagType = "1"
  18125. tempDiaginfo.MaindiagFlag = "1"
  18126. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18127. } else {
  18128. var tempDiaginfo service.DiaginfoStructTwo
  18129. tempDiaginfo.DiagCode = item.CountryCode
  18130. tempDiaginfo.DiagName = item.CountryContentName
  18131. tempDiaginfo.DiagType = "1"
  18132. tempDiaginfo.MaindiagFlag = "0"
  18133. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18134. }
  18135. }
  18136. struct4101.Diseinfo = tempDiaginfos
  18137. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18138. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18139. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18140. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18141. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18142. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18143. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18144. var iteminfo service.IteminfoStruct
  18145. var bedCostTotal float64 = 0 //床位总费
  18146. var bedCostSelfTotal float64 = 0 //床位自费
  18147. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18148. var operationCostTotal float64 = 0 //手术费
  18149. var operationCostSelfTotal float64 = 0 //手术费
  18150. var operationCostPartSelfTotal float64 = 0 //手术费
  18151. var otherCostTotal float64 = 0 //其他费用
  18152. var otherCostSelfTotal float64 = 0 //其他费用
  18153. var otherCostPartSelfTotal float64 = 0 //其他费用
  18154. var materialCostTotal float64 = 0 //材料费
  18155. var materialCostSelfTotal float64 = 0 //材料费
  18156. var materialCostPartSelfTotal float64 = 0 //材料费
  18157. var westernMedicineCostTotal float64 = 0 //西药费
  18158. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18159. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18160. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18161. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18162. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18163. var checkCostTotal float64 = 0 //检查费
  18164. var checkCostSelfTotal float64 = 0 //检查费
  18165. var checkCostPartSelfTotal float64 = 0 //检查费
  18166. var laboratoryCostTotal float64 = 0 //化验费
  18167. var laboratoryCostSelfTotal float64 = 0 //化验费
  18168. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18169. var treatCostTotal float64 = 0 //治疗费用
  18170. var treatCostSelfTotal float64 = 0 //治疗费用
  18171. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18172. decimal.DivisionPrecision = 2
  18173. var bed_fulamt_ownpay_amt float64 = 0
  18174. var operation_fulamt_ownpay_amt float64 = 0
  18175. var other_fulamt_ownpay_amt float64 = 0
  18176. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18177. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18178. var check_fulamt_ownpay_amt float64 = 0
  18179. var material_fulamt_ownpay_amt float64 = 0
  18180. var laboratory_fulamt_ownpay_amt float64 = 0
  18181. var treat_fulamt_ownpay_amt float64 = 0
  18182. var bed_claa_sunmfee float64 = 0
  18183. var bed_clab_amt float64 = 0
  18184. var bed_other_amt float64 = 0
  18185. var operation_claa_sunmfee float64 = 0
  18186. var operation_clab_amt float64 = 0
  18187. var operation_other_amt float64 = 0
  18188. var other_claa_sunmfee float64 = 0
  18189. var other_clab_amt float64 = 0
  18190. var other_other_amt float64 = 0
  18191. var westernMedicine_claa_sunmfee float64 = 0
  18192. var westernMedicine_clab_amt float64 = 0
  18193. var westernMedicine_other_amt float64 = 0
  18194. var chineseTraditional_claa_sunmfee float64 = 0
  18195. var chineseTraditional_clab_amt float64 = 0
  18196. var chineseTraditional_other_amt float64 = 0
  18197. var check_claa_sunmfee float64 = 0
  18198. var check_clab_amt float64 = 0
  18199. var check_other_amt float64 = 0
  18200. var material_claa_sunmfee float64 = 0
  18201. var material_clab_amt float64 = 0
  18202. var material_other_amt float64 = 0
  18203. var laboratory_claa_sunmfee float64 = 0
  18204. var laboratory_clab_amt float64 = 0
  18205. var laboratory_other_amt float64 = 0
  18206. var treat_claa_sunmfee float64 = 0
  18207. var treat_clab_amt float64 = 0
  18208. var treat_other_amt float64 = 0
  18209. for _, item := range order.HisOrderInfo {
  18210. if item.MedChrgitmType == "01" { //床位费
  18211. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18212. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18213. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18214. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18215. if item.ChrgitmLv == "1" {
  18216. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18217. }
  18218. if item.ChrgitmLv == "2" {
  18219. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18220. }
  18221. if item.ChrgitmLv == "3" {
  18222. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18223. }
  18224. }
  18225. if item.MedChrgitmType == "03" { //检查费
  18226. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18227. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18228. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18229. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18230. if item.ChrgitmLv == "1" {
  18231. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18232. }
  18233. if item.ChrgitmLv == "2" {
  18234. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18235. }
  18236. if item.ChrgitmLv == "3" {
  18237. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18238. }
  18239. }
  18240. if item.MedChrgitmType == "04" { //化验费
  18241. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18242. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18243. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18244. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18245. if item.ChrgitmLv == "1" {
  18246. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18247. }
  18248. if item.ChrgitmLv == "2" {
  18249. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18250. }
  18251. if item.ChrgitmLv == "3" {
  18252. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18253. }
  18254. }
  18255. if item.MedChrgitmType == "05" { //治疗费
  18256. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18257. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18258. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18259. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18260. if item.ChrgitmLv == "1" {
  18261. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18262. }
  18263. if item.ChrgitmLv == "2" {
  18264. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18265. }
  18266. if item.ChrgitmLv == "3" {
  18267. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18268. }
  18269. }
  18270. if item.MedChrgitmType == "06" { //手术费
  18271. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18272. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18273. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18274. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18275. if item.ChrgitmLv == "1" {
  18276. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18277. }
  18278. if item.ChrgitmLv == "2" {
  18279. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18280. }
  18281. if item.ChrgitmLv == "3" {
  18282. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18283. }
  18284. }
  18285. if item.MedChrgitmType == "08" { //材料费
  18286. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18287. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18288. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18289. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18290. if item.ChrgitmLv == "1" {
  18291. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18292. }
  18293. if item.ChrgitmLv == "2" {
  18294. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18295. }
  18296. if item.ChrgitmLv == "3" {
  18297. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18298. }
  18299. }
  18300. if item.MedChrgitmType == "09" { //西药费
  18301. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18302. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18303. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18304. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18305. if item.ChrgitmLv == "1" {
  18306. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18307. }
  18308. if item.ChrgitmLv == "2" {
  18309. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18310. }
  18311. if item.ChrgitmLv == "3" {
  18312. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18313. }
  18314. }
  18315. if item.MedChrgitmType == "11" { //中成费
  18316. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18317. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18318. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18319. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18320. if item.ChrgitmLv == "1" {
  18321. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18322. }
  18323. if item.ChrgitmLv == "2" {
  18324. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18325. }
  18326. if item.ChrgitmLv == "3" {
  18327. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18328. }
  18329. }
  18330. if item.MedChrgitmType == "14" { //其他费
  18331. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18332. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18333. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18334. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18335. if item.ChrgitmLv == "1" {
  18336. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18337. }
  18338. if item.ChrgitmLv == "2" {
  18339. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18340. }
  18341. if item.ChrgitmLv == "3" {
  18342. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18343. }
  18344. }
  18345. }
  18346. var iteminfoStructs []service.IteminfoStruct
  18347. if bedCostTotal != 0 {
  18348. iteminfo.MedChrgitm = "01"
  18349. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18350. iteminfo.Amt = bedCostTotal
  18351. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18352. iteminfo.ClabAmt = bed_clab_amt
  18353. iteminfo.OthAmt = bed_other_amt
  18354. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18355. }
  18356. if checkCostTotal != 0 {
  18357. iteminfo.MedChrgitm = "03"
  18358. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18359. iteminfo.Amt = checkCostTotal
  18360. iteminfo.ClaaSumfee = check_claa_sunmfee
  18361. iteminfo.ClabAmt = check_clab_amt
  18362. iteminfo.OthAmt = check_other_amt
  18363. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18364. }
  18365. if laboratoryCostTotal != 0 {
  18366. iteminfo.MedChrgitm = "04"
  18367. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18368. iteminfo.Amt = laboratoryCostTotal
  18369. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18370. iteminfo.ClabAmt = laboratory_clab_amt
  18371. iteminfo.OthAmt = laboratory_other_amt
  18372. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18373. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18374. }
  18375. if treatCostTotal != 0 {
  18376. iteminfo.MedChrgitm = "05"
  18377. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18378. iteminfo.Amt = treatCostTotal
  18379. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18380. iteminfo.ClabAmt = treat_clab_amt
  18381. iteminfo.OthAmt = treat_other_amt
  18382. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18383. //(struct4101.IteminfoStruct, iteminfo)
  18384. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18385. }
  18386. if operationCostTotal != 0 {
  18387. iteminfo.MedChrgitm = "06"
  18388. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18389. iteminfo.Amt = operationCostTotal
  18390. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18391. iteminfo.ClabAmt = operation_clab_amt
  18392. iteminfo.OthAmt = operation_other_amt
  18393. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18394. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18395. }
  18396. if materialCostTotal != 0 {
  18397. iteminfo.MedChrgitm = "08"
  18398. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18399. iteminfo.Amt = materialCostTotal
  18400. iteminfo.ClaaSumfee = material_claa_sunmfee
  18401. iteminfo.ClabAmt = material_clab_amt
  18402. iteminfo.OthAmt = material_other_amt
  18403. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18404. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18405. }
  18406. if westernMedicineCostTotal != 0 {
  18407. iteminfo.MedChrgitm = "09"
  18408. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18409. iteminfo.Amt = westernMedicineCostTotal
  18410. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18411. iteminfo.ClabAmt = westernMedicine_clab_amt
  18412. iteminfo.OthAmt = westernMedicine_other_amt
  18413. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18414. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18415. }
  18416. if chineseTraditionalMedicineCostTotal != 0 {
  18417. iteminfo.MedChrgitm = "11"
  18418. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18419. iteminfo.Amt = westernMedicineCostTotal
  18420. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18421. iteminfo.ClabAmt = westernMedicine_clab_amt
  18422. iteminfo.OthAmt = westernMedicine_other_amt
  18423. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18424. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18425. }
  18426. if otherCostTotal != 0 {
  18427. iteminfo.MedChrgitm = "14"
  18428. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18429. iteminfo.Amt = otherCostTotal
  18430. iteminfo.ClaaSumfee = other_claa_sunmfee
  18431. iteminfo.ClabAmt = other_clab_amt
  18432. iteminfo.OthAmt = other_other_amt
  18433. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18434. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18435. }
  18436. struct4101.IteminfoStruct = iteminfoStructs
  18437. struct4101.Ntly = "中国"
  18438. struct4101.AdmCaty = "A03.06"
  18439. struct4101.DoctorName = doctor.UserName
  18440. struct4101.DoctorCode = doctor.DoctorNumber
  18441. var res ResultSeventeen
  18442. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18443. struct4101.BillCode = order.Number
  18444. struct4101.BillNo = order.SetlId
  18445. var resOther ResultSeventeenOther
  18446. var pp models.PublicParams
  18447. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18448. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18449. pp.FixmedinsName = miConfig.OrgName
  18450. pp.FixmedinsCode = miConfig.Code
  18451. pp.RequestUrl = miConfig.Url
  18452. pp.Cainfo = miConfig.Cainfo
  18453. pp.SecretKey = miConfig.SecretKey
  18454. pp.AccessKey = miConfig.AccessKey
  18455. pp.OpterName = curRoles.UserName
  18456. client := &http.Client{}
  18457. var req *http.Request
  18458. data := make(map[string]interface{})
  18459. data["struct4101"] = struct4101
  18460. data["pp"] = pp
  18461. bytesData, _ := json.Marshal(data)
  18462. if miConfig.MdtrtareaAdmvs == "320921" {
  18463. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18464. } else {
  18465. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18466. }
  18467. resp, _ := client.Do(req)
  18468. defer resp.Body.Close()
  18469. body, ioErr := ioutil.ReadAll(resp.Body)
  18470. if ioErr != nil {
  18471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18473. return
  18474. }
  18475. var respJSON map[string]interface{}
  18476. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18479. return
  18480. }
  18481. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18482. userJSONBytes, _ := json.Marshal(respJSON)
  18483. fmt.Println("log")
  18484. fmt.Println(string(userJSONBytes))
  18485. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18486. utils.ErrorLog("解析失败:%v", err)
  18487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18488. return
  18489. }
  18490. res.InfRefmsgid = resOther.InfRefmsgid
  18491. res.Output = resOther.Output
  18492. res.ErrMsg = resOther.ErrMsg
  18493. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18494. res.Infcode = infocode
  18495. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18496. var pp models.PublicParams
  18497. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18498. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18499. pp.FixmedinsName = miConfig.OrgName
  18500. pp.FixmedinsCode = miConfig.Code
  18501. pp.RequestUrl = miConfig.Url
  18502. pp.Cainfo = miConfig.Cainfo
  18503. pp.SecretKey = miConfig.SecretKey
  18504. pp.AccessKey = miConfig.AccessKey
  18505. pp.OpterName = curRoles.UserName
  18506. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18507. result, _ := service.Jxyb4101(struct4101, pp)
  18508. var dat map[string]interface{}
  18509. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18510. fmt.Println(dat)
  18511. } else {
  18512. fmt.Println(err)
  18513. }
  18514. userJSONBytes, _ := json.Marshal(dat)
  18515. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18516. utils.ErrorLog("解析失败:%v", err)
  18517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18518. return
  18519. }
  18520. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18521. var pp models.PublicParams
  18522. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18523. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18524. pp.FixmedinsName = miConfig.OrgName
  18525. pp.FixmedinsCode = miConfig.Code
  18526. pp.RequestUrl = miConfig.Url
  18527. pp.Cainfo = miConfig.Cainfo
  18528. pp.SecretKey = miConfig.SecretKey
  18529. pp.AccessKey = miConfig.AccessKey
  18530. pp.OpterName = curRoles.UserName
  18531. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18532. result, _ := service.Jxyb4101(struct4101, pp)
  18533. var dat map[string]interface{}
  18534. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18535. fmt.Println(dat)
  18536. } else {
  18537. fmt.Println(err)
  18538. }
  18539. userJSONBytes, _ := json.Marshal(dat)
  18540. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18541. utils.ErrorLog("解析失败:%v", err)
  18542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18543. return
  18544. }
  18545. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18546. var pp models.PublicParams
  18547. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18548. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18549. pp.FixmedinsName = miConfig.OrgName
  18550. pp.FixmedinsCode = miConfig.Code
  18551. pp.RequestUrl = miConfig.Url
  18552. pp.Cainfo = miConfig.Cainfo
  18553. pp.SecretKey = miConfig.SecretKey
  18554. pp.AccessKey = miConfig.AccessKey
  18555. pp.OpterName = curRoles.UserName
  18556. result, _ := service.Hnyb4101(struct4101, pp)
  18557. var dat map[string]interface{}
  18558. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18559. fmt.Println(dat)
  18560. } else {
  18561. fmt.Println(err)
  18562. }
  18563. userJSONBytes, _ := json.Marshal(dat)
  18564. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18565. utils.ErrorLog("解析失败:%v", err)
  18566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18567. return
  18568. }
  18569. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18570. var resOther ResultSeventeenOther
  18571. var pp models.PublicParams
  18572. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18573. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18574. pp.FixmedinsName = miConfig.OrgName
  18575. pp.FixmedinsCode = miConfig.Code
  18576. pp.RequestUrl = miConfig.Url
  18577. pp.Cainfo = miConfig.Cainfo
  18578. pp.SecretKey = miConfig.SecretKey
  18579. pp.AccessKey = miConfig.AccessKey
  18580. pp.OpterName = curRoles.UserName
  18581. client := &http.Client{}
  18582. var req *http.Request
  18583. data := make(map[string]interface{})
  18584. data["struct4101"] = struct4101
  18585. data["pp"] = pp
  18586. bytesData, _ := json.Marshal(data)
  18587. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18588. resp, _ := client.Do(req)
  18589. defer resp.Body.Close()
  18590. body, ioErr := ioutil.ReadAll(resp.Body)
  18591. if ioErr != nil {
  18592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18594. return
  18595. }
  18596. var respJSON map[string]interface{}
  18597. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18600. return
  18601. }
  18602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18603. userJSONBytes, _ := json.Marshal(respJSON)
  18604. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18605. utils.ErrorLog("解析失败:%v", err)
  18606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18607. return
  18608. }
  18609. res.InfRefmsgid = resOther.InfRefmsgid
  18610. res.Output = resOther.Output
  18611. res.ErrMsg = resOther.ErrMsg
  18612. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18613. res.Infcode = infocode
  18614. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18615. var pp models.PublicParams
  18616. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18617. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18618. pp.FixmedinsName = miConfig.OrgName
  18619. pp.FixmedinsCode = miConfig.Code
  18620. pp.RequestUrl = miConfig.Url
  18621. pp.Cainfo = miConfig.Cainfo
  18622. pp.SecretKey = miConfig.SecretKey
  18623. pp.AccessKey = miConfig.AccessKey
  18624. pp.OpterName = curRoles.UserName
  18625. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18626. fmt.Println(requestLog)
  18627. fmt.Println(errMsgLog)
  18628. saveLog(result, requestLog, "4101a", "上传清单")
  18629. var dat map[string]interface{}
  18630. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18631. fmt.Println(dat)
  18632. } else {
  18633. fmt.Println(err)
  18634. }
  18635. userJSONBytes, _ := json.Marshal(dat)
  18636. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18637. utils.ErrorLog("解析失败:%v", err)
  18638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18639. return
  18640. }
  18641. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18642. var pp models.PublicParams
  18643. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18644. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18645. pp.FixmedinsName = miConfig.OrgName
  18646. pp.FixmedinsCode = miConfig.Code
  18647. pp.RequestUrl = miConfig.Url
  18648. pp.Cainfo = miConfig.Cainfo
  18649. pp.SecretKey = miConfig.SecretKey
  18650. pp.AccessKey = miConfig.AccessKey
  18651. pp.OpterName = curRoles.UserName
  18652. client := &http.Client{}
  18653. var req *http.Request
  18654. data := make(map[string]interface{})
  18655. data["struct4101"] = struct4101
  18656. data["pp"] = pp
  18657. bytesData, _ := json.Marshal(data)
  18658. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  18659. resp, _ := client.Do(req)
  18660. defer resp.Body.Close()
  18661. body, ioErr := ioutil.ReadAll(resp.Body)
  18662. if ioErr != nil {
  18663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18665. return
  18666. }
  18667. var respJSON map[string]interface{}
  18668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18671. return
  18672. }
  18673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18674. userJSONBytes, _ := json.Marshal(respJSON)
  18675. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18676. utils.ErrorLog("解析失败:%v", err)
  18677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18678. return
  18679. }
  18680. } else {
  18681. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18682. var dat map[string]interface{}
  18683. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18684. fmt.Println(dat)
  18685. } else {
  18686. fmt.Println(err)
  18687. }
  18688. userJSONBytes, _ := json.Marshal(dat)
  18689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18690. utils.ErrorLog("解析失败:%v", err)
  18691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18692. return
  18693. }
  18694. }
  18695. if res.Infcode != 0 {
  18696. errlog := &models.HisOrderError{
  18697. UserOrgId: order.UserOrgId,
  18698. Ctime: time.Now().Unix(),
  18699. Mtime: time.Now().Unix(),
  18700. ErrMsg: res.ErrMsg + "解析失败",
  18701. Status: 1,
  18702. PatientId: order.ID,
  18703. Stage: 10485,
  18704. }
  18705. service.CreateErrMsgLog(errlog)
  18706. continue
  18707. //c.ServeSuccessJSON(map[string]interface{}{
  18708. // "failed_code": -10,
  18709. // "msg": res.ErrMsg,
  18710. //})
  18711. } else {
  18712. //order.FaPiaoNumber = zero
  18713. //order.FaPiaoCode = last_order.FaPiaoCode
  18714. //service.UpdateOrder(order)
  18715. hisFundSettleListResult := &models.HisFundSettleListResult{
  18716. Number: res.Output.SetlListId,
  18717. Status: 1,
  18718. Ctime: time.Now().Unix(),
  18719. Mtime: time.Now().Unix(),
  18720. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18721. IsUpload: 1,
  18722. OrderId: order.ID,
  18723. }
  18724. service.CreateUploadRecord(hisFundSettleListResult)
  18725. continue
  18726. }
  18727. }
  18728. }
  18729. func (c *HisApiController) GetSettleList() {
  18730. order_id, _ := c.GetInt64("order_id")
  18731. admin_user_id, _ := c.GetInt64("admin_user_id")
  18732. order, _ := service.GetHisOrderByIDTwo(order_id)
  18733. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18734. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18735. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18736. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18737. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18738. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18739. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18740. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18741. if order.ID == 0 {
  18742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18743. return
  18744. }
  18745. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18746. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18747. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18748. //fmt.Println(count)
  18749. //var zero string
  18750. //number := count + 1
  18751. //if number >= 1000 {
  18752. // zero = "0000" + strconv.FormatInt(number, 10)
  18753. //} else if number >= 10000 {
  18754. // zero = "000" + strconv.FormatInt(number, 10)
  18755. //} else if number >= 100000 {
  18756. // zero = "00" + strconv.FormatInt(number, 10)
  18757. //} else if number >= 1000000 {
  18758. // zero = "0" + strconv.FormatInt(number, 10)
  18759. //} else {
  18760. // zero = strconv.FormatInt(number, 10)
  18761. //}
  18762. //fmt.Println(zero)
  18763. struct4101 := service.Struct4101{
  18764. PsnNo: order.PsnNo,
  18765. MdtrtId: order.MdtrtId,
  18766. SetlId: order.SetlId,
  18767. PsnName: order.PsnName,
  18768. Gend: order.Gend,
  18769. Brdy: his.Brdy,
  18770. Age: his.Age,
  18771. Naty: order.Naty,
  18772. PatnCertType: "01",
  18773. Certno: order.Certno,
  18774. Prfs: "90",
  18775. ConerName: roles[0].UserName,
  18776. PatnRlts: "99",
  18777. ConerAddr: miConfig.OrgName,
  18778. ConerTel: admin.Mobile,
  18779. HiType: order.Insutype,
  18780. Insuplc: miConfig.InsuplcAdmdvs,
  18781. MaindiagFlag: "1",
  18782. BillCode: order.SetlId,
  18783. BillNo: order.SetlId,
  18784. BizSn: order.Number,
  18785. PsnSelfPay: order.PsnPartAmt,
  18786. PsnOwnPay: order.PsnPartAmt,
  18787. AcctPay: order.AcctPay,
  18788. PsnCashpay: order.PsnCashPay,
  18789. HiPaymtd: "1",
  18790. Hsorg: miConfig.InsuplcAdmdvs,
  18791. HsorgOpter: miConfig.InsuplcAdmdvs,
  18792. MedinsFillPsn: curRoles.UserName,
  18793. MedinsFillDept: miConfig.OrgName,
  18794. IptMedType: "2",
  18795. }
  18796. struct4101.SetlBegnDate = order.SetlTime
  18797. struct4101.SetlEndDate = order.SetlTime
  18798. time_arr := strings.Split(order.SetlTime, " ")
  18799. struct4101.AdmTime = time_arr[0]
  18800. struct4101.AdmEndTime = time_arr[0]
  18801. //
  18802. //var rf []CustomFundPay
  18803. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18804. //
  18805. //var tempFunPays []service.CustomStruct
  18806. //for _, item := range rf {
  18807. // var tempFunPay service.CustomStruct
  18808. // tempFunPay.FundPayamt = item.FundPayamt
  18809. // tempFunPay.FundPayType = item.FundPayType
  18810. // tempFunPays = append(tempFunPays, tempFunPay)
  18811. //}
  18812. //struct4101.CustomStruct = tempFunPays
  18813. var tempDiaginfos []service.DiaginfoStructTwo
  18814. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18815. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18816. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  18817. var config []*models.HisXtDiagnoseConfig
  18818. for _, item := range diagnosis_ids {
  18819. id, _ := strconv.ParseInt(item, 10, 64)
  18820. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18821. config = append(config, &diagnosisConfig)
  18822. }
  18823. if miConfig.Code == "H15049901371" {
  18824. //for _, item := range config {
  18825. // if item.ID == 138 {
  18826. diagnosisConfig, _ := service.FindDiagnoseById(138)
  18827. var tempDiaginfo service.DiaginfoStructTwo
  18828. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  18829. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  18830. tempDiaginfo.DiagType = "1"
  18831. tempDiaginfo.MaindiagFlag = "1"
  18832. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18833. //}
  18834. //}
  18835. for _, item := range config {
  18836. if item.ID != 138 {
  18837. var tempDiaginfo service.DiaginfoStructTwo
  18838. tempDiaginfo.DiagCode = item.CountryCode
  18839. tempDiaginfo.DiagName = item.CountryContentName
  18840. tempDiaginfo.DiagType = "1"
  18841. tempDiaginfo.MaindiagFlag = "0"
  18842. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18843. }
  18844. }
  18845. } else {
  18846. for index, item := range config {
  18847. if index == 0 {
  18848. var tempDiaginfo service.DiaginfoStructTwo
  18849. tempDiaginfo.DiagCode = item.CountryCode
  18850. tempDiaginfo.DiagName = item.CountryContentName
  18851. tempDiaginfo.DiagType = "1"
  18852. tempDiaginfo.MaindiagFlag = "1"
  18853. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18854. } else {
  18855. var tempDiaginfo service.DiaginfoStructTwo
  18856. tempDiaginfo.DiagCode = item.CountryCode
  18857. tempDiaginfo.DiagName = item.CountryContentName
  18858. tempDiaginfo.DiagType = "1"
  18859. tempDiaginfo.MaindiagFlag = "0"
  18860. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18861. }
  18862. }
  18863. }
  18864. struct4101.Diseinfo = tempDiaginfos
  18865. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18866. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18867. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18868. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18869. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18870. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18871. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18872. var iteminfo service.IteminfoStruct
  18873. var bedCostTotal float64 = 0 //床位总费
  18874. var bedCostSelfTotal float64 = 0 //床位自费
  18875. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18876. var operationCostTotal float64 = 0 //手术费
  18877. var operationCostSelfTotal float64 = 0 //手术费
  18878. var operationCostPartSelfTotal float64 = 0 //手术费
  18879. var otherCostTotal float64 = 0 //其他费用
  18880. var otherCostSelfTotal float64 = 0 //其他费用
  18881. var otherCostPartSelfTotal float64 = 0 //其他费用
  18882. var materialCostTotal float64 = 0 //材料费
  18883. var materialCostSelfTotal float64 = 0 //材料费
  18884. var materialCostPartSelfTotal float64 = 0 //材料费
  18885. var westernMedicineCostTotal float64 = 0 //西药费
  18886. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18887. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18888. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18889. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18890. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18891. var checkCostTotal float64 = 0 //检查费
  18892. var checkCostSelfTotal float64 = 0 //检查费
  18893. var checkCostPartSelfTotal float64 = 0 //检查费
  18894. var laboratoryCostTotal float64 = 0 //化验费
  18895. var laboratoryCostSelfTotal float64 = 0 //化验费
  18896. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18897. var treatCostTotal float64 = 0 //治疗费用
  18898. var treatCostSelfTotal float64 = 0 //治疗费用
  18899. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18900. decimal.DivisionPrecision = 2
  18901. var bed_fulamt_ownpay_amt float64 = 0
  18902. var operation_fulamt_ownpay_amt float64 = 0
  18903. var other_fulamt_ownpay_amt float64 = 0
  18904. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18905. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18906. var check_fulamt_ownpay_amt float64 = 0
  18907. var material_fulamt_ownpay_amt float64 = 0
  18908. var laboratory_fulamt_ownpay_amt float64 = 0
  18909. var treat_fulamt_ownpay_amt float64 = 0
  18910. var bed_claa_sunmfee float64 = 0
  18911. var bed_clab_amt float64 = 0
  18912. var bed_other_amt float64 = 0
  18913. var operation_claa_sunmfee float64 = 0
  18914. var operation_clab_amt float64 = 0
  18915. var operation_other_amt float64 = 0
  18916. var other_claa_sunmfee float64 = 0
  18917. var other_clab_amt float64 = 0
  18918. var other_other_amt float64 = 0
  18919. var westernMedicine_claa_sunmfee float64 = 0
  18920. var westernMedicine_clab_amt float64 = 0
  18921. var westernMedicine_other_amt float64 = 0
  18922. var chineseTraditional_claa_sunmfee float64 = 0
  18923. var chineseTraditional_clab_amt float64 = 0
  18924. var chineseTraditional_other_amt float64 = 0
  18925. var check_claa_sunmfee float64 = 0
  18926. var check_clab_amt float64 = 0
  18927. var check_other_amt float64 = 0
  18928. var material_claa_sunmfee float64 = 0
  18929. var material_clab_amt float64 = 0
  18930. var material_other_amt float64 = 0
  18931. var laboratory_claa_sunmfee float64 = 0
  18932. var laboratory_clab_amt float64 = 0
  18933. var laboratory_other_amt float64 = 0
  18934. var treat_claa_sunmfee float64 = 0
  18935. var treat_clab_amt float64 = 0
  18936. var treat_other_amt float64 = 0
  18937. for _, item := range order.HisOrderInfo {
  18938. if item.MedChrgitmType == "01" { //床位费
  18939. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18940. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18941. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18942. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18943. if item.ChrgitmLv == "1" {
  18944. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18945. }
  18946. if item.ChrgitmLv == "2" {
  18947. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18948. }
  18949. if item.ChrgitmLv == "3" {
  18950. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18951. }
  18952. }
  18953. if item.MedChrgitmType == "03" { //检查费
  18954. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18955. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18956. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18957. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18958. if item.ChrgitmLv == "1" {
  18959. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18960. }
  18961. if item.ChrgitmLv == "2" {
  18962. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18963. }
  18964. if item.ChrgitmLv == "3" {
  18965. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18966. }
  18967. }
  18968. if item.MedChrgitmType == "04" { //化验费
  18969. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18970. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18971. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18972. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18973. if item.ChrgitmLv == "1" {
  18974. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18975. }
  18976. if item.ChrgitmLv == "2" {
  18977. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18978. }
  18979. if item.ChrgitmLv == "3" {
  18980. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18981. }
  18982. }
  18983. if item.MedChrgitmType == "05" { //治疗费
  18984. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18985. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18986. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18987. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18988. if item.ChrgitmLv == "1" {
  18989. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18990. }
  18991. if item.ChrgitmLv == "2" {
  18992. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18993. }
  18994. if item.ChrgitmLv == "3" {
  18995. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18996. }
  18997. }
  18998. if item.MedChrgitmType == "06" { //手术费
  18999. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19000. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19001. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19002. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19003. if item.ChrgitmLv == "1" {
  19004. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19005. }
  19006. if item.ChrgitmLv == "2" {
  19007. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19008. }
  19009. if item.ChrgitmLv == "3" {
  19010. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19011. }
  19012. }
  19013. if item.MedChrgitmType == "08" { //材料费
  19014. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19015. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19016. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19017. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19018. if item.ChrgitmLv == "1" {
  19019. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19020. }
  19021. if item.ChrgitmLv == "2" {
  19022. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19023. }
  19024. if item.ChrgitmLv == "3" {
  19025. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19026. }
  19027. }
  19028. if item.MedChrgitmType == "09" { //西药费
  19029. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19030. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19031. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19032. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19033. if item.ChrgitmLv == "1" {
  19034. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19035. }
  19036. if item.ChrgitmLv == "2" {
  19037. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19038. }
  19039. if item.ChrgitmLv == "3" {
  19040. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19041. }
  19042. }
  19043. if item.MedChrgitmType == "11" { //中成费
  19044. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19045. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19046. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19047. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19048. if item.ChrgitmLv == "1" {
  19049. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19050. }
  19051. if item.ChrgitmLv == "2" {
  19052. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19053. }
  19054. if item.ChrgitmLv == "3" {
  19055. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19056. }
  19057. }
  19058. if item.MedChrgitmType == "14" { //其他费
  19059. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19060. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19061. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19062. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19063. if item.ChrgitmLv == "1" {
  19064. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19065. }
  19066. if item.ChrgitmLv == "2" {
  19067. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19068. }
  19069. if item.ChrgitmLv == "3" {
  19070. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19071. }
  19072. }
  19073. }
  19074. var iteminfoStructs []service.IteminfoStruct
  19075. if bedCostTotal != 0 {
  19076. iteminfo.MedChrgitm = "01"
  19077. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19078. iteminfo.Amt = bedCostTotal
  19079. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19080. iteminfo.ClabAmt = bed_clab_amt
  19081. iteminfo.OthAmt = bed_other_amt
  19082. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19083. }
  19084. if checkCostTotal != 0 {
  19085. iteminfo.MedChrgitm = "03"
  19086. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19087. iteminfo.Amt = checkCostTotal
  19088. iteminfo.ClaaSumfee = check_claa_sunmfee
  19089. iteminfo.ClabAmt = check_clab_amt
  19090. iteminfo.OthAmt = check_other_amt
  19091. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19092. }
  19093. if laboratoryCostTotal != 0 {
  19094. iteminfo.MedChrgitm = "04"
  19095. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19096. iteminfo.Amt = laboratoryCostTotal
  19097. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19098. iteminfo.ClabAmt = laboratory_clab_amt
  19099. iteminfo.OthAmt = laboratory_other_amt
  19100. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19101. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19102. }
  19103. if treatCostTotal != 0 {
  19104. iteminfo.MedChrgitm = "05"
  19105. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19106. iteminfo.Amt = treatCostTotal
  19107. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19108. iteminfo.ClabAmt = treat_clab_amt
  19109. iteminfo.OthAmt = treat_other_amt
  19110. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19111. //(struct4101.IteminfoStruct, iteminfo)
  19112. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19113. }
  19114. if operationCostTotal != 0 {
  19115. iteminfo.MedChrgitm = "06"
  19116. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19117. iteminfo.Amt = operationCostTotal
  19118. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19119. iteminfo.ClabAmt = operation_clab_amt
  19120. iteminfo.OthAmt = operation_other_amt
  19121. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19122. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19123. }
  19124. if materialCostTotal != 0 {
  19125. iteminfo.MedChrgitm = "08"
  19126. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19127. iteminfo.Amt = materialCostTotal
  19128. iteminfo.ClaaSumfee = material_claa_sunmfee
  19129. iteminfo.ClabAmt = material_clab_amt
  19130. iteminfo.OthAmt = material_other_amt
  19131. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19132. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19133. }
  19134. if westernMedicineCostTotal != 0 {
  19135. iteminfo.MedChrgitm = "09"
  19136. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19137. iteminfo.Amt = westernMedicineCostTotal
  19138. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19139. iteminfo.ClabAmt = westernMedicine_clab_amt
  19140. iteminfo.OthAmt = westernMedicine_other_amt
  19141. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19142. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19143. }
  19144. if chineseTraditionalMedicineCostTotal != 0 {
  19145. iteminfo.MedChrgitm = "11"
  19146. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19147. iteminfo.Amt = westernMedicineCostTotal
  19148. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19149. iteminfo.ClabAmt = westernMedicine_clab_amt
  19150. iteminfo.OthAmt = westernMedicine_other_amt
  19151. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19152. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19153. }
  19154. if otherCostTotal != 0 {
  19155. iteminfo.MedChrgitm = "14"
  19156. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19157. iteminfo.Amt = otherCostTotal
  19158. iteminfo.ClaaSumfee = other_claa_sunmfee
  19159. iteminfo.ClabAmt = other_clab_amt
  19160. iteminfo.OthAmt = other_other_amt
  19161. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19162. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19163. }
  19164. struct4101.IteminfoStruct = iteminfoStructs
  19165. struct4101.Ntly = "中国"
  19166. struct4101.AdmCaty = "A03.06"
  19167. struct4101.DoctorName = doctor.UserName
  19168. struct4101.DoctorCode = doctor.DoctorNumber
  19169. var res ResultSeventeen
  19170. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19171. struct4101.BillCode = order.Number
  19172. struct4101.BillNo = order.SetlId
  19173. var resOther ResultSeventeenOther
  19174. var pp models.PublicParams
  19175. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19176. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19177. pp.FixmedinsName = miConfig.OrgName
  19178. pp.FixmedinsCode = miConfig.Code
  19179. pp.RequestUrl = miConfig.Url
  19180. pp.Cainfo = miConfig.Cainfo
  19181. pp.SecretKey = miConfig.SecretKey
  19182. pp.AccessKey = miConfig.AccessKey
  19183. pp.OpterName = curRoles.UserName
  19184. client := &http.Client{}
  19185. var req *http.Request
  19186. data := make(map[string]interface{})
  19187. data["struct4101"] = struct4101
  19188. data["pp"] = pp
  19189. bytesData, _ := json.Marshal(data)
  19190. if miConfig.MdtrtareaAdmvs == "320921" {
  19191. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19192. } else {
  19193. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19194. }
  19195. resp, _ := client.Do(req)
  19196. defer resp.Body.Close()
  19197. body, ioErr := ioutil.ReadAll(resp.Body)
  19198. if ioErr != nil {
  19199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19201. return
  19202. }
  19203. var respJSON map[string]interface{}
  19204. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19207. return
  19208. }
  19209. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19210. userJSONBytes, _ := json.Marshal(respJSON)
  19211. fmt.Println("log")
  19212. fmt.Println(string(userJSONBytes))
  19213. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19214. utils.ErrorLog("解析失败:%v", err)
  19215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19216. return
  19217. }
  19218. res.InfRefmsgid = resOther.InfRefmsgid
  19219. res.Output = resOther.Output
  19220. res.ErrMsg = resOther.ErrMsg
  19221. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19222. res.Infcode = infocode
  19223. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19224. var pp models.PublicParams
  19225. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19226. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19227. pp.FixmedinsName = miConfig.OrgName
  19228. pp.FixmedinsCode = miConfig.Code
  19229. pp.RequestUrl = miConfig.Url
  19230. pp.Cainfo = miConfig.Cainfo
  19231. pp.SecretKey = miConfig.SecretKey
  19232. pp.AccessKey = miConfig.AccessKey
  19233. pp.OpterName = curRoles.UserName
  19234. result, _ := service.Jxyb4101(struct4101, pp)
  19235. var dat map[string]interface{}
  19236. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19237. fmt.Println(dat)
  19238. } else {
  19239. fmt.Println(err)
  19240. }
  19241. userJSONBytes, _ := json.Marshal(dat)
  19242. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19243. utils.ErrorLog("解析失败:%v", err)
  19244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19245. return
  19246. }
  19247. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19248. var pp models.PublicParams
  19249. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19250. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19251. pp.FixmedinsName = miConfig.OrgName
  19252. pp.FixmedinsCode = miConfig.Code
  19253. pp.RequestUrl = miConfig.Url
  19254. pp.Cainfo = miConfig.Cainfo
  19255. pp.SecretKey = miConfig.SecretKey
  19256. pp.AccessKey = miConfig.AccessKey
  19257. pp.OpterName = curRoles.UserName
  19258. result, _ := service.Jxyb4101(struct4101, pp)
  19259. var dat map[string]interface{}
  19260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19261. fmt.Println(dat)
  19262. } else {
  19263. fmt.Println(err)
  19264. }
  19265. userJSONBytes, _ := json.Marshal(dat)
  19266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19267. utils.ErrorLog("解析失败:%v", err)
  19268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19269. return
  19270. }
  19271. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19272. var pp models.PublicParams
  19273. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19274. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19275. pp.FixmedinsName = miConfig.OrgName
  19276. pp.FixmedinsCode = miConfig.Code
  19277. pp.RequestUrl = miConfig.Url
  19278. pp.Cainfo = miConfig.Cainfo
  19279. pp.SecretKey = miConfig.SecretKey
  19280. pp.AccessKey = miConfig.AccessKey
  19281. pp.OpterName = curRoles.UserName
  19282. result, _ := service.Hnyb4101(struct4101, pp)
  19283. var dat map[string]interface{}
  19284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19285. fmt.Println(dat)
  19286. } else {
  19287. fmt.Println(err)
  19288. }
  19289. userJSONBytes, _ := json.Marshal(dat)
  19290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19291. utils.ErrorLog("解析失败:%v", err)
  19292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19293. return
  19294. }
  19295. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19296. var resOther ResultSeventeenOther
  19297. var pp models.PublicParams
  19298. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19299. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19300. pp.FixmedinsName = miConfig.OrgName
  19301. pp.FixmedinsCode = miConfig.Code
  19302. pp.RequestUrl = miConfig.Url
  19303. pp.Cainfo = miConfig.Cainfo
  19304. pp.SecretKey = miConfig.SecretKey
  19305. pp.AccessKey = miConfig.AccessKey
  19306. pp.OpterName = curRoles.UserName
  19307. client := &http.Client{}
  19308. var req *http.Request
  19309. data := make(map[string]interface{})
  19310. data["struct4101"] = struct4101
  19311. data["pp"] = pp
  19312. bytesData, _ := json.Marshal(data)
  19313. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19314. resp, _ := client.Do(req)
  19315. defer resp.Body.Close()
  19316. body, ioErr := ioutil.ReadAll(resp.Body)
  19317. if ioErr != nil {
  19318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19320. return
  19321. }
  19322. var respJSON map[string]interface{}
  19323. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19326. return
  19327. }
  19328. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19329. userJSONBytes, _ := json.Marshal(respJSON)
  19330. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19331. utils.ErrorLog("解析失败:%v", err)
  19332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19333. return
  19334. }
  19335. res.InfRefmsgid = resOther.InfRefmsgid
  19336. res.Output = resOther.Output
  19337. res.ErrMsg = resOther.ErrMsg
  19338. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19339. res.Infcode = infocode
  19340. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19341. var pp models.PublicParams
  19342. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19343. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19344. pp.FixmedinsName = miConfig.OrgName
  19345. pp.FixmedinsCode = miConfig.Code
  19346. pp.RequestUrl = miConfig.Url
  19347. pp.Cainfo = miConfig.Cainfo
  19348. pp.SecretKey = miConfig.SecretKey
  19349. pp.AccessKey = miConfig.AccessKey
  19350. pp.OpterName = curRoles.UserName
  19351. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19352. fmt.Println(requestLog)
  19353. fmt.Println(errMsgLog)
  19354. saveLog(result, requestLog, "4101a", "上传清单")
  19355. var dat map[string]interface{}
  19356. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19357. fmt.Println(dat)
  19358. } else {
  19359. fmt.Println(err)
  19360. }
  19361. userJSONBytes, _ := json.Marshal(dat)
  19362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19363. utils.ErrorLog("解析失败:%v", err)
  19364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19365. return
  19366. }
  19367. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19368. var pp models.PublicParams
  19369. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19370. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19371. pp.FixmedinsName = miConfig.OrgName
  19372. pp.FixmedinsCode = miConfig.Code
  19373. pp.RequestUrl = miConfig.Url
  19374. pp.Cainfo = miConfig.Cainfo
  19375. pp.SecretKey = miConfig.SecretKey
  19376. pp.AccessKey = miConfig.AccessKey
  19377. pp.OpterName = curRoles.UserName
  19378. client := &http.Client{}
  19379. var req *http.Request
  19380. data := make(map[string]interface{})
  19381. data["struct4101"] = struct4101
  19382. data["pp"] = pp
  19383. bytesData, _ := json.Marshal(data)
  19384. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19385. resp, _ := client.Do(req)
  19386. defer resp.Body.Close()
  19387. body, ioErr := ioutil.ReadAll(resp.Body)
  19388. if ioErr != nil {
  19389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19391. return
  19392. }
  19393. var respJSON map[string]interface{}
  19394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19397. return
  19398. }
  19399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19400. userJSONBytes, _ := json.Marshal(respJSON)
  19401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19402. utils.ErrorLog("解析失败:%v", err)
  19403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19404. return
  19405. }
  19406. } else {
  19407. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19408. var dat map[string]interface{}
  19409. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19410. fmt.Println(dat)
  19411. } else {
  19412. fmt.Println(err)
  19413. }
  19414. userJSONBytes, _ := json.Marshal(dat)
  19415. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19416. utils.ErrorLog("解析失败:%v", err)
  19417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19418. return
  19419. }
  19420. }
  19421. if res.Infcode != 0 {
  19422. c.ServeSuccessJSON(map[string]interface{}{
  19423. "failed_code": -10,
  19424. "msg": res.ErrMsg,
  19425. })
  19426. return
  19427. } else {
  19428. //order.FaPiaoNumber = zero
  19429. //order.FaPiaoCode = last_order.FaPiaoCode
  19430. //service.UpdateOrder(order)
  19431. hisFundSettleListResult := &models.HisFundSettleListResult{
  19432. Number: res.Output.SetlListId,
  19433. Status: 1,
  19434. Ctime: time.Now().Unix(),
  19435. Mtime: time.Now().Unix(),
  19436. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19437. IsUpload: 1,
  19438. OrderId: order_id,
  19439. }
  19440. service.CreateUploadRecord(hisFundSettleListResult)
  19441. c.ServeSuccessJSON(map[string]interface{}{
  19442. "msg": "上传成功",
  19443. "result": hisFundSettleListResult,
  19444. })
  19445. return
  19446. }
  19447. }
  19448. func (c *HisApiController) GetSettleListHospital() {
  19449. order_id, _ := c.GetInt64("order_id")
  19450. admin_user_id, _ := c.GetInt64("admin_user_id")
  19451. order, _ := service.GetHisOrderByIDTwo(order_id)
  19452. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19453. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19454. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19455. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19456. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19457. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19458. if order.ID == 0 {
  19459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19460. return
  19461. }
  19462. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19463. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19464. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19465. fmt.Println(count)
  19466. var zero string
  19467. number := count + 1
  19468. if number >= 1000 {
  19469. zero = "0000" + strconv.FormatInt(number, 10)
  19470. } else if number >= 10000 {
  19471. zero = "000" + strconv.FormatInt(number, 10)
  19472. } else if number >= 100000 {
  19473. zero = "00" + strconv.FormatInt(number, 10)
  19474. } else if number >= 1000000 {
  19475. zero = "0" + strconv.FormatInt(number, 10)
  19476. } else {
  19477. zero = strconv.FormatInt(number, 10)
  19478. }
  19479. fmt.Println(zero)
  19480. struct4101 := service.Struct4101{
  19481. PsnNo: order.PsnNo,
  19482. MdtrtId: order.MdtrtId,
  19483. SetlId: order.SetlId,
  19484. PsnName: order.PsnName,
  19485. Gend: order.Gend,
  19486. Brdy: his.Brdy,
  19487. Age: int64(order.Age),
  19488. Naty: order.Naty,
  19489. PatnCertType: "01",
  19490. Certno: order.Certno,
  19491. Prfs: "90",
  19492. ConerName: roles[0].UserName,
  19493. PatnRlts: "99",
  19494. ConerAddr: miConfig.OrgName,
  19495. ConerTel: admin.Mobile,
  19496. HiType: order.Insutype,
  19497. Insuplc: miConfig.InsuplcAdmdvs,
  19498. MaindiagFlag: "1",
  19499. BillCode: order.SetlId,
  19500. BillNo: order.SetlId,
  19501. BizSn: order.Number,
  19502. PsnSelfPay: order.PsnPartAmt,
  19503. PsnOwnPay: order.PsnPartAmt,
  19504. AcctPay: order.AcctPay,
  19505. PsnCashpay: order.PsnCashPay,
  19506. HiPaymtd: "1",
  19507. Hsorg: miConfig.InsuplcAdmdvs,
  19508. HsorgOpter: miConfig.InsuplcAdmdvs,
  19509. MedinsFillPsn: curRoles.UserName,
  19510. MedinsFillDept: depart.Name,
  19511. IptMedType: "2",
  19512. AdmTime: his.InHosptialTime,
  19513. AdmEndTime: his.OutHosptialTime,
  19514. }
  19515. struct4101.SetlBegnDate = order.SetlTime
  19516. struct4101.SetlEndDate = order.SetlTime
  19517. //var rf []CustomFundPay
  19518. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19519. //
  19520. //var tempFunPays []service.CustomStruct
  19521. //for _, item := range rf {
  19522. // var tempFunPay service.CustomStruct
  19523. // tempFunPay.FundPayamt = item.FundPayamt
  19524. // tempFunPay.FundPayType = item.FundPayType
  19525. // tempFunPays = append(tempFunPays, tempFunPay)
  19526. //}
  19527. //struct4101.CustomStruct = tempFunPays
  19528. var tempDiaginfos []service.DiaginfoStructTwo
  19529. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19530. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19531. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19532. //for _, item := range infos {
  19533. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19534. //}
  19535. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19536. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19537. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19538. fmt.Println(diagnosis_ids_arr)
  19539. if order.UserOrgId == 10210 {
  19540. var diagnosis_ids_arr_two []int64
  19541. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19542. var config []*models.HisXtDiagnoseConfig
  19543. for _, id := range diagnosis_ids_arr_two {
  19544. //id, _ := strconv.ParseInt(item, 10, 64)
  19545. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19546. if diagnosisConfig.ID > 0 {
  19547. config = append(config, &diagnosisConfig)
  19548. }
  19549. }
  19550. for index, item := range config {
  19551. if item.ID > 0 {
  19552. if index == 0 {
  19553. var tempDiaginfo service.DiaginfoStructTwo
  19554. tempDiaginfo.DiagCode = item.CountryCode
  19555. tempDiaginfo.DiagName = item.CountryContentName
  19556. tempDiaginfo.DiagType = "1"
  19557. tempDiaginfo.MaindiagFlag = "1"
  19558. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19559. } else {
  19560. var tempDiaginfo service.DiaginfoStructTwo
  19561. tempDiaginfo.DiagCode = item.CountryCode
  19562. tempDiaginfo.DiagName = item.CountryContentName
  19563. tempDiaginfo.DiagType = "1"
  19564. tempDiaginfo.MaindiagFlag = "0"
  19565. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19566. }
  19567. }
  19568. }
  19569. struct4101.Diseinfo = tempDiaginfos
  19570. } else {
  19571. var config []*models.HisXtDiagnoseConfig
  19572. for _, item := range diagnosis_ids_arr {
  19573. id, _ := strconv.ParseInt(item, 10, 64)
  19574. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19575. if diagnosisConfig.ID > 0 {
  19576. config = append(config, &diagnosisConfig)
  19577. }
  19578. }
  19579. for index, item := range config {
  19580. if item.ID > 0 {
  19581. if index == 0 {
  19582. var tempDiaginfo service.DiaginfoStructTwo
  19583. tempDiaginfo.DiagCode = item.CountryCode
  19584. tempDiaginfo.DiagName = item.CountryContentName
  19585. tempDiaginfo.DiagType = "1"
  19586. tempDiaginfo.MaindiagFlag = "1"
  19587. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19588. } else {
  19589. var tempDiaginfo service.DiaginfoStructTwo
  19590. tempDiaginfo.DiagCode = item.CountryCode
  19591. tempDiaginfo.DiagName = item.CountryContentName
  19592. tempDiaginfo.DiagType = "1"
  19593. tempDiaginfo.MaindiagFlag = "0"
  19594. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19595. }
  19596. }
  19597. }
  19598. struct4101.Diseinfo = tempDiaginfos
  19599. }
  19600. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19601. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19602. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19603. tempOpspdiseinfo2.OprnOprtCode = ""
  19604. tempOpspdiseinfo2.OprnOprtName = ""
  19605. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19606. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19607. var iteminfo service.IteminfoStruct
  19608. var bedCostTotal float64 = 0 //床位总费
  19609. var bedCostSelfTotal float64 = 0 //床位自费
  19610. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19611. var operationCostTotal float64 = 0 //手术费
  19612. var operationCostSelfTotal float64 = 0 //手术费
  19613. var operationCostPartSelfTotal float64 = 0 //手术费
  19614. var otherCostTotal float64 = 0 //其他费用
  19615. var otherCostSelfTotal float64 = 0 //其他费用
  19616. var otherCostPartSelfTotal float64 = 0 //其他费用
  19617. var materialCostTotal float64 = 0 //材料费
  19618. var materialCostSelfTotal float64 = 0 //材料费
  19619. var materialCostPartSelfTotal float64 = 0 //材料费
  19620. var westernMedicineCostTotal float64 = 0 //西药费
  19621. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19622. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19623. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19624. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19625. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19626. var checkCostTotal float64 = 0 //检查费
  19627. var checkCostSelfTotal float64 = 0 //检查费
  19628. var checkCostPartSelfTotal float64 = 0 //检查费
  19629. var laboratoryCostTotal float64 = 0 //化验费
  19630. var laboratoryCostSelfTotal float64 = 0 //化验费
  19631. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19632. var treatCostTotal float64 = 0 //治疗费用
  19633. var treatCostSelfTotal float64 = 0 //治疗费用
  19634. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19635. decimal.DivisionPrecision = 2
  19636. var bed_fulamt_ownpay_amt float64 = 0
  19637. var operation_fulamt_ownpay_amt float64 = 0
  19638. var other_fulamt_ownpay_amt float64 = 0
  19639. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19640. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19641. var check_fulamt_ownpay_amt float64 = 0
  19642. var material_fulamt_ownpay_amt float64 = 0
  19643. var laboratory_fulamt_ownpay_amt float64 = 0
  19644. var treat_fulamt_ownpay_amt float64 = 0
  19645. var bed_claa_sunmfee float64 = 0
  19646. var bed_clab_amt float64 = 0
  19647. var bed_other_amt float64 = 0
  19648. var operation_claa_sunmfee float64 = 0
  19649. var operation_clab_amt float64 = 0
  19650. var operation_other_amt float64 = 0
  19651. var other_claa_sunmfee float64 = 0
  19652. var other_clab_amt float64 = 0
  19653. var other_other_amt float64 = 0
  19654. var westernMedicine_claa_sunmfee float64 = 0
  19655. var westernMedicine_clab_amt float64 = 0
  19656. var westernMedicine_other_amt float64 = 0
  19657. var chineseTraditional_claa_sunmfee float64 = 0
  19658. var chineseTraditional_clab_amt float64 = 0
  19659. var chineseTraditional_other_amt float64 = 0
  19660. var check_claa_sunmfee float64 = 0
  19661. var check_clab_amt float64 = 0
  19662. var check_other_amt float64 = 0
  19663. var material_claa_sunmfee float64 = 0
  19664. var material_clab_amt float64 = 0
  19665. var material_other_amt float64 = 0
  19666. var laboratory_claa_sunmfee float64 = 0
  19667. var laboratory_clab_amt float64 = 0
  19668. var laboratory_other_amt float64 = 0
  19669. var treat_claa_sunmfee float64 = 0
  19670. var treat_clab_amt float64 = 0
  19671. var treat_other_amt float64 = 0
  19672. for _, item := range order.HisOrderInfo {
  19673. if item.MedChrgitmType == "01" { //床位费
  19674. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19675. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19676. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19677. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19678. if item.ChrgitmLv == "1" {
  19679. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19680. }
  19681. if item.ChrgitmLv == "2" {
  19682. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19683. }
  19684. if item.ChrgitmLv == "3" {
  19685. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19686. }
  19687. }
  19688. if item.MedChrgitmType == "03" { //检查费
  19689. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19690. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19691. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19692. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19693. if item.ChrgitmLv == "1" {
  19694. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19695. }
  19696. if item.ChrgitmLv == "2" {
  19697. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19698. }
  19699. if item.ChrgitmLv == "3" {
  19700. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19701. }
  19702. }
  19703. if item.MedChrgitmType == "04" { //化验费
  19704. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19705. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19706. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19707. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19708. if item.ChrgitmLv == "1" {
  19709. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19710. }
  19711. if item.ChrgitmLv == "2" {
  19712. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19713. }
  19714. if item.ChrgitmLv == "3" {
  19715. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19716. }
  19717. }
  19718. if item.MedChrgitmType == "05" { //治疗费
  19719. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19720. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19721. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19722. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19723. if item.ChrgitmLv == "1" {
  19724. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19725. }
  19726. if item.ChrgitmLv == "2" {
  19727. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19728. }
  19729. if item.ChrgitmLv == "3" {
  19730. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19731. }
  19732. }
  19733. if item.MedChrgitmType == "06" { //手术费
  19734. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19735. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19736. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19737. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19738. if item.ChrgitmLv == "1" {
  19739. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19740. }
  19741. if item.ChrgitmLv == "2" {
  19742. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19743. }
  19744. if item.ChrgitmLv == "3" {
  19745. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19746. }
  19747. }
  19748. if item.MedChrgitmType == "08" { //材料费
  19749. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19750. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19751. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19752. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19753. if item.ChrgitmLv == "1" {
  19754. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19755. }
  19756. if item.ChrgitmLv == "2" {
  19757. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19758. }
  19759. if item.ChrgitmLv == "3" {
  19760. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19761. }
  19762. }
  19763. if item.MedChrgitmType == "09" { //西药费
  19764. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19765. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19766. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19767. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19768. if item.ChrgitmLv == "1" {
  19769. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19770. }
  19771. if item.ChrgitmLv == "2" {
  19772. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19773. }
  19774. if item.ChrgitmLv == "3" {
  19775. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19776. }
  19777. }
  19778. if item.MedChrgitmType == "11" { //中成费
  19779. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19780. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19781. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19782. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19783. if item.ChrgitmLv == "1" {
  19784. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19785. }
  19786. if item.ChrgitmLv == "2" {
  19787. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19788. }
  19789. if item.ChrgitmLv == "3" {
  19790. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19791. }
  19792. }
  19793. if item.MedChrgitmType == "14" { //其他费
  19794. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19795. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19796. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19797. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19798. if item.ChrgitmLv == "1" {
  19799. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19800. }
  19801. if item.ChrgitmLv == "2" {
  19802. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19803. }
  19804. if item.ChrgitmLv == "3" {
  19805. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19806. }
  19807. }
  19808. }
  19809. var iteminfoStructs []service.IteminfoStruct
  19810. if bedCostTotal != 0 {
  19811. iteminfo.MedChrgitm = "01"
  19812. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19813. iteminfo.Amt = bedCostTotal
  19814. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19815. iteminfo.ClabAmt = bed_clab_amt
  19816. iteminfo.OthAmt = bed_other_amt
  19817. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19818. }
  19819. if checkCostTotal != 0 {
  19820. iteminfo.MedChrgitm = "03"
  19821. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19822. iteminfo.Amt = checkCostTotal
  19823. iteminfo.ClaaSumfee = check_claa_sunmfee
  19824. iteminfo.ClabAmt = check_clab_amt
  19825. iteminfo.OthAmt = check_other_amt
  19826. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19827. }
  19828. if laboratoryCostTotal != 0 {
  19829. iteminfo.MedChrgitm = "04"
  19830. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19831. iteminfo.Amt = laboratoryCostTotal
  19832. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19833. iteminfo.ClabAmt = laboratory_clab_amt
  19834. iteminfo.OthAmt = laboratory_other_amt
  19835. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19836. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19837. }
  19838. if treatCostTotal != 0 {
  19839. iteminfo.MedChrgitm = "05"
  19840. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19841. iteminfo.Amt = treatCostTotal
  19842. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19843. iteminfo.ClabAmt = treat_clab_amt
  19844. iteminfo.OthAmt = treat_other_amt
  19845. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19846. //(struct4101.IteminfoStruct, iteminfo)
  19847. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19848. }
  19849. if operationCostTotal != 0 {
  19850. iteminfo.MedChrgitm = "06"
  19851. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19852. iteminfo.Amt = operationCostTotal
  19853. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19854. iteminfo.ClabAmt = operation_clab_amt
  19855. iteminfo.OthAmt = operation_other_amt
  19856. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19857. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19858. }
  19859. if materialCostTotal != 0 {
  19860. iteminfo.MedChrgitm = "08"
  19861. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19862. iteminfo.Amt = materialCostTotal
  19863. iteminfo.ClaaSumfee = material_claa_sunmfee
  19864. iteminfo.ClabAmt = material_clab_amt
  19865. iteminfo.OthAmt = material_other_amt
  19866. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19867. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19868. }
  19869. if westernMedicineCostTotal != 0 {
  19870. iteminfo.MedChrgitm = "09"
  19871. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19872. iteminfo.Amt = westernMedicineCostTotal
  19873. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19874. iteminfo.ClabAmt = westernMedicine_clab_amt
  19875. iteminfo.OthAmt = westernMedicine_other_amt
  19876. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19877. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19878. }
  19879. if chineseTraditionalMedicineCostTotal != 0 {
  19880. iteminfo.MedChrgitm = "11"
  19881. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19882. iteminfo.Amt = westernMedicineCostTotal
  19883. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19884. iteminfo.ClabAmt = westernMedicine_clab_amt
  19885. iteminfo.OthAmt = westernMedicine_other_amt
  19886. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19887. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19888. }
  19889. if otherCostTotal != 0 {
  19890. iteminfo.MedChrgitm = "14"
  19891. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19892. iteminfo.Amt = otherCostTotal
  19893. iteminfo.ClaaSumfee = other_claa_sunmfee
  19894. iteminfo.ClabAmt = other_clab_amt
  19895. iteminfo.OthAmt = other_other_amt
  19896. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19897. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19898. }
  19899. struct4101.IteminfoStruct = iteminfoStructs
  19900. struct4101.Ntly = "中国"
  19901. struct4101.AdmCaty = "A03.06"
  19902. var resOther ResultSeventeenOther
  19903. var res ResultSeventeen
  19904. if miConfig.MdtrtareaAdmvs == "150499" {
  19905. var pp models.PublicParams
  19906. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19907. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19908. pp.FixmedinsName = miConfig.OrgName
  19909. pp.FixmedinsCode = miConfig.Code
  19910. pp.RequestUrl = miConfig.Url
  19911. pp.Cainfo = miConfig.Cainfo
  19912. pp.SecretKey = miConfig.SecretKey
  19913. pp.AccessKey = miConfig.AccessKey
  19914. pp.OpterName = curRoles.UserName
  19915. client := &http.Client{}
  19916. var req *http.Request
  19917. data := make(map[string]interface{})
  19918. data["struct4101"] = struct4101
  19919. data["pp"] = pp
  19920. bytesData, _ := json.Marshal(data)
  19921. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19922. resp, _ := client.Do(req)
  19923. defer resp.Body.Close()
  19924. body, ioErr := ioutil.ReadAll(resp.Body)
  19925. if ioErr != nil {
  19926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19928. return
  19929. }
  19930. var respJSON map[string]interface{}
  19931. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19934. return
  19935. }
  19936. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19937. userJSONBytes, _ := json.Marshal(respJSON)
  19938. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19939. utils.ErrorLog("解析失败:%v", err)
  19940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19941. return
  19942. }
  19943. res.InfRefmsgid = resOther.InfRefmsgid
  19944. res.Output = resOther.Output
  19945. res.ErrMsg = resOther.ErrMsg
  19946. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19947. res.Infcode = infocode
  19948. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19949. var pp models.PublicParams
  19950. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19951. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19952. pp.FixmedinsName = miConfig.OrgName
  19953. pp.FixmedinsCode = miConfig.Code
  19954. pp.RequestUrl = miConfig.Url
  19955. pp.Cainfo = miConfig.Cainfo
  19956. pp.SecretKey = miConfig.SecretKey
  19957. pp.AccessKey = miConfig.AccessKey
  19958. pp.OpterName = curRoles.UserName
  19959. result, _ := service.Jxyb4101(struct4101, pp)
  19960. var dat map[string]interface{}
  19961. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19962. fmt.Println(dat)
  19963. } else {
  19964. fmt.Println(err)
  19965. }
  19966. userJSONBytes, _ := json.Marshal(dat)
  19967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19968. utils.ErrorLog("解析失败:%v", err)
  19969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19970. return
  19971. }
  19972. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19973. var pp models.PublicParams
  19974. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19975. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19976. pp.FixmedinsName = miConfig.OrgName
  19977. pp.FixmedinsCode = miConfig.Code
  19978. pp.RequestUrl = miConfig.Url
  19979. pp.Cainfo = miConfig.Cainfo
  19980. pp.SecretKey = miConfig.SecretKey
  19981. pp.AccessKey = miConfig.AccessKey
  19982. pp.OpterName = curRoles.UserName
  19983. result, _ := service.Jxyb4101(struct4101, pp)
  19984. var dat map[string]interface{}
  19985. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19986. fmt.Println(dat)
  19987. } else {
  19988. fmt.Println(err)
  19989. }
  19990. userJSONBytes, _ := json.Marshal(dat)
  19991. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19992. utils.ErrorLog("解析失败:%v", err)
  19993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19994. return
  19995. }
  19996. } else {
  19997. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19998. var dat map[string]interface{}
  19999. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20000. fmt.Println(dat)
  20001. } else {
  20002. fmt.Println(err)
  20003. }
  20004. userJSONBytes, _ := json.Marshal(dat)
  20005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20006. utils.ErrorLog("解析失败:%v", err)
  20007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20008. return
  20009. }
  20010. }
  20011. if res.Infcode != 0 {
  20012. c.ServeSuccessJSON(map[string]interface{}{
  20013. "failed_code": -10,
  20014. "msg": res.ErrMsg,
  20015. })
  20016. return
  20017. } else {
  20018. if miConfig.MdtrtareaAdmvs != "150499" {
  20019. order.FaPiaoNumber = zero
  20020. order.FaPiaoCode = last_order.FaPiaoCode
  20021. service.UpdateOrder(order)
  20022. }
  20023. hisFundSettleListResult := &models.HisFundSettleListResult{
  20024. Number: res.Output.SetlListId,
  20025. Status: 1,
  20026. Ctime: time.Now().Unix(),
  20027. Mtime: time.Now().Unix(),
  20028. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20029. IsUpload: 1,
  20030. OrderId: order_id,
  20031. }
  20032. service.CreateUploadRecord(hisFundSettleListResult)
  20033. c.ServeSuccessJSON(map[string]interface{}{
  20034. "msg": "上传成功",
  20035. "result": hisFundSettleListResult,
  20036. })
  20037. return
  20038. }
  20039. }
  20040. //func (c *HisApiController) GetBatchSettleList() {
  20041. // orders, _ := service.GetAllHisOrder(10106)
  20042. // for _, item := range orders {
  20043. // order_id := item.ID
  20044. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20045. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20046. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20047. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20048. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20049. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20050. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20051. //
  20052. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20053. //
  20054. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20055. //
  20056. // if order.ID == 0 {
  20057. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20058. // return
  20059. // }
  20060. // if his.BalanceAccountsType == 2 {
  20061. // continue
  20062. // }
  20063. // struct4101 := service.Struct4101{
  20064. // PsnNo: order.PsnNo,
  20065. // MdtrtId: order.MdtrtId,
  20066. // SetlId: order.SetlId,
  20067. // PsnName: order.PsnName,
  20068. // Gend: order.Gend,
  20069. // Brdy: his.Brdy,
  20070. // Age: his.Age,
  20071. // Naty: order.Naty,
  20072. // PatnCertType: "01",
  20073. // Certno: order.Certno,
  20074. // Prfs: "90",
  20075. // ConerName: roles[0].UserName,
  20076. // PatnRlts: "99",
  20077. // ConerAddr: miConfig.OrgName,
  20078. // ConerTel: admin.Mobile,
  20079. // HiType: order.Insutype,
  20080. // Insuplc: his.InsuplcAdmdvs,
  20081. // MaindiagFlag: "1",
  20082. // BillCode: order.SetlId,
  20083. // BillNo: order.SetlId,
  20084. // BizSn: order.Number,
  20085. // PsnSelfPay: order.PsnPartAmt,
  20086. // PsnOwnPay: order.PsnPartAmt,
  20087. // AcctPay: order.AcctPay,
  20088. // PsnCashpay: order.PsnCashPay,
  20089. // HiPaymtd: "1",
  20090. // Hsorg: his.InsuplcAdmdvs,
  20091. // HsorgOpter: his.InsuplcAdmdvs,
  20092. // MedinsFillPsn: curRoles.UserName,
  20093. // MedinsFillDept: depart.Name,
  20094. // IptMedType: "2",
  20095. // }
  20096. // struct4101.SetlBegnDate = order.SetlTime
  20097. // struct4101.SetlEndDate = order.SetlTime
  20098. // //if order.SettleType == 1 {
  20099. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20100. // // dateStr := t.Format("2006-01-02")
  20101. // // struct4101.SetlBegnDate = dateStr
  20102. // // struct4101.SetlEndDate = dateStr
  20103. // //} else {
  20104. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20105. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20106. // // dateStartStr := t.Format("2006-01-02")
  20107. // // dateEndStr := t2.Format("2006-01-02")
  20108. // // struct4101.SetlBegnDate = dateStartStr
  20109. // // struct4101.SetlEndDate = dateEndStr
  20110. // //}
  20111. //
  20112. // var rf []CustomFundPay
  20113. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20114. //
  20115. // var tempFunPays []service.CustomStruct
  20116. // var tempFunPay610100 service.CustomStruct
  20117. //
  20118. // for _, item := range rf {
  20119. // if item.FundPayType == "610100" {
  20120. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20121. // tempFunPay610100.FundPayType = item.FundPayType
  20122. // } else {
  20123. // var tempFunPay service.CustomStruct
  20124. // tempFunPay.FundPayamt = item.FundPayamt
  20125. // tempFunPay.FundPayType = item.FundPayType
  20126. // tempFunPays = append(tempFunPays, tempFunPay)
  20127. // }
  20128. // }
  20129. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20130. // struct4101.CustomStruct = tempFunPays
  20131. //
  20132. // var tempDiaginfos []service.DiaginfoStructTwo
  20133. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20134. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20135. //
  20136. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20137. // var config []*models.HisXtDiagnoseConfig
  20138. // for _, item := range diagnosis_ids {
  20139. // id, _ := strconv.ParseInt(item, 10, 64)
  20140. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20141. // config = append(config, &diagnosisConfig)
  20142. // }
  20143. //
  20144. // for index, item := range config {
  20145. // if index == 0 {
  20146. // var tempDiaginfo service.DiaginfoStructTwo
  20147. // tempDiaginfo.DiagCode = item.CountryCode
  20148. // tempDiaginfo.DiagName = item.CountryContentName
  20149. // tempDiaginfo.DiagType = "1"
  20150. // tempDiaginfo.MaindiagFlag = "1"
  20151. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20152. // } else {
  20153. //
  20154. // var tempDiaginfo service.DiaginfoStructTwo
  20155. // tempDiaginfo.DiagCode = item.CountryCode
  20156. // tempDiaginfo.DiagName = item.CountryContentName
  20157. // tempDiaginfo.DiagType = "2"
  20158. // tempDiaginfo.MaindiagFlag = "0"
  20159. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20160. // }
  20161. // }
  20162. // struct4101.Diseinfo = tempDiaginfos
  20163. //
  20164. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20165. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20166. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20167. // tempOpspdiseinfo2.OprnOprtCode = ""
  20168. // tempOpspdiseinfo2.OprnOprtName = ""
  20169. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20170. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20171. //
  20172. // var iteminfo service.IteminfoStruct
  20173. //
  20174. // var bedCostTotal float64 = 0 //床位总费
  20175. // var bedCostSelfTotal float64 = 0 //床位自费
  20176. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20177. //
  20178. // var examineCostTotal float64 = 0 //诊查总费
  20179. // var examineCostSelfTotal float64 = 0 //诊查自费
  20180. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20181. //
  20182. // var nursingCostTotal float64 = 0 //护理总费
  20183. // var nursingCostSelfTotal float64 = 0 //护理自费
  20184. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20185. //
  20186. // var chineseMedicineCostTotal float64 = 0 //中成药
  20187. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20188. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20189. //
  20190. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20191. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20192. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20193. //
  20194. // var registerCostTotal float64 = 0 //一般诊疗费
  20195. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20196. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20197. //
  20198. // var operationCostTotal float64 = 0 //手术费
  20199. // var operationCostSelfTotal float64 = 0 //手术费
  20200. // var operationCostPartSelfTotal float64 = 0 //手术费
  20201. //
  20202. // var otherCostTotal float64 = 0 //其他费用
  20203. // var otherCostSelfTotal float64 = 0 //其他费用
  20204. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20205. //
  20206. // var materialCostTotal float64 = 0 //材料费
  20207. // var materialCostSelfTotal float64 = 0 //材料费
  20208. // var materialCostPartSelfTotal float64 = 0 //材料费
  20209. //
  20210. // var westernMedicineCostTotal float64 = 0 //西药费
  20211. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20212. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20213. //
  20214. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20215. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20216. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20217. //
  20218. // var checkCostTotal float64 = 0 //检查费
  20219. // var checkCostSelfTotal float64 = 0 //检查费
  20220. // var checkCostPartSelfTotal float64 = 0 //检查费
  20221. //
  20222. // var laboratoryCostTotal float64 = 0 //化验费
  20223. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20224. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20225. //
  20226. // var treatCostTotal float64 = 0 //治疗费用
  20227. // var treatCostSelfTotal float64 = 0 //治疗费用
  20228. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20229. //
  20230. // decimal.DivisionPrecision = 2
  20231. //
  20232. // var bed_fulamt_ownpay_amt float64 = 0
  20233. //
  20234. // var examine_fulamt_ownpay_amt float64 = 0
  20235. //
  20236. // var nursing_fulamt_ownpay_amt float64 = 0
  20237. //
  20238. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20239. //
  20240. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20241. //
  20242. // var register_fulamt_ownpay_amt float64 = 0
  20243. //
  20244. // var operation_fulamt_ownpay_amt float64 = 0
  20245. // var other_fulamt_ownpay_amt float64 = 0
  20246. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20247. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20248. // var check_fulamt_ownpay_amt float64 = 0
  20249. // var material_fulamt_ownpay_amt float64 = 0
  20250. // var laboratory_fulamt_ownpay_amt float64 = 0
  20251. // var treat_fulamt_ownpay_amt float64 = 0
  20252. //
  20253. // var bed_claa_sunmfee float64 = 0
  20254. // var bed_clab_amt float64 = 0
  20255. // var bed_other_amt float64 = 0
  20256. //
  20257. // var examine_claa_sunmfee float64 = 0
  20258. // var examine_clab_amt float64 = 0
  20259. // var examine_other_amt float64 = 0
  20260. //
  20261. // var nursing_claa_sunmfee float64 = 0
  20262. // var nursing_clab_amt float64 = 0
  20263. // var nursing_other_amt float64 = 0
  20264. //
  20265. // var chinese_medicine_claa_sunmfee float64 = 0
  20266. // var chinese_medicine_clab_amt float64 = 0
  20267. // var chinese_medicine_other_amt float64 = 0
  20268. //
  20269. // var commonly_treatment_claa_sunmfee float64 = 0
  20270. // var commonly_treatment_clab_amt float64 = 0
  20271. // var commonly_treatment_other_amt float64 = 0
  20272. //
  20273. // var operation_claa_sunmfee float64 = 0
  20274. // var operation_clab_amt float64 = 0
  20275. // var operation_other_amt float64 = 0
  20276. //
  20277. // var other_claa_sunmfee float64 = 0
  20278. // var other_clab_amt float64 = 0
  20279. // var other_other_amt float64 = 0
  20280. //
  20281. // var westernMedicine_claa_sunmfee float64 = 0
  20282. // var westernMedicine_clab_amt float64 = 0
  20283. // var westernMedicine_other_amt float64 = 0
  20284. //
  20285. // var chineseTraditional_claa_sunmfee float64 = 0
  20286. // var chineseTraditional_clab_amt float64 = 0
  20287. // var chineseTraditional_other_amt float64 = 0
  20288. //
  20289. // var check_claa_sunmfee float64 = 0
  20290. // var check_clab_amt float64 = 0
  20291. // var check_other_amt float64 = 0
  20292. //
  20293. // var material_claa_sunmfee float64 = 0
  20294. // var material_clab_amt float64 = 0
  20295. // var material_other_amt float64 = 0
  20296. //
  20297. // var laboratory_claa_sunmfee float64 = 0
  20298. // var laboratory_clab_amt float64 = 0
  20299. // var laboratory_other_amt float64 = 0
  20300. //
  20301. // var treat_claa_sunmfee float64 = 0
  20302. // var treat_clab_amt float64 = 0
  20303. // var treat_other_amt float64 = 0
  20304. //
  20305. // var register_claa_sunmfee float64 = 0
  20306. // var register_clab_amt float64 = 0
  20307. // var register_other_amt float64 = 0
  20308. //
  20309. // for _, item := range order.HisOrderInfo {
  20310. // if item.MedChrgitmType == "01" { //床位费
  20311. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20312. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20313. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20314. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20315. // if item.ChrgitmLv == "1" {
  20316. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20317. // }
  20318. // if item.ChrgitmLv == "2" {
  20319. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20320. //
  20321. // }
  20322. // if item.ChrgitmLv == "3" {
  20323. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20324. // }
  20325. //
  20326. // }
  20327. //
  20328. // if item.MedChrgitmType == "02" { //诊查
  20329. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20330. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20331. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20332. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20333. // if item.ChrgitmLv == "1" {
  20334. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20335. // }
  20336. // if item.ChrgitmLv == "2" {
  20337. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20338. //
  20339. // }
  20340. // if item.ChrgitmLv == "3" {
  20341. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20342. // }
  20343. //
  20344. // }
  20345. //
  20346. // if item.MedChrgitmType == "03" { //检查费
  20347. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20348. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20349. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20350. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20351. // if item.ChrgitmLv == "1" {
  20352. //
  20353. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20354. //
  20355. // }
  20356. // if item.ChrgitmLv == "2" {
  20357. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20358. //
  20359. // }
  20360. // if item.ChrgitmLv == "3" {
  20361. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20362. // }
  20363. // }
  20364. //
  20365. // if item.MedChrgitmType == "04" { //化验费
  20366. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20367. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20368. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20369. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20370. // if item.ChrgitmLv == "1" {
  20371. //
  20372. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20373. //
  20374. // }
  20375. // if item.ChrgitmLv == "2" {
  20376. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20377. //
  20378. // }
  20379. // if item.ChrgitmLv == "3" {
  20380. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20381. // }
  20382. // }
  20383. //
  20384. // if item.MedChrgitmType == "05" { //治疗费
  20385. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20386. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20387. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20388. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20389. // if item.ChrgitmLv == "1" {
  20390. //
  20391. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20392. //
  20393. // }
  20394. // if item.ChrgitmLv == "2" {
  20395. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20396. //
  20397. // }
  20398. // if item.ChrgitmLv == "3" {
  20399. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20400. // }
  20401. // }
  20402. //
  20403. // if item.MedChrgitmType == "06" { //手术费
  20404. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20405. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20406. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20407. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20408. //
  20409. // if item.ChrgitmLv == "1" {
  20410. //
  20411. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20412. //
  20413. // }
  20414. // if item.ChrgitmLv == "2" {
  20415. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20416. //
  20417. // }
  20418. // if item.ChrgitmLv == "3" {
  20419. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20420. // }
  20421. // }
  20422. //
  20423. // if item.MedChrgitmType == "07" { //手术费
  20424. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20425. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20426. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20427. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20428. //
  20429. // if item.ChrgitmLv == "1" {
  20430. //
  20431. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20432. //
  20433. // }
  20434. // if item.ChrgitmLv == "2" {
  20435. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20436. //
  20437. // }
  20438. // if item.ChrgitmLv == "3" {
  20439. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20440. // }
  20441. // }
  20442. //
  20443. // if item.MedChrgitmType == "08" { //材料费
  20444. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20445. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20446. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20447. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20448. // if item.ChrgitmLv == "1" {
  20449. //
  20450. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20451. //
  20452. // }
  20453. // if item.ChrgitmLv == "2" {
  20454. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20455. //
  20456. // }
  20457. // if item.ChrgitmLv == "3" {
  20458. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20459. // }
  20460. // }
  20461. // if item.MedChrgitmType == "09" { //西药费
  20462. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20463. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20464. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20465. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20466. // if item.ChrgitmLv == "1" {
  20467. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20468. // }
  20469. // if item.ChrgitmLv == "2" {
  20470. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20471. // }
  20472. // if item.ChrgitmLv == "3" {
  20473. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20474. // }
  20475. // }
  20476. // if item.MedChrgitmType == "10" { //中药饮片
  20477. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20478. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20479. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20480. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20481. // if item.ChrgitmLv == "1" {
  20482. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20483. // }
  20484. // if item.ChrgitmLv == "2" {
  20485. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20486. // }
  20487. // if item.ChrgitmLv == "3" {
  20488. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20489. // }
  20490. // }
  20491. //
  20492. // if item.MedChrgitmType == "11" { //中成费
  20493. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20494. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20495. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20496. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20497. // if item.ChrgitmLv == "1" {
  20498. //
  20499. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20500. //
  20501. // }
  20502. // if item.ChrgitmLv == "2" {
  20503. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20504. //
  20505. // }
  20506. // if item.ChrgitmLv == "3" {
  20507. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20508. // }
  20509. // }
  20510. //
  20511. // if item.MedChrgitmType == "12" { //中成费
  20512. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20513. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20514. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20515. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20516. // if item.ChrgitmLv == "1" {
  20517. //
  20518. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20519. //
  20520. // }
  20521. // if item.ChrgitmLv == "2" {
  20522. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20523. //
  20524. // }
  20525. // if item.ChrgitmLv == "3" {
  20526. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20527. // }
  20528. // }
  20529. //
  20530. // if item.MedChrgitmType == "13" { //中成费
  20531. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20532. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20533. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20534. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20535. // if item.ChrgitmLv == "1" {
  20536. //
  20537. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20538. //
  20539. // }
  20540. // if item.ChrgitmLv == "2" {
  20541. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20542. //
  20543. // }
  20544. // if item.ChrgitmLv == "3" {
  20545. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20546. // }
  20547. // }
  20548. //
  20549. // if item.MedChrgitmType == "14" { //其他费
  20550. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20551. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20552. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20553. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20554. // if item.ChrgitmLv == "1" {
  20555. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20556. //
  20557. // }
  20558. // if item.ChrgitmLv == "2" {
  20559. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20560. //
  20561. // }
  20562. // if item.ChrgitmLv == "3" {
  20563. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20564. // }
  20565. // }
  20566. //
  20567. // }
  20568. //
  20569. // var iteminfoStructs []service.IteminfoStruct
  20570. //
  20571. // if bedCostTotal != 0 {
  20572. // iteminfo.MedChrgitm = "01"
  20573. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20574. // iteminfo.Amt = bedCostTotal
  20575. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20576. // iteminfo.ClabAmt = bed_clab_amt
  20577. // iteminfo.OthAmt = bed_other_amt
  20578. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20579. // }
  20580. //
  20581. // if examineCostTotal != 0 {
  20582. // iteminfo.MedChrgitm = "02"
  20583. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20584. // iteminfo.Amt = examineCostTotal
  20585. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20586. // iteminfo.ClabAmt = examine_clab_amt
  20587. // iteminfo.OthAmt = examine_other_amt
  20588. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20589. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20590. // }
  20591. //
  20592. // if checkCostTotal != 0 {
  20593. // iteminfo.MedChrgitm = "03"
  20594. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20595. // iteminfo.Amt = checkCostTotal
  20596. // iteminfo.ClaaSumfee = check_claa_sunmfee
  20597. // iteminfo.ClabAmt = check_clab_amt
  20598. // iteminfo.OthAmt = check_other_amt
  20599. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20600. //
  20601. // }
  20602. //
  20603. // if laboratoryCostTotal != 0 {
  20604. // iteminfo.MedChrgitm = "04"
  20605. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20606. // iteminfo.Amt = laboratoryCostTotal
  20607. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20608. // iteminfo.ClabAmt = laboratory_clab_amt
  20609. // iteminfo.OthAmt = laboratory_other_amt
  20610. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20611. //
  20612. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20613. //
  20614. // }
  20615. //
  20616. // if treatCostTotal != 0 {
  20617. // iteminfo.MedChrgitm = "05"
  20618. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20619. // iteminfo.Amt = treatCostTotal
  20620. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  20621. // iteminfo.ClabAmt = treat_clab_amt
  20622. // iteminfo.OthAmt = treat_other_amt
  20623. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20624. // //(struct4101.IteminfoStruct, iteminfo)
  20625. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20626. // }
  20627. //
  20628. // if operationCostTotal != 0 {
  20629. // iteminfo.MedChrgitm = "06"
  20630. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20631. // iteminfo.Amt = operationCostTotal
  20632. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  20633. // iteminfo.ClabAmt = operation_clab_amt
  20634. // iteminfo.OthAmt = operation_other_amt
  20635. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20636. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20637. // }
  20638. //
  20639. // if nursingCostTotal != 0 {
  20640. // iteminfo.MedChrgitm = "07"
  20641. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  20642. // iteminfo.Amt = nursingCostTotal
  20643. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  20644. // iteminfo.ClabAmt = nursing_clab_amt
  20645. // iteminfo.OthAmt = nursing_other_amt
  20646. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20647. // }
  20648. //
  20649. // if materialCostTotal != 0 {
  20650. // iteminfo.MedChrgitm = "08"
  20651. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20652. // iteminfo.Amt = materialCostTotal
  20653. // iteminfo.ClaaSumfee = material_claa_sunmfee
  20654. // iteminfo.ClabAmt = material_clab_amt
  20655. // iteminfo.OthAmt = material_other_amt
  20656. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20657. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20658. // }
  20659. //
  20660. // if westernMedicineCostTotal != 0 {
  20661. // iteminfo.MedChrgitm = "09"
  20662. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20663. // iteminfo.Amt = westernMedicineCostTotal
  20664. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20665. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20666. // iteminfo.OthAmt = westernMedicine_other_amt
  20667. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20668. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20669. //
  20670. // }
  20671. //
  20672. // if chineseMedicineCostTotal != 0 {
  20673. // iteminfo.MedChrgitm = "10"
  20674. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  20675. // iteminfo.Amt = chineseMedicineCostTotal
  20676. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  20677. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  20678. // iteminfo.OthAmt = chinese_medicine_other_amt
  20679. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20680. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20681. //
  20682. // }
  20683. //
  20684. // if chineseTraditionalMedicineCostTotal != 0 {
  20685. // iteminfo.MedChrgitm = "11"
  20686. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20687. // iteminfo.Amt = westernMedicineCostTotal
  20688. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20689. // iteminfo.ClabAmt = westernMedicine_clab_amt
  20690. // iteminfo.OthAmt = westernMedicine_other_amt
  20691. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20692. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20693. //
  20694. // }
  20695. //
  20696. // if commonlyTreatmentCostTotal != 0 {
  20697. // iteminfo.MedChrgitm = "12"
  20698. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  20699. // iteminfo.Amt = commonlyTreatmentCostTotal
  20700. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  20701. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  20702. // iteminfo.OthAmt = commonly_treatment_other_amt
  20703. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20704. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20705. //
  20706. // }
  20707. //
  20708. // if registerCostTotal != 0 {
  20709. // iteminfo.MedChrgitm = "13"
  20710. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  20711. // iteminfo.Amt = registerCostTotal
  20712. // iteminfo.ClaaSumfee = register_claa_sunmfee
  20713. // iteminfo.ClabAmt = register_clab_amt
  20714. // iteminfo.OthAmt = register_other_amt
  20715. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20716. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20717. //
  20718. // }
  20719. //
  20720. // if otherCostTotal != 0 {
  20721. // iteminfo.MedChrgitm = "14"
  20722. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20723. // iteminfo.Amt = otherCostTotal
  20724. // iteminfo.ClaaSumfee = other_claa_sunmfee
  20725. // iteminfo.ClabAmt = other_clab_amt
  20726. // iteminfo.OthAmt = other_other_amt
  20727. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20728. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20729. //
  20730. // }
  20731. // struct4101.IteminfoStruct = iteminfoStructs
  20732. // time_arr := strings.Split(order.SetlTime, " ")
  20733. // struct4101.AdmTime = time_arr[0]
  20734. // struct4101.AdmEndTime = time_arr[0]
  20735. //
  20736. // struct4101.DoctorName = doctor.UserName
  20737. // struct4101.DoctorCode = doctor.DoctorNumber
  20738. //
  20739. // struct4101.Ntly = "中国"
  20740. // struct4101.AdmCaty = "A03.06"
  20741. // var res ResultSeventeen
  20742. // if miConfig.MdtrtareaAdmvs == "421300" {
  20743. // data := make(map[string]interface{})
  20744. // data["struct4101"] = struct4101
  20745. // data["secret_key"] = miConfig.SecretKey
  20746. // data["org_name"] = miConfig.OrgName
  20747. // data["opera"] = curRoles.UserName
  20748. // data["code"] = miConfig.Code
  20749. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  20750. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20751. //
  20752. // client := &http.Client{}
  20753. // bytesData, _ := json.Marshal(data)
  20754. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  20755. // resp, _ := client.Do(req)
  20756. // defer resp.Body.Close()
  20757. // body, ioErr := ioutil.ReadAll(resp.Body)
  20758. // if ioErr != nil {
  20759. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20761. // return
  20762. // }
  20763. // var respJSON map[string]interface{}
  20764. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20765. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20766. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20767. // return
  20768. // }
  20769. //
  20770. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20771. // userJSONBytes, _ := json.Marshal(respJSON)
  20772. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20773. // utils.ErrorLog("解析失败:%v", err)
  20774. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20775. // adminUser := c.GetAdminUserInfo()
  20776. // errlog := &models.HisOrderError{
  20777. // UserOrgId: adminUser.CurrentOrgId,
  20778. // Ctime: time.Now().Unix(),
  20779. // Mtime: time.Now().Unix(),
  20780. // ErrMsg: res.ErrMsg + "解析失败",
  20781. // Status: 1,
  20782. // PatientId: order_id,
  20783. // Stage: 10088,
  20784. // }
  20785. // service.CreateErrMsgLog(errlog)
  20786. // continue
  20787. // }
  20788. //
  20789. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  20790. // data := make(map[string]interface{})
  20791. // data["struct4101"] = struct4101
  20792. // data["secret_key"] = miConfig.SecretKey
  20793. // data["org_name"] = miConfig.OrgName
  20794. // data["opera"] = curRoles.UserName
  20795. // data["code"] = miConfig.Code
  20796. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  20797. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20798. //
  20799. // client := &http.Client{}
  20800. // bytesData, _ := json.Marshal(data)
  20801. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  20802. // resp, _ := client.Do(req)
  20803. // defer resp.Body.Close()
  20804. // body, ioErr := ioutil.ReadAll(resp.Body)
  20805. // if ioErr != nil {
  20806. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20808. // return
  20809. // }
  20810. // var respJSON map[string]interface{}
  20811. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20812. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20814. // return
  20815. // }
  20816. //
  20817. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20818. // userJSONBytes, _ := json.Marshal(respJSON)
  20819. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20820. // utils.ErrorLog("解析失败:%v", err)
  20821. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20822. // adminUser := c.GetAdminUserInfo()
  20823. // errlog := &models.HisOrderError{
  20824. // UserOrgId: adminUser.CurrentOrgId,
  20825. // Ctime: time.Now().Unix(),
  20826. // Mtime: time.Now().Unix(),
  20827. // ErrMsg: res.ErrMsg + "解析失败",
  20828. // Status: 1,
  20829. // PatientId: order_id,
  20830. // Stage: 10088,
  20831. // }
  20832. // service.CreateErrMsgLog(errlog)
  20833. // continue
  20834. // }
  20835. //
  20836. // } else {
  20837. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  20838. // fmt.Println(result)
  20839. //
  20840. // var dat map[string]interface{}
  20841. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20842. // fmt.Println(dat)
  20843. // } else {
  20844. // fmt.Println(err)
  20845. // }
  20846. // userJSONBytes, _ := json.Marshal(dat)
  20847. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20848. // utils.ErrorLog("解析失败:%v", err)
  20849. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20850. // adminUser := c.GetAdminUserInfo()
  20851. // errlog := &models.HisOrderError{
  20852. // UserOrgId: adminUser.CurrentOrgId,
  20853. // Ctime: time.Now().Unix(),
  20854. // Mtime: time.Now().Unix(),
  20855. // ErrMsg: res.ErrMsg + "解析失败",
  20856. // Status: 1,
  20857. // PatientId: order_id,
  20858. // Stage: 10106,
  20859. // }
  20860. // service.CreateErrMsgLog(errlog)
  20861. // continue
  20862. // }
  20863. // }
  20864. //
  20865. // if res.Infcode != 0 {
  20866. // adminUser := c.GetAdminUserInfo()
  20867. // errlog := &models.HisOrderError{
  20868. // UserOrgId: adminUser.CurrentOrgId,
  20869. // Ctime: time.Now().Unix(),
  20870. // Mtime: time.Now().Unix(),
  20871. // ErrMsg: res.ErrMsg,
  20872. // Status: 1,
  20873. // PatientId: order_id,
  20874. // Stage: 10106,
  20875. // }
  20876. // service.CreateErrMsgLog(errlog)
  20877. // continue
  20878. // } else {
  20879. // hisFundSettleListResult := &models.HisFundSettleListResult{
  20880. // Number: res.Output.SetlListId,
  20881. // Status: 1,
  20882. // Ctime: time.Now().Unix(),
  20883. // Mtime: time.Now().Unix(),
  20884. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20885. // IsUpload: 1,
  20886. // OrderId: order_id,
  20887. // }
  20888. // service.CreateUploadRecord(hisFundSettleListResult)
  20889. // continue
  20890. // }
  20891. // }
  20892. //}
  20893. func (c *HisApiController) GetOrgInfo() {
  20894. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  20895. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  20896. }
  20897. func (c *HisApiController) GetHisPatientInfo() {
  20898. medical_insurance_card := c.GetString("medical_insurance_card")
  20899. id_card_type, _ := c.GetInt64("id_card_type")
  20900. id_card := c.GetString("id_card")
  20901. adminInfo := c.GetAdminUserInfo()
  20902. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  20903. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  20904. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  20905. IdCardNo := ""
  20906. if id_card_type == 1 {
  20907. IdCardNo = medical_insurance_card
  20908. } else if id_card_type == 2 {
  20909. IdCardNo = id_card
  20910. }
  20911. if config.IsOpen == 1 {
  20912. 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
  20913. resp, requestErr := http.Get(api)
  20914. if requestErr != nil {
  20915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20916. return
  20917. }
  20918. defer resp.Body.Close()
  20919. body, ioErr := ioutil.ReadAll(resp.Body)
  20920. if ioErr != nil {
  20921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20923. return
  20924. }
  20925. var respJSON map[string]interface{}
  20926. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20929. return
  20930. }
  20931. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20932. userJSONBytes, _ := json.Marshal(userJSON)
  20933. var res ResultTwo
  20934. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20935. utils.ErrorLog("解析失败:%v", err)
  20936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20937. return
  20938. }
  20939. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  20940. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  20941. infoStr := string(Iinfos)
  20942. idetinfoStr := string(Idetinfos)
  20943. if res.Infcode == 0 {
  20944. his := models.VMHisPatient{
  20945. Status: 1,
  20946. Ctime: time.Now().Unix(),
  20947. Mtime: time.Now().Unix(),
  20948. PsnNo: res.Output.Baseinfo.PsnNo,
  20949. PsnCertType: res.Output.Baseinfo.PsnCertType,
  20950. Certno: res.Output.Baseinfo.Certno,
  20951. PsnName: res.Output.Baseinfo.PsnName,
  20952. Gend: res.Output.Baseinfo.Gend,
  20953. Naty: res.Output.Baseinfo.Naty,
  20954. Iinfo: infoStr,
  20955. Idetinfo: idetinfoStr,
  20956. UserOrgId: adminInfo.CurrentOrgId,
  20957. IsReturn: 1,
  20958. IdCardType: id_card_type,
  20959. }
  20960. c.ServeSuccessJSON(map[string]interface{}{
  20961. "info": his,
  20962. })
  20963. } else {
  20964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  20965. return
  20966. }
  20967. }
  20968. }
  20969. //func GetBasBaseInfo() (jsonStr string, err error) {
  20970. //
  20971. // handle := syscall.NewLazyDLL("SSCard.dll")
  20972. // add := handle.NewProc("ReadCardBas")
  20973. // str := make([]byte, 1024)
  20974. // str1 := make([]byte, 1024)
  20975. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  20976. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  20977. //
  20978. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  20979. //
  20980. // fmt.Println("> Add(4,5)的结果为:", ret)
  20981. // handle.Release()
  20982. //
  20983. // return "", nil
  20984. //
  20985. //}
  20986. //func GetQRBaseInfo() (jsonStr string, err error) {
  20987. // handle := syscall.LoadDLL("SSCard.dll")
  20988. // ReadCardBas := handle.FindProc("GetQRBase")
  20989. //
  20990. // str := make([]byte, 256)
  20991. // str1 := make([]byte, 256)
  20992. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  20993. //
  20994. // fmt.Println(string(str))
  20995. // fmt.Println(r)
  20996. // return string(str), nil
  20997. //}
  20998. //func CardInit() int {
  20999. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21000. // add := DllTestDef.MustFindProc("Init")
  21001. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21002. // if err != nil {
  21003. // fmt.Println("SSCard的运算结果为:", ret)
  21004. // }
  21005. // result := int(ret)
  21006. // return result
  21007. //}
  21008. //func CardInit() int {
  21009. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21010. // if err != nil {
  21011. // fmt.Println("SSCard的运算结果为:", ret)
  21012. // }
  21013. // fmt.Println(err)
  21014. // result := int(ret)
  21015. // return result
  21016. //}
  21017. func IntPtr(n int) uintptr {
  21018. return uintptr(n)
  21019. }
  21020. func StrPtr(s string) uintptr {
  21021. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21022. }
  21023. type Result2001 struct {
  21024. Cainfo interface{} `json:"cainfo"`
  21025. ErrMsg string `json:"err_msg"`
  21026. InfRefmsgid string `json:"inf_refmsgid"`
  21027. Infcode int64 `json:"infcode"`
  21028. Output struct {
  21029. Trtinfo struct {
  21030. PsnNo string `json:"psn_no"`
  21031. TrtChkType string `json:"trt_chk_type"`
  21032. FundPayType string `json:"fund_pay_type"`
  21033. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21034. Begndate string `json:"begndate"`
  21035. Enddate string `json:"enddate"`
  21036. TrtChkRslt string `json:"trt_chk_rslt"`
  21037. } `json:"trtinfo"`
  21038. } `json:"output"`
  21039. RefmsgTime string `json:"refmsg_time"`
  21040. RespondTime string `json:"respond_time"`
  21041. Signtype interface{} `json:"signtype"`
  21042. WarnMsg interface{} `json:"warn_msg"`
  21043. }
  21044. type Result2001Org10265 struct {
  21045. Cainfo interface{} `json:"cainfo"`
  21046. ErrMsg string `json:"err_msg"`
  21047. InfRefmsgid string `json:"inf_refmsgid"`
  21048. Infcode string `json:"infcode"`
  21049. Output struct {
  21050. Trtinfo struct {
  21051. PsnNo string `json:"psn_no"`
  21052. TrtChkType string `json:"trt_chk_type"`
  21053. FundPayType string `json:"fund_pay_type"`
  21054. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21055. Begndate string `json:"begndate"`
  21056. Enddate string `json:"enddate"`
  21057. TrtChkRslt string `json:"trt_chk_rslt"`
  21058. } `json:"trtinfo"`
  21059. } `json:"output"`
  21060. RefmsgTime string `json:"refmsg_time"`
  21061. RespondTime string `json:"respond_time"`
  21062. Signtype interface{} `json:"signtype"`
  21063. WarnMsg interface{} `json:"warn_msg"`
  21064. }
  21065. type ResultTwo struct {
  21066. ErrMsg string `json:"err_msg"`
  21067. InfRefmsgid string `json:"inf_refmsgid"`
  21068. Infcode int64 `json:"infcode"`
  21069. Output struct {
  21070. Baseinfo struct {
  21071. //Brdy string `json:"brdy"`
  21072. Certno string `json:"certno"`
  21073. Gend string `json:"gend"`
  21074. Naty string `json:"naty"`
  21075. PsnCertType string `json:"psn_cert_type"`
  21076. PsnName string `json:"psn_name"`
  21077. PsnNo string `json:"psn_no"`
  21078. } `json:"baseinfo"`
  21079. Idetinfo []interface{} `json:"idetinfo"`
  21080. Iinfo []struct {
  21081. Balc float64 `json:"balc"`
  21082. CvlservFlag string `json:"cvlserv_flag"`
  21083. EmpName string `json:"emp_name"`
  21084. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21085. Insutype string `json:"insutype"`
  21086. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21087. //PausInsuDate string `json:"paus_insu_date"`
  21088. //PsnInsuDate string `json:"psn_insu_date"`
  21089. PsnInsuStas string `json:"psn_insu_stas"`
  21090. PsnType string `json:"psn_type"`
  21091. } `json:"insuinfo"`
  21092. } `json:"output"`
  21093. RefmsgTime string `json:"refmsg_time"`
  21094. RespondTime string `json:"respond_time"`
  21095. Signtype interface{} `json:"signtype"`
  21096. WarnInfo interface{} `json:"warn_info"`
  21097. }
  21098. type ResultTwo10265 struct {
  21099. ErrMsg string `json:"err_msg"`
  21100. InfRefmsgid string `json:"inf_refmsgid"`
  21101. Infcode string `json:"infcode"`
  21102. Output struct {
  21103. Baseinfo struct {
  21104. //Brdy string `json:"brdy"`
  21105. Certno string `json:"certno"`
  21106. Gend string `json:"gend"`
  21107. Naty string `json:"naty"`
  21108. PsnCertType string `json:"psn_cert_type"`
  21109. PsnName string `json:"psn_name"`
  21110. PsnNo string `json:"psn_no"`
  21111. } `json:"baseinfo"`
  21112. Idetinfo []interface{} `json:"idetinfo"`
  21113. Iinfo []struct {
  21114. Balc float64 `json:"balc"`
  21115. CvlservFlag string `json:"cvlserv_flag"`
  21116. EmpName string `json:"emp_name"`
  21117. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21118. Insutype string `json:"insutype"`
  21119. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21120. PsnInsuStas string `json:"psn_insu_stas"`
  21121. PsnType string `json:"psn_type"`
  21122. } `json:"insuinfo"`
  21123. } `json:"output"`
  21124. RefmsgTime string `json:"refmsg_time"`
  21125. RespondTime string `json:"respond_time"`
  21126. Signtype interface{} `json:"signtype"`
  21127. WarnInfo interface{} `json:"warn_info"`
  21128. }
  21129. type ResultThree struct {
  21130. Cainfo interface{} `json:"cainfo"`
  21131. ErrMsg string `json:"err_msg"`
  21132. InfRefmsgid string `json:"inf_refmsgid"`
  21133. Infcode int64 `json:"infcode"`
  21134. Output struct {
  21135. Data struct {
  21136. IptOtpNo string `json:"ipt_otp_no"`
  21137. MdtrtID string `json:"mdtrt_id"`
  21138. PsnNo string `json:"psn_no"`
  21139. } `json:"data"`
  21140. } `json:"output"`
  21141. RefmsgTime string `json:"refmsg_time"`
  21142. RespondTime string `json:"respond_time"`
  21143. Signtype interface{} `json:"signtype"`
  21144. WarnMsg interface{} `json:"warn_msg"`
  21145. }
  21146. type ResultThree10265 struct {
  21147. Cainfo interface{} `json:"cainfo"`
  21148. ErrMsg string `json:"err_msg"`
  21149. InfRefmsgid string `json:"inf_refmsgid"`
  21150. Infcode string `json:"infcode"`
  21151. Output struct {
  21152. Data struct {
  21153. IptOtpNo string `json:"ipt_otp_no"`
  21154. MdtrtID string `json:"mdtrt_id"`
  21155. PsnNo string `json:"psn_no"`
  21156. } `json:"data"`
  21157. } `json:"output"`
  21158. RefmsgTime string `json:"refmsg_time"`
  21159. RespondTime string `json:"respond_time"`
  21160. Signtype interface{} `json:"signtype"`
  21161. WarnMsg interface{} `json:"warn_msg"`
  21162. }
  21163. type ResultFour struct {
  21164. Cainfo string `json:"cainfo"`
  21165. ErrMsg string `json:"err_msg"`
  21166. InfRefmsgid string `json:"inf_refmsgid"`
  21167. Infcode int64 `json:"infcode"`
  21168. Output struct {
  21169. Result []struct {
  21170. BasMednFlag string `json:"bas_medn_flag"`
  21171. ChldMedcFlag string `json:"chld_medc_flag"`
  21172. ChrgitmLv string `json:"chrgitm_lv"`
  21173. Cnt float64 `json:"cnt"`
  21174. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21175. DrtReimFlag string `json:"drt_reim_flag"`
  21176. FeedetlSn string `json:"feedetl_sn"`
  21177. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21178. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21179. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21180. ListSpItemFlag string `json:"list_sp_item_flag"`
  21181. LmtUsedFlag string `json:"lmt_used_flag"`
  21182. MedChrgitmType string `json:"med_chrgitm_type"`
  21183. Memo string `json:"memo"`
  21184. OverlmtAmt float64 `json:"overlmt_amt"`
  21185. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21186. Pric float64 `json:"pric"`
  21187. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21188. SelfpayProp float64 `json:"selfpay_prop"`
  21189. } `json:"result"`
  21190. } `json:"output"`
  21191. RefmsgTime string `json:"refmsg_time"`
  21192. RespondTime string `json:"respond_time"`
  21193. Signtype string `json:"signtype"`
  21194. WarnMsg string `json:"warn_msg"`
  21195. }
  21196. type ResultFour10265 struct {
  21197. Cainfo string `json:"cainfo"`
  21198. ErrMsg string `json:"err_msg"`
  21199. InfRefmsgid string `json:"inf_refmsgid"`
  21200. Infcode string `json:"infcode"`
  21201. Output struct {
  21202. Result []struct {
  21203. BasMednFlag string `json:"bas_medn_flag"`
  21204. ChldMedcFlag string `json:"chld_medc_flag"`
  21205. ChrgitmLv string `json:"chrgitm_lv"`
  21206. Cnt float64 `json:"cnt"`
  21207. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21208. DrtReimFlag string `json:"drt_reim_flag"`
  21209. FeedetlSn string `json:"feedetl_sn"`
  21210. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21211. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21212. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21213. ListSpItemFlag string `json:"list_sp_item_flag"`
  21214. LmtUsedFlag string `json:"lmt_used_flag"`
  21215. MedChrgitmType string `json:"med_chrgitm_type"`
  21216. Memo string `json:"memo"`
  21217. OverlmtAmt float64 `json:"overlmt_amt"`
  21218. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21219. Pric float64 `json:"pric"`
  21220. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21221. SelfpayProp float64 `json:"selfpay_prop"`
  21222. } `json:"result"`
  21223. } `json:"output"`
  21224. RefmsgTime string `json:"refmsg_time"`
  21225. RespondTime string `json:"respond_time"`
  21226. Signtype string `json:"signtype"`
  21227. WarnMsg string `json:"warn_msg"`
  21228. }
  21229. type ResultMemo struct {
  21230. InsuAdmdvs string `json:"insuAdmdvs"`
  21231. }
  21232. // [{"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}]
  21233. type ResultIDInfo struct {
  21234. Begntime string `json:"begntime"`
  21235. Endtime string `json:"endtime"`
  21236. Memo string `json:"memo"`
  21237. }
  21238. type ResultFive struct {
  21239. Balc float64 `json:"balc"`
  21240. CvlservFlag string `json:"cvlserv_flag"`
  21241. EmpName string `json:"emp_name"`
  21242. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21243. Insutype string `json:"insutype"`
  21244. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21245. PausInsuDate string `json:"paus_insu_date"`
  21246. PsnInsuDate string `json:"psn_insu_date"`
  21247. PsnInsuStas string `json:"psn_insu_stas"`
  21248. PsnType string `json:"psn_type"`
  21249. }
  21250. type ResultSix struct {
  21251. Cainfo interface{} `json:"cainfo"`
  21252. ErrMsg string `json:"err_msg"`
  21253. InfRefmsgid string `json:"inf_refmsgid"`
  21254. Infcode int64 `json:"infcode"`
  21255. Output struct {
  21256. } `json:"output"`
  21257. RefmsgTime string `json:"refmsg_time"`
  21258. RespondTime string `json:"respond_time"`
  21259. Signtype interface{} `json:"signtype"`
  21260. WarnMsg interface{} `json:"warn_msg"`
  21261. }
  21262. type FJ3507Result struct {
  21263. Cainfo interface{} `json:"cainfo"`
  21264. ErrMsg string `json:"err_msg"`
  21265. InfRefmsgid string `json:"inf_refmsgid"`
  21266. Infcode int64 `json:"infcode"`
  21267. Output struct {
  21268. retRslt string `json:"retRslt"`
  21269. msgRslt string `json:"msgRslt"`
  21270. } `json:"output"`
  21271. RefmsgTime string `json:"refmsg_time"`
  21272. RespondTime string `json:"respond_time"`
  21273. Signtype interface{} `json:"signtype"`
  21274. WarnMsg interface{} `json:"warn_msg"`
  21275. }
  21276. type FJ3507ResultFor10188 struct {
  21277. Cainfo interface{} `json:"cainfo"`
  21278. ErrMsg string `json:"err_msg"`
  21279. InfRefmsgid string `json:"inf_refmsgid"`
  21280. Infcode string `json:"infcode"`
  21281. RefmsgTime string `json:"refmsg_time"`
  21282. RespondTime string `json:"respond_time"`
  21283. Signtype interface{} `json:"signtype"`
  21284. WarnMsg interface{} `json:"warn_msg"`
  21285. }
  21286. type Result2406 struct {
  21287. Cainfo interface{} `json:"cainfo"`
  21288. ErrMsg string `json:"err_msg"`
  21289. InfRefmsgid string `json:"inf_refmsgid"`
  21290. Infcode int64 `json:"infcode"`
  21291. Output struct {
  21292. Result struct {
  21293. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21294. } `json:"result"`
  21295. } `json:"output"`
  21296. RefmsgTime string `json:"refmsg_time"`
  21297. RespondTime string `json:"respond_time"`
  21298. Signtype interface{} `json:"signtype"`
  21299. WarnMsg interface{} `json:"warn_msg"`
  21300. }
  21301. type GZResultSix struct {
  21302. Cainfo interface{} `json:"cainfo"`
  21303. ErrMsg string `json:"err_msg"`
  21304. InfRefmsgid string `json:"inf_refmsgid"`
  21305. Infcode int64 `json:"infcode"`
  21306. Output string `json:"output"`
  21307. RefmsgTime string `json:"refmsg_time"`
  21308. RespondTime string `json:"respond_time"`
  21309. Signtype interface{} `json:"signtype"`
  21310. WarnMsg interface{} `json:"warn_msg"`
  21311. }
  21312. type ResultSix10265 struct {
  21313. Cainfo interface{} `json:"cainfo"`
  21314. ErrMsg string `json:"err_msg"`
  21315. InfRefmsgid string `json:"inf_refmsgid"`
  21316. Infcode string `json:"infcode"`
  21317. Output struct {
  21318. } `json:"output"`
  21319. RefmsgTime string `json:"refmsg_time"`
  21320. RespondTime string `json:"respond_time"`
  21321. Signtype interface{} `json:"signtype"`
  21322. WarnMsg interface{} `json:"warn_msg"`
  21323. }
  21324. type ResultSeven struct {
  21325. Cainfo string `json:"cainfo"`
  21326. ErrMsg string `json:"err_msg"`
  21327. InfRefmsgid string `json:"inf_refmsgid"`
  21328. Infcode int64 `json:"infcode"`
  21329. Output struct {
  21330. Setlinfo struct {
  21331. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21332. AcctPay float64 `json:"acct_pay"`
  21333. ActPayDedc float64 `json:"act_pay_dedc"`
  21334. Age float64 `json:"age"`
  21335. Balc float64 `json:"balc"`
  21336. Certno string `json:"certno"`
  21337. ClrOptins string `json:"clr_optins"`
  21338. ClrType string `json:"clr_type"`
  21339. ClrWay string `json:"clr_way"`
  21340. CvlservFlag string `json:"cvlserv_flag"`
  21341. CvlservPay float64 `json:"cvlserv_pay"`
  21342. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21343. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21344. Gend string `json:"gend"`
  21345. HifesPay float64 `json:"hifes_pay"`
  21346. HifmiPay float64 `json:"hifmi_pay"`
  21347. HifpPay float64 `json:"hifp_pay"`
  21348. HospPartAmt float64 `json:"hosp_part_amt"`
  21349. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21350. Insutype string `json:"insutype"`
  21351. MafPay float64 `json:"maf_pay"`
  21352. MdtrtCertType string `json:"mdtrt_cert_type"`
  21353. HifobPay float64 `json:"hifob_pay"`
  21354. MdtrtID string `json:"mdtrt_id"`
  21355. MedType string `json:"med_type"`
  21356. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21357. MedinsSetlID string `json:"medins_setl_id"`
  21358. Naty string `json:"naty"`
  21359. OthPay float64 `json:"oth_pay"`
  21360. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21361. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21362. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21363. PsnCashPay float64 `json:"psn_cash_pay"`
  21364. PsnCertType string `json:"psn_cert_type"`
  21365. PsnName string `json:"psn_name"`
  21366. PsnNo string `json:"psn_no"`
  21367. PsnPartAmt float64 `json:"psn_part_amt"`
  21368. PsnType string `json:"psn_type"`
  21369. SetlID string `json:"setl_id"`
  21370. SetlTime string `json:"setl_time"`
  21371. } `json:"setlinfo"`
  21372. Setldetail interface{} `json:"setldetail"`
  21373. } `json:"output"`
  21374. RefmsgTime string `json:"refmsg_time"`
  21375. RespondTime string `json:"respond_time"`
  21376. Signtype interface{} `json:"signtype"`
  21377. WarnMsg interface{} `json:"warn_msg"`
  21378. }
  21379. type ResultSevenAH struct {
  21380. Cainfo string `json:"cainfo"`
  21381. ErrMsg string `json:"err_msg"`
  21382. InfRefmsgid string `json:"inf_refmsgid"`
  21383. Infcode int64 `json:"infcode"`
  21384. Output struct {
  21385. Setlinfo struct {
  21386. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21387. AcctPay float64 `json:"acct_pay"`
  21388. ActPayDedc float64 `json:"act_pay_dedc"`
  21389. Age float64 `json:"age"`
  21390. Balc float64 `json:"balc"`
  21391. Certno string `json:"certno"`
  21392. ClrOptins string `json:"clr_optins"`
  21393. ClrType string `json:"clr_type"`
  21394. ClrWay string `json:"clr_way"`
  21395. CvlservFlag string `json:"cvlserv_flag"`
  21396. CvlservPay float64 `json:"cvlserv_pay"`
  21397. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21398. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21399. Gend string `json:"gend"`
  21400. HifesPay float64 `json:"hifes_pay"`
  21401. HifmiPay float64 `json:"hifmi_pay"`
  21402. HifpPay float64 `json:"hifp_pay"`
  21403. HospPartAmt float64 `json:"hosp_part_amt"`
  21404. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21405. Insutype string `json:"insutype"`
  21406. MafPay float64 `json:"maf_pay"`
  21407. MdtrtCertType string `json:"mdtrt_cert_type"`
  21408. HifobPay float64 `json:"hifob_pay"`
  21409. MdtrtID string `json:"mdtrt_id"`
  21410. MedType string `json:"med_type"`
  21411. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21412. MedinsSetlID string `json:"medins_setl_id"`
  21413. Naty string `json:"naty"`
  21414. OthPay float64 `json:"oth_pay"`
  21415. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21416. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21417. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21418. PsnCashPay float64 `json:"psn_cash_pay"`
  21419. PsnCertType string `json:"psn_cert_type"`
  21420. PsnName string `json:"psn_name"`
  21421. PsnNo string `json:"psn_no"`
  21422. PsnPartAmt float64 `json:"psn_part_amt"`
  21423. PsnType string `json:"psn_type"`
  21424. SetlID string `json:"setl_id"`
  21425. SetlTime int64 `json:"setl_time"`
  21426. } `json:"setlinfo"`
  21427. Setldetail interface{} `json:"setldetail"`
  21428. } `json:"output"`
  21429. RefmsgTime string `json:"refmsg_time"`
  21430. RespondTime string `json:"respond_time"`
  21431. Signtype interface{} `json:"signtype"`
  21432. WarnMsg interface{} `json:"warn_msg"`
  21433. }
  21434. type ResultSeven10265 struct {
  21435. Cainfo string `json:"cainfo"`
  21436. ErrMsg string `json:"err_msg"`
  21437. InfRefmsgid string `json:"inf_refmsgid"`
  21438. Infcode string `json:"infcode"`
  21439. Output struct {
  21440. Setlinfo struct {
  21441. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21442. AcctPay float64 `json:"acct_pay"`
  21443. ActPayDedc float64 `json:"act_pay_dedc"`
  21444. Age float64 `json:"age"`
  21445. Balc float64 `json:"balc"`
  21446. Certno string `json:"certno"`
  21447. ClrOptins string `json:"clr_optins"`
  21448. ClrType string `json:"clr_type"`
  21449. ClrWay string `json:"clr_way"`
  21450. CvlservFlag string `json:"cvlserv_flag"`
  21451. CvlservPay float64 `json:"cvlserv_pay"`
  21452. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21453. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21454. Gend string `json:"gend"`
  21455. HifesPay float64 `json:"hifes_pay"`
  21456. HifmiPay float64 `json:"hifmi_pay"`
  21457. HifpPay float64 `json:"hifp_pay"`
  21458. HospPartAmt float64 `json:"hosp_part_amt"`
  21459. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21460. Insutype string `json:"insutype"`
  21461. MafPay float64 `json:"maf_pay"`
  21462. MdtrtCertType string `json:"mdtrt_cert_type"`
  21463. HifobPay float64 `json:"hifob_pay"`
  21464. MdtrtID string `json:"mdtrt_id"`
  21465. MedType string `json:"med_type"`
  21466. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21467. MedinsSetlID string `json:"medins_setl_id"`
  21468. Naty string `json:"naty"`
  21469. OthPay float64 `json:"oth_pay"`
  21470. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21471. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21472. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21473. PsnCashPay float64 `json:"psn_cash_pay"`
  21474. PsnCertType string `json:"psn_cert_type"`
  21475. PsnName string `json:"psn_name"`
  21476. PsnNo string `json:"psn_no"`
  21477. PsnPartAmt float64 `json:"psn_part_amt"`
  21478. PsnType string `json:"psn_type"`
  21479. SetlID string `json:"setl_id"`
  21480. SetlTime string `json:"setl_time"`
  21481. } `json:"setlinfo"`
  21482. Setldetail interface{} `json:"setldetail"`
  21483. } `json:"output"`
  21484. RefmsgTime string `json:"refmsg_time"`
  21485. RespondTime string `json:"respond_time"`
  21486. Signtype interface{} `json:"signtype"`
  21487. WarnMsg interface{} `json:"warn_msg"`
  21488. }
  21489. type ResultSeven10265Two struct {
  21490. Cainfo string `json:"cainfo"`
  21491. ErrMsg string `json:"err_msg"`
  21492. InfRefmsgid string `json:"inf_refmsgid"`
  21493. Infcode string `json:"infcode"`
  21494. Output struct {
  21495. Setlinfo struct {
  21496. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21497. AcctPay float64 `json:"acct_pay"`
  21498. ActPayDedc float64 `json:"act_pay_dedc"`
  21499. Age float64 `json:"age"`
  21500. Balc float64 `json:"balc"`
  21501. Certno string `json:"certno"`
  21502. ClrOptins string `json:"clr_optins"`
  21503. ClrType string `json:"clr_type"`
  21504. ClrWay string `json:"clr_way"`
  21505. CvlservFlag string `json:"cvlserv_flag"`
  21506. CvlservPay float64 `json:"cvlserv_pay"`
  21507. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21508. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21509. Gend string `json:"gend"`
  21510. HifesPay float64 `json:"hifes_pay"`
  21511. HifmiPay float64 `json:"hifmi_pay"`
  21512. HifpPay float64 `json:"hifp_pay"`
  21513. HospPartAmt string `json:"hosp_part_amt"`
  21514. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21515. Insutype string `json:"insutype"`
  21516. MafPay float64 `json:"maf_pay"`
  21517. MdtrtCertType string `json:"mdtrt_cert_type"`
  21518. HifobPay float64 `json:"hifob_pay"`
  21519. MdtrtID string `json:"mdtrt_id"`
  21520. MedType string `json:"med_type"`
  21521. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21522. MedinsSetlID string `json:"medins_setl_id"`
  21523. Naty string `json:"naty"`
  21524. OthPay float64 `json:"oth_pay"`
  21525. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21526. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21527. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21528. PsnCashPay float64 `json:"psn_cash_pay"`
  21529. PsnCertType string `json:"psn_cert_type"`
  21530. PsnName string `json:"psn_name"`
  21531. PsnNo string `json:"psn_no"`
  21532. PsnPartAmt float64 `json:"psn_part_amt"`
  21533. PsnType string `json:"psn_type"`
  21534. SetlID string `json:"setl_id"`
  21535. SetlTime string `json:"setl_time"`
  21536. } `json:"setlinfo"`
  21537. Setldetail interface{} `json:"setldetail"`
  21538. } `json:"output"`
  21539. RefmsgTime string `json:"refmsg_time"`
  21540. RespondTime string `json:"respond_time"`
  21541. Signtype interface{} `json:"signtype"`
  21542. WarnMsg interface{} `json:"warn_msg"`
  21543. }
  21544. type GZResultSeven10265Two struct {
  21545. Cainfo string `json:"cainfo"`
  21546. ErrMsg string `json:"err_msg"`
  21547. InfRefmsgid string `json:"inf_refmsgid"`
  21548. Infcode int64 `json:"infcode"`
  21549. Output struct {
  21550. Setlinfo struct {
  21551. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21552. AcctPay float64 `json:"acct_pay"`
  21553. ActPayDedc float64 `json:"act_pay_dedc"`
  21554. Age float64 `json:"age"`
  21555. Balc float64 `json:"balc"`
  21556. Certno string `json:"certno"`
  21557. ClrOptins string `json:"clr_optins"`
  21558. ClrType string `json:"clr_type"`
  21559. ClrWay string `json:"clr_way"`
  21560. CvlservFlag string `json:"cvlserv_flag"`
  21561. CvlservPay float64 `json:"cvlserv_pay"`
  21562. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21563. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21564. Gend string `json:"gend"`
  21565. HifesPay float64 `json:"hifes_pay"`
  21566. HifmiPay float64 `json:"hifmi_pay"`
  21567. HifpPay float64 `json:"hifp_pay"`
  21568. HospPartAmt float64 `json:"hosp_part_amt"`
  21569. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21570. Insutype string `json:"insutype"`
  21571. MafPay float64 `json:"maf_pay"`
  21572. MdtrtCertType string `json:"mdtrt_cert_type"`
  21573. HifobPay float64 `json:"hifob_pay"`
  21574. MdtrtID string `json:"mdtrt_id"`
  21575. MedType string `json:"med_type"`
  21576. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21577. MedinsSetlID string `json:"medins_setl_id"`
  21578. Naty string `json:"naty"`
  21579. OthPay float64 `json:"oth_pay"`
  21580. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21581. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21582. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21583. PsnCashPay float64 `json:"psn_cash_pay"`
  21584. PsnCertType string `json:"psn_cert_type"`
  21585. PsnName string `json:"psn_name"`
  21586. PsnNo string `json:"psn_no"`
  21587. PsnPartAmt float64 `json:"psn_part_amt"`
  21588. PsnType string `json:"psn_type"`
  21589. SetlID string `json:"setl_id"`
  21590. SetlTime string `json:"setl_time"`
  21591. } `json:"setlinfo"`
  21592. Setldetail interface{} `json:"setldetail"`
  21593. } `json:"output"`
  21594. RefmsgTime string `json:"refmsg_time"`
  21595. RespondTime string `json:"respond_time"`
  21596. Signtype interface{} `json:"signtype"`
  21597. WarnMsg interface{} `json:"warn_msg"`
  21598. }
  21599. type ResultEight struct {
  21600. Cainfo string `json:"cainfo"`
  21601. ErrMsg string `json:"err_msg"`
  21602. InfRefmsgid string `json:"inf_refmsgid"`
  21603. Infcode int64 `json:"infcode"`
  21604. Output struct {
  21605. Stmtinfo struct {
  21606. SetlOptins string `json:"setl_optins"`
  21607. StmtRslt string `json:"stmt_rslt"`
  21608. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21609. } `json:"stmtinfo"`
  21610. } `json:"output"`
  21611. RefmsgTime string `json:"refmsg_time"`
  21612. RespondTime string `json:"respond_time"`
  21613. Signtype interface{} `json:"signtype"`
  21614. WarnMsg interface{} `json:"warn_msg"`
  21615. }
  21616. type ResultEightFor10188 struct {
  21617. Cainfo string `json:"cainfo"`
  21618. ErrMsg string `json:"err_msg"`
  21619. InfRefmsgid string `json:"inf_refmsgid"`
  21620. Infcode string `json:"infcode"`
  21621. Output struct {
  21622. Stmtinfo struct {
  21623. SetlOptins string `json:"setl_optins"`
  21624. StmtRslt string `json:"stmt_rslt"`
  21625. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  21626. } `json:"stmtinfo"`
  21627. } `json:"output"`
  21628. RefmsgTime string `json:"refmsg_time"`
  21629. RespondTime string `json:"respond_time"`
  21630. Signtype interface{} `json:"signtype"`
  21631. WarnMsg interface{} `json:"warn_msg"`
  21632. }
  21633. type ResultNine struct {
  21634. Cainfo string `json:"cainfo"`
  21635. ErrMsg string `json:"err_msg"`
  21636. InfRefmsgid string `json:"inf_refmsgid"`
  21637. Infcode int64 `json:"infcode"`
  21638. Output struct {
  21639. FileQuryNo string `json:"file_qury_no"`
  21640. } `json:"output"`
  21641. RefmsgTime string `json:"refmsg_time"`
  21642. RespondTime string `json:"respond_time"`
  21643. Signtype interface{} `json:"signtype"`
  21644. WarnMsg interface{} `json:"warn_msg"`
  21645. }
  21646. type ResultTen struct {
  21647. Cainfo string `json:"cainfo"`
  21648. ErrMsg string `json:"err_msg"`
  21649. InfRefmsgid string `json:"inf_refmsgid"`
  21650. Infcode int64 `json:"infcode"`
  21651. Output struct {
  21652. Fileinfo struct {
  21653. DldEndtime string `json:"dld_endtime"`
  21654. FileQuryNo string `json:"file_qury_no"`
  21655. Filename string `json:"filename"`
  21656. } `json:"fileinfo"`
  21657. } `json:"output"`
  21658. RefmsgTime string `json:"refmsg_time"`
  21659. RespondTime string `json:"respond_time"`
  21660. Signtype interface{} `json:"signtype"`
  21661. WarnMsg interface{} `json:"warn_msg"`
  21662. }
  21663. type Result5262 struct {
  21664. ErrMsg string `json:"err_msg"`
  21665. InfRefmsgid string `json:"inf_refmsgid"`
  21666. Infcode int64 `json:"infcode"`
  21667. Output struct {
  21668. PageInfo struct {
  21669. Size int `json:"size"`
  21670. RecordCounts int `json:"record_counts"`
  21671. } `json:"page_info"`
  21672. Idetinfo []interface{} `json:"idetinfo"`
  21673. Result []struct {
  21674. SetlID string `json:"setl_id"`
  21675. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  21676. MdtrtID string `json:"mdtrt_id"`
  21677. InitSetlID string `json:"init_setl_id,omitempty"`
  21678. PsnNo string `json:"psn_no"`
  21679. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  21680. PsnName string `json:"psn_name"`
  21681. PsnCertType string `json:"psn_cert_type"`
  21682. Certno string `json:"certno"`
  21683. Gend string `json:"gend,omitempty"`
  21684. Naty string `json:"naty,omitempty"`
  21685. Brdy string `json:"brdy,omitempty"`
  21686. Age float64 `json:"age,omitempty"`
  21687. Insutype string `json:"insutype,omitempty"`
  21688. PsnType string `json:"psn_type"`
  21689. CvlservFlag string `json:"cvlserv_flag"`
  21690. CvlservLv string `json:"cvlserv_lv,omitempty"`
  21691. SpPsnType string `json:"sp_psn_type,omitempty"`
  21692. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  21693. ClctGrde string `json:"clct_grde,omitempty"`
  21694. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  21695. NwbFlag string `json:"nwb_flag,omitempty"`
  21696. InsuAdmdvs string `json:"insu_admdvs"`
  21697. EmpNo string `json:"emp_no,omitempty"`
  21698. EmpName string `json:"emp_name,omitempty"`
  21699. EmpType string `json:"emp_type,omitempty"`
  21700. EconType string `json:"econ_type,omitempty"`
  21701. AfilIndu string `json:"afil_indu,omitempty"`
  21702. AfilRlts string `json:"afil_rlts,omitempty"`
  21703. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  21704. PayLoc string `json:"pay_loc,omitempty"`
  21705. FixmedinsCode string `json:"fixmedins_code"`
  21706. FixmedinsName string `json:"fixmedins_name"`
  21707. HospLv string `json:"hosp_lv,omitempty"`
  21708. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  21709. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  21710. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  21711. Begndate string `json:"begndate"`
  21712. Enddate string `json:"enddate"`
  21713. SetlTime string `json:"setl_time"`
  21714. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  21715. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  21716. MedType string `json:"med_type"`
  21717. SetlType string `json:"setl_type,omitempty"`
  21718. ClrType string `json:"clr_type,omitempty"`
  21719. ClrWay string `json:"clr_way,omitempty"`
  21720. PsnSetlway string `json:"psn_setlway,omitempty"`
  21721. ClrOptins string `json:"clr_optins,omitempty"`
  21722. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  21723. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  21724. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  21725. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  21726. InscpAmt float64 `json:"inscp_amt,omitempty"`
  21727. DedcStd float64 `json:"dedc_std,omitempty"`
  21728. CrtDedc float64 `json:"crt_dedc,omitempty"`
  21729. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  21730. HifpPay float64 `json:"hifp_pay,omitempty"`
  21731. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  21732. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  21733. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  21734. HifesPay float64 `json:"hifes_pay,omitempty"`
  21735. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  21736. HifobPay float64 `json:"hifob_pay,omitempty"`
  21737. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  21738. MafPay float64 `json:"maf_pay,omitempty"`
  21739. OthfundPay float64 `json:"othfund_pay,omitempty"`
  21740. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  21741. PsnPay float64 `json:"psn_pay,omitempty"`
  21742. AcctPay float64 `json:"acct_pay,omitempty"`
  21743. CashPayamt float64 `json:"cash_payamt,omitempty"`
  21744. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  21745. Balc float64 `json:"balc,omitempty"`
  21746. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  21747. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  21748. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  21749. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  21750. Year string `json:"year,omitempty"`
  21751. DiseNo string `json:"dise_no,omitempty"`
  21752. DiseName string `json:"dise_name,omitempty"`
  21753. Invono string `json:"invono,omitempty"`
  21754. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  21755. ValiFlag string `json:"vali_flag,omitempty"`
  21756. Memo string `json:"memo,omitempty"`
  21757. Rid string `json:"rid"`
  21758. UpdtTime string `json:"updt_time,omitempty"`
  21759. CrterID string `json:"crter_id,omitempty"`
  21760. CrterName string `json:"crter_name,omitempty"`
  21761. CrteTime string `json:"crte_time,omitempty"`
  21762. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  21763. OpterID string `json:"opter_id,omitempty"`
  21764. OpterName string `json:"opter_name,omitempty"`
  21765. OptTime string `json:"opt_time,omitempty"`
  21766. OptinsNo string `json:"optins_no,omitempty"`
  21767. PoolareaNo string `json:"poolarea_no,omitempty"`
  21768. } `json:"result"`
  21769. } `json:"output"`
  21770. RefmsgTime string `json:"refmsg_time"`
  21771. RespondTime string `json:"respond_time"`
  21772. Signtype interface{} `json:"signtype"`
  21773. WarnInfo interface{} `json:"warn_info"`
  21774. }
  21775. type Result5267 struct {
  21776. ErrMsg string `json:"err_msg"`
  21777. InfRefmsgid string `json:"inf_refmsgid"`
  21778. Infcode int64 `json:"infcode"`
  21779. Output struct {
  21780. PageInfo struct {
  21781. Size int `json:"size"`
  21782. RecordCounts int `json:"record_counts"`
  21783. } `json:"pageinfo"`
  21784. Result []struct {
  21785. SetlID string `json:"setl_id"`
  21786. ClrOptins string `json:"clr_optins"`
  21787. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  21788. MdtrtID string `json:"mdtrt_id"`
  21789. InitSetlID string `json:"init_setl_id,omitempty"`
  21790. PsnNo string `json:"psn_no"`
  21791. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  21792. PsnName string `json:"psn_name"`
  21793. PsnCertType string `json:"psn_cert_type"`
  21794. Certno string `json:"certno"`
  21795. Gend string `json:"gend,omitempty"`
  21796. Naty string `json:"naty,omitempty"`
  21797. Brdy string `json:"brdy,omitempty"`
  21798. Age float64 `json:"age,omitempty"`
  21799. Insutype string `json:"insutype,omitempty"`
  21800. PsnType string `json:"psn_type"`
  21801. CvlservFlag string `json:"cvlserv_flag"`
  21802. CvlservLv string `json:"cvlserv_lv,omitempty"`
  21803. SpPsnType string `json:"sp_psn_type,omitempty"`
  21804. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  21805. ClctGrde string `json:"clct_grde,omitempty"`
  21806. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  21807. NwbFlag string `json:"nwb_flag,omitempty"`
  21808. InsuAdmdvs string `json:"insu_admdvs"`
  21809. EmpNo string `json:"emp_no,omitempty"`
  21810. EmpName string `json:"emp_name,omitempty"`
  21811. EmpType string `json:"emp_type,omitempty"`
  21812. EconType string `json:"econ_type,omitempty"`
  21813. AfilIndu string `json:"afil_indu,omitempty"`
  21814. AfilRlts string `json:"afil_rlts,omitempty"`
  21815. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  21816. PayLoc string `json:"pay_loc,omitempty"`
  21817. FixmedinsCode string `json:"fixmedins_code"`
  21818. FixmedinsName string `json:"fixmedins_name"`
  21819. HospLv string `json:"hosp_lv,omitempty"`
  21820. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  21821. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  21822. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  21823. Begndate string `json:"begndate,omitempty"`
  21824. Enddate string `json:"enddate,omitempty"`
  21825. SetlTime string `json:"setl_time,omitempty"`
  21826. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  21827. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  21828. MedType string `json:"med_type"`
  21829. SetlType string `json:"setl_type,omitempty"`
  21830. ClrType string `json:"clr_type,omitempty"`
  21831. ClrWay string `json:"clr_way,omitempty"`
  21832. PsnSetlway string `json:"psn_setlway,omitempty"`
  21833. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  21834. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  21835. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  21836. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  21837. InscpAmt float64 `json:"inscp_amt,omitempty"`
  21838. DedcStd float64 `json:"dedc_std,omitempty"`
  21839. CrtDedc float64 `json:"crt_dedc,omitempty"`
  21840. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  21841. HifpPay float64 `json:"hifp_pay,omitempty"`
  21842. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  21843. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  21844. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  21845. HifesPay float64 `json:"hifes_pay,omitempty"`
  21846. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  21847. HifobPay float64 `json:"hifob_pay,omitempty"`
  21848. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  21849. MafPay float64 `json:"maf_pay,omitempty"`
  21850. OthfundPay float64 `json:"othfund_pay,omitempty"`
  21851. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  21852. PsnPay float64 `json:"psn_pay,omitempty"`
  21853. AcctPay float64 `json:"acct_pay,omitempty"`
  21854. CashPayamt float64 `json:"cash_payamt,omitempty"`
  21855. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  21856. Balc float64 `json:"balc,omitempty"`
  21857. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  21858. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  21859. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  21860. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  21861. Year string `json:"year,omitempty"`
  21862. DiseNo string `json:"dise_no,omitempty"`
  21863. DiseName string `json:"dise_name,omitempty"`
  21864. Invono string `json:"invono,omitempty"`
  21865. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  21866. Memo string `json:"memo,omitempty"`
  21867. UpdtTime string `json:"updt_time,omitempty"`
  21868. OpterID string `json:"opter_id,omitempty"`
  21869. OpterName string `json:"opter_name,omitempty"`
  21870. OptTime string `json:"opt_time,omitempty"`
  21871. OptinsNo string `json:"optins_no,omitempty"`
  21872. PoolareaNo string `json:"poolarea_no,omitempty"`
  21873. } `json:"result"`
  21874. } `json:"output"`
  21875. RefmsgTime string `json:"refmsg_time"`
  21876. RespondTime string `json:"respond_time"`
  21877. Signtype interface{} `json:"signtype"`
  21878. WarnInfo interface{} `json:"warn_info"`
  21879. }
  21880. // type Autogenerated struct {
  21881. // Output struct {
  21882. // Setlinfo struct {
  21883. // SetlTime string `json:"setl_time"`
  21884. // CvlservPay float64 `json:"cvlserv_pay"`
  21885. // Year string `json:"year"`
  21886. // MedType string `json:"med_type"`
  21887. // PsnPay float64 `json:"psn_pay"`
  21888. // OpterID string `json:"opter_id"`
  21889. // Begndate string `json:"begndate"`
  21890. // FlxempeFlag string `json:"flxempe_flag"`
  21891. // HifmiPay float64 `json:"hifmi_pay"`
  21892. // PsnNo string `json:"psn_no"`
  21893. // ActPayDedc float64 `json:"act_pay_dedc"`
  21894. // MedinsSetlID interface{} `json:"medins_setl_id"`
  21895. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  21896. // ClrWay string `json:"clr_way"`
  21897. // OthPay float64 `json:"oth_pay"`
  21898. // Gend string `json:"gend"`
  21899. // MdtrtID string `json:"mdtrt_id"`
  21900. // AcctPay float64 `json:"acct_pay"`
  21901. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  21902. // Insutype string `json:"insutype"`
  21903. // Invono interface{} `json:"invono"`
  21904. // Enddate string `json:"enddate"`
  21905. // CashPayamt float64 `json:"cash_payamt"`
  21906. // PsnType string `json:"psn_type"`
  21907. // FixmedinsName string `json:"fixmedins_name"`
  21908. // HifpPay float64 `json:"hifp_pay"`
  21909. // NewFlag interface{} `json:"new_flag"`
  21910. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21911. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  21912. // PayLoc string `json:"pay_loc"`
  21913. // ClrType string `json:"clr_type"`
  21914. // RefdSetlFlag string `json:"refd_setl_flag"`
  21915. // CvlservFlag string `json:"cvlserv_flag"`
  21916. // EmpName string `json:"emp_name"`
  21917. // Brdy string `json:"brdy"`
  21918. // Naty string `json:"naty"`
  21919. // Certno string `json:"certno"`
  21920. // DiseCode string `json:"dise_code"`
  21921. // FixmedinsCode string `json:"fixmedins_code"`
  21922. // DedcHospLv string `json:"dedc_hosp_lv"`
  21923. // OpterName string `json:"opter_name"`
  21924. // Balc float64 `json:"balc"`
  21925. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  21926. // PsnCertType string `json:"psn_cert_type"`
  21927. // HifobPay float64 `json:"hifob_pay"`
  21928. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  21929. // HifesPay float64 `json:"hifes_pay"`
  21930. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21931. // OptTime string `json:"opt_time"`
  21932. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21933. // SetlID string `json:"setl_id"`
  21934. // MafPay float64 `json:"maf_pay"`
  21935. // PsnName string `json:"psn_name"`
  21936. // InsuOptins interface{} `json:"insu_optins"`
  21937. // PrefFundPay interface{} `json:"pref_fund_pay"`
  21938. // ClrOptins string `json:"clr_optins"`
  21939. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21940. // DiseName string `json:"dise_name"`
  21941. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  21942. // Age float64 `json:"age"`
  21943. // DtrtCertType string `json:"dtrt_cert_type"`
  21944. // HospLv string `json:"hosp_lv"`
  21945. // } `json:"setlinfo"`
  21946. // Setldetail []struct {
  21947. // FundPayType string `json:"fund_pay_type"`
  21948. // FundPayamt float64 `json:"fund_payamt"`
  21949. // SetlProcInfo interface{} `json:"setl_proc_info"`
  21950. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  21951. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  21952. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  21953. // PrefFundPay interface{} `json:"pref_fund_pay"`
  21954. // } `json:"setldetail"`
  21955. // } `json:"output"`
  21956. // Infcode int `json:"infcode"`
  21957. // WarnMsg interface{} `json:"warn_msg"`
  21958. // Cainfo interface{} `json:"cainfo"`
  21959. // ErrMsg interface{} `json:"err_msg"`
  21960. // RefmsgTime string `json:"refmsg_time"`
  21961. // Signtype interface{} `json:"signtype"`
  21962. // RespondTime string `json:"respond_time"`
  21963. // InfRefmsgid string `json:"inf_refmsgid"`
  21964. // }
  21965. type Result002 struct {
  21966. Cainfo interface{} `json:"cainfo"`
  21967. ErrMsg string `json:"err_msg"`
  21968. InfRefmsgid string `json:"inf_refmsgid"`
  21969. Infcode int64 `json:"infcode"`
  21970. Output struct {
  21971. RxFile string `json:"rx_file"`
  21972. SignDigest string `json:"sign_digest"`
  21973. SignCertSn string `json:"sign_cert_sn"`
  21974. SignCertDn string `json:"sign_cert_dn"`
  21975. } `json:"output"`
  21976. RefmsgTime string `json:"refmsg_time"`
  21977. RespondTime string `json:"respond_time"`
  21978. Signtype interface{} `json:"signtype"`
  21979. WarnMsg interface{} `json:"warn_msg"`
  21980. }
  21981. type Result003 struct {
  21982. Cainfo interface{} `json:"cainfo"`
  21983. ErrMsg string `json:"err_msg"`
  21984. InfRefmsgid string `json:"inf_refmsgid"`
  21985. Infcode int64 `json:"infcode"`
  21986. Output struct {
  21987. HiRxno string `json:"hi_rxno"`
  21988. RxStasCodg string `json:"rx_stas_codg"`
  21989. RxStasName string `json:"rx_stas_name"`
  21990. } `json:"output"`
  21991. RefmsgTime string `json:"refmsg_time"`
  21992. RespondTime string `json:"respond_time"`
  21993. Signtype interface{} `json:"signtype"`
  21994. WarnMsg interface{} `json:"warn_msg"`
  21995. }
  21996. type ResultEleven struct {
  21997. Cainfo string `json:"cainfo"`
  21998. ErrMsg string `json:"err_msg"`
  21999. InfRefmsgid string `json:"inf_refmsgid"`
  22000. Infcode int64 `json:"infcode"`
  22001. Output struct {
  22002. Setlinfo struct {
  22003. SetlTime string `json:"setl_time"`
  22004. CvlservPay float64 `json:"cvlserv_pay"`
  22005. Year string `json:"year"`
  22006. MedType string `json:"med_type"`
  22007. PsnPay float64 `json:"psn_pay"`
  22008. OpterID string `json:"opter_id"`
  22009. Begndate string `json:"begndate"`
  22010. FlxempeFlag string `json:"flxempe_flag"`
  22011. HifmiPay float64 `json:"hifmi_pay"`
  22012. PsnNo string `json:"psn_no"`
  22013. ActPayDedc float64 `json:"act_pay_dedc"`
  22014. MedinsSetlID interface{} `json:"medins_setl_id"`
  22015. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22016. ClrWay string `json:"clr_way"`
  22017. OthPay float64 `json:"oth_pay"`
  22018. Gend string `json:"gend"`
  22019. MdtrtID string `json:"mdtrt_id"`
  22020. AcctPay float64 `json:"acct_pay"`
  22021. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22022. Insutype string `json:"insutype"`
  22023. Invono interface{} `json:"invono"`
  22024. Enddate string `json:"enddate"`
  22025. CashPayamt float64 `json:"cash_payamt"`
  22026. PsnType string `json:"psn_type"`
  22027. FixmedinsName string `json:"fixmedins_name"`
  22028. HifpPay float64 `json:"hifp_pay"`
  22029. NewFlag interface{} `json:"new_flag"`
  22030. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22031. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22032. PayLoc string `json:"pay_loc"`
  22033. ClrType string `json:"clr_type"`
  22034. RefdSetlFlag string `json:"refd_setl_flag"`
  22035. CvlservFlag string `json:"cvlserv_flag"`
  22036. EmpName string `json:"emp_name"`
  22037. Brdy string `json:"brdy"`
  22038. Naty string `json:"naty"`
  22039. Certno string `json:"certno"`
  22040. DiseCode string `json:"dise_code"`
  22041. FixmedinsCode string `json:"fixmedins_code"`
  22042. DedcHospLv string `json:"dedc_hosp_lv"`
  22043. OpterName string `json:"opter_name"`
  22044. Balc float64 `json:"balc"`
  22045. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22046. PsnCertType string `json:"psn_cert_type"`
  22047. HifobPay float64 `json:"hifob_pay"`
  22048. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22049. HifesPay float64 `json:"hifes_pay"`
  22050. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22051. OptTime string `json:"opt_time"`
  22052. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22053. SetlID string `json:"setl_id"`
  22054. MafPay float64 `json:"maf_pay"`
  22055. PsnName string `json:"psn_name"`
  22056. InsuOptins interface{} `json:"insu_optins"`
  22057. PrefFundPay interface{} `json:"pref_fund_pay"`
  22058. ClrOptins string `json:"clr_optins"`
  22059. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22060. DiseName string `json:"dise_name"`
  22061. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22062. Age float64 `json:"age"`
  22063. DtrtCertType string `json:"dtrt_cert_type"`
  22064. HospLv string `json:"hosp_lv"`
  22065. PsnCashPay float64 `json:"psn_cash_pay"`
  22066. } `json:"setlinfo"`
  22067. } `json:"output"`
  22068. RefmsgTime string `json:"refmsg_time"`
  22069. RespondTime string `json:"respond_time"`
  22070. Signtype interface{} `json:"signtype"`
  22071. WarnMsg interface{} `json:"warn_msg"`
  22072. }
  22073. type ResultElevenah struct {
  22074. Cainfo string `json:"cainfo"`
  22075. ErrMsg string `json:"err_msg"`
  22076. InfRefmsgid string `json:"inf_refmsgid"`
  22077. Infcode int64 `json:"infcode"`
  22078. Output struct {
  22079. Setlinfo struct {
  22080. SetlTime int64 `json:"setl_time"`
  22081. CvlservPay float64 `json:"cvlserv_pay"`
  22082. Year string `json:"year"`
  22083. MedType string `json:"med_type"`
  22084. PsnPay float64 `json:"psn_pay"`
  22085. OpterID string `json:"opter_id"`
  22086. Begndate int64 `json:"begndate"`
  22087. FlxempeFlag string `json:"flxempe_flag"`
  22088. HifmiPay float64 `json:"hifmi_pay"`
  22089. PsnNo string `json:"psn_no"`
  22090. ActPayDedc float64 `json:"act_pay_dedc"`
  22091. MedinsSetlID interface{} `json:"medins_setl_id"`
  22092. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22093. ClrWay string `json:"clr_way"`
  22094. OthPay float64 `json:"oth_pay"`
  22095. Gend string `json:"gend"`
  22096. MdtrtID string `json:"mdtrt_id"`
  22097. AcctPay float64 `json:"acct_pay"`
  22098. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22099. Insutype string `json:"insutype"`
  22100. Invono interface{} `json:"invono"`
  22101. Enddate int64 `json:"enddate"`
  22102. CashPayamt float64 `json:"cash_payamt"`
  22103. PsnType string `json:"psn_type"`
  22104. FixmedinsName string `json:"fixmedins_name"`
  22105. HifpPay float64 `json:"hifp_pay"`
  22106. NewFlag interface{} `json:"new_flag"`
  22107. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22108. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22109. PayLoc string `json:"pay_loc"`
  22110. ClrType string `json:"clr_type"`
  22111. RefdSetlFlag string `json:"refd_setl_flag"`
  22112. CvlservFlag string `json:"cvlserv_flag"`
  22113. EmpName string `json:"emp_name"`
  22114. Brdy int64 `json:"brdy"`
  22115. Naty string `json:"naty"`
  22116. Certno string `json:"certno"`
  22117. DiseCode string `json:"dise_code"`
  22118. FixmedinsCode string `json:"fixmedins_code"`
  22119. DedcHospLv string `json:"dedc_hosp_lv"`
  22120. OpterName string `json:"opter_name"`
  22121. Balc float64 `json:"balc"`
  22122. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22123. PsnCertType string `json:"psn_cert_type"`
  22124. HifobPay float64 `json:"hifob_pay"`
  22125. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22126. HifesPay float64 `json:"hifes_pay"`
  22127. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22128. OptTime int64 `json:"opt_time"`
  22129. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22130. SetlID string `json:"setl_id"`
  22131. MafPay float64 `json:"maf_pay"`
  22132. PsnName string `json:"psn_name"`
  22133. InsuOptins interface{} `json:"insu_optins"`
  22134. PrefFundPay interface{} `json:"pref_fund_pay"`
  22135. ClrOptins string `json:"clr_optins"`
  22136. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22137. DiseName string `json:"dise_name"`
  22138. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22139. Age float64 `json:"age"`
  22140. DtrtCertType string `json:"dtrt_cert_type"`
  22141. HospLv string `json:"hosp_lv"`
  22142. PsnCashPay float64 `json:"psn_cash_pay"`
  22143. } `json:"setlinfo"`
  22144. } `json:"output"`
  22145. RefmsgTime string `json:"refmsg_time"`
  22146. RespondTime string `json:"respond_time"`
  22147. Signtype interface{} `json:"signtype"`
  22148. WarnMsg interface{} `json:"warn_msg"`
  22149. }
  22150. type ResultEleven10265 struct {
  22151. Cainfo string `json:"cainfo"`
  22152. ErrMsg string `json:"err_msg"`
  22153. InfRefmsgid string `json:"inf_refmsgid"`
  22154. Infcode string `json:"infcode"`
  22155. Output struct {
  22156. Setlinfo struct {
  22157. SetlTime string `json:"setl_time"`
  22158. CvlservPay float64 `json:"cvlserv_pay"`
  22159. Year string `json:"year"`
  22160. MedType string `json:"med_type"`
  22161. PsnPay float64 `json:"psn_pay"`
  22162. OpterID string `json:"opter_id"`
  22163. Begndate string `json:"begndate"`
  22164. FlxempeFlag string `json:"flxempe_flag"`
  22165. HifmiPay float64 `json:"hifmi_pay"`
  22166. PsnNo string `json:"psn_no"`
  22167. ActPayDedc float64 `json:"act_pay_dedc"`
  22168. MedinsSetlID interface{} `json:"medins_setl_id"`
  22169. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22170. ClrWay string `json:"clr_way"`
  22171. OthPay float64 `json:"oth_pay"`
  22172. Gend string `json:"gend"`
  22173. MdtrtID string `json:"mdtrt_id"`
  22174. AcctPay float64 `json:"acct_pay"`
  22175. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22176. Insutype string `json:"insutype"`
  22177. Invono interface{} `json:"invono"`
  22178. Enddate string `json:"enddate"`
  22179. CashPayamt float64 `json:"cash_payamt"`
  22180. PsnType string `json:"psn_type"`
  22181. FixmedinsName string `json:"fixmedins_name"`
  22182. HifpPay float64 `json:"hifp_pay"`
  22183. NewFlag interface{} `json:"new_flag"`
  22184. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22185. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22186. PayLoc string `json:"pay_loc"`
  22187. ClrType string `json:"clr_type"`
  22188. RefdSetlFlag string `json:"refd_setl_flag"`
  22189. CvlservFlag string `json:"cvlserv_flag"`
  22190. EmpName string `json:"emp_name"`
  22191. Brdy string `json:"brdy"`
  22192. Naty string `json:"naty"`
  22193. Certno string `json:"certno"`
  22194. DiseCode string `json:"dise_code"`
  22195. FixmedinsCode string `json:"fixmedins_code"`
  22196. DedcHospLv string `json:"dedc_hosp_lv"`
  22197. OpterName string `json:"opter_name"`
  22198. Balc float64 `json:"balc"`
  22199. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22200. PsnCertType string `json:"psn_cert_type"`
  22201. HifobPay float64 `json:"hifob_pay"`
  22202. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22203. HifesPay float64 `json:"hifes_pay"`
  22204. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22205. OptTime string `json:"opt_time"`
  22206. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22207. SetlID string `json:"setl_id"`
  22208. MafPay float64 `json:"maf_pay"`
  22209. PsnName string `json:"psn_name"`
  22210. InsuOptins interface{} `json:"insu_optins"`
  22211. PrefFundPay interface{} `json:"pref_fund_pay"`
  22212. ClrOptins string `json:"clr_optins"`
  22213. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22214. DiseName string `json:"dise_name"`
  22215. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22216. Age float64 `json:"age"`
  22217. DtrtCertType string `json:"dtrt_cert_type"`
  22218. HospLv string `json:"hosp_lv"`
  22219. PsnCashPay float64 `json:"psn_cash_pay"`
  22220. } `json:"setlinfo"`
  22221. } `json:"output"`
  22222. RefmsgTime string `json:"refmsg_time"`
  22223. RespondTime string `json:"respond_time"`
  22224. Signtype interface{} `json:"signtype"`
  22225. WarnMsg interface{} `json:"warn_msg"`
  22226. }
  22227. type ResultTwelve struct {
  22228. Cainfo string `json:"cainfo"`
  22229. ErrMsg string `json:"err_msg"`
  22230. InfRefmsgid string `json:"inf_refmsgid"`
  22231. Infcode int64 `json:"infcode"`
  22232. Output struct {
  22233. MdtrtId string `json:"mdtrt_id"`
  22234. ChrgBchno string `json:"chrg_bchno"`
  22235. PsnNo string `json:"psn_no"`
  22236. } `json:"output"`
  22237. RefmsgTime string `json:"refmsg_time"`
  22238. RespondTime string `json:"respond_time"`
  22239. Signtype interface{} `json:"signtype"`
  22240. WarnMsg interface{} `json:"warn_msg"`
  22241. }
  22242. type ResultThirteen struct {
  22243. ErrMsg string `json:"err_msg"`
  22244. InfRefmsgid string `json:"inf_refmsgid"`
  22245. Infcode int64 `json:"infcode"`
  22246. Output struct {
  22247. Result struct {
  22248. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22249. } `json:"result"`
  22250. } `json:"output"`
  22251. RefmsgTime string `json:"refmsg_time"`
  22252. RespondTime string `json:"respond_time"`
  22253. Signtype interface{} `json:"signtype"`
  22254. WarnInfo interface{} `json:"warn_info"`
  22255. }
  22256. type ResultThirteen10265 struct {
  22257. ErrMsg string `json:"err_msg"`
  22258. InfRefmsgid string `json:"inf_refmsgid"`
  22259. Infcode string `json:"infcode"`
  22260. Output struct {
  22261. Result struct {
  22262. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22263. } `json:"result"`
  22264. } `json:"output"`
  22265. RefmsgTime string `json:"refmsg_time"`
  22266. RespondTime string `json:"respond_time"`
  22267. Signtype interface{} `json:"signtype"`
  22268. WarnInfo interface{} `json:"warn_info"`
  22269. }
  22270. type ResultFourteen struct {
  22271. ErrMsg string `json:"err_msg"`
  22272. InfRefmsgid string `json:"inf_refmsgid"`
  22273. Infcode int64 `json:"infcode"`
  22274. Output struct {
  22275. } `json:"output"`
  22276. RefmsgTime string `json:"refmsg_time"`
  22277. RespondTime string `json:"respond_time"`
  22278. Signtype interface{} `json:"signtype"`
  22279. WarnInfo interface{} `json:"warn_info"`
  22280. }
  22281. type ResultCFYLJG001 struct {
  22282. ErrMsg string `json:"err_msg"`
  22283. InfRefmsgid string `json:"inf_refmsgid"`
  22284. Infcode int64 `json:"infcode"`
  22285. Output struct {
  22286. RxTraceCode string `json:"rx_trace_code"`
  22287. HiRxno string `json:"hi_rxno"`
  22288. } `json:"output"`
  22289. RefmsgTime string `json:"refmsg_time"`
  22290. RespondTime string `json:"respond_time"`
  22291. Signtype interface{} `json:"signtype"`
  22292. WarnInfo interface{} `json:"warn_info"`
  22293. }
  22294. type ResultCFYLJG007 struct {
  22295. ErrMsg string `json:"err_msg"`
  22296. InfRefmsgid string `json:"inf_refmsgid"`
  22297. Infcode int64 `json:"infcode"`
  22298. Output struct {
  22299. HiRxno string `json:"hi_rxno"`
  22300. RxStasName string `json:"rx_stas_name"`
  22301. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22302. Seltdelts []interface{} `json:"seltdelts"`
  22303. RxUsedStasName string `json:"rx_used_stas_name"`
  22304. RxStasCodg string `json:"rx_stas_codg"`
  22305. } `json:"output"`
  22306. RefmsgTime string `json:"refmsg_time"`
  22307. RespondTime string `json:"respond_time"`
  22308. Signtype interface{} `json:"signtype"`
  22309. WarnInfo interface{} `json:"warn_info"`
  22310. }
  22311. type ResultCFYLJG002 struct {
  22312. ErrMsg string `json:"err_msg"`
  22313. InfRefmsgid string `json:"inf_refmsgid"`
  22314. Infcode int64 `json:"infcode"`
  22315. Output struct {
  22316. RxFile string `json:"rx_file"`
  22317. SignDigest string `json:"sign_digest"`
  22318. SignCertSn string `json:"sign_cert_sn"`
  22319. SignCertDn string `json:"sign_cert_dn"`
  22320. } `json:"output"`
  22321. RefmsgTime string `json:"refmsg_time"`
  22322. RespondTime string `json:"respond_time"`
  22323. Signtype interface{} `json:"signtype"`
  22324. WarnInfo interface{} `json:"warn_info"`
  22325. }
  22326. type ResultCFYLJG003 struct {
  22327. ErrMsg string `json:"err_msg"`
  22328. InfRefmsgid string `json:"inf_refmsgid"`
  22329. Infcode int64 `json:"infcode"`
  22330. Output struct {
  22331. HiRxno string `json:"hi_rxno"`
  22332. RxStasCodg string `json:"rx_stas_codg"`
  22333. RxStasName string `json:"rx_stas_name"`
  22334. } `json:"output"`
  22335. RefmsgTime string `json:"refmsg_time"`
  22336. RespondTime string `json:"respond_time"`
  22337. Signtype interface{} `json:"signtype"`
  22338. WarnInfo interface{} `json:"warn_info"`
  22339. }
  22340. type ResultCFYLJG004 struct {
  22341. ErrMsg string `json:"err_msg"`
  22342. InfRefmsgid string `json:"inf_refmsgid"`
  22343. Infcode int64 `json:"infcode"`
  22344. Output struct {
  22345. HiRxno string `json:"hi_rxno"`
  22346. RxStasCodg string `json:"rx_stas_codg"`
  22347. RxStasName string `json:"rx_stas_name"`
  22348. } `json:"output"`
  22349. RefmsgTime string `json:"refmsg_time"`
  22350. RespondTime string `json:"respond_time"`
  22351. Signtype interface{} `json:"signtype"`
  22352. WarnInfo interface{} `json:"warn_info"`
  22353. }
  22354. type ResultCFYLJG008 struct {
  22355. ErrMsg string `json:"err_msg"`
  22356. InfRefmsgid string `json:"inf_refmsgid"`
  22357. Infcode int64 `json:"infcode"`
  22358. Output struct {
  22359. PoolareaNo string `json:"poolareaNo"`
  22360. AdmdvsName string `json:"admdvsName"`
  22361. Count string `json:"count"`
  22362. } `json:"output"`
  22363. RefmsgTime string `json:"refmsg_time"`
  22364. RespondTime string `json:"respond_time"`
  22365. Signtype interface{} `json:"signtype"`
  22366. WarnInfo interface{} `json:"warn_info"`
  22367. }
  22368. type ResultCFYLJG005 struct {
  22369. ErrMsg string `json:"err_msg"`
  22370. InfRefmsgid string `json:"inf_refmsgid"`
  22371. Infcode int64 `json:"infcode"`
  22372. Output struct {
  22373. HiRxNo string `json:"hi_rxno"`
  22374. FixMedinsCode string `json:"fixmedins_code"`
  22375. FixMedinsName string `json:"fixmedins_name"`
  22376. RxStasCodg string `json:"rx_stas_codg"`
  22377. RxStasName string `json:"rx_stas_name"`
  22378. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22379. RxUserdStasName string `json:"rx_userd_stas_name"`
  22380. PrscTime string `json:"prsc_time"`
  22381. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22382. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22383. RxUsedWayName string `json:"rx_used_way_name"`
  22384. RxFrquCodg string `json:"rx_frqu_codg"`
  22385. RxFrquName string `json:"rx_frqu_name"`
  22386. RxDosunt string `json:"rx_dosunt"`
  22387. RxDoscnt float64 `json:"rx_doscnt"`
  22388. RxDrordDscr string `json:"rx_drord_dscr"`
  22389. ValiDays int64 `json:"vali_days"`
  22390. ValiEndTime string `json:"vali_end_time"`
  22391. ReptFlag string `json:"rept_flag"`
  22392. MaxReptCnt int64 `json:"max_rept_cnt"`
  22393. ReptdCnt int64 `json:"reptd_cnt"`
  22394. MinInrvDays int64 `json:"min_inrv_days"`
  22395. RxTypeCode string `json:"rx_type_code"`
  22396. RxTypeName string `json:"rx_type_name"`
  22397. LongRxFlag string `json:"long_rx_flag"`
  22398. RxDetlList []struct {
  22399. MedListCodg string `json:"med_list_codg"`
  22400. MedinsListCodg string `json:"medins_list_codg"`
  22401. HospPrepFlag string `json:"hosp_prep_flag"`
  22402. RxItemTypeCode string `json:"rx_item_type_code"`
  22403. RxItemTypeName string `json:"rx_item_type_name"`
  22404. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22405. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22406. TcmHerbFoote string `json:"tcmherb_foote"`
  22407. MednTypeCode string `json:"medn_type_code"`
  22408. MednTypeName string `json:"medn_type_name"`
  22409. MainMedcFlag string `json:"main_medc_flag"`
  22410. UrgtFlag string `json:"urgt_flag"`
  22411. BasMednFlag string `json:"bas_medn_flag"`
  22412. ImpDrugFlag string `json:"imp_drug_flag"`
  22413. ProdBarc string `json:"prod_barc"`
  22414. DrugProdname string `json:"drug_prodname"`
  22415. GennameCodg string `json:"genname_codg"`
  22416. DrugGenname string `json:"drug_genname"`
  22417. DrugDosform string `json:"drug_dosform"`
  22418. DrugSpec string `json:"drug_spec"`
  22419. PrdrName string `json:"prdr_name"`
  22420. MedcWayCodg string `json:"medc_way_codg"`
  22421. MedcWayDscr string `json:"medc_way_dscr"`
  22422. MedcBegntime string `json:"medc_begntime"`
  22423. MedcEndtime string `json:"medc_endtime"`
  22424. MedcDays float64 `json:"medc_days"`
  22425. DrugPric float64 `json:"drug_pric"`
  22426. DrugSumamt float64 `json:"drug_sumamt"`
  22427. DrugCnt float64 `json:"drug_cnt"`
  22428. DrugDosunt string `json:"drug_dosunt"`
  22429. SinDoscnt float64 `json:"sin_doscnt"`
  22430. SinDosunt string `json:"sin_dosunt"`
  22431. UsedFrquCodg string `json:"used_frqu_codg"`
  22432. UsedFrquName string `json:"used_frqu_name"`
  22433. DrugTotlcnt string `json:"drug_totlcnt"`
  22434. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22435. DiseCodg string `json:"dise_codg"`
  22436. HospApprFlag string `json:"hosp_appr_flag"`
  22437. } `json:"rx_detl_list"`
  22438. RxOtpinfo struct {
  22439. MedType string `json:"med_type"`
  22440. IptOtpNo string `json:"ipt_otp_no"`
  22441. OtpIptFlag string `json:"otp_ipt_flag"`
  22442. PatnName string `json:"patn_name"`
  22443. PatnAge float64 `json:"patn_age"`
  22444. PatnHgt float64 `json:"patn_hgt"`
  22445. PatnWt float64 `json:"patn_wt"`
  22446. Gend string `json:"gend"`
  22447. GesoVal float64 `json:"geso_val"`
  22448. NwbFlag string `json:"nwb_flag"`
  22449. NwbAge string `json:"nwb_age"`
  22450. SuckPrdFlag string `json:"suck_prd_flag"`
  22451. AlgsHis string `json:"algs_his"`
  22452. Insutype string `json:"insutype"`
  22453. PrscDeptName string `json:"prsc_dept_name"`
  22454. PrscDrName string `json:"prsc_dr_name"`
  22455. PharName string `json:"phar_name"`
  22456. PharChkTime string `json:"phar_chk_time"`
  22457. MdtrtTime string `json:"mdtrt_time"`
  22458. DiseCodg string `json:"dise_codg"`
  22459. DiseName string `json:"dise_name"`
  22460. SpDiseFlag string `json:"sp_dise_flag"`
  22461. MaindiagCode string `json:"maindiag_code"`
  22462. MaindiagName string `json:"maindiag_name"`
  22463. DiseCondDscr string `json:"dise_cond_dscr"`
  22464. FstdiagFlag string `json:"fstdiag_flag"`
  22465. } `json:"rx_otpinfo"`
  22466. RxDiseList []struct {
  22467. DiagType string `json:"diag_type"`
  22468. MaindiagFlag string `json:"maindiag_flag"`
  22469. DiagSrtNo string `json:"diag_srt_no"`
  22470. DiagCode string `json:"diag_code"`
  22471. DiagName string `json:"diag_name"`
  22472. DiagDept string `json:"diag_dept"`
  22473. DiagDrNo string `json:"diag_dr_no"`
  22474. DiagDrName string `json:"diag_dr_name"`
  22475. DiagTime string `json:"diag_time"`
  22476. TcmDiseCode string `json:"tcm_dise_code"`
  22477. TcmDiseName string `json:"tcm_dise_name"`
  22478. TcmSympCode string `json:"tcmsymp_code"`
  22479. TcmSymp string `json:"tcmsymp"`
  22480. } `json:"rx_dise_list"`
  22481. } `json:"output"`
  22482. RefmsgTime string `json:"refmsg_time"`
  22483. RespondTime string `json:"respond_time"`
  22484. Signtype interface{} `json:"signtype"`
  22485. WarnInfo interface{} `json:"warn_info"`
  22486. }
  22487. type ResultCFYLJG006 struct {
  22488. ErrMsg string `json:"err_msg"`
  22489. InfRefmsgid string `json:"inf_refmsgid"`
  22490. Infcode int64 `json:"infcode"`
  22491. Output struct {
  22492. HiRxNo string `json:"hi_rxno"`
  22493. PharCode string `json:"phar_code"`
  22494. PharName string `json:"phar_name"`
  22495. RxChkOpnn string `json:"rx_chk_opnn"`
  22496. RxChkTime string `json:"rx_chk_time"`
  22497. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22498. RxChkStasName string `json:"rx_chk_stas_name"`
  22499. RxStasCodg string `json:"rx_stas_codg"`
  22500. RxStasName string `json:"rx_stas_name"`
  22501. } `json:"output"`
  22502. RefmsgTime string `json:"refmsg_time"`
  22503. RespondTime string `json:"respond_time"`
  22504. Signtype interface{} `json:"signtype"`
  22505. WarnInfo interface{} `json:"warn_info"`
  22506. }
  22507. type ResultFourteen10265 struct {
  22508. ErrMsg string `json:"err_msg"`
  22509. InfRefmsgid string `json:"inf_refmsgid"`
  22510. Infcode string `json:"infcode"`
  22511. Output struct {
  22512. } `json:"output"`
  22513. RefmsgTime string `json:"refmsg_time"`
  22514. RespondTime string `json:"respond_time"`
  22515. Signtype interface{} `json:"signtype"`
  22516. WarnInfo interface{} `json:"warn_info"`
  22517. }
  22518. type ResultSixteen struct {
  22519. Cainfo string `json:"cainfo"`
  22520. ErrMsg string `json:"err_msg"`
  22521. InfRefmsgid string `json:"inf_refmsgid"`
  22522. Infcode int64 `json:"infcode"`
  22523. Output struct {
  22524. Setlinfo struct {
  22525. MdtrtID string `json:"mdtrt_id"`
  22526. SetlID string `json:"setl_id"`
  22527. ClrOptins string `json:"clr_optins"`
  22528. SetlTime string `json:"setl_time"`
  22529. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22530. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22531. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22532. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22533. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22534. ActPayDedc float64 `json:"act_pay_dedc"`
  22535. HifpPay float64 `json:"hifp_pay"`
  22536. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22537. Lfpay float64 `json:"selfpay"`
  22538. CvlservPay float64 `json:"cvlserv_pay"`
  22539. HifesPay float64 `json:"hifes_pay"`
  22540. HifmiPay float64 `json:"hifmi_pay"`
  22541. HifobPay float64 `json:"hifob_pay"`
  22542. MafPay float64 `json:"maf_pay"`
  22543. OthPay float64 `json:"oth_pay"`
  22544. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22545. PsnPartAmt float64 `json:"psn_part_amt"`
  22546. AcctPay float64 `json:"acct_pay"`
  22547. Balc float64 `json:"balc"`
  22548. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22549. HospPartAmt float64 `json:"hosp_part_amt"`
  22550. MedinsSetlID string `json:"medins_setl_id"`
  22551. PdnCashPay string `json:"pdn_cash_pay"`
  22552. } `json:"setlinfo"`
  22553. } `json:"output"`
  22554. RefmsgTime string `json:"refmsg_time"`
  22555. RespondTime string `json:"respond_time"`
  22556. Signtype interface{} `json:"signtype"`
  22557. WarnMsg interface{} `json:"warn_msg"`
  22558. }
  22559. type ResultSixteen10265 struct {
  22560. Cainfo string `json:"cainfo"`
  22561. ErrMsg string `json:"err_msg"`
  22562. InfRefmsgid string `json:"inf_refmsgid"`
  22563. Infcode string `json:"infcode"`
  22564. Output struct {
  22565. Setlinfo struct {
  22566. MdtrtID string `json:"mdtrt_id"`
  22567. SetlID string `json:"setl_id"`
  22568. ClrOptins string `json:"clr_optins"`
  22569. SetlTime string `json:"setl_time"`
  22570. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22571. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22572. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22573. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22574. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22575. ActPayDedc float64 `json:"act_pay_dedc"`
  22576. HifpPay float64 `json:"hifp_pay"`
  22577. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22578. Lfpay float64 `json:"selfpay"`
  22579. CvlservPay float64 `json:"cvlserv_pay"`
  22580. HifesPay float64 `json:"hifes_pay"`
  22581. HifmiPay float64 `json:"hifmi_pay"`
  22582. HifobPay float64 `json:"hifob_pay"`
  22583. MafPay float64 `json:"maf_pay"`
  22584. OthPay float64 `json:"oth_pay"`
  22585. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22586. PsnPartAmt float64 `json:"psn_part_amt"`
  22587. AcctPay float64 `json:"acct_pay"`
  22588. Balc float64 `json:"balc"`
  22589. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22590. HospPartAmt float64 `json:"hosp_part_amt"`
  22591. MedinsSetlID string `json:"medins_setl_id"`
  22592. PdnCashPay string `json:"pdn_cash_pay"`
  22593. } `json:"setlinfo"`
  22594. } `json:"output"`
  22595. RefmsgTime string `json:"refmsg_time"`
  22596. RespondTime string `json:"respond_time"`
  22597. Signtype interface{} `json:"signtype"`
  22598. WarnMsg interface{} `json:"warn_msg"`
  22599. }
  22600. type ResultSixteen10265Two struct {
  22601. Cainfo string `json:"cainfo"`
  22602. ErrMsg string `json:"err_msg"`
  22603. InfRefmsgid string `json:"inf_refmsgid"`
  22604. Infcode string `json:"infcode"`
  22605. Output struct {
  22606. Setlinfo interface{} `json:"setlinfo"`
  22607. } `json:"output"`
  22608. RefmsgTime string `json:"refmsg_time"`
  22609. RespondTime string `json:"respond_time"`
  22610. Signtype interface{} `json:"signtype"`
  22611. WarnMsg interface{} `json:"warn_msg"`
  22612. }
  22613. type ResultgzSixteen10265Two struct {
  22614. Cainfo string `json:"cainfo"`
  22615. ErrMsg string `json:"err_msg"`
  22616. InfRefmsgid string `json:"inf_refmsgid"`
  22617. Infcode int64 `json:"infcode"`
  22618. Output struct {
  22619. Setlinfo interface{} `json:"setlinfo"`
  22620. } `json:"output"`
  22621. RefmsgTime string `json:"refmsg_time"`
  22622. RespondTime string `json:"respond_time"`
  22623. Signtype interface{} `json:"signtype"`
  22624. WarnMsg interface{} `json:"warn_msg"`
  22625. }
  22626. type ResultSeventeen struct {
  22627. ErrMsg string `json:"err_msg"`
  22628. InfRefmsgid string `json:"inf_refmsgid"`
  22629. Infcode int64 `json:"infcode"`
  22630. Output struct {
  22631. SetlListId string `json:"setl_list_id"`
  22632. } `json:"output"`
  22633. RefmsgTime string `json:"refmsg_time"`
  22634. RespondTime string `json:"respond_time"`
  22635. Signtype string `json:"signtype"`
  22636. WarnInfo string `json:"warn_info"`
  22637. }
  22638. type ResultSeventeenOther struct {
  22639. ErrMsg string `json:"err_msg"`
  22640. InfRefmsgid string `json:"inf_refmsgid"`
  22641. Infcode string `json:"infcode"`
  22642. Output struct {
  22643. SetlListId string `json:"setl_list_id"`
  22644. } `json:"output"`
  22645. RefmsgTime string `json:"refmsg_time"`
  22646. RespondTime string `json:"respond_time"`
  22647. Signtype string `json:"signtype"`
  22648. WarnInfo string `json:"warn_info"`
  22649. }
  22650. type Result90991 struct {
  22651. ErrMsg string `json:"err_msg"`
  22652. InfRefmsgid string `json:"inf_refmsgid"`
  22653. Infcode int64 `json:"infcode"`
  22654. Output struct {
  22655. Result struct {
  22656. PsnNo string `json:"psn_no"`
  22657. CardStat string `json:"card_stat"`
  22658. Certno string `json:"certno"`
  22659. PsnName string `json:"psn_name"`
  22660. CheckStat string `json:"check_stat"`
  22661. SscnoCheckStat string `json:"sscno_check_stat"`
  22662. } `json:"result"`
  22663. } `json:"output"`
  22664. RefmsgTime string `json:"refmsg_time"`
  22665. RespondTime string `json:"respond_time"`
  22666. Signtype interface{} `json:"signtype"`
  22667. WarnInfo interface{} `json:"warn_info"`
  22668. }
  22669. type Result90100 struct {
  22670. ErrMsg string `json:"err_msg"`
  22671. InfRefmsgid string `json:"inf_refmsgid"`
  22672. Infcode int64 `json:"infcode"`
  22673. Output struct {
  22674. PoolareaNo string `json:"poolarea_no"`
  22675. PoolareaNoName string `json:"poolarea_no_name"`
  22676. Insutype string `json:"insutype"`
  22677. InsutypeName string `json:"insutype_name"`
  22678. ClctType string `json:"clct_type"`
  22679. ClctTypeName string `json:"clct_type_name"`
  22680. ClctFlag string `json:"clct_flag"`
  22681. ClctFlagName string `json:"clct_flag_name"`
  22682. AccrymBegn string `json:"accrym_begn"`
  22683. AccrymEnd string `json:"accrym_end"`
  22684. ClctTime string `json:"clct_time"`
  22685. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  22686. } `json:"output"`
  22687. RefmsgTime string `json:"refmsg_time"`
  22688. RespondTime string `json:"respond_time"`
  22689. Signtype interface{} `json:"signtype"`
  22690. WarnInfo interface{} `json:"warn_info"`
  22691. }
  22692. type Custom struct {
  22693. DetItemFeeSumamt string
  22694. Cut string
  22695. FeedetlSn string
  22696. Price string
  22697. MedListCodg string
  22698. Type int64
  22699. AdviceId int64
  22700. ProjectId int64
  22701. ItemId int64
  22702. }
  22703. type Result5301 struct {
  22704. ErrMsg string `json:"err_msg"`
  22705. InfRefmsgid string `json:"inf_refmsgid"`
  22706. Infcode int64 `json:"infcode"`
  22707. Output struct {
  22708. Result []struct {
  22709. OpspDiseCode string `json:"opsp_dise_code"`
  22710. OpspDiseName string `json:"opsp_dise_name"`
  22711. Begndate string `json:"begndate"`
  22712. Enddate string `json:"enddate"`
  22713. } `json:"feedetail"`
  22714. } `json:"output"`
  22715. RefmsgTime string `json:"refmsg_time"`
  22716. RespondTime string `json:"respond_time"`
  22717. Signtype interface{} `json:"signtype"`
  22718. WarnInfo interface{} `json:"warn_info"`
  22719. }
  22720. type Result5301For10265 struct {
  22721. ErrMsg string `json:"err_msg"`
  22722. InfRefmsgid string `json:"inf_refmsgid"`
  22723. Infcode string `json:"infcode"`
  22724. Output struct {
  22725. Result []struct {
  22726. OpspDiseCode string `json:"opsp_dise_code"`
  22727. OpspDiseName string `json:"opsp_dise_name"`
  22728. Begndate string `json:"begndate"`
  22729. Enddate string `json:"enddate"`
  22730. } `json:"feedetail"`
  22731. } `json:"output"`
  22732. RefmsgTime string `json:"refmsg_time"`
  22733. RespondTime string `json:"respond_time"`
  22734. Signtype interface{} `json:"signtype"`
  22735. WarnInfo interface{} `json:"warn_info"`
  22736. }
  22737. //获取个人信息----挂号-----上传就诊信息
  22738. func (c *HisApiController) GetRegisterInfo() {
  22739. id, _ := c.GetInt64("id")
  22740. record_time := c.GetString("record_time")
  22741. settlementValue, _ := c.GetInt64("settlement_value")
  22742. medical_insurance_card := c.GetString("medical_insurance_card")
  22743. name := c.GetString("name")
  22744. id_card_type, _ := c.GetInt64("id_card_type")
  22745. certificates, _ := c.GetInt64("certificates")
  22746. medical_care, _ := c.GetInt64("medical_care")
  22747. birthday := c.GetString("birthday")
  22748. id_card := c.GetString("id_card")
  22749. register_type, _ := c.GetInt64("register")
  22750. doctor, _ := c.GetInt64("doctor")
  22751. department, _ := c.GetInt64("department")
  22752. gender, _ := c.GetInt64("sex")
  22753. registration_fee, _ := c.GetFloat("registration_fee")
  22754. medical_expenses, _ := c.GetFloat("medical_expenses")
  22755. social_type, _ := c.GetInt64("social_type")
  22756. admin_user_id, _ := c.GetInt64("admin_user_id")
  22757. insuplc_admdvs := c.GetString("insuplc_admdvs")
  22758. mdtrt_type := c.GetString("mdtrt_type")
  22759. if id_card_type == 5 {
  22760. id_card_type = 4
  22761. }
  22762. timeLayout := "2006-01-02"
  22763. loc, _ := time.LoadLocation("Local")
  22764. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  22765. birthUnix := birthdays.Unix()
  22766. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  22767. if err != nil {
  22768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22769. return
  22770. }
  22771. recordDateTime := theTime.Unix()
  22772. adminInfo := c.GetAdminUserInfo()
  22773. var patient service.Patients
  22774. if id == 0 {
  22775. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  22776. } else {
  22777. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  22778. }
  22779. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  22780. if patientPrescription.ID == 0 {
  22781. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  22782. }
  22783. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22784. if patient.ID == 0 {
  22785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  22786. return
  22787. }
  22788. if len(patient.IdCardNo) == 0 {
  22789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  22790. return
  22791. }
  22792. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22793. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  22794. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  22795. //就诊结算未完成,不能进行二次挂号
  22796. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  22797. if len(his) >= 1 {
  22798. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  22799. if len(his) >= 1 && order.ID == 0 {
  22800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  22801. return
  22802. }
  22803. }
  22804. //var register_log string
  22805. if config.IsOpen == 1 {
  22806. var res ResultTwo
  22807. var res10265 ResultTwo10265
  22808. var PsnNo string
  22809. var PsnCertType string
  22810. var Certno string
  22811. var PsnName string
  22812. var Gend string
  22813. var Naty string
  22814. var Brdy string
  22815. var Age float64
  22816. var infoStr string
  22817. var idetinfoStr string
  22818. var infocode int64
  22819. var verify_number string
  22820. fmt.Println(verify_number)
  22821. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  22822. psn_info, _ := service.GetPsnByPatientId(id)
  22823. PsnNo = psn_info.PsnNo
  22824. PsnCertType = psn_info.PsnCertType
  22825. Certno = psn_info.Certno
  22826. PsnName = psn_info.PsnName
  22827. Gend = psn_info.Gend
  22828. Naty = psn_info.Naty
  22829. Brdy = psn_info.Brdy
  22830. Age = psn_info.Age
  22831. infoStr = psn_info.Insuinfo
  22832. idetinfoStr = psn_info.Idetinfo
  22833. infocode = 0
  22834. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22835. psn_info, _ := service.GetPsnByPatientId(id)
  22836. PsnNo = psn_info.PsnNo
  22837. PsnCertType = psn_info.PsnCertType
  22838. Certno = psn_info.Certno
  22839. PsnName = psn_info.PsnName
  22840. Gend = psn_info.Gend
  22841. Naty = psn_info.Naty
  22842. Brdy = psn_info.Brdy
  22843. Age = psn_info.Age
  22844. infoStr = psn_info.Insuinfo
  22845. idetinfoStr = psn_info.Idetinfo
  22846. infocode = 0
  22847. verify_number = psn_info.VerifyNumber
  22848. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22849. if id_card_type == 2 {
  22850. //请求内网数据
  22851. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  22852. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22853. "&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
  22854. resp, requestErr := http.Get(api)
  22855. if requestErr != nil {
  22856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22857. return
  22858. }
  22859. body, ioErr := ioutil.ReadAll(resp.Body)
  22860. if ioErr != nil {
  22861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22863. return
  22864. }
  22865. var respJSON map[string]interface{}
  22866. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22869. return
  22870. }
  22871. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22872. result_byte, _ := json.Marshal(respJSON)
  22873. result := string(result_byte)
  22874. var dat map[string]interface{}
  22875. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22876. fmt.Println(dat)
  22877. } else {
  22878. fmt.Println(err)
  22879. }
  22880. userJSONBytes, _ := json.Marshal(dat)
  22881. var res ResultTwo
  22882. var resTwo10265 ResultTwo10265
  22883. if miConfig.Code == "H15049901371" {
  22884. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  22885. utils.ErrorLog("解析失败:%v", err)
  22886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22887. return
  22888. }
  22889. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  22890. res.Infcode = Infcode
  22891. res.ErrMsg = resTwo10265.ErrMsg
  22892. res.Output = resTwo10265.Output
  22893. res.InfRefmsgid = resTwo10265.InfRefmsgid
  22894. res.RespondTime = resTwo10265.RespondTime
  22895. res.WarnInfo = resTwo10265.WarnInfo
  22896. } else {
  22897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22898. utils.ErrorLog("解析失败:%v", err)
  22899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22900. return
  22901. }
  22902. }
  22903. //var insutypes []string
  22904. //var insutype string
  22905. //var is390 int = 0
  22906. //var is310 int = 0
  22907. //for _, item := range res.Output.Iinfo {
  22908. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22909. // insutypes = append(insutypes, item.Insutype)
  22910. // }
  22911. //}
  22912. //if len(insutypes) == 1 {
  22913. // insutype = insutypes[0]
  22914. //} else {
  22915. // for _, i := range insutypes {
  22916. // if i == "390" {
  22917. // is390 = 1
  22918. // }
  22919. //
  22920. // if i == "310" {
  22921. // is310 = 1
  22922. // }
  22923. // }
  22924. //}
  22925. //if is390 == 1 {
  22926. // insutype = "390"
  22927. //}
  22928. //if is310 == 1 {
  22929. // insutype = "310"
  22930. //}
  22931. //if len(insutypes) == 0 {
  22932. // insutype = "310"
  22933. //}
  22934. PsnNo = res.Output.Baseinfo.PsnNo
  22935. PsnCertType = res.Output.Baseinfo.PsnCertType
  22936. Certno = res.Output.Baseinfo.Certno
  22937. PsnName = res.Output.Baseinfo.PsnName
  22938. Gend = res.Output.Baseinfo.Gend
  22939. Naty = res.Output.Baseinfo.Naty
  22940. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22941. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22942. infoStr = string(Iinfos)
  22943. idetinfoStr = string(Idetinfos)
  22944. infocode = res.Infcode
  22945. //infocode = 0
  22946. //verify_number = psn_info.VerifyNumber
  22947. } else {
  22948. psn_info, _ := service.GetPsnByPatientId(id)
  22949. PsnNo = psn_info.PsnNo
  22950. PsnCertType = psn_info.PsnCertType
  22951. Certno = psn_info.Certno
  22952. PsnName = psn_info.PsnName
  22953. Gend = psn_info.Gend
  22954. Naty = psn_info.Naty
  22955. Brdy = psn_info.Brdy
  22956. Age = psn_info.Age
  22957. infoStr = psn_info.Insuinfo
  22958. idetinfoStr = psn_info.Idetinfo
  22959. infocode = 0
  22960. verify_number = psn_info.VerifyNumber
  22961. }
  22962. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22963. if id_card_type == 1 {
  22964. psn_info, _ := service.GetPsnByPatientId(id)
  22965. PsnNo = psn_info.PsnNo
  22966. PsnCertType = psn_info.PsnCertType
  22967. Certno = psn_info.Certno
  22968. PsnName = psn_info.PsnName
  22969. Gend = psn_info.Gend
  22970. Naty = psn_info.Naty
  22971. Brdy = psn_info.Brdy
  22972. Age = psn_info.Age
  22973. infoStr = psn_info.Insuinfo
  22974. idetinfoStr = psn_info.Idetinfo
  22975. infocode = 0
  22976. verify_number = psn_info.VerifyNumber
  22977. } else if id_card_type == 2 {
  22978. 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)
  22979. fmt.Println(errMsgLog)
  22980. saveLog(result, requestLog, "1101", "人员基本信息获取")
  22981. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22982. utils.ErrorLog("解析失败:%v", err)
  22983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22984. return
  22985. }
  22986. PsnNo = res.Output.Baseinfo.PsnNo
  22987. PsnCertType = res.Output.Baseinfo.PsnCertType
  22988. Certno = res.Output.Baseinfo.Certno
  22989. PsnName = res.Output.Baseinfo.PsnName
  22990. Gend = res.Output.Baseinfo.Gend
  22991. Naty = res.Output.Baseinfo.Naty
  22992. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22993. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22994. infoStr = string(Iinfos)
  22995. idetinfoStr = string(Idetinfos)
  22996. infocode = res.Infcode
  22997. }
  22998. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22999. if id_card_type == 1 {
  23000. psn_info, _ := service.GetPsnByPatientId(id)
  23001. PsnNo = psn_info.PsnNo
  23002. PsnCertType = psn_info.PsnCertType
  23003. Certno = psn_info.Certno
  23004. PsnName = psn_info.PsnName
  23005. Gend = psn_info.Gend
  23006. Naty = psn_info.Naty
  23007. Brdy = psn_info.Brdy
  23008. Age = psn_info.Age
  23009. infoStr = psn_info.Insuinfo
  23010. idetinfoStr = psn_info.Idetinfo
  23011. infocode = 0
  23012. verify_number = psn_info.VerifyNumber
  23013. } else if id_card_type == 2 {
  23014. 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, "")
  23015. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23016. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23017. utils.ErrorLog("解析失败:%v", err)
  23018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23019. return
  23020. }
  23021. PsnNo = res.Output.Baseinfo.PsnNo
  23022. PsnCertType = res.Output.Baseinfo.PsnCertType
  23023. Certno = res.Output.Baseinfo.Certno
  23024. PsnName = res.Output.Baseinfo.PsnName
  23025. Gend = res.Output.Baseinfo.Gend
  23026. Naty = res.Output.Baseinfo.Naty
  23027. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23028. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23029. infoStr = string(Iinfos)
  23030. idetinfoStr = string(Idetinfos)
  23031. infocode = res.Infcode
  23032. } else {
  23033. psn_info, _ := service.GetPsnByPatientId(id)
  23034. PsnNo = psn_info.PsnNo
  23035. PsnCertType = psn_info.PsnCertType
  23036. Certno = psn_info.Certno
  23037. PsnName = psn_info.PsnName
  23038. Gend = psn_info.Gend
  23039. Naty = psn_info.Naty
  23040. Brdy = psn_info.Brdy
  23041. Age = psn_info.Age
  23042. infoStr = psn_info.Insuinfo
  23043. idetinfoStr = psn_info.Idetinfo
  23044. infocode = 0
  23045. verify_number = psn_info.VerifyNumber
  23046. }
  23047. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23048. if id_card_type == 1 {
  23049. psn_info, _ := service.GetPsnByPatientId(id)
  23050. PsnNo = psn_info.PsnNo
  23051. PsnCertType = psn_info.PsnCertType
  23052. Certno = psn_info.Certno
  23053. PsnName = psn_info.PsnName
  23054. Gend = psn_info.Gend
  23055. Naty = psn_info.Naty
  23056. Brdy = psn_info.Brdy
  23057. Age = psn_info.Age
  23058. infoStr = psn_info.Insuinfo
  23059. idetinfoStr = psn_info.Idetinfo
  23060. infocode = 0
  23061. verify_number = psn_info.VerifyNumber
  23062. } else if id_card_type == 2 {
  23063. psn_info, _ := service.GetPsnByPatientId(id)
  23064. PsnNo = psn_info.PsnNo
  23065. PsnCertType = psn_info.PsnCertType
  23066. Certno = psn_info.Certno
  23067. PsnName = psn_info.PsnName
  23068. Gend = psn_info.Gend
  23069. Naty = psn_info.Naty
  23070. Brdy = psn_info.Brdy
  23071. Age = psn_info.Age
  23072. infoStr = psn_info.Insuinfo
  23073. idetinfoStr = psn_info.Idetinfo
  23074. infocode = 0
  23075. verify_number = psn_info.VerifyNumber
  23076. } else {
  23077. psn_info, _ := service.GetPsnByPatientId(id)
  23078. PsnNo = psn_info.PsnNo
  23079. PsnCertType = psn_info.PsnCertType
  23080. Certno = psn_info.Certno
  23081. PsnName = psn_info.PsnName
  23082. Gend = psn_info.Gend
  23083. Naty = psn_info.Naty
  23084. Brdy = psn_info.Brdy
  23085. Age = psn_info.Age
  23086. infoStr = psn_info.Insuinfo
  23087. idetinfoStr = psn_info.Idetinfo
  23088. infocode = 0
  23089. verify_number = psn_info.VerifyNumber
  23090. }
  23091. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23092. psn_info, _ := service.GetPsnByPatientId(id)
  23093. PsnNo = psn_info.PsnNo
  23094. PsnCertType = psn_info.PsnCertType
  23095. Certno = psn_info.Certno
  23096. PsnName = psn_info.PsnName
  23097. Gend = psn_info.Gend
  23098. Naty = psn_info.Naty
  23099. Brdy = psn_info.Brdy
  23100. Age = psn_info.Age
  23101. infoStr = psn_info.Insuinfo
  23102. idetinfoStr = psn_info.Idetinfo
  23103. infocode = 0
  23104. verify_number = psn_info.VerifyNumber
  23105. idetinfoStr = psn_info.Idetinfo
  23106. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23107. if id_card_type == 1 {
  23108. psn_info, _ := service.GetPsnByPatientId(id)
  23109. PsnNo = psn_info.PsnNo
  23110. PsnCertType = psn_info.PsnCertType
  23111. Certno = psn_info.Certno
  23112. PsnName = psn_info.PsnName
  23113. Gend = psn_info.Gend
  23114. Naty = psn_info.Naty
  23115. Brdy = psn_info.Brdy
  23116. Age = psn_info.Age
  23117. infoStr = psn_info.Insuinfo
  23118. idetinfoStr = psn_info.Idetinfo
  23119. infocode = 0
  23120. verify_number = psn_info.VerifyNumber
  23121. } else if id_card_type == 2 {
  23122. 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)
  23123. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23124. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23125. utils.ErrorLog("解析失败:%v", err)
  23126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23127. return
  23128. }
  23129. PsnNo = res.Output.Baseinfo.PsnNo
  23130. PsnCertType = res.Output.Baseinfo.PsnCertType
  23131. Certno = res.Output.Baseinfo.Certno
  23132. PsnName = res.Output.Baseinfo.PsnName
  23133. Gend = res.Output.Baseinfo.Gend
  23134. Naty = res.Output.Baseinfo.Naty
  23135. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23136. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23137. infoStr = string(Iinfos)
  23138. idetinfoStr = string(Idetinfos)
  23139. infocode = res.Infcode
  23140. } else if id_card_type == 4 {
  23141. psn_info, _ := service.GetPsnByPatientId(id)
  23142. PsnNo = psn_info.PsnNo
  23143. PsnCertType = psn_info.PsnCertType
  23144. Certno = psn_info.Certno
  23145. PsnName = psn_info.PsnName
  23146. Gend = psn_info.Gend
  23147. Naty = psn_info.Naty
  23148. Brdy = psn_info.Brdy
  23149. Age = psn_info.Age
  23150. infoStr = psn_info.Insuinfo
  23151. idetinfoStr = psn_info.Idetinfo
  23152. infocode = 0
  23153. verify_number = psn_info.VerifyNumber
  23154. }
  23155. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23156. var result string
  23157. var requestLog string
  23158. 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), "")
  23159. if id_card_type == 4 {
  23160. psn_info, _ := service.GetPsnByPatientId(id)
  23161. PsnNo = psn_info.PsnNo
  23162. PsnCertType = psn_info.PsnCertType
  23163. Certno = psn_info.Certno
  23164. PsnName = psn_info.PsnName
  23165. Gend = psn_info.Gend
  23166. Naty = psn_info.Naty
  23167. Brdy = psn_info.Brdy
  23168. Age = psn_info.Age
  23169. infoStr = psn_info.Insuinfo
  23170. idetinfoStr = psn_info.Idetinfo
  23171. infocode = 0
  23172. verify_number = psn_info.VerifyNumber
  23173. } else {
  23174. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23175. if miConfig.Code == "H15049901371" {
  23176. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23177. utils.ErrorLog("解析失败:%v", err)
  23178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23179. return
  23180. }
  23181. res.ErrMsg = res10265.ErrMsg
  23182. res.Output = res10265.Output
  23183. res.InfRefmsgid = res10265.InfRefmsgid
  23184. } else {
  23185. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23186. utils.ErrorLog("解析失败:%v", err)
  23187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23188. return
  23189. }
  23190. }
  23191. PsnNo = res.Output.Baseinfo.PsnNo
  23192. PsnCertType = res.Output.Baseinfo.PsnCertType
  23193. Certno = res.Output.Baseinfo.Certno
  23194. PsnName = res.Output.Baseinfo.PsnName
  23195. Gend = res.Output.Baseinfo.Gend
  23196. Naty = res.Output.Baseinfo.Naty
  23197. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23198. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23199. infoStr = string(Iinfos)
  23200. idetinfoStr = string(Idetinfos)
  23201. if miConfig.Code == "H15049901371" {
  23202. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23203. } else {
  23204. infocode = res.Infcode
  23205. }
  23206. }
  23207. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23208. psn_info, _ := service.GetPsnByPatientId(id)
  23209. PsnNo = psn_info.PsnNo
  23210. PsnCertType = psn_info.PsnCertType
  23211. Certno = psn_info.Certno
  23212. PsnName = psn_info.PsnName
  23213. Gend = psn_info.Gend
  23214. Naty = psn_info.Naty
  23215. Brdy = psn_info.Brdy
  23216. Age = psn_info.Age
  23217. infoStr = psn_info.Insuinfo
  23218. idetinfoStr = psn_info.Idetinfo
  23219. infocode = 0
  23220. verify_number = psn_info.VerifyNumber
  23221. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23222. psn_info, _ := service.GetPsnByPatientId(id)
  23223. PsnNo = psn_info.PsnNo
  23224. PsnCertType = psn_info.PsnCertType
  23225. Certno = psn_info.Certno
  23226. PsnName = psn_info.PsnName
  23227. Gend = psn_info.Gend
  23228. Naty = psn_info.Naty
  23229. Brdy = psn_info.Brdy
  23230. Age = psn_info.Age
  23231. infoStr = psn_info.Insuinfo
  23232. idetinfoStr = psn_info.Idetinfo
  23233. infocode = 0
  23234. verify_number = psn_info.VerifyNumber
  23235. } else {
  23236. var result string
  23237. var requestLog string
  23238. //if miConfig.UserOrgId == 10138 {
  23239. if id_card_type != 4 || id_card_type != 1 {
  23240. var insa string
  23241. if len(patient.InsuplcAdmdvs) > 0 {
  23242. insa = patient.InsuplcAdmdvs
  23243. } else {
  23244. insa = miConfig.InsuplcAdmdvs
  23245. }
  23246. //psn_info, _ := service.GetPsnByPatientId(id)
  23247. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23248. 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)
  23249. }
  23250. //}
  23251. //else {
  23252. // var insa string
  23253. // if len(patient.InsuplcAdmdvs) > 0 {
  23254. // insa = patient.InsuplcAdmdvs
  23255. // } else {
  23256. // insa = miConfig.InsuplcAdmdvs
  23257. // }
  23258. // 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)
  23259. //}
  23260. if id_card_type == 4 || id_card_type == 1 {
  23261. psn_info, _ := service.GetPsnByPatientId(id)
  23262. PsnNo = psn_info.PsnNo
  23263. PsnCertType = psn_info.PsnCertType
  23264. Certno = psn_info.Certno
  23265. PsnName = psn_info.PsnName
  23266. Gend = psn_info.Gend
  23267. Naty = psn_info.Naty
  23268. Brdy = psn_info.Brdy
  23269. Age = psn_info.Age
  23270. infoStr = psn_info.Insuinfo
  23271. idetinfoStr = psn_info.Idetinfo
  23272. infocode = 0
  23273. verify_number = psn_info.VerifyNumber
  23274. } else {
  23275. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23276. if miConfig.Code == "H15049901371" {
  23277. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23278. utils.ErrorLog("解析失败:%v", err)
  23279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23280. return
  23281. }
  23282. res.ErrMsg = res10265.ErrMsg
  23283. res.Output = res10265.Output
  23284. res.InfRefmsgid = res10265.InfRefmsgid
  23285. } else {
  23286. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23287. utils.ErrorLog("解析失败:%v", err)
  23288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23289. return
  23290. }
  23291. }
  23292. PsnNo = res.Output.Baseinfo.PsnNo
  23293. PsnCertType = res.Output.Baseinfo.PsnCertType
  23294. Certno = res.Output.Baseinfo.Certno
  23295. PsnName = res.Output.Baseinfo.PsnName
  23296. Gend = res.Output.Baseinfo.Gend
  23297. Naty = res.Output.Baseinfo.Naty
  23298. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23299. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23300. infoStr = string(Iinfos)
  23301. idetinfoStr = string(Idetinfos)
  23302. if miConfig.Code == "H15049901371" {
  23303. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23304. } else {
  23305. infocode = res.Infcode
  23306. }
  23307. }
  23308. }
  23309. if infocode == 0 {
  23310. his := models.VMHisPatient{
  23311. Name: name,
  23312. Gender: gender,
  23313. Birthday: birthUnix,
  23314. MedicalTreatmentType: medical_care,
  23315. IdType: certificates,
  23316. IdCardNo: id_card,
  23317. BalanceAccountsType: settlementValue,
  23318. SocialType: social_type,
  23319. MedicalInsuranceNumber: medical_insurance_card,
  23320. RegisterType: register_type,
  23321. RegisterCost: registration_fee,
  23322. TreatmentCost: medical_expenses,
  23323. Status: 1,
  23324. Ctime: time.Now().Unix(),
  23325. Mtime: time.Now().Unix(),
  23326. PsnNo: PsnNo,
  23327. PsnCertType: PsnCertType,
  23328. Certno: Certno,
  23329. PsnName: PsnName,
  23330. Gend: Gend,
  23331. Naty: Naty,
  23332. Brdy: Brdy,
  23333. Age: Age,
  23334. Iinfo: infoStr,
  23335. Idetinfo: idetinfoStr,
  23336. PatientId: patient.ID,
  23337. RecordDate: theTime.Unix(),
  23338. UserOrgId: adminInfo.CurrentOrgId,
  23339. AdminUserId: admin_user_id,
  23340. IsReturn: 1,
  23341. IdCardType: id_card_type,
  23342. Doctor: doctor,
  23343. Departments: department,
  23344. MdtrtGrpType: mdtrt_type,
  23345. }
  23346. timestamp := time.Now().Unix()
  23347. tempTime := time.Unix(timestamp, 0)
  23348. timeFormat := tempTime.Format("20060102150405")
  23349. chrgBchno := rand.Intn(100000) + 10000
  23350. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23351. his.Number = ipt_otp_no
  23352. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23353. department, _ := service.GetDepartMentDetail(department)
  23354. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23355. IdCardNo := ""
  23356. if id_card_type == 1 {
  23357. // IdCardNo = medical_insurance_card
  23358. IdCardNo = patient.IdCardNo
  23359. } else {
  23360. IdCardNo = patient.IdCardNo
  23361. }
  23362. var rf []*ResultFive
  23363. json.Unmarshal([]byte(his.Iinfo), &rf)
  23364. var insutypes []*ResultFive
  23365. var insutype string
  23366. var insuplc_admdvs_temp string
  23367. var is390 int = 0
  23368. var is310 int = 0
  23369. for _, item := range rf {
  23370. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23371. insutypes = append(insutypes, item)
  23372. }
  23373. }
  23374. if len(insutypes) == 1 {
  23375. insutype = insutypes[0].Insutype
  23376. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23377. if insutype == "390" {
  23378. is390 = 1
  23379. }
  23380. if insutype == "310" {
  23381. is310 = 1
  23382. }
  23383. } else {
  23384. for _, i := range insutypes {
  23385. if i.Insutype == "390" {
  23386. is390 = 1
  23387. }
  23388. if i.Insutype == "310" {
  23389. is310 = 1
  23390. }
  23391. }
  23392. }
  23393. if is390 == 1 {
  23394. insutype = "390"
  23395. }
  23396. if is310 == 1 {
  23397. insutype = "310"
  23398. }
  23399. fmt.Println(social_type)
  23400. if social_type > 0 {
  23401. insutype = strconv.FormatInt(social_type, 10)
  23402. }
  23403. var infocode int64
  23404. var resThree ResultThree
  23405. var resThree10265 ResultThree10265
  23406. if len(insuplc_admdvs) == 0 {
  23407. psn_info, _ := service.GetPsnByPatientId(id)
  23408. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23409. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23410. //}
  23411. } else {
  23412. insuplc_admdvs_temp = insuplc_admdvs
  23413. }
  23414. if miConfig.MdtrtareaAdmvs == "421300" {
  23415. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23416. psn_info, _ := service.GetPsnByPatientId(id)
  23417. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23418. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23419. "&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
  23420. resp, requestErr := http.Get(api)
  23421. if requestErr != nil {
  23422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23423. return
  23424. }
  23425. body, ioErr := ioutil.ReadAll(resp.Body)
  23426. if ioErr != nil {
  23427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23429. return
  23430. }
  23431. var respJSON map[string]interface{}
  23432. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23435. return
  23436. }
  23437. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23438. result, _ := json.Marshal(respJSON)
  23439. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23440. utils.ErrorLog("解析失败:%v", err)
  23441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23442. return
  23443. }
  23444. infocode = resThree.Infcode
  23445. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23446. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23447. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23448. // insuplc_admdvs_temp =
  23449. //}
  23450. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23451. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23452. //}
  23453. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23454. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23455. "&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
  23456. resp, requestErr := http.Get(api)
  23457. if requestErr != nil {
  23458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23459. return
  23460. }
  23461. body, ioErr := ioutil.ReadAll(resp.Body)
  23462. if ioErr != nil {
  23463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23465. return
  23466. }
  23467. var respJSON map[string]interface{}
  23468. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23471. return
  23472. }
  23473. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23474. result, _ := json.Marshal(respJSON)
  23475. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23476. utils.ErrorLog("解析失败:%v", err)
  23477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23478. return
  23479. }
  23480. infocode = resThree.Infcode
  23481. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23482. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23483. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23484. // insuplc_admdvs_temp =
  23485. //}
  23486. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23487. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23488. //}
  23489. utils.ErrorLog("解析失败:%v", insutype)
  23490. utils.ErrorLog("解析失败:%v", PsnNo)
  23491. utils.ErrorLog("解析失败:%v", Certno)
  23492. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23493. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23494. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23495. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23496. utils.ErrorLog("解析失败:%v", PsnNo)
  23497. utils.ErrorLog("解析失败:%v", department.Number)
  23498. utils.ErrorLog("解析失败:%v", department.Name)
  23499. utils.ErrorLog("解析失败:%v", roles.UserName)
  23500. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23501. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23502. "&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
  23503. resp, requestErr := http.Get(api)
  23504. if requestErr != nil {
  23505. utils.ErrorLog("解析失败:%v", requestErr)
  23506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23507. return
  23508. }
  23509. body, ioErr := ioutil.ReadAll(resp.Body)
  23510. if ioErr != nil {
  23511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23513. return
  23514. }
  23515. var respJSON map[string]interface{}
  23516. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23519. return
  23520. }
  23521. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23522. result, _ := json.Marshal(respJSON)
  23523. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23524. utils.ErrorLog("解析失败:%v", err)
  23525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23526. return
  23527. }
  23528. infocode = resThree.Infcode
  23529. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23530. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23531. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23532. // insuplc_admdvs_temp =
  23533. //}
  23534. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23535. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23536. //}
  23537. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23538. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23539. "&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
  23540. resp, requestErr := http.Get(api)
  23541. if requestErr != nil {
  23542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23543. return
  23544. }
  23545. body, ioErr := ioutil.ReadAll(resp.Body)
  23546. if ioErr != nil {
  23547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23549. return
  23550. }
  23551. var respJSON map[string]interface{}
  23552. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23555. return
  23556. }
  23557. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23558. result, _ := json.Marshal(respJSON)
  23559. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23560. utils.ErrorLog("解析失败:%v", err)
  23561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23562. return
  23563. }
  23564. infocode = resThree.Infcode
  23565. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23566. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23567. psn_info, _ := service.GetPsnByPatientId(id)
  23568. var verify_number string
  23569. if id_card_type == 4 {
  23570. verify_number = psn_info.VerifyNumber
  23571. } else if id_card_type == 1 {
  23572. bas := strings.Split(psn_info.CardInfo, "|")
  23573. cardNumber := bas[2]
  23574. verify_number = cardNumber
  23575. }
  23576. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23577. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23578. "&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
  23579. resp, requestErr := http.Get(api)
  23580. if requestErr != nil {
  23581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23582. return
  23583. }
  23584. body, ioErr := ioutil.ReadAll(resp.Body)
  23585. if ioErr != nil {
  23586. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23588. return
  23589. }
  23590. var respJSON map[string]interface{}
  23591. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23594. return
  23595. }
  23596. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23597. result, _ := json.Marshal(respJSON)
  23598. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23599. // utils.ErrorLog("解析失败:%v", err)
  23600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23601. // return
  23602. //}
  23603. //infocode = resThree.Infcode
  23604. //result, _ := json.Marshal(respJSON)
  23605. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23606. utils.ErrorLog("解析失败:%v", err)
  23607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23608. return
  23609. }
  23610. resThree.ErrMsg = resThree10265.ErrMsg
  23611. resThree.Output = resThree10265.Output
  23612. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23613. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23614. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23615. psn_info, _ := service.GetPsnByPatientId(id)
  23616. his.PsnNo = psn_info.PsnNo
  23617. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23618. var cert_no string
  23619. if id_card_type == 3 {
  23620. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  23621. cert_no = IdCardNo
  23622. } else if id_card_type == 4 {
  23623. cert_no = IdCardNo
  23624. psn_info.VerifyNumber = psn_info.VerifyNumber
  23625. } else {
  23626. bas := strings.Split(psn_info.CardInfo, "|")
  23627. cert_no = bas[2]
  23628. }
  23629. var hisPrescription []*models.HisPrescription
  23630. for _, item := range rf {
  23631. if item.Insutype == insutype {
  23632. //insuplc_admdvs = item.InsuplcAdmdvs
  23633. his.InsuplcAdmdvs = insuplc_admdvs
  23634. }
  23635. }
  23636. his.Insutype = insutype
  23637. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  23638. fmt.Println(res3101)
  23639. fmt.Println(res3101.Infcode)
  23640. if res3101.Infcode == "0" {
  23641. fmt.Println("33333333")
  23642. if len(res3101.Output.Result) > 0 {
  23643. fmt.Println("222222")
  23644. for _, item := range res3101.Output.Result {
  23645. if len(res3101.ErrMsg) == 0 {
  23646. res3101.ErrMsg = item.VolaCont
  23647. } else {
  23648. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  23649. }
  23650. }
  23651. c.ServeSuccessJSON(map[string]interface{}{
  23652. "failed_code": -10,
  23653. "msg": res3101.ErrMsg,
  23654. })
  23655. return
  23656. } else {
  23657. fmt.Println("11111")
  23658. var api string
  23659. if miConfig.MdtrtareaAdmvs == "320921" {
  23660. ipt_otp_no = timeFormat
  23661. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23662. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23663. "&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
  23664. } else {
  23665. ipt_otp_no = timeFormat
  23666. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  23667. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23668. "&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
  23669. }
  23670. resp, requestErr := http.Get(api)
  23671. if requestErr != nil {
  23672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23673. return
  23674. }
  23675. body, ioErr := ioutil.ReadAll(resp.Body)
  23676. if ioErr != nil {
  23677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23679. return
  23680. }
  23681. var respJSON map[string]interface{}
  23682. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23685. return
  23686. }
  23687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23688. result, _ := json.Marshal(respJSON)
  23689. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23690. utils.ErrorLog("解析失败:%v", err)
  23691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23692. return
  23693. }
  23694. resThree.ErrMsg = resThree10265.ErrMsg
  23695. resThree.Output = resThree10265.Output
  23696. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23697. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23698. }
  23699. } else if res3101.Infcode != "0" {
  23700. c.ServeSuccessJSON(map[string]interface{}{
  23701. "failed_code": -10,
  23702. "msg": res3101.ErrMsg,
  23703. })
  23704. return
  23705. }
  23706. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23707. psn_info, _ := service.GetPsnByPatientId(id)
  23708. var cert_no string
  23709. if id_card_type == 1 {
  23710. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  23711. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23712. } else if id_card_type == 4 {
  23713. cert_no = psn_info.VerifyNumber
  23714. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23715. } else {
  23716. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23717. cert_no = psn_info.VerifyNumber
  23718. }
  23719. 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)
  23720. saveLog(result, requestLog, "2201", "挂号")
  23721. if miConfig.Code == "H15049901371" {
  23722. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23723. utils.ErrorLog("解析失败:%v", err)
  23724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23725. return
  23726. }
  23727. resThree.ErrMsg = resThree10265.ErrMsg
  23728. resThree.Output = resThree10265.Output
  23729. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23730. } else {
  23731. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23732. utils.ErrorLog("解析失败:%v", err)
  23733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23734. return
  23735. }
  23736. }
  23737. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23738. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  23739. psn_info, _ := service.GetPsnByPatientId(id)
  23740. var result string
  23741. var requestLog string
  23742. if id_card_type == 1 {
  23743. bas := strings.Split(psn_info.CardInfo, "|")
  23744. basNumber := bas[2]
  23745. card_sn := bas[3]
  23746. 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)
  23747. saveLog(result, requestLog, "2201A", "挂号")
  23748. } else if id_card_type == 2 {
  23749. 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, "", "", "", "", "", "")
  23750. saveLog(result, requestLog, "2201A", "挂号")
  23751. } else {
  23752. 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)
  23753. saveLog(result, requestLog, "2201A", "挂号")
  23754. }
  23755. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23756. utils.ErrorLog("解析失败:%v", err)
  23757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23758. return
  23759. }
  23760. infocode = resThree.Infcode
  23761. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  23762. psn_info, _ := service.GetPsnByPatientId(id)
  23763. var result string
  23764. var requestLog string
  23765. if id_card_type == 1 {
  23766. bas := strings.Split(psn_info.CardInfo, "|")
  23767. basNumber := bas[2]
  23768. card_sn := ""
  23769. 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)
  23770. saveLog(result, requestLog, "2201A", "挂号")
  23771. } else if id_card_type == 2 {
  23772. 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, "", "", "", "", "", "")
  23773. saveLog(result, requestLog, "2201A", "挂号")
  23774. } else {
  23775. 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)
  23776. saveLog(result, requestLog, "2201A", "挂号")
  23777. }
  23778. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23779. utils.ErrorLog("解析失败:%v", err)
  23780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23781. return
  23782. }
  23783. infocode = resThree.Infcode
  23784. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23785. psn_info, _ := service.GetPsnByPatientId(id)
  23786. his.PsnNo = psn_info.PsnNo
  23787. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23788. var cert_no string
  23789. if id_card_type == 1 {
  23790. bas := strings.Split(psn_info.CardInfo, "|")
  23791. cert_no = bas[2]
  23792. } else if id_card_type == 4 {
  23793. cert_no = psn_info.VerifyNumber
  23794. psn_info.VerifyNumber = psn_info.VerifyNumber
  23795. IdCardNo = psn_info.VerifyNumber
  23796. } else {
  23797. cert_no = IdCardNo
  23798. psn_info.VerifyNumber = cert_no
  23799. }
  23800. for _, item := range rf {
  23801. if item.Insutype == insutype {
  23802. his.InsuplcAdmdvs = insuplc_admdvs
  23803. }
  23804. }
  23805. his.Insutype = insutype
  23806. var api string
  23807. ipt_otp_no = timeFormat
  23808. 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 +
  23809. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23810. "&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
  23811. resp, requestErr := http.Get(api)
  23812. if requestErr != nil {
  23813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23814. return
  23815. }
  23816. body, ioErr := ioutil.ReadAll(resp.Body)
  23817. if ioErr != nil {
  23818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23820. return
  23821. }
  23822. var respJSON map[string]interface{}
  23823. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23826. return
  23827. }
  23828. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23829. if status == "0" {
  23830. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23831. c.ServeSuccessJSON(map[string]interface{}{
  23832. "failed_code": -10,
  23833. "msg": err_msg,
  23834. })
  23835. return
  23836. }
  23837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23838. result, _ := json.Marshal(respJSON)
  23839. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23840. utils.ErrorLog("解析失败:%v", err)
  23841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23842. return
  23843. }
  23844. infocode = resThree.Infcode
  23845. } else if miConfig.MdtrtareaAdmvs == "340699" {
  23846. psn_info, _ := service.GetPsnByPatientId(id)
  23847. his.PsnNo = psn_info.PsnNo
  23848. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23849. var cert_no string
  23850. if id_card_type == 1 {
  23851. bas := strings.Split(psn_info.CardInfo, "|")
  23852. cert_no = bas[2]
  23853. } else if id_card_type == 4 {
  23854. cert_no = psn_info.VerifyNumber
  23855. psn_info.VerifyNumber = psn_info.VerifyNumber
  23856. IdCardNo = psn_info.VerifyNumber
  23857. } else {
  23858. cert_no = IdCardNo
  23859. psn_info.VerifyNumber = cert_no
  23860. }
  23861. for _, item := range rf {
  23862. if item.Insutype == insutype {
  23863. his.InsuplcAdmdvs = insuplc_admdvs
  23864. patient.InsuplcAdmdvs = insuplc_admdvs
  23865. }
  23866. }
  23867. his.Insutype = insutype
  23868. var api string
  23869. ipt_otp_no = timeFormat
  23870. 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 +
  23871. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23872. "&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
  23873. resp, requestErr := http.Get(api)
  23874. if requestErr != nil {
  23875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23876. return
  23877. }
  23878. body, ioErr := ioutil.ReadAll(resp.Body)
  23879. if ioErr != nil {
  23880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23882. return
  23883. }
  23884. var respJSON map[string]interface{}
  23885. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23888. return
  23889. }
  23890. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23891. if status == "0" {
  23892. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23893. c.ServeSuccessJSON(map[string]interface{}{
  23894. "failed_code": -10,
  23895. "msg": err_msg,
  23896. })
  23897. return
  23898. }
  23899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23900. result, _ := json.Marshal(respJSON)
  23901. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23902. utils.ErrorLog("解析失败:%v", err)
  23903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23904. return
  23905. }
  23906. infocode = resThree.Infcode
  23907. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23908. psn_info, _ := service.GetPsnByPatientId(id)
  23909. var result string
  23910. var requestLog string
  23911. if id_card_type == 1 {
  23912. bas := strings.Split(psn_info.CardInfo, "|")
  23913. basNumber := bas[2]
  23914. card_sn := bas[3]
  23915. 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)
  23916. saveLog(result, requestLog, "2201A", "挂号")
  23917. } else if id_card_type == 2 {
  23918. 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, "", "")
  23919. saveLog(result, requestLog, "2201A", "挂号")
  23920. } else {
  23921. 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, "", "")
  23922. saveLog(result, requestLog, "2201A", "挂号")
  23923. }
  23924. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23925. utils.ErrorLog("解析失败:%v", err)
  23926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23927. return
  23928. }
  23929. infocode = resThree.Infcode
  23930. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23931. psn_info, _ := service.GetPsnByPatientId(id)
  23932. 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)
  23933. saveLog(result, requestLog, "2201A", "挂号")
  23934. if miConfig.Code == "H15049901371" {
  23935. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  23936. utils.ErrorLog("解析失败:%v", err)
  23937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23938. return
  23939. }
  23940. resThree.ErrMsg = resThree10265.ErrMsg
  23941. resThree.Output = resThree10265.Output
  23942. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  23943. } else {
  23944. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23945. utils.ErrorLog("解析失败:%v", err)
  23946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23947. return
  23948. }
  23949. }
  23950. if miConfig.Code == "H15049901371" {
  23951. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  23952. } else {
  23953. infocode = resThree.Infcode
  23954. }
  23955. } else {
  23956. psn_info, _ := service.GetPsnByPatientId(id)
  23957. if id_card_type == 4 || id_card_type == 1 {
  23958. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23959. }
  23960. var rf []*ResultFive
  23961. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  23962. var insutypes []*ResultFive
  23963. var insutype string
  23964. var is390 int = 0
  23965. var is310 int = 0
  23966. for _, item := range rf {
  23967. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23968. insutypes = append(insutypes, item)
  23969. }
  23970. }
  23971. if len(insutypes) == 1 {
  23972. insutype = insutypes[0].Insutype
  23973. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23974. } else {
  23975. for _, i := range insutypes {
  23976. if i.Insutype == "390" {
  23977. is390 = 1
  23978. }
  23979. if i.Insutype == "310" {
  23980. is310 = 1
  23981. }
  23982. }
  23983. }
  23984. if is390 == 1 {
  23985. insutype = "390"
  23986. }
  23987. if is310 == 1 {
  23988. insutype = "310"
  23989. }
  23990. fmt.Println(len(insutypes))
  23991. if len(insutypes) == 0 {
  23992. for index, item := range rf {
  23993. if index == 0 {
  23994. insutype = item.Insutype
  23995. insuplc_admdvs = item.InsuplcAdmdvs
  23996. }
  23997. }
  23998. fmt.Println(insutype)
  23999. fmt.Println(insuplc_admdvs)
  24000. }
  24001. if social_type > 0 {
  24002. insutype = strconv.FormatInt(social_type, 10)
  24003. }
  24004. fmt.Println("--------")
  24005. fmt.Println(psn_info)
  24006. fmt.Println(psn_info.PsnNo)
  24007. if miConfig.MdtrtareaAdmvs == "441202" {
  24008. var hisPrescription []*models.HisPrescription
  24009. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24010. if res3101.Infcode == 0 {
  24011. fmt.Println("33333333")
  24012. if len(res3101.Output.Result) > 0 {
  24013. fmt.Println("222222")
  24014. for _, item := range res3101.Output.Result {
  24015. if len(res3101.ErrMsg) == 0 {
  24016. res3101.ErrMsg = item.VolaCont
  24017. } else {
  24018. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24019. }
  24020. }
  24021. c.ServeSuccessJSON(map[string]interface{}{
  24022. "failed_code": -10,
  24023. "msg": res3101.ErrMsg,
  24024. })
  24025. return
  24026. } else {
  24027. hour := time.Now().Format("15")
  24028. min := time.Now().Format("04")
  24029. sec := time.Now().Format("05")
  24030. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24031. fmt.Println(record_time_two)
  24032. 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)
  24033. saveLog(result, requestLog, "2201A", "挂号")
  24034. if miConfig.Code == "H15049901371" {
  24035. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24036. utils.ErrorLog("解析失败:%v", err)
  24037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24038. return
  24039. }
  24040. resThree.ErrMsg = resThree10265.ErrMsg
  24041. resThree.Output = resThree10265.Output
  24042. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24043. } else {
  24044. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24045. utils.ErrorLog("解析失败:%v", err)
  24046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24047. return
  24048. }
  24049. }
  24050. if miConfig.Code == "H15049901371" {
  24051. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24052. } else {
  24053. infocode = resThree.Infcode
  24054. }
  24055. }
  24056. } else if res3101.Infcode != 0 {
  24057. c.ServeSuccessJSON(map[string]interface{}{
  24058. "failed_code": -10,
  24059. "msg": res3101.ErrMsg,
  24060. })
  24061. return
  24062. }
  24063. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24064. var hisPrescription []*models.HisPrescription
  24065. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24066. if res3101.Infcode == 0 {
  24067. fmt.Println("33333333")
  24068. if len(res3101.Output.Result) > 0 {
  24069. fmt.Println("222222")
  24070. for _, item := range res3101.Output.Result {
  24071. if len(res3101.ErrMsg) == 0 {
  24072. res3101.ErrMsg = item.VolaCont
  24073. } else {
  24074. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24075. }
  24076. }
  24077. c.ServeSuccessJSON(map[string]interface{}{
  24078. "failed_code": -10,
  24079. "msg": res3101.ErrMsg,
  24080. })
  24081. return
  24082. } else {
  24083. hour := time.Now().Format("15")
  24084. min := time.Now().Format("04")
  24085. sec := time.Now().Format("05")
  24086. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24087. fmt.Println(record_time_two)
  24088. 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)
  24089. saveLog(result, requestLog, "2201A", "挂号")
  24090. if miConfig.Code == "H15049901371" {
  24091. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24092. utils.ErrorLog("解析失败:%v", err)
  24093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24094. return
  24095. }
  24096. resThree.ErrMsg = resThree10265.ErrMsg
  24097. resThree.Output = resThree10265.Output
  24098. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24099. } else {
  24100. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24101. utils.ErrorLog("解析失败:%v", err)
  24102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24103. return
  24104. }
  24105. }
  24106. if miConfig.Code == "H15049901371" {
  24107. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24108. } else {
  24109. infocode = resThree.Infcode
  24110. }
  24111. }
  24112. } else if res3101.Infcode != 0 {
  24113. c.ServeSuccessJSON(map[string]interface{}{
  24114. "failed_code": -10,
  24115. "msg": res3101.ErrMsg,
  24116. })
  24117. return
  24118. }
  24119. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24120. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24121. psn_info, _ := service.GetPsnByPatientId(id)
  24122. var verify_number string
  24123. if id_card_type == 4 {
  24124. verify_number = psn_info.VerifyNumber
  24125. } else if id_card_type == 1 {
  24126. bas := strings.Split(psn_info.CardInfo, "|")
  24127. cardNumber := bas[2]
  24128. verify_number = cardNumber
  24129. } else {
  24130. verify_number = psn_info.Certno
  24131. }
  24132. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24133. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24134. "&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
  24135. resp, requestErr := http.Get(api)
  24136. if requestErr != nil {
  24137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24138. return
  24139. }
  24140. body, ioErr := ioutil.ReadAll(resp.Body)
  24141. if ioErr != nil {
  24142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24144. return
  24145. }
  24146. var respJSON map[string]interface{}
  24147. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24150. return
  24151. }
  24152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24153. result, _ := json.Marshal(respJSON)
  24154. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24155. utils.ErrorLog("解析失败:%v", err)
  24156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24157. return
  24158. }
  24159. infocode = resThree.Infcode
  24160. } else {
  24161. hour := time.Now().Format("15")
  24162. min := time.Now().Format("04")
  24163. sec := time.Now().Format("05")
  24164. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24165. if id_card_type == 1 {
  24166. for _, item := range rf {
  24167. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24168. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24169. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24170. } else if strconv.FormatInt(social_type, 10) == "390" {
  24171. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24172. } else {
  24173. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24174. }
  24175. }
  24176. }
  24177. }
  24178. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24179. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24180. }
  24181. if id_card_type == 1 {
  24182. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24183. bas := strings.Split(psn_info.CardInfo, "|")
  24184. basNumber := bas[1]
  24185. IdCardNo = basNumber
  24186. }
  24187. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24188. IdCardNo = psn_info.VerifyNumber
  24189. }
  24190. if len(insuplc_admdvs_temp) == 0 {
  24191. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24192. }
  24193. var result string
  24194. var requestLog string
  24195. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  24196. var hisPrescription []*models.HisPrescription
  24197. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24198. if res3101.Infcode == 0 {
  24199. if len(res3101.Output.Result) > 0 {
  24200. for _, item := range res3101.Output.Result {
  24201. if len(res3101.ErrMsg) == 0 {
  24202. res3101.ErrMsg = item.VolaCont
  24203. } else {
  24204. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24205. }
  24206. }
  24207. c.ServeSuccessJSON(map[string]interface{}{
  24208. "failed_code": -10,
  24209. "msg": res3101.ErrMsg,
  24210. })
  24211. return
  24212. } else {
  24213. hour := time.Now().Format("15")
  24214. min := time.Now().Format("04")
  24215. sec := time.Now().Format("05")
  24216. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24217. fmt.Println(record_time_two)
  24218. 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)
  24219. saveLog(result, requestLog, "2201A", "挂号")
  24220. if miConfig.Code == "H15049901371" {
  24221. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24222. utils.ErrorLog("解析失败:%v", err)
  24223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24224. return
  24225. }
  24226. resThree.ErrMsg = resThree10265.ErrMsg
  24227. resThree.Output = resThree10265.Output
  24228. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24229. } else {
  24230. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24231. utils.ErrorLog("解析失败:%v", err)
  24232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24233. return
  24234. }
  24235. }
  24236. if miConfig.Code == "H15049901371" {
  24237. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24238. } else {
  24239. infocode = resThree.Infcode
  24240. }
  24241. }
  24242. } else if res3101.Infcode != 0 {
  24243. c.ServeSuccessJSON(map[string]interface{}{
  24244. "failed_code": -10,
  24245. "msg": res3101.ErrMsg,
  24246. })
  24247. return
  24248. }
  24249. } else {
  24250. psn_info, _ := service.GetPsnByPatientId(id)
  24251. var rf []*ResultFive
  24252. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24253. //var insutypes []*ResultFive
  24254. var insutype string
  24255. if social_type > 0 {
  24256. insutype = strconv.FormatInt(social_type, 10)
  24257. }
  24258. for _, item := range rf {
  24259. if item.Insutype == insutype {
  24260. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24261. }
  24262. }
  24263. 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)
  24264. saveLog(result, requestLog, "2201A", "挂号")
  24265. }
  24266. if miConfig.Code == "H15049901371" {
  24267. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24268. utils.ErrorLog("解析失败:%v", err)
  24269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24270. return
  24271. }
  24272. resThree.ErrMsg = resThree10265.ErrMsg
  24273. resThree.Output = resThree10265.Output
  24274. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24275. } else {
  24276. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24277. utils.ErrorLog("解析失败:%v", err)
  24278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24279. return
  24280. }
  24281. }
  24282. if miConfig.Code == "H15049901371" {
  24283. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24284. } else {
  24285. infocode = resThree.Infcode
  24286. }
  24287. }
  24288. }
  24289. if infocode == -1 {
  24290. adminUser := c.GetAdminUserInfo()
  24291. errlog := &models.HisOrderError{
  24292. UserOrgId: adminUser.CurrentOrgId,
  24293. Ctime: time.Now().Unix(),
  24294. Mtime: time.Now().Unix(),
  24295. ErrMsg: resThree.ErrMsg,
  24296. Status: 1,
  24297. PatientId: id,
  24298. RecordTime: recordDateTime,
  24299. Stage: 2,
  24300. }
  24301. service.CreateErrMsgLog(errlog)
  24302. c.ServeSuccessJSON(map[string]interface{}{
  24303. "failed_code": -10,
  24304. "msg": resThree.ErrMsg,
  24305. })
  24306. return
  24307. }
  24308. his.Number = resThree.Output.Data.MdtrtID
  24309. his.PsnNo = resThree.Output.Data.PsnNo
  24310. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24311. his.IdCardNo = patient.IdCardNo
  24312. his.PhoneNumber = patient.Phone
  24313. his.UserOrgId = adminInfo.CurrentOrgId
  24314. his.Insutype = insutype
  24315. his.Ctime = time.Now().Unix()
  24316. his.Mtime = time.Now().Unix()
  24317. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24318. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24319. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24320. }
  24321. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24322. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24323. }
  24324. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24325. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24326. }
  24327. his.Status = 1
  24328. his.MdtrtGrpType = mdtrt_type
  24329. service.UpdateHisPatientStatus(&his)
  24330. service.UpdateHisPatient123(&patient)
  24331. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24332. c.ServeSuccessJSON(map[string]interface{}{
  24333. "his_info": his,
  24334. })
  24335. } else {
  24336. adminUser := c.GetAdminUserInfo()
  24337. errlog := &models.HisOrderError{
  24338. UserOrgId: adminUser.CurrentOrgId,
  24339. Ctime: time.Now().Unix(),
  24340. Mtime: time.Now().Unix(),
  24341. ErrMsg: res.ErrMsg,
  24342. Status: 1,
  24343. PatientId: id,
  24344. RecordTime: recordDateTime,
  24345. Stage: 1,
  24346. }
  24347. service.CreateErrMsgLog(errlog)
  24348. c.ServeSuccessJSON(map[string]interface{}{
  24349. "failed_code": -10,
  24350. "msg": res.ErrMsg,
  24351. })
  24352. return
  24353. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24354. }
  24355. }
  24356. }
  24357. func (c *HisApiController) GetUploadInfo() {
  24358. id, _ := c.GetInt64("id")
  24359. record_time := c.GetString("record_time")
  24360. his_patient_id, _ := c.GetInt64("his_patient_id")
  24361. order_id, _ := c.GetInt64("order_id")
  24362. pay_way, _ := c.GetInt64("pay_way")
  24363. pay_ways := c.GetString("pay_ways")
  24364. oth_desc := c.GetString("oth_desc")
  24365. pay_price, _ := c.GetFloat("pay_price")
  24366. pay_card_no := c.GetString("pay_card_no")
  24367. discount_price, _ := c.GetFloat("discount_price")
  24368. preferential_price, _ := c.GetFloat("preferential_price")
  24369. reality_price, _ := c.GetFloat("reality_price")
  24370. found_price, _ := c.GetFloat("found_price")
  24371. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24372. private_price, _ := c.GetFloat("private_price")
  24373. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24374. admin_user_id, _ := c.GetInt64("admin_user_id")
  24375. fapiao_code := c.GetString("fapiao_code")
  24376. fapiao_number := c.GetString("fapiao_number")
  24377. diagnosis_id := c.GetString("diagnosis")
  24378. sick_type, _ := c.GetInt64("sick_type")
  24379. reg_type, _ := c.GetInt64("p_type")
  24380. begin_time := c.GetString("begin_time")
  24381. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24382. cash_pay := c.GetString("cash_pay")
  24383. band_card_pay := c.GetString("band_card_pay")
  24384. wechat_pay := c.GetString("wechat_pay")
  24385. ali_pay := c.GetString("ali_pay")
  24386. jifen_pay := c.GetString("jifen_pay")
  24387. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24388. fmt.Println(acct_used_flag)
  24389. id_str := c.GetString("ids")
  24390. ids_arr := strings.Split(id_str, ",")
  24391. timeLayout := "2006-01-02"
  24392. loc, _ := time.LoadLocation("Local")
  24393. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24394. if err != nil {
  24395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24396. return
  24397. }
  24398. recordDateTime := theTime.Unix()
  24399. adminUser := c.GetAdminUserInfo()
  24400. var tempOrder models.HisOrder
  24401. tempOrder, _ = service.GetHisOrderByID(order_id)
  24402. var prescriptions []*models.HisPrescription
  24403. var start_time int64
  24404. var end_time int64
  24405. //押金模块
  24406. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24407. tmp_decimal := c.GetString("tmp_decimal")
  24408. var decimal float64 //本次使用的押金
  24409. var errmsg error
  24410. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24411. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24412. return
  24413. }
  24414. if len(tmp_decimal) > 0 {
  24415. if tmp_decimal[0] == 45 {
  24416. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24417. return
  24418. }
  24419. }
  24420. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24421. fmt.Println(errs)
  24422. decimal = tt
  24423. //if adminUser.CurrentOrgId == 10106{
  24424. // if len(fapiao_code) == 0{
  24425. // fapiao_code = "144072080589"
  24426. // }
  24427. // if len(fapiao_number) == 0{
  24428. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24429. // if order.ID == 0{
  24430. // fapiao_number = "00001520"
  24431. // }else{
  24432. // //fapiao_code = "00001520"
  24433. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24434. // var zero string
  24435. // if fpNumber >= 1000{
  24436. // zero = "0000" + strconv.Itoa(fpNumber)
  24437. // }else if fpNumber >= 10000{
  24438. // zero = "000" + strconv.Itoa(fpNumber)
  24439. // } else if fpNumber >= 100000{
  24440. // zero = "00" + strconv.Itoa(fpNumber)
  24441. // } else if fpNumber >= 1000000{
  24442. // zero = "0" + strconv.Itoa(fpNumber)
  24443. // }else {
  24444. // zero = strconv.Itoa(fpNumber)
  24445. // }
  24446. // fapiao_number = zero
  24447. // }
  24448. // }
  24449. //}
  24450. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24451. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24452. var patientPrescription models.HisPrescriptionInfo
  24453. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24454. if patientPrescription.ID == 0 {
  24455. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24456. }
  24457. //if patientPrescription.Do
  24458. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24459. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24460. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24461. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24462. var config []*models.HisXtDiagnoseConfig
  24463. for _, item := range diagnosis_ids {
  24464. id, _ := strconv.ParseInt(item, 10, 64)
  24465. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24466. config = append(config, &diagnosisConfig)
  24467. }
  24468. sickConfig, _ := service.FindSickById(sick_type)
  24469. //if tempOrder.ID == 0 {
  24470. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24471. //}
  24472. if tempOrder.ID == 0 {
  24473. var result string
  24474. var requestLog string
  24475. var res2 ResultSix
  24476. var res3 GZResultSix
  24477. var ressix10265 ResultSix10265
  24478. if miConfig.MdtrtareaAdmvs == "421300" {
  24479. data := make(map[string]interface{})
  24480. client := &http.Client{}
  24481. data["psn_no"] = his.PsnNo
  24482. data["mdtrt_id"] = his.Number
  24483. data["opter"] = roles.UserName
  24484. data["org_name"] = miConfig.OrgName
  24485. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24486. data["doctor_id"] = doctor_info.DoctorNumber
  24487. data["doctor_name"] = doctor_info.UserName
  24488. data["department"] = department.Name
  24489. data["fixmedins_code"] = miConfig.Code
  24490. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24491. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24492. data["secret_key"] = miConfig.SecretKey
  24493. data["sick_code"] = sickConfig.CountryCode
  24494. data["sick_name"] = sickConfig.ClassName
  24495. data["dept"] = strconv.FormatInt(department.ID, 10)
  24496. data["config"] = config
  24497. data["begin_time"] = begin_time
  24498. bytesData, _ := json.Marshal(data)
  24499. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24500. resp, _ := client.Do(req)
  24501. defer resp.Body.Close()
  24502. body, ioErr := ioutil.ReadAll(resp.Body)
  24503. if ioErr != nil {
  24504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24506. return
  24507. }
  24508. var respJSON map[string]interface{}
  24509. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24512. return
  24513. }
  24514. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24515. userJSONBytes, _ := json.Marshal(respJSON)
  24516. fmt.Println("log")
  24517. fmt.Println(string(userJSONBytes))
  24518. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24519. utils.ErrorLog("解析失败:%v", err)
  24520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24521. return
  24522. }
  24523. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24524. data := make(map[string]interface{})
  24525. client := &http.Client{}
  24526. data["psn_no"] = his.PsnNo
  24527. data["mdtrt_id"] = his.Number
  24528. data["opter"] = roles.UserName
  24529. data["org_name"] = miConfig.OrgName
  24530. if reg_type == 11 && his.Insutype == "390" {
  24531. data["med_type"] = "110104"
  24532. } else {
  24533. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24534. }
  24535. data["doctor_id"] = doctor_info.DoctorNumber
  24536. data["doctor_name"] = doctor_info.UserName
  24537. data["department"] = department.Name
  24538. data["fixmedins_code"] = miConfig.Code
  24539. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24540. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24541. data["secret_key"] = miConfig.SecretKey
  24542. data["sick_code"] = sickConfig.CountryCode
  24543. data["sick_name"] = sickConfig.ClassName
  24544. data["dept"] = strconv.FormatInt(department.ID, 10)
  24545. data["config"] = config
  24546. data["begin_time"] = begin_time
  24547. bytesData, _ := json.Marshal(data)
  24548. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24549. resp, _ := client.Do(req)
  24550. defer resp.Body.Close()
  24551. body, ioErr := ioutil.ReadAll(resp.Body)
  24552. if ioErr != nil {
  24553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24555. return
  24556. }
  24557. var respJSON map[string]interface{}
  24558. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24561. return
  24562. }
  24563. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24564. userJSONBytes, _ := json.Marshal(respJSON)
  24565. fmt.Println("log")
  24566. fmt.Println(string(userJSONBytes))
  24567. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24568. utils.ErrorLog("解析失败:%v", err)
  24569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24570. return
  24571. }
  24572. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24573. data := make(map[string]interface{})
  24574. client := &http.Client{}
  24575. data["psn_no"] = his.PsnNo
  24576. data["mdtrt_id"] = his.Number
  24577. data["opter"] = roles.UserName
  24578. data["org_name"] = miConfig.OrgName
  24579. if reg_type == 11 && his.Insutype == "390" {
  24580. data["med_type"] = "110104"
  24581. } else {
  24582. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24583. }
  24584. data["doctor_id"] = doctor_info.DoctorNumber
  24585. data["doctor_name"] = doctor_info.UserName
  24586. data["department"] = department.Name
  24587. data["fixmedins_code"] = miConfig.Code
  24588. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24589. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24590. data["secret_key"] = miConfig.SecretKey
  24591. data["sick_code"] = sickConfig.CountryCode
  24592. data["sick_name"] = sickConfig.ClassName
  24593. data["dept"] = strconv.FormatInt(department.ID, 10)
  24594. data["config"] = config
  24595. data["begin_time"] = begin_time
  24596. bytesData, _ := json.Marshal(data)
  24597. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24598. resp, _ := client.Do(req)
  24599. defer resp.Body.Close()
  24600. body, ioErr := ioutil.ReadAll(resp.Body)
  24601. if ioErr != nil {
  24602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24604. return
  24605. }
  24606. var respJSON map[string]interface{}
  24607. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24610. return
  24611. }
  24612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24613. userJSONBytes, _ := json.Marshal(respJSON)
  24614. fmt.Println("log")
  24615. fmt.Println(string(userJSONBytes))
  24616. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24617. utils.ErrorLog("解析失败:%v", err)
  24618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24619. return
  24620. }
  24621. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24622. data := make(map[string]interface{})
  24623. client := &http.Client{}
  24624. data["psn_no"] = his.PsnNo
  24625. data["mdtrt_id"] = his.Number
  24626. data["opter"] = roles.UserName
  24627. data["org_name"] = miConfig.OrgName
  24628. if reg_type == 11 && his.Insutype == "390" {
  24629. data["med_type"] = "110104"
  24630. } else {
  24631. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24632. }
  24633. data["doctor_id"] = doctor_info.DoctorNumber
  24634. data["doctor_name"] = doctor_info.UserName
  24635. data["department"] = department.Name
  24636. data["fixmedins_code"] = miConfig.Code
  24637. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24638. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24639. data["secret_key"] = miConfig.SecretKey
  24640. data["sick_code"] = sickConfig.CountryCode
  24641. data["sick_name"] = sickConfig.ClassName
  24642. data["dept"] = strconv.FormatInt(department.ID, 10)
  24643. data["config"] = config
  24644. data["begin_time"] = begin_time
  24645. bytesData, _ := json.Marshal(data)
  24646. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  24647. resp, _ := client.Do(req)
  24648. defer resp.Body.Close()
  24649. body, ioErr := ioutil.ReadAll(resp.Body)
  24650. if ioErr != nil {
  24651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24653. return
  24654. }
  24655. var respJSON map[string]interface{}
  24656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24659. return
  24660. }
  24661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24662. userJSONBytes, _ := json.Marshal(respJSON)
  24663. fmt.Println("log")
  24664. fmt.Println(string(userJSONBytes))
  24665. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24666. utils.ErrorLog("解析失败:%v", err)
  24667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24668. return
  24669. }
  24670. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24671. data := make(map[string]interface{})
  24672. client := &http.Client{}
  24673. data["psn_no"] = his.PsnNo
  24674. data["mdtrt_id"] = his.Number
  24675. data["doctor"] = roles.UserName
  24676. data["department"] = department.Name
  24677. data["org_name"] = miConfig.OrgName
  24678. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24679. data["doctor_id"] = doctor_info.DoctorNumber
  24680. data["new_doctor_name"] = doctor_info.UserName
  24681. data["fixmedins_code"] = miConfig.Code
  24682. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24683. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24684. data["secret_key"] = miConfig.SecretKey
  24685. data["sick_code"] = sickConfig.CountryCode
  24686. data["sick_name"] = sickConfig.ClassName
  24687. data["url"] = miConfig.Url
  24688. data["ak"] = miConfig.AccessKey
  24689. data["begin_time"] = begin_time
  24690. data["cainfo"] = miConfig.Cainfo
  24691. data["dept"] = strconv.FormatInt(department.ID, 10)
  24692. data["config"] = config
  24693. bytesData, _ := json.Marshal(data)
  24694. var req *http.Request
  24695. if miConfig.MdtrtareaAdmvs == "320921" {
  24696. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24697. //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 +
  24698. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  24699. } else {
  24700. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  24701. }
  24702. resp, _ := client.Do(req)
  24703. defer resp.Body.Close()
  24704. body, ioErr := ioutil.ReadAll(resp.Body)
  24705. if ioErr != nil {
  24706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24708. return
  24709. }
  24710. var respJSON map[string]interface{}
  24711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24714. return
  24715. }
  24716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24717. userJSONBytes, _ := json.Marshal(respJSON)
  24718. fmt.Println("log")
  24719. fmt.Println(string(userJSONBytes))
  24720. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  24721. utils.ErrorLog("解析失败:%v", err)
  24722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24723. return
  24724. }
  24725. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24726. res2.Output = ressix10265.Output
  24727. res2.ErrMsg = ressix10265.ErrMsg
  24728. res2.Cainfo = ressix10265.Cainfo
  24729. res2.WarnMsg = ressix10265.WarnMsg
  24730. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24731. res2.Infcode = infocode
  24732. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24733. data := make(map[string]interface{})
  24734. client := &http.Client{}
  24735. data["psn_no"] = his.PsnNo
  24736. data["mdtrt_id"] = his.Number
  24737. data["doctor"] = roles.UserName
  24738. data["department"] = department.Name
  24739. data["org_name"] = miConfig.OrgName
  24740. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24741. data["doctor_id"] = doctor_info.DoctorNumber
  24742. data["new_doctor_name"] = doctor_info.UserName
  24743. data["fixmedins_code"] = miConfig.Code
  24744. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24745. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24746. data["secret_key"] = miConfig.SecretKey
  24747. data["sick_code"] = sickConfig.CountryCode
  24748. data["sick_name"] = sickConfig.ClassName
  24749. data["url"] = miConfig.Url
  24750. data["ak"] = miConfig.AccessKey
  24751. data["begin_time"] = begin_time
  24752. data["cainfo"] = miConfig.Cainfo
  24753. data["dept"] = strconv.FormatInt(department.ID, 10)
  24754. data["config"] = config
  24755. bytesData, _ := json.Marshal(data)
  24756. var req *http.Request
  24757. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  24758. resp, _ := client.Do(req)
  24759. defer resp.Body.Close()
  24760. body, ioErr := ioutil.ReadAll(resp.Body)
  24761. if ioErr != nil {
  24762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24764. return
  24765. }
  24766. var respJSON map[string]interface{}
  24767. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24770. return
  24771. }
  24772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24773. userJSONBytes, _ := json.Marshal(respJSON)
  24774. fmt.Println("log")
  24775. fmt.Println(string(userJSONBytes))
  24776. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  24777. utils.ErrorLog("解析失败:%v", err)
  24778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24779. return
  24780. }
  24781. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24782. res2.Output = ressix10265.Output
  24783. res2.ErrMsg = ressix10265.ErrMsg
  24784. res2.Cainfo = ressix10265.Cainfo
  24785. res2.WarnMsg = ressix10265.WarnMsg
  24786. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24787. res2.Infcode = infocode
  24788. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24789. 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)
  24790. saveLog(result, requestLog, "2203", "上传就诊信息")
  24791. var respJSON2 map[string]interface{}
  24792. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  24793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24795. return
  24796. }
  24797. userJSONBytes2, _ := json.Marshal(respJSON2)
  24798. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  24799. utils.ErrorLog("解析失败:%v", err)
  24800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24801. return
  24802. }
  24803. 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)
  24804. fmt.Println(result2)
  24805. fmt.Println(src_request)
  24806. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24807. data := make(map[string]interface{})
  24808. client := &http.Client{}
  24809. data["psn_no"] = his.PsnNo
  24810. data["mdtrt_id"] = his.Number
  24811. data["doctor"] = roles.UserName
  24812. data["department"] = department.Name
  24813. data["org_name"] = miConfig.OrgName
  24814. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24815. data["doctor_id"] = doctor_info.DoctorNumber
  24816. data["new_doctor_name"] = doctor_info.UserName
  24817. data["fixmedins_code"] = miConfig.Code
  24818. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24819. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24820. data["secret_key"] = miConfig.SecretKey
  24821. data["sick_code"] = sickConfig.CountryCode
  24822. data["sick_name"] = sickConfig.ClassName
  24823. data["url"] = miConfig.Url
  24824. data["ak"] = miConfig.AccessKey
  24825. data["begin_time"] = begin_time
  24826. data["cainfo"] = miConfig.Cainfo
  24827. data["dept"] = strconv.FormatInt(department.ID, 10)
  24828. data["config"] = config
  24829. bytesData, _ := json.Marshal(data)
  24830. var req *http.Request
  24831. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  24832. resp, _ := client.Do(req)
  24833. defer resp.Body.Close()
  24834. body, ioErr := ioutil.ReadAll(resp.Body)
  24835. if ioErr != nil {
  24836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24838. return
  24839. }
  24840. var respJSON map[string]interface{}
  24841. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24844. return
  24845. }
  24846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24847. userJSONBytes, _ := json.Marshal(respJSON)
  24848. fmt.Println("log")
  24849. fmt.Println(string(userJSONBytes))
  24850. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24851. utils.ErrorLog("解析失败:%v", err)
  24852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24853. return
  24854. }
  24855. } else {
  24856. if miConfig.MdtrtareaAdmvs == "440781" { //
  24857. 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)
  24858. } else {
  24859. if miConfig.Code == "H15049901371" {
  24860. //赤峰地区国家医保医疗类别
  24861. //职工透析:医疗类别选特殊情况门诊990502
  24862. //居民定额血透门慢: 医疗类别选门诊慢病140104
  24863. var med_type string
  24864. if his.Insutype == "390" {
  24865. if reg_type == 14 {
  24866. med_type = "9933"
  24867. } else if reg_type == 11 {
  24868. med_type = "11"
  24869. }
  24870. } else if his.Insutype == "310" {
  24871. if reg_type == 14 {
  24872. med_type = "990502"
  24873. } else if reg_type == 11 {
  24874. med_type = "11"
  24875. }
  24876. }
  24877. 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)
  24878. } else {
  24879. 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)
  24880. }
  24881. }
  24882. saveLog(result, requestLog, "2203", "上传就诊信息")
  24883. var respJSON2 map[string]interface{}
  24884. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  24885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24887. return
  24888. }
  24889. userJSONBytes2, _ := json.Marshal(respJSON2)
  24890. if miConfig.Code == "H15049901371" {
  24891. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  24892. utils.ErrorLog("解析失败:%v", err)
  24893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24894. return
  24895. }
  24896. res2.InfRefmsgid = ressix10265.InfRefmsgid
  24897. res2.Output = ressix10265.Output
  24898. res2.ErrMsg = ressix10265.ErrMsg
  24899. res2.Cainfo = ressix10265.Cainfo
  24900. res2.WarnMsg = ressix10265.WarnMsg
  24901. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  24902. res2.Infcode = infocode
  24903. } else {
  24904. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24905. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  24906. utils.ErrorLog("解析失败:%v", err)
  24907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24908. return
  24909. }
  24910. res2.Infcode = res3.Infcode
  24911. } else {
  24912. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  24913. utils.ErrorLog("解析失败:%v", err)
  24914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24915. return
  24916. }
  24917. }
  24918. }
  24919. }
  24920. if res2.Infcode == -1 {
  24921. adminUser := c.GetAdminUserInfo()
  24922. errlog := &models.HisOrderError{
  24923. UserOrgId: adminUser.CurrentOrgId,
  24924. Ctime: time.Now().Unix(),
  24925. Mtime: time.Now().Unix(),
  24926. ErrMsg: res2.ErrMsg,
  24927. Status: 1,
  24928. PatientId: id,
  24929. RecordTime: recordDateTime,
  24930. Stage: 3,
  24931. }
  24932. service.CreateErrMsgLog(errlog)
  24933. c.ServeSuccessJSON(map[string]interface{}{
  24934. "failed_code": -10,
  24935. "msg": res2.ErrMsg,
  24936. })
  24937. return
  24938. } else {
  24939. his.Diagnosis = diagnosis_id
  24940. his.SickType = sickConfig.ID
  24941. //var p_type int64
  24942. //if reg_type == 1111 || reg_type == 1112 {
  24943. // p_type = 11
  24944. //
  24945. //}
  24946. his.PType = fmt.Sprintf("%d", reg_type)
  24947. service.UpdateHisPatientThree(&his)
  24948. data := make(map[string]interface{})
  24949. if settle_accounts_type == 1 { //日结
  24950. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  24951. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  24952. } else {
  24953. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  24954. }
  24955. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  24956. data["pre"] = prescriptions
  24957. } else { //月结
  24958. start_time_str := c.GetString("start_time")
  24959. end_time_str := c.GetString("end_time")
  24960. timeLayout := "2006-01-02"
  24961. loc, _ := time.LoadLocation("Local")
  24962. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  24963. if err != nil {
  24964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24965. return
  24966. }
  24967. recordStartTime := theStartTime.Unix()
  24968. start_time = recordStartTime
  24969. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  24970. if err != nil {
  24971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24972. return
  24973. }
  24974. recordEndTime := theEndTime.Unix()
  24975. end_time = recordEndTime
  24976. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  24977. data["pre"] = prescriptions
  24978. }
  24979. timestamp := time.Now().Unix()
  24980. tempTime := time.Unix(timestamp, 0)
  24981. timeFormat := tempTime.Format("20060102150405")
  24982. chrgBchno := rand.Intn(100000) + 10000
  24983. new_chrg_bchno := ""
  24984. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  24985. new_chrg_bchno = chrg_bchno
  24986. strconv.FormatInt(his.PatientId, 10)
  24987. client := &http.Client{}
  24988. if adminUser.CurrentOrgId == 10265 {
  24989. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  24990. new_chrg_bchno = "0000"
  24991. }
  24992. }
  24993. data["psn_no"] = his.PsnNo
  24994. data["mdtrt_id"] = his.Number
  24995. data["chrg_bchno"] = new_chrg_bchno
  24996. data["org_name"] = miConfig.OrgName
  24997. data["doctor"] = doctor_info.UserName
  24998. data["doctor_id"] = doctor_info.DoctorNumber
  24999. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25000. data["fixmedins_code"] = miConfig.Code
  25001. data["dept_code"] = department.Number
  25002. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25003. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25004. data["secret_key"] = miConfig.SecretKey
  25005. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25006. data["url"] = miConfig.Url
  25007. data["ak"] = miConfig.AccessKey
  25008. data["new_doctor_name"] = patientPrescription.Doctor
  25009. data["diag_code"] = sickConfig.CountryCode
  25010. data["cainfo"] = miConfig.Cainfo
  25011. data["opter"] = roles.UserName
  25012. var ids []int64
  25013. for _, item := range prescriptions {
  25014. ids = append(ids, item.ID)
  25015. }
  25016. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25017. if config.IsOpen == 1 { //对接了医保,走医保流程
  25018. var res ResultFour
  25019. var resFour10265 ResultFour10265
  25020. if miConfig.MdtrtareaAdmvs == "421300" {
  25021. bytesData, _ := json.Marshal(data)
  25022. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25023. resp, _ := client.Do(req)
  25024. defer resp.Body.Close()
  25025. body, ioErr := ioutil.ReadAll(resp.Body)
  25026. if ioErr != nil {
  25027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25029. return
  25030. }
  25031. var respJSON map[string]interface{}
  25032. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25035. return
  25036. }
  25037. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25038. userJSONBytes, _ := json.Marshal(respJSON)
  25039. fmt.Println("log")
  25040. fmt.Println(string(userJSONBytes))
  25041. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25042. utils.ErrorLog("解析失败:%v", err)
  25043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25044. return
  25045. }
  25046. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25047. bytesData, _ := json.Marshal(data)
  25048. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25049. resp, _ := client.Do(req)
  25050. defer resp.Body.Close()
  25051. body, ioErr := ioutil.ReadAll(resp.Body)
  25052. if ioErr != nil {
  25053. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25055. return
  25056. }
  25057. var respJSON map[string]interface{}
  25058. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25059. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25061. return
  25062. }
  25063. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25064. userJSONBytes, _ := json.Marshal(respJSON)
  25065. fmt.Println("log")
  25066. fmt.Println(string(userJSONBytes))
  25067. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25068. utils.ErrorLog("解析失败:%v", err)
  25069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25070. return
  25071. }
  25072. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25073. bytesData, _ := json.Marshal(data)
  25074. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25075. resp, _ := client.Do(req)
  25076. defer resp.Body.Close()
  25077. body, ioErr := ioutil.ReadAll(resp.Body)
  25078. if ioErr != nil {
  25079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25081. return
  25082. }
  25083. var respJSON map[string]interface{}
  25084. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25087. return
  25088. }
  25089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25090. userJSONBytes, _ := json.Marshal(respJSON)
  25091. fmt.Println("log")
  25092. fmt.Println(string(userJSONBytes))
  25093. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25094. utils.ErrorLog("解析失败:%v", err)
  25095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25096. return
  25097. }
  25098. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25099. bytesData, _ := json.Marshal(data)
  25100. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25101. resp, _ := client.Do(req)
  25102. defer resp.Body.Close()
  25103. body, ioErr := ioutil.ReadAll(resp.Body)
  25104. if ioErr != nil {
  25105. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25107. return
  25108. }
  25109. var respJSON map[string]interface{}
  25110. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25111. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25113. return
  25114. }
  25115. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25116. userJSONBytes, _ := json.Marshal(respJSON)
  25117. fmt.Println("log")
  25118. fmt.Println(string(userJSONBytes))
  25119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25120. utils.ErrorLog("解析失败:%v", err)
  25121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25122. return
  25123. }
  25124. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25125. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25126. if result3101.Infcode == "0" {
  25127. if len(result3101.Output.Result) > 0 {
  25128. var errMsgs []string
  25129. for _, item := range result3101.Output.Result {
  25130. errMsgs = append(errMsgs, item.VolaCont)
  25131. }
  25132. c.ServeSuccessJSON(map[string]interface{}{
  25133. "failed_code": -10,
  25134. "msg": errMsgs,
  25135. })
  25136. return
  25137. }
  25138. }
  25139. bytesData, _ := json.Marshal(data)
  25140. var req *http.Request
  25141. if miConfig.MdtrtareaAdmvs == "320921" {
  25142. data["diag_code"] = sickConfig.CountryCode
  25143. fmt.Println(data)
  25144. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25145. } else {
  25146. data["diag_code"] = sickConfig.CountryCode
  25147. fmt.Println(data)
  25148. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25149. }
  25150. resp, _ := client.Do(req)
  25151. defer resp.Body.Close()
  25152. body, ioErr := ioutil.ReadAll(resp.Body)
  25153. if ioErr != nil {
  25154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25156. return
  25157. }
  25158. var respJSON map[string]interface{}
  25159. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25162. return
  25163. }
  25164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25165. userJSONBytes, _ := json.Marshal(respJSON)
  25166. fmt.Println("log")
  25167. fmt.Println(string(userJSONBytes))
  25168. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25169. utils.ErrorLog("解析失败:%v", err)
  25170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25171. return
  25172. }
  25173. res.InfRefmsgid = resFour10265.InfRefmsgid
  25174. res.Output = resFour10265.Output
  25175. res.ErrMsg = resFour10265.ErrMsg
  25176. res.Cainfo = resFour10265.Cainfo
  25177. res.WarnMsg = resFour10265.WarnMsg
  25178. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25179. res.Infcode = infocode
  25180. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25181. var pagesize int = 2
  25182. var start int = 1
  25183. var stop int
  25184. var pagecount int
  25185. var curpage int
  25186. var isSuccess bool = true
  25187. data["doctor_id"] = doctor_info.DoctorNumber
  25188. //总页数,向上取整,注意除之前要先转换类型为float64
  25189. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25190. for curpage = 1; curpage <= pagecount; curpage++ {
  25191. if curpage == 1 {
  25192. start = 1
  25193. } else {
  25194. start = (curpage-1)*pagesize + 1
  25195. }
  25196. stop = curpage * pagesize
  25197. if stop > len(prescriptions) {
  25198. stop = len(prescriptions)
  25199. }
  25200. //var requestLog string
  25201. data["pre"] = prescriptions[start-1 : stop]
  25202. fmt.Println(data["pre"])
  25203. bytesData, _ := json.Marshal(data)
  25204. var req *http.Request
  25205. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25206. resp, _ := client.Do(req)
  25207. defer resp.Body.Close()
  25208. body, ioErr := ioutil.ReadAll(resp.Body)
  25209. if ioErr != nil {
  25210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25212. return
  25213. }
  25214. var respJSON map[string]interface{}
  25215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25218. return
  25219. }
  25220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25221. userJSONBytes, _ := json.Marshal(respJSON)
  25222. fmt.Println("log")
  25223. fmt.Println(string(userJSONBytes))
  25224. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25225. utils.ErrorLog("解析失败:%v", err)
  25226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25227. return
  25228. }
  25229. res.InfRefmsgid = resFour10265.InfRefmsgid
  25230. res.Output = resFour10265.Output
  25231. res.ErrMsg = resFour10265.ErrMsg
  25232. res.Cainfo = resFour10265.Cainfo
  25233. res.WarnMsg = resFour10265.WarnMsg
  25234. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25235. res.Infcode = infocode
  25236. if infocode == 0 {
  25237. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25238. } else {
  25239. isSuccess = false
  25240. errlog := &models.HisOrderError{
  25241. UserOrgId: adminUser.CurrentOrgId,
  25242. Ctime: time.Now().Unix(),
  25243. Mtime: time.Now().Unix(),
  25244. Number: chrg_bchno,
  25245. ErrMsg: "",
  25246. Status: 1,
  25247. PatientId: id,
  25248. RecordTime: recordDateTime,
  25249. Stage: 4,
  25250. }
  25251. service.CreateErrMsgLog(errlog)
  25252. c.ServeSuccessJSON(map[string]interface{}{
  25253. "failed_code": -10,
  25254. "msg": res.ErrMsg,
  25255. })
  25256. return
  25257. }
  25258. }
  25259. if isSuccess {
  25260. res.Infcode = 0
  25261. }
  25262. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25263. 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)
  25264. var dat map[string]interface{}
  25265. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25266. fmt.Println(dat)
  25267. } else {
  25268. fmt.Println(err)
  25269. }
  25270. saveLog(result, request_log, "2204", "上传费用明细")
  25271. userJSONBytes, _ := json.Marshal(dat)
  25272. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25273. utils.ErrorLog("解析失败:%v", err)
  25274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25275. return
  25276. }
  25277. res.InfRefmsgid = resFour10265.InfRefmsgid
  25278. res.Output = resFour10265.Output
  25279. res.ErrMsg = resFour10265.ErrMsg
  25280. res.Cainfo = resFour10265.Cainfo
  25281. res.WarnMsg = resFour10265.WarnMsg
  25282. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25283. res.Infcode = infocode
  25284. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25285. bytesData, _ := json.Marshal(data)
  25286. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25287. resp, _ := client.Do(req)
  25288. defer resp.Body.Close()
  25289. body, ioErr := ioutil.ReadAll(resp.Body)
  25290. if ioErr != nil {
  25291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25293. return
  25294. }
  25295. var respJSON map[string]interface{}
  25296. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25299. return
  25300. }
  25301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25302. userJSONBytes, _ := json.Marshal(respJSON)
  25303. fmt.Println("log")
  25304. fmt.Println(string(userJSONBytes))
  25305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25306. utils.ErrorLog("解析失败:%v", err)
  25307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25308. return
  25309. }
  25310. } else {
  25311. if miConfig.Code == "H15049901371" {
  25312. 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)
  25313. var dat map[string]interface{}
  25314. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25315. fmt.Println(dat)
  25316. } else {
  25317. fmt.Println(err)
  25318. }
  25319. saveLog(result, request_log, "2204", "上传费用明细")
  25320. userJSONBytes, _ := json.Marshal(dat)
  25321. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25322. utils.ErrorLog("解析失败:%v", err)
  25323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25324. return
  25325. }
  25326. res.InfRefmsgid = resFour10265.InfRefmsgid
  25327. res.Output = resFour10265.Output
  25328. res.ErrMsg = resFour10265.ErrMsg
  25329. res.Cainfo = resFour10265.Cainfo
  25330. res.WarnMsg = resFour10265.WarnMsg
  25331. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25332. res.Infcode = infocode
  25333. } else {
  25334. 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)
  25335. var dat map[string]interface{}
  25336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25337. fmt.Println(dat)
  25338. } else {
  25339. fmt.Println(err)
  25340. }
  25341. saveLog(result, request_log, "2204", "上传费用明细")
  25342. userJSONBytes, _ := json.Marshal(dat)
  25343. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25344. utils.ErrorLog("解析失败:%v", err)
  25345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25346. return
  25347. }
  25348. }
  25349. }
  25350. if res.Infcode == 0 {
  25351. order := &models.HisOrder{
  25352. UserOrgId: adminUser.CurrentOrgId,
  25353. HisPatientId: his.ID,
  25354. PatientId: his.PatientId,
  25355. SettleAccountsDate: recordDateTime,
  25356. MdtrtId: his.Number,
  25357. PsnNo: his.PsnNo,
  25358. MedType: strconv.FormatInt(reg_type, 10),
  25359. Ctime: time.Now().Unix(),
  25360. Mtime: time.Now().Unix(),
  25361. Status: 1,
  25362. Number: chrg_bchno,
  25363. Infcode: res.Infcode,
  25364. WarnMsg: res.WarnMsg,
  25365. Cainfo: res.Cainfo,
  25366. ErrMsg: res.ErrMsg,
  25367. RespondTime: res.RefmsgTime,
  25368. InfRefmsgid: res.InfRefmsgid,
  25369. OrderStatus: 1,
  25370. PayWay: pay_way,
  25371. PayWays: pay_ways,
  25372. OthDesc: oth_desc,
  25373. PayPrice: pay_price,
  25374. PayCardNo: pay_card_no,
  25375. DiscountPrice: discount_price,
  25376. PreferentialPrice: preferential_price,
  25377. RealityPrice: reality_price,
  25378. FoundPrice: found_price,
  25379. MedicalInsurancePrice: medical_insurance_price,
  25380. PrivatePrice: private_price,
  25381. IsMedicineInsurance: 1,
  25382. SettleType: settle_accounts_type,
  25383. SettleStartTime: start_time,
  25384. SettleEndTime: end_time,
  25385. Creator: roles.AdminUserId,
  25386. Modify: roles.AdminUserId,
  25387. FaPiaoNumber: fapiao_number,
  25388. FaPiaoCode: fapiao_code,
  25389. PType: 2,
  25390. Diagnosis: diagnosis_id,
  25391. CashPay: cash_pay,
  25392. WechatPay: wechat_pay,
  25393. AliPay: ali_pay,
  25394. JifenPay: jifen_pay,
  25395. BandCardPay: band_card_pay,
  25396. }
  25397. err = service.CreateOrder(order)
  25398. if err != nil {
  25399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25400. return
  25401. }
  25402. for _, item := range res.Output.Result {
  25403. temp := strings.Split(item.FeedetlSn, "-")
  25404. var advice_id int64 = 0
  25405. var project_id int64 = 0
  25406. var types int64 = 0
  25407. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25408. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25409. if temp[1] == "1" {
  25410. advice_id = id
  25411. project_id = 0
  25412. } else if temp[1] == "2" {
  25413. advice_id = 0
  25414. project_id = id
  25415. }
  25416. if item.MedChrgitmType == "9" {
  25417. item.MedChrgitmType = "09"
  25418. }
  25419. info := &models.HisOrderInfo{
  25420. OrderNumber: order.Number,
  25421. FeedetlSn: item.FeedetlSn,
  25422. UploadDate: time.Now().Unix(),
  25423. AdviceId: advice_id,
  25424. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25425. Cnt: item.Cnt,
  25426. Pric: float64(item.Pric),
  25427. PatientId: his.PatientId,
  25428. PricUplmtAmt: item.PricUplmtAmt,
  25429. SelfpayProp: item.SelfpayProp,
  25430. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25431. OverlmtAmt: item.OverlmtAmt,
  25432. PreselfpayAmt: item.PreselfpayAmt,
  25433. BasMednFlag: item.BasMednFlag,
  25434. MedChrgitmType: item.MedChrgitmType,
  25435. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25436. Status: 1,
  25437. Memo: item.Memo,
  25438. Mtime: time.Now().Unix(),
  25439. InscpScpAmt: item.InscpScpAmt,
  25440. DrtReimFlag: item.DrtReimFlag,
  25441. Ctime: time.Now().Unix(),
  25442. ListSpItemFlag: item.ListSpItemFlag,
  25443. ChldMedcFlag: item.ChldMedcFlag,
  25444. LmtUsedFlag: item.LmtUsedFlag,
  25445. ChrgitmLv: item.ChrgitmLv,
  25446. UserOrgId: adminUser.CurrentOrgId,
  25447. HisPatientId: his.ID,
  25448. OrderId: order.ID,
  25449. ProjectId: project_id,
  25450. Type: types,
  25451. }
  25452. service.CreateOrderInfo(info)
  25453. }
  25454. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25455. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25456. var total float64
  25457. for _, item := range prescriptions {
  25458. if item.Type == 1 { //药品
  25459. for _, subItem := range item.HisDoctorAdviceInfo {
  25460. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25461. total_one := price * subItem.PrescribingNumber
  25462. total = total + total_one
  25463. }
  25464. }
  25465. if item.Type == 2 { //项目
  25466. for _, subItem := range item.HisPrescriptionProject {
  25467. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25468. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25469. total_one := price * cnt
  25470. total = total + total_one
  25471. }
  25472. }
  25473. }
  25474. allTotal := fmt.Sprintf("%.2f", total)
  25475. //if adminUser.CurrentOrgId == 9919 {
  25476. //
  25477. // allTotal = fmt.Sprintf("%.2f", total)
  25478. //
  25479. //} else {
  25480. //
  25481. // allTotal = fmt.Sprintf("%.2f", total)
  25482. //
  25483. //}
  25484. if res.Infcode == 0 {
  25485. var rf []*ResultFive
  25486. json.Unmarshal([]byte(his.Iinfo), &rf)
  25487. chrg_bchno := chrg_bchno
  25488. cert_no := his.Certno
  25489. var insutypes []string
  25490. var insutype string
  25491. var is390 int = 0
  25492. var is310 int = 0
  25493. for _, item := range rf {
  25494. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25495. insutypes = append(insutypes, item.Insutype)
  25496. }
  25497. }
  25498. if len(insutypes) == 1 {
  25499. insutype = insutypes[0]
  25500. } else {
  25501. for _, i := range insutypes {
  25502. if i == "390" {
  25503. is390 = 1
  25504. }
  25505. if i == "310" {
  25506. is310 = 1
  25507. }
  25508. }
  25509. }
  25510. if is390 == 1 {
  25511. insutype = "390"
  25512. }
  25513. if is310 == 1 {
  25514. insutype = "310"
  25515. }
  25516. if len(insutypes) == 0 {
  25517. insutype = "310"
  25518. }
  25519. if len(insutypes) == 2 {
  25520. insutype = strconv.FormatInt(his.SocialType, 10)
  25521. }
  25522. insutype = strconv.FormatInt(his.SocialType, 10)
  25523. //insutype = "390"
  25524. if his.IdCardType == 1 {
  25525. // cert_no = his.MedicalInsuranceNumber
  25526. cert_no = his.Certno
  25527. } else {
  25528. cert_no = his.Certno
  25529. }
  25530. var res ResultSeven
  25531. var resSeven10265 ResultSeven10265
  25532. var gzresSeven10265Two GZResultSeven10265Two
  25533. var src_resquest string
  25534. var result2 string
  25535. if miConfig.MdtrtareaAdmvs == "421300" {
  25536. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25537. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25538. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25539. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25540. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25541. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25542. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25543. resp, requestErr := http.Get(api)
  25544. if requestErr != nil {
  25545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25546. return
  25547. }
  25548. body, ioErr := ioutil.ReadAll(resp.Body)
  25549. if ioErr != nil {
  25550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25552. return
  25553. }
  25554. var respJSON map[string]interface{}
  25555. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25558. return
  25559. }
  25560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25561. result, _ := json.Marshal(respJSON)
  25562. if miConfig.Code == "H15049901371" {
  25563. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25564. utils.ErrorLog("解析失败:%v", err)
  25565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25566. return
  25567. }
  25568. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25569. res.Output = resSeven10265.Output
  25570. res.ErrMsg = resSeven10265.ErrMsg
  25571. res.Cainfo = resSeven10265.Cainfo
  25572. res.WarnMsg = resSeven10265.WarnMsg
  25573. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25574. res.Infcode = infocode
  25575. } else {
  25576. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25577. utils.ErrorLog("解析失败:%v", err)
  25578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25579. return
  25580. }
  25581. }
  25582. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25583. if reg_type == 11 && his.Insutype == "390" {
  25584. reg_type = 110104
  25585. }
  25586. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25587. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25588. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25589. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25590. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25591. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25592. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25593. resp, requestErr := http.Get(api)
  25594. if requestErr != nil {
  25595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25596. return
  25597. }
  25598. body, ioErr := ioutil.ReadAll(resp.Body)
  25599. if ioErr != nil {
  25600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25602. return
  25603. }
  25604. var respJSON map[string]interface{}
  25605. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25608. return
  25609. }
  25610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25611. result, _ := json.Marshal(respJSON)
  25612. if miConfig.Code == "H15049901371" {
  25613. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25614. utils.ErrorLog("解析失败:%v", err)
  25615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25616. return
  25617. }
  25618. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25619. res.Output = resSeven10265.Output
  25620. res.ErrMsg = resSeven10265.ErrMsg
  25621. res.Cainfo = resSeven10265.Cainfo
  25622. res.WarnMsg = resSeven10265.WarnMsg
  25623. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25624. res.Infcode = infocode
  25625. } else {
  25626. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25627. utils.ErrorLog("解析失败:%v", err)
  25628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25629. return
  25630. }
  25631. }
  25632. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25633. if reg_type == 11 && his.Insutype == "390" {
  25634. reg_type = 110104
  25635. }
  25636. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25637. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25638. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25639. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25640. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25641. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25642. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25643. resp, requestErr := http.Get(api)
  25644. if requestErr != nil {
  25645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25646. return
  25647. }
  25648. body, ioErr := ioutil.ReadAll(resp.Body)
  25649. if ioErr != nil {
  25650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25652. return
  25653. }
  25654. var respJSON map[string]interface{}
  25655. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25658. return
  25659. }
  25660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25661. result, _ := json.Marshal(respJSON)
  25662. if miConfig.Code == "H15049901371" {
  25663. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25664. utils.ErrorLog("解析失败:%v", err)
  25665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25666. return
  25667. }
  25668. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25669. res.Output = resSeven10265.Output
  25670. res.ErrMsg = resSeven10265.ErrMsg
  25671. res.Cainfo = resSeven10265.Cainfo
  25672. res.WarnMsg = resSeven10265.WarnMsg
  25673. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25674. res.Infcode = infocode
  25675. } else {
  25676. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25677. utils.ErrorLog("解析失败:%v", err)
  25678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25679. return
  25680. }
  25681. }
  25682. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25683. if reg_type == 11 && his.Insutype == "390" {
  25684. reg_type = 110104
  25685. }
  25686. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25687. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25688. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25689. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25690. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25691. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25692. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25693. resp, requestErr := http.Get(api)
  25694. if requestErr != nil {
  25695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25696. return
  25697. }
  25698. body, ioErr := ioutil.ReadAll(resp.Body)
  25699. if ioErr != nil {
  25700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25702. return
  25703. }
  25704. var respJSON map[string]interface{}
  25705. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25708. return
  25709. }
  25710. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25711. result, _ := json.Marshal(respJSON)
  25712. if miConfig.Code == "H15049901371" {
  25713. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25714. utils.ErrorLog("解析失败:%v", err)
  25715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25716. return
  25717. }
  25718. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25719. res.Output = resSeven10265.Output
  25720. res.ErrMsg = resSeven10265.ErrMsg
  25721. res.Cainfo = resSeven10265.Cainfo
  25722. res.WarnMsg = resSeven10265.WarnMsg
  25723. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25724. res.Infcode = infocode
  25725. } else {
  25726. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25727. utils.ErrorLog("解析失败:%v", err)
  25728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25729. return
  25730. }
  25731. }
  25732. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25733. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  25734. if result3101.Infcode == "0" {
  25735. if len(result3101.Output.Result) > 0 {
  25736. var errMsgs []string
  25737. for _, item := range result3101.Output.Result {
  25738. errMsgs = append(errMsgs, item.VolaCont)
  25739. }
  25740. c.ServeSuccessJSON(map[string]interface{}{
  25741. "failed_code": -10,
  25742. "msg": errMsgs,
  25743. })
  25744. return
  25745. } else {
  25746. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25747. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25748. bas := strings.Split(psn_info.CardInfo, "|")
  25749. if his.IdCardType == 1 {
  25750. cert_no = bas[2]
  25751. } else if his.IdCardType == 3 {
  25752. cert_no = his.Certno
  25753. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25754. } else if his.IdCardType == 4 {
  25755. cert_no = his.Certno
  25756. psn_info.VerifyNumber = psn_info.VerifyNumber
  25757. }
  25758. var api string
  25759. if miConfig.MdtrtareaAdmvs == "320921" {
  25760. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25761. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25762. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25763. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25764. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25765. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25766. "&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
  25767. } else {
  25768. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25769. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25770. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25771. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25772. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25773. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25774. "&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
  25775. }
  25776. resp, requestErr := http.Get(api)
  25777. if requestErr != nil {
  25778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25779. return
  25780. }
  25781. body, ioErr := ioutil.ReadAll(resp.Body)
  25782. if ioErr != nil {
  25783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25785. return
  25786. }
  25787. var respJSON map[string]interface{}
  25788. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25791. return
  25792. }
  25793. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25794. result, _ := json.Marshal(respJSON)
  25795. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25796. utils.ErrorLog("解析失败:%v", err)
  25797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25798. return
  25799. }
  25800. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25801. res.Output = resSeven10265.Output
  25802. res.ErrMsg = resSeven10265.ErrMsg
  25803. res.Cainfo = resSeven10265.Cainfo
  25804. res.WarnMsg = resSeven10265.WarnMsg
  25805. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25806. res.Infcode = infocode
  25807. }
  25808. }
  25809. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25810. psn_info, _ := service.GetPsnByPatientId(id)
  25811. var verify_number string
  25812. if psn_info.IdCardType == 4 {
  25813. verify_number = psn_info.VerifyNumber
  25814. } else if psn_info.IdCardType == 1 {
  25815. bas := strings.Split(psn_info.CardInfo, "|")
  25816. cardNumber := bas[2]
  25817. verify_number = cardNumber
  25818. } else {
  25819. psn_info.IdCardType = 2
  25820. verify_number = psn_info.Certno
  25821. }
  25822. var api string
  25823. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25824. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25825. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25826. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25827. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25828. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25829. "&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
  25830. resp, requestErr := http.Get(api)
  25831. if requestErr != nil {
  25832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25833. return
  25834. }
  25835. body, ioErr := ioutil.ReadAll(resp.Body)
  25836. if ioErr != nil {
  25837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25839. return
  25840. }
  25841. var respJSON map[string]interface{}
  25842. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25845. return
  25846. }
  25847. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25848. result, _ := json.Marshal(respJSON)
  25849. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25850. utils.ErrorLog("解析失败:%v", err)
  25851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25852. return
  25853. }
  25854. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25855. res.Output = resSeven10265.Output
  25856. res.ErrMsg = resSeven10265.ErrMsg
  25857. res.Cainfo = resSeven10265.Cainfo
  25858. res.WarnMsg = resSeven10265.WarnMsg
  25859. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25860. res.Infcode = infocode
  25861. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25862. var cert_no string
  25863. if his.IdCardType == 4 {
  25864. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25865. cert_no = psn_info.VerifyNumber
  25866. 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)
  25867. } else if his.IdCardType == 1 {
  25868. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25869. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25870. 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)
  25871. }
  25872. //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)
  25873. var dat map[string]interface{}
  25874. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25875. fmt.Println(dat)
  25876. } else {
  25877. fmt.Println(err)
  25878. }
  25879. saveLog(result2, src_resquest, "2207", "结算")
  25880. userJSONBytes, _ := json.Marshal(dat)
  25881. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  25882. utils.ErrorLog("解析失败:%v", err)
  25883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25884. return
  25885. }
  25886. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25887. res.Output = resSeven10265.Output
  25888. res.ErrMsg = resSeven10265.ErrMsg
  25889. res.Cainfo = resSeven10265.Cainfo
  25890. res.WarnMsg = resSeven10265.WarnMsg
  25891. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25892. res.Infcode = infocode
  25893. } else if miConfig.MdtrtareaAdmvs == "450721" {
  25894. res2 := c.GetoleInfo()
  25895. if res2.Infcode == 0 {
  25896. var result string
  25897. var request_log string
  25898. var result_log string
  25899. if res2.Output.MdtrtCertType == "02" {
  25900. 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)
  25901. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25902. } else if res2.Output.MdtrtCertType == "01" {
  25903. 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)
  25904. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25905. } else {
  25906. 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)
  25907. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  25908. }
  25909. var dat map[string]interface{}
  25910. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25911. fmt.Println(dat)
  25912. } else {
  25913. fmt.Println(err)
  25914. }
  25915. userJSONBytes, _ := json.Marshal(dat)
  25916. var res5 ResultTwo
  25917. //var resTwo10265 ResultTwo10265
  25918. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  25919. utils.ErrorLog("解析失败:%v", err)
  25920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25921. return
  25922. }
  25923. if res5.Infcode == -1 {
  25924. c.ServeSuccessJSON(map[string]interface{}{
  25925. "failed_code": -10,
  25926. "msg": res5.ErrMsg,
  25927. })
  25928. return
  25929. }
  25930. var insutypes []string
  25931. var insutype string
  25932. var is390 int = 0
  25933. var is310 int = 0
  25934. for _, item := range res5.Output.Iinfo {
  25935. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25936. insutypes = append(insutypes, item.Insutype)
  25937. }
  25938. }
  25939. if len(insutypes) == 1 {
  25940. insutype = insutypes[0]
  25941. } else {
  25942. for _, i := range insutypes {
  25943. if i == "390" {
  25944. is390 = 1
  25945. }
  25946. if i == "310" {
  25947. is310 = 1
  25948. }
  25949. }
  25950. }
  25951. if is390 == 1 {
  25952. insutype = "390"
  25953. }
  25954. if is310 == 1 {
  25955. insutype = "310"
  25956. }
  25957. if len(insutypes) == 0 {
  25958. insutype = "310"
  25959. }
  25960. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  25961. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  25962. infoStr := string(Iinfos)
  25963. idetinfoStr := string(Idetinfos)
  25964. psn := &models.HisPsn{
  25965. PsnNo: res5.Output.Baseinfo.PsnNo,
  25966. PatientId: id,
  25967. Certno: res5.Output.Baseinfo.Certno,
  25968. Gend: res5.Output.Baseinfo.Gend,
  25969. Naty: res5.Output.Baseinfo.Naty,
  25970. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  25971. PsnName: res5.Output.Baseinfo.PsnName,
  25972. Idetinfo: idetinfoStr,
  25973. Insuinfo: infoStr,
  25974. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  25975. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  25976. VerifyNumber: res2.Output.EcToken,
  25977. }
  25978. if res2.Output.MdtrtCertType == "01" {
  25979. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25980. psn.VerifyNumber = res2.Output.EcToken
  25981. } else if res2.Output.MdtrtCertType == "02" {
  25982. psn.VerifyNumber = res2.Output.CardNo
  25983. } else {
  25984. psn.VerifyNumber = res2.Output.MdtrtCertNo
  25985. }
  25986. service.CreateHisPsn(psn)
  25987. if res2.Output.MdtrtCertType == "01" {
  25988. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25989. token := res2.Output.EcToken
  25990. 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)
  25991. } else if res2.Output.MdtrtCertType == "02" {
  25992. 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)
  25993. } else {
  25994. 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)
  25995. }
  25996. var dat2 map[string]interface{}
  25997. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  25998. fmt.Println(dat2)
  25999. } else {
  26000. fmt.Println(err)
  26001. }
  26002. userJSONBytes3, _ := json.Marshal(dat2)
  26003. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26004. utils.ErrorLog("解析失败:%v", err)
  26005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26006. return
  26007. }
  26008. saveLog(result2, src_resquest, "2207", "结算")
  26009. } else {
  26010. c.ServeSuccessJSON(map[string]interface{}{
  26011. "failed_code": -10,
  26012. "msg": res2.ErrMsg,
  26013. })
  26014. return
  26015. }
  26016. } else {
  26017. if miConfig.Code == "H15049901371" {
  26018. //赤峰地区国家医保医疗类别
  26019. //职工透析:医疗类别选特殊情况门诊990502
  26020. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26021. var med_type string
  26022. if his.Insutype == "390" {
  26023. if reg_type == 14 {
  26024. med_type = "9933"
  26025. } else if reg_type == 11 {
  26026. med_type = "11"
  26027. }
  26028. } else if his.Insutype == "310" {
  26029. if reg_type == 14 {
  26030. med_type = "990502"
  26031. } else if reg_type == 11 {
  26032. med_type = "11"
  26033. }
  26034. }
  26035. 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)
  26036. } else {
  26037. if his.IdCardType == 4 {
  26038. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26039. var token string
  26040. token = psn_info.VerifyNumber
  26041. 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)
  26042. } else {
  26043. if his.IdCardType == 1 {
  26044. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26045. bas := strings.Split(psn_info.CardInfo, "|")
  26046. basNumber := bas[2]
  26047. cert_no = basNumber
  26048. }
  26049. 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)
  26050. }
  26051. }
  26052. //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)
  26053. var dat map[string]interface{}
  26054. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26055. fmt.Println(dat)
  26056. } else {
  26057. fmt.Println(err)
  26058. }
  26059. saveLog(result2, src_resquest, "2207", "结算")
  26060. userJSONBytes, _ := json.Marshal(dat)
  26061. if miConfig.Code == "H15049901371" {
  26062. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26063. utils.ErrorLog("解析失败:%v", err)
  26064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26065. return
  26066. }
  26067. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26068. res.Output = resSeven10265.Output
  26069. res.ErrMsg = resSeven10265.ErrMsg
  26070. res.Cainfo = resSeven10265.Cainfo
  26071. res.WarnMsg = resSeven10265.WarnMsg
  26072. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26073. res.Infcode = infocode
  26074. } else {
  26075. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26076. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26077. utils.ErrorLog("解析失败:%v", err)
  26078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26079. return
  26080. }
  26081. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26082. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26083. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26084. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26085. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26086. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26087. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26088. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26089. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26090. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26091. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26092. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26093. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26094. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26095. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26096. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26097. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26098. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26099. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26100. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26101. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26102. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26103. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26104. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26105. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26106. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26107. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26108. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26109. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26110. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26111. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26112. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26113. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26114. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26115. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26116. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26117. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26118. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26119. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26120. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26121. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26122. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26123. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26124. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26125. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26126. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26127. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26128. res.Cainfo = gzresSeven10265Two.Cainfo
  26129. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26130. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26131. //res.Infcode = infocode
  26132. } else {
  26133. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26134. utils.ErrorLog("解析失败:%v", err)
  26135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26136. return
  26137. }
  26138. }
  26139. }
  26140. }
  26141. if res.Infcode == -1 {
  26142. errlog := &models.HisOrderError{
  26143. UserOrgId: adminUser.CurrentOrgId,
  26144. Ctime: time.Now().Unix(),
  26145. Mtime: time.Now().Unix(),
  26146. Number: chrg_bchno,
  26147. ErrMsg: res.ErrMsg,
  26148. Status: 1,
  26149. PatientId: id,
  26150. RecordTime: recordDateTime,
  26151. Stage: 6,
  26152. }
  26153. service.CreateErrMsgLog(errlog)
  26154. c.ServeSuccessJSON(map[string]interface{}{
  26155. "failed_code": -10,
  26156. "msg": res.ErrMsg,
  26157. })
  26158. return
  26159. } else {
  26160. sickConfig, _ := service.FindSickById(his.SickType)
  26161. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26162. order.OrderStatus = 2
  26163. order.Status = 1
  26164. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26165. order.SetlId = res.Output.Setlinfo.SetlID
  26166. order.PsnNo = res.Output.Setlinfo.PsnNo
  26167. order.PsnName = res.Output.Setlinfo.PsnName
  26168. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26169. order.Certno = res.Output.Setlinfo.Certno
  26170. order.Gend = res.Output.Setlinfo.Gend
  26171. order.Naty = res.Output.Setlinfo.Naty
  26172. order.Age = res.Output.Setlinfo.Age
  26173. order.Insutype = res.Output.Setlinfo.Insutype
  26174. order.PsnType = res.Output.Setlinfo.PsnType
  26175. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26176. order.SetlTime = res.Output.Setlinfo.SetlTime
  26177. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26178. if res.Output.Setlinfo.MedType == "140101" {
  26179. order.MedType = "14"
  26180. } else {
  26181. if res.Output.Setlinfo.MedType == "110104" {
  26182. order.MedType = "11"
  26183. } else {
  26184. order.MedType = res.Output.Setlinfo.MedType
  26185. }
  26186. }
  26187. if reg_type == 1112 {
  26188. order.MedType = "1112"
  26189. }
  26190. if reg_type == 1111 {
  26191. order.MedType = "1111"
  26192. }
  26193. order.ClrType = res.Output.Setlinfo.ClrType
  26194. if adminUser.CurrentOrgId == 10480 {
  26195. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26196. order.ClrType = "11"
  26197. } else {
  26198. order.ClrType = "9903"
  26199. }
  26200. }
  26201. if adminUser.CurrentOrgId == 10721 {
  26202. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26203. order.ClrType = "11"
  26204. } else {
  26205. order.ClrType = "9903"
  26206. }
  26207. }
  26208. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26209. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26210. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26211. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26212. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26213. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26214. order.HifpPay = res.Output.Setlinfo.HifpPay
  26215. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26216. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26217. order.HifesPay = res.Output.Setlinfo.HifesPay
  26218. order.HifobPay = res.Output.Setlinfo.HifobPay
  26219. order.MafPay = res.Output.Setlinfo.MafPay
  26220. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26221. order.OthPay = res.Output.Setlinfo.OthPay
  26222. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26223. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26224. order.AcctPay = res.Output.Setlinfo.AcctPay
  26225. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26226. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26227. order.Balc = res.Output.Setlinfo.Balc
  26228. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26229. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26230. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26231. //order.ClrType = res.Output.Setlinfo.ClrType
  26232. order.ClrWay = res.Output.Setlinfo.ClrWay
  26233. order.Creator = order.Creator
  26234. order.Modify = roles.AdminUserId
  26235. order.RequestLog = src_resquest
  26236. order.FaPiaoNumber = fapiao_number
  26237. order.FaPiaoCode = fapiao_code
  26238. order.SickName = sickConfig.ClassName
  26239. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26240. //detailStr := string(setlDetail)
  26241. //order.SetlDetail = detailStr
  26242. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26243. err = service.UpDateOrder(order)
  26244. if err == nil {
  26245. //判断是否使用了押金
  26246. if dec_way == "true" {
  26247. tmpstring := strconv.FormatInt(order.ID, 10)
  26248. order.Decimal = decimal
  26249. service.UpDateOrder(order)
  26250. //扣押金
  26251. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26252. if errmsg != nil {
  26253. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26254. return
  26255. }
  26256. }
  26257. c.ServeSuccessJSON(map[string]interface{}{
  26258. "msg": "结算成功",
  26259. })
  26260. } else {
  26261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26262. return
  26263. }
  26264. }
  26265. } else {
  26266. adminUser := c.GetAdminUserInfo()
  26267. errlog := &models.HisOrderError{
  26268. UserOrgId: adminUser.CurrentOrgId,
  26269. Ctime: time.Now().Unix(),
  26270. Mtime: time.Now().Unix(),
  26271. ErrMsg: res.ErrMsg,
  26272. Status: 1,
  26273. PatientId: id,
  26274. RecordTime: recordDateTime,
  26275. Stage: 4,
  26276. }
  26277. service.CreateErrMsgLog(errlog)
  26278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26279. return
  26280. }
  26281. } else {
  26282. adminUser := c.GetAdminUserInfo()
  26283. errlog := &models.HisOrderError{
  26284. UserOrgId: adminUser.CurrentOrgId,
  26285. Ctime: time.Now().Unix(),
  26286. Mtime: time.Now().Unix(),
  26287. ErrMsg: res.ErrMsg,
  26288. Status: 1,
  26289. PatientId: id,
  26290. RecordTime: recordDateTime,
  26291. Stage: 4,
  26292. }
  26293. service.CreateErrMsgLog(errlog)
  26294. c.ServeSuccessJSON(map[string]interface{}{
  26295. "failed_code": -10,
  26296. "msg": res.ErrMsg,
  26297. })
  26298. return
  26299. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26300. //return
  26301. }
  26302. }
  26303. }
  26304. } else if tempOrder.ID > 0 {
  26305. if tempOrder.IsPre == 1 {
  26306. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26307. var rf []*ResultFive
  26308. json.Unmarshal([]byte(his.Iinfo), &rf)
  26309. chrg_bchno := tempOrder.Number
  26310. cert_no := his.Certno
  26311. var insutypes []string
  26312. var insutype string
  26313. var is390 int = 0
  26314. var is310 int = 0
  26315. for _, item := range rf {
  26316. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26317. insutypes = append(insutypes, item.Insutype)
  26318. }
  26319. }
  26320. if len(insutypes) == 1 {
  26321. insutype = insutypes[0]
  26322. } else {
  26323. for _, i := range insutypes {
  26324. if i == "390" {
  26325. is390 = 1
  26326. }
  26327. if i == "310" {
  26328. is310 = 1
  26329. }
  26330. }
  26331. }
  26332. if is390 == 1 {
  26333. insutype = "390"
  26334. }
  26335. if is310 == 1 {
  26336. insutype = "310"
  26337. }
  26338. if len(insutypes) == 0 {
  26339. insutype = "310"
  26340. }
  26341. if len(insutypes) == 2 {
  26342. insutype = strconv.FormatInt(his.SocialType, 10)
  26343. }
  26344. //insutype = "390"
  26345. if his.IdCardType == 1 {
  26346. // cert_no = his.MedicalInsuranceNumber
  26347. cert_no = his.Certno
  26348. } else {
  26349. cert_no = his.Certno
  26350. }
  26351. var res ResultSeven
  26352. var ahres ResultSevenAH
  26353. var resSeven10265 ResultSeven10265
  26354. var gzresSeven10265Two GZResultSeven10265Two
  26355. var src_resquest string
  26356. var result2 string
  26357. if miConfig.MdtrtareaAdmvs == "450721" {
  26358. res2 := c.GetoleInfo()
  26359. if res2.Infcode == 0 {
  26360. var result string
  26361. var request_log string
  26362. var result_log string
  26363. if res2.Output.MdtrtCertType == "02" {
  26364. 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)
  26365. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26366. } else if res2.Output.MdtrtCertType == "01" {
  26367. 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)
  26368. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26369. } else {
  26370. 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)
  26371. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26372. }
  26373. var dat map[string]interface{}
  26374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26375. fmt.Println(dat)
  26376. } else {
  26377. fmt.Println(err)
  26378. }
  26379. userJSONBytes, _ := json.Marshal(dat)
  26380. var res5 ResultTwo
  26381. //var resTwo10265 ResultTwo10265
  26382. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26383. utils.ErrorLog("解析失败:%v", err)
  26384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26385. return
  26386. }
  26387. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26388. if res5.Infcode == -1 {
  26389. c.ServeSuccessJSON(map[string]interface{}{
  26390. "failed_code": -10,
  26391. "msg": res5.ErrMsg,
  26392. })
  26393. return
  26394. }
  26395. var insutypes []string
  26396. var insutype string
  26397. var is390 int = 0
  26398. var is310 int = 0
  26399. for _, item := range res5.Output.Iinfo {
  26400. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26401. insutypes = append(insutypes, item.Insutype)
  26402. }
  26403. }
  26404. if len(insutypes) == 1 {
  26405. insutype = insutypes[0]
  26406. } else {
  26407. for _, i := range insutypes {
  26408. if i == "390" {
  26409. is390 = 1
  26410. }
  26411. if i == "310" {
  26412. is310 = 1
  26413. }
  26414. }
  26415. }
  26416. if is390 == 1 {
  26417. insutype = "390"
  26418. }
  26419. if is310 == 1 {
  26420. insutype = "310"
  26421. }
  26422. if len(insutypes) == 0 {
  26423. insutype = "310"
  26424. }
  26425. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26426. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26427. infoStr := string(Iinfos)
  26428. idetinfoStr := string(Idetinfos)
  26429. psn := &models.HisPsn{
  26430. PsnNo: res5.Output.Baseinfo.PsnNo,
  26431. PatientId: id,
  26432. Certno: res5.Output.Baseinfo.Certno,
  26433. Gend: res5.Output.Baseinfo.Gend,
  26434. Naty: res5.Output.Baseinfo.Naty,
  26435. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26436. PsnName: res5.Output.Baseinfo.PsnName,
  26437. Idetinfo: idetinfoStr,
  26438. Insuinfo: infoStr,
  26439. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26440. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26441. VerifyNumber: res2.Output.EcToken,
  26442. }
  26443. service.CreateHisPsn(psn)
  26444. if res2.Output.MdtrtCertType == "01" {
  26445. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26446. token := res2.Output.EcToken
  26447. 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)
  26448. } else if res2.Output.MdtrtCertType == "02" {
  26449. 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)
  26450. } else {
  26451. 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)
  26452. }
  26453. var dat2 map[string]interface{}
  26454. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26455. fmt.Println(dat2)
  26456. } else {
  26457. fmt.Println(err)
  26458. }
  26459. userJSONBytes3, _ := json.Marshal(dat2)
  26460. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26461. utils.ErrorLog("解析失败:%v", err)
  26462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26463. return
  26464. }
  26465. saveLog(result2, src_resquest, "2207", "结算")
  26466. } else {
  26467. c.ServeSuccessJSON(map[string]interface{}{
  26468. "failed_code": -10,
  26469. "msg": res2.ErrMsg,
  26470. })
  26471. return
  26472. }
  26473. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26474. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26475. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26476. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26477. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26478. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26479. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26480. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26481. resp, requestErr := http.Get(api)
  26482. if requestErr != nil {
  26483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26484. return
  26485. }
  26486. body, ioErr := ioutil.ReadAll(resp.Body)
  26487. if ioErr != nil {
  26488. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26490. return
  26491. }
  26492. var respJSON map[string]interface{}
  26493. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26496. return
  26497. }
  26498. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26499. result, _ := json.Marshal(respJSON)
  26500. fmt.Println("log")
  26501. fmt.Println(string(result))
  26502. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26503. utils.ErrorLog("解析失败:%v", err)
  26504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26505. return
  26506. }
  26507. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26508. if reg_type == 11 && his.Insutype == "390" {
  26509. reg_type = 110104
  26510. }
  26511. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26512. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26513. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26514. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26515. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26516. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26517. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26518. resp, requestErr := http.Get(api)
  26519. if requestErr != nil {
  26520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26521. return
  26522. }
  26523. body, ioErr := ioutil.ReadAll(resp.Body)
  26524. if ioErr != nil {
  26525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26527. return
  26528. }
  26529. var respJSON map[string]interface{}
  26530. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26533. return
  26534. }
  26535. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26536. result, _ := json.Marshal(respJSON)
  26537. fmt.Println("log")
  26538. fmt.Println(string(result))
  26539. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26540. utils.ErrorLog("解析失败:%v", err)
  26541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26542. return
  26543. }
  26544. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26545. if reg_type == 11 && his.Insutype == "390" {
  26546. reg_type = 110104
  26547. }
  26548. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26549. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26550. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26551. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26552. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26553. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26554. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26555. resp, requestErr := http.Get(api)
  26556. if requestErr != nil {
  26557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26558. return
  26559. }
  26560. body, ioErr := ioutil.ReadAll(resp.Body)
  26561. if ioErr != nil {
  26562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26564. return
  26565. }
  26566. var respJSON map[string]interface{}
  26567. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26570. return
  26571. }
  26572. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26573. result, _ := json.Marshal(respJSON)
  26574. fmt.Println("log")
  26575. fmt.Println(string(result))
  26576. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26577. utils.ErrorLog("解析失败:%v", err)
  26578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26579. return
  26580. }
  26581. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26582. if reg_type == 11 && his.Insutype == "390" {
  26583. reg_type = 110104
  26584. }
  26585. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26586. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26587. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26588. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26589. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26590. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26591. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26592. resp, requestErr := http.Get(api)
  26593. if requestErr != nil {
  26594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26595. return
  26596. }
  26597. body, ioErr := ioutil.ReadAll(resp.Body)
  26598. if ioErr != nil {
  26599. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26601. return
  26602. }
  26603. var respJSON map[string]interface{}
  26604. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26605. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26607. return
  26608. }
  26609. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26610. result, _ := json.Marshal(respJSON)
  26611. fmt.Println("log")
  26612. fmt.Println(string(result))
  26613. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26614. utils.ErrorLog("解析失败:%v", err)
  26615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26616. return
  26617. }
  26618. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26619. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  26620. if result3101.Infcode == "0" {
  26621. if len(result3101.Output.Result) > 0 {
  26622. var errMsgs []string
  26623. for _, item := range result3101.Output.Result {
  26624. errMsgs = append(errMsgs, item.VolaCont)
  26625. }
  26626. c.ServeSuccessJSON(map[string]interface{}{
  26627. "failed_code": -10,
  26628. "msg": errMsgs,
  26629. })
  26630. return
  26631. } else {
  26632. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26633. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26634. bas := strings.Split(psn_info.CardInfo, "|")
  26635. if his.IdCardType == 1 {
  26636. cert_no = bas[2]
  26637. } else if his.IdCardType == 3 {
  26638. cert_no = his.Certno
  26639. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26640. } else if his.IdCardType == 4 {
  26641. cert_no = his.Certno
  26642. psn_info.VerifyNumber = psn_info.VerifyNumber
  26643. }
  26644. //江苏地区国家医保医疗类别
  26645. //职工透析:医疗类别选特殊情况门诊9933
  26646. //居民血透门慢: 医疗类别选门诊慢病1402
  26647. //var med_type string
  26648. //if his.Insutype == "310" {
  26649. // if reg_type == 14 {
  26650. // med_type = "9933"
  26651. // } else if reg_type == 11 {
  26652. // med_type = "11"
  26653. //
  26654. // }
  26655. //} else if his.Insutype == "390" {
  26656. // if reg_type == 14 {
  26657. // med_type = "1402"
  26658. // } else if reg_type == 11 {
  26659. // med_type = "11"
  26660. // }
  26661. //}
  26662. var api string
  26663. if miConfig.MdtrtareaAdmvs == "320921" {
  26664. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26665. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26666. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26667. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26668. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26669. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26670. "&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
  26671. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26672. } else {
  26673. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26674. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26675. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26676. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26677. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26678. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26679. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26680. "&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
  26681. }
  26682. resp, requestErr := http.Get(api)
  26683. if requestErr != nil {
  26684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26685. return
  26686. }
  26687. body, ioErr := ioutil.ReadAll(resp.Body)
  26688. if ioErr != nil {
  26689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26691. return
  26692. }
  26693. var respJSON map[string]interface{}
  26694. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26697. return
  26698. }
  26699. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26700. result, _ := json.Marshal(respJSON)
  26701. fmt.Println("log")
  26702. fmt.Println(string(result))
  26703. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26704. utils.ErrorLog("解析失败:%v", err)
  26705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26706. return
  26707. }
  26708. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26709. res.Output = resSeven10265.Output
  26710. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26711. res.ErrMsg = resSeven10265.ErrMsg
  26712. res.Cainfo = resSeven10265.Cainfo
  26713. res.WarnMsg = resSeven10265.WarnMsg
  26714. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26715. res.Infcode = infocode
  26716. }
  26717. }
  26718. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26719. psn_info, _ := service.GetPsnByPatientId(id)
  26720. var verify_number string
  26721. if psn_info.IdCardType == 4 {
  26722. verify_number = psn_info.VerifyNumber
  26723. } else if psn_info.IdCardType == 1 {
  26724. bas := strings.Split(psn_info.CardInfo, "|")
  26725. cardNumber := bas[2]
  26726. verify_number = cardNumber
  26727. } else {
  26728. verify_number = psn_info.Certno
  26729. psn_info.IdCardType = 2
  26730. }
  26731. var api string
  26732. new_chrg_bchno := chrg_bchno
  26733. if adminUser.CurrentOrgId == 10265 {
  26734. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26735. new_chrg_bchno = "0000"
  26736. }
  26737. }
  26738. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26739. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  26740. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26741. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26742. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  26743. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26744. "&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
  26745. resp, requestErr := http.Get(api)
  26746. if requestErr != nil {
  26747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26748. return
  26749. }
  26750. body, ioErr := ioutil.ReadAll(resp.Body)
  26751. if ioErr != nil {
  26752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26754. return
  26755. }
  26756. var respJSON map[string]interface{}
  26757. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26760. return
  26761. }
  26762. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26763. result, _ := json.Marshal(respJSON)
  26764. fmt.Println("log")
  26765. fmt.Println(string(result))
  26766. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26767. utils.ErrorLog("解析失败:%v", err)
  26768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26769. return
  26770. }
  26771. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26772. res.Output = resSeven10265.Output
  26773. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26774. res.ErrMsg = resSeven10265.ErrMsg
  26775. res.Cainfo = resSeven10265.Cainfo
  26776. res.WarnMsg = resSeven10265.WarnMsg
  26777. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26778. res.Infcode = infocode
  26779. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26780. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26781. var cert_no string
  26782. if his.IdCardType == 1 {
  26783. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26784. } else {
  26785. cert_no = psn_info.VerifyNumber
  26786. }
  26787. 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)
  26788. var dat map[string]interface{}
  26789. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26790. fmt.Println(dat)
  26791. } else {
  26792. fmt.Println(err)
  26793. }
  26794. saveLog(result2, src_resquest, "2207", "结算")
  26795. userJSONBytes, _ := json.Marshal(dat)
  26796. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26797. utils.ErrorLog("解析失败:%v", err)
  26798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26799. return
  26800. }
  26801. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26802. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26803. var cert_no string
  26804. var card_sn string
  26805. if his.IdCardType == 1 {
  26806. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26807. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26808. bas := strings.Split(psn_info.CardInfo, "|")
  26809. card_sn = bas[3]
  26810. } else if his.IdCardType == 2 {
  26811. cert_no = his.IdCardNo
  26812. } else {
  26813. cert_no = psn_info.VerifyNumber
  26814. }
  26815. var rf []*ResultFive
  26816. json.Unmarshal([]byte(his.Iinfo), &rf)
  26817. var psn_type string
  26818. for _, item := range rf {
  26819. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  26820. psn_type = item.PsnType
  26821. }
  26822. }
  26823. 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)
  26824. var dat map[string]interface{}
  26825. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26826. fmt.Println(dat)
  26827. } else {
  26828. fmt.Println(err)
  26829. }
  26830. saveLog(result2, src_resquest, "2207", "结算")
  26831. userJSONBytes, _ := json.Marshal(dat)
  26832. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26833. utils.ErrorLog("解析失败:%v", err)
  26834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26835. return
  26836. }
  26837. } else if miConfig.MdtrtareaAdmvs == "361025" {
  26838. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26839. var cert_no string
  26840. var card_sn string
  26841. if his.IdCardType == 1 {
  26842. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26843. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26844. //bas := strings.Split(psn_info.CardInfo, "|")
  26845. card_sn = ""
  26846. } else if his.IdCardType == 2 {
  26847. cert_no = his.IdCardNo
  26848. } else {
  26849. cert_no = psn_info.VerifyNumber
  26850. }
  26851. var rf []*ResultFive
  26852. json.Unmarshal([]byte(his.Iinfo), &rf)
  26853. var psn_type string
  26854. for _, item := range rf {
  26855. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  26856. psn_type = item.PsnType
  26857. }
  26858. }
  26859. 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)
  26860. var dat map[string]interface{}
  26861. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26862. fmt.Println(dat)
  26863. } else {
  26864. fmt.Println(err)
  26865. }
  26866. saveLog(result2, src_resquest, "2207", "结算")
  26867. userJSONBytes, _ := json.Marshal(dat)
  26868. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26869. utils.ErrorLog("解析失败:%v", err)
  26870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26871. return
  26872. }
  26873. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26874. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26875. if his.IdCardType == 1 {
  26876. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26877. bas := strings.Split(psn_info.CardInfo, "|")
  26878. cert_no = bas[2]
  26879. } else if his.IdCardType == 3 {
  26880. cert_no = his.Certno
  26881. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26882. } else if his.IdCardType == 4 {
  26883. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26884. cert_no = psn_info.VerifyNumber
  26885. psn_info.VerifyNumber = psn_info.VerifyNumber
  26886. } else {
  26887. cert_no = his.Certno
  26888. psn_info.VerifyNumber = his.Certno
  26889. }
  26890. var api string
  26891. var med_type string
  26892. if his.Insutype == "390" {
  26893. if reg_type == 992102 {
  26894. med_type = "992102"
  26895. }
  26896. if reg_type == 140104 {
  26897. med_type = "140104"
  26898. }
  26899. if reg_type == 140201 {
  26900. med_type = "140201"
  26901. }
  26902. if reg_type == 14 {
  26903. med_type = "14"
  26904. }
  26905. } else if his.Insutype == "310" {
  26906. if reg_type == 992102 {
  26907. med_type = "992102"
  26908. }
  26909. if reg_type == 140104 {
  26910. med_type = "140104"
  26911. }
  26912. if reg_type == 140201 {
  26913. med_type = "140201"
  26914. }
  26915. if reg_type == 14 {
  26916. med_type = "14"
  26917. }
  26918. }
  26919. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26920. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26921. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26922. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26923. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26924. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26925. "&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
  26926. resp, requestErr := http.Get(api)
  26927. if requestErr != nil {
  26928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26929. return
  26930. }
  26931. body, ioErr := ioutil.ReadAll(resp.Body)
  26932. if ioErr != nil {
  26933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26935. return
  26936. }
  26937. var respJSON map[string]interface{}
  26938. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26941. return
  26942. }
  26943. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26944. if status == "0" {
  26945. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26946. c.ServeSuccessJSON(map[string]interface{}{
  26947. "failed_code": -10,
  26948. "msg": err_msg,
  26949. })
  26950. return
  26951. }
  26952. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26953. result, _ := json.Marshal(respJSON)
  26954. fmt.Println("log")
  26955. fmt.Println(string(result))
  26956. if err := json.Unmarshal(result, &ahres); err != nil {
  26957. utils.ErrorLog("解析失败:%v", err)
  26958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26959. return
  26960. }
  26961. res.InfRefmsgid = ahres.InfRefmsgid
  26962. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26963. // 创建对应的Time类型
  26964. t := time.UnixMilli(timestamp)
  26965. // 格式化成指定的日期字符串
  26966. str := t.Format("2006-01-02 15:04:05")
  26967. res.Output.Setlinfo.SetlTime = str
  26968. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  26969. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  26970. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26971. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  26972. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  26973. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  26974. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26975. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  26976. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  26977. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  26978. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  26979. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  26980. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  26981. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  26982. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  26983. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  26984. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  26985. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  26986. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26987. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  26988. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  26989. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  26990. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  26991. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  26992. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  26993. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  26994. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  26995. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  26996. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  26997. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  26998. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  26999. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27000. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27001. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27002. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27003. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27004. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27005. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27006. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27007. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27008. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27009. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27010. res.Output.Setldetail = ahres.Output.Setldetail
  27011. res.ErrMsg = ahres.ErrMsg
  27012. res.Cainfo = ahres.Cainfo
  27013. res.WarnMsg = ahres.WarnMsg
  27014. res.Infcode = ahres.Infcode
  27015. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27016. res.Output.Setlinfo.ClrType = "11"
  27017. } else {
  27018. res.Output.Setlinfo.ClrType = "9903"
  27019. }
  27020. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27021. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27022. if his.IdCardType == 1 {
  27023. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27024. bas := strings.Split(psn_info.CardInfo, "|")
  27025. cert_no = bas[2]
  27026. } else if his.IdCardType == 3 {
  27027. cert_no = his.Certno
  27028. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27029. } else if his.IdCardType == 4 {
  27030. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27031. cert_no = his.Certno
  27032. psn_info.VerifyNumber = psn_info.VerifyNumber
  27033. } else {
  27034. cert_no = his.Certno
  27035. psn_info.VerifyNumber = his.Certno
  27036. }
  27037. var api string
  27038. var med_type string
  27039. if his.Insutype == "390" {
  27040. if reg_type == 992102 {
  27041. med_type = "992102"
  27042. }
  27043. if reg_type == 140104 {
  27044. med_type = "140104"
  27045. }
  27046. if reg_type == 14 {
  27047. med_type = "14"
  27048. }
  27049. if reg_type == 140201 {
  27050. med_type = "140201"
  27051. }
  27052. } else if his.Insutype == "310" {
  27053. if reg_type == 992102 {
  27054. med_type = "992102"
  27055. }
  27056. if reg_type == 14 {
  27057. med_type = "14"
  27058. }
  27059. if reg_type == 140104 {
  27060. med_type = "140104"
  27061. }
  27062. if reg_type == 140201 {
  27063. med_type = "140201"
  27064. }
  27065. }
  27066. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27067. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27068. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27069. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27070. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27071. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27072. "&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
  27073. resp, requestErr := http.Get(api)
  27074. if requestErr != nil {
  27075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27076. return
  27077. }
  27078. body, ioErr := ioutil.ReadAll(resp.Body)
  27079. if ioErr != nil {
  27080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27082. return
  27083. }
  27084. var respJSON map[string]interface{}
  27085. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27088. return
  27089. }
  27090. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27091. if status == "0" {
  27092. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27093. c.ServeSuccessJSON(map[string]interface{}{
  27094. "failed_code": -10,
  27095. "msg": err_msg,
  27096. })
  27097. return
  27098. }
  27099. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27100. result, _ := json.Marshal(respJSON)
  27101. fmt.Println("log")
  27102. fmt.Println(string(result))
  27103. if err := json.Unmarshal(result, &ahres); err != nil {
  27104. utils.ErrorLog("解析失败:%v", err)
  27105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27106. return
  27107. }
  27108. res.InfRefmsgid = ahres.InfRefmsgid
  27109. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27110. // 创建对应的Time类型
  27111. t := time.UnixMilli(timestamp)
  27112. // 格式化成指定的日期字符串
  27113. str := t.Format("2006-01-02 15:04:05")
  27114. res.Output.Setlinfo.SetlTime = str
  27115. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27116. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27117. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27118. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27119. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27120. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27121. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27122. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27123. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27124. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27125. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27126. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27127. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27128. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27129. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27130. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27131. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27132. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27133. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27134. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27135. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27136. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27137. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27138. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27139. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27140. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27141. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27142. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27143. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27144. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27145. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27146. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27147. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27148. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27149. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27150. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27151. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27152. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27153. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27154. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27155. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27156. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27157. res.Output.Setldetail = ahres.Output.Setldetail
  27158. res.ErrMsg = ahres.ErrMsg
  27159. res.Cainfo = ahres.Cainfo
  27160. res.WarnMsg = ahres.WarnMsg
  27161. res.Infcode = ahres.Infcode
  27162. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27163. res.Output.Setlinfo.ClrType = "11"
  27164. } else {
  27165. res.Output.Setlinfo.ClrType = "9903"
  27166. }
  27167. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27168. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27169. var cert_no string
  27170. if his.IdCardType == 1 {
  27171. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27172. } else if his.IdCardType == 2 {
  27173. cert_no = his.IdCardNo
  27174. } else {
  27175. cert_no = psn_info.VerifyNumber
  27176. }
  27177. 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, "")
  27178. var dat map[string]interface{}
  27179. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27180. fmt.Println(dat)
  27181. } else {
  27182. fmt.Println(err)
  27183. }
  27184. saveLog(result2, src_resquest, "2207", "结算")
  27185. userJSONBytes, _ := json.Marshal(dat)
  27186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27187. utils.ErrorLog("解析失败:%v", err)
  27188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27189. return
  27190. }
  27191. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27192. psn_info, _ := service.GetPsnByPatientId(id)
  27193. var verify_number string
  27194. if psn_info.IdCardType == 4 {
  27195. verify_number = psn_info.VerifyNumber
  27196. } else if psn_info.IdCardType == 1 {
  27197. bas := strings.Split(psn_info.CardInfo, "|")
  27198. cardNumber := bas[2]
  27199. verify_number = cardNumber
  27200. } else {
  27201. verify_number = psn_info.Certno
  27202. psn_info.IdCardType = 2
  27203. }
  27204. var api string
  27205. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27206. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27207. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27208. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27209. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27210. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27211. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27212. resp, requestErr := http.Get(api)
  27213. if requestErr != nil {
  27214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27215. return
  27216. }
  27217. body, ioErr := ioutil.ReadAll(resp.Body)
  27218. if ioErr != nil {
  27219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27221. return
  27222. }
  27223. var respJSON map[string]interface{}
  27224. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27227. return
  27228. }
  27229. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27230. result, _ := json.Marshal(respJSON)
  27231. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27232. utils.ErrorLog("解析失败:%v", err)
  27233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27234. return
  27235. }
  27236. } else {
  27237. var src_resquest string
  27238. if miConfig.Code == "H15049901371" {
  27239. //赤峰地区国家医保医疗类别
  27240. //职工透析:医疗类别选特殊情况门诊990502
  27241. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27242. var med_type string
  27243. if his.Insutype == "390" {
  27244. if reg_type == 14 {
  27245. med_type = "9933"
  27246. } else if reg_type == 11 {
  27247. med_type = "11"
  27248. }
  27249. } else if his.Insutype == "310" {
  27250. if reg_type == 14 {
  27251. med_type = "990502"
  27252. } else if reg_type == 11 {
  27253. med_type = "11"
  27254. }
  27255. }
  27256. 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)
  27257. } else {
  27258. if his.IdCardType == 4 {
  27259. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27260. token := psn_info.VerifyNumber
  27261. 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)
  27262. } else {
  27263. 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)
  27264. }
  27265. }
  27266. var dat map[string]interface{}
  27267. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27268. fmt.Println(dat)
  27269. } else {
  27270. fmt.Println(err)
  27271. }
  27272. saveLog(result2, src_resquest, "2207", "结算")
  27273. userJSONBytes, _ := json.Marshal(dat)
  27274. if miConfig.Code == "H15049901371" {
  27275. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27276. utils.ErrorLog("解析失败:%v", err)
  27277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27278. return
  27279. }
  27280. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27281. res.Output = resSeven10265.Output
  27282. res.ErrMsg = resSeven10265.ErrMsg
  27283. res.Cainfo = resSeven10265.Cainfo
  27284. res.WarnMsg = resSeven10265.WarnMsg
  27285. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27286. res.Infcode = infocode
  27287. } else {
  27288. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27289. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27290. utils.ErrorLog("解析失败:%v", err)
  27291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27292. return
  27293. }
  27294. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27295. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27296. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27297. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27298. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27299. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27300. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27301. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27302. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27303. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27304. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27305. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27306. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27307. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27308. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27309. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27310. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27311. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27312. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27313. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27314. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27315. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27316. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27317. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27318. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27319. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27320. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27321. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27322. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27323. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27324. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27325. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27326. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27327. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27328. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27329. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27330. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27331. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27332. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27333. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27334. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27335. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27336. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27337. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27338. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27339. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27340. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27341. res.Cainfo = gzresSeven10265Two.Cainfo
  27342. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27343. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27344. //res.Infcode = infocode
  27345. } else {
  27346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27347. utils.ErrorLog("解析失败:%v", err)
  27348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27349. return
  27350. }
  27351. }
  27352. }
  27353. }
  27354. if res.Infcode == -1 {
  27355. errlog := &models.HisOrderError{
  27356. UserOrgId: adminUser.CurrentOrgId,
  27357. Ctime: time.Now().Unix(),
  27358. Mtime: time.Now().Unix(),
  27359. Number: chrg_bchno,
  27360. ErrMsg: res.ErrMsg,
  27361. Status: 1,
  27362. PatientId: id,
  27363. RecordTime: recordDateTime,
  27364. Stage: 6,
  27365. }
  27366. service.CreateErrMsgLog(errlog)
  27367. c.ServeSuccessJSON(map[string]interface{}{
  27368. "failed_code": -10,
  27369. "msg": res.ErrMsg,
  27370. })
  27371. return
  27372. } else {
  27373. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27374. order.OrderStatus = 2
  27375. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27376. order.SetlId = res.Output.Setlinfo.SetlID
  27377. order.PsnNo = res.Output.Setlinfo.PsnNo
  27378. order.PsnName = res.Output.Setlinfo.PsnName
  27379. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27380. order.Certno = res.Output.Setlinfo.Certno
  27381. order.Gend = res.Output.Setlinfo.Gend
  27382. order.Naty = res.Output.Setlinfo.Naty
  27383. order.Age = res.Output.Setlinfo.Age
  27384. order.Insutype = res.Output.Setlinfo.Insutype
  27385. order.PsnType = res.Output.Setlinfo.PsnType
  27386. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27387. order.SetlTime = res.Output.Setlinfo.SetlTime
  27388. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27389. order.PayWays = pay_ways
  27390. order.AcctUsedFlag = acct_used_flag
  27391. order.WechatPay = wechat_pay
  27392. order.AliPay = ali_pay
  27393. order.JifenPay = jifen_pay
  27394. order.BandCardPay = band_card_pay
  27395. order.CashPay = cash_pay
  27396. order.OthDesc = oth_desc
  27397. //order.MedType = res.Output.Setlinfo.MedType
  27398. if reg_type == 1112 {
  27399. order.MedType = "1112"
  27400. }
  27401. if reg_type == 1111 {
  27402. order.MedType = "1111"
  27403. }
  27404. order.ClrType = res.Output.Setlinfo.ClrType
  27405. if adminUser.CurrentOrgId == 10480 {
  27406. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27407. order.ClrType = "11"
  27408. } else {
  27409. order.ClrType = "9903"
  27410. }
  27411. }
  27412. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27413. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27414. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27415. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27416. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27417. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27418. order.HifpPay = res.Output.Setlinfo.HifpPay
  27419. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27420. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27421. order.HifesPay = res.Output.Setlinfo.HifesPay
  27422. order.HifobPay = res.Output.Setlinfo.HifobPay
  27423. order.MafPay = res.Output.Setlinfo.MafPay
  27424. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27425. order.OthPay = res.Output.Setlinfo.OthPay
  27426. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27427. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27428. order.AcctPay = res.Output.Setlinfo.AcctPay
  27429. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27430. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27431. order.Balc = res.Output.Setlinfo.Balc
  27432. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27433. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27434. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27435. order.ClrWay = res.Output.Setlinfo.ClrWay
  27436. order.Creator = order.Creator
  27437. order.Modify = roles.AdminUserId
  27438. order.RequestLog = src_resquest
  27439. order.Diagnosis = diagnosis_id
  27440. order.FaPiaoNumber = fapiao_number
  27441. order.FaPiaoCode = fapiao_code
  27442. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27443. detailStr := string(setlDetail)
  27444. order.SetlDetail = detailStr
  27445. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27446. err = service.UpDateOrder(order)
  27447. if err == nil {
  27448. //判断是否使用了押金
  27449. if dec_way == "true" {
  27450. tmpstring := strconv.FormatInt(order.ID, 10)
  27451. //扣押金
  27452. order.Decimal = decimal
  27453. service.UpDateOrder(order)
  27454. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27455. if errmsg != nil {
  27456. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27457. return
  27458. }
  27459. }
  27460. c.ServeSuccessJSON(map[string]interface{}{
  27461. "msg": "结算成功",
  27462. })
  27463. } else {
  27464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27465. return
  27466. }
  27467. }
  27468. }
  27469. }
  27470. }
  27471. // 上传明细-预结算-
  27472. func (c *HisApiController) GetPreUploadInfo() {
  27473. id, _ := c.GetInt64("id")
  27474. record_time := c.GetString("record_time")
  27475. his_patient_id, _ := c.GetInt64("his_patient_id")
  27476. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27477. admin_user_id, _ := c.GetInt64("admin_user_id")
  27478. diagnosis_id := c.GetString("diagnosis")
  27479. sick_type, _ := c.GetInt64("sick_type")
  27480. reg_type, _ := c.GetInt64("p_type")
  27481. begin_time := c.GetString("begin_time")
  27482. acct_used_flag := c.GetString("acct_used_flag")
  27483. id_str := c.GetString("ids")
  27484. ids_arr := strings.Split(id_str, ",")
  27485. timeLayout := "2006-01-02"
  27486. loc, _ := time.LoadLocation("Local")
  27487. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27488. if err != nil {
  27489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27490. return
  27491. }
  27492. recordDateTime := theTime.Unix()
  27493. adminUser := c.GetAdminUserInfo()
  27494. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27495. var config []*models.HisXtDiagnoseConfig
  27496. for _, item := range diagnosis_ids {
  27497. id, _ := strconv.ParseInt(item, 10, 64)
  27498. if id > 0 {
  27499. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27500. config = append(config, &diagnosisConfig)
  27501. }
  27502. }
  27503. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27504. sickConfig, _ := service.FindSickById(sick_type)
  27505. var prescriptions []*models.HisPrescription
  27506. var start_time int64
  27507. var end_time int64
  27508. var isSuccess bool = true
  27509. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27510. fmt.Println(his_patient_id)
  27511. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27512. timestamp := time.Now().Unix()
  27513. tempTime := time.Unix(timestamp, 0)
  27514. timeFormat := tempTime.Format("20060102150405")
  27515. chrgBchno := rand.Intn(100000) + 10000
  27516. new_chrg_bchno := ""
  27517. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27518. new_chrg_bchno = chrg_bchno
  27519. if adminUser.CurrentOrgId == 10265 {
  27520. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27521. new_chrg_bchno = "0000"
  27522. }
  27523. }
  27524. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27525. var patientPrescription models.HisPrescriptionInfo
  27526. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27527. if patientPrescription.ID == 0 {
  27528. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27529. }
  27530. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27531. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27532. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27533. strconv.FormatInt(his.PatientId, 10)
  27534. var res2406 Result2406
  27535. //安徽单病种处理
  27536. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27537. data := make(map[string]interface{})
  27538. client := &http.Client{}
  27539. data["psn_no"] = his.PsnNo
  27540. data["mdtrt_id"] = his.Number
  27541. data["operator"] = roles.UserName
  27542. data["cert_no"] = his.IdCardNo
  27543. data["org_name"] = miConfig.OrgName
  27544. data["psn_name"] = his.Name
  27545. data["ipt_otp_no"] = his.IptOtpNo
  27546. data["ipt_psn_sp_flag_type"] = "0901"
  27547. data["ipt_psn_sp_flag"] = "1"
  27548. data["fixmedins_code"] = miConfig.Code
  27549. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27550. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27551. data["url"] = miConfig.Url
  27552. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27553. bytesData, _ := json.Marshal(data)
  27554. var req *http.Request
  27555. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27556. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27557. resp, _ := client.Do(req)
  27558. defer resp.Body.Close()
  27559. body, ioErr := ioutil.ReadAll(resp.Body)
  27560. if ioErr != nil {
  27561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27563. return
  27564. }
  27565. var respJSON map[string]interface{}
  27566. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27569. return
  27570. }
  27571. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27572. if status == "0" {
  27573. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27574. c.ServeSuccessJSON(map[string]interface{}{
  27575. "failed_code": -10,
  27576. "msg": err_msg,
  27577. })
  27578. return
  27579. }
  27580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27581. userJSONBytes, _ := json.Marshal(respJSON)
  27582. fmt.Println("log")
  27583. fmt.Println(string(userJSONBytes))
  27584. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27585. utils.ErrorLog("解析失败:%v", err)
  27586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27587. return
  27588. }
  27589. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  27590. data := make(map[string]interface{})
  27591. client := &http.Client{}
  27592. data["psn_no"] = his.PsnNo
  27593. data["mdtrt_id"] = his.Number
  27594. data["operator"] = roles.UserName
  27595. data["cert_no"] = his.IdCardNo
  27596. data["org_name"] = miConfig.OrgName
  27597. data["psn_name"] = his.Name
  27598. data["ipt_otp_no"] = his.IptOtpNo
  27599. data["ipt_psn_sp_flag_type"] = "0901"
  27600. data["ipt_psn_sp_flag"] = "1"
  27601. data["fixmedins_code"] = miConfig.Code
  27602. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27603. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27604. data["url"] = miConfig.Url
  27605. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  27606. bytesData, _ := json.Marshal(data)
  27607. var req *http.Request
  27608. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  27609. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  27610. resp, _ := client.Do(req)
  27611. defer resp.Body.Close()
  27612. body, ioErr := ioutil.ReadAll(resp.Body)
  27613. if ioErr != nil {
  27614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27616. return
  27617. }
  27618. var respJSON map[string]interface{}
  27619. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27622. return
  27623. }
  27624. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27625. if status == "0" {
  27626. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27627. c.ServeSuccessJSON(map[string]interface{}{
  27628. "failed_code": -10,
  27629. "msg": err_msg,
  27630. })
  27631. return
  27632. }
  27633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27634. userJSONBytes, _ := json.Marshal(respJSON)
  27635. fmt.Println("log")
  27636. fmt.Println(string(userJSONBytes))
  27637. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  27638. utils.ErrorLog("解析失败:%v", err)
  27639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27640. return
  27641. }
  27642. }
  27643. if res2406.Infcode != 0 {
  27644. adminUser := c.GetAdminUserInfo()
  27645. errlog := &models.HisOrderError{
  27646. UserOrgId: adminUser.CurrentOrgId,
  27647. Ctime: time.Now().Unix(),
  27648. Mtime: time.Now().Unix(),
  27649. ErrMsg: res2406.ErrMsg,
  27650. Status: 1,
  27651. PatientId: id,
  27652. RecordTime: recordDateTime,
  27653. Stage: 3,
  27654. }
  27655. service.CreateErrMsgLog(errlog)
  27656. c.ServeSuccessJSON(map[string]interface{}{
  27657. "failed_code": -10,
  27658. "msg": res2406.ErrMsg,
  27659. })
  27660. return
  27661. }
  27662. var res2 ResultSix
  27663. var res3 GZResultSix
  27664. var resSix10265 ResultSix10265
  27665. //var time_stamp string
  27666. if miConfig.MdtrtareaAdmvs == "421300" {
  27667. data := make(map[string]interface{})
  27668. client := &http.Client{}
  27669. data["psn_no"] = his.PsnNo
  27670. data["mdtrt_id"] = his.Number
  27671. data["department"] = department.Name
  27672. data["org_name"] = miConfig.OrgName
  27673. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27674. data["doctor_id"] = doctor_info.DoctorNumber
  27675. data["doctor_name"] = roles.UserName
  27676. data["fixmedins_code"] = miConfig.Code
  27677. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27678. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27679. data["secret_key"] = miConfig.SecretKey
  27680. data["sick_code"] = sickConfig.CountryCode
  27681. data["sick_name"] = sickConfig.ClassName
  27682. data["begin_time"] = begin_time
  27683. data["dept"] = strconv.FormatInt(department.ID, 10)
  27684. data["config"] = config
  27685. data["opter"] = roles.UserName
  27686. fmt.Println(data)
  27687. bytesData, _ := json.Marshal(data)
  27688. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  27689. resp, _ := client.Do(req)
  27690. defer resp.Body.Close()
  27691. body, ioErr := ioutil.ReadAll(resp.Body)
  27692. if ioErr != nil {
  27693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27695. return
  27696. }
  27697. var respJSON map[string]interface{}
  27698. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27701. return
  27702. }
  27703. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27704. userJSONBytes, _ := json.Marshal(respJSON)
  27705. fmt.Println("log")
  27706. fmt.Println(string(userJSONBytes))
  27707. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27708. utils.ErrorLog("解析失败:%v", err)
  27709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27710. return
  27711. }
  27712. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27713. data := make(map[string]interface{})
  27714. client := &http.Client{}
  27715. data["psn_no"] = his.PsnNo
  27716. data["mdtrt_id"] = his.Number
  27717. data["department"] = department.Name
  27718. data["org_name"] = miConfig.OrgName
  27719. if reg_type == 11 && his.Insutype == "390" {
  27720. data["med_type"] = "110104"
  27721. } else {
  27722. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27723. }
  27724. data["doctor_id"] = doctor_info.DoctorNumber
  27725. data["doctor_name"] = roles.UserName
  27726. data["fixmedins_code"] = miConfig.Code
  27727. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27728. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27729. data["secret_key"] = miConfig.SecretKey
  27730. data["sick_code"] = sickConfig.CountryCode
  27731. data["sick_name"] = sickConfig.ClassName
  27732. data["begin_time"] = begin_time
  27733. data["dept"] = strconv.FormatInt(department.ID, 10)
  27734. data["config"] = config
  27735. data["opter"] = roles.UserName
  27736. fmt.Println(data)
  27737. bytesData, _ := json.Marshal(data)
  27738. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  27739. resp, _ := client.Do(req)
  27740. defer resp.Body.Close()
  27741. body, ioErr := ioutil.ReadAll(resp.Body)
  27742. if ioErr != nil {
  27743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27745. return
  27746. }
  27747. var respJSON map[string]interface{}
  27748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27751. return
  27752. }
  27753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27754. userJSONBytes, _ := json.Marshal(respJSON)
  27755. fmt.Println("log")
  27756. fmt.Println(string(userJSONBytes))
  27757. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27758. utils.ErrorLog("解析失败:%v", err)
  27759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27760. return
  27761. }
  27762. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27763. data := make(map[string]interface{})
  27764. client := &http.Client{}
  27765. data["psn_no"] = his.PsnNo
  27766. data["mdtrt_id"] = his.Number
  27767. data["department"] = department.Name
  27768. data["org_name"] = miConfig.OrgName
  27769. if reg_type == 11 && his.Insutype == "390" {
  27770. data["med_type"] = "110104"
  27771. } else {
  27772. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27773. }
  27774. data["doctor_id"] = doctor_info.DoctorNumber
  27775. data["doctor_name"] = roles.UserName
  27776. data["fixmedins_code"] = miConfig.Code
  27777. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27778. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27779. data["secret_key"] = miConfig.SecretKey
  27780. data["sick_code"] = sickConfig.CountryCode
  27781. data["sick_name"] = sickConfig.ClassName
  27782. data["begin_time"] = begin_time
  27783. data["dept"] = strconv.FormatInt(department.ID, 10)
  27784. data["config"] = config
  27785. data["opter"] = roles.UserName
  27786. fmt.Println(data)
  27787. bytesData, _ := json.Marshal(data)
  27788. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  27789. resp, _ := client.Do(req)
  27790. defer resp.Body.Close()
  27791. body, ioErr := ioutil.ReadAll(resp.Body)
  27792. if ioErr != nil {
  27793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27795. return
  27796. }
  27797. var respJSON map[string]interface{}
  27798. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27801. return
  27802. }
  27803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27804. userJSONBytes, _ := json.Marshal(respJSON)
  27805. fmt.Println("log")
  27806. fmt.Println(string(userJSONBytes))
  27807. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27808. utils.ErrorLog("解析失败:%v", err)
  27809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27810. return
  27811. }
  27812. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27813. data := make(map[string]interface{})
  27814. client := &http.Client{}
  27815. data["psn_no"] = his.PsnNo
  27816. data["mdtrt_id"] = his.Number
  27817. data["department"] = department.Name
  27818. data["org_name"] = miConfig.OrgName
  27819. if reg_type == 11 && his.Insutype == "390" {
  27820. data["med_type"] = "110104"
  27821. } else {
  27822. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27823. }
  27824. data["doctor_id"] = doctor_info.DoctorNumber
  27825. data["doctor_name"] = roles.UserName
  27826. data["fixmedins_code"] = miConfig.Code
  27827. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27828. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27829. data["secret_key"] = miConfig.SecretKey
  27830. data["sick_code"] = sickConfig.CountryCode
  27831. data["sick_name"] = sickConfig.ClassName
  27832. data["begin_time"] = begin_time
  27833. data["dept"] = strconv.FormatInt(department.ID, 10)
  27834. data["config"] = config
  27835. data["opter"] = roles.UserName
  27836. fmt.Println(data)
  27837. bytesData, _ := json.Marshal(data)
  27838. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  27839. resp, _ := client.Do(req)
  27840. defer resp.Body.Close()
  27841. body, ioErr := ioutil.ReadAll(resp.Body)
  27842. if ioErr != nil {
  27843. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27845. return
  27846. }
  27847. var respJSON map[string]interface{}
  27848. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27851. return
  27852. }
  27853. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27854. userJSONBytes, _ := json.Marshal(respJSON)
  27855. fmt.Println("log")
  27856. fmt.Println(string(userJSONBytes))
  27857. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27858. utils.ErrorLog("解析失败:%v", err)
  27859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27860. return
  27861. }
  27862. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27863. data := make(map[string]interface{})
  27864. client := &http.Client{}
  27865. data["psn_no"] = his.PsnNo
  27866. data["mdtrt_id"] = his.Number
  27867. data["doctor"] = roles.UserName
  27868. data["department"] = department.Name
  27869. data["org_name"] = miConfig.OrgName
  27870. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27871. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  27872. data["fixmedins_code"] = miConfig.Code
  27873. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27874. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27875. data["secret_key"] = miConfig.SecretKey
  27876. data["sick_code"] = sickConfig.CountryCode
  27877. data["sick_name"] = sickConfig.ClassName
  27878. data["begin_time"] = begin_time
  27879. data["dept"] = strconv.FormatInt(department.ID, 10)
  27880. data["config"] = config
  27881. data["url"] = miConfig.Url
  27882. data["ak"] = miConfig.AccessKey
  27883. data["cainfo"] = miConfig.Cainfo
  27884. bytesData, _ := json.Marshal(data)
  27885. var req *http.Request
  27886. if miConfig.MdtrtareaAdmvs == "320921" {
  27887. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  27888. } else {
  27889. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  27890. }
  27891. resp, _ := client.Do(req)
  27892. defer resp.Body.Close()
  27893. body, ioErr := ioutil.ReadAll(resp.Body)
  27894. if ioErr != nil {
  27895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27897. return
  27898. }
  27899. var respJSON map[string]interface{}
  27900. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27903. return
  27904. }
  27905. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  27906. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  27907. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  27908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27909. userJSONBytes, _ := json.Marshal(respJSON)
  27910. fmt.Println("log")
  27911. fmt.Println(string(userJSONBytes))
  27912. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  27913. utils.ErrorLog("解析失败:%v", err)
  27914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27915. return
  27916. }
  27917. res2.InfRefmsgid = resSix10265.InfRefmsgid
  27918. res2.Output = resSix10265.Output
  27919. res2.ErrMsg = resSix10265.ErrMsg
  27920. res2.Cainfo = resSix10265.Cainfo
  27921. res2.WarnMsg = resSix10265.WarnMsg
  27922. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  27923. res2.Infcode = infocode
  27924. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27925. data := make(map[string]interface{})
  27926. client := &http.Client{}
  27927. data["psn_no"] = his.PsnNo
  27928. data["mdtrt_id"] = his.Number
  27929. data["doctor"] = roles.UserName
  27930. data["department"] = department.Name
  27931. data["org_name"] = miConfig.OrgName
  27932. data["med_type"] = strconv.FormatInt(reg_type, 10)
  27933. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  27934. data["fixmedins_code"] = miConfig.Code
  27935. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27936. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  27937. data["secret_key"] = miConfig.SecretKey
  27938. data["sick_code"] = sickConfig.CountryCode
  27939. data["sick_name"] = sickConfig.ClassName
  27940. data["begin_time"] = begin_time
  27941. data["dept"] = strconv.FormatInt(department.ID, 10)
  27942. data["config"] = config
  27943. //data["url"] = miConfig.Url
  27944. //data["ak"] = miConfig.AccessKey
  27945. data["cainfo"] = miConfig.Cainfo
  27946. fmt.Println(data)
  27947. bytesData, _ := json.Marshal(data)
  27948. var req *http.Request
  27949. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  27950. resp, _ := client.Do(req)
  27951. defer resp.Body.Close()
  27952. body, ioErr := ioutil.ReadAll(resp.Body)
  27953. if ioErr != nil {
  27954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27956. return
  27957. }
  27958. var respJSON map[string]interface{}
  27959. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27962. return
  27963. }
  27964. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  27965. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  27966. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  27967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27968. userJSONBytes, _ := json.Marshal(respJSON)
  27969. fmt.Println("log")
  27970. fmt.Println(string(userJSONBytes))
  27971. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  27972. utils.ErrorLog("解析失败:%v", err)
  27973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27974. return
  27975. }
  27976. res2.InfRefmsgid = resSix10265.InfRefmsgid
  27977. res2.Output = resSix10265.Output
  27978. res2.ErrMsg = resSix10265.ErrMsg
  27979. res2.Cainfo = resSix10265.Cainfo
  27980. res2.WarnMsg = resSix10265.WarnMsg
  27981. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  27982. res2.Infcode = infocode
  27983. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27984. 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)
  27985. saveLog(result, requestLog, "2203", "上传就诊信息")
  27986. var respJSON2 map[string]interface{}
  27987. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  27988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27990. return
  27991. }
  27992. userJSONBytes2, _ := json.Marshal(respJSON2)
  27993. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27994. utils.ErrorLog("解析失败:%v", err)
  27995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27996. return
  27997. }
  27998. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27999. var result string
  28000. var requestLog string
  28001. 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, "")
  28002. saveLog(result, requestLog, "2203", "上传就诊信息")
  28003. var respJSON2 map[string]interface{}
  28004. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28007. return
  28008. }
  28009. userJSONBytes2, _ := json.Marshal(respJSON2)
  28010. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28011. utils.ErrorLog("解析失败:%v", err)
  28012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28013. return
  28014. }
  28015. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28016. var result string
  28017. var requestLog string
  28018. 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, "")
  28019. saveLog(result, requestLog, "2203", "上传就诊信息")
  28020. var respJSON2 map[string]interface{}
  28021. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28024. return
  28025. }
  28026. userJSONBytes2, _ := json.Marshal(respJSON2)
  28027. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28028. utils.ErrorLog("解析失败:%v", err)
  28029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28030. return
  28031. }
  28032. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28033. data := make(map[string]interface{})
  28034. client := &http.Client{}
  28035. data["psn_no"] = his.PsnNo
  28036. data["mdtrt_id"] = his.Number
  28037. data["operator"] = roles.UserName
  28038. data["department"] = department.Name
  28039. data["org_name"] = miConfig.OrgName
  28040. var med_type string
  28041. if his.Insutype == "390" {
  28042. if reg_type == 992102 {
  28043. med_type = "992102"
  28044. data["sick_code"] = "ZDZ940"
  28045. data["sick_name"] = "慢性肾衰竭"
  28046. }
  28047. if reg_type == 140104 {
  28048. med_type = "140104"
  28049. data["sick_code"] = sickConfig.CountryCode
  28050. data["sick_name"] = sickConfig.ClassName
  28051. }
  28052. if reg_type == 14 {
  28053. med_type = "140104"
  28054. data["sick_code"] = sickConfig.CountryCode
  28055. data["sick_name"] = sickConfig.ClassName
  28056. }
  28057. } else if his.Insutype == "310" {
  28058. if reg_type == 992102 {
  28059. med_type = "992102"
  28060. data["sick_code"] = "ZDZ940"
  28061. data["sick_name"] = "慢性肾衰竭"
  28062. }
  28063. if reg_type == 140104 {
  28064. med_type = "140104"
  28065. data["sick_code"] = sickConfig.CountryCode
  28066. data["sick_name"] = sickConfig.ClassName
  28067. }
  28068. if reg_type == 14 {
  28069. med_type = "14"
  28070. data["sick_code"] = sickConfig.CountryCode
  28071. data["sick_name"] = sickConfig.ClassName
  28072. }
  28073. }
  28074. data["med_type"] = med_type
  28075. data["doctor_number"] = doctor_info.DoctorNumber
  28076. data["doctor_name"] = doctor_info.UserName
  28077. data["fixmedins_code"] = miConfig.Code
  28078. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28079. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28080. data["secret_key"] = miConfig.SecretKey
  28081. data["begin_time"] = begin_time
  28082. data["dept"] = strconv.FormatInt(department.ID, 10)
  28083. data["config"] = config
  28084. data["url"] = miConfig.Url
  28085. data["ak"] = miConfig.AccessKey
  28086. data["cainfo"] = miConfig.Cainfo
  28087. bytesData, _ := json.Marshal(data)
  28088. var req *http.Request
  28089. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28090. resp, _ := client.Do(req)
  28091. defer resp.Body.Close()
  28092. body, ioErr := ioutil.ReadAll(resp.Body)
  28093. if ioErr != nil {
  28094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28096. return
  28097. }
  28098. var respJSON map[string]interface{}
  28099. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28102. return
  28103. }
  28104. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28105. if status == "0" {
  28106. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28107. c.ServeSuccessJSON(map[string]interface{}{
  28108. "failed_code": -10,
  28109. "msg": err_msg,
  28110. })
  28111. return
  28112. }
  28113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28114. userJSONBytes, _ := json.Marshal(respJSON)
  28115. fmt.Println("log")
  28116. fmt.Println(string(userJSONBytes))
  28117. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28118. utils.ErrorLog("解析失败:%v", err)
  28119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28120. return
  28121. }
  28122. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28123. data := make(map[string]interface{})
  28124. client := &http.Client{}
  28125. data["psn_no"] = his.PsnNo
  28126. data["mdtrt_id"] = his.Number
  28127. data["operator"] = roles.UserName
  28128. data["department"] = department.Name
  28129. data["org_name"] = miConfig.OrgName
  28130. var med_type string
  28131. if his.Insutype == "390" {
  28132. if reg_type == 992102 {
  28133. med_type = "992102"
  28134. data["sick_code"] = sickConfig.CountryCode
  28135. data["sick_name"] = sickConfig.ClassName
  28136. }
  28137. if reg_type == 140104 {
  28138. med_type = "140104"
  28139. data["sick_code"] = sickConfig.CountryCode
  28140. data["sick_name"] = sickConfig.ClassName
  28141. }
  28142. if reg_type == 140201 {
  28143. med_type = "140201"
  28144. data["sick_code"] = sickConfig.CountryCode
  28145. data["sick_name"] = sickConfig.ClassName
  28146. }
  28147. if reg_type == 14 {
  28148. med_type = "14"
  28149. data["sick_code"] = sickConfig.CountryCode
  28150. data["sick_name"] = sickConfig.ClassName
  28151. }
  28152. } else if his.Insutype == "310" {
  28153. if reg_type == 992102 {
  28154. med_type = "992102"
  28155. data["sick_code"] = sickConfig.CountryCode
  28156. data["sick_name"] = sickConfig.ClassName
  28157. }
  28158. if reg_type == 140104 {
  28159. med_type = "140104"
  28160. data["sick_code"] = sickConfig.CountryCode
  28161. data["sick_name"] = sickConfig.ClassName
  28162. }
  28163. if reg_type == 140201 {
  28164. med_type = "140201"
  28165. data["sick_code"] = sickConfig.CountryCode
  28166. data["sick_name"] = sickConfig.ClassName
  28167. }
  28168. if reg_type == 14 {
  28169. med_type = "14"
  28170. data["sick_code"] = sickConfig.CountryCode
  28171. data["sick_name"] = sickConfig.ClassName
  28172. }
  28173. }
  28174. data["med_type"] = med_type
  28175. data["doctor_number"] = doctor_info.DoctorNumber
  28176. data["doctor_name"] = doctor_info.UserName
  28177. data["fixmedins_code"] = miConfig.Code
  28178. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28179. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28180. data["secret_key"] = miConfig.SecretKey
  28181. data["begin_time"] = begin_time
  28182. data["dept"] = strconv.FormatInt(department.ID, 10)
  28183. data["config"] = config
  28184. data["url"] = miConfig.Url
  28185. data["ak"] = miConfig.AccessKey
  28186. data["cainfo"] = miConfig.Cainfo
  28187. bytesData, _ := json.Marshal(data)
  28188. var req *http.Request
  28189. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28190. resp, _ := client.Do(req)
  28191. defer resp.Body.Close()
  28192. body, ioErr := ioutil.ReadAll(resp.Body)
  28193. if ioErr != nil {
  28194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28196. return
  28197. }
  28198. var respJSON map[string]interface{}
  28199. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28202. return
  28203. }
  28204. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28205. if status == "0" {
  28206. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28207. c.ServeSuccessJSON(map[string]interface{}{
  28208. "failed_code": -10,
  28209. "msg": err_msg,
  28210. })
  28211. return
  28212. }
  28213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28214. userJSONBytes, _ := json.Marshal(respJSON)
  28215. fmt.Println("log")
  28216. fmt.Println(string(userJSONBytes))
  28217. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28218. utils.ErrorLog("解析失败:%v", err)
  28219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28220. return
  28221. }
  28222. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28223. var result string
  28224. var requestLog string
  28225. 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, "")
  28226. saveLog(result, requestLog, "2203", "上传就诊信息")
  28227. var respJSON2 map[string]interface{}
  28228. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28229. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28231. return
  28232. }
  28233. userJSONBytes2, _ := json.Marshal(respJSON2)
  28234. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28235. utils.ErrorLog("解析失败:%v", err)
  28236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28237. return
  28238. }
  28239. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28240. data := make(map[string]interface{})
  28241. client := &http.Client{}
  28242. data["psn_no"] = his.PsnNo
  28243. data["mdtrt_id"] = his.Number
  28244. data["doctor"] = roles.UserName
  28245. data["department"] = department.Name
  28246. data["org_name"] = miConfig.OrgName
  28247. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28248. data["doctor_id"] = doctor_info.DoctorNumber
  28249. data["fixmedins_code"] = miConfig.Code
  28250. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28251. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28252. data["secret_key"] = miConfig.SecretKey
  28253. data["sick_code"] = sickConfig.CountryCode
  28254. data["sick_name"] = sickConfig.ClassName
  28255. data["begin_time"] = begin_time
  28256. data["new_doctor_name"] = doctor_info.UserName
  28257. data["dept"] = strconv.FormatInt(department.ID, 10)
  28258. data["config"] = config
  28259. bytesData, _ := json.Marshal(data)
  28260. var req *http.Request
  28261. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28262. resp, _ := client.Do(req)
  28263. defer resp.Body.Close()
  28264. body, ioErr := ioutil.ReadAll(resp.Body)
  28265. if ioErr != nil {
  28266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28268. return
  28269. }
  28270. var respJSON map[string]interface{}
  28271. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28274. return
  28275. }
  28276. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28277. userJSONBytes, _ := json.Marshal(respJSON)
  28278. fmt.Println("log")
  28279. fmt.Println(string(userJSONBytes))
  28280. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28281. utils.ErrorLog("解析失败:%v", err)
  28282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28283. return
  28284. }
  28285. } else {
  28286. var result string
  28287. var requestLog string
  28288. if miConfig.MdtrtareaAdmvs == "440781" { //
  28289. 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)
  28290. } else {
  28291. if miConfig.Code == "H15049901371" {
  28292. //赤峰地区国家医保医疗类别
  28293. //职工透析:医疗类别选特殊情况门诊990502
  28294. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28295. var med_type string
  28296. if his.Insutype == "390" {
  28297. if reg_type == 14 {
  28298. med_type = "9933"
  28299. } else if reg_type == 11 {
  28300. med_type = "11"
  28301. }
  28302. } else if his.Insutype == "310" {
  28303. if reg_type == 14 {
  28304. med_type = "990502"
  28305. } else if reg_type == 11 {
  28306. med_type = "11"
  28307. }
  28308. }
  28309. 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)
  28310. } else {
  28311. 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)
  28312. }
  28313. saveLog(result, requestLog, "2203", "上传就诊信息")
  28314. var respJSON2 map[string]interface{}
  28315. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28318. return
  28319. }
  28320. userJSONBytes2, _ := json.Marshal(respJSON2)
  28321. if miConfig.Code == "H15049901371" {
  28322. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28323. utils.ErrorLog("解析失败:%v", err)
  28324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28325. return
  28326. }
  28327. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28328. res2.Output = resSix10265.Output
  28329. res2.ErrMsg = resSix10265.ErrMsg
  28330. res2.Cainfo = resSix10265.Cainfo
  28331. res2.WarnMsg = resSix10265.WarnMsg
  28332. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28333. res2.Infcode = infocode
  28334. } else {
  28335. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28336. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28337. utils.ErrorLog("解析失败:%v", err)
  28338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28339. return
  28340. }
  28341. res2.Infcode = res3.Infcode
  28342. } else {
  28343. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28344. utils.ErrorLog("解析失败:%v", err)
  28345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28346. return
  28347. }
  28348. }
  28349. }
  28350. }
  28351. }
  28352. if res2.Infcode == -1 {
  28353. adminUser := c.GetAdminUserInfo()
  28354. errlog := &models.HisOrderError{
  28355. UserOrgId: adminUser.CurrentOrgId,
  28356. Ctime: time.Now().Unix(),
  28357. Mtime: time.Now().Unix(),
  28358. ErrMsg: res2.ErrMsg,
  28359. Status: 1,
  28360. PatientId: id,
  28361. RecordTime: recordDateTime,
  28362. Stage: 3,
  28363. }
  28364. service.CreateErrMsgLog(errlog)
  28365. c.ServeSuccessJSON(map[string]interface{}{
  28366. "failed_code": -10,
  28367. "msg": res2.ErrMsg,
  28368. })
  28369. return
  28370. }
  28371. if res2.Infcode != 0 {
  28372. adminUser := c.GetAdminUserInfo()
  28373. errlog := &models.HisOrderError{
  28374. UserOrgId: adminUser.CurrentOrgId,
  28375. Ctime: time.Now().Unix(),
  28376. Mtime: time.Now().Unix(),
  28377. ErrMsg: res2.ErrMsg,
  28378. Status: 1,
  28379. PatientId: id,
  28380. RecordTime: recordDateTime,
  28381. Stage: 3,
  28382. }
  28383. service.CreateErrMsgLog(errlog)
  28384. c.ServeSuccessJSON(map[string]interface{}{
  28385. "failed_code": -10,
  28386. "msg": res2.ErrMsg,
  28387. })
  28388. return
  28389. } else {
  28390. his.Diagnosis = diagnosis_id
  28391. his.SickType = sickConfig.ID
  28392. his.PType = fmt.Sprintf("%d", reg_type)
  28393. service.UpdateHisPatientThree(&his)
  28394. data := make(map[string]interface{})
  28395. if settle_accounts_type == 1 { //日结
  28396. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28397. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28398. } else {
  28399. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28400. }
  28401. data["pre"] = prescriptions
  28402. } else { //月结
  28403. start_time_str := c.GetString("start_time")
  28404. end_time_str := c.GetString("end_time")
  28405. timeLayout := "2006-01-02"
  28406. loc, _ := time.LoadLocation("Local")
  28407. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28408. if err != nil {
  28409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28410. return
  28411. }
  28412. recordStartTime := theStartTime.Unix()
  28413. start_time = recordStartTime
  28414. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28415. if err != nil {
  28416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28417. return
  28418. }
  28419. recordEndTime := theEndTime.Unix()
  28420. end_time = recordEndTime
  28421. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28422. data["pre"] = prescriptions
  28423. }
  28424. client := &http.Client{}
  28425. data["psn_no"] = his.PsnNo
  28426. data["mdtrt_id"] = his.Number
  28427. data["chrg_bchno"] = new_chrg_bchno
  28428. data["org_name"] = miConfig.OrgName
  28429. data["doctor"] = doctor_info.UserName
  28430. data["doctor_id"] = doctor_info.DoctorNumber
  28431. data["dept"] = department.Name
  28432. data["fixmedins_code"] = miConfig.Code
  28433. data["opter"] = roles.UserName
  28434. data["dept_code"] = department.Number
  28435. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28436. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28437. data["secret_key"] = miConfig.SecretKey
  28438. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28439. data["url"] = miConfig.Url
  28440. data["ak"] = miConfig.AccessKey
  28441. data["new_doctor_name"] = patientPrescription.Doctor
  28442. if his.Insutype == "390" {
  28443. if reg_type == 992102 {
  28444. data["diag_code"] = "ZDZ940"
  28445. }
  28446. if reg_type == 140104 {
  28447. data["diag_code"] = sickConfig.CountryCode
  28448. }
  28449. if reg_type == 140201 {
  28450. data["diag_code"] = sickConfig.CountryCode
  28451. }
  28452. if reg_type == 14 {
  28453. data["diag_code"] = sickConfig.CountryCode
  28454. }
  28455. } else if his.Insutype == "310" {
  28456. if miConfig.MdtrtareaAdmvs == "341203" {
  28457. if reg_type == 992102 {
  28458. data["diag_code"] = "ZDZ940"
  28459. }
  28460. if reg_type != 992102 {
  28461. data["diag_code"] = sickConfig.CountryCode
  28462. }
  28463. } else {
  28464. data["diag_code"] = sickConfig.CountryCode
  28465. }
  28466. }
  28467. data["cainfo"] = miConfig.Cainfo
  28468. data["opter"] = roles.UserName
  28469. var ids []int64
  28470. for _, item := range prescriptions {
  28471. ids = append(ids, item.ID)
  28472. }
  28473. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28474. if config.IsOpen == 1 { //对接了医保,走医保流程
  28475. var res ResultFour
  28476. var resFour10265 ResultFour10265
  28477. if miConfig.MdtrtareaAdmvs == "421300" {
  28478. bytesData, _ := json.Marshal(data)
  28479. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28480. resp, _ := client.Do(req)
  28481. defer resp.Body.Close()
  28482. body, ioErr := ioutil.ReadAll(resp.Body)
  28483. if ioErr != nil {
  28484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28486. return
  28487. }
  28488. var respJSON map[string]interface{}
  28489. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28492. return
  28493. }
  28494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28495. userJSONBytes, _ := json.Marshal(respJSON)
  28496. fmt.Println("log")
  28497. fmt.Println(string(userJSONBytes))
  28498. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28499. utils.ErrorLog("解析失败:%v", err)
  28500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28501. return
  28502. }
  28503. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28504. bytesData, _ := json.Marshal(data)
  28505. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28506. resp, _ := client.Do(req)
  28507. defer resp.Body.Close()
  28508. body, ioErr := ioutil.ReadAll(resp.Body)
  28509. if ioErr != nil {
  28510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28512. return
  28513. }
  28514. var respJSON map[string]interface{}
  28515. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28518. return
  28519. }
  28520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28521. userJSONBytes, _ := json.Marshal(respJSON)
  28522. fmt.Println("log")
  28523. fmt.Println(string(userJSONBytes))
  28524. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28525. utils.ErrorLog("解析失败:%v", err)
  28526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28527. return
  28528. }
  28529. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28530. bytesData, _ := json.Marshal(data)
  28531. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28532. resp, _ := client.Do(req)
  28533. defer resp.Body.Close()
  28534. body, ioErr := ioutil.ReadAll(resp.Body)
  28535. if ioErr != nil {
  28536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28538. return
  28539. }
  28540. var respJSON map[string]interface{}
  28541. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28544. return
  28545. }
  28546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28547. userJSONBytes, _ := json.Marshal(respJSON)
  28548. fmt.Println("log")
  28549. fmt.Println(string(userJSONBytes))
  28550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28551. utils.ErrorLog("解析失败:%v", err)
  28552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28553. return
  28554. }
  28555. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28556. bytesData, _ := json.Marshal(data)
  28557. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28558. resp, _ := client.Do(req)
  28559. defer resp.Body.Close()
  28560. body, ioErr := ioutil.ReadAll(resp.Body)
  28561. if ioErr != nil {
  28562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28564. return
  28565. }
  28566. var respJSON map[string]interface{}
  28567. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28570. return
  28571. }
  28572. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28573. userJSONBytes, _ := json.Marshal(respJSON)
  28574. fmt.Println("log")
  28575. fmt.Println(string(userJSONBytes))
  28576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28577. utils.ErrorLog("解析失败:%v", err)
  28578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28579. return
  28580. }
  28581. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28582. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28583. if result3101.Infcode == "0" {
  28584. if len(result3101.Output.Result) > 0 {
  28585. var errMsgs []string
  28586. for _, item := range result3101.Output.Result {
  28587. errMsgs = append(errMsgs, item.VolaCont)
  28588. }
  28589. c.ServeSuccessJSON(map[string]interface{}{
  28590. "failed_code": -10,
  28591. "msg": errMsgs,
  28592. })
  28593. return
  28594. } else {
  28595. if miConfig.MdtrtareaAdmvs == "320921" {
  28596. data["doctor_id"] = "D320923012139"
  28597. } else {
  28598. data["doctor_id"] = "D371621008686"
  28599. }
  28600. bytesData, _ := json.Marshal(data)
  28601. var req *http.Request
  28602. if miConfig.MdtrtareaAdmvs == "320921" {
  28603. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28604. } else {
  28605. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28606. }
  28607. resp, _ := client.Do(req)
  28608. defer resp.Body.Close()
  28609. body, ioErr := ioutil.ReadAll(resp.Body)
  28610. if ioErr != nil {
  28611. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28613. return
  28614. }
  28615. var respJSON map[string]interface{}
  28616. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28619. return
  28620. }
  28621. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28622. userJSONBytes, _ := json.Marshal(respJSON)
  28623. fmt.Println("log")
  28624. fmt.Println(string(userJSONBytes))
  28625. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28626. utils.ErrorLog("解析失败:%v", err)
  28627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28628. return
  28629. }
  28630. res.InfRefmsgid = resFour10265.InfRefmsgid
  28631. res.Output = resFour10265.Output
  28632. res.ErrMsg = resFour10265.ErrMsg
  28633. res.Cainfo = resFour10265.Cainfo
  28634. res.WarnMsg = resFour10265.WarnMsg
  28635. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28636. res.Infcode = infocode
  28637. }
  28638. }
  28639. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28640. var pagesize int = 5
  28641. var start int = 1
  28642. var stop int
  28643. var pagecount int
  28644. var curpage int
  28645. data["doctor_id"] = doctor_info.DoctorNumber
  28646. var res2 ResultFour
  28647. //var result res.
  28648. //总页数,向上取整,注意除之前要先转换类型为float64
  28649. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  28650. for curpage = 1; curpage <= pagecount; curpage++ {
  28651. if curpage == 1 {
  28652. start = 1
  28653. } else {
  28654. start = (curpage-1)*pagesize + 1
  28655. }
  28656. stop = curpage * pagesize
  28657. if stop > len(prescriptions) {
  28658. stop = len(prescriptions)
  28659. }
  28660. //var requestLog string
  28661. data["pre"] = prescriptions[start-1 : stop]
  28662. fmt.Println(data["pre"])
  28663. bytesData, _ := json.Marshal(data)
  28664. var req *http.Request
  28665. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  28666. resp, _ := client.Do(req)
  28667. defer resp.Body.Close()
  28668. body, ioErr := ioutil.ReadAll(resp.Body)
  28669. if ioErr != nil {
  28670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28672. return
  28673. }
  28674. var respJSON map[string]interface{}
  28675. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28678. return
  28679. }
  28680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28681. userJSONBytes, _ := json.Marshal(respJSON)
  28682. fmt.Println("log")
  28683. fmt.Println(string(userJSONBytes))
  28684. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  28685. utils.ErrorLog("解析失败:%v", err)
  28686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28687. return
  28688. }
  28689. res.InfRefmsgid = resFour10265.InfRefmsgid
  28690. res.Output = resFour10265.Output
  28691. res.ErrMsg = resFour10265.ErrMsg
  28692. res.Cainfo = resFour10265.Cainfo
  28693. res.WarnMsg = resFour10265.WarnMsg
  28694. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  28695. res.Infcode = infocode
  28696. if infocode == 0 {
  28697. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  28698. } else {
  28699. isSuccess = false
  28700. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  28701. res.Infcode = -1
  28702. res.ErrMsg = resFour10265.ErrMsg
  28703. errlog := &models.HisOrderError{
  28704. UserOrgId: adminUser.CurrentOrgId,
  28705. Ctime: time.Now().Unix(),
  28706. Mtime: time.Now().Unix(),
  28707. Number: chrg_bchno,
  28708. ErrMsg: "",
  28709. Status: 1,
  28710. PatientId: id,
  28711. RecordTime: recordDateTime,
  28712. Stage: 4,
  28713. }
  28714. service.CreateErrMsgLog(errlog)
  28715. }
  28716. }
  28717. if isSuccess {
  28718. res.Infcode = 0
  28719. res.Output.Result = res2.Output.Result
  28720. } else {
  28721. order := &models.HisOrder{
  28722. UserOrgId: adminUser.CurrentOrgId,
  28723. HisPatientId: his.ID,
  28724. PatientId: his.PatientId,
  28725. SettleAccountsDate: recordDateTime,
  28726. Ctime: time.Now().Unix(),
  28727. Mtime: time.Now().Unix(),
  28728. MdtrtId: his.Number,
  28729. PsnNo: his.PsnNo,
  28730. MedType: strconv.FormatInt(reg_type, 10),
  28731. Status: 1,
  28732. Number: chrg_bchno,
  28733. Infcode: res.Infcode,
  28734. WarnMsg: res.WarnMsg,
  28735. Cainfo: res.Cainfo,
  28736. ErrMsg: res.ErrMsg,
  28737. RespondTime: res.RefmsgTime,
  28738. InfRefmsgid: res.InfRefmsgid,
  28739. OrderStatus: 1,
  28740. IsMedicineInsurance: 1,
  28741. SettleType: settle_accounts_type,
  28742. SettleStartTime: start_time,
  28743. SettleEndTime: end_time,
  28744. Creator: roles.AdminUserId,
  28745. Modify: roles.AdminUserId,
  28746. PType: 2,
  28747. Diagnosis: diagnosis_id,
  28748. }
  28749. err = service.CreateOrder(order)
  28750. if err != nil {
  28751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  28752. return
  28753. }
  28754. c.ServeSuccessJSON(map[string]interface{}{
  28755. "failed_code": -10,
  28756. "msg": res2.ErrMsg,
  28757. })
  28758. return
  28759. }
  28760. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28761. 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)
  28762. var dat map[string]interface{}
  28763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28764. fmt.Println(dat)
  28765. } else {
  28766. fmt.Println(err)
  28767. }
  28768. saveLog(result, request_log, "2204", "上传费用明细")
  28769. userJSONBytes, _ := json.Marshal(dat)
  28770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28771. utils.ErrorLog("解析失败:%v", err)
  28772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28773. return
  28774. }
  28775. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28776. 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, "", "")
  28777. var dat map[string]interface{}
  28778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28779. fmt.Println(dat)
  28780. } else {
  28781. fmt.Println(err)
  28782. }
  28783. saveLog(result, request_log, "2204", "上传费用明细")
  28784. userJSONBytes, _ := json.Marshal(dat)
  28785. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28786. utils.ErrorLog("解析失败:%v", err)
  28787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28788. return
  28789. }
  28790. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28791. 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, "", "")
  28792. var dat map[string]interface{}
  28793. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28794. fmt.Println(dat)
  28795. } else {
  28796. fmt.Println(err)
  28797. }
  28798. saveLog(result, request_log, "2204", "上传费用明细")
  28799. userJSONBytes, _ := json.Marshal(dat)
  28800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28801. utils.ErrorLog("解析失败:%v", err)
  28802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28803. return
  28804. }
  28805. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28806. bytesData, _ := json.Marshal(data)
  28807. var req *http.Request
  28808. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  28809. resp, _ := client.Do(req)
  28810. defer resp.Body.Close()
  28811. body, ioErr := ioutil.ReadAll(resp.Body)
  28812. if ioErr != nil {
  28813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28815. return
  28816. }
  28817. var respJSON map[string]interface{}
  28818. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28821. return
  28822. }
  28823. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28824. if status == "0" {
  28825. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28826. c.ServeSuccessJSON(map[string]interface{}{
  28827. "failed_code": -10,
  28828. "msg": err_msg,
  28829. })
  28830. return
  28831. }
  28832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28833. userJSONBytes, _ := json.Marshal(respJSON)
  28834. fmt.Println("log")
  28835. fmt.Println(string(userJSONBytes))
  28836. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28837. utils.ErrorLog("解析失败:%v", err)
  28838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28839. return
  28840. }
  28841. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28842. bytesData, _ := json.Marshal(data)
  28843. var req *http.Request
  28844. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  28845. resp, _ := client.Do(req)
  28846. defer resp.Body.Close()
  28847. body, ioErr := ioutil.ReadAll(resp.Body)
  28848. if ioErr != nil {
  28849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28851. return
  28852. }
  28853. var respJSON map[string]interface{}
  28854. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28857. return
  28858. }
  28859. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28860. if status == "0" {
  28861. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28862. c.ServeSuccessJSON(map[string]interface{}{
  28863. "failed_code": -10,
  28864. "msg": err_msg,
  28865. })
  28866. return
  28867. }
  28868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28869. userJSONBytes, _ := json.Marshal(respJSON)
  28870. fmt.Println("log")
  28871. fmt.Println(string(userJSONBytes))
  28872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28873. utils.ErrorLog("解析失败:%v", err)
  28874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28875. return
  28876. }
  28877. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28878. 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, "", "")
  28879. var dat map[string]interface{}
  28880. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28881. fmt.Println(dat)
  28882. } else {
  28883. fmt.Println(err)
  28884. }
  28885. saveLog(result, request_log, "2204", "上传费用明细")
  28886. userJSONBytes, _ := json.Marshal(dat)
  28887. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28888. utils.ErrorLog("解析失败:%v", err)
  28889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28890. return
  28891. }
  28892. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28893. bytesData, _ := json.Marshal(data)
  28894. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  28895. resp, _ := client.Do(req)
  28896. defer resp.Body.Close()
  28897. body, ioErr := ioutil.ReadAll(resp.Body)
  28898. if ioErr != nil {
  28899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28901. return
  28902. }
  28903. var respJSON map[string]interface{}
  28904. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28907. return
  28908. }
  28909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28910. userJSONBytes, _ := json.Marshal(respJSON)
  28911. fmt.Println("log")
  28912. fmt.Println(string(userJSONBytes))
  28913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28914. utils.ErrorLog("解析失败:%v", err)
  28915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28916. return
  28917. }
  28918. } else {
  28919. if miConfig.MdtrtareaAdmvs == "441202" {
  28920. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28921. if result3101.Infcode == 0 {
  28922. if len(result3101.Output.Result) > 0 {
  28923. var errMsgs []string
  28924. for _, item := range result3101.Output.Result {
  28925. errMsgs = append(errMsgs, item.VolaCont)
  28926. }
  28927. c.ServeSuccessJSON(map[string]interface{}{
  28928. "failed_code": -10,
  28929. "msg": errMsgs,
  28930. })
  28931. return
  28932. } else {
  28933. 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)
  28934. var dat map[string]interface{}
  28935. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28936. fmt.Println(dat)
  28937. } else {
  28938. fmt.Println(err)
  28939. }
  28940. saveLog(result, request_log, "2204", "上传费用明细")
  28941. userJSONBytes, _ := json.Marshal(dat)
  28942. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28943. utils.ErrorLog("解析失败:%v", err)
  28944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28945. return
  28946. }
  28947. }
  28948. } else {
  28949. c.ServeSuccessJSON(map[string]interface{}{
  28950. "failed_code": -10,
  28951. "msg": result3101.ErrMsg,
  28952. })
  28953. return
  28954. }
  28955. } else if miConfig.MdtrtareaAdmvs == "440205" {
  28956. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  28957. if result3101.Infcode == 0 {
  28958. if len(result3101.Output.Result) > 0 {
  28959. var errMsgs []string
  28960. for _, item := range result3101.Output.Result {
  28961. errMsgs = append(errMsgs, item.VolaCont)
  28962. }
  28963. c.ServeSuccessJSON(map[string]interface{}{
  28964. "failed_code": -10,
  28965. "msg": errMsgs,
  28966. })
  28967. return
  28968. } else {
  28969. 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)
  28970. var dat map[string]interface{}
  28971. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28972. fmt.Println(dat)
  28973. } else {
  28974. fmt.Println(err)
  28975. }
  28976. saveLog(result, request_log, "2204", "上传费用明细")
  28977. userJSONBytes, _ := json.Marshal(dat)
  28978. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28979. utils.ErrorLog("解析失败:%v", err)
  28980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28981. return
  28982. }
  28983. }
  28984. } else {
  28985. c.ServeSuccessJSON(map[string]interface{}{
  28986. "failed_code": -10,
  28987. "msg": result3101.ErrMsg,
  28988. })
  28989. return
  28990. }
  28991. } else {
  28992. if miConfig.Code == "H15049901371" {
  28993. 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)
  28994. var dat map[string]interface{}
  28995. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28996. fmt.Println(dat)
  28997. } else {
  28998. fmt.Println(err)
  28999. }
  29000. saveLog(result, request_log, "2204", "上传费用明细")
  29001. userJSONBytes, _ := json.Marshal(dat)
  29002. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29003. utils.ErrorLog("解析失败:%v", err)
  29004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29005. return
  29006. }
  29007. res.InfRefmsgid = resFour10265.InfRefmsgid
  29008. res.Output = resFour10265.Output
  29009. res.ErrMsg = resFour10265.ErrMsg
  29010. res.Cainfo = resFour10265.Cainfo
  29011. res.WarnMsg = resFour10265.WarnMsg
  29012. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29013. res.Infcode = infocode
  29014. } else {
  29015. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" {
  29016. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29017. if result3101.Infcode == 0 {
  29018. if len(result3101.Output.Result) > 0 {
  29019. var errMsgs []string
  29020. for _, item := range result3101.Output.Result {
  29021. errMsgs = append(errMsgs, item.VolaCont)
  29022. }
  29023. c.ServeSuccessJSON(map[string]interface{}{
  29024. "failed_code": -10,
  29025. "msg": errMsgs,
  29026. })
  29027. return
  29028. } else {
  29029. 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)
  29030. var dat map[string]interface{}
  29031. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29032. fmt.Println(dat)
  29033. } else {
  29034. fmt.Println(err)
  29035. }
  29036. saveLog(result, request_log, "2204", "上传费用明细")
  29037. userJSONBytes, _ := json.Marshal(dat)
  29038. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29039. utils.ErrorLog("解析失败:%v", err)
  29040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29041. return
  29042. }
  29043. }
  29044. } else {
  29045. c.ServeSuccessJSON(map[string]interface{}{
  29046. "failed_code": -10,
  29047. "msg": result3101.ErrMsg,
  29048. })
  29049. return
  29050. }
  29051. } else {
  29052. 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)
  29053. var dat map[string]interface{}
  29054. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29055. fmt.Println(dat)
  29056. } else {
  29057. fmt.Println(err)
  29058. }
  29059. saveLog(result, request_log, "2204", "上传费用明细")
  29060. userJSONBytes, _ := json.Marshal(dat)
  29061. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29062. utils.ErrorLog("解析失败:%v", err)
  29063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29064. return
  29065. }
  29066. }
  29067. }
  29068. }
  29069. }
  29070. var total_two float64
  29071. if res.Infcode == -1 {
  29072. errlog := &models.HisOrderError{
  29073. UserOrgId: adminUser.CurrentOrgId,
  29074. Ctime: time.Now().Unix(),
  29075. Mtime: time.Now().Unix(),
  29076. Number: chrg_bchno,
  29077. ErrMsg: res.ErrMsg,
  29078. Status: 1,
  29079. PatientId: id,
  29080. RecordTime: recordDateTime,
  29081. Stage: 4,
  29082. }
  29083. service.CreateErrMsgLog(errlog)
  29084. c.ServeSuccessJSON(map[string]interface{}{
  29085. "failed_code": -10,
  29086. "msg": res.ErrMsg,
  29087. })
  29088. return
  29089. }
  29090. if res.Infcode == 0 {
  29091. order := &models.HisOrder{
  29092. UserOrgId: adminUser.CurrentOrgId,
  29093. HisPatientId: his.ID,
  29094. PatientId: his.PatientId,
  29095. SettleAccountsDate: recordDateTime,
  29096. Ctime: time.Now().Unix(),
  29097. Mtime: time.Now().Unix(),
  29098. MdtrtId: his.Number,
  29099. PsnNo: his.PsnNo,
  29100. MedType: strconv.FormatInt(reg_type, 10),
  29101. Status: 1,
  29102. Number: chrg_bchno,
  29103. Infcode: res.Infcode,
  29104. WarnMsg: res.WarnMsg,
  29105. Cainfo: res.Cainfo,
  29106. ErrMsg: res.ErrMsg,
  29107. RespondTime: res.RefmsgTime,
  29108. InfRefmsgid: res.InfRefmsgid,
  29109. OrderStatus: 1,
  29110. IsMedicineInsurance: 1,
  29111. SettleType: settle_accounts_type,
  29112. SettleStartTime: start_time,
  29113. SettleEndTime: end_time,
  29114. Creator: roles.AdminUserId,
  29115. Modify: roles.AdminUserId,
  29116. PType: 2,
  29117. Diagnosis: diagnosis_id,
  29118. }
  29119. err = service.CreateOrder(order)
  29120. if err != nil {
  29121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29122. return
  29123. }
  29124. for _, item := range res.Output.Result {
  29125. temp := strings.Split(item.FeedetlSn, "-")
  29126. var advice_id int64 = 0
  29127. var project_id int64 = 0
  29128. var types int64 = 0
  29129. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29130. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29131. if temp[1] == "1" {
  29132. advice_id = id
  29133. project_id = 0
  29134. } else if temp[1] == "2" {
  29135. advice_id = 0
  29136. project_id = id
  29137. }
  29138. total_two = total_two + item.DetItemFeeSumamt
  29139. info := &models.HisOrderInfo{
  29140. OrderNumber: order.Number,
  29141. FeedetlSn: item.FeedetlSn,
  29142. UploadDate: time.Now().Unix(),
  29143. AdviceId: advice_id,
  29144. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29145. Cnt: item.Cnt,
  29146. Pric: float64(item.Pric),
  29147. PatientId: his.PatientId,
  29148. PricUplmtAmt: item.PricUplmtAmt,
  29149. SelfpayProp: item.SelfpayProp,
  29150. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29151. OverlmtAmt: item.OverlmtAmt,
  29152. PreselfpayAmt: item.PreselfpayAmt,
  29153. BasMednFlag: item.BasMednFlag,
  29154. MedChrgitmType: item.MedChrgitmType,
  29155. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29156. Status: 1,
  29157. Memo: item.Memo,
  29158. Mtime: time.Now().Unix(),
  29159. InscpScpAmt: item.InscpScpAmt,
  29160. DrtReimFlag: item.DrtReimFlag,
  29161. Ctime: time.Now().Unix(),
  29162. ListSpItemFlag: item.ListSpItemFlag,
  29163. ChldMedcFlag: item.ChldMedcFlag,
  29164. LmtUsedFlag: item.LmtUsedFlag,
  29165. ChrgitmLv: item.ChrgitmLv,
  29166. UserOrgId: adminUser.CurrentOrgId,
  29167. HisPatientId: his.ID,
  29168. OrderId: order.ID,
  29169. ProjectId: project_id,
  29170. Type: types,
  29171. }
  29172. service.CreateOrderInfo(info)
  29173. }
  29174. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29175. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29176. var total float64
  29177. for _, item := range prescriptions {
  29178. if item.Type == 1 { //药品
  29179. for _, subItem := range item.HisDoctorAdviceInfo {
  29180. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29181. total_one := price * subItem.PrescribingNumber
  29182. fmt.Println("subItem")
  29183. fmt.Println(subItem.Price)
  29184. fmt.Println("price")
  29185. fmt.Println(price)
  29186. fmt.Println("total_one")
  29187. fmt.Println(total_one)
  29188. total = total + total_one
  29189. fmt.Println(total)
  29190. }
  29191. }
  29192. if item.Type == 2 { //项目
  29193. for _, subItem := range item.HisPrescriptionProject {
  29194. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29195. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29196. total_one := price * cnt
  29197. total = total + total_one
  29198. }
  29199. }
  29200. }
  29201. allTotal := fmt.Sprintf("%.2f", total)
  29202. if res.Infcode == 0 {
  29203. var rf []*ResultFive
  29204. json.Unmarshal([]byte(his.Iinfo), &rf)
  29205. chrg_bchno := chrg_bchno
  29206. cert_no := his.Certno
  29207. var insutypes []string
  29208. var insutype string
  29209. var is390 int = 0
  29210. var is310 int = 0
  29211. for _, item := range rf {
  29212. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29213. insutypes = append(insutypes, item.Insutype)
  29214. }
  29215. }
  29216. if len(insutypes) == 1 {
  29217. insutype = insutypes[0]
  29218. } else {
  29219. for _, i := range insutypes {
  29220. if i == "390" {
  29221. is390 = 1
  29222. }
  29223. if i == "310" {
  29224. is310 = 1
  29225. }
  29226. }
  29227. }
  29228. if is390 == 1 {
  29229. insutype = "390"
  29230. }
  29231. if is310 == 1 {
  29232. insutype = "310"
  29233. }
  29234. if len(insutypes) == 0 {
  29235. insutype = "390"
  29236. }
  29237. if len(insutypes) == 2 {
  29238. insutype = strconv.FormatInt(his.SocialType, 10)
  29239. }
  29240. //insutype = "390"
  29241. if his.IdCardType == 1 {
  29242. cert_no = his.MedicalInsuranceNumber
  29243. } else {
  29244. cert_no = his.Certno
  29245. }
  29246. var res ResultSeven
  29247. var ahres ResultSevenAH
  29248. var resSeven10265 ResultSeven10265
  29249. var resSeven10265Two ResultSeven10265Two
  29250. var gzresSeven10265Two GZResultSeven10265Two
  29251. if miConfig.MdtrtareaAdmvs == "421300" {
  29252. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29253. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29254. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29255. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29256. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29257. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29258. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29259. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29260. resp, requestErr := http.Get(api)
  29261. if requestErr != nil {
  29262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29263. return
  29264. }
  29265. body, ioErr := ioutil.ReadAll(resp.Body)
  29266. if ioErr != nil {
  29267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29269. return
  29270. }
  29271. var respJSON map[string]interface{}
  29272. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29275. return
  29276. }
  29277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29278. result, _ := json.Marshal(respJSON)
  29279. fmt.Println("log")
  29280. fmt.Println(string(result))
  29281. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29282. utils.ErrorLog("解析失败:%v", err)
  29283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29284. return
  29285. }
  29286. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29287. if reg_type == 11 && his.Insutype == "390" {
  29288. reg_type = 110104
  29289. }
  29290. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29291. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29292. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29293. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29294. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29295. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29296. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29297. resp, requestErr := http.Get(api)
  29298. if requestErr != nil {
  29299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29300. return
  29301. }
  29302. body, ioErr := ioutil.ReadAll(resp.Body)
  29303. if ioErr != nil {
  29304. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29306. return
  29307. }
  29308. var respJSON map[string]interface{}
  29309. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29312. return
  29313. }
  29314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29315. result, _ := json.Marshal(respJSON)
  29316. fmt.Println("log")
  29317. fmt.Println(string(result))
  29318. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29319. utils.ErrorLog("解析失败:%v", err)
  29320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29321. return
  29322. }
  29323. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29324. if reg_type == 11 && his.Insutype == "390" {
  29325. reg_type = 110104
  29326. }
  29327. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29328. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29329. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29330. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29331. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29332. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29333. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29334. resp, requestErr := http.Get(api)
  29335. if requestErr != nil {
  29336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29337. return
  29338. }
  29339. body, ioErr := ioutil.ReadAll(resp.Body)
  29340. if ioErr != nil {
  29341. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29343. return
  29344. }
  29345. var respJSON map[string]interface{}
  29346. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29349. return
  29350. }
  29351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29352. result, _ := json.Marshal(respJSON)
  29353. fmt.Println("log")
  29354. fmt.Println(string(result))
  29355. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29356. utils.ErrorLog("解析失败:%v", err)
  29357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29358. return
  29359. }
  29360. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29361. if reg_type == 11 && his.Insutype == "390" {
  29362. reg_type = 110104
  29363. }
  29364. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29365. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29366. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29367. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29368. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29369. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29370. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29371. resp, requestErr := http.Get(api)
  29372. if requestErr != nil {
  29373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29374. return
  29375. }
  29376. body, ioErr := ioutil.ReadAll(resp.Body)
  29377. if ioErr != nil {
  29378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29380. return
  29381. }
  29382. var respJSON map[string]interface{}
  29383. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29386. return
  29387. }
  29388. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29389. result, _ := json.Marshal(respJSON)
  29390. fmt.Println("log")
  29391. fmt.Println(string(result))
  29392. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29393. utils.ErrorLog("解析失败:%v", err)
  29394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29395. return
  29396. }
  29397. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29398. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29399. if result3101.Infcode == "0" {
  29400. if len(result3101.Output.Result) > 0 {
  29401. var errMsgs []string
  29402. for _, item := range result3101.Output.Result {
  29403. errMsgs = append(errMsgs, item.VolaCont)
  29404. }
  29405. c.ServeSuccessJSON(map[string]interface{}{
  29406. "failed_code": -10,
  29407. "msg": errMsgs,
  29408. })
  29409. return
  29410. } else {
  29411. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29412. if his.IdCardType != 4 {
  29413. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29414. bas := strings.Split(psn_info.CardInfo, "|")
  29415. if his.IdCardType == 1 {
  29416. cert_no = bas[2]
  29417. } else {
  29418. cert_no = bas[1]
  29419. }
  29420. } else {
  29421. cert_no = his.Certno
  29422. }
  29423. //江苏地区国家医保医疗类别
  29424. //职工透析:医疗类别选特殊情况门诊9933
  29425. //居民血透门慢: 医疗类别选门诊慢病1402
  29426. //var med_type string
  29427. //if his.Insutype == "310" {
  29428. // if reg_type == 14 {
  29429. // med_type = "9933"
  29430. // } else if reg_type == 11 {
  29431. // med_type = "11"
  29432. //
  29433. // }
  29434. //} else if his.Insutype == "390" {
  29435. // if reg_type == 14 {
  29436. // med_type = "1402"
  29437. // } else if reg_type == 11 {
  29438. // med_type = "11"
  29439. // }
  29440. //}
  29441. var api string
  29442. if miConfig.MdtrtareaAdmvs == "320921" {
  29443. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29444. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29445. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29446. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29447. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29448. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29449. "&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
  29450. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29451. } else {
  29452. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29453. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29454. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29455. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29456. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29457. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29458. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29459. "&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
  29460. }
  29461. resp, requestErr := http.Get(api)
  29462. if requestErr != nil {
  29463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29464. return
  29465. }
  29466. body, ioErr := ioutil.ReadAll(resp.Body)
  29467. if ioErr != nil {
  29468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29470. return
  29471. }
  29472. var respJSON map[string]interface{}
  29473. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29476. return
  29477. }
  29478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29479. result, _ := json.Marshal(respJSON)
  29480. fmt.Println("log")
  29481. fmt.Println(string(result))
  29482. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29483. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29484. utils.ErrorLog("解析失败:%v", err)
  29485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29486. return
  29487. }
  29488. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29489. res.Output = resSeven10265.Output
  29490. res.ErrMsg = resSeven10265.ErrMsg
  29491. res.Cainfo = resSeven10265.Cainfo
  29492. res.WarnMsg = resSeven10265.WarnMsg
  29493. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29494. res.Infcode = infocode
  29495. } else {
  29496. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29497. utils.ErrorLog("解析失败:%v", err)
  29498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29499. return
  29500. }
  29501. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29502. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29503. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29504. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29505. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29506. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29507. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29508. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29509. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29510. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29511. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29512. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29513. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29514. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29515. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29516. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29517. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29518. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29519. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29520. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29521. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29522. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29523. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29524. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29525. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29526. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29527. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29528. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29529. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29530. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29531. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29532. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29533. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29534. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29535. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29536. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29537. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29538. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29539. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29540. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29541. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  29542. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  29543. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  29544. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  29545. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  29546. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  29547. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  29548. res.ErrMsg = resSeven10265Two.ErrMsg
  29549. res.Cainfo = resSeven10265Two.Cainfo
  29550. res.WarnMsg = resSeven10265Two.WarnMsg
  29551. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29552. res.Infcode = infocode
  29553. }
  29554. }
  29555. }
  29556. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29557. psn_info, _ := service.GetPsnByPatientId(id)
  29558. var verify_number string
  29559. if psn_info.IdCardType == 4 {
  29560. verify_number = psn_info.VerifyNumber
  29561. } else if psn_info.IdCardType == 1 {
  29562. bas := strings.Split(psn_info.CardInfo, "|")
  29563. cardNumber := bas[2]
  29564. verify_number = cardNumber
  29565. } else {
  29566. psn_info.IdCardType = 2
  29567. verify_number = psn_info.Certno
  29568. }
  29569. var api string
  29570. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29571. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  29572. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29573. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29574. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29575. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29576. "&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
  29577. resp, requestErr := http.Get(api)
  29578. if requestErr != nil {
  29579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29580. return
  29581. }
  29582. body, ioErr := ioutil.ReadAll(resp.Body)
  29583. if ioErr != nil {
  29584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29586. return
  29587. }
  29588. var respJSON map[string]interface{}
  29589. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29592. return
  29593. }
  29594. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29595. result, _ := json.Marshal(respJSON)
  29596. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29597. utils.ErrorLog("解析失败:%v", err)
  29598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29599. return
  29600. }
  29601. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29602. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  29603. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  29604. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29605. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  29606. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  29607. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  29608. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  29609. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  29610. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  29611. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  29612. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  29613. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  29614. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  29615. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  29616. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  29617. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  29618. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  29619. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  29620. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  29621. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29622. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  29623. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  29624. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  29625. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  29626. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  29627. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  29628. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  29629. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  29630. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  29631. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  29632. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  29633. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  29634. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  29635. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29636. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  29637. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  29638. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  29639. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  29640. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  29641. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  29642. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  29643. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  29644. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  29645. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  29646. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  29647. res.ErrMsg = resSeven10265.ErrMsg
  29648. res.Cainfo = resSeven10265.Cainfo
  29649. res.WarnMsg = resSeven10265.WarnMsg
  29650. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29651. res.Infcode = infocode
  29652. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29653. acct_used_flag := "1"
  29654. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  29655. var result string
  29656. var request_log string
  29657. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  29658. 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)
  29659. } else {
  29660. 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)
  29661. }
  29662. var dat map[string]interface{}
  29663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29664. fmt.Println(dat)
  29665. } else {
  29666. fmt.Println(err)
  29667. }
  29668. saveLog(result, request_log, "2206", "预结算")
  29669. userJSONBytes, _ := json.Marshal(dat)
  29670. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29671. utils.ErrorLog("解析失败:%v", err)
  29672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29673. return
  29674. }
  29675. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29676. var result string
  29677. var request_log string
  29678. if his.IdCardType == 2 {
  29679. 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, "")
  29680. } else if his.IdCardType == 1 {
  29681. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29682. bas := strings.Split(psn_info.CardInfo, "|")
  29683. basNumber := bas[2]
  29684. card_sn := bas[3]
  29685. var rf []*ResultFive
  29686. json.Unmarshal([]byte(his.Iinfo), &rf)
  29687. var psn_type string
  29688. for _, item := range rf {
  29689. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29690. psn_type = item.PsnType
  29691. }
  29692. }
  29693. 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)
  29694. } else {
  29695. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29696. //bas := strings.Split(psn_info.CardInfo, "|")
  29697. //basNumber := bas[2]
  29698. //card_sn := bas[3]
  29699. var rf []*ResultFive
  29700. json.Unmarshal([]byte(his.Iinfo), &rf)
  29701. var psn_type string
  29702. for _, item := range rf {
  29703. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29704. psn_type = item.PsnType
  29705. }
  29706. }
  29707. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29708. 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)
  29709. }
  29710. var dat map[string]interface{}
  29711. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29712. fmt.Println(dat)
  29713. } else {
  29714. fmt.Println(err)
  29715. }
  29716. saveLog(result, request_log, "2206", "预结算")
  29717. userJSONBytes, _ := json.Marshal(dat)
  29718. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29719. utils.ErrorLog("解析失败:%v", err)
  29720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29721. return
  29722. }
  29723. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29724. var result string
  29725. var request_log string
  29726. if his.IdCardType == 2 {
  29727. 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, "")
  29728. } else if his.IdCardType == 1 {
  29729. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29730. bas := strings.Split(psn_info.CardInfo, "|")
  29731. basNumber := bas[0]
  29732. card_sn := ""
  29733. var rf []*ResultFive
  29734. json.Unmarshal([]byte(his.Iinfo), &rf)
  29735. var psn_type string
  29736. for _, item := range rf {
  29737. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29738. psn_type = item.PsnType
  29739. }
  29740. }
  29741. 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)
  29742. } else {
  29743. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29744. //bas := strings.Split(psn_info.CardInfo, "|")
  29745. //basNumber := bas[2]
  29746. //card_sn := bas[3]
  29747. var rf []*ResultFive
  29748. json.Unmarshal([]byte(his.Iinfo), &rf)
  29749. var psn_type string
  29750. for _, item := range rf {
  29751. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  29752. psn_type = item.PsnType
  29753. }
  29754. }
  29755. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29756. 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)
  29757. }
  29758. var dat map[string]interface{}
  29759. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29760. fmt.Println(dat)
  29761. } else {
  29762. fmt.Println(err)
  29763. }
  29764. saveLog(result, request_log, "2206", "预结算")
  29765. userJSONBytes, _ := json.Marshal(dat)
  29766. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29767. utils.ErrorLog("解析失败:%v", err)
  29768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29769. return
  29770. }
  29771. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29772. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29773. if his.IdCardType == 4 {
  29774. psn_info.VerifyNumber = psn_info.VerifyNumber
  29775. cert_no = psn_info.VerifyNumber
  29776. } else if his.IdCardType == 2 {
  29777. cert_no = psn_info.Certno
  29778. psn_info.VerifyNumber = psn_info.Certno
  29779. } else {
  29780. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29781. bas := strings.Split(psn_info.CardInfo, "|")
  29782. if his.IdCardType == 1 {
  29783. cert_no = bas[2]
  29784. } else {
  29785. cert_no = bas[1]
  29786. }
  29787. }
  29788. var api string
  29789. var med_type string
  29790. if his.Insutype == "390" {
  29791. if reg_type == 992102 {
  29792. med_type = "992102"
  29793. }
  29794. if reg_type == 140104 {
  29795. med_type = "140104"
  29796. }
  29797. if reg_type == 140201 {
  29798. med_type = "140201"
  29799. }
  29800. if reg_type == 14 {
  29801. med_type = "140104"
  29802. }
  29803. } else if his.Insutype == "310" {
  29804. if reg_type == 992102 {
  29805. med_type = "992102"
  29806. }
  29807. if reg_type == 140104 {
  29808. med_type = "140104"
  29809. }
  29810. if reg_type == 140201 {
  29811. med_type = "140201"
  29812. }
  29813. if reg_type == 14 {
  29814. med_type = "140104"
  29815. }
  29816. }
  29817. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29818. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29819. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29820. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29821. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29822. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29823. "&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
  29824. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29825. resp, requestErr := http.Get(api)
  29826. if requestErr != nil {
  29827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29828. return
  29829. }
  29830. body, ioErr := ioutil.ReadAll(resp.Body)
  29831. if ioErr != nil {
  29832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29834. return
  29835. }
  29836. var respJSON map[string]interface{}
  29837. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29840. return
  29841. }
  29842. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29843. if status == "0" {
  29844. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29845. c.ServeSuccessJSON(map[string]interface{}{
  29846. "failed_code": -10,
  29847. "msg": err_msg,
  29848. })
  29849. return
  29850. }
  29851. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29852. result, _ := json.Marshal(respJSON)
  29853. fmt.Println("log")
  29854. fmt.Println(string(result))
  29855. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  29856. utils.ErrorLog("解析失败:%v", err)
  29857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29858. return
  29859. }
  29860. res.InfRefmsgid = ahres.InfRefmsgid
  29861. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29862. // 创建对应的Time类型
  29863. t := time.UnixMilli(timestamp)
  29864. // 格式化成指定的日期字符串
  29865. str := t.Format("2006-01-02 15:04:05")
  29866. res.Output.Setlinfo.SetlTime = str
  29867. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29868. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29869. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29870. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29871. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29872. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29873. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29874. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29875. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29876. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  29877. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29878. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29879. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29880. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29881. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29882. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29883. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29884. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29885. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29886. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29887. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29888. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29889. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29890. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29891. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29892. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29893. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29894. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29895. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29896. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29897. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29898. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29899. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29900. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29901. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29902. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29903. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29904. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29905. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29906. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29907. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29908. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29909. //res.Output.Setldetail = ahres.Output.Setldetail
  29910. res.ErrMsg = ahres.ErrMsg
  29911. res.Cainfo = ahres.Cainfo
  29912. res.WarnMsg = ahres.WarnMsg
  29913. res.Infcode = ahres.Infcode
  29914. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29915. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29916. if his.IdCardType == 4 {
  29917. psn_info.VerifyNumber = psn_info.VerifyNumber
  29918. cert_no = psn_info.Certno
  29919. } else if his.IdCardType == 2 {
  29920. cert_no = psn_info.Certno
  29921. psn_info.VerifyNumber = psn_info.Certno
  29922. } else {
  29923. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29924. bas := strings.Split(psn_info.CardInfo, "|")
  29925. if his.IdCardType == 1 {
  29926. cert_no = bas[2]
  29927. } else {
  29928. cert_no = bas[1]
  29929. }
  29930. }
  29931. var api string
  29932. var med_type string
  29933. if his.Insutype == "390" {
  29934. if reg_type == 992102 {
  29935. med_type = "992102"
  29936. }
  29937. if reg_type == 140104 {
  29938. med_type = "140104"
  29939. }
  29940. if reg_type == 140201 {
  29941. med_type = "140201"
  29942. }
  29943. if reg_type == 14 {
  29944. med_type = "14"
  29945. }
  29946. } else if his.Insutype == "310" {
  29947. if reg_type == 992102 {
  29948. med_type = "992102"
  29949. }
  29950. if reg_type == 140104 {
  29951. med_type = "140104"
  29952. }
  29953. if reg_type == 140201 {
  29954. med_type = "140201"
  29955. }
  29956. if reg_type == 14 {
  29957. med_type = "14"
  29958. }
  29959. }
  29960. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29961. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29962. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29963. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29964. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29965. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29966. "&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
  29967. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29968. resp, requestErr := http.Get(api)
  29969. if requestErr != nil {
  29970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29971. return
  29972. }
  29973. body, ioErr := ioutil.ReadAll(resp.Body)
  29974. if ioErr != nil {
  29975. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29977. return
  29978. }
  29979. var respJSON map[string]interface{}
  29980. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29983. return
  29984. }
  29985. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29986. if status == "0" {
  29987. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29988. c.ServeSuccessJSON(map[string]interface{}{
  29989. "failed_code": -10,
  29990. "msg": err_msg,
  29991. })
  29992. return
  29993. }
  29994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29995. result, _ := json.Marshal(respJSON)
  29996. fmt.Println("log")
  29997. fmt.Println(string(result))
  29998. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  29999. utils.ErrorLog("解析失败:%v", err)
  30000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30001. return
  30002. }
  30003. res.InfRefmsgid = ahres.InfRefmsgid
  30004. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30005. // 创建对应的Time类型
  30006. t := time.UnixMilli(timestamp)
  30007. // 格式化成指定的日期字符串
  30008. str := t.Format("2006-01-02 15:04:05")
  30009. res.Output.Setlinfo.SetlTime = str
  30010. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30011. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30012. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30013. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30014. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30015. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30016. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30017. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30018. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30019. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30020. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30021. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30022. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30023. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30024. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30025. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30026. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30027. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30028. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30029. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30030. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30031. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30032. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30033. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30034. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30035. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30036. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30037. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30038. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30039. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30040. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30041. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30042. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30043. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30044. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30045. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30046. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30047. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30048. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30049. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30050. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30051. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30052. //res.Output.Setldetail = ahres.Output.Setldetail
  30053. res.ErrMsg = ahres.ErrMsg
  30054. res.Cainfo = ahres.Cainfo
  30055. res.WarnMsg = ahres.WarnMsg
  30056. res.Infcode = ahres.Infcode
  30057. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30058. var result string
  30059. var request_log string
  30060. if his.IdCardType == 2 {
  30061. 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")
  30062. } else if his.IdCardType == 1 {
  30063. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30064. bas := strings.Split(psn_info.CardInfo, "|")
  30065. basNumber := bas[2]
  30066. card_sn := bas[3]
  30067. 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")
  30068. } else {
  30069. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30070. 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")
  30071. }
  30072. var dat map[string]interface{}
  30073. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30074. fmt.Println(dat)
  30075. } else {
  30076. fmt.Println(err)
  30077. }
  30078. saveLog(result, request_log, "2206", "预结算")
  30079. userJSONBytes, _ := json.Marshal(dat)
  30080. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30081. utils.ErrorLog("解析失败:%v", err)
  30082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30083. return
  30084. }
  30085. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30086. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30087. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30088. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30089. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30090. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30091. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30092. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30093. resp, requestErr := http.Get(api)
  30094. if requestErr != nil {
  30095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30096. return
  30097. }
  30098. body, ioErr := ioutil.ReadAll(resp.Body)
  30099. if ioErr != nil {
  30100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30102. return
  30103. }
  30104. var respJSON map[string]interface{}
  30105. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30108. return
  30109. }
  30110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30111. result, _ := json.Marshal(respJSON)
  30112. fmt.Println("log")
  30113. fmt.Println(string(result))
  30114. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30115. utils.ErrorLog("解析失败:%v", err)
  30116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30117. return
  30118. }
  30119. } else {
  30120. if miConfig.MdtrtareaAdmvs == "441202" {
  30121. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30122. if result3101.Infcode == 0 {
  30123. if len(result3101.Output.Result) > 0 {
  30124. var errMsgs []string
  30125. for _, item := range result3101.Output.Result {
  30126. errMsgs = append(errMsgs, item.VolaCont)
  30127. }
  30128. c.ServeSuccessJSON(map[string]interface{}{
  30129. "failed_code": -10,
  30130. "msg": errMsgs,
  30131. })
  30132. return
  30133. } else {
  30134. var result string
  30135. var request_log string
  30136. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30137. allTotal = fmt.Sprintf("%.2f", total_two)
  30138. if his.IdCardType == 4 {
  30139. 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)
  30140. } else {
  30141. 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)
  30142. }
  30143. var dat map[string]interface{}
  30144. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30145. fmt.Println(dat)
  30146. } else {
  30147. fmt.Println(err)
  30148. }
  30149. saveLog(result, request_log, "2206", "预结算")
  30150. //userJSONBytes, _ := json.Marshal(dat)
  30151. //
  30152. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30153. // utils.ErrorLog("解析失败:%v", err)
  30154. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30155. // return
  30156. //}
  30157. userJSONBytes, _ := json.Marshal(dat)
  30158. if miConfig.Code == "H15049901371" {
  30159. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30160. utils.ErrorLog("解析失败:%v", err)
  30161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30162. return
  30163. }
  30164. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30165. res.Output = resSeven10265.Output
  30166. res.ErrMsg = resSeven10265.ErrMsg
  30167. res.Cainfo = resSeven10265.Cainfo
  30168. res.WarnMsg = resSeven10265.WarnMsg
  30169. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30170. res.Infcode = infocode
  30171. } else {
  30172. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30173. utils.ErrorLog("解析失败:%v", err)
  30174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30175. return
  30176. }
  30177. }
  30178. }
  30179. } else {
  30180. c.ServeSuccessJSON(map[string]interface{}{
  30181. "failed_code": -10,
  30182. "msg": result3101.ErrMsg,
  30183. })
  30184. return
  30185. }
  30186. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30187. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30188. if result3101.Infcode == 0 {
  30189. if len(result3101.Output.Result) > 0 {
  30190. var errMsgs []string
  30191. for _, item := range result3101.Output.Result {
  30192. errMsgs = append(errMsgs, item.VolaCont)
  30193. }
  30194. c.ServeSuccessJSON(map[string]interface{}{
  30195. "failed_code": -10,
  30196. "msg": errMsgs,
  30197. })
  30198. return
  30199. } else {
  30200. var result string
  30201. var request_log string
  30202. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30203. allTotal = fmt.Sprintf("%.2f", total_two)
  30204. if his.IdCardType == 4 {
  30205. 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)
  30206. } else {
  30207. 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)
  30208. }
  30209. var dat map[string]interface{}
  30210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30211. fmt.Println(dat)
  30212. } else {
  30213. fmt.Println(err)
  30214. }
  30215. saveLog(result, request_log, "2206", "预结算")
  30216. //userJSONBytes, _ := json.Marshal(dat)
  30217. //
  30218. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30219. // utils.ErrorLog("解析失败:%v", err)
  30220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30221. // return
  30222. //}
  30223. userJSONBytes, _ := json.Marshal(dat)
  30224. if miConfig.Code == "H15049901371" {
  30225. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30226. utils.ErrorLog("解析失败:%v", err)
  30227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30228. return
  30229. }
  30230. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30231. res.Output = resSeven10265.Output
  30232. res.ErrMsg = resSeven10265.ErrMsg
  30233. res.Cainfo = resSeven10265.Cainfo
  30234. res.WarnMsg = resSeven10265.WarnMsg
  30235. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30236. res.Infcode = infocode
  30237. } else {
  30238. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30239. utils.ErrorLog("解析失败:%v", err)
  30240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30241. return
  30242. }
  30243. }
  30244. }
  30245. } else {
  30246. c.ServeSuccessJSON(map[string]interface{}{
  30247. "failed_code": -10,
  30248. "msg": result3101.ErrMsg,
  30249. })
  30250. return
  30251. }
  30252. } else {
  30253. var result string
  30254. var request_log string
  30255. var dat map[string]interface{}
  30256. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30257. allTotal = fmt.Sprintf("%.2f", total_two)
  30258. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  30259. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30260. if result3101.Infcode == 0 {
  30261. if len(result3101.Output.Result) > 0 {
  30262. var errMsgs []string
  30263. for _, item := range result3101.Output.Result {
  30264. errMsgs = append(errMsgs, item.VolaCont)
  30265. }
  30266. c.ServeSuccessJSON(map[string]interface{}{
  30267. "failed_code": -10,
  30268. "msg": errMsgs,
  30269. })
  30270. return
  30271. } else {
  30272. var result string
  30273. var request_log string
  30274. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30275. allTotal = fmt.Sprintf("%.2f", total_two)
  30276. if his.IdCardType == 4 {
  30277. 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)
  30278. } else {
  30279. 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)
  30280. }
  30281. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30282. fmt.Println(dat)
  30283. } else {
  30284. fmt.Println(err)
  30285. }
  30286. saveLog(result, request_log, "2206", "预结算")
  30287. }
  30288. } else {
  30289. c.ServeSuccessJSON(map[string]interface{}{
  30290. "failed_code": -10,
  30291. "msg": result3101.ErrMsg,
  30292. })
  30293. return
  30294. }
  30295. } else {
  30296. if his.IdCardType == 4 {
  30297. 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)
  30298. } else {
  30299. 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)
  30300. }
  30301. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30302. fmt.Println(dat)
  30303. } else {
  30304. fmt.Println(err)
  30305. }
  30306. saveLog(result, request_log, "2206", "预结算")
  30307. }
  30308. //userJSONBytes, _ := json.Marshal(dat)
  30309. //
  30310. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30311. // utils.ErrorLog("解析失败:%v", err)
  30312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30313. // return
  30314. //}
  30315. userJSONBytes, _ := json.Marshal(dat)
  30316. if miConfig.Code == "H15049901371" {
  30317. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30318. utils.ErrorLog("解析失败:%v", err)
  30319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30320. return
  30321. }
  30322. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30323. res.Output = resSeven10265.Output
  30324. res.ErrMsg = resSeven10265.ErrMsg
  30325. res.Cainfo = resSeven10265.Cainfo
  30326. res.WarnMsg = resSeven10265.WarnMsg
  30327. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30328. res.Infcode = infocode
  30329. } else {
  30330. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30331. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30332. utils.ErrorLog("解析失败:%v", err)
  30333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30334. return
  30335. }
  30336. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30337. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30338. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30339. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30340. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30341. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30342. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30343. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30344. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30345. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30346. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30347. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30348. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30349. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30350. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30351. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30352. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30353. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30354. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30355. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30356. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30357. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30358. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30359. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30360. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30361. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30362. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30363. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30364. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30365. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30366. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30367. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30368. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30369. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30370. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30371. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30372. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30373. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30374. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30375. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30376. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30377. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30378. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30379. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30380. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30381. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30382. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30383. res.Cainfo = gzresSeven10265Two.Cainfo
  30384. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30385. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30386. //res.Infcode = infocode
  30387. } else {
  30388. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30389. utils.ErrorLog("解析失败:%v", err)
  30390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30391. return
  30392. }
  30393. }
  30394. }
  30395. }
  30396. }
  30397. utils.ErrorLog("解析失败:%v", res.Infcode)
  30398. if res.Infcode == -1 {
  30399. errlog := &models.HisOrderError{
  30400. UserOrgId: adminUser.CurrentOrgId,
  30401. Ctime: time.Now().Unix(),
  30402. Mtime: time.Now().Unix(),
  30403. Number: chrg_bchno,
  30404. ErrMsg: res.ErrMsg,
  30405. Status: 1,
  30406. PatientId: id,
  30407. RecordTime: recordDateTime,
  30408. Stage: 20,
  30409. }
  30410. service.CreateErrMsgLog(errlog)
  30411. c.ServeSuccessJSON(map[string]interface{}{
  30412. "failed_code": -10,
  30413. "msg": res.ErrMsg,
  30414. })
  30415. return
  30416. }
  30417. if res.Infcode != 0 {
  30418. errlog := &models.HisOrderError{
  30419. UserOrgId: adminUser.CurrentOrgId,
  30420. Ctime: time.Now().Unix(),
  30421. Mtime: time.Now().Unix(),
  30422. Number: chrg_bchno,
  30423. ErrMsg: res.ErrMsg,
  30424. Status: 1,
  30425. PatientId: id,
  30426. RecordTime: recordDateTime,
  30427. Stage: 20,
  30428. }
  30429. service.CreateErrMsgLog(errlog)
  30430. c.ServeSuccessJSON(map[string]interface{}{
  30431. "failed_code": -10,
  30432. "msg": res.ErrMsg,
  30433. })
  30434. return
  30435. } else {
  30436. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30437. order.OrderStatus = 1
  30438. order.IsPre = 1
  30439. order.Status = 1
  30440. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30441. order.SetlId = res.Output.Setlinfo.SetlID
  30442. order.PsnNo = res.Output.Setlinfo.PsnNo
  30443. order.PsnName = res.Output.Setlinfo.PsnName
  30444. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30445. order.Certno = res.Output.Setlinfo.Certno
  30446. order.Gend = res.Output.Setlinfo.Gend
  30447. order.Naty = res.Output.Setlinfo.Naty
  30448. order.Age = res.Output.Setlinfo.Age
  30449. order.Insutype = res.Output.Setlinfo.Insutype
  30450. order.PsnType = res.Output.Setlinfo.PsnType
  30451. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30452. order.SetlTime = res.Output.Setlinfo.SetlTime
  30453. order.AcctUsedFlag = acct_used_flag
  30454. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30455. if res.Output.Setlinfo.MedType == "140101" {
  30456. order.MedType = "14"
  30457. } else {
  30458. if res.Output.Setlinfo.MedType == "110104" {
  30459. order.MedType = "11"
  30460. } else {
  30461. order.MedType = res.Output.Setlinfo.MedType
  30462. }
  30463. }
  30464. if res.Output.Setlinfo.MedType == "992102" {
  30465. order.MedType = "992102"
  30466. }
  30467. if res.Output.Setlinfo.MedType == "140104" {
  30468. order.MedType = "140104"
  30469. }
  30470. if res.Output.Setlinfo.MedType == "140201" {
  30471. order.MedType = "140201"
  30472. }
  30473. if res.Output.Setlinfo.MedType == "14" {
  30474. order.MedType = "14"
  30475. }
  30476. if reg_type == 1112 {
  30477. order.MedType = "1112"
  30478. }
  30479. if reg_type == 1111 {
  30480. order.MedType = "1111"
  30481. }
  30482. order.ClrType = res.Output.Setlinfo.ClrType
  30483. if adminUser.CurrentOrgId == 10480 {
  30484. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30485. order.ClrType = "11"
  30486. } else {
  30487. order.ClrType = "9903"
  30488. }
  30489. }
  30490. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30491. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30492. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30493. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30494. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30495. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30496. order.HifpPay = res.Output.Setlinfo.HifpPay
  30497. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30498. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30499. order.HifesPay = res.Output.Setlinfo.HifesPay
  30500. order.HifobPay = res.Output.Setlinfo.HifobPay
  30501. order.MafPay = res.Output.Setlinfo.MafPay
  30502. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30503. order.OthPay = res.Output.Setlinfo.OthPay
  30504. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30505. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30506. order.AcctPay = res.Output.Setlinfo.AcctPay
  30507. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30508. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30509. order.Balc = res.Output.Setlinfo.Balc
  30510. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30511. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30512. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30513. order.ClrWay = res.Output.Setlinfo.ClrWay
  30514. order.Creator = order.Creator
  30515. order.Modify = roles.AdminUserId
  30516. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30517. //detailStr := string(setlDetail)
  30518. //order.SetlDetail = detailStr
  30519. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30520. err = service.UpDateOrder(order)
  30521. if err == nil {
  30522. c.ServeSuccessJSON(map[string]interface{}{
  30523. "msg": "预结算成功",
  30524. })
  30525. } else {
  30526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30527. return
  30528. }
  30529. }
  30530. } else {
  30531. adminUser := c.GetAdminUserInfo()
  30532. errlog := &models.HisOrderError{
  30533. UserOrgId: adminUser.CurrentOrgId,
  30534. Ctime: time.Now().Unix(),
  30535. Mtime: time.Now().Unix(),
  30536. ErrMsg: res.ErrMsg,
  30537. Status: 1,
  30538. PatientId: id,
  30539. RecordTime: recordDateTime,
  30540. Stage: 4,
  30541. }
  30542. service.CreateErrMsgLog(errlog)
  30543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  30544. return
  30545. }
  30546. } else {
  30547. if miConfig.MdtrtareaAdmvs == "150499" {
  30548. order := &models.HisOrder{
  30549. UserOrgId: adminUser.CurrentOrgId,
  30550. HisPatientId: his.ID,
  30551. PatientId: his.PatientId,
  30552. SettleAccountsDate: recordDateTime,
  30553. Ctime: time.Now().Unix(),
  30554. Mtime: time.Now().Unix(),
  30555. MdtrtId: his.Number,
  30556. PsnNo: his.PsnNo,
  30557. MedType: strconv.FormatInt(reg_type, 10),
  30558. Status: 1,
  30559. Number: chrg_bchno,
  30560. Infcode: res.Infcode,
  30561. WarnMsg: res.WarnMsg,
  30562. Cainfo: res.Cainfo,
  30563. ErrMsg: res.ErrMsg,
  30564. RespondTime: res.RefmsgTime,
  30565. InfRefmsgid: res.InfRefmsgid,
  30566. OrderStatus: 1,
  30567. IsMedicineInsurance: 1,
  30568. SettleType: settle_accounts_type,
  30569. SettleStartTime: start_time,
  30570. SettleEndTime: end_time,
  30571. Creator: roles.AdminUserId,
  30572. Modify: roles.AdminUserId,
  30573. PType: 2,
  30574. Diagnosis: diagnosis_id,
  30575. }
  30576. err = service.CreateOrder(order)
  30577. if err != nil {
  30578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30579. return
  30580. }
  30581. }
  30582. adminUser := c.GetAdminUserInfo()
  30583. errlog := &models.HisOrderError{
  30584. UserOrgId: adminUser.CurrentOrgId,
  30585. Ctime: time.Now().Unix(),
  30586. Mtime: time.Now().Unix(),
  30587. ErrMsg: res.ErrMsg,
  30588. Status: 1,
  30589. PatientId: id,
  30590. RecordTime: recordDateTime,
  30591. Stage: 4,
  30592. }
  30593. service.CreateErrMsgLog(errlog)
  30594. c.ServeSuccessJSON(map[string]interface{}{
  30595. "failed_code": -10,
  30596. "msg": res.ErrMsg,
  30597. })
  30598. return
  30599. }
  30600. }
  30601. }
  30602. }
  30603. // 退款
  30604. func (c *HisApiController) Refund() {
  30605. order_id, _ := c.GetInt64("order_id")
  30606. admin_user_id, _ := c.GetInt64("admin_user_id")
  30607. adminUser := c.GetAdminUserInfo()
  30608. var order models.HisOrder
  30609. order, _ = service.GetHisOrderByID(order_id)
  30610. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  30611. if fapiao.ID > 0 {
  30612. c.ServeSuccessJSON(map[string]interface{}{
  30613. "failed_code": -10,
  30614. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  30615. })
  30616. return
  30617. }
  30618. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30619. if order.ID == 0 {
  30620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30621. return
  30622. }
  30623. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30624. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30625. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30626. if config.IsOpen == 1 { //对接了医保,走医保流程
  30627. var res ResultSixteen
  30628. var ahres ResultSevenAH
  30629. var resSixteen10265 ResultSixteen10265
  30630. var resSixteen10265Two ResultSixteen10265Two
  30631. var gz ResultgzSixteen10265Two
  30632. var src_resquest string
  30633. var result string
  30634. if miConfig.MdtrtareaAdmvs == "421300" {
  30635. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30636. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30637. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30638. resp3, requestErr3 := http.Get(api3)
  30639. if requestErr3 != nil {
  30640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30641. return
  30642. }
  30643. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30644. if ioErr3 != nil {
  30645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30647. return
  30648. }
  30649. var respJSON3 map[string]interface{}
  30650. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30653. return
  30654. }
  30655. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30656. userJSONBytes3, _ := json.Marshal(respJSON3)
  30657. fmt.Println("log")
  30658. fmt.Println(string(userJSONBytes3))
  30659. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30660. utils.ErrorLog("解析失败:%v", err)
  30661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30662. return
  30663. }
  30664. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30665. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  30666. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30667. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30668. resp3, requestErr3 := http.Get(api3)
  30669. if requestErr3 != nil {
  30670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30671. return
  30672. }
  30673. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30674. if ioErr3 != nil {
  30675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30677. return
  30678. }
  30679. var respJSON3 map[string]interface{}
  30680. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30683. return
  30684. }
  30685. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30686. userJSONBytes3, _ := json.Marshal(respJSON3)
  30687. fmt.Println("log")
  30688. fmt.Println(string(userJSONBytes3))
  30689. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30690. utils.ErrorLog("解析失败:%v", err)
  30691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30692. return
  30693. }
  30694. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30695. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  30696. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30697. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30698. resp3, requestErr3 := http.Get(api3)
  30699. if requestErr3 != nil {
  30700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30701. return
  30702. }
  30703. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30704. if ioErr3 != nil {
  30705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30707. return
  30708. }
  30709. var respJSON3 map[string]interface{}
  30710. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30713. return
  30714. }
  30715. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30716. userJSONBytes3, _ := json.Marshal(respJSON3)
  30717. fmt.Println("log")
  30718. fmt.Println(string(userJSONBytes3))
  30719. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30720. utils.ErrorLog("解析失败:%v", err)
  30721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30722. return
  30723. }
  30724. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30725. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  30726. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30727. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30728. resp3, requestErr3 := http.Get(api3)
  30729. if requestErr3 != nil {
  30730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30731. return
  30732. }
  30733. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30734. if ioErr3 != nil {
  30735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30737. return
  30738. }
  30739. var respJSON3 map[string]interface{}
  30740. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30743. return
  30744. }
  30745. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30746. userJSONBytes3, _ := json.Marshal(respJSON3)
  30747. fmt.Println("log")
  30748. fmt.Println(string(userJSONBytes3))
  30749. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30750. utils.ErrorLog("解析失败:%v", err)
  30751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30752. return
  30753. }
  30754. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30755. var api3 string
  30756. if miConfig.MdtrtareaAdmvs == "320921" {
  30757. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  30758. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30759. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30760. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30761. } else {
  30762. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30763. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  30764. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30765. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30766. }
  30767. resp3, requestErr3 := http.Get(api3)
  30768. if requestErr3 != nil {
  30769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30770. return
  30771. }
  30772. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30773. if ioErr3 != nil {
  30774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30776. return
  30777. }
  30778. var respJSON3 map[string]interface{}
  30779. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30782. return
  30783. }
  30784. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30785. userJSONBytes3, _ := json.Marshal(respJSON3)
  30786. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  30787. utils.ErrorLog("解析失败:%v", err)
  30788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30789. return
  30790. }
  30791. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  30792. res.Output = resSixteen10265.Output
  30793. res.ErrMsg = resSixteen10265.ErrMsg
  30794. res.Cainfo = resSixteen10265.Cainfo
  30795. res.WarnMsg = resSixteen10265.WarnMsg
  30796. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  30797. res.Infcode = infocode
  30798. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30799. var api3 string
  30800. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  30801. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30802. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30803. resp3, requestErr3 := http.Get(api3)
  30804. if requestErr3 != nil {
  30805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30806. return
  30807. }
  30808. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30809. if ioErr3 != nil {
  30810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30812. return
  30813. }
  30814. var respJSON3 map[string]interface{}
  30815. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30816. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30818. return
  30819. }
  30820. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30821. userJSONBytes3, _ := json.Marshal(respJSON3)
  30822. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  30823. utils.ErrorLog("解析失败:%v", err)
  30824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30825. return
  30826. }
  30827. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  30828. res.Output = resSixteen10265.Output
  30829. res.ErrMsg = resSixteen10265.ErrMsg
  30830. res.Cainfo = resSixteen10265.Cainfo
  30831. res.WarnMsg = resSixteen10265.WarnMsg
  30832. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  30833. res.Infcode = infocode
  30834. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30835. 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)
  30836. var dat map[string]interface{}
  30837. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30838. fmt.Println(dat)
  30839. } else {
  30840. fmt.Println(err)
  30841. }
  30842. saveLog(result, src_resquest, "2208", "退费")
  30843. userJSONBytes, _ := json.Marshal(dat)
  30844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30845. utils.ErrorLog("解析失败:%v", err)
  30846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30847. return
  30848. }
  30849. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30850. 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, "")
  30851. var dat map[string]interface{}
  30852. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30853. fmt.Println(dat)
  30854. } else {
  30855. fmt.Println(err)
  30856. }
  30857. saveLog(result, src_resquest, "2208", "退费")
  30858. userJSONBytes, _ := json.Marshal(dat)
  30859. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30860. utils.ErrorLog("解析失败:%v", err)
  30861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30862. return
  30863. }
  30864. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30865. 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, "")
  30866. var dat map[string]interface{}
  30867. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30868. fmt.Println(dat)
  30869. } else {
  30870. fmt.Println(err)
  30871. }
  30872. saveLog(result, src_resquest, "2208", "退费")
  30873. userJSONBytes, _ := json.Marshal(dat)
  30874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30875. utils.ErrorLog("解析失败:%v", err)
  30876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30877. return
  30878. }
  30879. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30880. var api3 string
  30881. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  30882. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30883. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30884. resp3, requestErr3 := http.Get(api3)
  30885. if requestErr3 != nil {
  30886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30887. return
  30888. }
  30889. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30890. if ioErr3 != nil {
  30891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30893. return
  30894. }
  30895. var respJSON3 map[string]interface{}
  30896. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30899. return
  30900. }
  30901. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  30902. if status == "0" {
  30903. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  30904. c.ServeSuccessJSON(map[string]interface{}{
  30905. "failed_code": -10,
  30906. "msg": err_msg,
  30907. })
  30908. return
  30909. }
  30910. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30911. userJSONBytes3, _ := json.Marshal(respJSON3)
  30912. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  30913. // utils.ErrorLog("解析失败:%v", err)
  30914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30915. // return
  30916. //}
  30917. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  30918. utils.ErrorLog("解析失败:%v", err)
  30919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30920. return
  30921. }
  30922. res.InfRefmsgid = ahres.InfRefmsgid
  30923. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30924. // 创建对应的Time类型
  30925. t := time.UnixMilli(timestamp)
  30926. // 格式化成指定的日期字符串
  30927. str := t.Format("2006-01-02 15:04:05")
  30928. res.Output.Setlinfo.SetlTime = str
  30929. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30930. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30931. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30932. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30933. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30934. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30935. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30936. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30937. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30938. //
  30939. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30940. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30941. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30942. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30943. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30944. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30945. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30946. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30947. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30948. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30949. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30950. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30951. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30952. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30953. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30954. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30955. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30956. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30957. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30958. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30959. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30960. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30961. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30962. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30963. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30964. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30965. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30966. //res.Output.Setldetail = ahres.Output.Setldetail
  30967. res.ErrMsg = ahres.ErrMsg
  30968. res.Cainfo = ahres.Cainfo
  30969. res.WarnMsg = ahres.WarnMsg
  30970. res.Infcode = ahres.Infcode
  30971. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30972. var api3 string
  30973. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  30974. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30975. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30976. resp3, requestErr3 := http.Get(api3)
  30977. if requestErr3 != nil {
  30978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30979. return
  30980. }
  30981. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  30982. if ioErr3 != nil {
  30983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  30984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30985. return
  30986. }
  30987. var respJSON3 map[string]interface{}
  30988. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  30989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30991. return
  30992. }
  30993. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  30994. if status == "0" {
  30995. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  30996. c.ServeSuccessJSON(map[string]interface{}{
  30997. "failed_code": -10,
  30998. "msg": err_msg,
  30999. })
  31000. return
  31001. }
  31002. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31003. userJSONBytes3, _ := json.Marshal(respJSON3)
  31004. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31005. // utils.ErrorLog("解析失败:%v", err)
  31006. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31007. // return
  31008. //}
  31009. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31010. utils.ErrorLog("解析失败:%v", err)
  31011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31012. return
  31013. }
  31014. res.InfRefmsgid = ahres.InfRefmsgid
  31015. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31016. // 创建对应的Time类型
  31017. t := time.UnixMilli(timestamp)
  31018. // 格式化成指定的日期字符串
  31019. str := t.Format("2006-01-02 15:04:05")
  31020. res.Output.Setlinfo.SetlTime = str
  31021. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31022. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31023. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31024. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31025. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31026. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31027. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31028. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31029. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31030. //
  31031. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31032. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31033. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31034. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31035. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31036. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31037. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31038. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31039. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31040. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31041. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31042. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31043. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31044. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31045. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31046. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31047. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31048. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31049. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31050. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31051. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31052. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31053. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31054. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31055. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31056. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31057. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31058. //res.Output.Setldetail = ahres.Output.Setldetail
  31059. res.ErrMsg = ahres.ErrMsg
  31060. res.Cainfo = ahres.Cainfo
  31061. res.WarnMsg = ahres.WarnMsg
  31062. res.Infcode = ahres.Infcode
  31063. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31064. 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, "")
  31065. var dat map[string]interface{}
  31066. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31067. fmt.Println(dat)
  31068. } else {
  31069. fmt.Println(err)
  31070. }
  31071. saveLog(result, src_resquest, "2208", "退费")
  31072. userJSONBytes, _ := json.Marshal(dat)
  31073. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31074. utils.ErrorLog("解析失败:%v", err)
  31075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31076. return
  31077. }
  31078. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31079. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31080. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31081. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31082. resp3, requestErr3 := http.Get(api3)
  31083. if requestErr3 != nil {
  31084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31085. return
  31086. }
  31087. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31088. if ioErr3 != nil {
  31089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31091. return
  31092. }
  31093. var respJSON3 map[string]interface{}
  31094. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31097. return
  31098. }
  31099. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31100. userJSONBytes3, _ := json.Marshal(respJSON3)
  31101. fmt.Println("log")
  31102. fmt.Println(string(userJSONBytes3))
  31103. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31104. utils.ErrorLog("解析失败:%v", err)
  31105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31106. return
  31107. }
  31108. } else {
  31109. if miConfig.Code == "H15049901371" {
  31110. 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)
  31111. var dat map[string]interface{}
  31112. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31113. fmt.Println(dat)
  31114. } else {
  31115. fmt.Println(err)
  31116. }
  31117. saveLog(result, src_resquest, "2208", "退费")
  31118. if strings.Contains(result, "Post") {
  31119. res.Infcode = -1
  31120. res.ErrMsg = result
  31121. }
  31122. userJSONBytes, _ := json.Marshal(dat)
  31123. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31124. utils.ErrorLog("解析失败:%v", err)
  31125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31126. return
  31127. }
  31128. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31129. res.Output = resSixteen10265.Output
  31130. res.ErrMsg = resSixteen10265.ErrMsg
  31131. res.Cainfo = resSixteen10265.Cainfo
  31132. res.WarnMsg = resSixteen10265.WarnMsg
  31133. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31134. res.Infcode = infocode
  31135. } else {
  31136. 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)
  31137. var dat map[string]interface{}
  31138. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31139. fmt.Println(dat)
  31140. } else {
  31141. fmt.Println(err)
  31142. }
  31143. saveLog(result, src_resquest, "2208", "退费")
  31144. userJSONBytes, _ := json.Marshal(dat)
  31145. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31146. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31147. utils.ErrorLog("解析失败:%v", err)
  31148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31149. return
  31150. }
  31151. res.Infcode = gz.Infcode
  31152. } else {
  31153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31154. utils.ErrorLog("解析失败:%v", err)
  31155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31156. return
  31157. }
  31158. }
  31159. if strings.Contains(result, "Post") {
  31160. res.Infcode = -1
  31161. res.ErrMsg = result
  31162. }
  31163. }
  31164. }
  31165. if res.Infcode == -1 {
  31166. c.ServeSuccessJSON(map[string]interface{}{
  31167. "failed_code": -10,
  31168. "msg": res.ErrMsg,
  31169. })
  31170. return
  31171. }
  31172. if res.Infcode != -1 {
  31173. var res2 ResultSix
  31174. var resSix10265 ResultSix10265
  31175. if miConfig.MdtrtareaAdmvs == "421300" {
  31176. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31177. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31178. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31179. resp3, requestErr3 := http.Get(api3)
  31180. if requestErr3 != nil {
  31181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31182. return
  31183. }
  31184. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31185. if ioErr3 != nil {
  31186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31188. return
  31189. }
  31190. var respJSON3 map[string]interface{}
  31191. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31194. return
  31195. }
  31196. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31197. userJSONBytes3, _ := json.Marshal(respJSON3)
  31198. fmt.Println("log")
  31199. fmt.Println(string(userJSONBytes3))
  31200. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31201. utils.ErrorLog("解析失败:%v", err)
  31202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31203. return
  31204. }
  31205. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31206. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31207. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31208. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31209. resp3, requestErr3 := http.Get(api3)
  31210. if requestErr3 != nil {
  31211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31212. return
  31213. }
  31214. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31215. if ioErr3 != nil {
  31216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31218. return
  31219. }
  31220. var respJSON3 map[string]interface{}
  31221. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31224. return
  31225. }
  31226. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31227. userJSONBytes3, _ := json.Marshal(respJSON3)
  31228. fmt.Println("log")
  31229. fmt.Println(string(userJSONBytes3))
  31230. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31231. utils.ErrorLog("解析失败:%v", err)
  31232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31233. return
  31234. }
  31235. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31236. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31237. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31238. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31239. resp3, requestErr3 := http.Get(api3)
  31240. if requestErr3 != nil {
  31241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31242. return
  31243. }
  31244. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31245. if ioErr3 != nil {
  31246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31248. return
  31249. }
  31250. var respJSON3 map[string]interface{}
  31251. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31254. return
  31255. }
  31256. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31257. userJSONBytes3, _ := json.Marshal(respJSON3)
  31258. fmt.Println("log")
  31259. fmt.Println(string(userJSONBytes3))
  31260. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31261. utils.ErrorLog("解析失败:%v", err)
  31262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31263. return
  31264. }
  31265. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31266. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31267. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31268. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31269. resp3, requestErr3 := http.Get(api3)
  31270. if requestErr3 != nil {
  31271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31272. return
  31273. }
  31274. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31275. if ioErr3 != nil {
  31276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31278. return
  31279. }
  31280. var respJSON3 map[string]interface{}
  31281. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31284. return
  31285. }
  31286. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31287. userJSONBytes3, _ := json.Marshal(respJSON3)
  31288. fmt.Println("log")
  31289. fmt.Println(string(userJSONBytes3))
  31290. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31291. utils.ErrorLog("解析失败:%v", err)
  31292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31293. return
  31294. }
  31295. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31296. var api3 string
  31297. if miConfig.MdtrtareaAdmvs == "320921" {
  31298. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31299. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31300. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31301. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31302. } else {
  31303. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31304. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31305. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31306. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31307. }
  31308. resp3, requestErr3 := http.Get(api3)
  31309. if requestErr3 != nil {
  31310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31311. return
  31312. }
  31313. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31314. if ioErr3 != nil {
  31315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31317. return
  31318. }
  31319. var respJSON3 map[string]interface{}
  31320. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31323. return
  31324. }
  31325. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31326. userJSONBytes3, _ := json.Marshal(respJSON3)
  31327. fmt.Println("log")
  31328. fmt.Println(string(userJSONBytes3))
  31329. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31330. utils.ErrorLog("解析失败:%v", err)
  31331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31332. return
  31333. }
  31334. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31335. res2.Output = resSix10265.Output
  31336. res2.ErrMsg = resSix10265.ErrMsg
  31337. res2.Cainfo = resSix10265.Cainfo
  31338. res2.WarnMsg = resSix10265.WarnMsg
  31339. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31340. res2.Infcode = infocode
  31341. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31342. var api3 string
  31343. new_chrg_bchno := order.Number
  31344. if adminUser.CurrentOrgId == 10265 {
  31345. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31346. new_chrg_bchno = "0000"
  31347. }
  31348. }
  31349. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31350. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31351. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31352. resp3, requestErr3 := http.Get(api3)
  31353. if requestErr3 != nil {
  31354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31355. return
  31356. }
  31357. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31358. if ioErr3 != nil {
  31359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31361. return
  31362. }
  31363. var respJSON3 map[string]interface{}
  31364. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31367. return
  31368. }
  31369. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31370. userJSONBytes3, _ := json.Marshal(respJSON3)
  31371. fmt.Println("log")
  31372. fmt.Println(string(userJSONBytes3))
  31373. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31374. utils.ErrorLog("解析失败:%v", err)
  31375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31376. return
  31377. }
  31378. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31379. res2.Output = resSix10265.Output
  31380. res2.ErrMsg = resSix10265.ErrMsg
  31381. res2.Cainfo = resSix10265.Cainfo
  31382. res2.WarnMsg = resSix10265.WarnMsg
  31383. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31384. res2.Infcode = infocode
  31385. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31386. 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)
  31387. var dat map[string]interface{}
  31388. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31389. fmt.Println(dat)
  31390. } else {
  31391. fmt.Println(err)
  31392. }
  31393. saveLog(result2, src_request, "2205", "撤销明细")
  31394. userJSONBytes, _ := json.Marshal(dat)
  31395. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31396. utils.ErrorLog("解析失败:%v", err)
  31397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31398. return
  31399. }
  31400. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31401. 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, "")
  31402. var dat map[string]interface{}
  31403. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31404. fmt.Println(dat)
  31405. } else {
  31406. fmt.Println(err)
  31407. }
  31408. saveLog(result2, src_request, "2205", "撤销明细")
  31409. userJSONBytes, _ := json.Marshal(dat)
  31410. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31411. utils.ErrorLog("解析失败:%v", err)
  31412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31413. return
  31414. }
  31415. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31416. 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, "")
  31417. var dat map[string]interface{}
  31418. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31419. fmt.Println(dat)
  31420. } else {
  31421. fmt.Println(err)
  31422. }
  31423. saveLog(result2, src_request, "2205", "撤销明细")
  31424. userJSONBytes, _ := json.Marshal(dat)
  31425. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31426. utils.ErrorLog("解析失败:%v", err)
  31427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31428. return
  31429. }
  31430. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31431. var api3 string
  31432. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31433. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31434. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31435. resp3, requestErr3 := http.Get(api3)
  31436. if requestErr3 != nil {
  31437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31438. return
  31439. }
  31440. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31441. if ioErr3 != nil {
  31442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31444. return
  31445. }
  31446. var respJSON3 map[string]interface{}
  31447. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31450. return
  31451. }
  31452. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31453. if status == "0" {
  31454. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31455. c.ServeSuccessJSON(map[string]interface{}{
  31456. "failed_code": -10,
  31457. "msg": err_msg,
  31458. })
  31459. return
  31460. }
  31461. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31462. userJSONBytes3, _ := json.Marshal(respJSON3)
  31463. fmt.Println("log")
  31464. fmt.Println(string(userJSONBytes3))
  31465. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31466. utils.ErrorLog("解析失败:%v", err)
  31467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31468. return
  31469. }
  31470. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31471. 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, "")
  31472. var dat map[string]interface{}
  31473. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31474. fmt.Println(dat)
  31475. } else {
  31476. fmt.Println(err)
  31477. }
  31478. saveLog(result2, src_request, "2205", "撤销明细")
  31479. userJSONBytes, _ := json.Marshal(dat)
  31480. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31481. utils.ErrorLog("解析失败:%v", err)
  31482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31483. return
  31484. }
  31485. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31486. 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, "")
  31487. var dat map[string]interface{}
  31488. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31489. fmt.Println(dat)
  31490. } else {
  31491. fmt.Println(err)
  31492. }
  31493. saveLog(result2, src_request, "2205", "撤销明细")
  31494. userJSONBytes, _ := json.Marshal(dat)
  31495. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31496. utils.ErrorLog("解析失败:%v", err)
  31497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31498. return
  31499. }
  31500. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31501. var api3 string
  31502. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31503. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31505. resp3, requestErr3 := http.Get(api3)
  31506. if requestErr3 != nil {
  31507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31508. return
  31509. }
  31510. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31511. if ioErr3 != nil {
  31512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31514. return
  31515. }
  31516. var respJSON3 map[string]interface{}
  31517. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31520. return
  31521. }
  31522. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31523. if status == "0" {
  31524. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31525. c.ServeSuccessJSON(map[string]interface{}{
  31526. "failed_code": -10,
  31527. "msg": err_msg,
  31528. })
  31529. return
  31530. }
  31531. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31532. userJSONBytes3, _ := json.Marshal(respJSON3)
  31533. fmt.Println("log")
  31534. fmt.Println(string(userJSONBytes3))
  31535. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31536. utils.ErrorLog("解析失败:%v", err)
  31537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31538. return
  31539. }
  31540. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31541. 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, "")
  31542. var dat map[string]interface{}
  31543. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31544. fmt.Println(dat)
  31545. } else {
  31546. fmt.Println(err)
  31547. }
  31548. saveLog(result2, src_request, "2205", "撤销明细")
  31549. userJSONBytes, _ := json.Marshal(dat)
  31550. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31551. utils.ErrorLog("解析失败:%v", err)
  31552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31553. return
  31554. }
  31555. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31556. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  31557. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31558. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31559. resp3, requestErr3 := http.Get(api3)
  31560. if requestErr3 != nil {
  31561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31562. return
  31563. }
  31564. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31565. if ioErr3 != nil {
  31566. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31568. return
  31569. }
  31570. var respJSON3 map[string]interface{}
  31571. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31572. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31574. return
  31575. }
  31576. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31577. userJSONBytes3, _ := json.Marshal(respJSON3)
  31578. fmt.Println("log")
  31579. fmt.Println(string(userJSONBytes3))
  31580. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31581. utils.ErrorLog("解析失败:%v", err)
  31582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31583. return
  31584. }
  31585. } else {
  31586. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31587. res2.Infcode = 0
  31588. } else {
  31589. 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)
  31590. var dat map[string]interface{}
  31591. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31592. fmt.Println(dat)
  31593. } else {
  31594. fmt.Println(err)
  31595. }
  31596. saveLog(result2, src_request, "2205", "撤销明细")
  31597. userJSONBytes, _ := json.Marshal(dat)
  31598. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31599. utils.ErrorLog("解析失败:%v", err)
  31600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31601. return
  31602. }
  31603. }
  31604. }
  31605. if res2.Infcode == -1 {
  31606. c.ServeSuccessJSON(map[string]interface{}{
  31607. "failed_code": -10,
  31608. "msg": res2.ErrMsg,
  31609. })
  31610. return
  31611. }
  31612. if res2.Infcode == 0 {
  31613. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  31614. if err == nil {
  31615. //当押金不为零时产生退费记录
  31616. if order.Decimal != 0 {
  31617. tmp := strconv.FormatInt(order.ID, 10)
  31618. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  31619. if err != nil {
  31620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31621. return
  31622. }
  31623. }
  31624. c.ServeSuccessJSON(map[string]interface{}{
  31625. "msg": "退费成功",
  31626. })
  31627. } else {
  31628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31629. return
  31630. }
  31631. } else {
  31632. c.ServeSuccessJSON(map[string]interface{}{
  31633. "failed_code": -10,
  31634. "msg": res2.ErrMsg,
  31635. })
  31636. }
  31637. } else {
  31638. c.ServeSuccessJSON(map[string]interface{}{
  31639. "failed_code": -10,
  31640. "msg": res.ErrMsg,
  31641. })
  31642. }
  31643. }
  31644. }
  31645. func (c *HisApiController) RefundNumber() {
  31646. record_time := c.GetString("record_time")
  31647. //patient_id, _ := c.GetInt64("patient_id")
  31648. admin_user_id, _ := c.GetInt64("admin_user_id")
  31649. his_patient_id, _ := c.GetInt64("id")
  31650. timeLayout := "2006-01-02"
  31651. loc, _ := time.LoadLocation("Local")
  31652. adminUser := c.GetAdminUserInfo()
  31653. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31654. fmt.Println(err)
  31655. if err != nil {
  31656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31657. return
  31658. }
  31659. recordDateTime := theTime.Unix()
  31660. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31661. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  31662. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  31663. //order, _ := service.GetHisOrderByID(order_id)
  31664. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31665. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31666. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31667. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  31668. if count > 0 {
  31669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  31670. return
  31671. }
  31672. if config.IsOpen == 1 { //对接了医保,走医保流程
  31673. var res2 ResultSix
  31674. var res3 GZResultSix
  31675. var resSix10265 ResultSix10265
  31676. if miConfig.MdtrtareaAdmvs == "421300" {
  31677. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  31678. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31679. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31680. resp3, requestErr3 := http.Get(api3)
  31681. if requestErr3 != nil {
  31682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31683. return
  31684. }
  31685. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31686. if ioErr3 != nil {
  31687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31689. return
  31690. }
  31691. var respJSON3 map[string]interface{}
  31692. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31695. return
  31696. }
  31697. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31698. userJSONBytes3, _ := json.Marshal(respJSON3)
  31699. fmt.Println("log")
  31700. fmt.Println(string(userJSONBytes3))
  31701. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31702. utils.ErrorLog("解析失败:%v", err)
  31703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31704. return
  31705. }
  31706. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31707. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  31708. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31709. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31710. resp3, requestErr3 := http.Get(api3)
  31711. if requestErr3 != nil {
  31712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31713. return
  31714. }
  31715. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31716. if ioErr3 != nil {
  31717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31719. return
  31720. }
  31721. var respJSON3 map[string]interface{}
  31722. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31725. return
  31726. }
  31727. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31728. userJSONBytes3, _ := json.Marshal(respJSON3)
  31729. fmt.Println("log")
  31730. fmt.Println(string(userJSONBytes3))
  31731. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31732. utils.ErrorLog("解析失败:%v", err)
  31733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31734. return
  31735. }
  31736. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31737. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  31738. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31739. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31740. resp3, requestErr3 := http.Get(api3)
  31741. if requestErr3 != nil {
  31742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31743. return
  31744. }
  31745. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31746. if ioErr3 != nil {
  31747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31749. return
  31750. }
  31751. var respJSON3 map[string]interface{}
  31752. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31755. return
  31756. }
  31757. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31758. userJSONBytes3, _ := json.Marshal(respJSON3)
  31759. fmt.Println("log")
  31760. fmt.Println(string(userJSONBytes3))
  31761. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31762. utils.ErrorLog("解析失败:%v", err)
  31763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31764. return
  31765. }
  31766. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31767. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  31768. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31769. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31770. resp3, requestErr3 := http.Get(api3)
  31771. if requestErr3 != nil {
  31772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31773. return
  31774. }
  31775. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31776. if ioErr3 != nil {
  31777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31779. return
  31780. }
  31781. var respJSON3 map[string]interface{}
  31782. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31785. return
  31786. }
  31787. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31788. userJSONBytes3, _ := json.Marshal(respJSON3)
  31789. fmt.Println("log")
  31790. fmt.Println(string(userJSONBytes3))
  31791. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31792. utils.ErrorLog("解析失败:%v", err)
  31793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31794. return
  31795. }
  31796. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31797. var api3 string
  31798. if miConfig.MdtrtareaAdmvs == "320921" {
  31799. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  31800. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31801. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31802. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31803. } else {
  31804. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31805. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  31806. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31807. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31808. }
  31809. resp3, requestErr3 := http.Get(api3)
  31810. if requestErr3 != nil {
  31811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31812. return
  31813. }
  31814. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31815. if ioErr3 != nil {
  31816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31818. return
  31819. }
  31820. var respJSON3 map[string]interface{}
  31821. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31824. return
  31825. }
  31826. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31827. userJSONBytes3, _ := json.Marshal(respJSON3)
  31828. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31829. utils.ErrorLog("解析失败:%v", err)
  31830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31831. return
  31832. }
  31833. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31834. res2.Output = resSix10265.Output
  31835. res2.ErrMsg = resSix10265.ErrMsg
  31836. res2.Cainfo = resSix10265.Cainfo
  31837. res2.WarnMsg = resSix10265.WarnMsg
  31838. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31839. res2.Infcode = infocode
  31840. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31841. var api3 string
  31842. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  31843. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31844. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31845. resp3, requestErr3 := http.Get(api3)
  31846. if requestErr3 != nil {
  31847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31848. return
  31849. }
  31850. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31851. if ioErr3 != nil {
  31852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31854. return
  31855. }
  31856. var respJSON3 map[string]interface{}
  31857. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31860. return
  31861. }
  31862. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31863. userJSONBytes3, _ := json.Marshal(respJSON3)
  31864. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31865. utils.ErrorLog("解析失败:%v", err)
  31866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31867. return
  31868. }
  31869. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31870. res2.Output = resSix10265.Output
  31871. res2.ErrMsg = resSix10265.ErrMsg
  31872. res2.Cainfo = resSix10265.Cainfo
  31873. res2.WarnMsg = resSix10265.WarnMsg
  31874. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31875. res2.Infcode = infocode
  31876. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31877. 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)
  31878. var dat map[string]interface{}
  31879. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31880. fmt.Println(dat)
  31881. } else {
  31882. fmt.Println(err)
  31883. }
  31884. saveLog(result, request, "2202", "退号")
  31885. userJSONBytes, _ := json.Marshal(dat)
  31886. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31887. utils.ErrorLog("解析失败:%v", err)
  31888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31889. return
  31890. }
  31891. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31892. 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, "")
  31893. var dat map[string]interface{}
  31894. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31895. fmt.Println(dat)
  31896. } else {
  31897. fmt.Println(err)
  31898. }
  31899. saveLog(result, request, "2202", "退号")
  31900. userJSONBytes, _ := json.Marshal(dat)
  31901. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31902. utils.ErrorLog("解析失败:%v", err)
  31903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31904. return
  31905. }
  31906. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31907. 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, "")
  31908. var dat map[string]interface{}
  31909. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31910. fmt.Println(dat)
  31911. } else {
  31912. fmt.Println(err)
  31913. }
  31914. saveLog(result, request, "2202", "退号")
  31915. userJSONBytes, _ := json.Marshal(dat)
  31916. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31917. utils.ErrorLog("解析失败:%v", err)
  31918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31919. return
  31920. }
  31921. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31922. var api3 string
  31923. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  31924. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31925. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31926. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31927. resp3, requestErr3 := http.Get(api3)
  31928. if requestErr3 != nil {
  31929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31930. return
  31931. }
  31932. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31933. if ioErr3 != nil {
  31934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31936. return
  31937. }
  31938. var respJSON3 map[string]interface{}
  31939. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31942. return
  31943. }
  31944. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31945. if status == "0" {
  31946. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31947. c.ServeSuccessJSON(map[string]interface{}{
  31948. "failed_code": -10,
  31949. "msg": err_msg,
  31950. })
  31951. return
  31952. }
  31953. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31954. userJSONBytes3, _ := json.Marshal(respJSON3)
  31955. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31956. utils.ErrorLog("解析失败:%v", err)
  31957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31958. return
  31959. }
  31960. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  31961. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31962. var api3 string
  31963. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  31964. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31965. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31966. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31967. resp3, requestErr3 := http.Get(api3)
  31968. if requestErr3 != nil {
  31969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31970. return
  31971. }
  31972. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31973. if ioErr3 != nil {
  31974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31976. return
  31977. }
  31978. var respJSON3 map[string]interface{}
  31979. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31982. return
  31983. }
  31984. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31985. if status == "0" {
  31986. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31987. c.ServeSuccessJSON(map[string]interface{}{
  31988. "failed_code": -10,
  31989. "msg": err_msg,
  31990. })
  31991. return
  31992. }
  31993. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31994. userJSONBytes3, _ := json.Marshal(respJSON3)
  31995. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31996. utils.ErrorLog("解析失败:%v", err)
  31997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31998. return
  31999. }
  32000. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32001. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32002. 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, "")
  32003. var dat map[string]interface{}
  32004. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32005. fmt.Println(dat)
  32006. } else {
  32007. fmt.Println(err)
  32008. }
  32009. saveLog(result, request, "2202", "退号")
  32010. userJSONBytes, _ := json.Marshal(dat)
  32011. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32012. utils.ErrorLog("解析失败:%v", err)
  32013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32014. return
  32015. }
  32016. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32017. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32018. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32019. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32020. resp3, requestErr3 := http.Get(api3)
  32021. if requestErr3 != nil {
  32022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32023. return
  32024. }
  32025. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32026. if ioErr3 != nil {
  32027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32029. return
  32030. }
  32031. var respJSON3 map[string]interface{}
  32032. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32035. return
  32036. }
  32037. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32038. userJSONBytes3, _ := json.Marshal(respJSON3)
  32039. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32040. utils.ErrorLog("解析失败:%v", err)
  32041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32042. return
  32043. }
  32044. } else {
  32045. var api3 string
  32046. if miConfig.Code == "H15049901371" {
  32047. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32048. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32049. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32050. } else {
  32051. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32052. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32053. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32054. }
  32055. resp3, requestErr3 := http.Get(api3)
  32056. if requestErr3 != nil {
  32057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32058. return
  32059. }
  32060. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32061. if ioErr3 != nil {
  32062. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32064. return
  32065. }
  32066. var respJSON3 map[string]interface{}
  32067. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32068. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32070. return
  32071. }
  32072. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32073. userJSONBytes3, _ := json.Marshal(respJSON3)
  32074. if miConfig.Code == "H15049901371" {
  32075. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32076. utils.ErrorLog("解析失败:%v", err)
  32077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32078. return
  32079. }
  32080. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32081. res2.Output = resSix10265.Output
  32082. res2.ErrMsg = resSix10265.ErrMsg
  32083. res2.Cainfo = resSix10265.Cainfo
  32084. res2.WarnMsg = resSix10265.WarnMsg
  32085. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32086. res2.Infcode = infocode
  32087. } else {
  32088. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32089. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32090. utils.ErrorLog("解析失败:%v", err)
  32091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32092. return
  32093. }
  32094. res2.Infcode = res3.Infcode
  32095. } else {
  32096. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32097. utils.ErrorLog("解析失败:%v", err)
  32098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32099. return
  32100. }
  32101. }
  32102. }
  32103. }
  32104. if res2.Infcode == -1 {
  32105. c.ServeSuccessJSON(map[string]interface{}{
  32106. "failed_code": -10,
  32107. "msg": res2.ErrMsg,
  32108. })
  32109. return
  32110. }
  32111. if res2.Infcode == 0 {
  32112. if err == nil {
  32113. c.ServeSuccessJSON(map[string]interface{}{
  32114. "msg": "退号成功",
  32115. })
  32116. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32117. } else {
  32118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32119. return
  32120. }
  32121. }
  32122. } else {
  32123. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32124. //if err == nil {
  32125. // c.ServeSuccessJSON(map[string]interface{}{
  32126. // "msg": "退费成功",
  32127. // })
  32128. //} else {
  32129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32130. // return
  32131. //}
  32132. }
  32133. }
  32134. func (c *HisApiController) RefundDetail() {
  32135. order_id, _ := c.GetInt64("order_id")
  32136. admin_user_id, _ := c.GetInt64("admin_user_id")
  32137. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32138. number := c.GetString("number")
  32139. record_time := c.GetString("record_time")
  32140. patient_id, _ := c.GetInt64("patient_id")
  32141. //med_type, _ := c.GetInt64("med_type")
  32142. timeLayout := "2006-01-02"
  32143. loc, _ := time.LoadLocation("Local")
  32144. adminUser := c.GetAdminUserInfo()
  32145. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32146. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32147. fmt.Println(err)
  32148. if err != nil {
  32149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32150. return
  32151. }
  32152. recordDateTime := theTime.Unix()
  32153. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32154. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32155. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32156. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32157. var order models.HisOrder
  32158. order, _ = service.GetHisOrderByID(order_id)
  32159. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32160. if config.IsOpen == 1 { //对接了医保,走医保流程
  32161. var res2 ResultSix
  32162. if miConfig.MdtrtareaAdmvs == "421300" {
  32163. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32164. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32165. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32166. resp3, requestErr3 := http.Get(api3)
  32167. if requestErr3 != nil {
  32168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32169. return
  32170. }
  32171. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32172. if ioErr3 != nil {
  32173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32175. return
  32176. }
  32177. var respJSON3 map[string]interface{}
  32178. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32181. return
  32182. }
  32183. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32184. userJSONBytes3, _ := json.Marshal(respJSON3)
  32185. fmt.Println("log")
  32186. fmt.Println(string(userJSONBytes3))
  32187. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32188. utils.ErrorLog("解析失败:%v", err)
  32189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32190. return
  32191. }
  32192. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32193. if err == nil {
  32194. c.ServeSuccessJSON(map[string]interface{}{
  32195. "msg": "撤销明细成功",
  32196. })
  32197. return
  32198. } else {
  32199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32200. return
  32201. }
  32202. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32203. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32204. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32205. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32206. resp3, requestErr3 := http.Get(api3)
  32207. if requestErr3 != nil {
  32208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32209. return
  32210. }
  32211. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32212. if ioErr3 != nil {
  32213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32215. return
  32216. }
  32217. var respJSON3 map[string]interface{}
  32218. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32221. return
  32222. }
  32223. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32224. userJSONBytes3, _ := json.Marshal(respJSON3)
  32225. fmt.Println("log")
  32226. fmt.Println(string(userJSONBytes3))
  32227. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32228. utils.ErrorLog("解析失败:%v", err)
  32229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32230. return
  32231. }
  32232. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32233. if err == nil {
  32234. c.ServeSuccessJSON(map[string]interface{}{
  32235. "msg": "撤销明细成功",
  32236. })
  32237. return
  32238. } else {
  32239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32240. return
  32241. }
  32242. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32243. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32244. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32245. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32246. resp3, requestErr3 := http.Get(api3)
  32247. if requestErr3 != nil {
  32248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32249. return
  32250. }
  32251. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32252. if ioErr3 != nil {
  32253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32255. return
  32256. }
  32257. var respJSON3 map[string]interface{}
  32258. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32261. return
  32262. }
  32263. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32264. userJSONBytes3, _ := json.Marshal(respJSON3)
  32265. fmt.Println("log")
  32266. fmt.Println(string(userJSONBytes3))
  32267. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32268. utils.ErrorLog("解析失败:%v", err)
  32269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32270. return
  32271. }
  32272. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32273. if err == nil {
  32274. c.ServeSuccessJSON(map[string]interface{}{
  32275. "msg": "撤销明细成功",
  32276. })
  32277. return
  32278. } else {
  32279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32280. return
  32281. }
  32282. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32283. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32284. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&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. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32313. if err == nil {
  32314. c.ServeSuccessJSON(map[string]interface{}{
  32315. "msg": "撤销明细成功",
  32316. })
  32317. return
  32318. } else {
  32319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32320. return
  32321. }
  32322. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32323. var resSix10265 ResultSix10265
  32324. var api3 string
  32325. if miConfig.MdtrtareaAdmvs == "320921" {
  32326. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32327. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32328. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32329. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32330. } else {
  32331. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32332. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32333. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32334. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32335. }
  32336. resp3, requestErr3 := http.Get(api3)
  32337. utils.ErrorLog("接口: %v", requestErr3)
  32338. if requestErr3 != nil {
  32339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32340. return
  32341. }
  32342. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32343. if ioErr3 != nil {
  32344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32346. return
  32347. }
  32348. var respJSON3 map[string]interface{}
  32349. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32352. return
  32353. }
  32354. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32355. userJSONBytes3, _ := json.Marshal(respJSON3)
  32356. fmt.Println("log")
  32357. fmt.Println(string(userJSONBytes3))
  32358. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32359. utils.ErrorLog("解析失败:%v", err)
  32360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32361. return
  32362. }
  32363. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32364. res2.Output = resSix10265.Output
  32365. res2.ErrMsg = resSix10265.ErrMsg
  32366. res2.Cainfo = resSix10265.Cainfo
  32367. res2.WarnMsg = resSix10265.WarnMsg
  32368. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32369. res2.Infcode = infocode
  32370. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32371. if err == nil {
  32372. c.ServeSuccessJSON(map[string]interface{}{
  32373. "msg": "撤销明细成功",
  32374. })
  32375. return
  32376. } else {
  32377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32378. return
  32379. }
  32380. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32381. var api3 string
  32382. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32383. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32384. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32385. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32386. resp3, requestErr3 := http.Get(api3)
  32387. utils.ErrorLog("接口: %v", requestErr3)
  32388. if requestErr3 != nil {
  32389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32390. return
  32391. }
  32392. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32393. if ioErr3 != nil {
  32394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32396. return
  32397. }
  32398. var respJSON3 map[string]interface{}
  32399. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32402. return
  32403. }
  32404. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32405. if status == "0" {
  32406. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32407. c.ServeSuccessJSON(map[string]interface{}{
  32408. "failed_code": -10,
  32409. "msg": err_msg,
  32410. })
  32411. return
  32412. }
  32413. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32414. userJSONBytes3, _ := json.Marshal(respJSON3)
  32415. fmt.Println("log")
  32416. fmt.Println(string(userJSONBytes3))
  32417. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32418. utils.ErrorLog("解析失败:%v", err)
  32419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32420. return
  32421. }
  32422. fmt.Println(res2.Infcode)
  32423. if res2.Infcode == -1 {
  32424. c.ServeSuccessJSON(map[string]interface{}{
  32425. "failed_code": -10,
  32426. "msg": res2.ErrMsg,
  32427. })
  32428. return
  32429. }
  32430. if res2.Infcode == 0 {
  32431. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32432. if err == nil {
  32433. c.ServeSuccessJSON(map[string]interface{}{
  32434. "msg": "撤销明细成功",
  32435. })
  32436. return
  32437. } else {
  32438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32439. return
  32440. }
  32441. } else {
  32442. c.ServeSuccessJSON(map[string]interface{}{
  32443. "failed_code": -10,
  32444. "msg": res2.ErrMsg,
  32445. })
  32446. }
  32447. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32448. if err == nil {
  32449. c.ServeSuccessJSON(map[string]interface{}{
  32450. "msg": "撤销明细成功",
  32451. })
  32452. return
  32453. } else {
  32454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32455. return
  32456. }
  32457. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32458. var api3 string
  32459. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32460. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32461. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32462. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32463. resp3, requestErr3 := http.Get(api3)
  32464. utils.ErrorLog("接口: %v", requestErr3)
  32465. if requestErr3 != nil {
  32466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32467. return
  32468. }
  32469. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32470. if ioErr3 != nil {
  32471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32473. return
  32474. }
  32475. var respJSON3 map[string]interface{}
  32476. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32479. return
  32480. }
  32481. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32482. if status == "0" {
  32483. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32484. c.ServeSuccessJSON(map[string]interface{}{
  32485. "failed_code": -10,
  32486. "msg": err_msg,
  32487. })
  32488. return
  32489. }
  32490. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32491. userJSONBytes3, _ := json.Marshal(respJSON3)
  32492. fmt.Println("log")
  32493. fmt.Println(string(userJSONBytes3))
  32494. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32495. utils.ErrorLog("解析失败:%v", err)
  32496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32497. return
  32498. }
  32499. fmt.Println(res2.Infcode)
  32500. if res2.Infcode == -1 {
  32501. c.ServeSuccessJSON(map[string]interface{}{
  32502. "failed_code": -10,
  32503. "msg": res2.ErrMsg,
  32504. })
  32505. return
  32506. }
  32507. if res2.Infcode == 0 {
  32508. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32509. if err == nil {
  32510. c.ServeSuccessJSON(map[string]interface{}{
  32511. "msg": "撤销明细成功",
  32512. })
  32513. return
  32514. } else {
  32515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32516. return
  32517. }
  32518. } else {
  32519. c.ServeSuccessJSON(map[string]interface{}{
  32520. "failed_code": -10,
  32521. "msg": res2.ErrMsg,
  32522. })
  32523. }
  32524. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32525. if err == nil {
  32526. c.ServeSuccessJSON(map[string]interface{}{
  32527. "msg": "撤销明细成功",
  32528. })
  32529. return
  32530. } else {
  32531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32532. return
  32533. }
  32534. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32535. var resSix10265 ResultSix10265
  32536. new_chrg_bchno := order.Number
  32537. if adminUser.CurrentOrgId == 10265 {
  32538. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  32539. new_chrg_bchno = "0000"
  32540. }
  32541. }
  32542. var api3 string
  32543. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  32544. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32545. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32546. resp3, requestErr3 := http.Get(api3)
  32547. if requestErr3 != nil {
  32548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32549. return
  32550. }
  32551. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32552. if ioErr3 != nil {
  32553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32555. return
  32556. }
  32557. var respJSON3 map[string]interface{}
  32558. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32561. return
  32562. }
  32563. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32564. userJSONBytes3, _ := json.Marshal(respJSON3)
  32565. fmt.Println("log")
  32566. fmt.Println(string(userJSONBytes3))
  32567. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32568. utils.ErrorLog("解析失败:%v", err)
  32569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32570. return
  32571. }
  32572. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32573. res2.Output = resSix10265.Output
  32574. res2.ErrMsg = resSix10265.ErrMsg
  32575. res2.Cainfo = resSix10265.Cainfo
  32576. res2.WarnMsg = resSix10265.WarnMsg
  32577. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32578. res2.Infcode = infocode
  32579. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32580. if err == nil {
  32581. c.ServeSuccessJSON(map[string]interface{}{
  32582. "msg": "撤销明细成功",
  32583. })
  32584. return
  32585. } else {
  32586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32587. return
  32588. }
  32589. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32590. 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)
  32591. var dat map[string]interface{}
  32592. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32593. fmt.Println(dat)
  32594. } else {
  32595. fmt.Println(err)
  32596. }
  32597. saveLog(result2, src_request, "2205", "撤销明细")
  32598. userJSONBytes, _ := json.Marshal(dat)
  32599. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32600. utils.ErrorLog("解析失败:%v", err)
  32601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32602. return
  32603. }
  32604. if res2.Infcode == 0 {
  32605. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32606. if err == nil {
  32607. c.ServeSuccessJSON(map[string]interface{}{
  32608. "msg": "撤销明细成功",
  32609. })
  32610. return
  32611. } else {
  32612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32613. return
  32614. }
  32615. } else {
  32616. c.ServeSuccessJSON(map[string]interface{}{
  32617. "failed_code": -10,
  32618. "msg": res2.ErrMsg,
  32619. })
  32620. }
  32621. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32622. 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, "")
  32623. var dat map[string]interface{}
  32624. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32625. fmt.Println(dat)
  32626. } else {
  32627. fmt.Println(err)
  32628. }
  32629. saveLog(result2, src_request, "2205", "撤销明细")
  32630. userJSONBytes, _ := json.Marshal(dat)
  32631. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32632. utils.ErrorLog("解析失败:%v", err)
  32633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32634. return
  32635. }
  32636. if res2.Infcode == 0 {
  32637. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32638. if err == nil {
  32639. c.ServeSuccessJSON(map[string]interface{}{
  32640. "msg": "撤销明细成功",
  32641. })
  32642. return
  32643. } else {
  32644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32645. return
  32646. }
  32647. } else {
  32648. c.ServeSuccessJSON(map[string]interface{}{
  32649. "failed_code": -10,
  32650. "msg": res2.ErrMsg,
  32651. })
  32652. }
  32653. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32654. 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, "")
  32655. var dat map[string]interface{}
  32656. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32657. fmt.Println(dat)
  32658. } else {
  32659. fmt.Println(err)
  32660. }
  32661. saveLog(result2, src_request, "2205", "撤销明细")
  32662. userJSONBytes, _ := json.Marshal(dat)
  32663. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32664. utils.ErrorLog("解析失败:%v", err)
  32665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32666. return
  32667. }
  32668. if res2.Infcode == 0 {
  32669. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32670. if err == nil {
  32671. c.ServeSuccessJSON(map[string]interface{}{
  32672. "msg": "撤销明细成功",
  32673. })
  32674. return
  32675. } else {
  32676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32677. return
  32678. }
  32679. } else {
  32680. c.ServeSuccessJSON(map[string]interface{}{
  32681. "failed_code": -10,
  32682. "msg": res2.ErrMsg,
  32683. })
  32684. }
  32685. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32686. 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, "")
  32687. var dat map[string]interface{}
  32688. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32689. fmt.Println(dat)
  32690. } else {
  32691. fmt.Println(err)
  32692. }
  32693. saveLog(result2, src_request, "2205", "撤销明细")
  32694. userJSONBytes, _ := json.Marshal(dat)
  32695. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32696. utils.ErrorLog("解析失败:%v", err)
  32697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32698. return
  32699. }
  32700. if res2.Infcode == 0 {
  32701. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32702. if err == nil {
  32703. c.ServeSuccessJSON(map[string]interface{}{
  32704. "msg": "撤销明细成功",
  32705. })
  32706. return
  32707. } else {
  32708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32709. return
  32710. }
  32711. } else {
  32712. c.ServeSuccessJSON(map[string]interface{}{
  32713. "failed_code": -10,
  32714. "msg": res2.ErrMsg,
  32715. })
  32716. }
  32717. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32718. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  32719. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32720. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32721. resp2, requestErr2 := http.Get(api2)
  32722. if requestErr2 != nil {
  32723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32724. return
  32725. }
  32726. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32727. if ioErr2 != nil {
  32728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32730. return
  32731. }
  32732. var respJSON2 map[string]interface{}
  32733. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32736. return
  32737. }
  32738. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32739. userJSONBytes3, _ := json.Marshal(respJSON2)
  32740. fmt.Println("log")
  32741. fmt.Println(string(userJSONBytes3))
  32742. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32743. utils.ErrorLog("解析失败:%v", err)
  32744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32745. return
  32746. }
  32747. if res2.Infcode == 0 {
  32748. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32749. if err == nil {
  32750. c.ServeSuccessJSON(map[string]interface{}{
  32751. "msg": "撤销明细成功",
  32752. })
  32753. return
  32754. } else {
  32755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32756. return
  32757. }
  32758. } else {
  32759. c.ServeSuccessJSON(map[string]interface{}{
  32760. "failed_code": -10,
  32761. "msg": res2.ErrMsg,
  32762. })
  32763. }
  32764. } else {
  32765. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  32766. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32767. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32768. resp2, requestErr2 := http.Get(api2)
  32769. if requestErr2 != nil {
  32770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32771. return
  32772. }
  32773. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32774. if ioErr2 != nil {
  32775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32777. return
  32778. }
  32779. var respJSON2 map[string]interface{}
  32780. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32783. return
  32784. }
  32785. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32786. userJSONBytes3, _ := json.Marshal(respJSON2)
  32787. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32788. utils.ErrorLog("解析失败:%v", err)
  32789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32790. return
  32791. }
  32792. if res2.Infcode == -1 {
  32793. c.ServeSuccessJSON(map[string]interface{}{
  32794. "failed_code": -10,
  32795. "msg": res2.ErrMsg,
  32796. })
  32797. return
  32798. } else {
  32799. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32800. if err == nil {
  32801. c.ServeSuccessJSON(map[string]interface{}{
  32802. "msg": "撤销明细成功",
  32803. })
  32804. return
  32805. } else {
  32806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32807. return
  32808. }
  32809. }
  32810. }
  32811. } else {
  32812. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32813. if err == nil {
  32814. c.ServeSuccessJSON(map[string]interface{}{
  32815. "msg": "退费成功",
  32816. })
  32817. } else {
  32818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32819. return
  32820. }
  32821. }
  32822. }
  32823. // 对账
  32824. func (c *HisApiController) GetCheckAccount() {
  32825. start_time := c.GetString("start_time")
  32826. end_time := c.GetString("end_time")
  32827. insutype := c.GetString("insutype")
  32828. clr_type := c.GetString("clr_type")
  32829. clr_org := c.GetString("clr_optins")
  32830. admin_user_id, _ := c.GetInt64("admin_user_id")
  32831. adminUser := c.GetAdminUserInfo()
  32832. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32833. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32834. if len(clr_org) == 0 {
  32835. clr_org = miConfig.InsuplcAdmdvs
  32836. }
  32837. timeLayout := "2006-01-02"
  32838. loc, _ := time.LoadLocation("Local")
  32839. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  32840. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  32841. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  32842. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  32843. fixmedins_setl_cnt := int64(len(orders))
  32844. var medfee_sumamt float64
  32845. var acct_pay float64
  32846. var fund_pay_sumamt float64
  32847. for _, item := range orders {
  32848. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  32849. acct_pay = acct_pay + item.AcctPay
  32850. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  32851. }
  32852. var user_name string
  32853. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32854. if role.ID == 0 {
  32855. user_name = "xxx"
  32856. } else {
  32857. user_name = role.UserName
  32858. }
  32859. var res ResultEight
  32860. var res10188 ResultEightFor10188
  32861. if config.IsOpen == 1 {
  32862. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32863. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  32864. "insutype=" + insutype +
  32865. "&clr_type=" + clr_type +
  32866. "&setl_optins=" + clr_org +
  32867. "&stmt_begndate=" + start_time +
  32868. "&stm_enddate=" + end_time +
  32869. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32870. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32871. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32872. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  32873. "&fixmedins_code=" + miConfig.Code +
  32874. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32875. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32876. "&secret_key=" + miConfig.SecretKey +
  32877. "&org_name=" + miConfig.OrgName +
  32878. "&doctor=" + user_name +
  32879. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32880. fmt.Println(api)
  32881. resp, requestErr := http.Get(api)
  32882. if requestErr != nil {
  32883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32884. return
  32885. }
  32886. body, ioErr := ioutil.ReadAll(resp.Body)
  32887. fmt.Println(body)
  32888. if ioErr != nil {
  32889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32891. return
  32892. }
  32893. var respJSON map[string]interface{}
  32894. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32897. return
  32898. }
  32899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32900. userJSONBytes, _ := json.Marshal(respJSON)
  32901. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32902. utils.ErrorLog("解析失败:%v", err)
  32903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32904. return
  32905. }
  32906. res.InfRefmsgid = res10188.InfRefmsgid
  32907. res.Output = res10188.Output
  32908. res.ErrMsg = res10188.ErrMsg
  32909. res.Cainfo = res10188.Cainfo
  32910. res.WarnMsg = res10188.WarnMsg
  32911. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  32912. res.Infcode = infocode
  32913. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32914. if clr_type != "9903" {
  32915. clr_type = "99" // 就诊 ID(来自2201接口返回)
  32916. }
  32917. if clr_type == "9903" {
  32918. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  32919. }
  32920. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  32921. "insutype=" + insutype +
  32922. "&clr_type=" + clr_type +
  32923. "&setl_optins=" + clr_org +
  32924. "&stmt_begndate=" + start_time +
  32925. "&stm_enddate=" + end_time +
  32926. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  32927. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  32928. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  32929. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  32930. "&fixmedins_code=" + miConfig.Code +
  32931. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  32932. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32933. "&secret_key=" + miConfig.SecretKey +
  32934. "&org_name=" + miConfig.OrgName +
  32935. "&doctor=" + user_name
  32936. resp, requestErr := http.Get(api)
  32937. if requestErr != nil {
  32938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32939. return
  32940. }
  32941. body, ioErr := ioutil.ReadAll(resp.Body)
  32942. if ioErr != nil {
  32943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32945. return
  32946. }
  32947. var respJSON map[string]interface{}
  32948. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32951. return
  32952. }
  32953. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32954. result, _ := json.Marshal(respJSON)
  32955. fmt.Println("log")
  32956. fmt.Println(string(result))
  32957. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  32958. utils.ErrorLog("解析失败:%v", err)
  32959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32960. return
  32961. }
  32962. res.InfRefmsgid = res10188.InfRefmsgid
  32963. res.Output = res10188.Output
  32964. res.ErrMsg = res10188.ErrMsg
  32965. res.Cainfo = res10188.Cainfo
  32966. res.WarnMsg = res10188.WarnMsg
  32967. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  32968. res.Infcode = infocode
  32969. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32970. var baseParams models.BaseParams
  32971. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  32972. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  32973. baseParams.SecretKey = miConfig.SecretKey
  32974. baseParams.OrgName = miConfig.OrgName
  32975. baseParams.FixmedinsCode = miConfig.Code
  32976. baseParams.EncKey = miConfig.EncKey
  32977. baseParams.AppSecret = miConfig.AppSecret
  32978. baseParams.SignKey = miConfig.SignKey
  32979. baseParams.AppID = miConfig.Code
  32980. baseParams.Doctor = role.UserName
  32981. baseParams.RequestUrl = miConfig.Url
  32982. businessParams := models.BusinessParams{
  32983. Insutype: insutype,
  32984. ClrType: clr_type,
  32985. SetlOptins: clr_org,
  32986. StmtBegndate: start_time,
  32987. StmtEnddate: end_time,
  32988. MedfeeSumamt: medfee_sumamt,
  32989. FundPaySumamt: fund_pay_sumamt,
  32990. AcctPay: acct_pay,
  32991. FixmedinsSetlCnt: fixmedins_setl_cnt,
  32992. }
  32993. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  32994. fmt.Println(requestLog)
  32995. fmt.Println(result)
  32996. fmt.Println(err_msg)
  32997. var dat map[string]interface{}
  32998. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32999. fmt.Println(dat)
  33000. } else {
  33001. fmt.Println(err)
  33002. }
  33003. userJSONBytes, _ := json.Marshal(dat)
  33004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33005. utils.ErrorLog("解析失败:%v", err)
  33006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33007. return
  33008. }
  33009. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33010. var baseParams models.BaseParams
  33011. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33012. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33013. baseParams.SecretKey = miConfig.SecretKey
  33014. baseParams.OrgName = miConfig.OrgName
  33015. baseParams.FixmedinsCode = miConfig.Code
  33016. baseParams.EncKey = miConfig.EncKey
  33017. baseParams.AppSecret = miConfig.AppSecret
  33018. baseParams.SignKey = miConfig.SignKey
  33019. baseParams.AppID = miConfig.Code
  33020. baseParams.Doctor = role.UserName
  33021. baseParams.RequestUrl = miConfig.Url
  33022. baseParams.AccessKey = miConfig.AccessKey
  33023. businessParams := models.BusinessParams{
  33024. Insutype: insutype,
  33025. ClrType: clr_type,
  33026. SetlOptins: "430822",
  33027. StmtBegndate: start_time,
  33028. StmtEnddate: end_time,
  33029. MedfeeSumamt: medfee_sumamt,
  33030. FundPaySumamt: fund_pay_sumamt,
  33031. AcctPay: acct_pay,
  33032. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33033. }
  33034. 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)
  33035. fmt.Println(requestLog)
  33036. fmt.Println(result)
  33037. var dat map[string]interface{}
  33038. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33039. fmt.Println(dat)
  33040. } else {
  33041. fmt.Println(err)
  33042. }
  33043. userJSONBytes, _ := json.Marshal(dat)
  33044. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33045. utils.ErrorLog("解析失败:%v", err)
  33046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33047. return
  33048. }
  33049. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33050. var baseParams models.BaseParams
  33051. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33052. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33053. baseParams.SecretKey = miConfig.SecretKey
  33054. baseParams.OrgName = miConfig.OrgName
  33055. baseParams.FixmedinsCode = miConfig.Code
  33056. baseParams.EncKey = miConfig.EncKey
  33057. baseParams.AppSecret = miConfig.AppSecret
  33058. baseParams.SignKey = miConfig.SignKey
  33059. baseParams.AppID = miConfig.Code
  33060. baseParams.Doctor = role.UserName
  33061. baseParams.RequestUrl = miConfig.Url
  33062. businessParams := models.BusinessParams{
  33063. Insutype: insutype,
  33064. ClrType: clr_type,
  33065. SetlOptins: clr_org,
  33066. StmtBegndate: start_time,
  33067. StmtEnddate: end_time,
  33068. MedfeeSumamt: medfee_sumamt,
  33069. FundPaySumamt: fund_pay_sumamt,
  33070. AcctPay: acct_pay,
  33071. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33072. }
  33073. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33074. fmt.Println(requestLog)
  33075. fmt.Println(result)
  33076. fmt.Println(err_msg)
  33077. var dat map[string]interface{}
  33078. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33079. fmt.Println(dat)
  33080. } else {
  33081. fmt.Println(err)
  33082. }
  33083. userJSONBytes, _ := json.Marshal(dat)
  33084. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33085. utils.ErrorLog("解析失败:%v", err)
  33086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33087. return
  33088. }
  33089. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33090. if len(clr_type) == 0 {
  33091. clr_type = "11"
  33092. }
  33093. api := miConfig.Url + "gdyb/ten?" +
  33094. "insutype=" + insutype +
  33095. "&clr_type=" + clr_type +
  33096. "&setl_optins=" + clr_org +
  33097. "&stmt_begndate=" + start_time +
  33098. "&stm_enddate=" + end_time +
  33099. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33100. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33101. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33102. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33103. "&fixmedins_code=" + miConfig.Code +
  33104. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33105. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33106. "&secret_key=" + miConfig.SecretKey +
  33107. "&org_name=" + miConfig.OrgName +
  33108. "&doctor=" + user_name
  33109. fmt.Println(api)
  33110. resp, requestErr := http.Get(api)
  33111. if requestErr != nil {
  33112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33113. return
  33114. }
  33115. body, ioErr := ioutil.ReadAll(resp.Body)
  33116. fmt.Println(body)
  33117. if ioErr != nil {
  33118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33120. return
  33121. }
  33122. var respJSON map[string]interface{}
  33123. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33126. return
  33127. }
  33128. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33129. userJSONBytes, _ := json.Marshal(respJSON)
  33130. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33131. utils.ErrorLog("解析失败:%v", err)
  33132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33133. return
  33134. }
  33135. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33136. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33137. //fixmedins_setl_cnt := int64(len(orders_two))
  33138. //var medfee_sumamt float64
  33139. //var acct_pay float64
  33140. //var fund_pay_sumamt float64
  33141. //for _, item := range orders_two {
  33142. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33143. // acct_pay = acct_pay + item.AcctPay
  33144. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33145. //}
  33146. var baseParams models.BaseParams
  33147. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33148. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33149. baseParams.SecretKey = miConfig.SecretKey
  33150. baseParams.OrgName = miConfig.OrgName
  33151. baseParams.FixmedinsCode = miConfig.Code
  33152. baseParams.EncKey = miConfig.EncKey
  33153. baseParams.AppSecret = miConfig.AppSecret
  33154. baseParams.SignKey = miConfig.SignKey
  33155. baseParams.AppID = miConfig.Code
  33156. baseParams.Doctor = role.UserName
  33157. baseParams.RequestUrl = miConfig.Url
  33158. if clr_type == "9903" {
  33159. clr_type = "9994"
  33160. }
  33161. businessParams := models.BusinessParams{
  33162. Insutype: insutype,
  33163. ClrType: clr_type,
  33164. SetlOptins: "360302",
  33165. StmtBegndate: start_time,
  33166. StmtEnddate: end_time,
  33167. MedfeeSumamt: 0,
  33168. FundPaySumamt: 0,
  33169. AcctPay: 0,
  33170. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33171. }
  33172. 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))
  33173. fmt.Println(requestLog)
  33174. fmt.Println(result)
  33175. var dat map[string]interface{}
  33176. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33177. fmt.Println(dat)
  33178. } else {
  33179. fmt.Println(err)
  33180. }
  33181. userJSONBytes, _ := json.Marshal(dat)
  33182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33183. utils.ErrorLog("解析失败:%v", err)
  33184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33185. return
  33186. }
  33187. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33188. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33189. fixmedins_setl_cnt := int64(len(orders_two))
  33190. var medfee_sumamt float64
  33191. var acct_pay float64
  33192. var fund_pay_sumamt float64
  33193. for _, item := range orders_two {
  33194. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33195. acct_pay = acct_pay + item.AcctPay
  33196. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33197. }
  33198. var baseParams models.BaseParams
  33199. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33200. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33201. baseParams.SecretKey = miConfig.SecretKey
  33202. baseParams.OrgName = miConfig.OrgName
  33203. baseParams.FixmedinsCode = miConfig.Code
  33204. baseParams.EncKey = miConfig.EncKey
  33205. baseParams.AppSecret = miConfig.AppSecret
  33206. baseParams.SignKey = miConfig.SignKey
  33207. baseParams.AppID = miConfig.Code
  33208. baseParams.Doctor = role.UserName
  33209. baseParams.RequestUrl = miConfig.Url
  33210. if clr_type == "9903" {
  33211. clr_type = "9994"
  33212. }
  33213. businessParams := models.BusinessParams{
  33214. Insutype: insutype,
  33215. ClrType: clr_type,
  33216. SetlOptins: "361025",
  33217. StmtBegndate: start_time,
  33218. StmtEnddate: end_time,
  33219. MedfeeSumamt: 0,
  33220. FundPaySumamt: 0,
  33221. AcctPay: 0,
  33222. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33223. }
  33224. 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))
  33225. fmt.Println(requestLog)
  33226. fmt.Println(result)
  33227. var dat map[string]interface{}
  33228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33229. fmt.Println(dat)
  33230. } else {
  33231. fmt.Println(err)
  33232. }
  33233. userJSONBytes, _ := json.Marshal(dat)
  33234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33235. utils.ErrorLog("解析失败:%v", err)
  33236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33237. return
  33238. }
  33239. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33240. var api string
  33241. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33242. "&clr_type=" + clr_type +
  33243. "&setl_optins=" + clr_org +
  33244. "&stmt_begndate=" + start_time +
  33245. "&stm_enddate=" + end_time +
  33246. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33247. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33248. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33249. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33250. "&fixmedins_code=" + miConfig.Code +
  33251. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33252. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33253. "&secret_key=" + miConfig.SecretKey +
  33254. "&org_name=" + miConfig.OrgName +
  33255. "&doctor=" + user_name + "&url=" + miConfig.Url
  33256. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33257. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33258. resp, requestErr := http.Get(api)
  33259. if requestErr != nil {
  33260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33261. return
  33262. }
  33263. body, ioErr := ioutil.ReadAll(resp.Body)
  33264. if ioErr != nil {
  33265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33267. return
  33268. }
  33269. var respJSON map[string]interface{}
  33270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33273. return
  33274. }
  33275. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33276. if status == "0" {
  33277. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33278. c.ServeSuccessJSON(map[string]interface{}{
  33279. "failed_code": -10,
  33280. "msg": err_msg,
  33281. })
  33282. return
  33283. }
  33284. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33285. userJSONBytes, _ := json.Marshal(respJSON)
  33286. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33287. utils.ErrorLog("解析失败:%v", err)
  33288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33289. return
  33290. }
  33291. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33292. var api string
  33293. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33294. "&clr_type=" + clr_type +
  33295. "&setl_optins=" + clr_org +
  33296. "&stmt_begndate=" + start_time +
  33297. "&stm_enddate=" + end_time +
  33298. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33299. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33300. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33301. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33302. "&fixmedins_code=" + miConfig.Code +
  33303. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33304. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33305. "&secret_key=" + miConfig.SecretKey +
  33306. "&org_name=" + miConfig.OrgName +
  33307. "&doctor=" + user_name + "&url=" + miConfig.Url
  33308. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33309. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33310. resp, requestErr := http.Get(api)
  33311. if requestErr != nil {
  33312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33313. return
  33314. }
  33315. body, ioErr := ioutil.ReadAll(resp.Body)
  33316. if ioErr != nil {
  33317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33319. return
  33320. }
  33321. var respJSON map[string]interface{}
  33322. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33325. return
  33326. }
  33327. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33328. if status == "0" {
  33329. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33330. c.ServeSuccessJSON(map[string]interface{}{
  33331. "failed_code": -10,
  33332. "msg": err_msg,
  33333. })
  33334. return
  33335. }
  33336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33337. userJSONBytes, _ := json.Marshal(respJSON)
  33338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33339. utils.ErrorLog("解析失败:%v", err)
  33340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33341. return
  33342. }
  33343. } else {
  33344. if len(clr_type) == 0 {
  33345. clr_type = "11"
  33346. }
  33347. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33348. "insutype=" + insutype +
  33349. "&clr_type=" + clr_type +
  33350. "&setl_optins=" + clr_org +
  33351. "&stmt_begndate=" + start_time +
  33352. "&stm_enddate=" + end_time +
  33353. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33354. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33355. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33356. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33357. "&fixmedins_code=" + miConfig.Code +
  33358. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33359. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33360. "&secret_key=" + miConfig.SecretKey +
  33361. "&org_name=" + miConfig.OrgName +
  33362. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33363. fmt.Println(api)
  33364. resp, requestErr := http.Get(api)
  33365. if requestErr != nil {
  33366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33367. return
  33368. }
  33369. body, ioErr := ioutil.ReadAll(resp.Body)
  33370. fmt.Println(body)
  33371. if ioErr != nil {
  33372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33374. return
  33375. }
  33376. var respJSON map[string]interface{}
  33377. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33380. return
  33381. }
  33382. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33383. userJSONBytes, _ := json.Marshal(respJSON)
  33384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33385. utils.ErrorLog("解析失败:%v", err)
  33386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33387. return
  33388. }
  33389. }
  33390. if res.Infcode == 0 {
  33391. if res.Output.Stmtinfo.StmtRslt == "0" {
  33392. micc := &models.MedicalInsuranceCostCompare{
  33393. StartTime: startime.Unix(),
  33394. EndTime: endtime.Unix(),
  33395. Insutype: insutype,
  33396. CheckType: 1,
  33397. Num: fixmedins_setl_cnt,
  33398. Mtime: time.Now().Unix(),
  33399. Status: 1,
  33400. UserOrgId: adminUser.CurrentOrgId,
  33401. CostTotal: medfee_sumamt,
  33402. FuncTotal: fund_pay_sumamt,
  33403. PsnPay: acct_pay,
  33404. Creator: admin_user_id,
  33405. Ctime: time.Now().Unix(),
  33406. ClrType: clr_type,
  33407. }
  33408. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33409. if err == nil {
  33410. c.ServeSuccessJSON(map[string]interface{}{
  33411. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33412. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33413. })
  33414. } else {
  33415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33416. }
  33417. } else {
  33418. c.ServeSuccessJSON(map[string]interface{}{
  33419. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33420. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33421. })
  33422. }
  33423. } else {
  33424. c.ServeSuccessJSON(map[string]interface{}{
  33425. "failed_code": -10,
  33426. "msg": res.ErrMsg,
  33427. })
  33428. }
  33429. }
  33430. }
  33431. func (c *HisApiController) Check310() {
  33432. adminUser := c.GetAdminUserInfo()
  33433. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33434. var user_name string
  33435. user_name = "高慧裕"
  33436. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33437. "insutype=" + "310" +
  33438. "&clr_type=" + "" +
  33439. "&setl_optins=" + "441202" +
  33440. "&stmt_begndate=" + "2022-03-01" +
  33441. "&stm_enddate=" + "2022-03-31" +
  33442. "&medfee_sumamt=" + "194930.12" +
  33443. "&fund_pay_sumamt=" + "188741.46" +
  33444. "&acct_pay=" + "0" +
  33445. "&fixmedins_setl_cnt=" + "452" +
  33446. "&fixmedins_code=" + miConfig.Code +
  33447. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33448. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33449. "&secret_key=" + miConfig.SecretKey +
  33450. "&org_name=" + miConfig.OrgName +
  33451. "&doctor=" + user_name
  33452. fmt.Println(api)
  33453. resp, requestErr := http.Get(api)
  33454. if requestErr != nil {
  33455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33456. return
  33457. }
  33458. body, ioErr := ioutil.ReadAll(resp.Body)
  33459. fmt.Println(body)
  33460. if ioErr != nil {
  33461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33463. return
  33464. }
  33465. var respJSON map[string]interface{}
  33466. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33469. return
  33470. }
  33471. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33472. userJSONBytes, _ := json.Marshal(respJSON)
  33473. var res ResultEight
  33474. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33475. utils.ErrorLog("解析失败:%v", err)
  33476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33477. return
  33478. }
  33479. }
  33480. func (c *HisApiController) Check390() {
  33481. adminUser := c.GetAdminUserInfo()
  33482. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33483. var user_name string
  33484. user_name = "高慧裕"
  33485. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33486. "insutype=" + "390" +
  33487. "&clr_type=" + "" +
  33488. "&setl_optins=" + "441202" +
  33489. "&stmt_begndate=" + "2022-03-01" +
  33490. "&stm_enddate=" + "2022-03-31" +
  33491. "&medfee_sumamt=" + "1068448.89" +
  33492. "&fund_pay_sumamt=" + "1014677.62" +
  33493. "&acct_pay=" + "0" +
  33494. "&fixmedins_setl_cnt=" + "1950" +
  33495. "&fixmedins_code=" + miConfig.Code +
  33496. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33497. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33498. "&secret_key=" + miConfig.SecretKey +
  33499. "&org_name=" + miConfig.OrgName +
  33500. "&doctor=" + user_name
  33501. fmt.Println(api)
  33502. resp, requestErr := http.Get(api)
  33503. if requestErr != nil {
  33504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33505. return
  33506. }
  33507. body, ioErr := ioutil.ReadAll(resp.Body)
  33508. fmt.Println(body)
  33509. if ioErr != nil {
  33510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33512. return
  33513. }
  33514. var respJSON map[string]interface{}
  33515. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33518. return
  33519. }
  33520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33521. userJSONBytes, _ := json.Marshal(respJSON)
  33522. var res ResultEight
  33523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33524. utils.ErrorLog("解析失败:%v", err)
  33525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33526. return
  33527. }
  33528. }
  33529. // 对账明细
  33530. func (c *HisApiController) GetCheckDetailAccount() {
  33531. start_time := c.GetString("start_time")
  33532. end_time := c.GetString("end_time")
  33533. admin_user_id, _ := c.GetInt64("admin_user_id")
  33534. adminUser := c.GetAdminUserInfo()
  33535. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33536. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33537. timeLayout := "2006-01-02"
  33538. loc, _ := time.LoadLocation("Local")
  33539. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33540. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33541. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  33542. rand.Seed(time.Now().UnixNano())
  33543. num := rand.Intn(30000)
  33544. Mkdir(miConfig.OrgName)
  33545. file := strconv.FormatInt(int64(num), 10)
  33546. file_name := file + ".txt"
  33547. zip_name := file + ".zip"
  33548. zip_path := miConfig.OrgName + "/" + zip_name
  33549. file_path := miConfig.OrgName + "/" + file_name
  33550. decimal.DivisionPrecision = 2
  33551. var medfee_sumamt float64
  33552. var psn_cash_pay float64
  33553. var fund_pay_sumamt float64
  33554. fixmedins_setl_cnt := int64(len(orders))
  33555. for _, item := range orders {
  33556. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33557. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  33558. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33559. }
  33560. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  33561. defer f.Close()
  33562. if err != nil {
  33563. fmt.Println(err.Error())
  33564. } else {
  33565. for _, item := range orders {
  33566. var refd_setl_flag string
  33567. if item.OrderStatus == 2 {
  33568. refd_setl_flag = "0"
  33569. var str string
  33570. str = item.SetlId + " " +
  33571. item.MdtrtId + " " +
  33572. item.PsnNo + " " +
  33573. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33574. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33575. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  33576. _, err = f.Write([]byte(str))
  33577. }
  33578. if item.OrderStatus == 3 {
  33579. var str string
  33580. str = item.SetlId + " " +
  33581. item.MdtrtId + " " +
  33582. item.PsnNo + " " +
  33583. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  33584. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  33585. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  33586. _, err = f.Write([]byte(str))
  33587. var str2 string
  33588. str2 = item.SetlId + " " +
  33589. item.MdtrtId + " " +
  33590. item.PsnNo + " " +
  33591. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  33592. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  33593. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  33594. _, err = f.Write([]byte(str2))
  33595. }
  33596. }
  33597. }
  33598. Zip(file_path, zip_path)
  33599. fmt.Println(ReadFile(zip_path))
  33600. fmt.Println(string(ReadFile(zip_path)))
  33601. if config.IsOpen == 1 {
  33602. var user_name string
  33603. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33604. if role.ID == 0 {
  33605. user_name = "管理员"
  33606. } else {
  33607. user_name = role.UserName
  33608. }
  33609. baseParams := models.BaseParams{
  33610. SecretKey: miConfig.SecretKey,
  33611. FixmedinsCode: miConfig.Code,
  33612. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33613. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33614. OrgName: miConfig.OrgName,
  33615. Doctor: user_name,
  33616. }
  33617. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  33618. var dat map[string]interface{}
  33619. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33620. fmt.Println(dat)
  33621. } else {
  33622. fmt.Println(err)
  33623. }
  33624. userJSONBytes, _ := json.Marshal(dat)
  33625. var res ResultNine
  33626. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33627. utils.ErrorLog("解析失败:%v", err)
  33628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33629. return
  33630. }
  33631. if res.Infcode == 0 {
  33632. fileNo := res.Output.FileQuryNo
  33633. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  33634. "file_qury_no=" + fileNo +
  33635. "&setl_optins=" + "定点医保中心" +
  33636. "&stmt_begndate=" + start_time +
  33637. "&stm_enddate=" + end_time +
  33638. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33639. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33640. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  33641. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33642. "&fixmedins_code=" + miConfig.Code +
  33643. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33644. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33645. "&secret_key=" + miConfig.SecretKey +
  33646. "&org_name=" + miConfig.OrgName +
  33647. "&doctor=" + user_name
  33648. resp, requestErr := http.Get(api)
  33649. if requestErr != nil {
  33650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33651. return
  33652. }
  33653. body, ioErr := ioutil.ReadAll(resp.Body)
  33654. if ioErr != nil {
  33655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33657. return
  33658. }
  33659. var respJSON map[string]interface{}
  33660. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33663. return
  33664. }
  33665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33666. userJSONBytes, _ := json.Marshal(respJSON)
  33667. var res ResultTen
  33668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33669. utils.ErrorLog("解析失败:%v", err)
  33670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33671. return
  33672. }
  33673. if res.Infcode == 0 {
  33674. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  33675. micc := &models.MedicalInsuranceCostCompare{
  33676. StartTime: startime.Unix(),
  33677. EndTime: endtime.Unix(),
  33678. Insutype: "0",
  33679. CheckType: 2,
  33680. Num: fixmedins_setl_cnt,
  33681. Mtime: time.Now().Unix(),
  33682. Status: 1,
  33683. UserOrgId: adminUser.CurrentOrgId,
  33684. CostTotal: medfee_sumamt,
  33685. FuncTotal: fund_pay_sumamt,
  33686. PsnPay: psn_cash_pay,
  33687. Creator: admin_user_id,
  33688. Ctime: time.Now().Unix(),
  33689. }
  33690. service.CreateMedicalInsuranceCostCompareRecord(micc)
  33691. c.ServeSuccessJSON(map[string]interface{}{
  33692. "msg": "明细对账成功",
  33693. })
  33694. }
  33695. } else {
  33696. }
  33697. }
  33698. }
  33699. type CustomOrderInfo struct {
  33700. Name string
  33701. Spec string
  33702. Unit string
  33703. Count float64
  33704. Price float64
  33705. Total float64
  33706. }
  33707. func (c *HisApiController) GetBatchSettleAccounts() {
  33708. admin_user_id, _ := c.GetInt64("admin_user_id")
  33709. order_ids := c.GetString("order_ids")
  33710. order_ids_arr := strings.Split(order_ids, ",")
  33711. data3 := []map[string]interface{}{}
  33712. for _, item := range order_ids_arr {
  33713. id, _ := strconv.ParseInt(item, 10, 64)
  33714. order_id := id
  33715. adminUser := c.GetAdminUserInfo()
  33716. order, _ := service.GetHisOrderByID(order_id)
  33717. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33718. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  33719. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  33720. orderInfos = append(orderInfos, orderInfos_two...)
  33721. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  33722. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  33723. var diagnosis_ids []string
  33724. if his.ID > 0 {
  33725. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  33726. } else {
  33727. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  33728. }
  33729. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  33730. var dia_config []*models.HisXtDiagnoseConfig
  33731. var name string
  33732. for _, item := range diagnosis_ids {
  33733. id, _ := strconv.ParseInt(item, 10, 64)
  33734. diagnosisConfig, _ := service.FindDiagnoseById(id)
  33735. dia_config = append(dia_config, &diagnosisConfig)
  33736. if len(name) == 0 {
  33737. name = diagnosisConfig.ClassName
  33738. }
  33739. //} else {
  33740. // name = name + "," + diagnosisConfig.ClassName
  33741. //}
  33742. }
  33743. var bedCostTotal float64 = 0 //床位总费
  33744. var bedCostSelfTotal float64 = 0 //床位自费
  33745. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  33746. var bedSelfTotal float64 = 0 //床位部分项目自费
  33747. var bedInscpTotal float64 = 0 //床位部分项目自费
  33748. var operationCostTotal float64 = 0 //手术费
  33749. var operationCostSelfTotal float64 = 0 //手术费
  33750. var operationCostPartSelfTotal float64 = 0 //手术费
  33751. var operationSelfTotal float64 = 0 //床位部分项目自费
  33752. var operationInscpTotal float64 = 0 //床位部分项目自费
  33753. var otherCostTotal float64 = 0 //其他费用
  33754. var otherCostSelfTotal float64 = 0 //其他费用
  33755. var otherCostPartSelfTotal float64 = 0 //其他费用
  33756. var otherSelfTotal float64 = 0 //床位部分项目自费
  33757. var otherInscpTotal float64 = 0 //床位部分项目自费
  33758. var materialCostTotal float64 = 0 //材料费
  33759. var materialCostSelfTotal float64 = 0 //材料费
  33760. var materialCostPartSelfTotal float64 = 0 //材料费
  33761. var materialSelfTotal float64 = 0 //床位部分项目自费
  33762. var materialInscpTotal float64 = 0 //床位部分项目自费
  33763. var westernMedicineCostTotal float64 = 0 //西药费
  33764. var westernMedicineCostSelfTotal float64 = 0 //西药费
  33765. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  33766. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  33767. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  33768. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  33769. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  33770. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  33771. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  33772. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  33773. var checkCostTotal float64 = 0 //检查费
  33774. var checkCostSelfTotal float64 = 0 //检查费
  33775. var checkCostPartSelfTotal float64 = 0 //检查费
  33776. var checkSelfTotal float64 = 0 //床位部分项目自费
  33777. var checkInscpTotal float64 = 0 //床位部分项目自费
  33778. var laboratoryCostTotal float64 = 0 //化验费
  33779. var laboratoryCostSelfTotal float64 = 0 //化验费
  33780. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  33781. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  33782. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  33783. var treatCostTotal float64 = 0 //治疗费用
  33784. var treatCostSelfTotal float64 = 0 //治疗费用
  33785. var treatCostPartSelfTotal float64 = 0 //治疗费用
  33786. var treatSelfTotal float64 = 0 //床位部分项目自费
  33787. var treatInscpTotal float64 = 0 //床位部分项目自费
  33788. decimal.DivisionPrecision = 2
  33789. for _, item := range orderInfos {
  33790. if item.MedChrgitmType == "01" { //床位费
  33791. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33792. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33793. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33794. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33795. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33796. }
  33797. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  33798. if item.MedChrgitmType == "03" { //检查费
  33799. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33800. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33801. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33802. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33803. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33804. }
  33805. } else {
  33806. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  33807. fmt.Println("------------")
  33808. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33809. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33810. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33811. }
  33812. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  33813. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33814. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33815. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33816. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33817. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33818. }
  33819. }
  33820. if item.MedChrgitmType == "04" { //化验费
  33821. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33822. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33823. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33824. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33825. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33826. }
  33827. if item.MedChrgitmType == "05" { //治疗费
  33828. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33829. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33830. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33831. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33832. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33833. }
  33834. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  33835. fmt.Println("------------")
  33836. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33837. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33838. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33839. }
  33840. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  33841. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33842. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33843. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33844. }
  33845. //if item.MedChrgitmType == "06" { //手术费
  33846. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33847. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33848. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33849. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33850. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33851. //
  33852. //}
  33853. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  33854. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33855. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33856. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33857. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33858. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33859. }
  33860. if item.MedChrgitmType == "09" { //西药费
  33861. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33862. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33863. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33864. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33865. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33866. }
  33867. if item.MedChrgitmType == "11" { //中成费
  33868. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33869. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33870. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33871. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33872. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33873. }
  33874. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  33875. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  33876. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  33877. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  33878. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  33879. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  33880. }
  33881. }
  33882. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33883. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33884. var user_name string
  33885. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33886. if role.ID == 0 {
  33887. user_name = "管理员"
  33888. } else {
  33889. user_name = role.UserName
  33890. }
  33891. baseParams := models.BaseParams{
  33892. SecretKey: miConfig.SecretKey,
  33893. FixmedinsCode: miConfig.Code,
  33894. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  33895. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  33896. OrgName: miConfig.OrgName,
  33897. Doctor: user_name,
  33898. RequestUrl: miConfig.Url,
  33899. AccessKey: miConfig.AccessKey,
  33900. }
  33901. businessParams := models.BusinessParams{
  33902. PsnNo: order.PsnNo,
  33903. MdtrtId: order.MdtrtId,
  33904. SetlId: order.SetlId,
  33905. }
  33906. var res ResultEleven
  33907. var resEleven10265 ResultEleven10265
  33908. if config.IsOpen == 1 {
  33909. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  33910. result := service.Gdyb5203(baseParams, businessParams)
  33911. service.Gdyb5204(baseParams, businessParams)
  33912. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  33913. var dat map[string]interface{}
  33914. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33915. fmt.Println(dat)
  33916. } else {
  33917. fmt.Println(err)
  33918. }
  33919. userJSONBytes, _ := json.Marshal(dat)
  33920. if miConfig.Code == "H15049901371" {
  33921. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  33922. utils.ErrorLog("解析失败:%v", err)
  33923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33924. return
  33925. }
  33926. res.InfRefmsgid = resEleven10265.InfRefmsgid
  33927. res.Output = resEleven10265.Output
  33928. res.ErrMsg = resEleven10265.ErrMsg
  33929. res.Cainfo = resEleven10265.Cainfo
  33930. res.WarnMsg = resEleven10265.WarnMsg
  33931. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  33932. res.Infcode = infocode
  33933. } else {
  33934. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33935. utils.ErrorLog("解析失败:%v", err)
  33936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33937. return
  33938. }
  33939. }
  33940. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33941. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  33942. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  33943. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  33944. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  33945. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33946. var doctor_name string
  33947. if roles.ID == 0 {
  33948. doctor_name = "管理员"
  33949. } else {
  33950. doctor_name = roles.UserName
  33951. }
  33952. yiliao_leibie := ""
  33953. switch order.MedType {
  33954. case "11":
  33955. yiliao_leibie = "普通门诊"
  33956. break
  33957. case "12":
  33958. yiliao_leibie = "门诊挂号"
  33959. break
  33960. case "13":
  33961. yiliao_leibie = "急诊"
  33962. break
  33963. case "14":
  33964. yiliao_leibie = "门诊特殊病"
  33965. break
  33966. case "15":
  33967. yiliao_leibie = "门诊统筹"
  33968. break
  33969. case "16":
  33970. yiliao_leibie = "门诊慢性病"
  33971. break
  33972. case "21":
  33973. yiliao_leibie = "普通住院"
  33974. break
  33975. }
  33976. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  33977. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  33978. if res.Infcode == 0 {
  33979. data2 := map[string]interface{}{
  33980. "diagnosis": name,
  33981. "order_infos": orderInfos,
  33982. "number": order.MdtrtId,
  33983. "date": order.SettleAccountsDate,
  33984. "charge_admin": charge_admin,
  33985. "printor_admin": printor_admin,
  33986. "info": res.Output.Setlinfo,
  33987. "order": order,
  33988. "bedCostTotal": bedCostTotal,
  33989. "bedCostSelfTotal": bedCostSelfTotal,
  33990. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  33991. "bedSelfTotal": bedSelfTotal,
  33992. "bedInscpTotal": bedInscpTotal,
  33993. "operationCostTotal": operationCostTotal,
  33994. "operationCostSelfTotal": operationCostSelfTotal,
  33995. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  33996. "operationSelfTotal": operationSelfTotal,
  33997. "operationInscpTotal": operationInscpTotal,
  33998. "otherCostTotal": otherCostTotal,
  33999. "otherCostSelfTotal": otherCostSelfTotal,
  34000. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34001. "otherSelfTotal": otherSelfTotal,
  34002. "otherInscpTotal": otherInscpTotal,
  34003. "materialCostTotal": materialCostTotal,
  34004. "materialCostSelfTotal": materialCostSelfTotal,
  34005. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34006. "materialSelfTotal": materialSelfTotal,
  34007. "materialInscpTotal": materialInscpTotal,
  34008. "westernMedicineCostTotal": westernMedicineCostTotal,
  34009. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34010. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34011. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34012. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34013. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34014. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34015. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34016. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34017. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34018. "checkCostTotal": checkCostTotal,
  34019. "checkCostSelfTotal": checkCostSelfTotal,
  34020. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34021. "checkSelfTotal": checkSelfTotal,
  34022. "checkInscpTotal": checkInscpTotal,
  34023. "laboratoryCostTotal": laboratoryCostTotal,
  34024. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34025. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34026. "laboratorySelfTotal": laboratorySelfTotal,
  34027. "laboratoryInscpTotal": laboratoryInscpTotal,
  34028. "treatCostTotal": treatCostTotal,
  34029. "treatCostSelfTotal": treatCostSelfTotal,
  34030. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34031. "treatSelfTotal": treatSelfTotal,
  34032. "treatInscpTotal": treatInscpTotal,
  34033. "doctor_info": doctor_info,
  34034. "doctor_code": adminRole_two.DoctorCode,
  34035. "doctor_name": doctor_name,
  34036. "health_card_no": order.PsnNo,
  34037. "department": departments.Name,
  34038. "yiliao_leibie": yiliao_leibie,
  34039. "after_money": order.AccountPrice,
  34040. "patient": patient,
  34041. "org_name": miConfig.OrgName,
  34042. "org_code": miConfig.Code,
  34043. "order_number": order.Number,
  34044. "his_hospital": his_hospital,
  34045. "his": his,
  34046. "dia_config": dia_config,
  34047. "psn_cash_pay": order.PsnCashPay,
  34048. //"check_order_info": cus_slice,
  34049. }
  34050. data3 = append(data3, data2)
  34051. }
  34052. }
  34053. }
  34054. c.ServeSuccessJSON(map[string]interface{}{
  34055. "infos": data3,
  34056. })
  34057. }
  34058. func (c *HisApiController) GetSettleAccounts() {
  34059. //id, _ := c.GetInt64("id")
  34060. //record_time := c.GetString("record_time")
  34061. order_id, _ := c.GetInt64("order_id")
  34062. admin_user_id, _ := c.GetInt64("admin_user_id")
  34063. //timeLayout := "2006-01-02"
  34064. //loc, _ := time.LoadLocation("Local")
  34065. //
  34066. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34067. //if err != nil {
  34068. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34069. // return
  34070. //}Hbyb5203
  34071. //recordDateTime := theTime.Unix()
  34072. adminUser := c.GetAdminUserInfo()
  34073. order, _ := service.GetHisOrderByID(order_id)
  34074. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34075. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34076. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34077. orderInfos = append(orderInfos, orderInfos_two...)
  34078. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34079. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34080. var diagnosis_ids []string
  34081. if his.ID > 0 {
  34082. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34083. } else {
  34084. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34085. }
  34086. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34087. var dia_config []*models.HisXtDiagnoseConfig
  34088. var name string
  34089. for _, item := range diagnosis_ids {
  34090. id, _ := strconv.ParseInt(item, 10, 64)
  34091. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34092. dia_config = append(dia_config, &diagnosisConfig)
  34093. if len(name) == 0 {
  34094. name = diagnosisConfig.ClassName
  34095. } else {
  34096. name = name + "," + diagnosisConfig.ClassName
  34097. }
  34098. }
  34099. if patient.UserOrgId == 10215 {
  34100. name = "慢性肾功能不全(血透治疗)"
  34101. }
  34102. var bedCostTotal float64 = 0 //床位总费
  34103. var bedCostSelfTotal float64 = 0 //床位自费
  34104. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34105. var bedSelfTotal float64 = 0 //床位部分项目自费
  34106. var bedInscpTotal float64 = 0 //床位部分项目自费
  34107. var operationCostTotal float64 = 0 //手术费
  34108. var operationCostSelfTotal float64 = 0 //手术费
  34109. var operationCostPartSelfTotal float64 = 0 //手术费
  34110. var operationSelfTotal float64 = 0 //床位部分项目自费
  34111. var operationInscpTotal float64 = 0 //床位部分项目自费
  34112. var otherCostTotal float64 = 0 //其他费用
  34113. var otherCostSelfTotal float64 = 0 //其他费用
  34114. var otherCostPartSelfTotal float64 = 0 //其他费用
  34115. var otherSelfTotal float64 = 0 //床位部分项目自费
  34116. var otherInscpTotal float64 = 0 //床位部分项目自费
  34117. var materialCostTotal float64 = 0 //材料费
  34118. var materialCostSelfTotal float64 = 0 //材料费
  34119. var materialCostPartSelfTotal float64 = 0 //材料费
  34120. var materialSelfTotal float64 = 0 //床位部分项目自费
  34121. var materialInscpTotal float64 = 0 //床位部分项目自费
  34122. var westernMedicineCostTotal float64 = 0 //西药费
  34123. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34124. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34125. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34126. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34127. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34128. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34129. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34130. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34131. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34132. var checkCostTotal float64 = 0 //检查费
  34133. var checkCostSelfTotal float64 = 0 //检查费
  34134. var checkCostPartSelfTotal float64 = 0 //检查费
  34135. var checkSelfTotal float64 = 0 //床位部分项目自费
  34136. var checkInscpTotal float64 = 0 //床位部分项目自费
  34137. var laboratoryCostTotal float64 = 0 //化验费
  34138. var laboratoryCostSelfTotal float64 = 0 //化验费
  34139. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34140. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34141. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34142. var treatCostTotal float64 = 0 //治疗费用
  34143. var treatCostSelfTotal float64 = 0 //治疗费用
  34144. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34145. var treatSelfTotal float64 = 0 //床位部分项目自费
  34146. var treatInscpTotal float64 = 0 //床位部分项目自费
  34147. var zcCostTotal float64 = 0 //治疗费用
  34148. var zcCostSelfTotal float64 = 0 //治疗费用
  34149. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34150. var zcSelfTotal float64 = 0 //床位部分项目自费
  34151. var zcInscpTotal float64 = 0 //床位部分项目自费
  34152. var huliCostTotal float64 = 0 //治疗费用
  34153. var huliCostSelfTotal float64 = 0 //治疗费用
  34154. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34155. var huliSelfTotal float64 = 0 //床位部分项目自费
  34156. var huliInscpTotal float64 = 0 //床位部分项目自费
  34157. decimal.DivisionPrecision = 2
  34158. for _, item := range orderInfos {
  34159. if item.MedChrgitmType == "01" { //床位费
  34160. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34161. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34162. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34163. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34164. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34165. }
  34166. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34167. if item.MedChrgitmType == "03" { //检查费
  34168. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34169. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34170. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34171. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34172. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34173. }
  34174. } else {
  34175. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34176. fmt.Println("------------")
  34177. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34178. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34179. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34180. }
  34181. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34182. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34183. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34184. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34185. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34186. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34187. }
  34188. }
  34189. if item.MedChrgitmType == "04" { //化验费
  34190. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34191. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34192. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34193. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34194. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34195. }
  34196. if item.MedChrgitmType == "05" { //治疗费
  34197. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34198. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34199. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34200. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34201. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34202. }
  34203. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34204. fmt.Println("------------")
  34205. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34206. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34207. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34208. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34209. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34210. }
  34211. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34212. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34213. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34214. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34215. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34216. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34217. }
  34218. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34219. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34220. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34221. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34222. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34223. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34224. }
  34225. if item.MedChrgitmType == "09" { //西药费
  34226. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34227. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34228. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34229. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34230. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34231. }
  34232. if item.MedChrgitmType == "11" { //中成费
  34233. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34234. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34235. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34236. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34237. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34238. }
  34239. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34240. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34241. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34242. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34243. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34244. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34245. }
  34246. if item.MedChrgitmType == "02" { //其他费
  34247. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34248. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34249. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34250. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34251. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34252. }
  34253. if item.MedChrgitmType == "07" { //其他费
  34254. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34255. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34256. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34257. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34258. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34259. }
  34260. }
  34261. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34262. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34263. var user_name string
  34264. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34265. if role.ID == 0 {
  34266. user_name = "管理员"
  34267. } else {
  34268. user_name = role.UserName
  34269. }
  34270. baseParams := models.BaseParams{
  34271. SecretKey: miConfig.SecretKey,
  34272. FixmedinsCode: miConfig.Code,
  34273. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34274. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34275. OrgName: miConfig.OrgName,
  34276. Doctor: user_name,
  34277. RequestUrl: miConfig.Url,
  34278. AccessKey: miConfig.AccessKey,
  34279. }
  34280. businessParams := models.BusinessParams{
  34281. PsnNo: order.PsnNo,
  34282. MdtrtId: order.MdtrtId,
  34283. SetlId: order.SetlId,
  34284. }
  34285. var res ResultEleven
  34286. var resah ResultElevenah
  34287. var resEleven10265 ResultEleven10265
  34288. if config.IsOpen == 1 {
  34289. if miConfig.MdtrtareaAdmvs == "421300" {
  34290. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34291. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34292. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34293. resp, requestErr := http.Get(api)
  34294. if requestErr != nil {
  34295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34296. return
  34297. }
  34298. body, ioErr := ioutil.ReadAll(resp.Body)
  34299. if ioErr != nil {
  34300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34302. return
  34303. }
  34304. var respJSON map[string]interface{}
  34305. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34308. return
  34309. }
  34310. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34311. result, _ := json.Marshal(respJSON)
  34312. fmt.Println("log")
  34313. fmt.Println(string(result))
  34314. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34315. utils.ErrorLog("解析失败:%v", err)
  34316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34317. return
  34318. }
  34319. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34320. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34321. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34322. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34323. resp, requestErr := http.Get(api)
  34324. if requestErr != nil {
  34325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34326. return
  34327. }
  34328. body, ioErr := ioutil.ReadAll(resp.Body)
  34329. if ioErr != nil {
  34330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34332. return
  34333. }
  34334. var respJSON map[string]interface{}
  34335. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34338. return
  34339. }
  34340. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34341. result, _ := json.Marshal(respJSON)
  34342. fmt.Println("log")
  34343. fmt.Println(string(result))
  34344. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34345. utils.ErrorLog("解析失败:%v", err)
  34346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34347. return
  34348. }
  34349. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34350. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34351. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34353. resp, requestErr := http.Get(api)
  34354. if requestErr != nil {
  34355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34356. return
  34357. }
  34358. body, ioErr := ioutil.ReadAll(resp.Body)
  34359. if ioErr != nil {
  34360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34362. return
  34363. }
  34364. var respJSON map[string]interface{}
  34365. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34368. return
  34369. }
  34370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34371. result, _ := json.Marshal(respJSON)
  34372. fmt.Println("log")
  34373. fmt.Println(string(result))
  34374. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34375. utils.ErrorLog("解析失败:%v", err)
  34376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34377. return
  34378. }
  34379. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34380. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34381. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34382. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34383. resp, requestErr := http.Get(api)
  34384. if requestErr != nil {
  34385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34386. return
  34387. }
  34388. body, ioErr := ioutil.ReadAll(resp.Body)
  34389. if ioErr != nil {
  34390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34392. return
  34393. }
  34394. var respJSON map[string]interface{}
  34395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34398. return
  34399. }
  34400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34401. result, _ := json.Marshal(respJSON)
  34402. fmt.Println("log")
  34403. fmt.Println(string(result))
  34404. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34405. utils.ErrorLog("解析失败:%v", err)
  34406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34407. return
  34408. }
  34409. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34410. var api string
  34411. if miConfig.MdtrtareaAdmvs == "320921" {
  34412. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34413. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34414. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34415. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34416. } else {
  34417. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34418. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34419. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34420. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34421. }
  34422. resp, requestErr := http.Get(api)
  34423. if requestErr != nil {
  34424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34425. return
  34426. }
  34427. body, ioErr := ioutil.ReadAll(resp.Body)
  34428. if ioErr != nil {
  34429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34431. return
  34432. }
  34433. var respJSON map[string]interface{}
  34434. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34437. return
  34438. }
  34439. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34440. result, _ := json.Marshal(respJSON)
  34441. fmt.Println("log")
  34442. fmt.Println(string(result))
  34443. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34444. utils.ErrorLog("解析失败:%v", err)
  34445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34446. return
  34447. }
  34448. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34449. res.Output = resEleven10265.Output
  34450. res.ErrMsg = resEleven10265.ErrMsg
  34451. res.Cainfo = resEleven10265.Cainfo
  34452. res.WarnMsg = resEleven10265.WarnMsg
  34453. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34454. res.Infcode = infocode
  34455. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34456. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34457. saveLog(result, requestLog, "5203", "结算单")
  34458. var dat map[string]interface{}
  34459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34460. fmt.Println(dat)
  34461. } else {
  34462. fmt.Println(err)
  34463. }
  34464. userJSONBytes, _ := json.Marshal(dat)
  34465. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34466. utils.ErrorLog("解析失败:%v", err)
  34467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34468. return
  34469. }
  34470. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34471. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34472. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34473. saveLog(result, requestLog, "5203", "结算单")
  34474. var dat map[string]interface{}
  34475. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34476. fmt.Println(dat)
  34477. } else {
  34478. fmt.Println(err)
  34479. }
  34480. userJSONBytes, _ := json.Marshal(dat)
  34481. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34482. utils.ErrorLog("解析失败:%v", err)
  34483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34484. return
  34485. }
  34486. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34487. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34488. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34489. saveLog(result, requestLog, "5203", "结算单")
  34490. var dat map[string]interface{}
  34491. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34492. fmt.Println(dat)
  34493. } else {
  34494. fmt.Println(err)
  34495. }
  34496. userJSONBytes, _ := json.Marshal(dat)
  34497. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34498. utils.ErrorLog("解析失败:%v", err)
  34499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34500. return
  34501. }
  34502. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34503. var api string
  34504. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34505. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34506. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34507. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34508. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34509. resp, requestErr := http.Get(api)
  34510. if requestErr != nil {
  34511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34512. return
  34513. }
  34514. body, ioErr := ioutil.ReadAll(resp.Body)
  34515. if ioErr != nil {
  34516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34518. return
  34519. }
  34520. var respJSON map[string]interface{}
  34521. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34524. return
  34525. }
  34526. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34527. if status == "0" {
  34528. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34529. c.ServeSuccessJSON(map[string]interface{}{
  34530. "failed_code": -10,
  34531. "msg": err_msg,
  34532. })
  34533. return
  34534. }
  34535. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34536. result, _ := json.Marshal(respJSON)
  34537. fmt.Println("log")
  34538. fmt.Println(string(result))
  34539. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34540. utils.ErrorLog("解析失败:%v", err)
  34541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34542. return
  34543. }
  34544. res.InfRefmsgid = resah.InfRefmsgid
  34545. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34546. // 创建对应的Time类型
  34547. t := time.UnixMilli(timestamp)
  34548. // 格式化成指定的日期字符串
  34549. str := t.Format("2006-01-02 15:04:05")
  34550. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34551. // 创建对应的Time类型
  34552. t3 := time.UnixMilli(timestamp2)
  34553. // 格式化成指定的日期字符串
  34554. str2 := t3.Format("2006-01-02 15:04:05")
  34555. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34556. // 创建对应的Time类型
  34557. t4 := time.UnixMilli(timestamp3)
  34558. // 格式化成指定的日期字符串
  34559. str3 := t4.Format("2006-01-02 15:04:05")
  34560. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34561. // 创建对应的Time类型
  34562. t5 := time.UnixMilli(timestamp4)
  34563. // 格式化成指定的日期字符串
  34564. str5 := t5.Format("2006-01-02 15:04:05")
  34565. res.Output.Setlinfo.Brdy = str2
  34566. res.Output.Setlinfo.SetlTime = str
  34567. res.Output.Setlinfo.Begndate = str3
  34568. res.Output.Setlinfo.Enddate = str5
  34569. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34570. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34571. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34572. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34573. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34574. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34575. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34576. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34577. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34578. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34579. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34580. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34581. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34582. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34583. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34584. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34585. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34586. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34587. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34588. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34589. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34590. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34591. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34592. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34593. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34594. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34595. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34596. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34597. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34598. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34599. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34600. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34601. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34602. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34603. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34604. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34605. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34606. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34607. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34608. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34609. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34610. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34611. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34612. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34613. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34614. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34615. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  34616. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  34617. //res.Output.Setldetail = resah.Output.Setldetail
  34618. res.ErrMsg = resah.ErrMsg
  34619. res.Cainfo = resah.Cainfo
  34620. res.WarnMsg = resah.WarnMsg
  34621. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34622. var api string
  34623. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34624. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34625. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34626. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34627. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34628. resp, requestErr := http.Get(api)
  34629. if requestErr != nil {
  34630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34631. return
  34632. }
  34633. body, ioErr := ioutil.ReadAll(resp.Body)
  34634. if ioErr != nil {
  34635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34637. return
  34638. }
  34639. var respJSON map[string]interface{}
  34640. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34643. return
  34644. }
  34645. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34646. if status == "0" {
  34647. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  34648. c.ServeSuccessJSON(map[string]interface{}{
  34649. "failed_code": -10,
  34650. "msg": err_msg,
  34651. })
  34652. return
  34653. }
  34654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34655. result, _ := json.Marshal(respJSON)
  34656. fmt.Println("log")
  34657. fmt.Println(string(result))
  34658. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  34659. utils.ErrorLog("解析失败:%v", err)
  34660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34661. return
  34662. }
  34663. res.InfRefmsgid = resah.InfRefmsgid
  34664. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34665. // 创建对应的Time类型
  34666. t := time.UnixMilli(timestamp)
  34667. // 格式化成指定的日期字符串
  34668. str := t.Format("2006-01-02 15:04:05")
  34669. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  34670. // 创建对应的Time类型
  34671. t3 := time.UnixMilli(timestamp2)
  34672. // 格式化成指定的日期字符串
  34673. str2 := t3.Format("2006-01-02 15:04:05")
  34674. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  34675. // 创建对应的Time类型
  34676. t4 := time.UnixMilli(timestamp3)
  34677. // 格式化成指定的日期字符串
  34678. str3 := t4.Format("2006-01-02 15:04:05")
  34679. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  34680. // 创建对应的Time类型
  34681. t5 := time.UnixMilli(timestamp4)
  34682. // 格式化成指定的日期字符串
  34683. str5 := t5.Format("2006-01-02 15:04:05")
  34684. res.Output.Setlinfo.Brdy = str2
  34685. res.Output.Setlinfo.SetlTime = str
  34686. res.Output.Setlinfo.Begndate = str3
  34687. res.Output.Setlinfo.Enddate = str5
  34688. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  34689. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  34690. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  34691. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  34692. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34693. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34694. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  34695. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  34696. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34697. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  34698. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  34699. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  34700. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  34701. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  34702. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  34703. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  34704. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  34705. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  34706. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  34707. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  34708. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  34709. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  34710. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  34711. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  34712. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  34713. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  34714. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  34715. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  34716. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  34717. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  34718. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  34719. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  34720. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  34721. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  34722. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  34723. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  34724. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  34725. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  34726. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  34727. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  34728. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  34729. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  34730. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  34731. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  34732. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  34733. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  34734. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  34735. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  34736. //res.Output.Setldetail = resah.Output.Setldetail
  34737. res.ErrMsg = resah.ErrMsg
  34738. res.Cainfo = resah.Cainfo
  34739. res.WarnMsg = resah.WarnMsg
  34740. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34741. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  34742. saveLog(result, requestLog, "5203", "结算单")
  34743. var dat map[string]interface{}
  34744. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34745. fmt.Println(dat)
  34746. } else {
  34747. fmt.Println(err)
  34748. }
  34749. userJSONBytes, _ := json.Marshal(dat)
  34750. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34751. utils.ErrorLog("解析失败:%v", err)
  34752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34753. return
  34754. }
  34755. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34756. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34757. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34758. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34759. resp, requestErr := http.Get(api)
  34760. if requestErr != nil {
  34761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34762. return
  34763. }
  34764. body, ioErr := ioutil.ReadAll(resp.Body)
  34765. if ioErr != nil {
  34766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34768. return
  34769. }
  34770. var respJSON map[string]interface{}
  34771. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34774. return
  34775. }
  34776. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34777. result, _ := json.Marshal(respJSON)
  34778. fmt.Println("log")
  34779. fmt.Println(string(result))
  34780. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34781. utils.ErrorLog("解析失败:%v", err)
  34782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34783. return
  34784. }
  34785. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34786. res.Output = resEleven10265.Output
  34787. res.ErrMsg = resEleven10265.ErrMsg
  34788. res.Cainfo = resEleven10265.Cainfo
  34789. res.WarnMsg = resEleven10265.WarnMsg
  34790. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34791. res.Infcode = infocode
  34792. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34793. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34794. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34795. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34796. resp, requestErr := http.Get(api)
  34797. if requestErr != nil {
  34798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34799. return
  34800. }
  34801. body, ioErr := ioutil.ReadAll(resp.Body)
  34802. if ioErr != nil {
  34803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34805. return
  34806. }
  34807. var respJSON map[string]interface{}
  34808. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34811. return
  34812. }
  34813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34814. result, _ := json.Marshal(respJSON)
  34815. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34816. utils.ErrorLog("解析失败:%v", err)
  34817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34818. return
  34819. }
  34820. } else if miConfig.MdtrtareaAdmvs == "450721" {
  34821. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  34822. //return
  34823. } else {
  34824. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34825. if len(his.InsuplcAdmdvs) == 0 {
  34826. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34827. } else {
  34828. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34829. }
  34830. result := service.Gdyb5203(baseParams, businessParams)
  34831. //service.Gdyb5204(baseParams, businessParams)
  34832. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34833. var dat map[string]interface{}
  34834. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34835. fmt.Println(dat)
  34836. } else {
  34837. fmt.Println(err)
  34838. }
  34839. userJSONBytes, _ := json.Marshal(dat)
  34840. if miConfig.Code == "H15049901371" {
  34841. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34842. utils.ErrorLog("解析失败:%v", err)
  34843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34844. return
  34845. }
  34846. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34847. res.Output = resEleven10265.Output
  34848. res.ErrMsg = resEleven10265.ErrMsg
  34849. res.Cainfo = resEleven10265.Cainfo
  34850. res.WarnMsg = resEleven10265.WarnMsg
  34851. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34852. res.Infcode = infocode
  34853. } else {
  34854. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34855. utils.ErrorLog("解析失败:%v", err)
  34856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34857. return
  34858. }
  34859. }
  34860. }
  34861. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34862. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34863. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34864. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34865. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34866. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34867. var doctor_name string
  34868. if roles.ID == 0 {
  34869. doctor_name = "管理员"
  34870. } else {
  34871. doctor_name = roles.UserName
  34872. }
  34873. yiliao_leibie := ""
  34874. switch order.MedType {
  34875. case "11":
  34876. yiliao_leibie = "普通门诊"
  34877. break
  34878. case "12":
  34879. yiliao_leibie = "门诊挂号"
  34880. break
  34881. case "13":
  34882. yiliao_leibie = "急诊"
  34883. break
  34884. case "14":
  34885. yiliao_leibie = "门诊特殊病"
  34886. break
  34887. case "15":
  34888. yiliao_leibie = "门诊统筹"
  34889. break
  34890. case "16":
  34891. yiliao_leibie = "门诊慢性病"
  34892. break
  34893. case "21":
  34894. yiliao_leibie = "普通住院"
  34895. break
  34896. }
  34897. //var rf []CustomFundPay
  34898. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  34899. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34900. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  34901. if res.Infcode == 0 {
  34902. 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 {
  34903. c.ServeSuccessJSON(map[string]interface{}{
  34904. "diagnosis": name,
  34905. "order_infos": orderInfos,
  34906. "number": order.MdtrtId,
  34907. "date": order.SettleAccountsDate,
  34908. "charge_admin": charge_admin,
  34909. "printor_admin": printor_admin,
  34910. "info": res.Output.Setlinfo,
  34911. "order": order,
  34912. "bedCostTotal": bedCostTotal,
  34913. "bedCostSelfTotal": bedCostSelfTotal,
  34914. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34915. "bedSelfTotal": bedSelfTotal,
  34916. "bedInscpTotal": bedInscpTotal,
  34917. "operationCostTotal": operationCostTotal,
  34918. "operationCostSelfTotal": operationCostSelfTotal,
  34919. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34920. "operationSelfTotal": operationSelfTotal,
  34921. "operationInscpTotal": operationInscpTotal,
  34922. "otherCostTotal": otherCostTotal,
  34923. "otherCostSelfTotal": otherCostSelfTotal,
  34924. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34925. "otherSelfTotal": otherSelfTotal,
  34926. "otherInscpTotal": otherInscpTotal,
  34927. "materialCostTotal": materialCostTotal,
  34928. "materialCostSelfTotal": materialCostSelfTotal,
  34929. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34930. "materialSelfTotal": materialSelfTotal,
  34931. "materialInscpTotal": materialInscpTotal,
  34932. "westernMedicineCostTotal": westernMedicineCostTotal,
  34933. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34934. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34935. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34936. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34937. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34938. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34939. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34940. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34941. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34942. "checkCostTotal": checkCostTotal,
  34943. "checkCostSelfTotal": checkCostSelfTotal,
  34944. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34945. "checkSelfTotal": checkSelfTotal,
  34946. "checkInscpTotal": checkInscpTotal,
  34947. "laboratoryCostTotal": laboratoryCostTotal,
  34948. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34949. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34950. "laboratorySelfTotal": laboratorySelfTotal,
  34951. "laboratoryInscpTotal": laboratoryInscpTotal,
  34952. "treatCostTotal": treatCostTotal,
  34953. "treatCostSelfTotal": treatCostSelfTotal,
  34954. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34955. "treatSelfTotal": treatSelfTotal,
  34956. "treatInscpTotal": treatInscpTotal,
  34957. "doctor_info": doctor_info,
  34958. "doctor_code": adminRole_two.DoctorCode,
  34959. "doctor_name": doctor_name,
  34960. "health_card_no": order.PsnNo,
  34961. "department": departments.Name,
  34962. "yiliao_leibie": yiliao_leibie,
  34963. "after_money": order.AccountPrice,
  34964. "patient": patient,
  34965. "org_name": miConfig.OrgName,
  34966. "org_code": miConfig.Code,
  34967. "order_number": order.Number,
  34968. "his_hospital": his_hospital,
  34969. "his": his,
  34970. "dia_config": dia_config,
  34971. "psn_cash_pay": order.PsnCashPay,
  34972. "zcCostTotal": zcCostTotal,
  34973. "zcCostSelfTotal": zcCostSelfTotal,
  34974. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  34975. "zcSelfTotal": zcSelfTotal,
  34976. "zcInscpTotal": zcInscpTotal,
  34977. "huliCostTotal": huliCostTotal,
  34978. "huliCostSelfTotal": huliCostSelfTotal,
  34979. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  34980. "huliSelfTotal": huliSelfTotal,
  34981. "huliInscpTotal": huliInscpTotal,
  34982. //"funds": rf,
  34983. //"check_order_info": cus_slice,
  34984. })
  34985. } else {
  34986. c.ServeSuccessJSON(map[string]interface{}{
  34987. "diagnosis": name,
  34988. "order_infos": orderInfos,
  34989. "number": order.MdtrtId,
  34990. "date": order.SettleAccountsDate,
  34991. "charge_admin": charge_admin,
  34992. "printor_admin": printor_admin,
  34993. "info": order,
  34994. "order": order,
  34995. "bedCostTotal": bedCostTotal,
  34996. "bedCostSelfTotal": bedCostSelfTotal,
  34997. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34998. "bedSelfTotal": bedSelfTotal,
  34999. "bedInscpTotal": bedInscpTotal,
  35000. "operationCostTotal": operationCostTotal,
  35001. "operationCostSelfTotal": operationCostSelfTotal,
  35002. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35003. "operationSelfTotal": operationSelfTotal,
  35004. "operationInscpTotal": operationInscpTotal,
  35005. "otherCostTotal": otherCostTotal,
  35006. "otherCostSelfTotal": otherCostSelfTotal,
  35007. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35008. "otherSelfTotal": otherSelfTotal,
  35009. "otherInscpTotal": otherInscpTotal,
  35010. "materialCostTotal": materialCostTotal,
  35011. "materialCostSelfTotal": materialCostSelfTotal,
  35012. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35013. "materialSelfTotal": materialSelfTotal,
  35014. "materialInscpTotal": materialInscpTotal,
  35015. "westernMedicineCostTotal": westernMedicineCostTotal,
  35016. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35017. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35018. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35019. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35020. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35021. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35022. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35023. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35024. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35025. "checkCostTotal": checkCostTotal,
  35026. "checkCostSelfTotal": checkCostSelfTotal,
  35027. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35028. "checkSelfTotal": checkSelfTotal,
  35029. "checkInscpTotal": checkInscpTotal,
  35030. "laboratoryCostTotal": laboratoryCostTotal,
  35031. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35032. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35033. "laboratorySelfTotal": laboratorySelfTotal,
  35034. "laboratoryInscpTotal": laboratoryInscpTotal,
  35035. "treatCostTotal": treatCostTotal,
  35036. "treatCostSelfTotal": treatCostSelfTotal,
  35037. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35038. "treatSelfTotal": treatSelfTotal,
  35039. "treatInscpTotal": treatInscpTotal,
  35040. "doctor_info": doctor_info,
  35041. "doctor_code": adminRole_two.DoctorCode,
  35042. "doctor_name": doctor_name,
  35043. "health_card_no": order.PsnNo,
  35044. "department": departments.Name,
  35045. "yiliao_leibie": yiliao_leibie,
  35046. "after_money": order.AccountPrice,
  35047. "patient": patient,
  35048. "org_name": miConfig.OrgName,
  35049. "org_code": miConfig.Code,
  35050. "order_number": order.Number,
  35051. "his_hospital": his_hospital,
  35052. "his": his,
  35053. "dia_config": dia_config,
  35054. "psn_cash_pay": order.PsnCashPay,
  35055. "zcCostTotal": zcCostTotal,
  35056. "zcCostSelfTotal": zcCostSelfTotal,
  35057. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35058. "zcSelfTotal": zcSelfTotal,
  35059. "zcInscpTotal": zcInscpTotal,
  35060. "huliCostTotal": huliCostTotal,
  35061. "huliCostSelfTotal": huliCostSelfTotal,
  35062. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35063. "huliSelfTotal": huliSelfTotal,
  35064. "huliInscpTotal": huliInscpTotal,
  35065. //"funds": rf,
  35066. //"check_order_info": cus_slice,
  35067. })
  35068. }
  35069. }
  35070. }
  35071. }
  35072. //func (c *HisApiController) CheckTreatment() {
  35073. // patient_id, _ := c.GetInt64("patient_id")
  35074. // id_card_no := c.GetString("id_card_no")
  35075. // insutype := c.GetString("insutype")
  35076. // med_type := c.GetString("med_type")
  35077. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35078. //
  35079. // adminUser := c.GetAdminUserInfo()
  35080. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35081. //
  35082. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35083. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35084. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35085. //
  35086. // if miConfig.MdtrtareaAdmvs == "421300" {
  35087. // var res ResultTwo
  35088. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35089. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35090. // "&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)
  35091. // resp, requestErr := http.Get(api)
  35092. // if requestErr != nil {
  35093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35094. // return
  35095. // }
  35096. //
  35097. // body, ioErr := ioutil.ReadAll(resp.Body)
  35098. // if ioErr != nil {
  35099. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35101. // return
  35102. // }
  35103. // var respJSON map[string]interface{}
  35104. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35105. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35107. // return
  35108. // }
  35109. //
  35110. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35111. // result, _ := json.Marshal(respJSON)
  35112. //
  35113. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35114. // utils.ErrorLog("解析失败:%v", err)
  35115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35116. // return
  35117. // }
  35118. //
  35119. // if res.Infcode == 0 {
  35120. //
  35121. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35122. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35123. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35124. // resp, requestErr := http.Get(api)
  35125. // if requestErr != nil {
  35126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35127. // return
  35128. // }
  35129. //
  35130. // body, ioErr := ioutil.ReadAll(resp.Body)
  35131. // if ioErr != nil {
  35132. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35133. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35134. // return
  35135. // }
  35136. // var respJSON map[string]interface{}
  35137. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35138. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35140. // return
  35141. // }
  35142. // var res Result2001
  35143. //
  35144. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35145. // result2, _ := json.Marshal(respJSON)
  35146. //
  35147. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35148. // utils.ErrorLog("解析失败:%v", err)
  35149. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35150. // return
  35151. // }
  35152. //
  35153. // if res.Infcode == 0 {
  35154. // c.ServeSuccessJSON(map[string]interface{}{
  35155. // "msg": res.Output.Trtinfo,
  35156. // })
  35157. // }
  35158. //
  35159. // } else {
  35160. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35161. // return
  35162. // }
  35163. //
  35164. // } else {
  35165. //
  35166. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35167. // var dat map[string]interface{}
  35168. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35169. // fmt.Println(dat)
  35170. // } else {
  35171. // fmt.Println(err)
  35172. // }
  35173. // userJSONBytes, _ := json.Marshal(dat)
  35174. // var res ResultTwo
  35175. // var res10265 ResultTwo10265
  35176. // if miConfig.Code == "H15049901371" {
  35177. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35178. // utils.ErrorLog("解析失败:%v", err)
  35179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35180. // return
  35181. // }
  35182. // res.ErrMsg = res10265.ErrMsg
  35183. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35184. // res.Infcode = infocode
  35185. // res.Output = res10265.Output
  35186. // res.InfRefmsgid = res10265.InfRefmsgid
  35187. // } else {
  35188. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35189. // utils.ErrorLog("解析失败:%v", err)
  35190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35191. // return
  35192. // }
  35193. // }
  35194. //
  35195. // var user_name string
  35196. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35197. // if role.ID == 0 {
  35198. // user_name = "xxx"
  35199. // } else {
  35200. // user_name = role.UserName
  35201. // }
  35202. //
  35203. // baseParams := models.BaseParams{
  35204. // SecretKey: miConfig.SecretKey,
  35205. // FixmedinsCode: miConfig.Code,
  35206. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35207. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35208. // OrgName: miConfig.OrgName,
  35209. // Doctor: user_name,
  35210. // }
  35211. //
  35212. // if config.IsOpen == 1 {
  35213. // if miConfig.Code == "H15049901371" {
  35214. // if med_type == "14" {
  35215. // if insutype == "390" {
  35216. // med_type = "9933"
  35217. // } else if insutype == "310" {
  35218. // med_type = "990502"
  35219. // }
  35220. // } else if med_type == "11" {
  35221. // med_type = "11"
  35222. // }
  35223. // }
  35224. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35225. // var dat map[string]interface{}
  35226. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35227. // fmt.Println(dat)
  35228. // } else {
  35229. // fmt.Println(err)
  35230. // }
  35231. // var res Result2001
  35232. // var res10265 Result2001Org10265
  35233. // if miConfig.Code == "H15049901371" {
  35234. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35235. // utils.ErrorLog("解析失败:%v", err)
  35236. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35237. // return
  35238. // }
  35239. // res.ErrMsg = res10265.ErrMsg
  35240. // res.Output = res10265.Output
  35241. // res.InfRefmsgid = res10265.InfRefmsgid
  35242. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35243. // res.Infcode = infocode
  35244. // } else {
  35245. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35246. // utils.ErrorLog("解析失败:%v", err)
  35247. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35248. // return
  35249. // }
  35250. // }
  35251. // if res.Infcode == 0 {
  35252. // c.ServeSuccessJSON(map[string]interface{}{
  35253. // "msg": res.Output.Trtinfo,
  35254. // })
  35255. // }
  35256. // }
  35257. // }
  35258. //}
  35259. //func (c *HisApiController) PutRecord() {
  35260. // id, _ := c.GetInt64("id")
  35261. // record_time := c.GetString("record_time")
  35262. // timeLayout := "2006-01-02"
  35263. // loc, _ := time.LoadLocation("Local")
  35264. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35265. // if err != nil {
  35266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35267. // return
  35268. // }
  35269. // recordDateTime := theTime.Unix()
  35270. //
  35271. // adminInfo := c.GetAdminUserInfo()
  35272. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35273. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35274. //
  35275. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35276. //
  35277. // fmt.Println(miConfig.SecretKey)
  35278. //
  35279. // if patient == nil {
  35280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35281. // return
  35282. // }
  35283. // if len(patient.IdCardNo) == 0 {
  35284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35285. // return
  35286. // }
  35287. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35288. // if config.IsOpen == 1 {
  35289. // 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
  35290. // resp, requestErr := http.Get(api)
  35291. // if requestErr != nil {
  35292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35293. // return
  35294. // }
  35295. // defer resp.Body.Close()
  35296. // body, ioErr := ioutil.ReadAll(resp.Body)
  35297. // if ioErr != nil {
  35298. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35299. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35300. // return
  35301. // }
  35302. // var respJSON map[string]interface{}
  35303. //
  35304. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35305. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35306. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35307. // return
  35308. // }
  35309. //
  35310. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35311. // userJSONBytes, _ := json.Marshal(userJSON)
  35312. // var res ResultTwo
  35313. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35314. // utils.ErrorLog("解析失败:%v", err)
  35315. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35316. // return
  35317. // }
  35318. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35319. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35320. // infoStr := string(Iinfos)
  35321. // idetinfoStr := string(Idetinfos)
  35322. //
  35323. // if res.Infcode == 0 {
  35324. // his := models.VMHisPatient{
  35325. // Status: 1,
  35326. // Ctime: time.Now().Unix(),
  35327. // Mtime: time.Now().Unix(),
  35328. // PsnNo: res.Output.Baseinfo.PsnNo,
  35329. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35330. // Certno: res.Output.Baseinfo.Certno,
  35331. // PsnName: res.Output.Baseinfo.PsnName,
  35332. // Gend: res.Output.Baseinfo.Gend,
  35333. // Naty: res.Output.Baseinfo.Naty,
  35334. // Brdy: res.Output.Baseinfo.Brdy,
  35335. // Age: res.Output.Baseinfo.Age,
  35336. // Iinfo: infoStr,
  35337. // Idetinfo: idetinfoStr,
  35338. // PatientId: patient.ID,
  35339. // RecordDate: theTime.Unix(),
  35340. // UserOrgId: adminInfo.CurrentOrgId,
  35341. // AdminUserId: adminInfo.AdminUser.Id,
  35342. // IsReturn: 1,
  35343. // }
  35344. //
  35345. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35346. // //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")
  35347. // //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")
  35348. //
  35349. // //var dat map[string]interface{}
  35350. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35351. // // fmt.Println(dat)
  35352. // //} else {
  35353. // // fmt.Println(err)
  35354. // //}
  35355. //
  35356. // var dat2 map[string]interface{}
  35357. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35358. // fmt.Println(dat2)
  35359. // } else {
  35360. // fmt.Println(err)
  35361. // }
  35362. //
  35363. // } else {
  35364. // adminUser := c.GetAdminUserInfo()
  35365. // errlog := &models.HisOrderError{
  35366. // UserOrgId: adminUser.CurrentOrgId,
  35367. // Ctime: time.Now().Unix(),
  35368. // Mtime: time.Now().Unix(),
  35369. // ErrMsg: res.ErrMsg,
  35370. // Status: 1,
  35371. // PatientId: id,
  35372. // RecordTime: recordDateTime,
  35373. // Stage: 1,
  35374. // }
  35375. // service.CreateErrMsgLog(errlog)
  35376. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35377. // return
  35378. // }
  35379. // }
  35380. //
  35381. //}
  35382. //func (c *HisApiController) GetUploadDiag() {
  35383. // id, _ := c.GetInt64("id")
  35384. // record_time := c.GetString("record_time")
  35385. //
  35386. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35387. // sick_type, _ := c.GetInt64("sick_type")
  35388. // reg_type, _ := c.GetInt64("reg_type")
  35389. //
  35390. // timeLayout := "2006-01-02"
  35391. // loc, _ := time.LoadLocation("Local")
  35392. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35393. // if err != nil {
  35394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35395. // return
  35396. // }
  35397. //
  35398. // var patientPrescription models.HisPrescriptionInfo
  35399. // recordDateTime := theTime.Unix()
  35400. // adminInfo := c.GetAdminUserInfo()
  35401. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35402. //
  35403. // if patientPrescription.ID == 0 {
  35404. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35405. // }
  35406. //
  35407. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35408. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35409. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35410. // sickConfig, _ := service.FindSickById(sick_type)
  35411. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35412. //
  35413. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35414. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35415. // "&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 +
  35416. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35417. // resp2, requestErr2 := http.Get(api2)
  35418. // if requestErr2 != nil {
  35419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35420. // return
  35421. // }
  35422. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35423. // if ioErr2 != nil {
  35424. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35425. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35426. // return
  35427. // }
  35428. // var respJSON2 map[string]interface{}
  35429. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35430. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35431. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35432. // return
  35433. // }
  35434. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35435. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35436. //
  35437. // var res2 ResultSix
  35438. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35439. // utils.ErrorLog("解析失败:%v", err)
  35440. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35441. // return
  35442. // }
  35443. // if res2.Infcode != 0 {
  35444. // adminUser := c.GetAdminUserInfo()
  35445. // errlog := &models.HisOrderError{
  35446. // UserOrgId: adminUser.CurrentOrgId,
  35447. // Ctime: time.Now().Unix(),
  35448. // Mtime: time.Now().Unix(),
  35449. // ErrMsg: res2.ErrMsg,
  35450. // Status: 1,
  35451. // PatientId: id,
  35452. // RecordTime: recordDateTime,
  35453. // Stage: 3,
  35454. // }
  35455. // service.CreateErrMsgLog(errlog)
  35456. //
  35457. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35458. // return
  35459. // }
  35460. //
  35461. // c.ServeSuccessJSON(map[string]interface{}{
  35462. // "msg": "上传成功",
  35463. // })
  35464. //
  35465. //}
  35466. type QueryResult struct {
  35467. ID int64
  35468. Name string
  35469. Code string
  35470. List_type_code string
  35471. }
  35472. func (c *HisApiController) GetCheckCode() {
  35473. ids_str := c.GetString("ids")
  35474. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35475. ids_arr := strings.Split(ids_str, ",")
  35476. var queryResult []QueryResult
  35477. ids := make([]int64, 0)
  35478. for _, item := range ids_arr {
  35479. id, _ := strconv.ParseInt(item, 10, 64)
  35480. ids = append(ids, id)
  35481. }
  35482. if record_type == 1 {
  35483. drugs, _ := service.GetBatchDrugList(ids)
  35484. for _, item := range drugs {
  35485. result := QueryResult{
  35486. ID: item.ID,
  35487. Name: item.DrugName,
  35488. Code: item.MedicalInsuranceNumber,
  35489. List_type_code: "101",
  35490. }
  35491. queryResult = append(queryResult, result)
  35492. }
  35493. } else if record_type == 2 {
  35494. goods, _ := service.GetBatchGoodInformationList(ids)
  35495. fmt.Println(goods)
  35496. for _, item := range goods {
  35497. result := QueryResult{
  35498. ID: item.ID,
  35499. Name: item.GoodName,
  35500. Code: item.SocialSecurityDirectoryCode,
  35501. List_type_code: "301",
  35502. }
  35503. queryResult = append(queryResult, result)
  35504. }
  35505. } else if record_type == 3 {
  35506. projects, _ := service.GetBathchMyPorjecgList(ids)
  35507. for _, item := range projects {
  35508. result := QueryResult{
  35509. ID: item.ID,
  35510. Name: item.ProjectName,
  35511. Code: item.MedicalCode,
  35512. List_type_code: "201",
  35513. }
  35514. queryResult = append(queryResult, result)
  35515. }
  35516. }
  35517. admin_user_id, _ := c.GetInt64("admin_user_id")
  35518. adminUser := c.GetAdminUserInfo()
  35519. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35520. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35521. var user_name string
  35522. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35523. if role.ID == 0 {
  35524. user_name = "管理员"
  35525. } else {
  35526. user_name = role.UserName
  35527. }
  35528. baseParams := models.BaseParams{
  35529. SecretKey: miConfig.SecretKey,
  35530. FixmedinsCode: miConfig.Code,
  35531. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35532. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35533. OrgName: miConfig.OrgName,
  35534. Doctor: user_name,
  35535. }
  35536. var result string
  35537. if miConfig.MdtrtareaAdmvs == "430800" {
  35538. for _, item := range queryResult {
  35539. if record_type == 1 {
  35540. 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)
  35541. } else if record_type == 2 {
  35542. fmt.Println(item.Code)
  35543. 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)
  35544. } else if record_type == 3 {
  35545. 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)
  35546. }
  35547. var dat map[string]interface{}
  35548. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35549. fmt.Println(dat)
  35550. } else {
  35551. fmt.Println(err)
  35552. }
  35553. userJSONBytes, _ := json.Marshal(dat)
  35554. var res ResultSix
  35555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35556. utils.ErrorLog("解析失败:%v", err)
  35557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35558. return
  35559. }
  35560. if res.Infcode == 0 {
  35561. if record_type == 1 {
  35562. service.UpdateBaseDrugById(item.ID)
  35563. } else if record_type == 2 {
  35564. service.UpdateGoodInformaitonByDetail(item.ID)
  35565. } else if record_type == 3 {
  35566. service.UpdateProjectById(item.ID)
  35567. }
  35568. c.ServeSuccessJSON(map[string]interface{}{
  35569. "failed_code": 0,
  35570. "msg": "目录对照成功",
  35571. })
  35572. } else {
  35573. c.ServeSuccessJSON(map[string]interface{}{
  35574. "failed_code": -10,
  35575. "msg": res.ErrMsg,
  35576. })
  35577. }
  35578. }
  35579. } else {
  35580. for _, item := range queryResult {
  35581. var result string
  35582. if record_type == 1 {
  35583. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35584. } else if record_type == 2 {
  35585. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35586. } else if record_type == 3 {
  35587. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  35588. }
  35589. var dat map[string]interface{}
  35590. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35591. fmt.Println(dat)
  35592. } else {
  35593. fmt.Println(err)
  35594. }
  35595. userJSONBytes, _ := json.Marshal(dat)
  35596. var res ResultSix
  35597. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35598. utils.ErrorLog("解析失败:%v", err)
  35599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35600. return
  35601. }
  35602. if res.Infcode == 0 {
  35603. if record_type == 1 {
  35604. service.UpdateBaseDrugById(item.ID)
  35605. } else if record_type == 2 {
  35606. service.UpdateGoodInformaitonByDetail(item.ID)
  35607. } else if record_type == 3 {
  35608. service.UpdateProjectById(item.ID)
  35609. }
  35610. c.ServeSuccessJSON(map[string]interface{}{
  35611. "failed_code": 0,
  35612. "msg": "目录对照成功",
  35613. })
  35614. } else {
  35615. c.ServeSuccessJSON(map[string]interface{}{
  35616. "failed_code": -10,
  35617. "msg": res.ErrMsg,
  35618. })
  35619. }
  35620. }
  35621. }
  35622. }
  35623. func (c *HisApiController) UnCheckCode() {
  35624. ids_str := c.GetString("ids")
  35625. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35626. admin_user_id, _ := c.GetInt64("admin_user_id")
  35627. ids_arr := strings.Split(ids_str, ",")
  35628. var queryResult []QueryResult
  35629. ids := make([]int64, 0)
  35630. for _, item := range ids_arr {
  35631. id, _ := strconv.ParseInt(item, 10, 64)
  35632. ids = append(ids, id)
  35633. }
  35634. if record_type == 1 {
  35635. drugs, _ := service.GetBatchDrugList(ids)
  35636. for _, item := range drugs {
  35637. result := QueryResult{
  35638. ID: item.ID,
  35639. Name: item.DrugName,
  35640. Code: item.MedicalInsuranceNumber,
  35641. List_type_code: "101",
  35642. }
  35643. queryResult = append(queryResult, result)
  35644. }
  35645. } else if record_type == 2 {
  35646. goods, _ := service.GetBatchGoodInformationList(ids)
  35647. for _, item := range goods {
  35648. result := QueryResult{
  35649. ID: item.ID,
  35650. Name: item.GoodName,
  35651. Code: item.SocialSecurityDirectoryCode,
  35652. List_type_code: "301",
  35653. }
  35654. queryResult = append(queryResult, result)
  35655. }
  35656. } else if record_type == 3 {
  35657. projects, _ := service.GetBathchMyPorjecgList(ids)
  35658. for _, item := range projects {
  35659. result := QueryResult{
  35660. ID: item.ID,
  35661. Name: item.ProjectName,
  35662. Code: item.MedicalCode,
  35663. List_type_code: "201",
  35664. }
  35665. queryResult = append(queryResult, result)
  35666. }
  35667. }
  35668. adminUser := c.GetAdminUserInfo()
  35669. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35670. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35671. var user_name string
  35672. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35673. if role.ID == 0 {
  35674. user_name = "xxx"
  35675. } else {
  35676. user_name = role.UserName
  35677. }
  35678. baseParams := &models.BaseParams{
  35679. SecretKey: miConfig.SecretKey,
  35680. FixmedinsCode: miConfig.Code,
  35681. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35682. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35683. OrgName: miConfig.OrgName,
  35684. Doctor: user_name,
  35685. }
  35686. if config.IsOpen == 1 {
  35687. if miConfig.MdtrtareaAdmvs == "430800" {
  35688. for _, item := range queryResult {
  35689. var result string
  35690. if record_type == 1 {
  35691. 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)
  35692. } else if record_type == 2 {
  35693. fmt.Println(item.Code)
  35694. 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)
  35695. } else if record_type == 3 {
  35696. 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)
  35697. }
  35698. var dat map[string]interface{}
  35699. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35700. fmt.Println(dat)
  35701. } else {
  35702. fmt.Println(err)
  35703. }
  35704. userJSONBytes, _ := json.Marshal(dat)
  35705. var res ResultSix
  35706. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35707. utils.ErrorLog("解析失败:%v", err)
  35708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35709. return
  35710. }
  35711. if res.Infcode == 0 {
  35712. if record_type == 1 {
  35713. service.UpdateBaseDrugById(item.ID)
  35714. } else if record_type == 2 {
  35715. service.UpdateGoodInformaitonByDetail(item.ID)
  35716. } else if record_type == 3 {
  35717. service.UpdateProjectById(item.ID)
  35718. }
  35719. c.ServeSuccessJSON(map[string]interface{}{
  35720. "failed_code": 0,
  35721. "msg": "目录对照成功",
  35722. })
  35723. } else {
  35724. c.ServeSuccessJSON(map[string]interface{}{
  35725. "failed_code": -10,
  35726. "msg": res.ErrMsg,
  35727. })
  35728. }
  35729. }
  35730. } else {
  35731. for _, item := range queryResult {
  35732. var result string
  35733. if record_type == 1 {
  35734. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  35735. } else if record_type == 2 {
  35736. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  35737. } else if record_type == 3 {
  35738. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  35739. }
  35740. var dat2 map[string]interface{}
  35741. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  35742. fmt.Println(dat2)
  35743. } else {
  35744. fmt.Println(err)
  35745. }
  35746. userJSONBytes, _ := json.Marshal(dat2)
  35747. var res ResultSix
  35748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35749. utils.ErrorLog("解析失败:%v", err)
  35750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35751. return
  35752. }
  35753. if res.Infcode == 0 {
  35754. if record_type == 1 {
  35755. service.UpdateDrugByIdDetail(item.ID)
  35756. } else if record_type == 2 {
  35757. service.UpdateGoodInfoById(item.ID)
  35758. } else if record_type == 3 {
  35759. service.UpdateMyProjectById(item.ID)
  35760. }
  35761. c.ServeSuccessJSON(map[string]interface{}{
  35762. "failed_code": 0,
  35763. "msg": "撤销目录对照成功",
  35764. })
  35765. } else {
  35766. c.ServeSuccessJSON(map[string]interface{}{
  35767. "failed_code": -10,
  35768. "msg": res.ErrMsg,
  35769. })
  35770. }
  35771. }
  35772. }
  35773. }
  35774. }
  35775. func (c *HisApiController) GetPatientInfo() {
  35776. id_card_no := c.GetString("id_card_no")
  35777. admin_user_id, _ := c.GetInt64("admin_user_id")
  35778. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  35779. if patient.ID == 0 {
  35780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35781. return
  35782. }
  35783. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  35784. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35785. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  35786. var res ResultTwo
  35787. var res10265 ResultTwo10265
  35788. if config.IsOpen == 1 {
  35789. if miConfig.MdtrtareaAdmvs == "150499" {
  35790. //请求内网数据
  35791. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  35792. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  35793. "&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
  35794. resp, requestErr := http.Get(api)
  35795. if requestErr != nil {
  35796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35797. return
  35798. }
  35799. body, ioErr := ioutil.ReadAll(resp.Body)
  35800. if ioErr != nil {
  35801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35803. return
  35804. }
  35805. var respJSON map[string]interface{}
  35806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35809. return
  35810. }
  35811. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35812. result_byte, _ := json.Marshal(respJSON)
  35813. result := string(result_byte)
  35814. var dat map[string]interface{}
  35815. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35816. fmt.Println(dat)
  35817. } else {
  35818. fmt.Println(err)
  35819. }
  35820. userJSONBytes, _ := json.Marshal(dat)
  35821. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35822. utils.ErrorLog("解析失败:%v", err)
  35823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35824. return
  35825. }
  35826. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35827. res.Infcode = Infcode
  35828. res.ErrMsg = res10265.ErrMsg
  35829. res.Output = res10265.Output
  35830. res.InfRefmsgid = res10265.InfRefmsgid
  35831. res.RespondTime = res10265.RespondTime
  35832. res.WarnInfo = res10265.WarnInfo
  35833. } else {
  35834. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35835. var dat map[string]interface{}
  35836. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35837. fmt.Println(dat)
  35838. } else {
  35839. fmt.Println(err)
  35840. }
  35841. userJSONBytes, _ := json.Marshal(dat)
  35842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35843. utils.ErrorLog("解析失败:%v", err)
  35844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35845. return
  35846. }
  35847. }
  35848. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35849. // utils.ErrorLog("解析失败:%v", err)
  35850. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35851. // return
  35852. //}
  35853. for index, item := range res.Output.Iinfo {
  35854. if item.PsnInsuStas == "2" {
  35855. fmt.Println("--------")
  35856. res.Output.Iinfo[index].Insutype = "300"
  35857. res.Output.Iinfo[index].PsnInsuStas = "1"
  35858. }
  35859. }
  35860. fmt.Println(res.Output.Iinfo)
  35861. if res.Infcode != 0 {
  35862. c.ServeSuccessJSON(map[string]interface{}{
  35863. "failed_code": -10,
  35864. "msg": res.ErrMsg,
  35865. })
  35866. } else {
  35867. c.ServeSuccessJSON(map[string]interface{}{
  35868. "failed_code": 0,
  35869. "info": res,
  35870. })
  35871. }
  35872. }
  35873. }
  35874. func (c *HisApiController) PsnPutOnRecord() {
  35875. record_type, _ := c.GetInt64("type")
  35876. patient_id, _ := c.GetInt64("patient_id")
  35877. admin_user_id, _ := c.GetInt64("admin_user_id")
  35878. start_time := c.GetString("start_time")
  35879. end_time := c.GetString("end_time")
  35880. adminUser := c.GetAdminUserInfo()
  35881. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35882. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35883. var patients []*models.Patients
  35884. if record_type == 1 { //全部备案
  35885. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  35886. patients = append(patients, patient...)
  35887. } else { //单个备案
  35888. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35889. patients = append(patients, patient)
  35890. }
  35891. var user_name string
  35892. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35893. if role.ID == 0 {
  35894. user_name = "xxx"
  35895. } else {
  35896. user_name = role.UserName
  35897. }
  35898. if config.IsOpen == 1 {
  35899. for _, item := range patients {
  35900. 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
  35901. resp, requestErr := http.Get(api)
  35902. if requestErr != nil {
  35903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35904. return
  35905. }
  35906. defer resp.Body.Close()
  35907. body, ioErr := ioutil.ReadAll(resp.Body)
  35908. if ioErr != nil {
  35909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35911. return
  35912. }
  35913. var respJSON map[string]interface{}
  35914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35917. return
  35918. }
  35919. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35920. userJSONBytes, _ := json.Marshal(userJSON)
  35921. var res ResultTwo
  35922. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35923. utils.ErrorLog("解析失败:%v", err)
  35924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35925. return
  35926. }
  35927. if res.Infcode == 0 {
  35928. 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)
  35929. var dat map[string]interface{}
  35930. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35931. fmt.Println(dat)
  35932. } else {
  35933. fmt.Println(err)
  35934. }
  35935. userJSONBytes, _ := json.Marshal(dat)
  35936. var res2 ResultThirteen
  35937. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35938. utils.ErrorLog("解析失败:%v", err)
  35939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35940. return
  35941. }
  35942. if res2.Infcode == 0 {
  35943. psnResult := &models.GdybPsnRecord{
  35944. UserOrgId: adminUser.CurrentOrgId,
  35945. PatientId: item.ID,
  35946. PsnNo: res.Output.Baseinfo.PsnNo,
  35947. Ctime: time.Now().Unix(),
  35948. Mtime: time.Now().Unix(),
  35949. Status: 1,
  35950. IsCancel: 1,
  35951. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  35952. }
  35953. service.CreatePsnRecord(psnResult)
  35954. } else {
  35955. c.ServeSuccessJSON(map[string]interface{}{
  35956. "failed_code": -10,
  35957. "msg": res2.ErrMsg,
  35958. })
  35959. return
  35960. }
  35961. }
  35962. }
  35963. }
  35964. }
  35965. func (c *HisApiController) PsnUnPutOnRecord() {
  35966. id, _ := c.GetInt64("id")
  35967. //record_type, _ := c.GetInt64("type")
  35968. admin_user_id, _ := c.GetInt64("admin_user_id")
  35969. adminUser := c.GetAdminUserInfo()
  35970. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35971. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35972. var user_name string
  35973. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35974. if role.ID == 0 {
  35975. user_name = "xxx"
  35976. } else {
  35977. user_name = role.UserName
  35978. }
  35979. psn_record, _ := service.GetPsnRecordById(id)
  35980. if psn_record.ID == 0 {
  35981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  35982. return
  35983. }
  35984. if config.IsOpen == 1 {
  35985. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  35986. var dat map[string]interface{}
  35987. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35988. fmt.Println(dat)
  35989. } else {
  35990. fmt.Println(err)
  35991. }
  35992. userJSONBytes, _ := json.Marshal(dat)
  35993. var res ResultFourteen
  35994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35995. utils.ErrorLog("解析失败:%v", err)
  35996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35997. return
  35998. }
  35999. if res.Infcode == 0 {
  36000. psn_record.IsCancel = 2
  36001. service.CreatePsnRecord(&psn_record)
  36002. } else {
  36003. c.ServeSuccessJSON(map[string]interface{}{
  36004. "failed_code": -10,
  36005. "msg": res.ErrMsg,
  36006. })
  36007. return
  36008. }
  36009. }
  36010. }
  36011. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36012. patient_id, _ := c.GetInt64("patient_id")
  36013. insutype_two := c.GetString("insutype")
  36014. psn_no := c.GetString("psn_no")
  36015. doctor_id, _ := c.GetInt64("doctor_id")
  36016. sick_id, _ := c.GetInt64("sick_id")
  36017. department_id, _ := c.GetInt64("department_id")
  36018. start_time := c.GetString("start_time")
  36019. end_time := c.GetString("end_time")
  36020. check_time := c.GetString("check_time")
  36021. hospital_code := c.GetString("hospital_code")
  36022. hospital_name := c.GetString("hospital_name")
  36023. adminUser := c.GetAdminUserInfo()
  36024. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36025. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36026. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36027. sick, _ := service.FindSickById(sick_id)
  36028. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36029. if len(hospital_code) == 0 {
  36030. hospital_code = miConfig.Code
  36031. }
  36032. if len(hospital_name) == 0 {
  36033. hospital_name = miConfig.OrgName
  36034. }
  36035. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36036. var res ResultTwo
  36037. var res10265 ResultTwo10265
  36038. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36039. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36040. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36041. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36042. "&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
  36043. resp, requestErr := http.Get(api)
  36044. if requestErr != nil {
  36045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36046. return
  36047. }
  36048. body, ioErr := ioutil.ReadAll(resp.Body)
  36049. if ioErr != nil {
  36050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36052. return
  36053. }
  36054. var respJSON map[string]interface{}
  36055. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36058. return
  36059. }
  36060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36061. result, _ := json.Marshal(respJSON)
  36062. fmt.Println("log")
  36063. fmt.Println(string(result))
  36064. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36065. utils.ErrorLog("解析失败:%v", err)
  36066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36067. return
  36068. }
  36069. res.ErrMsg = res10265.ErrMsg
  36070. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36071. res.Infcode = infocode
  36072. res.Output = res10265.Output
  36073. res.InfRefmsgid = res10265.InfRefmsgid
  36074. } else {
  36075. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36076. if miConfig.Code == "H15049901371" {
  36077. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36078. utils.ErrorLog("解析失败:%v", err)
  36079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36080. return
  36081. }
  36082. res.ErrMsg = res10265.ErrMsg
  36083. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36084. res.Infcode = infocode
  36085. res.Output = res10265.Output
  36086. res.InfRefmsgid = res10265.InfRefmsgid
  36087. } else {
  36088. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36089. utils.ErrorLog("解析失败:%v", err)
  36090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36091. return
  36092. }
  36093. }
  36094. }
  36095. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36096. infoStr := string(Iinfos)
  36097. var rf []*ResultFive
  36098. json.Unmarshal([]byte(infoStr), &rf)
  36099. var insuplc_admdvs string
  36100. var insutype string
  36101. var is390 int = 0
  36102. var is310 int = 0
  36103. var insutypes []*ResultFive
  36104. for _, item := range rf {
  36105. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36106. insutypes = append(insutypes, item)
  36107. }
  36108. }
  36109. if len(insutypes) == 1 {
  36110. insutype = insutypes[0].Insutype
  36111. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36112. } else {
  36113. for _, i := range insutypes {
  36114. if i.Insutype == "390" {
  36115. is390 = 1
  36116. }
  36117. if i.Insutype == "310" {
  36118. is310 = 1
  36119. }
  36120. }
  36121. }
  36122. if is390 == 1 {
  36123. insutype = "390"
  36124. }
  36125. if is310 == 1 {
  36126. insutype = "310"
  36127. }
  36128. if len(insutypes) == 2 {
  36129. insutype = insutype_two
  36130. }
  36131. if len(insutypes) == 0 {
  36132. insutype = "310"
  36133. }
  36134. insutype = insutype_two
  36135. fmt.Println(insutype)
  36136. for _, item := range rf {
  36137. fmt.Println(item.Insutype)
  36138. fmt.Println(insutype)
  36139. if item.Insutype == insutype {
  36140. fmt.Println(item.Insutype)
  36141. fmt.Println(insutype)
  36142. insuplc_admdvs = item.InsuplcAdmdvs
  36143. }
  36144. }
  36145. fmt.Println(insuplc_admdvs)
  36146. var res2 ResultThirteen
  36147. var res10265_2 ResultThirteen10265
  36148. if config.IsOpen == 1 {
  36149. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36150. } else {
  36151. if miConfig.MdtrtareaAdmvs == "150499" {
  36152. //
  36153. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36154. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36155. // "&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
  36156. //resp, requestErr := http.Get(api)
  36157. //if requestErr != nil {
  36158. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36159. // return
  36160. //}
  36161. //
  36162. //body, ioErr := ioutil.ReadAll(resp.Body)
  36163. //if ioErr != nil {
  36164. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36165. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36166. // return
  36167. //}
  36168. //var respJSON map[string]interface{}
  36169. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36170. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36171. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36172. // return
  36173. //}
  36174. //
  36175. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36176. //result, _ := json.Marshal(respJSON)
  36177. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36178. // utils.ErrorLog("解析失败:%v", err)
  36179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36180. // return
  36181. //}
  36182. //infocode = resThree.Infcode
  36183. //result, _ := json.Marshal(respJSON)
  36184. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36185. // utils.ErrorLog("解析失败:%v", err)
  36186. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36187. // return
  36188. //}
  36189. //
  36190. //resThree.ErrMsg = resThree10265.ErrMsg
  36191. //
  36192. //resThree.Output = resThree10265.Output
  36193. //
  36194. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36195. //
  36196. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36197. //
  36198. } else {
  36199. 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)
  36200. var dat map[string]interface{}
  36201. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36202. fmt.Println(dat)
  36203. } else {
  36204. fmt.Println(err)
  36205. }
  36206. userJSONBytes, _ := json.Marshal(dat)
  36207. if miConfig.Code == "H15049901371" {
  36208. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36209. utils.ErrorLog("解析失败:%v", err)
  36210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36211. return
  36212. }
  36213. res2.ErrMsg = res10265_2.ErrMsg
  36214. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36215. res2.Infcode = infocode
  36216. res2.Output = res10265_2.Output
  36217. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36218. } else {
  36219. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36220. utils.ErrorLog("解析失败:%v", err)
  36221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36222. return
  36223. }
  36224. }
  36225. }
  36226. }
  36227. if res2.Infcode == 0 {
  36228. psnResult := &models.GdybPsnNcdsRecord{
  36229. UserOrgId: adminUser.CurrentOrgId,
  36230. PatientId: patient.ID,
  36231. PsnNo: psn_no,
  36232. DoctorId: doctor.AdminUserId,
  36233. DepartmentId: department_id,
  36234. SickType: sick_id,
  36235. Insutype: insutype,
  36236. Ctime: time.Now().Unix(),
  36237. Mtime: time.Now().Unix(),
  36238. Status: 1,
  36239. IsCancel: 1,
  36240. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36241. }
  36242. service.CreatePsnNCDSRecord(psnResult)
  36243. c.ServeSuccessJSON(map[string]interface{}{
  36244. "failed_code": 0,
  36245. "msg": "备案成功",
  36246. "result": psnResult,
  36247. })
  36248. } else {
  36249. c.ServeSuccessJSON(map[string]interface{}{
  36250. "failed_code": -10,
  36251. "msg": res2.ErrMsg,
  36252. })
  36253. return
  36254. }
  36255. }
  36256. }
  36257. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36258. id, _ := c.GetInt64("id")
  36259. admin_user_id, _ := c.GetInt64("admin_user_id")
  36260. adminUser := c.GetAdminUserInfo()
  36261. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36262. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36263. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36264. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36265. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36266. //var user_name string
  36267. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36268. //if role.ID == 0 {
  36269. // user_name = "xxx"
  36270. //} else {
  36271. // user_name = role.UserName
  36272. //}
  36273. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36274. if psn_record.ID == 0 {
  36275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36276. return
  36277. }
  36278. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36279. var res ResultTwo
  36280. var res10265 ResultTwo10265
  36281. if miConfig.Code == "H15049901371" {
  36282. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36283. utils.ErrorLog("解析失败:%v", err)
  36284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36285. return
  36286. }
  36287. res.ErrMsg = res10265.ErrMsg
  36288. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36289. res.Infcode = infocode
  36290. res.Output = res10265.Output
  36291. res.InfRefmsgid = res10265.InfRefmsgid
  36292. } else {
  36293. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36294. utils.ErrorLog("解析失败:%v", err)
  36295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36296. return
  36297. }
  36298. }
  36299. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36300. infoStr := string(Iinfos)
  36301. var rf []*ResultFive
  36302. json.Unmarshal([]byte(infoStr), &rf)
  36303. var insuplc_admdvs string
  36304. var insutype string
  36305. var is390 int = 0
  36306. var is310 int = 0
  36307. var insutypes []*ResultFive
  36308. for _, item := range rf {
  36309. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36310. insutypes = append(insutypes, item)
  36311. }
  36312. }
  36313. if len(insutypes) == 1 {
  36314. insutype = insutypes[0].Insutype
  36315. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36316. } else {
  36317. for _, i := range insutypes {
  36318. if i.Insutype == "390" {
  36319. is390 = 1
  36320. }
  36321. if i.Insutype == "310" {
  36322. is310 = 1
  36323. }
  36324. }
  36325. }
  36326. if is390 == 1 {
  36327. insutype = "390"
  36328. }
  36329. if is310 == 1 {
  36330. insutype = "310"
  36331. }
  36332. if len(insutypes) == 0 {
  36333. insutype = "310"
  36334. }
  36335. insutype = psn_record.Insutype
  36336. for _, item := range rf {
  36337. if item.Insutype == insutype {
  36338. insuplc_admdvs = item.InsuplcAdmdvs
  36339. }
  36340. }
  36341. if config.IsOpen == 1 {
  36342. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36343. var dat map[string]interface{}
  36344. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36345. fmt.Println(dat)
  36346. } else {
  36347. fmt.Println(err)
  36348. }
  36349. userJSONBytes, _ := json.Marshal(dat)
  36350. var res ResultFourteen
  36351. var res10265 ResultFourteen10265
  36352. if miConfig.Code == "H15049901371" {
  36353. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36354. utils.ErrorLog("解析失败:%v", err)
  36355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36356. return
  36357. }
  36358. res.ErrMsg = res10265.ErrMsg
  36359. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36360. res.Infcode = infocode
  36361. res.Output = res10265.Output
  36362. res.InfRefmsgid = res10265.InfRefmsgid
  36363. } else {
  36364. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36365. utils.ErrorLog("解析失败:%v", err)
  36366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36367. return
  36368. }
  36369. }
  36370. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36371. // utils.ErrorLog("解析失败:%v", err)
  36372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36373. // return
  36374. //}
  36375. if res.Infcode == 0 {
  36376. psn_record.IsCancel = 2
  36377. service.CreatePsnNCDSRecord(&psn_record)
  36378. c.ServeSuccessJSON(map[string]interface{}{
  36379. "failed_code": 0,
  36380. "msg": "撤销备案成功",
  36381. })
  36382. } else {
  36383. c.ServeSuccessJSON(map[string]interface{}{
  36384. "failed_code": -10,
  36385. "msg": res.ErrMsg,
  36386. })
  36387. return
  36388. }
  36389. }
  36390. }
  36391. func (c *HisApiController) TestTest() {
  36392. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36393. fmt.Println(patient.Iinfo)
  36394. }
  36395. type CustomData struct {
  36396. MsgId string
  36397. PsnNo string
  36398. Info string
  36399. }
  36400. func (c *HisApiController) ReversalData() {
  36401. var customData []*CustomData
  36402. custom := &CustomData{
  36403. MsgId: "H44022900158202103301714472004",
  36404. PsnNo: "44020000001101329945",
  36405. Info: "2207",
  36406. }
  36407. customData = append(customData, custom)
  36408. custom1 := &CustomData{
  36409. MsgId: "H4402290015820210330172057803",
  36410. PsnNo: "44020000001101161813",
  36411. Info: "2207",
  36412. }
  36413. customData = append(customData, custom1)
  36414. custom2 := &CustomData{
  36415. MsgId: "H44022900158202103301705198813",
  36416. PsnNo: "44190000133097375417",
  36417. Info: "2207",
  36418. }
  36419. customData = append(customData, custom2)
  36420. custom3 := &CustomData{
  36421. MsgId: "H44022900158202103301715524756",
  36422. PsnNo: "44020000001100187221",
  36423. Info: "2207",
  36424. }
  36425. customData = append(customData, custom3)
  36426. custom4 := &CustomData{
  36427. MsgId: "H44022900158202103301730376224",
  36428. PsnNo: "44020000001101959155",
  36429. Info: "2207",
  36430. }
  36431. customData = append(customData, custom4)
  36432. custom5 := &CustomData{
  36433. MsgId: "H44022900158202103301748008725",
  36434. PsnNo: "44020000001104246641",
  36435. Info: "2207",
  36436. }
  36437. customData = append(customData, custom5)
  36438. custom6 := &CustomData{
  36439. MsgId: "H44022900158202103301718096755",
  36440. PsnNo: "44020000001102211860",
  36441. Info: "2207",
  36442. }
  36443. customData = append(customData, custom6)
  36444. custom7 := &CustomData{
  36445. MsgId: "H44022900158202103301736551640",
  36446. PsnNo: "44020000001102687718",
  36447. Info: "2207",
  36448. }
  36449. customData = append(customData, custom7)
  36450. custom8 := &CustomData{
  36451. MsgId: "H44022900158202103301743097676",
  36452. PsnNo: "44020000001102127785",
  36453. Info: "2207",
  36454. }
  36455. customData = append(customData, custom8)
  36456. custom9 := &CustomData{
  36457. MsgId: "H44022900158202103301712304203",
  36458. PsnNo: "44020000001101518097",
  36459. Info: "2207",
  36460. }
  36461. customData = append(customData, custom9)
  36462. custom10 := &CustomData{
  36463. MsgId: "H44022900158202103301738448785",
  36464. PsnNo: "44020000001100500813",
  36465. Info: "2207",
  36466. }
  36467. customData = append(customData, custom10)
  36468. custom11 := &CustomData{
  36469. MsgId: "H44022900158202103301732455843",
  36470. PsnNo: "44020000001102690557",
  36471. Info: "2207",
  36472. }
  36473. customData = append(customData, custom11)
  36474. custom12 := &CustomData{
  36475. MsgId: "H44022900158202103301745421708",
  36476. PsnNo: "44020000001102211928",
  36477. Info: "2207",
  36478. }
  36479. customData = append(customData, custom12)
  36480. custom1212 := &CustomData{
  36481. MsgId: "H440229001582021033017351627",
  36482. PsnNo: "44020000001102481733",
  36483. Info: "2207",
  36484. }
  36485. customData = append(customData, custom1212)
  36486. custom13 := &CustomData{
  36487. MsgId: "H44022900158202103301740327951",
  36488. PsnNo: "44020000001103174866",
  36489. Info: "2207",
  36490. }
  36491. customData = append(customData, custom13)
  36492. custom14 := &CustomData{
  36493. MsgId: "H4402290015820210330174922668",
  36494. PsnNo: "44020000001102927272",
  36495. Info: "2207",
  36496. }
  36497. customData = append(customData, custom14)
  36498. custom15 := &CustomData{
  36499. MsgId: "H44022900158202103301752362273",
  36500. PsnNo: "44020000001102942890",
  36501. Info: "2207",
  36502. }
  36503. customData = append(customData, custom15)
  36504. custom16 := &CustomData{
  36505. MsgId: "H44022900158202103301751082917",
  36506. PsnNo: "44020000001101662162",
  36507. Info: "2207",
  36508. }
  36509. customData = append(customData, custom16)
  36510. custom17 := &CustomData{
  36511. MsgId: "H44022900158202103301754147728",
  36512. PsnNo: "44020000000229014511",
  36513. Info: "2207",
  36514. }
  36515. customData = append(customData, custom17)
  36516. adminUser := c.GetAdminUserInfo()
  36517. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36518. for _, item := range customData {
  36519. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36520. fmt.Println(result)
  36521. }
  36522. }
  36523. func (c *HisApiController) GetAllopatry() {
  36524. year := c.GetString("year")
  36525. month := c.GetString("month")
  36526. admin_user_id, _ := c.GetInt64("admin_user_id")
  36527. adminUser := c.GetAdminUserInfo()
  36528. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36529. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36530. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36531. var dat map[string]interface{}
  36532. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36533. fmt.Println(dat)
  36534. } else {
  36535. fmt.Println(err)
  36536. }
  36537. userJSONBytes, _ := json.Marshal(dat)
  36538. var res models.Result9001
  36539. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36540. utils.ErrorLog("解析失败:%v", err)
  36541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36542. return
  36543. }
  36544. fmt.Println(res.Output.Signinoutb)
  36545. fmt.Println(res.Output.Signinoutb.SignNo)
  36546. fmt.Println(string(userJSONBytes))
  36547. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36548. var dat3 map[string]interface{}
  36549. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  36550. fmt.Println(dat3)
  36551. } else {
  36552. fmt.Println(err)
  36553. }
  36554. userJSONBytes3, _ := json.Marshal(dat3)
  36555. var res3 models.Result3260
  36556. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  36557. utils.ErrorLog("解析失败:%v", err)
  36558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36559. return
  36560. }
  36561. var curpage int
  36562. var pagesize int = 100
  36563. var start int = 1
  36564. //var stop int
  36565. //pagecount := 10
  36566. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  36567. var res22 []models.Result3260
  36568. for curpage = 1; curpage <= pagecount; curpage++ {
  36569. if curpage == 1 {
  36570. start = 0
  36571. } else {
  36572. start = (curpage-1)*pagesize + 1
  36573. }
  36574. fmt.Println(start)
  36575. //stop = curpage * pagesize
  36576. //if stop > int(res3.Output.Totalrow) {
  36577. // stop =int(res3.Output.Totalrow)
  36578. //}
  36579. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  36580. var dat2 map[string]interface{}
  36581. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36582. fmt.Println(dat)
  36583. } else {
  36584. fmt.Println(err)
  36585. }
  36586. userJSONBytes2, _ := json.Marshal(dat2)
  36587. var res2 models.Result3260
  36588. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36589. utils.ErrorLog("解析失败:%v", err)
  36590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36591. return
  36592. }
  36593. if res2.Infcode == 0 {
  36594. res22 = append(res22, res2)
  36595. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36596. //var dat2 map[string]interface{}
  36597. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36598. // fmt.Println(dat)
  36599. //} else {
  36600. // fmt.Println(err)
  36601. //}
  36602. //c.ServeSuccessJSON(map[string]interface{}{
  36603. // "list": res2.Output.Data,
  36604. //})
  36605. //continue
  36606. }
  36607. }
  36608. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36609. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  36610. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  36611. //var dat2 map[string]interface{}
  36612. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36613. // fmt.Println(dat)
  36614. //} else {
  36615. // fmt.Println(err)
  36616. //}
  36617. //userJSONBytes2, _ := json.Marshal(dat2)
  36618. //var res2 models.Result3260
  36619. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36620. // utils.ErrorLog("解析失败:%v", err)
  36621. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36622. // return
  36623. //}
  36624. //if res2.Infcode == 0 {
  36625. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36626. // var dat2 map[string]interface{}
  36627. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  36628. // fmt.Println(dat)
  36629. // } else {
  36630. // fmt.Println(err)
  36631. // }
  36632. // c.ServeSuccessJSON(map[string]interface{}{
  36633. // "list": res2.Output.Data,
  36634. // })
  36635. //}
  36636. }
  36637. func (c *HisApiController) ComfirmAllopatry() {
  36638. year := c.GetString("year")
  36639. month := c.GetString("month")
  36640. admin_user_id, _ := c.GetInt64("admin_user_id")
  36641. adminUser := c.GetAdminUserInfo()
  36642. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36643. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36644. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36645. var dat map[string]interface{}
  36646. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36647. fmt.Println(dat)
  36648. } else {
  36649. fmt.Println(err)
  36650. }
  36651. userJSONBytes, _ := json.Marshal(dat)
  36652. var res models.Result9001
  36653. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36654. utils.ErrorLog("解析失败:%v", err)
  36655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36656. return
  36657. }
  36658. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  36659. var dat2 map[string]interface{}
  36660. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  36661. fmt.Println(dat)
  36662. } else {
  36663. fmt.Println(err)
  36664. }
  36665. userJSONBytes2, _ := json.Marshal(dat2)
  36666. var res2 models.Result3260
  36667. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  36668. utils.ErrorLog("解析失败:%v", err)
  36669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36670. return
  36671. }
  36672. //if res2.Infcode == 0 {
  36673. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  36674. // var dat map[string]interface{}
  36675. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36676. // fmt.Println(dat)
  36677. // } else {
  36678. // fmt.Println(err)
  36679. // }
  36680. // userJSONBytes, _ := json.Marshal(dat)
  36681. // var res3 models.Result3261
  36682. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  36683. // utils.ErrorLog("解析失败:%v", err)
  36684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36685. // return
  36686. // }
  36687. //
  36688. // if res3.Infcode == 0 {
  36689. // record := &models.HisYidiClearRecord{
  36690. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  36691. // Ctime: time.Now().Unix(),
  36692. // Mtime: time.Now().Unix(),
  36693. // Status: 1,
  36694. // MsgId: msgId,
  36695. // }
  36696. // service.SaveClearRecord(record)
  36697. // c.ServeSuccessJSON(map[string]interface{}{
  36698. // "msg": "提取成功",
  36699. // })
  36700. // }
  36701. //}
  36702. }
  36703. func (c *HisApiController) RefundAllopatry() {
  36704. year := c.GetString("year")
  36705. month := c.GetString("month")
  36706. //id, _ := c.GetInt64("id")
  36707. admin_user_id, _ := c.GetInt64("admin_user_id")
  36708. adminUser := c.GetAdminUserInfo()
  36709. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36710. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36711. //record, _ := service.GetClearRecordById(id)
  36712. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  36713. var dat map[string]interface{}
  36714. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  36715. fmt.Println(dat)
  36716. } else {
  36717. fmt.Println(err)
  36718. }
  36719. userJSONBytes, _ := json.Marshal(dat)
  36720. var res models.Result9001
  36721. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36722. utils.ErrorLog("解析失败:%v", err)
  36723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36724. return
  36725. }
  36726. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  36727. var dat2 map[string]interface{}
  36728. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36729. fmt.Println(dat)
  36730. } else {
  36731. fmt.Println(err)
  36732. }
  36733. userJSONBytes2, _ := json.Marshal(dat2)
  36734. var empty ResultFourteen
  36735. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  36736. utils.ErrorLog("解析失败:%v", err)
  36737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36738. return
  36739. }
  36740. if empty.Infcode == 0 {
  36741. c.ServeSuccessJSON(map[string]interface{}{
  36742. "msg": "撤销成功",
  36743. })
  36744. return
  36745. }
  36746. }
  36747. func (c *HisApiController) ReversalOtherData() {
  36748. var customData []*CustomData
  36749. custom := &CustomData{
  36750. MsgId: "H44022900158202103301714472004",
  36751. PsnNo: "44020000001101329945",
  36752. Info: "2208",
  36753. }
  36754. customData = append(customData, custom)
  36755. custom1 := &CustomData{
  36756. MsgId: "H4402290015820210330172057803",
  36757. PsnNo: "44020000001101161813",
  36758. Info: "2208",
  36759. }
  36760. customData = append(customData, custom1)
  36761. custom2 := &CustomData{
  36762. MsgId: "H44022900158202103301705198813",
  36763. PsnNo: "44190000133097375417",
  36764. Info: "2208",
  36765. }
  36766. customData = append(customData, custom2)
  36767. custom3 := &CustomData{
  36768. MsgId: "H44022900158202103301715524756",
  36769. PsnNo: "44020000001100187221",
  36770. Info: "2208",
  36771. }
  36772. customData = append(customData, custom3)
  36773. custom4 := &CustomData{
  36774. MsgId: "H44022900158202103301730376224",
  36775. PsnNo: "44020000001101959155",
  36776. Info: "2208",
  36777. }
  36778. customData = append(customData, custom4)
  36779. custom5 := &CustomData{
  36780. MsgId: "H44022900158202103301748008725",
  36781. PsnNo: "44020000001104246641",
  36782. Info: "2208",
  36783. }
  36784. customData = append(customData, custom5)
  36785. custom6 := &CustomData{
  36786. MsgId: "H44022900158202103301718096755",
  36787. PsnNo: "44020000001102211860",
  36788. Info: "2208",
  36789. }
  36790. customData = append(customData, custom6)
  36791. custom7 := &CustomData{
  36792. MsgId: "H44022900158202103301736551640",
  36793. PsnNo: "44020000001102687718",
  36794. Info: "2208",
  36795. }
  36796. customData = append(customData, custom7)
  36797. custom8 := &CustomData{
  36798. MsgId: "H44022900158202103301743097676",
  36799. PsnNo: "44020000001102127785",
  36800. Info: "2208",
  36801. }
  36802. customData = append(customData, custom8)
  36803. custom9 := &CustomData{
  36804. MsgId: "H44022900158202103301712304203",
  36805. PsnNo: "44020000001101518097",
  36806. Info: "2208",
  36807. }
  36808. customData = append(customData, custom9)
  36809. custom10 := &CustomData{
  36810. MsgId: "H44022900158202103301738448785",
  36811. PsnNo: "44020000001100500813",
  36812. Info: "2208",
  36813. }
  36814. customData = append(customData, custom10)
  36815. custom11 := &CustomData{
  36816. MsgId: "H44022900158202103301732455843",
  36817. PsnNo: "44020000001102690557",
  36818. Info: "2208",
  36819. }
  36820. customData = append(customData, custom11)
  36821. custom12 := &CustomData{
  36822. MsgId: "H44022900158202103301745421708",
  36823. PsnNo: "44020000001102211928",
  36824. Info: "2208",
  36825. }
  36826. customData = append(customData, custom12)
  36827. custom1212 := &CustomData{
  36828. MsgId: "H440229001582021033017351627",
  36829. PsnNo: "44020000001102481733",
  36830. Info: "2208",
  36831. }
  36832. customData = append(customData, custom1212)
  36833. custom13 := &CustomData{
  36834. MsgId: "H44022900158202103301740327951",
  36835. PsnNo: "44020000001103174866",
  36836. Info: "2208",
  36837. }
  36838. customData = append(customData, custom13)
  36839. custom14 := &CustomData{
  36840. MsgId: "H4402290015820210330174922668",
  36841. PsnNo: "44020000001102927272",
  36842. Info: "2208",
  36843. }
  36844. customData = append(customData, custom14)
  36845. custom15 := &CustomData{
  36846. MsgId: "H44022900158202103301752362273",
  36847. PsnNo: "44020000001102942890",
  36848. Info: "2208",
  36849. }
  36850. customData = append(customData, custom15)
  36851. custom16 := &CustomData{
  36852. MsgId: "H44022900158202103301751082917",
  36853. PsnNo: "44020000001101662162",
  36854. Info: "2208",
  36855. }
  36856. customData = append(customData, custom16)
  36857. custom17 := &CustomData{
  36858. MsgId: "H44022900158202103301754147728",
  36859. PsnNo: "44020000000229014511",
  36860. Info: "2208",
  36861. }
  36862. customData = append(customData, custom17)
  36863. adminUser := c.GetAdminUserInfo()
  36864. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36865. for _, item := range customData {
  36866. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36867. fmt.Println(result)
  36868. }
  36869. }
  36870. func PathExists(path string) (bool, error) {
  36871. _, err := os.Stat(path)
  36872. if err == nil {
  36873. return true, nil
  36874. }
  36875. if os.IsNotExist(err) {
  36876. return false, nil
  36877. }
  36878. return false, err
  36879. }
  36880. // 创建文件夹
  36881. func Mkdir(dir string) {
  36882. // 创建文件夹
  36883. exist, err := PathExists(dir)
  36884. if err != nil {
  36885. fmt.Println(err.Error())
  36886. } else {
  36887. if exist {
  36888. fmt.Println(dir + "文件夹已存在!")
  36889. } else {
  36890. // 文件夹名称,权限
  36891. err := os.Mkdir(dir, os.ModePerm)
  36892. if err != nil {
  36893. fmt.Println(dir+"文件夹创建失败:", err.Error())
  36894. } else {
  36895. fmt.Println(dir + "文件夹创建成功!")
  36896. }
  36897. }
  36898. }
  36899. }
  36900. // 压缩文件
  36901. func Zip(srcFile string, destZip string) error {
  36902. zipfile, err := os.Create(destZip)
  36903. if err != nil {
  36904. return err
  36905. }
  36906. defer zipfile.Close()
  36907. archive := zip.NewWriter(zipfile)
  36908. defer archive.Close()
  36909. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  36910. if err != nil {
  36911. return err
  36912. }
  36913. header, err := zip.FileInfoHeader(info)
  36914. if err != nil {
  36915. return err
  36916. }
  36917. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  36918. // header.Name = path
  36919. if info.IsDir() {
  36920. header.Name += "/"
  36921. } else {
  36922. header.Method = zip.Deflate
  36923. }
  36924. writer, err := archive.CreateHeader(header)
  36925. if err != nil {
  36926. return err
  36927. }
  36928. if !info.IsDir() {
  36929. file, err := os.Open(path)
  36930. if err != nil {
  36931. return err
  36932. }
  36933. defer file.Close()
  36934. _, err = io.Copy(writer, file)
  36935. }
  36936. return err
  36937. })
  36938. return err
  36939. }
  36940. func ReadFile(filePath string) []byte {
  36941. f, err := os.Open(filePath)
  36942. if err != nil {
  36943. fmt.Println("read file fail", err)
  36944. return nil
  36945. }
  36946. defer f.Close()
  36947. fd, err := ioutil.ReadAll(f)
  36948. if err != nil {
  36949. fmt.Println("read to fd fail", err)
  36950. return nil
  36951. }
  36952. return fd
  36953. }
  36954. func saveLogq(result string, request string, infno string, desc string) {
  36955. dir := "日志"
  36956. utils.Mkdir(dir)
  36957. month := time.Unix(1557042972, 0).Format("1")
  36958. year := time.Now().Format("2006")
  36959. month = time.Now().Format("01")
  36960. day := time.Now().Format("02")
  36961. hour := time.Now().Format("15")
  36962. min := time.Now().Format("04")
  36963. sec := time.Now().Format("05")
  36964. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  36965. file := year + month + day + "_log"
  36966. file_name := file + ".txt"
  36967. file_path := "日志" + "/" + file_name
  36968. exist, _ := utils.PathExists(file_path)
  36969. if exist { //存在
  36970. fmt.Println("存在")
  36971. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  36972. if err != nil {
  36973. fmt.Println("read fail")
  36974. }
  36975. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  36976. n, _ := f.Seek(0, 2)
  36977. _, err = f.WriteAt([]byte(content), n)
  36978. } else { //不存在
  36979. fmt.Println("文件不存在,创建文件")
  36980. f, err := os.Create("日志" + "/" + file_name)
  36981. defer f.Close()
  36982. if err != nil {
  36983. } else {
  36984. _, err = f.Write([]byte("记录日志"))
  36985. }
  36986. }
  36987. }
  36988. func saveLog(result string, request string, infno string, desc string) {
  36989. org_id, _ := beego.AppConfig.Int64("org_id")
  36990. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  36991. dir := miConfig.OrgName + "日志"
  36992. utils.Mkdir(dir)
  36993. month := time.Unix(1557042972, 0).Format("1")
  36994. year := time.Now().Format("2006")
  36995. month = time.Now().Format("01")
  36996. day := time.Now().Format("02")
  36997. hour := time.Now().Format("15")
  36998. min := time.Now().Format("04")
  36999. sec := time.Now().Format("05")
  37000. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37001. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37002. file_name := file + ".txt"
  37003. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37004. exist, _ := utils.PathExists(file_path)
  37005. if exist { //存在
  37006. fmt.Println("存在")
  37007. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37008. if err != nil {
  37009. fmt.Println("read fail")
  37010. }
  37011. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37012. n, _ := f.Seek(0, 2)
  37013. _, err = f.WriteAt([]byte(content), n)
  37014. } else { //不存在
  37015. fmt.Println("文件不存在,创建文件")
  37016. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37017. defer f.Close()
  37018. if err != nil {
  37019. } else {
  37020. _, err = f.Write([]byte("记录日志"))
  37021. }
  37022. }
  37023. }
  37024. type Charset string
  37025. const (
  37026. UTF8 = Charset("UTF-8")
  37027. GB18030 = Charset("GB18030")
  37028. )
  37029. func ConvertToString(src string, srcCode string, tagCode string) string {
  37030. srcCoder := mahonia.NewDecoder(srcCode)
  37031. srcResult := srcCoder.ConvertString(src)
  37032. tagCoder := mahonia.NewDecoder(tagCode)
  37033. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37034. result := string(cdata)
  37035. return result
  37036. }
  37037. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37038. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37039. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37040. var token string
  37041. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37042. var api string
  37043. if miConfig.MdtrtareaAdmvs == "320921" {
  37044. 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 +
  37045. "&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
  37046. fmt.Println(api)
  37047. } else {
  37048. 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 +
  37049. "&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
  37050. }
  37051. resp, requestErr := http.Get(api)
  37052. if requestErr != nil {
  37053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37054. return ""
  37055. }
  37056. body, ioErr := ioutil.ReadAll(resp.Body)
  37057. if ioErr != nil {
  37058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37060. return ""
  37061. }
  37062. var respJSON map[string]interface{}
  37063. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37066. return ""
  37067. }
  37068. var status string
  37069. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37070. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37071. var res ResultTwo //1101结果
  37072. var res10265 ResultTwo10265 //1101结果
  37073. if status == "0" { //读卡成功
  37074. var card_info string //卡信息
  37075. var busi_card_info string
  37076. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37077. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37078. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37079. fmt.Println(card_info)
  37080. fmt.Println(busi_card_info)
  37081. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37082. result, _ := json.Marshal(respJSON)
  37083. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37084. utils.ErrorLog("解析失败:%v", err)
  37085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37086. return ""
  37087. }
  37088. res.ErrMsg = res10265.ErrMsg
  37089. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37090. res.Infcode = infocode
  37091. res.Output = res10265.Output
  37092. res.InfRefmsgid = res10265.InfRefmsgid
  37093. if res.Infcode == 0 {
  37094. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37095. if err == gorm.ErrRecordNotFound {
  37096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37097. return ""
  37098. } else if err != nil {
  37099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37100. return ""
  37101. } else {
  37102. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37103. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37104. infoStr := string(Iinfos)
  37105. idetinfoStr := string(Idetinfos)
  37106. psn := &models.HisPsn{
  37107. PsnNo: res.Output.Baseinfo.PsnNo,
  37108. PatientId: patient.ID,
  37109. Certno: res.Output.Baseinfo.Certno,
  37110. Gend: res.Output.Baseinfo.Gend,
  37111. Naty: res.Output.Baseinfo.Naty,
  37112. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37113. PsnName: res.Output.Baseinfo.PsnName,
  37114. Idetinfo: idetinfoStr,
  37115. Insuinfo: infoStr,
  37116. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37117. CardInfo: card_info,
  37118. VerifyNumber: token,
  37119. }
  37120. service.CreateHisPsn(psn)
  37121. return token
  37122. }
  37123. }
  37124. } else {
  37125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37126. return ""
  37127. }
  37128. } else { //读卡失败
  37129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37130. return ""
  37131. }
  37132. return token
  37133. }
  37134. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37135. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37136. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37137. var token string
  37138. var api string
  37139. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37140. "&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
  37141. fmt.Println(api)
  37142. resp, requestErr := http.Get(api)
  37143. if requestErr != nil {
  37144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37145. return ""
  37146. }
  37147. body, ioErr := ioutil.ReadAll(resp.Body)
  37148. if ioErr != nil {
  37149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37151. return ""
  37152. }
  37153. var respJSON map[string]interface{}
  37154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37157. return ""
  37158. }
  37159. var status string
  37160. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37161. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37162. var res ResultTwo //1101结果
  37163. if status == "1" { //读卡成功
  37164. var card_info string //卡信息
  37165. var busi_card_info string
  37166. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37167. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37168. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37169. fmt.Println(card_info)
  37170. fmt.Println(busi_card_info)
  37171. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37172. result, _ := json.Marshal(respJSON)
  37173. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37174. utils.ErrorLog("解析失败:%v", err)
  37175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37176. return ""
  37177. }
  37178. if res.Infcode == 0 {
  37179. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37180. if err == gorm.ErrRecordNotFound {
  37181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37182. return ""
  37183. } else if err != nil {
  37184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37185. return ""
  37186. } else {
  37187. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37188. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37189. infoStr := string(Iinfos)
  37190. idetinfoStr := string(Idetinfos)
  37191. psn := &models.HisPsn{
  37192. PsnNo: res.Output.Baseinfo.PsnNo,
  37193. PatientId: patient.ID,
  37194. Certno: res.Output.Baseinfo.Certno,
  37195. Gend: res.Output.Baseinfo.Gend,
  37196. Naty: res.Output.Baseinfo.Naty,
  37197. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37198. PsnName: res.Output.Baseinfo.PsnName,
  37199. Idetinfo: idetinfoStr,
  37200. Insuinfo: infoStr,
  37201. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37202. CardInfo: card_info,
  37203. VerifyNumber: token,
  37204. }
  37205. service.CreateHisPsn(psn)
  37206. return token
  37207. }
  37208. }
  37209. } else {
  37210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37211. return ""
  37212. }
  37213. return token
  37214. }
  37215. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37216. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37217. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37218. var token string
  37219. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37220. var api string
  37221. if miConfig.MdtrtareaAdmvs == "320921" {
  37222. 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 +
  37223. "&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
  37224. fmt.Println(api)
  37225. } else {
  37226. 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 +
  37227. "&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
  37228. }
  37229. resp, requestErr := http.Get(api)
  37230. if requestErr != nil {
  37231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37232. return ""
  37233. }
  37234. body, ioErr := ioutil.ReadAll(resp.Body)
  37235. if ioErr != nil {
  37236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37238. return ""
  37239. }
  37240. var respJSON map[string]interface{}
  37241. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37244. return ""
  37245. }
  37246. var status string
  37247. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37248. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37249. var res ResultTwo //1101结果
  37250. var res10265 ResultTwo10265 //1101结果
  37251. if status == "0" { //读卡成功
  37252. var card_info string //卡信息
  37253. var busi_card_info string
  37254. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37255. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37256. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37257. fmt.Println(card_info)
  37258. fmt.Println(busi_card_info)
  37259. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37260. result, _ := json.Marshal(respJSON)
  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. if res.Infcode == 0 {
  37272. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37273. if err == gorm.ErrRecordNotFound {
  37274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37275. return ""
  37276. } else if err != nil {
  37277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37278. return ""
  37279. } else {
  37280. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37281. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37282. infoStr := string(Iinfos)
  37283. idetinfoStr := string(Idetinfos)
  37284. psn := &models.HisPsn{
  37285. PsnNo: res.Output.Baseinfo.PsnNo,
  37286. PatientId: patient.ID,
  37287. Certno: res.Output.Baseinfo.Certno,
  37288. Gend: res.Output.Baseinfo.Gend,
  37289. Naty: res.Output.Baseinfo.Naty,
  37290. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37291. PsnName: res.Output.Baseinfo.PsnName,
  37292. Idetinfo: idetinfoStr,
  37293. Insuinfo: infoStr,
  37294. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37295. CardInfo: card_info,
  37296. VerifyNumber: token,
  37297. }
  37298. service.CreateHisPsn(psn)
  37299. return token
  37300. }
  37301. }
  37302. } else {
  37303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37304. return ""
  37305. }
  37306. } else { //读卡失败
  37307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37308. return ""
  37309. }
  37310. return token
  37311. }
  37312. func DeleteExtraSpaceTwo(s string) string {
  37313. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37314. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37315. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37316. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37317. s2 := make([]byte, len(s1)) //定义字符数组切片
  37318. copy(s2, s1) //将字符串复制到切片
  37319. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37320. for len(spc_index) > 0 { //找到适配项
  37321. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37322. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37323. }
  37324. return string(s2)
  37325. }
  37326. func Remove0000(s string) string {
  37327. str := make([]rune, 0, len(s))
  37328. for _, v := range []rune(s) {
  37329. if v == 0 {
  37330. continue
  37331. }
  37332. str = append(str, v)
  37333. }
  37334. return string(str)
  37335. }
  37336. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37337. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37338. readCard := DllDef.MustFindProc("EcQuery")
  37339. pCardInfo := make([]byte, 8192)
  37340. pBusiCardInfo := make([]byte, 8192)
  37341. data := make(map[string]interface{})
  37342. //pData := make(map[string]interface{})
  37343. inputData := make(map[string]interface{})
  37344. inputData["orgId"] = code
  37345. inputData["businessType"] = "01101"
  37346. inputData["operatorId"] = operator_id
  37347. inputData["operatorName"] = operator_name
  37348. inputData["officeId"] = "001"
  37349. inputData["officeName"] = "血透室"
  37350. //
  37351. data["data"] = inputData
  37352. data["transType"] = "ec.query"
  37353. data["orgId"] = code
  37354. bytesData, _ := json.Marshal(data)
  37355. pCardInfo = bytesData
  37356. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37357. fmt.Println(ret2)
  37358. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37359. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37360. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37361. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37362. if ret2 != 0 {
  37363. return "", ""
  37364. }
  37365. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37366. }
  37367. func DeleteExtraSpace(s string) string {
  37368. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37369. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37370. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37371. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37372. s2 := make([]byte, len(s1)) //定义字符数组切片
  37373. copy(s2, s1) //将字符串复制到切片
  37374. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37375. for len(spc_index) > 0 { //找到适配项
  37376. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37377. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37378. }
  37379. return string(s2)
  37380. }
  37381. // 对账
  37382. func (c *HisApiController) Post3202() {
  37383. start_time := c.GetString("start_time")
  37384. end_time := c.GetString("end_time")
  37385. //insutype := c.GetString("insutype")
  37386. clr_type := c.GetString("clr_type")
  37387. clr_org := c.GetString("clr_optins")
  37388. admin_user_id, _ := c.GetInt64("admin_user_id")
  37389. adminUser := c.GetAdminUserInfo()
  37390. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37391. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37392. if len(clr_org) == 0 {
  37393. clr_org = miConfig.MdtrtareaAdmvs
  37394. }
  37395. timeLayout := "2006-01-02"
  37396. loc, _ := time.LoadLocation("Local")
  37397. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37398. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37399. var orders []*models.HisOrder
  37400. if clr_org == "421300" {
  37401. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37402. } else if clr_org == "420902" {
  37403. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37404. } else {
  37405. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37406. }
  37407. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37408. //fixmedins_setl_cnt := int64(len(orders))
  37409. var medfee_sumamt float64
  37410. var acct_pay float64
  37411. var fund_pay_sumamt float64
  37412. for _, item := range orders {
  37413. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37414. acct_pay = acct_pay + item.AcctPay
  37415. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37416. }
  37417. //var medfee_sumamt_two float64
  37418. //var acct_pay_two float64
  37419. //var fund_pay_sumamt_two float64
  37420. //for _, item := range orders_two {
  37421. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37422. // acct_pay_two = acct_pay_two + item.AcctPay
  37423. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37424. //}
  37425. //var user_name string
  37426. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37427. //if role.ID == 0 {
  37428. // user_name = "xxx"
  37429. //} else {
  37430. // user_name = role.UserName
  37431. //}
  37432. var res ResultSix
  37433. if config.IsOpen == 1 {
  37434. var bps []*models.BusinessParamsTwo
  37435. var bp models.BusinessParamsTwo
  37436. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37437. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37438. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37439. bp.MedfeeSumamt = medfee_sumamt_str
  37440. bp.AcctPay = acct_pay_str
  37441. bp.FundPaySumamt = fund_pay_sumamt_str
  37442. bp.Insutype = ""
  37443. bp.StmtBegndate = start_time
  37444. bp.ClrType = clr_type
  37445. bp.SetlOptins = clr_org
  37446. bp.StmtEnddate = end_time
  37447. bps = append(bps, &bp)
  37448. data := make(map[string]interface{})
  37449. data["bps"] = bps
  37450. data["org_name"] = miConfig.OrgName
  37451. data["doctor"] = role.UserName
  37452. data["fixmedins_code"] = miConfig.Code
  37453. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37454. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37455. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37456. if miConfig.MdtrtareaAdmvs == "421300" {
  37457. client := &http.Client{}
  37458. bytesData, _ := json.Marshal(data)
  37459. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37460. resp, _ := client.Do(req)
  37461. defer resp.Body.Close()
  37462. body, ioErr := ioutil.ReadAll(resp.Body)
  37463. if ioErr != nil {
  37464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37466. return
  37467. }
  37468. var respJSON map[string]interface{}
  37469. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37472. return
  37473. }
  37474. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37475. userJSONBytes, _ := json.Marshal(respJSON)
  37476. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37477. utils.ErrorLog("解析失败:%v", err)
  37478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37479. return
  37480. }
  37481. }
  37482. if miConfig.MdtrtareaAdmvs == "420200" {
  37483. client := &http.Client{}
  37484. bytesData, _ := json.Marshal(data)
  37485. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37486. resp, _ := client.Do(req)
  37487. defer resp.Body.Close()
  37488. body, ioErr := ioutil.ReadAll(resp.Body)
  37489. if ioErr != nil {
  37490. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37492. return
  37493. }
  37494. var respJSON map[string]interface{}
  37495. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37498. return
  37499. }
  37500. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37501. userJSONBytes, _ := json.Marshal(respJSON)
  37502. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37503. utils.ErrorLog("解析失败:%v", err)
  37504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37505. return
  37506. }
  37507. }
  37508. if miConfig.MdtrtareaAdmvs == "421182" {
  37509. client := &http.Client{}
  37510. bytesData, _ := json.Marshal(data)
  37511. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37512. resp, _ := client.Do(req)
  37513. defer resp.Body.Close()
  37514. body, ioErr := ioutil.ReadAll(resp.Body)
  37515. if ioErr != nil {
  37516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37518. return
  37519. }
  37520. var respJSON map[string]interface{}
  37521. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37524. return
  37525. }
  37526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37527. userJSONBytes, _ := json.Marshal(respJSON)
  37528. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37529. utils.ErrorLog("解析失败:%v", err)
  37530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37531. return
  37532. }
  37533. }
  37534. if miConfig.MdtrtareaAdmvs == "420902" {
  37535. client := &http.Client{}
  37536. bytesData, _ := json.Marshal(data)
  37537. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37538. resp, _ := client.Do(req)
  37539. defer resp.Body.Close()
  37540. body, ioErr := ioutil.ReadAll(resp.Body)
  37541. if ioErr != nil {
  37542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37544. return
  37545. }
  37546. var respJSON map[string]interface{}
  37547. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37550. return
  37551. }
  37552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37553. userJSONBytes, _ := json.Marshal(respJSON)
  37554. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37555. utils.ErrorLog("解析失败:%v", err)
  37556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37557. return
  37558. }
  37559. }
  37560. if res.Infcode == 0 {
  37561. c.ServeSuccessJSON(map[string]interface{}{
  37562. "msg": "发起成功",
  37563. })
  37564. } else {
  37565. c.ServeSuccessJSON(map[string]interface{}{
  37566. "failed_code": -10,
  37567. "msg": res.ErrMsg,
  37568. })
  37569. }
  37570. }
  37571. }
  37572. func (c *HisApiController) Post3204a() {
  37573. start_time := c.GetString("start_time")
  37574. end_time := c.GetString("end_time")
  37575. //insutype := c.GetString("insutype")
  37576. clr_type := c.GetString("clr_type")
  37577. clr_org := c.GetString("clr_optins")
  37578. admin_user_id, _ := c.GetInt64("admin_user_id")
  37579. adminUser := c.GetAdminUserInfo()
  37580. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37581. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37582. if len(clr_org) == 0 {
  37583. clr_org = miConfig.MdtrtareaAdmvs
  37584. }
  37585. timeLayout := "2006-01-02"
  37586. loc, _ := time.LoadLocation("Local")
  37587. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37588. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37589. var orders []*models.HisOrder
  37590. if clr_org == "421300" {
  37591. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37592. } else if clr_org == "420902" {
  37593. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37594. } else {
  37595. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37596. }
  37597. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37598. //fixmedins_setl_cnt := int64(len(orders))
  37599. var medfee_sumamt float64
  37600. var acct_pay float64
  37601. var fund_pay_sumamt float64
  37602. for _, item := range orders {
  37603. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37604. acct_pay = acct_pay + item.AcctPay
  37605. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37606. }
  37607. //var medfee_sumamt_two float64
  37608. //var acct_pay_two float64
  37609. //var fund_pay_sumamt_two float64
  37610. //for _, item := range orders_two {
  37611. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37612. // acct_pay_two = acct_pay_two + item.AcctPay
  37613. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37614. //}
  37615. //var user_name string
  37616. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37617. //if role.ID == 0 {
  37618. // user_name = "xxx"
  37619. //} else {
  37620. // user_name = role.UserName
  37621. //}
  37622. var res ResultSix
  37623. if config.IsOpen == 1 {
  37624. var bps []*models.BusinessParamsTwo
  37625. var bp models.BusinessParamsTwo
  37626. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37627. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37628. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37629. bp.MedfeeSumamt = medfee_sumamt_str
  37630. bp.AcctPay = acct_pay_str
  37631. bp.FundPaySumamt = fund_pay_sumamt_str
  37632. bp.Insutype = ""
  37633. bp.StmtBegndate = start_time
  37634. bp.ClrType = clr_type
  37635. bp.SetlOptins = clr_org
  37636. bp.StmtEnddate = end_time
  37637. bps = append(bps, &bp)
  37638. data := make(map[string]interface{})
  37639. data["bps"] = bps
  37640. data["org_name"] = miConfig.OrgName
  37641. data["doctor"] = role.UserName
  37642. data["fixmedins_code"] = miConfig.Code
  37643. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37644. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37645. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37646. if miConfig.MdtrtareaAdmvs == "421300" {
  37647. client := &http.Client{}
  37648. bytesData, _ := json.Marshal(data)
  37649. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37650. resp, _ := client.Do(req)
  37651. defer resp.Body.Close()
  37652. body, ioErr := ioutil.ReadAll(resp.Body)
  37653. if ioErr != nil {
  37654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37656. return
  37657. }
  37658. var respJSON map[string]interface{}
  37659. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37662. return
  37663. }
  37664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37665. userJSONBytes, _ := json.Marshal(respJSON)
  37666. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37667. utils.ErrorLog("解析失败:%v", err)
  37668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37669. return
  37670. }
  37671. }
  37672. if miConfig.MdtrtareaAdmvs == "420200" {
  37673. client := &http.Client{}
  37674. bytesData, _ := json.Marshal(data)
  37675. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  37676. resp, _ := client.Do(req)
  37677. defer resp.Body.Close()
  37678. body, ioErr := ioutil.ReadAll(resp.Body)
  37679. if ioErr != nil {
  37680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37682. return
  37683. }
  37684. var respJSON map[string]interface{}
  37685. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37688. return
  37689. }
  37690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37691. userJSONBytes, _ := json.Marshal(respJSON)
  37692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37693. utils.ErrorLog("解析失败:%v", err)
  37694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37695. return
  37696. }
  37697. }
  37698. if miConfig.MdtrtareaAdmvs == "421182" {
  37699. client := &http.Client{}
  37700. bytesData, _ := json.Marshal(data)
  37701. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  37702. resp, _ := client.Do(req)
  37703. defer resp.Body.Close()
  37704. body, ioErr := ioutil.ReadAll(resp.Body)
  37705. if ioErr != nil {
  37706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37708. return
  37709. }
  37710. var respJSON map[string]interface{}
  37711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37714. return
  37715. }
  37716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37717. userJSONBytes, _ := json.Marshal(respJSON)
  37718. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37719. utils.ErrorLog("解析失败:%v", err)
  37720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37721. return
  37722. }
  37723. }
  37724. if miConfig.MdtrtareaAdmvs == "420902" {
  37725. client := &http.Client{}
  37726. bytesData, _ := json.Marshal(data)
  37727. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  37728. resp, _ := client.Do(req)
  37729. defer resp.Body.Close()
  37730. body, ioErr := ioutil.ReadAll(resp.Body)
  37731. if ioErr != nil {
  37732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37734. return
  37735. }
  37736. var respJSON map[string]interface{}
  37737. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37740. return
  37741. }
  37742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37743. userJSONBytes, _ := json.Marshal(respJSON)
  37744. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37745. utils.ErrorLog("解析失败:%v", err)
  37746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37747. return
  37748. }
  37749. }
  37750. if res.Infcode == 0 {
  37751. c.ServeSuccessJSON(map[string]interface{}{
  37752. "msg": "撤销成功",
  37753. })
  37754. } else {
  37755. c.ServeSuccessJSON(map[string]interface{}{
  37756. "failed_code": -10,
  37757. "msg": res.ErrMsg,
  37758. })
  37759. }
  37760. }
  37761. }
  37762. func (c *HisApiController) Post3204() {
  37763. admin_user_id, _ := c.GetInt64("admin_user_id")
  37764. id := c.GetString("id")
  37765. adminUser := c.GetAdminUserInfo()
  37766. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37767. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37768. //clr_org := miConfig.MdtrtareaAdmvs
  37769. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37770. var res ResultSix
  37771. if config.IsOpen == 1 {
  37772. data := make(map[string]interface{})
  37773. data["id"] = id
  37774. data["org_name"] = miConfig.OrgName
  37775. data["doctor"] = role.UserName
  37776. data["fixmedins_code"] = miConfig.Code
  37777. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37778. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37779. client := &http.Client{}
  37780. bytesData, _ := json.Marshal(data)
  37781. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  37782. resp, _ := client.Do(req)
  37783. defer resp.Body.Close()
  37784. body, ioErr := ioutil.ReadAll(resp.Body)
  37785. if ioErr != nil {
  37786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37788. return
  37789. }
  37790. var respJSON map[string]interface{}
  37791. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37794. return
  37795. }
  37796. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37797. userJSONBytes, _ := json.Marshal(respJSON)
  37798. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37799. utils.ErrorLog("解析失败:%v", err)
  37800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37801. return
  37802. }
  37803. if res.Infcode == 0 {
  37804. c.ServeSuccessJSON(map[string]interface{}{
  37805. "msg": "发起成功",
  37806. })
  37807. } else {
  37808. c.ServeSuccessJSON(map[string]interface{}{
  37809. "failed_code": -10,
  37810. "msg": res.ErrMsg,
  37811. })
  37812. }
  37813. }
  37814. }
  37815. func (c *HisApiController) Post8404() {
  37816. admin_user_id, _ := c.GetInt64("admin_user_id")
  37817. month := c.GetString("month")
  37818. adminUser := c.GetAdminUserInfo()
  37819. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37820. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37821. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37822. var res ResultSix
  37823. if config.IsOpen == 1 {
  37824. data := make(map[string]interface{})
  37825. data["month"] = month
  37826. data["org_name"] = miConfig.OrgName
  37827. data["doctor"] = role.UserName
  37828. data["fixmedins_code"] = miConfig.Code
  37829. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37830. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37831. client := &http.Client{}
  37832. bytesData, _ := json.Marshal(data)
  37833. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  37834. resp, _ := client.Do(req)
  37835. defer resp.Body.Close()
  37836. body, ioErr := ioutil.ReadAll(resp.Body)
  37837. if ioErr != nil {
  37838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37840. return
  37841. }
  37842. var respJSON map[string]interface{}
  37843. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37846. return
  37847. }
  37848. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37849. userJSONBytes, _ := json.Marshal(respJSON)
  37850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37851. utils.ErrorLog("解析失败:%v", err)
  37852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37853. return
  37854. }
  37855. if res.Infcode == 0 {
  37856. c.ServeSuccessJSON(map[string]interface{}{
  37857. "msg": "查询成功",
  37858. })
  37859. } else {
  37860. c.ServeSuccessJSON(map[string]interface{}{
  37861. "failed_code": -10,
  37862. "msg": res.ErrMsg,
  37863. })
  37864. }
  37865. }
  37866. }
  37867. func (c *HisApiController) Post3202b() {
  37868. start_time := c.GetString("start_time")
  37869. end_time := c.GetString("end_time")
  37870. //insutype := c.GetString("insutype")
  37871. clr_type := c.GetString("clr_type")
  37872. clr_org := c.GetString("clr_optins")
  37873. admin_user_id, _ := c.GetInt64("admin_user_id")
  37874. adminUser := c.GetAdminUserInfo()
  37875. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37876. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37877. if len(clr_org) == 0 {
  37878. clr_org = miConfig.MdtrtareaAdmvs
  37879. }
  37880. timeLayout := "2006-01-02"
  37881. loc, _ := time.LoadLocation("Local")
  37882. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37883. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37884. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37885. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37886. //fixmedins_setl_cnt := int64(len(orders))
  37887. var medfee_sumamt float64
  37888. var acct_pay float64
  37889. var fund_pay_sumamt float64
  37890. for _, item := range orders {
  37891. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37892. acct_pay = acct_pay + item.AcctPay
  37893. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37894. }
  37895. //var medfee_sumamt_two float64
  37896. //var acct_pay_two float64
  37897. //var fund_pay_sumamt_two float64
  37898. //for _, item := range orders_two {
  37899. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37900. // acct_pay_two = acct_pay_two + item.AcctPay
  37901. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37902. //}
  37903. //var user_name string
  37904. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37905. //if role.ID == 0 {
  37906. // user_name = "xxx"
  37907. //} else {
  37908. // user_name = role.UserName
  37909. //}
  37910. var res ResultSix
  37911. if config.IsOpen == 1 {
  37912. var bps []*models.BusinessParamsTwo
  37913. var bp models.BusinessParamsTwo
  37914. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37915. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37916. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37917. bp.MedfeeSumamt = medfee_sumamt_str
  37918. bp.AcctPay = acct_pay_str
  37919. bp.FundPaySumamt = fund_pay_sumamt_str
  37920. bp.Insutype = "390"
  37921. bp.StmtBegndate = start_time
  37922. bp.ClrType = clr_type
  37923. bp.SetlOptins = clr_org
  37924. bp.StmtEnddate = end_time
  37925. bps = append(bps, &bp)
  37926. data := make(map[string]interface{})
  37927. data["bps"] = bps
  37928. data["org_name"] = miConfig.OrgName
  37929. data["doctor"] = role.UserName
  37930. data["fixmedins_code"] = miConfig.Code
  37931. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37932. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37933. if miConfig.MdtrtareaAdmvs == "421300" {
  37934. client := &http.Client{}
  37935. bytesData, _ := json.Marshal(data)
  37936. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  37937. resp, _ := client.Do(req)
  37938. defer resp.Body.Close()
  37939. body, ioErr := ioutil.ReadAll(resp.Body)
  37940. if ioErr != nil {
  37941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37943. return
  37944. }
  37945. var respJSON map[string]interface{}
  37946. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37949. return
  37950. }
  37951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37952. userJSONBytes, _ := json.Marshal(respJSON)
  37953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37954. utils.ErrorLog("解析失败:%v", err)
  37955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37956. return
  37957. }
  37958. }
  37959. if miConfig.MdtrtareaAdmvs == "420200" {
  37960. client := &http.Client{}
  37961. bytesData, _ := json.Marshal(data)
  37962. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  37963. resp, _ := client.Do(req)
  37964. defer resp.Body.Close()
  37965. body, ioErr := ioutil.ReadAll(resp.Body)
  37966. if ioErr != nil {
  37967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37969. return
  37970. }
  37971. var respJSON map[string]interface{}
  37972. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37975. return
  37976. }
  37977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37978. userJSONBytes, _ := json.Marshal(respJSON)
  37979. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37980. utils.ErrorLog("解析失败:%v", err)
  37981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37982. return
  37983. }
  37984. }
  37985. if miConfig.MdtrtareaAdmvs == "421182" {
  37986. client := &http.Client{}
  37987. bytesData, _ := json.Marshal(data)
  37988. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  37989. resp, _ := client.Do(req)
  37990. defer resp.Body.Close()
  37991. body, ioErr := ioutil.ReadAll(resp.Body)
  37992. if ioErr != nil {
  37993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37995. return
  37996. }
  37997. var respJSON map[string]interface{}
  37998. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38001. return
  38002. }
  38003. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38004. userJSONBytes, _ := json.Marshal(respJSON)
  38005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38006. utils.ErrorLog("解析失败:%v", err)
  38007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38008. return
  38009. }
  38010. }
  38011. if res.Infcode == 0 {
  38012. c.ServeSuccessJSON(map[string]interface{}{
  38013. "msg": "发起成功",
  38014. })
  38015. } else {
  38016. c.ServeSuccessJSON(map[string]interface{}{
  38017. "failed_code": -10,
  38018. "msg": res.ErrMsg,
  38019. })
  38020. }
  38021. }
  38022. }
  38023. func (c *HisApiController) Post1608() {
  38024. start_time := c.GetString("start_time")
  38025. end_time := c.GetString("end_time")
  38026. admin_user_id, _ := c.GetInt64("admin_user_id")
  38027. adminUser := c.GetAdminUserInfo()
  38028. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38029. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38030. timeLayout := "2006-01-02"
  38031. loc, _ := time.LoadLocation("Local")
  38032. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38033. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38034. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38035. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38036. fixmedins_setl_cnt := int64(len(orders))
  38037. var medfee_sumamt float64
  38038. var func_smamt float64
  38039. for _, item := range orders {
  38040. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38041. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38042. }
  38043. times := strings.Split(start_time, "-")
  38044. time_tows := strings.Split(end_time, "-")
  38045. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38046. var res ResultSix
  38047. if config.IsOpen == 1 {
  38048. //var bps []*models.BusinessParamsTwo
  38049. //var bp models.BusinessParamsTwo
  38050. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38051. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38052. data := make(map[string]interface{})
  38053. data["org_name"] = miConfig.OrgName
  38054. data["doctor"] = role.UserName
  38055. data["func_smamt"] = func_smamt_str
  38056. data["fixmedins_code"] = miConfig.Code
  38057. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38058. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38059. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38060. data["medfee_sumamt"] = medfee_sumamt_str
  38061. data["start_time"] = times[0] + times[1] + times[2]
  38062. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38063. if miConfig.MdtrtareaAdmvs == "421300" {
  38064. client := &http.Client{}
  38065. bytesData, _ := json.Marshal(data)
  38066. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38067. resp, _ := client.Do(req)
  38068. defer resp.Body.Close()
  38069. body, ioErr := ioutil.ReadAll(resp.Body)
  38070. if ioErr != nil {
  38071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38073. return
  38074. }
  38075. var respJSON map[string]interface{}
  38076. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38079. return
  38080. }
  38081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38082. userJSONBytes, _ := json.Marshal(respJSON)
  38083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38084. utils.ErrorLog("解析失败:%v", err)
  38085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38086. return
  38087. }
  38088. }
  38089. if miConfig.MdtrtareaAdmvs == "420200" {
  38090. client := &http.Client{}
  38091. bytesData, _ := json.Marshal(data)
  38092. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38093. resp, _ := client.Do(req)
  38094. defer resp.Body.Close()
  38095. body, ioErr := ioutil.ReadAll(resp.Body)
  38096. if ioErr != nil {
  38097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38099. return
  38100. }
  38101. var respJSON map[string]interface{}
  38102. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38105. return
  38106. }
  38107. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38108. userJSONBytes, _ := json.Marshal(respJSON)
  38109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38110. utils.ErrorLog("解析失败:%v", err)
  38111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38112. return
  38113. }
  38114. }
  38115. if miConfig.MdtrtareaAdmvs == "421182" {
  38116. client := &http.Client{}
  38117. bytesData, _ := json.Marshal(data)
  38118. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38119. resp, _ := client.Do(req)
  38120. defer resp.Body.Close()
  38121. body, ioErr := ioutil.ReadAll(resp.Body)
  38122. if ioErr != nil {
  38123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38125. return
  38126. }
  38127. var respJSON map[string]interface{}
  38128. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38131. return
  38132. }
  38133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38134. userJSONBytes, _ := json.Marshal(respJSON)
  38135. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38136. utils.ErrorLog("解析失败:%v", err)
  38137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38138. return
  38139. }
  38140. }
  38141. if res.Infcode == 0 {
  38142. c.ServeSuccessJSON(map[string]interface{}{
  38143. "msg": "发起成功",
  38144. })
  38145. } else {
  38146. c.ServeSuccessJSON(map[string]interface{}{
  38147. "failed_code": -10,
  38148. "msg": res.ErrMsg,
  38149. })
  38150. }
  38151. }
  38152. }
  38153. // 5.11.1.1【5262】结算信息按时间段查询
  38154. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38155. admin_user_id, _ := c.GetInt64("admin_user_id")
  38156. adminUser := c.GetAdminUserInfo()
  38157. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38158. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38159. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38160. var res Result5262
  38161. if config.IsOpen == 1 {
  38162. if miConfig.MdtrtareaAdmvs == "421300" {
  38163. data := make(map[string]interface{})
  38164. data["bps"] = bp
  38165. data["org_name"] = miConfig.OrgName
  38166. data["doctor"] = role.UserName
  38167. data["fixmedins_code"] = miConfig.Code
  38168. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38169. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38170. data["page"] = strconv.FormatInt(page, 10)
  38171. data["limit"] = strconv.FormatInt(limit, 10)
  38172. fmt.Println(data)
  38173. client := &http.Client{}
  38174. bytesData, _ := json.Marshal(data)
  38175. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38176. resp, _ := client.Do(req)
  38177. defer resp.Body.Close()
  38178. body, ioErr := ioutil.ReadAll(resp.Body)
  38179. if ioErr != nil {
  38180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38182. return
  38183. }
  38184. var respJSON map[string]interface{}
  38185. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38188. return
  38189. }
  38190. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38191. userJSONBytes, _ := json.Marshal(respJSON)
  38192. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38193. utils.ErrorLog("解析失败:%v", err)
  38194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38195. return
  38196. }
  38197. }
  38198. if miConfig.MdtrtareaAdmvs == "420200" {
  38199. data := make(map[string]interface{})
  38200. data["bps"] = bp
  38201. data["org_name"] = miConfig.OrgName
  38202. data["doctor"] = role.UserName
  38203. data["fixmedins_code"] = miConfig.Code
  38204. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38205. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38206. data["page"] = strconv.FormatInt(page, 10)
  38207. data["limit"] = strconv.FormatInt(limit, 10)
  38208. fmt.Println(data)
  38209. client := &http.Client{}
  38210. bytesData, _ := json.Marshal(data)
  38211. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38212. resp, _ := client.Do(req)
  38213. defer resp.Body.Close()
  38214. body, ioErr := ioutil.ReadAll(resp.Body)
  38215. if ioErr != nil {
  38216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38218. return
  38219. }
  38220. var respJSON map[string]interface{}
  38221. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38224. return
  38225. }
  38226. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38227. userJSONBytes, _ := json.Marshal(respJSON)
  38228. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38229. utils.ErrorLog("解析失败:%v", err)
  38230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38231. return
  38232. }
  38233. }
  38234. if miConfig.MdtrtareaAdmvs == "421182" {
  38235. data := make(map[string]interface{})
  38236. data["bps"] = bp
  38237. data["org_name"] = miConfig.OrgName
  38238. data["doctor"] = role.UserName
  38239. data["fixmedins_code"] = miConfig.Code
  38240. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38241. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38242. data["page"] = strconv.FormatInt(page, 10)
  38243. data["limit"] = strconv.FormatInt(limit, 10)
  38244. fmt.Println(data)
  38245. client := &http.Client{}
  38246. bytesData, _ := json.Marshal(data)
  38247. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38248. resp, _ := client.Do(req)
  38249. defer resp.Body.Close()
  38250. body, ioErr := ioutil.ReadAll(resp.Body)
  38251. if ioErr != nil {
  38252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38254. return
  38255. }
  38256. var respJSON map[string]interface{}
  38257. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38260. return
  38261. }
  38262. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38263. userJSONBytes, _ := json.Marshal(respJSON)
  38264. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38265. utils.ErrorLog("解析失败:%v", err)
  38266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38267. return
  38268. }
  38269. }
  38270. if miConfig.MdtrtareaAdmvs == "420902" {
  38271. data := make(map[string]interface{})
  38272. data["bps"] = bp
  38273. data["org_name"] = miConfig.OrgName
  38274. data["doctor"] = role.UserName
  38275. data["fixmedins_code"] = miConfig.Code
  38276. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38277. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38278. data["page"] = strconv.FormatInt(page, 10)
  38279. data["limit"] = strconv.FormatInt(limit, 10)
  38280. fmt.Println(data)
  38281. client := &http.Client{}
  38282. bytesData, _ := json.Marshal(data)
  38283. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38284. resp, _ := client.Do(req)
  38285. defer resp.Body.Close()
  38286. body, ioErr := ioutil.ReadAll(resp.Body)
  38287. if ioErr != nil {
  38288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38290. return
  38291. }
  38292. var respJSON map[string]interface{}
  38293. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38296. return
  38297. }
  38298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38299. userJSONBytes, _ := json.Marshal(respJSON)
  38300. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38301. utils.ErrorLog("解析失败:%v", err)
  38302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38303. return
  38304. }
  38305. }
  38306. if res.Infcode == 0 {
  38307. c.ServeSuccessJSON(map[string]interface{}{
  38308. "order": res.Output.Result,
  38309. "total": res.Output.PageInfo.RecordCounts,
  38310. })
  38311. } else {
  38312. c.ServeSuccessJSON(map[string]interface{}{
  38313. "failed_code": -10,
  38314. "msg": res.ErrMsg,
  38315. })
  38316. }
  38317. }
  38318. }
  38319. // 5.11.1.2【5267】异地结算信息时间段查询
  38320. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38321. admin_user_id, _ := c.GetInt64("admin_user_id")
  38322. adminUser := c.GetAdminUserInfo()
  38323. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38324. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38325. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38326. var res Result5267
  38327. if config.IsOpen == 1 {
  38328. if miConfig.MdtrtareaAdmvs == "421300" {
  38329. data := make(map[string]interface{})
  38330. data["bps"] = bp
  38331. data["org_name"] = miConfig.OrgName
  38332. data["doctor"] = role.UserName
  38333. data["fixmedins_code"] = miConfig.Code
  38334. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38335. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38336. data["page"] = page
  38337. data["limit"] = limit
  38338. fmt.Println(data)
  38339. client := &http.Client{}
  38340. bytesData, _ := json.Marshal(data)
  38341. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38342. resp, _ := client.Do(req)
  38343. defer resp.Body.Close()
  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(body), &respJSON); err != nil {
  38352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38354. return
  38355. }
  38356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38357. userJSONBytes, _ := json.Marshal(respJSON)
  38358. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38359. utils.ErrorLog("解析失败:%v", err)
  38360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38361. return
  38362. }
  38363. }
  38364. if miConfig.MdtrtareaAdmvs == "420200" {
  38365. data := make(map[string]interface{})
  38366. data["bps"] = bp
  38367. data["org_name"] = miConfig.OrgName
  38368. data["doctor"] = role.UserName
  38369. data["fixmedins_code"] = miConfig.Code
  38370. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38371. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38372. data["page"] = page
  38373. data["limit"] = limit
  38374. fmt.Println(data)
  38375. client := &http.Client{}
  38376. bytesData, _ := json.Marshal(data)
  38377. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38378. resp, _ := client.Do(req)
  38379. defer resp.Body.Close()
  38380. body, ioErr := ioutil.ReadAll(resp.Body)
  38381. if ioErr != nil {
  38382. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38384. return
  38385. }
  38386. var respJSON map[string]interface{}
  38387. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38390. return
  38391. }
  38392. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38393. userJSONBytes, _ := json.Marshal(respJSON)
  38394. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38395. utils.ErrorLog("解析失败:%v", err)
  38396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38397. return
  38398. }
  38399. }
  38400. if miConfig.MdtrtareaAdmvs == "421182" {
  38401. data := make(map[string]interface{})
  38402. data["bps"] = bp
  38403. data["org_name"] = miConfig.OrgName
  38404. data["doctor"] = role.UserName
  38405. data["fixmedins_code"] = miConfig.Code
  38406. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38407. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38408. data["page"] = page
  38409. data["limit"] = limit
  38410. fmt.Println(data)
  38411. client := &http.Client{}
  38412. bytesData, _ := json.Marshal(data)
  38413. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38414. resp, _ := client.Do(req)
  38415. defer resp.Body.Close()
  38416. body, ioErr := ioutil.ReadAll(resp.Body)
  38417. if ioErr != nil {
  38418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38420. return
  38421. }
  38422. var respJSON map[string]interface{}
  38423. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38426. return
  38427. }
  38428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38429. userJSONBytes, _ := json.Marshal(respJSON)
  38430. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38431. utils.ErrorLog("解析失败:%v", err)
  38432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38433. return
  38434. }
  38435. }
  38436. if res.Infcode == 0 {
  38437. c.ServeSuccessJSON(map[string]interface{}{
  38438. "order": res.Output.Result,
  38439. "total": res.Output.PageInfo.RecordCounts,
  38440. })
  38441. } else {
  38442. c.ServeSuccessJSON(map[string]interface{}{
  38443. "failed_code": -10,
  38444. "msg": res.ErrMsg,
  38445. })
  38446. }
  38447. }
  38448. }
  38449. func (c *HisApiController) Post3501() {
  38450. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38451. data := make(map[string]interface{})
  38452. var struct3501s []models.Struct3501
  38453. var struct3501 models.Struct3501
  38454. struct3501.OrgName = miConfig.OrgName
  38455. struct3501.AccessKey = miConfig.AccessKey
  38456. struct3501.RequestUrl = miConfig.Url
  38457. struct3501.SecretKey = miConfig.SecretKey
  38458. struct3501.ManuDate = "2022-08-17"
  38459. struct3501.FixmedinsBchno = ""
  38460. struct3501.ManuLotnum = ""
  38461. struct3501.RxFlag = "0"
  38462. struct3501.ExpyEnd = "2022-08-17"
  38463. struct3501.Invdate = "2022-08-17"
  38464. struct3501.InvCnt = "20.25"
  38465. struct3501.Memo = ""
  38466. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38467. struct3501.FixmedinsHilistId = miConfig.Code
  38468. struct3501.FixmedinsHilistName = miConfig.OrgName
  38469. struct3501s = append(struct3501s, struct3501)
  38470. data["struct_3501s"] = struct3501s
  38471. client := &http.Client{}
  38472. bytesData, _ := json.Marshal(data)
  38473. var req *http.Request
  38474. if miConfig.MdtrtareaAdmvs == "320921" {
  38475. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38476. } else {
  38477. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38478. }
  38479. resp, _ := client.Do(req)
  38480. defer resp.Body.Close()
  38481. body, ioErr := ioutil.ReadAll(resp.Body)
  38482. if ioErr != nil {
  38483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38485. return
  38486. }
  38487. var respJSON map[string]interface{}
  38488. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38491. return
  38492. }
  38493. var res ResultSix
  38494. var resSix10265 ResultSix10265 //1101结果
  38495. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38496. result, _ := json.Marshal(respJSON)
  38497. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38498. utils.ErrorLog("解析失败:%v", err)
  38499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38500. return
  38501. }
  38502. res.InfRefmsgid = resSix10265.InfRefmsgid
  38503. res.Output = resSix10265.Output
  38504. res.ErrMsg = resSix10265.ErrMsg
  38505. res.Cainfo = resSix10265.Cainfo
  38506. res.WarnMsg = resSix10265.WarnMsg
  38507. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38508. res.Infcode = infocode
  38509. if infocode == 0 {
  38510. c.ServeSuccessJSON(map[string]interface{}{
  38511. "msg": "上传成功",
  38512. })
  38513. return
  38514. } else {
  38515. c.ServeSuccessJSON(map[string]interface{}{
  38516. "failed_code": -10,
  38517. "msg": res.ErrMsg,
  38518. })
  38519. return
  38520. }
  38521. }
  38522. func (c *HisApiController) Post3502() {
  38523. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38524. data := make(map[string]interface{})
  38525. var struct3502s []models.Struct3502
  38526. var struct3502 models.Struct3502
  38527. struct3502.OrgName = miConfig.OrgName
  38528. struct3502.AccessKey = miConfig.AccessKey
  38529. struct3502.RequestUrl = miConfig.Url
  38530. struct3502.SecretKey = miConfig.SecretKey
  38531. struct3502.ManuDate = "2022-08-15"
  38532. struct3502.FixmedinsBchno = ""
  38533. struct3502.ManuLotnum = ""
  38534. struct3502.RxFlag = "0"
  38535. struct3502.ExpyEnd = "2022-08-15"
  38536. struct3502.Invdate = "2022-08-15"
  38537. struct3502.InvCnt = "20.25"
  38538. struct3502.Memo = ""
  38539. struct3502.MedListCodg = "XB01ABD056B002020200517"
  38540. struct3502.FixmedinsHilistId = miConfig.Code
  38541. struct3502.FixmedinsHilistName = miConfig.OrgName
  38542. struct3502s = append(struct3502s, struct3502)
  38543. data["struct_3502s"] = struct3502s
  38544. client := &http.Client{}
  38545. bytesData, _ := json.Marshal(data)
  38546. var req *http.Request
  38547. if miConfig.MdtrtareaAdmvs == "320921" {
  38548. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38549. } else {
  38550. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38551. }
  38552. resp, _ := client.Do(req)
  38553. defer resp.Body.Close()
  38554. body, ioErr := ioutil.ReadAll(resp.Body)
  38555. if ioErr != nil {
  38556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38558. return
  38559. }
  38560. var respJSON map[string]interface{}
  38561. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38564. return
  38565. }
  38566. var res ResultSix
  38567. var resSix10265 ResultSix10265 //1101结果
  38568. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38569. result, _ := json.Marshal(respJSON)
  38570. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38571. utils.ErrorLog("解析失败:%v", err)
  38572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38573. return
  38574. }
  38575. res.InfRefmsgid = resSix10265.InfRefmsgid
  38576. res.Output = resSix10265.Output
  38577. res.ErrMsg = resSix10265.ErrMsg
  38578. res.Cainfo = resSix10265.Cainfo
  38579. res.WarnMsg = resSix10265.WarnMsg
  38580. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38581. res.Infcode = infocode
  38582. if infocode == 0 {
  38583. c.ServeSuccessJSON(map[string]interface{}{
  38584. "msg": "上传成功",
  38585. })
  38586. return
  38587. } else {
  38588. c.ServeSuccessJSON(map[string]interface{}{
  38589. "failed_code": -10,
  38590. "msg": res.ErrMsg,
  38591. })
  38592. return
  38593. }
  38594. }
  38595. func (c *HisApiController) Post3503() {
  38596. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38597. data := make(map[string]interface{})
  38598. var struct3501s []models.Struct3501
  38599. var struct3501 models.Struct3501
  38600. struct3501.OrgName = miConfig.OrgName
  38601. struct3501.AccessKey = miConfig.AccessKey
  38602. struct3501.RequestUrl = miConfig.Url
  38603. struct3501.SecretKey = miConfig.SecretKey
  38604. struct3501.ManuDate = "2022-08-15"
  38605. struct3501.FixmedinsBchno = ""
  38606. struct3501.ManuLotnum = ""
  38607. struct3501.RxFlag = "0"
  38608. struct3501.ExpyEnd = "2022-08-15"
  38609. struct3501.Invdate = "2022-08-15"
  38610. struct3501.InvCnt = "20.25"
  38611. struct3501.Memo = ""
  38612. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38613. struct3501.FixmedinsHilistId = miConfig.Code
  38614. struct3501.FixmedinsHilistName = miConfig.OrgName
  38615. struct3501s = append(struct3501s, struct3501)
  38616. data["struct_3501s"] = struct3501s
  38617. client := &http.Client{}
  38618. bytesData, _ := json.Marshal(data)
  38619. var req *http.Request
  38620. if miConfig.MdtrtareaAdmvs == "320921" {
  38621. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38622. } else {
  38623. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38624. }
  38625. resp, _ := client.Do(req)
  38626. defer resp.Body.Close()
  38627. body, ioErr := ioutil.ReadAll(resp.Body)
  38628. if ioErr != nil {
  38629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38631. return
  38632. }
  38633. var respJSON map[string]interface{}
  38634. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38637. return
  38638. }
  38639. var res ResultSix
  38640. var resSix10265 ResultSix10265 //1101结果
  38641. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38642. result, _ := json.Marshal(respJSON)
  38643. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38644. utils.ErrorLog("解析失败:%v", err)
  38645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38646. return
  38647. }
  38648. res.InfRefmsgid = resSix10265.InfRefmsgid
  38649. res.Output = resSix10265.Output
  38650. res.ErrMsg = resSix10265.ErrMsg
  38651. res.Cainfo = resSix10265.Cainfo
  38652. res.WarnMsg = resSix10265.WarnMsg
  38653. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38654. res.Infcode = infocode
  38655. if infocode == 0 {
  38656. c.ServeSuccessJSON(map[string]interface{}{
  38657. "msg": "上传成功",
  38658. })
  38659. return
  38660. } else {
  38661. c.ServeSuccessJSON(map[string]interface{}{
  38662. "failed_code": -10,
  38663. "msg": res.ErrMsg,
  38664. })
  38665. return
  38666. }
  38667. }
  38668. func (c *HisApiController) Post3504() {
  38669. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38670. data := make(map[string]interface{})
  38671. var struct3501s []models.Struct3501
  38672. var struct3501 models.Struct3501
  38673. struct3501.OrgName = miConfig.OrgName
  38674. struct3501.AccessKey = miConfig.AccessKey
  38675. struct3501.RequestUrl = miConfig.Url
  38676. struct3501.SecretKey = miConfig.SecretKey
  38677. struct3501.ManuDate = "2022-08-15"
  38678. struct3501.FixmedinsBchno = ""
  38679. struct3501.ManuLotnum = ""
  38680. struct3501.RxFlag = "0"
  38681. struct3501.ExpyEnd = "2022-08-15"
  38682. struct3501.Invdate = "2022-08-15"
  38683. struct3501.InvCnt = "20.25"
  38684. struct3501.Memo = ""
  38685. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38686. struct3501.FixmedinsHilistId = miConfig.Code
  38687. struct3501.FixmedinsHilistName = miConfig.OrgName
  38688. struct3501s = append(struct3501s, struct3501)
  38689. data["struct_3501s"] = struct3501s
  38690. client := &http.Client{}
  38691. bytesData, _ := json.Marshal(data)
  38692. var req *http.Request
  38693. if miConfig.MdtrtareaAdmvs == "320921" {
  38694. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38695. } else {
  38696. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38697. }
  38698. resp, _ := client.Do(req)
  38699. defer resp.Body.Close()
  38700. body, ioErr := ioutil.ReadAll(resp.Body)
  38701. if ioErr != nil {
  38702. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38704. return
  38705. }
  38706. var respJSON map[string]interface{}
  38707. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38710. return
  38711. }
  38712. var res ResultSix
  38713. var resSix10265 ResultSix10265 //1101结果
  38714. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38715. result, _ := json.Marshal(respJSON)
  38716. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38717. utils.ErrorLog("解析失败:%v", err)
  38718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38719. return
  38720. }
  38721. res.InfRefmsgid = resSix10265.InfRefmsgid
  38722. res.Output = resSix10265.Output
  38723. res.ErrMsg = resSix10265.ErrMsg
  38724. res.Cainfo = resSix10265.Cainfo
  38725. res.WarnMsg = resSix10265.WarnMsg
  38726. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38727. res.Infcode = infocode
  38728. if infocode == 0 {
  38729. c.ServeSuccessJSON(map[string]interface{}{
  38730. "msg": "上传成功",
  38731. })
  38732. return
  38733. } else {
  38734. c.ServeSuccessJSON(map[string]interface{}{
  38735. "failed_code": -10,
  38736. "msg": res.ErrMsg,
  38737. })
  38738. return
  38739. }
  38740. }
  38741. func (c *HisApiController) Post3505() {
  38742. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38743. data := make(map[string]interface{})
  38744. var struct3501s []models.Struct3501
  38745. var struct3501 models.Struct3501
  38746. struct3501.OrgName = miConfig.OrgName
  38747. struct3501.AccessKey = miConfig.AccessKey
  38748. struct3501.RequestUrl = miConfig.Url
  38749. struct3501.SecretKey = miConfig.SecretKey
  38750. struct3501.ManuDate = "2022-08-15"
  38751. struct3501.FixmedinsBchno = ""
  38752. struct3501.ManuLotnum = ""
  38753. struct3501.RxFlag = "0"
  38754. struct3501.ExpyEnd = "2022-08-15"
  38755. struct3501.Invdate = "2022-08-15"
  38756. struct3501.InvCnt = "20.25"
  38757. struct3501.Memo = ""
  38758. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38759. struct3501.FixmedinsHilistId = miConfig.Code
  38760. struct3501.FixmedinsHilistName = miConfig.OrgName
  38761. struct3501s = append(struct3501s, struct3501)
  38762. data["struct_3501s"] = struct3501s
  38763. client := &http.Client{}
  38764. bytesData, _ := json.Marshal(data)
  38765. var req *http.Request
  38766. if miConfig.MdtrtareaAdmvs == "320921" {
  38767. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38768. } else {
  38769. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38770. }
  38771. resp, _ := client.Do(req)
  38772. defer resp.Body.Close()
  38773. body, ioErr := ioutil.ReadAll(resp.Body)
  38774. if ioErr != nil {
  38775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38777. return
  38778. }
  38779. var respJSON map[string]interface{}
  38780. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38783. return
  38784. }
  38785. var res ResultSix
  38786. var resSix10265 ResultSix10265 //1101结果
  38787. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38788. result, _ := json.Marshal(respJSON)
  38789. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38790. utils.ErrorLog("解析失败:%v", err)
  38791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38792. return
  38793. }
  38794. res.InfRefmsgid = resSix10265.InfRefmsgid
  38795. res.Output = resSix10265.Output
  38796. res.ErrMsg = resSix10265.ErrMsg
  38797. res.Cainfo = resSix10265.Cainfo
  38798. res.WarnMsg = resSix10265.WarnMsg
  38799. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38800. res.Infcode = infocode
  38801. if infocode == 0 {
  38802. c.ServeSuccessJSON(map[string]interface{}{
  38803. "msg": "上传成功",
  38804. })
  38805. return
  38806. } else {
  38807. c.ServeSuccessJSON(map[string]interface{}{
  38808. "failed_code": -10,
  38809. "msg": res.ErrMsg,
  38810. })
  38811. return
  38812. }
  38813. }
  38814. func (c *HisApiController) Post3506() {
  38815. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38816. data := make(map[string]interface{})
  38817. var struct3501s []models.Struct3501
  38818. var struct3501 models.Struct3501
  38819. struct3501.OrgName = miConfig.OrgName
  38820. struct3501.AccessKey = miConfig.AccessKey
  38821. struct3501.RequestUrl = miConfig.Url
  38822. struct3501.SecretKey = miConfig.SecretKey
  38823. struct3501.ManuDate = "2022-08-15"
  38824. struct3501.FixmedinsBchno = ""
  38825. struct3501.ManuLotnum = ""
  38826. struct3501.RxFlag = "0"
  38827. struct3501.ExpyEnd = "2022-08-15"
  38828. struct3501.Invdate = "2022-08-15"
  38829. struct3501.InvCnt = "20.25"
  38830. struct3501.Memo = ""
  38831. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38832. struct3501.FixmedinsHilistId = miConfig.Code
  38833. struct3501.FixmedinsHilistName = miConfig.OrgName
  38834. struct3501s = append(struct3501s, struct3501)
  38835. data["struct_3501s"] = struct3501s
  38836. client := &http.Client{}
  38837. bytesData, _ := json.Marshal(data)
  38838. var req *http.Request
  38839. if miConfig.MdtrtareaAdmvs == "320921" {
  38840. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38841. } else {
  38842. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38843. }
  38844. resp, _ := client.Do(req)
  38845. defer resp.Body.Close()
  38846. body, ioErr := ioutil.ReadAll(resp.Body)
  38847. if ioErr != nil {
  38848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38850. return
  38851. }
  38852. var respJSON map[string]interface{}
  38853. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38856. return
  38857. }
  38858. var res ResultSix
  38859. var resSix10265 ResultSix10265 //1101结果
  38860. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38861. result, _ := json.Marshal(respJSON)
  38862. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38863. utils.ErrorLog("解析失败:%v", err)
  38864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38865. return
  38866. }
  38867. res.InfRefmsgid = resSix10265.InfRefmsgid
  38868. res.Output = resSix10265.Output
  38869. res.ErrMsg = resSix10265.ErrMsg
  38870. res.Cainfo = resSix10265.Cainfo
  38871. res.WarnMsg = resSix10265.WarnMsg
  38872. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38873. res.Infcode = infocode
  38874. if infocode == 0 {
  38875. c.ServeSuccessJSON(map[string]interface{}{
  38876. "msg": "上传成功",
  38877. })
  38878. return
  38879. } else {
  38880. c.ServeSuccessJSON(map[string]interface{}{
  38881. "failed_code": -10,
  38882. "msg": res.ErrMsg,
  38883. })
  38884. return
  38885. }
  38886. }
  38887. func (c *HisApiController) Post3507() {
  38888. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38889. data := make(map[string]interface{})
  38890. var struct3501s []models.Struct3501
  38891. var struct3501 models.Struct3501
  38892. struct3501.OrgName = miConfig.OrgName
  38893. struct3501.AccessKey = miConfig.AccessKey
  38894. struct3501.RequestUrl = miConfig.Url
  38895. struct3501.SecretKey = miConfig.SecretKey
  38896. struct3501.ManuDate = "2022-08-15"
  38897. struct3501.FixmedinsBchno = ""
  38898. struct3501.ManuLotnum = ""
  38899. struct3501.RxFlag = "0"
  38900. struct3501.ExpyEnd = "2022-08-15"
  38901. struct3501.Invdate = "2022-08-15"
  38902. struct3501.InvCnt = "20.25"
  38903. struct3501.Memo = ""
  38904. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38905. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  38906. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  38907. struct3501s = append(struct3501s, struct3501)
  38908. data["struct_3501s"] = struct3501s
  38909. client := &http.Client{}
  38910. bytesData, _ := json.Marshal(data)
  38911. var req *http.Request
  38912. if miConfig.MdtrtareaAdmvs == "320921" {
  38913. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38914. } else {
  38915. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38916. }
  38917. resp, _ := client.Do(req)
  38918. defer resp.Body.Close()
  38919. body, ioErr := ioutil.ReadAll(resp.Body)
  38920. if ioErr != nil {
  38921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38923. return
  38924. }
  38925. var respJSON map[string]interface{}
  38926. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38929. return
  38930. }
  38931. var res ResultSix
  38932. var resSix10265 ResultSix10265 //1101结果
  38933. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38934. result, _ := json.Marshal(respJSON)
  38935. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38936. utils.ErrorLog("解析失败:%v", err)
  38937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38938. return
  38939. }
  38940. res.InfRefmsgid = resSix10265.InfRefmsgid
  38941. res.Output = resSix10265.Output
  38942. res.ErrMsg = resSix10265.ErrMsg
  38943. res.Cainfo = resSix10265.Cainfo
  38944. res.WarnMsg = resSix10265.WarnMsg
  38945. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38946. res.Infcode = infocode
  38947. if infocode == 0 {
  38948. c.ServeSuccessJSON(map[string]interface{}{
  38949. "msg": "上传成功",
  38950. })
  38951. return
  38952. } else {
  38953. c.ServeSuccessJSON(map[string]interface{}{
  38954. "failed_code": -10,
  38955. "msg": res.ErrMsg,
  38956. })
  38957. return
  38958. }
  38959. }
  38960. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  38961. // WebSocket服务器地址
  38962. serverURL := "ws://127.0.0.1:8899"
  38963. // 解析WebSocket服务器地址
  38964. u, err := url.Parse(serverURL)
  38965. if err != nil {
  38966. }
  38967. // 建立WebSocket连接
  38968. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  38969. if err != nil {
  38970. }
  38971. defer conn.Close()
  38972. input2 := make(map[string]interface{})
  38973. input := make(map[string]interface{})
  38974. inputData := make(map[string]interface{})
  38975. inputData["orgId"] = code
  38976. inputData["businessType"] = "01101"
  38977. inputData["operatorId"] = operator_id
  38978. inputData["operatorName"] = operator_name
  38979. inputData["officeId"] = "001"
  38980. inputData["officeName"] = "血透室"
  38981. inputData["deviceType"] = ""
  38982. input["data"] = inputData
  38983. input["orgId"] = code
  38984. input["transType"] = "ec.query"
  38985. //if md == ""
  38986. if md[:4] == "4403" {
  38987. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38988. } else if md[:4] == "4401" {
  38989. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38990. } else {
  38991. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  38992. }
  38993. input2["indata"] = input
  38994. fmt.Println(input2)
  38995. bytesData, _ := json.Marshal(input2)
  38996. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  38997. if err != nil {
  38998. fmt.Println(err)
  38999. }
  39000. // 接收消息
  39001. _, receivedMessage, err := conn.ReadMessage()
  39002. if err != nil {
  39003. fmt.Println(err)
  39004. }
  39005. return "", string(receivedMessage)
  39006. }
  39007. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39008. // WebSocket服务器地址
  39009. serverURL := "ws://127.0.0.1:8899"
  39010. // 解析WebSocket服务器地址
  39011. u, err := url.Parse(serverURL)
  39012. if err != nil {
  39013. }
  39014. // 建立WebSocket连接
  39015. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39016. if err != nil {
  39017. }
  39018. defer conn.Close()
  39019. input2 := make(map[string]interface{})
  39020. input := make(map[string]interface{})
  39021. inputData := make(map[string]interface{})
  39022. inputData["orgId"] = code
  39023. inputData["businessType"] = "01101"
  39024. inputData["operatorId"] = operator_id
  39025. inputData["operatorName"] = operator_name
  39026. inputData["officeId"] = "001"
  39027. inputData["officeName"] = "血透室"
  39028. inputData["deviceType"] = ""
  39029. input["data"] = inputData
  39030. input["orgId"] = code
  39031. input["transType"] = "ec.query"
  39032. //if md == ""
  39033. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39034. input2["indata"] = input
  39035. fmt.Println(input2)
  39036. bytesData, _ := json.Marshal(input2)
  39037. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39038. if err != nil {
  39039. fmt.Println(err)
  39040. }
  39041. // 接收消息
  39042. _, receivedMessage, err := conn.ReadMessage()
  39043. if err != nil {
  39044. fmt.Println(err)
  39045. }
  39046. return "", string(receivedMessage)
  39047. }
  39048. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39049. // WebSocket服务器地址
  39050. serverURL := "ws://127.0.0.1:8899"
  39051. // 解析WebSocket服务器地址
  39052. u, err := url.Parse(serverURL)
  39053. if err != nil {
  39054. }
  39055. // 建立WebSocket连接
  39056. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39057. if err != nil {
  39058. }
  39059. defer conn.Close()
  39060. input2 := make(map[string]interface{})
  39061. input := make(map[string]interface{})
  39062. inputData := make(map[string]interface{})
  39063. inputData["orgId"] = code
  39064. inputData["businessType"] = "01301"
  39065. inputData["operatorId"] = operator_id
  39066. inputData["operatorName"] = operator_name
  39067. inputData["officeId"] = "001"
  39068. inputData["officeName"] = "血透室"
  39069. inputData["deviceType"] = ""
  39070. input["data"] = inputData
  39071. input["orgId"] = code
  39072. input["transType"] = "ec.query"
  39073. //if md == ""
  39074. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39075. input2["indata"] = input
  39076. fmt.Println(input2)
  39077. bytesData, _ := json.Marshal(input2)
  39078. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39079. if err != nil {
  39080. fmt.Println(err)
  39081. }
  39082. // 接收消息
  39083. _, receivedMessage, err := conn.ReadMessage()
  39084. if err != nil {
  39085. fmt.Println(err)
  39086. }
  39087. return "", string(receivedMessage)
  39088. }
  39089. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39090. // WebSocket服务器地址
  39091. serverURL := "ws://127.0.0.1:8899"
  39092. // 解析WebSocket服务器地址
  39093. u, err := url.Parse(serverURL)
  39094. if err != nil {
  39095. }
  39096. // 建立WebSocket连接
  39097. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39098. if err != nil {
  39099. }
  39100. defer conn.Close()
  39101. input2 := make(map[string]interface{})
  39102. input := make(map[string]interface{})
  39103. inputData := make(map[string]interface{})
  39104. inputData["orgId"] = code
  39105. inputData["businessType"] = "01103"
  39106. inputData["operatorId"] = operator_id
  39107. inputData["operatorName"] = operator_name
  39108. inputData["officeId"] = "001"
  39109. inputData["officeName"] = "血透室"
  39110. inputData["deviceType"] = ""
  39111. input["data"] = inputData
  39112. input["orgId"] = code
  39113. input["transType"] = "ec.query"
  39114. //if md ==
  39115. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39116. input2["indata"] = input
  39117. fmt.Println(input2)
  39118. bytesData, _ := json.Marshal(input2)
  39119. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39120. if err != nil {
  39121. fmt.Println(err)
  39122. }
  39123. // 接收消息
  39124. _, receivedMessage, err := conn.ReadMessage()
  39125. if err != nil {
  39126. fmt.Println(err)
  39127. }
  39128. return "", string(receivedMessage)
  39129. }
  39130. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39131. // WebSocket服务器地址
  39132. serverURL := "ws://127.0.0.1:8899"
  39133. // 解析WebSocket服务器地址
  39134. u, err := url.Parse(serverURL)
  39135. if err != nil {
  39136. }
  39137. // 建立WebSocket连接
  39138. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39139. if err != nil {
  39140. }
  39141. defer conn.Close()
  39142. input2 := make(map[string]interface{})
  39143. input := make(map[string]interface{})
  39144. inputData := make(map[string]interface{})
  39145. inputData["orgId"] = code
  39146. inputData["businessType"] = "01101"
  39147. inputData["operatorId"] = operator_id
  39148. inputData["operatorName"] = operator_name
  39149. inputData["officeId"] = "001"
  39150. inputData["officeName"] = "血透室"
  39151. inputData["deviceType"] = ""
  39152. input["data"] = inputData
  39153. input["orgId"] = code
  39154. input["transType"] = "ec.query"
  39155. //if md == ""
  39156. if md[:4] == "4403" {
  39157. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39158. } else if md[:4] == "4401" {
  39159. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39160. } else {
  39161. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39162. }
  39163. input2["indata"] = input
  39164. fmt.Println(input2)
  39165. bytesData, _ := json.Marshal(input2)
  39166. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39167. if err != nil {
  39168. fmt.Println(err)
  39169. }
  39170. // 接收消息
  39171. _, receivedMessage, err := conn.ReadMessage()
  39172. if err != nil {
  39173. fmt.Println(err)
  39174. }
  39175. return "", string(receivedMessage)
  39176. }
  39177. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39178. // WebSocket服务器地址
  39179. serverURL := "ws://127.0.0.1:8899"
  39180. // 解析WebSocket服务器地址
  39181. u, err := url.Parse(serverURL)
  39182. if err != nil {
  39183. }
  39184. // 建立WebSocket连接
  39185. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39186. if err != nil {
  39187. }
  39188. defer conn.Close()
  39189. input2 := make(map[string]interface{})
  39190. input := make(map[string]interface{})
  39191. inputData := make(map[string]interface{})
  39192. inputData["orgId"] = code
  39193. inputData["businessType"] = "01301"
  39194. inputData["operatorId"] = operator_id
  39195. inputData["operatorName"] = operator_name
  39196. inputData["officeId"] = "001"
  39197. inputData["officeName"] = "血透室"
  39198. inputData["deviceType"] = ""
  39199. input["data"] = inputData
  39200. input["orgId"] = code
  39201. input["transType"] = "ec.query"
  39202. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39203. input2["indata"] = input
  39204. bytesData, _ := json.Marshal(input2)
  39205. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39206. if err != nil {
  39207. fmt.Println(err)
  39208. }
  39209. // 接收消息
  39210. _, receivedMessage, err := conn.ReadMessage()
  39211. if err != nil {
  39212. fmt.Println(err)
  39213. }
  39214. return "", string(receivedMessage)
  39215. }
  39216. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39217. newArr = make([]string, 0)
  39218. for i := 0; i < len(arr); i++ {
  39219. repeat := false
  39220. for j := i + 1; j < len(arr); j++ {
  39221. if arr[i] == arr[j] {
  39222. repeat = true
  39223. break
  39224. }
  39225. }
  39226. if !repeat {
  39227. newArr = append(newArr, arr[i])
  39228. }
  39229. }
  39230. return
  39231. }
  39232. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39233. if len(idNumber) != 18 {
  39234. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39235. }
  39236. // 提取出生日期
  39237. year, err := strconv.Atoi(idNumber[6:10])
  39238. if err != nil {
  39239. return "", 0, err
  39240. }
  39241. month, err := strconv.Atoi(idNumber[10:12])
  39242. if err != nil {
  39243. return "", 0, err
  39244. }
  39245. day, err := strconv.Atoi(idNumber[12:14])
  39246. if err != nil {
  39247. return "", 0, err
  39248. }
  39249. // 格式化生日字符串
  39250. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39251. birthdateFormatted := birthdate.Format("2006-01-02")
  39252. // 计算年龄
  39253. today := time.Now()
  39254. age := today.Year() - birthdate.Year()
  39255. if today.YearDay() < birthdate.YearDay() {
  39256. age--
  39257. }
  39258. return birthdateFormatted, age, nil
  39259. }
  39260. // 从身份证号码中提取出生年月日
  39261. func getBirthDateFromIDCard(idCard string) (string, error) {
  39262. // 身份证号码长度应为18位
  39263. if len(idCard) != 18 {
  39264. return "", fmt.Errorf("身份证号码长度应为18位")
  39265. }
  39266. // 提取出生日期部分 (YYYYMMDD)
  39267. birthDateStr := idCard[6:14]
  39268. // 解析出生日期
  39269. birthDate, err := time.Parse("20060102", birthDateStr)
  39270. if err != nil {
  39271. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39272. }
  39273. // 格式化出生日期为 YYYY-MM-DD
  39274. formattedDate := birthDate.Format("2006-01-02")
  39275. return formattedDate, nil
  39276. }