his_api_controller.go 1.7MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737
  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/CFYLJG012", &HisApiController{}, "get:GetCFYLJG12")
  117. beego.Router("/api/CFYLJG013", &HisApiController{}, "get:GetCFYLJG13")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  137. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  138. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  139. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  140. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  141. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  142. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  143. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  144. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  145. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  146. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  147. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  148. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  149. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  150. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  151. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  152. //库盘和变更
  153. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  154. //删除库盘和变更
  155. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  156. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  157. //药品变更
  158. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  159. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  160. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  161. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  162. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  163. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  164. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  165. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  166. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  167. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  168. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  169. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  170. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  171. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  172. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  173. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  174. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  175. beego.Router("/api/5101", &HisApiController{}, "get:Get5101")
  176. beego.Router("/api/5102", &HisApiController{}, "get:Get5102")
  177. }
  178. func (c *HisApiController) Get5101() {
  179. adminUser := c.GetAdminUserInfo()
  180. admin_user_id, _ := c.GetInt64("admin_user_id")
  181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  182. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  183. if miConfig.MdtrtareaAdmvs == "341203" {
  184. fmt.Println(miConfig.SecretKey)
  185. var res models.Result9001Two
  186. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  187. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  188. resp, requestErr := http.Get(api)
  189. if requestErr != nil {
  190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  191. return
  192. }
  193. body, ioErr := ioutil.ReadAll(resp.Body)
  194. if ioErr != nil {
  195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  197. return
  198. }
  199. var respJSON map[string]interface{}
  200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  203. return
  204. }
  205. status := respJSON["data"].(map[string]interface{})["status"].(string)
  206. if status == "0" {
  207. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  208. c.ServeSuccessJSON(map[string]interface{}{
  209. "failed_code": -10,
  210. "msg": err_msg,
  211. })
  212. return
  213. }
  214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  215. result, _ := json.Marshal(respJSON)
  216. fmt.Println("log")
  217. fmt.Println(string(result))
  218. if err := json.Unmarshal([]byte(result), &res); err != nil {
  219. utils.ErrorLog("解析失败:%v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. if res.Infcode == 0 {
  224. sign := models.HisSignIn{
  225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  226. SignNo: res.Output.Signinoutb.SignNo,
  227. SignTime: "",
  228. Ctime: time.Now().Unix(),
  229. Mtime: time.Now().Unix(),
  230. Status: 1,
  231. InputLog: "",
  232. OutputLog: "",
  233. FixmedinsCode: miConfig.Code,
  234. }
  235. err := service.CreateSignIn(&sign)
  236. if err == nil {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "msg": "签到成功",
  239. })
  240. }
  241. } else {
  242. c.ServeSuccessJSON(map[string]interface{}{
  243. "failed_code": -10,
  244. "msg": res.ErrMsg,
  245. })
  246. return
  247. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  248. //return
  249. }
  250. } else if miConfig.MdtrtareaAdmvs == "340699" {
  251. fmt.Println(miConfig.SecretKey)
  252. var res models.Result9001Two
  253. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  254. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  255. resp, requestErr := http.Get(api)
  256. if requestErr != nil {
  257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  258. return
  259. }
  260. body, ioErr := ioutil.ReadAll(resp.Body)
  261. if ioErr != nil {
  262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  264. return
  265. }
  266. var respJSON map[string]interface{}
  267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  270. return
  271. }
  272. status := respJSON["data"].(map[string]interface{})["status"].(string)
  273. if status == "0" {
  274. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  275. c.ServeSuccessJSON(map[string]interface{}{
  276. "failed_code": -10,
  277. "msg": err_msg,
  278. })
  279. return
  280. }
  281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  282. result, _ := json.Marshal(respJSON)
  283. fmt.Println("log")
  284. fmt.Println(string(result))
  285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  286. utils.ErrorLog("解析失败:%v", err)
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. if res.Infcode == 0 {
  291. sign := models.HisSignIn{
  292. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  293. SignNo: res.Output.Signinoutb.SignNo,
  294. SignTime: "",
  295. Ctime: time.Now().Unix(),
  296. Mtime: time.Now().Unix(),
  297. Status: 1,
  298. InputLog: "",
  299. OutputLog: "",
  300. FixmedinsCode: miConfig.Code,
  301. }
  302. err := service.CreateSignIn(&sign)
  303. if err == nil {
  304. c.ServeSuccessJSON(map[string]interface{}{
  305. "msg": "查询成功",
  306. })
  307. }
  308. } else {
  309. c.ServeSuccessJSON(map[string]interface{}{
  310. "failed_code": -10,
  311. "msg": res.ErrMsg,
  312. })
  313. return
  314. }
  315. }
  316. }
  317. func (c *HisApiController) Get5102() {
  318. adminUser := c.GetAdminUserInfo()
  319. admin_user_id, _ := c.GetInt64("admin_user_id")
  320. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  321. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  322. if miConfig.MdtrtareaAdmvs == "341203" {
  323. fmt.Println(miConfig.SecretKey)
  324. var res models.Result9001Two
  325. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  326. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  327. resp, requestErr := http.Get(api)
  328. if requestErr != nil {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  330. return
  331. }
  332. body, ioErr := ioutil.ReadAll(resp.Body)
  333. if ioErr != nil {
  334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  336. return
  337. }
  338. var respJSON map[string]interface{}
  339. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  342. return
  343. }
  344. status := respJSON["data"].(map[string]interface{})["status"].(string)
  345. if status == "0" {
  346. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  347. c.ServeSuccessJSON(map[string]interface{}{
  348. "failed_code": -10,
  349. "msg": err_msg,
  350. })
  351. return
  352. }
  353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  354. result, _ := json.Marshal(respJSON)
  355. fmt.Println("log")
  356. fmt.Println(string(result))
  357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  358. utils.ErrorLog("解析失败:%v", err)
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. if res.Infcode == 0 {
  363. sign := models.HisSignIn{
  364. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  365. SignNo: res.Output.Signinoutb.SignNo,
  366. SignTime: "",
  367. Ctime: time.Now().Unix(),
  368. Mtime: time.Now().Unix(),
  369. Status: 1,
  370. InputLog: "",
  371. OutputLog: "",
  372. FixmedinsCode: miConfig.Code,
  373. }
  374. err := service.CreateSignIn(&sign)
  375. if err == nil {
  376. c.ServeSuccessJSON(map[string]interface{}{
  377. "msg": "签到成功",
  378. })
  379. }
  380. } else {
  381. c.ServeSuccessJSON(map[string]interface{}{
  382. "failed_code": -10,
  383. "msg": res.ErrMsg,
  384. })
  385. return
  386. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  387. //return
  388. }
  389. } else if miConfig.MdtrtareaAdmvs == "340699" {
  390. fmt.Println(miConfig.SecretKey)
  391. var res models.Result9001Two
  392. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  394. resp, requestErr := http.Get(api)
  395. if requestErr != nil {
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  397. return
  398. }
  399. body, ioErr := ioutil.ReadAll(resp.Body)
  400. if ioErr != nil {
  401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  403. return
  404. }
  405. var respJSON map[string]interface{}
  406. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. return
  410. }
  411. status := respJSON["data"].(map[string]interface{})["status"].(string)
  412. if status == "0" {
  413. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  414. c.ServeSuccessJSON(map[string]interface{}{
  415. "failed_code": -10,
  416. "msg": err_msg,
  417. })
  418. return
  419. }
  420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  421. result, _ := json.Marshal(respJSON)
  422. fmt.Println("log")
  423. fmt.Println(string(result))
  424. if err := json.Unmarshal([]byte(result), &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == 0 {
  430. sign := models.HisSignIn{
  431. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  432. SignNo: res.Output.Signinoutb.SignNo,
  433. SignTime: "",
  434. Ctime: time.Now().Unix(),
  435. Mtime: time.Now().Unix(),
  436. Status: 1,
  437. InputLog: "",
  438. OutputLog: "",
  439. FixmedinsCode: miConfig.Code,
  440. }
  441. err := service.CreateSignIn(&sign)
  442. if err == nil {
  443. c.ServeSuccessJSON(map[string]interface{}{
  444. "msg": "查询成功",
  445. })
  446. }
  447. } else {
  448. c.ServeSuccessJSON(map[string]interface{}{
  449. "failed_code": -10,
  450. "msg": res.ErrMsg,
  451. })
  452. return
  453. }
  454. }
  455. }
  456. func (c *HisApiController) Get3201() {
  457. adminUser := c.GetAdminUserInfo()
  458. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  459. 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)
  460. var response Response
  461. if err := json.Unmarshal([]byte(result), &response); err != nil {
  462. fmt.Println("Error decoding JSON:", err)
  463. return
  464. }
  465. }
  466. func (c *HisApiController) TestNet() {
  467. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  468. //return
  469. c.ServeSuccessJSON(map[string]interface{}{
  470. "msg": "成功",
  471. })
  472. }
  473. func (c *HisApiController) Get3508() {
  474. admin_user_id, _ := c.GetInt64("admin_user_id")
  475. drug_id, _ := c.GetInt64("id")
  476. start_time := c.GetString("start_time")
  477. end_time := c.GetString("end_time")
  478. adminUser := c.GetAdminUserInfo()
  479. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  480. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  481. drug, _ := service.GetDrugByID(drug_id)
  482. var struct3508 models.Struct3508
  483. struct3508.OrgName = miConfig.OrgName
  484. struct3508.FixmedinsCode = miConfig.Code
  485. struct3508.AccessKey = miConfig.AccessKey
  486. struct3508.Opter = curRoles.UserName
  487. struct3508.RequestUrl = miConfig.Url
  488. struct3508.Url = miConfig.Url
  489. struct3508.AppId = miConfig.Cainfo
  490. struct3508.AppSecret = miConfig.AppSecret
  491. struct3508.Enckey = miConfig.EncKey
  492. struct3508.SignKey = miConfig.SignKey
  493. struct3508.SecretKey = miConfig.SecretKey
  494. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  495. struct3508.Begndate = start_time
  496. struct3508.Enddate = end_time
  497. result1, result2, _ := service.FJyb3508(struct3508)
  498. saveLog(result1, result2, "3508", "3508")
  499. var res models.Result3508
  500. var respJSON2 map[string]interface{}
  501. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  504. return
  505. }
  506. userJSONBytes2, _ := json.Marshal(respJSON2)
  507. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  508. utils.ErrorLog("解析失败:%v", err)
  509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  510. return
  511. }
  512. if res.Infcode == -1 {
  513. c.ServeSuccessJSON(map[string]interface{}{
  514. "failed_code": -10,
  515. "msg": res.ErrMsg,
  516. })
  517. } else {
  518. c.ServeSuccessJSON(map[string]interface{}{
  519. "info": res.Output,
  520. })
  521. }
  522. }
  523. func (c *HisApiController) Get3509() {
  524. admin_user_id, _ := c.GetInt64("admin_user_id")
  525. drug_id, _ := c.GetInt64("id")
  526. start_time := c.GetString("start_time")
  527. end_time := c.GetString("end_time")
  528. adminUser := c.GetAdminUserInfo()
  529. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  530. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  531. drug, _ := service.GetDrugByID(drug_id)
  532. var struct3508 models.Struct3509
  533. struct3508.OrgName = miConfig.OrgName
  534. struct3508.FixmedinsCode = miConfig.Code
  535. struct3508.AccessKey = miConfig.AccessKey
  536. struct3508.Opter = curRoles.UserName
  537. struct3508.RequestUrl = miConfig.Url
  538. struct3508.Url = miConfig.Url
  539. struct3508.AppId = miConfig.Cainfo
  540. struct3508.AppSecret = miConfig.AppSecret
  541. struct3508.Enckey = miConfig.EncKey
  542. struct3508.SignKey = miConfig.SignKey
  543. struct3508.SecretKey = miConfig.SecretKey
  544. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  545. struct3508.Begndate = start_time
  546. struct3508.Enddate = end_time
  547. result1, result2, _ := service.FJyb3509(struct3508)
  548. saveLog(result1, result2, "3509", "3509")
  549. var res models.Result3509
  550. var respJSON2 map[string]interface{}
  551. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  554. return
  555. }
  556. userJSONBytes2, _ := json.Marshal(respJSON2)
  557. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  558. utils.ErrorLog("解析失败:%v", err)
  559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  560. return
  561. }
  562. if res.Infcode == -1 {
  563. c.ServeSuccessJSON(map[string]interface{}{
  564. "failed_code": -10,
  565. "msg": res.ErrMsg,
  566. })
  567. } else {
  568. c.ServeSuccessJSON(map[string]interface{}{
  569. "info": res.Output,
  570. })
  571. }
  572. }
  573. func (c *HisApiController) Get3510() {
  574. admin_user_id, _ := c.GetInt64("admin_user_id")
  575. drug_id, _ := c.GetInt64("id")
  576. start_time := c.GetString("start_time")
  577. end_time := c.GetString("end_time")
  578. adminUser := c.GetAdminUserInfo()
  579. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  580. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  581. drug, _ := service.GetDrugByID(drug_id)
  582. var struct3508 models.Struct3510
  583. struct3508.FixmedinsCode = miConfig.Code
  584. struct3508.OrgName = miConfig.OrgName
  585. struct3508.AccessKey = miConfig.AccessKey
  586. struct3508.Opter = curRoles.UserName
  587. struct3508.RequestUrl = miConfig.Url
  588. struct3508.Url = miConfig.Url
  589. struct3508.AppId = miConfig.Cainfo
  590. struct3508.AppSecret = miConfig.AppSecret
  591. struct3508.Enckey = miConfig.EncKey
  592. struct3508.SignKey = miConfig.SignKey
  593. struct3508.SecretKey = miConfig.SecretKey
  594. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  595. struct3508.Begndate = start_time
  596. struct3508.Enddate = end_time
  597. result1, result2, _ := service.FJyb3510(struct3508)
  598. saveLog(result1, result2, "3510", "3510")
  599. var res models.Result3510
  600. var respJSON2 map[string]interface{}
  601. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  604. return
  605. }
  606. userJSONBytes2, _ := json.Marshal(respJSON2)
  607. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  608. utils.ErrorLog("解析失败:%v", err)
  609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  610. return
  611. }
  612. if res.Infcode == -1 {
  613. c.ServeSuccessJSON(map[string]interface{}{
  614. "failed_code": -10,
  615. "msg": res.ErrMsg,
  616. })
  617. } else {
  618. c.ServeSuccessJSON(map[string]interface{}{
  619. "info": res.Output,
  620. })
  621. }
  622. }
  623. func (c *HisApiController) Get3511() {
  624. admin_user_id, _ := c.GetInt64("admin_user_id")
  625. drug_id, _ := c.GetInt64("id")
  626. start_time := c.GetString("start_time")
  627. end_time := c.GetString("end_time")
  628. adminUser := c.GetAdminUserInfo()
  629. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  630. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  631. drug, _ := service.GetDrugByID(drug_id)
  632. var struct3508 models.Struct3511
  633. struct3508.FixmedinsCode = miConfig.Code
  634. struct3508.OrgName = miConfig.OrgName
  635. struct3508.AccessKey = miConfig.AccessKey
  636. struct3508.Opter = curRoles.UserName
  637. struct3508.RequestUrl = miConfig.Url
  638. struct3508.Url = miConfig.Url
  639. struct3508.AppId = miConfig.Cainfo
  640. struct3508.AppSecret = miConfig.AppSecret
  641. struct3508.Enckey = miConfig.EncKey
  642. struct3508.SignKey = miConfig.SignKey
  643. struct3508.SecretKey = miConfig.SecretKey
  644. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  645. struct3508.Begndate = start_time
  646. struct3508.Enddate = end_time
  647. result1, result2, _ := service.FJyb3511(struct3508)
  648. saveLog(result1, result2, "3511", "3511")
  649. var res models.Result3511
  650. var respJSON2 map[string]interface{}
  651. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  654. return
  655. }
  656. userJSONBytes2, _ := json.Marshal(respJSON2)
  657. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  658. utils.ErrorLog("解析失败:%v", err)
  659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  660. return
  661. }
  662. if res.Infcode == -1 {
  663. c.ServeSuccessJSON(map[string]interface{}{
  664. "failed_code": -10,
  665. "msg": res.ErrMsg,
  666. })
  667. } else {
  668. c.ServeSuccessJSON(map[string]interface{}{
  669. "info": res.Output,
  670. })
  671. }
  672. }
  673. func (c *HisApiController) Get3512() {
  674. admin_user_id, _ := c.GetInt64("admin_user_id")
  675. drug_id, _ := c.GetInt64("id")
  676. start_time := c.GetString("start_time")
  677. end_time := c.GetString("end_time")
  678. adminUser := c.GetAdminUserInfo()
  679. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  680. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  681. drug, _ := service.GetDrugByID(drug_id)
  682. var struct3508 models.Struct3512
  683. struct3508.FixmedinsCode = miConfig.Code
  684. struct3508.OrgName = miConfig.OrgName
  685. struct3508.AccessKey = miConfig.AccessKey
  686. struct3508.Opter = curRoles.UserName
  687. struct3508.RequestUrl = miConfig.Url
  688. struct3508.Url = miConfig.Url
  689. struct3508.AppId = miConfig.Cainfo
  690. struct3508.AppSecret = miConfig.AppSecret
  691. struct3508.Enckey = miConfig.EncKey
  692. struct3508.SignKey = miConfig.SignKey
  693. struct3508.SecretKey = miConfig.SecretKey
  694. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  695. struct3508.Begndate = start_time
  696. struct3508.Enddate = end_time
  697. result1, result2, _ := service.FJyb3512(struct3508)
  698. saveLog(result1, result2, "3512", "3512")
  699. var res models.Result3512
  700. var respJSON2 map[string]interface{}
  701. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. userJSONBytes2, _ := json.Marshal(respJSON2)
  707. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  708. utils.ErrorLog("解析失败:%v", err)
  709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  710. return
  711. }
  712. if res.Infcode == -1 {
  713. c.ServeSuccessJSON(map[string]interface{}{
  714. "failed_code": -10,
  715. "msg": res.ErrMsg,
  716. })
  717. } else {
  718. c.ServeSuccessJSON(map[string]interface{}{
  719. "info": res.Output,
  720. })
  721. }
  722. }
  723. func (c *HisApiController) Get3513() {
  724. admin_user_id, _ := c.GetInt64("admin_user_id")
  725. drug_id, _ := c.GetInt64("id")
  726. start_time := c.GetString("start_time")
  727. end_time := c.GetString("end_time")
  728. adminUser := c.GetAdminUserInfo()
  729. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  730. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  731. drug, _ := service.GetDrugByID(drug_id)
  732. var struct3508 models.Struct3513
  733. struct3508.FixmedinsCode = miConfig.Code
  734. struct3508.OrgName = miConfig.OrgName
  735. struct3508.AccessKey = miConfig.AccessKey
  736. struct3508.Opter = curRoles.UserName
  737. struct3508.RequestUrl = miConfig.Url
  738. struct3508.Url = miConfig.Url
  739. struct3508.AppId = miConfig.Cainfo
  740. struct3508.AppSecret = miConfig.AppSecret
  741. struct3508.Enckey = miConfig.EncKey
  742. struct3508.SignKey = miConfig.SignKey
  743. struct3508.SecretKey = miConfig.SecretKey
  744. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  745. struct3508.Begndate = start_time
  746. struct3508.Enddate = end_time
  747. result1, result2, _ := service.FJyb3513(struct3508)
  748. saveLog(result1, result2, "3513", "3513")
  749. var res models.Result3513
  750. var respJSON2 map[string]interface{}
  751. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  754. return
  755. }
  756. userJSONBytes2, _ := json.Marshal(respJSON2)
  757. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  758. utils.ErrorLog("解析失败:%v", err)
  759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  760. return
  761. }
  762. if res.Infcode == -1 {
  763. c.ServeSuccessJSON(map[string]interface{}{
  764. "failed_code": -10,
  765. "msg": res.ErrMsg,
  766. })
  767. } else {
  768. c.ServeSuccessJSON(map[string]interface{}{
  769. "info": res.Output,
  770. })
  771. }
  772. }
  773. func (c *HisApiController) Get35081() {
  774. admin_user_id, _ := c.GetInt64("admin_user_id")
  775. drug_id, _ := c.GetInt64("id")
  776. //start_time := c.GetString("start_time")
  777. //end_time := c.GetString("end_time")
  778. page, _ := c.GetInt("page")
  779. adminUser := c.GetAdminUserInfo()
  780. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  781. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  782. drug, _ := service.GetDrugByID(drug_id)
  783. var struct3508 models.Struct35081
  784. struct3508.FixmedinsCode = miConfig.Code
  785. struct3508.OrgName = miConfig.OrgName
  786. struct3508.AccessKey = miConfig.AccessKey
  787. struct3508.Opter = curRoles.UserName
  788. struct3508.RequestUrl = miConfig.Url
  789. struct3508.Url = miConfig.Url
  790. struct3508.AppId = miConfig.Cainfo
  791. struct3508.AppSecret = miConfig.AppSecret
  792. struct3508.Enckey = miConfig.EncKey
  793. struct3508.SignKey = miConfig.SignKey
  794. struct3508.SecretKey = miConfig.SecretKey
  795. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  796. struct3508.PageNum = page
  797. struct3508.PageSize = 10
  798. result1, result2, _ := service.FJyb35081(struct3508)
  799. saveLog(result1, result2, "35081", "35081")
  800. var res models.Result35081
  801. var respJSON2 map[string]interface{}
  802. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  805. return
  806. }
  807. userJSONBytes2, _ := json.Marshal(respJSON2)
  808. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  809. utils.ErrorLog("解析失败:%v", err)
  810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  811. return
  812. }
  813. if res.Infcode == -1 {
  814. c.ServeSuccessJSON(map[string]interface{}{
  815. "failed_code": -10,
  816. "msg": res.ErrMsg,
  817. })
  818. } else {
  819. c.ServeSuccessJSON(map[string]interface{}{
  820. "info": res.Output,
  821. })
  822. }
  823. }
  824. func (c *HisApiController) Get35082() {
  825. admin_user_id, _ := c.GetInt64("admin_user_id")
  826. drug_id, _ := c.GetInt64("id")
  827. //start_time := c.GetString("start_time")
  828. //end_time := c.GetString("end_time")
  829. page, _ := c.GetInt("page")
  830. adminUser := c.GetAdminUserInfo()
  831. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  832. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  833. drug, _ := service.GetDrugByID(drug_id)
  834. var struct3508 models.Struct35082
  835. struct3508.FixmedinsCode = miConfig.Code
  836. struct3508.OrgName = miConfig.OrgName
  837. struct3508.AccessKey = miConfig.AccessKey
  838. struct3508.Opter = curRoles.UserName
  839. struct3508.RequestUrl = miConfig.Url
  840. struct3508.Url = miConfig.Url
  841. struct3508.AppId = miConfig.Cainfo
  842. struct3508.AppSecret = miConfig.AppSecret
  843. struct3508.Enckey = miConfig.EncKey
  844. struct3508.SignKey = miConfig.SignKey
  845. struct3508.SecretKey = miConfig.SecretKey
  846. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  847. struct3508.PageNum = page
  848. struct3508.PageSize = 10
  849. result1, result2, _ := service.FJyb35082(struct3508)
  850. saveLog(result1, result2, "35082", "35082")
  851. var res models.Result35082
  852. var respJSON2 map[string]interface{}
  853. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  856. return
  857. }
  858. userJSONBytes2, _ := json.Marshal(respJSON2)
  859. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  860. utils.ErrorLog("解析失败:%v", err)
  861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  862. return
  863. }
  864. if res.Infcode == -1 {
  865. c.ServeSuccessJSON(map[string]interface{}{
  866. "failed_code": -10,
  867. "msg": res.ErrMsg,
  868. })
  869. } else {
  870. c.ServeSuccessJSON(map[string]interface{}{
  871. "info": res.Output,
  872. })
  873. }
  874. }
  875. func (c *HisApiController) FJ3501AND3502() {
  876. ids := c.GetString("ids")
  877. admin_user_id, _ := c.GetInt64("admin_user_id")
  878. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  879. id_arr := strings.Split(ids, ",")
  880. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  881. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  882. //库盘
  883. var errs []string
  884. for _, drug := range drugs {
  885. if drug.IsPc == 0 {
  886. var res2 ResultSix
  887. var res3 ResultSix
  888. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  889. var struct3501 models.Struct3501
  890. struct3501.Code = miConfig.Code
  891. struct3501.OrgName = miConfig.OrgName
  892. struct3501.AccessKey = miConfig.AccessKey
  893. struct3501.Opter = roles.UserName
  894. struct3501.RequestUrl = miConfig.Url
  895. struct3501.Url = miConfig.Url
  896. struct3501.AppId = miConfig.Cainfo
  897. struct3501.AppSecret = miConfig.AppSecret
  898. struct3501.Enckey = miConfig.EncKey
  899. struct3501.SignKey = miConfig.SignKey
  900. struct3501.SecretKey = miConfig.SecretKey
  901. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  902. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  903. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  904. struct3501.RxFlag = "1"
  905. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  906. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  907. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  908. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  909. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  910. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  911. struct3501.FixmedinsBchno = number
  912. struct3501.DrugTracCodg = drug.DrugCode
  913. memo := make(map[string]interface{})
  914. memo["pric"] = drug.Price
  915. bytesData, _ := json.Marshal(memo)
  916. struct3501.Memo = string(bytesData)
  917. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  918. result1, result2, _ := service.FJyb3501(struct3501)
  919. saveLog(result1, result2, "3501", "3501")
  920. //saveLog(result, requestLog, "2201", "挂号")
  921. var respJSON2 map[string]interface{}
  922. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  925. return
  926. }
  927. userJSONBytes2, _ := json.Marshal(respJSON2)
  928. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  929. utils.ErrorLog("解析失败:%v", err)
  930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  931. return
  932. }
  933. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  934. data := make(map[string]interface{})
  935. data["struct_3501s"] = struct3501
  936. client := &http.Client{}
  937. bytesData, _ := json.Marshal(data)
  938. var req *http.Request
  939. if miConfig.MdtrtareaAdmvs == "320921" {
  940. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  941. } else {
  942. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  943. }
  944. resp, _ := client.Do(req)
  945. defer resp.Body.Close()
  946. body, ioErr := ioutil.ReadAll(resp.Body)
  947. if ioErr != nil {
  948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  949. }
  950. var respJSON map[string]interface{}
  951. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  954. return
  955. }
  956. var resSix10265 ResultSix10265 //1101结果
  957. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  958. result, _ := json.Marshal(respJSON)
  959. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  960. utils.ErrorLog("解析失败:%v", err)
  961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  962. return
  963. }
  964. res2.InfRefmsgid = resSix10265.InfRefmsgid
  965. res2.Output = resSix10265.Output
  966. res2.ErrMsg = resSix10265.ErrMsg
  967. res2.Cainfo = resSix10265.Cainfo
  968. res2.WarnMsg = resSix10265.WarnMsg
  969. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  970. res2.Infcode = infocode
  971. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  972. data := make(map[string]interface{})
  973. data["struct_3501s"] = struct3501
  974. client := &http.Client{}
  975. bytesData, _ := json.Marshal(data)
  976. var req *http.Request
  977. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  978. resp, _ := client.Do(req)
  979. defer resp.Body.Close()
  980. body, ioErr := ioutil.ReadAll(resp.Body)
  981. if ioErr != nil {
  982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  983. }
  984. var respJSON map[string]interface{}
  985. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  988. return
  989. }
  990. var resSix10265 ResultSix10265 //1101结果
  991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  992. result, _ := json.Marshal(respJSON)
  993. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  994. utils.ErrorLog("解析失败:%v", err)
  995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  996. return
  997. }
  998. res2.InfRefmsgid = resSix10265.InfRefmsgid
  999. res2.Output = resSix10265.Output
  1000. res2.ErrMsg = resSix10265.ErrMsg
  1001. res2.Cainfo = resSix10265.Cainfo
  1002. res2.WarnMsg = resSix10265.WarnMsg
  1003. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1004. res2.Infcode = infocode
  1005. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  1006. data := make(map[string]interface{})
  1007. data["struct_3501s"] = struct3501
  1008. client := &http.Client{}
  1009. bytesData, _ := json.Marshal(data)
  1010. var req *http.Request
  1011. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  1012. resp, _ := client.Do(req)
  1013. defer resp.Body.Close()
  1014. body, ioErr := ioutil.ReadAll(resp.Body)
  1015. if ioErr != nil {
  1016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1017. }
  1018. var respJSON map[string]interface{}
  1019. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1022. return
  1023. }
  1024. var resSix10265 ResultSix10265 //1101结果
  1025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1026. result, _ := json.Marshal(respJSON)
  1027. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1028. utils.ErrorLog("解析失败:%v", err)
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. return
  1031. }
  1032. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1033. res2.Output = resSix10265.Output
  1034. res2.ErrMsg = resSix10265.ErrMsg
  1035. res2.Cainfo = resSix10265.Cainfo
  1036. res2.WarnMsg = resSix10265.WarnMsg
  1037. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1038. res2.Infcode = infocode
  1039. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  1040. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  1041. saveLog(result1, result2, "3501", "3501")
  1042. //saveLog(result, requestLog, "2201", "挂号")
  1043. var respJSON2 map[string]interface{}
  1044. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1047. return
  1048. }
  1049. userJSONBytes2, _ := json.Marshal(respJSON2)
  1050. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1051. utils.ErrorLog("解析失败:%v", err)
  1052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1053. return
  1054. }
  1055. }
  1056. if res2.Infcode != -1 {
  1057. drug.IsPc = 1
  1058. drug.Bchno = number
  1059. drug.PcDate = time.Now().Unix()
  1060. err := service.SaveW(drug)
  1061. if err == nil {
  1062. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  1063. var struct3502 models.Struct3502
  1064. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1065. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1066. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1067. struct3502.FixmedinsCode = miConfig.Code
  1068. struct3502.Code = miConfig.Code
  1069. struct3502.RxFlag = "0"
  1070. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1071. struct3502.OrgName = miConfig.OrgName
  1072. struct3502.Opter = roles.UserName
  1073. struct3502.AccessKey = miConfig.AccessKey
  1074. struct3502.RequestUrl = miConfig.Url
  1075. struct3502.SecretKey = miConfig.SecretKey
  1076. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1077. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1078. struct3502.Url = miConfig.Url
  1079. struct3502.AppId = miConfig.Cainfo
  1080. struct3502.AppSecret = miConfig.AppSecret
  1081. struct3502.Enckey = miConfig.EncKey
  1082. struct3502.SignKey = miConfig.SignKey
  1083. struct3502.SecretKey = miConfig.SecretKey
  1084. struct3502.DrugTracCodg = drug.DrugCode
  1085. struct3502.Memo = ""
  1086. struct3502.InvChgType = "108"
  1087. struct3502.FixmedinsBchno = bg_number
  1088. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  1089. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  1090. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  1091. result11, result22, _ := service.FJyb3502(struct3502)
  1092. saveLog(result11, result22, "3502", "3502")
  1093. var respJSON3 map[string]interface{}
  1094. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. userJSONBytes3, _ := json.Marshal(respJSON3)
  1100. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1101. utils.ErrorLog("解析失败:%v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. return
  1104. }
  1105. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1106. data := make(map[string]interface{})
  1107. data["struct_3502s"] = struct3502
  1108. client := &http.Client{}
  1109. bytesData, _ := json.Marshal(data)
  1110. var req *http.Request
  1111. if miConfig.MdtrtareaAdmvs == "320921" {
  1112. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1113. } else {
  1114. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1115. }
  1116. resp, _ := client.Do(req)
  1117. defer resp.Body.Close()
  1118. body, ioErr := ioutil.ReadAll(resp.Body)
  1119. if ioErr != nil {
  1120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1121. }
  1122. var respJSON map[string]interface{}
  1123. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1126. return
  1127. }
  1128. var resSix10265 ResultSix10265 //1101结果
  1129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1130. result, _ := json.Marshal(respJSON)
  1131. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1132. utils.ErrorLog("解析失败:%v", err)
  1133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1134. return
  1135. }
  1136. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1137. res3.Output = resSix10265.Output
  1138. res3.ErrMsg = resSix10265.ErrMsg
  1139. res3.Cainfo = resSix10265.Cainfo
  1140. res3.WarnMsg = resSix10265.WarnMsg
  1141. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1142. res3.Infcode = infocode
  1143. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1144. data := make(map[string]interface{})
  1145. data["struct_3502s"] = struct3502
  1146. client := &http.Client{}
  1147. bytesData, _ := json.Marshal(data)
  1148. var req *http.Request
  1149. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  1150. resp, _ := client.Do(req)
  1151. defer resp.Body.Close()
  1152. body, ioErr := ioutil.ReadAll(resp.Body)
  1153. if ioErr != nil {
  1154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1155. }
  1156. var respJSON map[string]interface{}
  1157. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1160. return
  1161. }
  1162. var resSix10265 ResultSix10265 //1101结果
  1163. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1164. result, _ := json.Marshal(respJSON)
  1165. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1166. utils.ErrorLog("解析失败:%v", err)
  1167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1168. return
  1169. }
  1170. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1171. res3.Output = resSix10265.Output
  1172. res3.ErrMsg = resSix10265.ErrMsg
  1173. res3.Cainfo = resSix10265.Cainfo
  1174. res3.WarnMsg = resSix10265.WarnMsg
  1175. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1176. res3.Infcode = infocode
  1177. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1178. data := make(map[string]interface{})
  1179. data["struct_3501s"] = struct3501
  1180. client := &http.Client{}
  1181. bytesData, _ := json.Marshal(data)
  1182. var req *http.Request
  1183. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1184. resp, _ := client.Do(req)
  1185. defer resp.Body.Close()
  1186. body, ioErr := ioutil.ReadAll(resp.Body)
  1187. if ioErr != nil {
  1188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1189. }
  1190. var respJSON map[string]interface{}
  1191. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1194. return
  1195. }
  1196. var resSix10265 ResultSix10265 //1101结果
  1197. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1198. result, _ := json.Marshal(respJSON)
  1199. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1200. utils.ErrorLog("解析失败:%v", err)
  1201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1202. return
  1203. }
  1204. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1205. res2.Output = resSix10265.Output
  1206. res2.ErrMsg = resSix10265.ErrMsg
  1207. res2.Cainfo = resSix10265.Cainfo
  1208. res2.WarnMsg = resSix10265.WarnMsg
  1209. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1210. res2.Infcode = infocode
  1211. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1212. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  1213. saveLog(result11, result22, "3502", "3502")
  1214. var respJSON3 map[string]interface{}
  1215. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1218. return
  1219. }
  1220. userJSONBytes3, _ := json.Marshal(respJSON3)
  1221. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1222. utils.ErrorLog("解析失败:%v", err)
  1223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1224. return
  1225. }
  1226. }
  1227. if res3.Infcode == -1 {
  1228. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1229. c.ServeSuccessJSON(map[string]interface{}{
  1230. "failed_code": -10,
  1231. "msg": res3.ErrMsg,
  1232. })
  1233. } else {
  1234. drug.IsBg = 1
  1235. drug.BgBchno = bg_number
  1236. service.SaveW(drug)
  1237. }
  1238. }
  1239. } else {
  1240. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  1241. }
  1242. }
  1243. //变更
  1244. }
  1245. if len(errs) == 0 {
  1246. c.ServeSuccessJSON(map[string]interface{}{
  1247. "msg": "盘存变更成功",
  1248. })
  1249. } else {
  1250. c.ServeSuccessJSON(map[string]interface{}{
  1251. "failed_code": -10,
  1252. "msg": errs,
  1253. })
  1254. }
  1255. }
  1256. func (c *HisApiController) DeletePCandBG() {
  1257. ids := c.GetString("ids")
  1258. id_arr := strings.Split(ids, ",")
  1259. admin_user_id, _ := c.GetInt64("admin_user_id")
  1260. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1261. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1262. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1263. var err []string
  1264. for _, item := range drugs {
  1265. if item.IsPc == 1 && item.IsBg == 1 {
  1266. var res FJ3507Result
  1267. var res2 FJ3507Result
  1268. var struct3507 models.Struct3507
  1269. struct3507.FixmedinsBchno = item.Bchno
  1270. struct3507.InvDataType = "1"
  1271. struct3507.Opter = roles.UserName
  1272. struct3507.OrgName = miConfig.OrgName
  1273. struct3507.AccessKey = miConfig.AccessKey
  1274. struct3507.RequestUrl = miConfig.Url
  1275. struct3507.FixmedinsCode = miConfig.Code
  1276. struct3507.Code = miConfig.Code
  1277. struct3507.SecretKey = miConfig.SecretKey
  1278. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1279. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1280. struct3507.Url = miConfig.Url
  1281. struct3507.AppId = miConfig.Cainfo
  1282. struct3507.AppSecret = miConfig.AppSecret
  1283. struct3507.Enckey = miConfig.EncKey
  1284. struct3507.SignKey = miConfig.SignKey
  1285. struct3507.SecretKey = miConfig.SecretKey
  1286. if miConfig.MdtrtareaAdmvs == "350500" {
  1287. result, result1, _ := service.FJyb3507(struct3507)
  1288. saveLog(result, result1, "3507", "3507")
  1289. var respJSON2 map[string]interface{}
  1290. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1293. return
  1294. }
  1295. userJSONBytes2, _ := json.Marshal(respJSON2)
  1296. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1297. utils.ErrorLog("解析失败:%v", err)
  1298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1299. return
  1300. }
  1301. } else {
  1302. data := make(map[string]interface{})
  1303. data["struct_3507s"] = struct3507
  1304. client := &http.Client{}
  1305. bytesData, _ := json.Marshal(data)
  1306. var req *http.Request
  1307. if miConfig.MdtrtareaAdmvs == "320921" {
  1308. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1309. } else {
  1310. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1311. }
  1312. resp, _ := client.Do(req)
  1313. defer resp.Body.Close()
  1314. body, ioErr := ioutil.ReadAll(resp.Body)
  1315. if ioErr != nil {
  1316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1317. }
  1318. var respJSON map[string]interface{}
  1319. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1322. return
  1323. }
  1324. var resSix10265 ResultSix10265 //1101结果
  1325. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1326. result, _ := json.Marshal(respJSON)
  1327. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1328. utils.ErrorLog("解析失败:%v", err)
  1329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1330. return
  1331. }
  1332. res.InfRefmsgid = resSix10265.InfRefmsgid
  1333. //res.Output = resSix10265.Output
  1334. res.ErrMsg = resSix10265.ErrMsg
  1335. res.Cainfo = resSix10265.Cainfo
  1336. res.WarnMsg = resSix10265.WarnMsg
  1337. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1338. res.Infcode = infocode
  1339. }
  1340. if res.Infcode == 0 {
  1341. item.IsPc = 0
  1342. err2 := service.SaveW(item)
  1343. if err2 == nil {
  1344. var struct3507_2 models.Struct3507
  1345. struct3507_2.OrgName = miConfig.OrgName
  1346. struct3507_2.AccessKey = miConfig.AccessKey
  1347. struct3507_2.RequestUrl = miConfig.Url
  1348. struct3507_2.Opter = roles.UserName
  1349. struct3507_2.FixmedinsCode = miConfig.Code
  1350. struct3507_2.Code = miConfig.Code
  1351. struct3507_2.SecretKey = miConfig.SecretKey
  1352. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1353. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1354. struct3507_2.Url = miConfig.Url
  1355. struct3507_2.AppId = miConfig.Cainfo
  1356. struct3507_2.AppSecret = miConfig.AppSecret
  1357. struct3507_2.Enckey = miConfig.EncKey
  1358. struct3507_2.SignKey = miConfig.SignKey
  1359. struct3507_2.SecretKey = miConfig.SecretKey
  1360. struct3507_2.FixmedinsBchno = item.BgBchno
  1361. struct3507_2.InvDataType = "2"
  1362. if miConfig.MdtrtareaAdmvs == "350500" {
  1363. result11, result22, _ := service.FJyb3507(struct3507_2)
  1364. saveLog(result11, result22, "3507", "3507")
  1365. var respJSON3 map[string]interface{}
  1366. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1369. return
  1370. }
  1371. userJSONBytes3, _ := json.Marshal(respJSON3)
  1372. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1373. utils.ErrorLog("解析失败:%v", err)
  1374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1375. return
  1376. }
  1377. } else {
  1378. data := make(map[string]interface{})
  1379. data["struct_3507s"] = struct3507_2
  1380. client := &http.Client{}
  1381. bytesData, _ := json.Marshal(data)
  1382. var req *http.Request
  1383. if miConfig.MdtrtareaAdmvs == "320921" {
  1384. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1385. } else {
  1386. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1387. }
  1388. resp, _ := client.Do(req)
  1389. defer resp.Body.Close()
  1390. body, ioErr := ioutil.ReadAll(resp.Body)
  1391. if ioErr != nil {
  1392. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1393. }
  1394. var respJSON map[string]interface{}
  1395. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1398. return
  1399. }
  1400. var resSix10265 ResultSix10265 //1101结果
  1401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1402. result, _ := json.Marshal(respJSON)
  1403. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1404. utils.ErrorLog("解析失败:%v", err)
  1405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1406. return
  1407. }
  1408. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1409. //res2.Output = resSix10265.Output
  1410. res2.ErrMsg = resSix10265.ErrMsg
  1411. res2.Cainfo = resSix10265.Cainfo
  1412. res2.WarnMsg = resSix10265.WarnMsg
  1413. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1414. res2.Infcode = infocode
  1415. }
  1416. if res2.Infcode != -1 {
  1417. item.IsBg = 0
  1418. item.Bchno = ""
  1419. item.BgBchno = ""
  1420. item.PcDate = 0
  1421. service.SaveW(item)
  1422. } else {
  1423. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1424. }
  1425. }
  1426. } else {
  1427. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1428. }
  1429. }
  1430. if item.IsPc == 1 && item.IsBg == 0 {
  1431. var res FJ3507Result
  1432. var struct3507 models.Struct3507
  1433. struct3507.FixmedinsBchno = item.Bchno
  1434. struct3507.InvDataType = "1"
  1435. struct3507.Opter = roles.UserName
  1436. struct3507.FixmedinsCode = miConfig.Code
  1437. struct3507.Code = miConfig.Code
  1438. struct3507.OrgName = miConfig.OrgName
  1439. struct3507.AccessKey = miConfig.AccessKey
  1440. struct3507.RequestUrl = miConfig.Url
  1441. struct3507.SecretKey = miConfig.SecretKey
  1442. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1443. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1444. struct3507.Url = miConfig.Url
  1445. struct3507.AppId = miConfig.Cainfo
  1446. struct3507.AppSecret = miConfig.AppSecret
  1447. struct3507.Enckey = miConfig.EncKey
  1448. struct3507.SignKey = miConfig.SignKey
  1449. struct3507.SecretKey = miConfig.SecretKey
  1450. //result, result1, _ := service.FJyb3507(struct3507)
  1451. //saveLog(result, result1, "3507", "3507")
  1452. if miConfig.MdtrtareaAdmvs == "350500" {
  1453. result, result1, _ := service.FJyb3507(struct3507)
  1454. saveLog(result, result1, "3507", "3507")
  1455. var respJSON2 map[string]interface{}
  1456. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1459. return
  1460. }
  1461. userJSONBytes2, _ := json.Marshal(respJSON2)
  1462. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1463. utils.ErrorLog("解析失败:%v", err)
  1464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1465. return
  1466. }
  1467. } else {
  1468. data := make(map[string]interface{})
  1469. data["struct_3507s"] = struct3507
  1470. client := &http.Client{}
  1471. bytesData, _ := json.Marshal(data)
  1472. var req *http.Request
  1473. if miConfig.MdtrtareaAdmvs == "320921" {
  1474. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1475. } else {
  1476. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1477. }
  1478. resp, _ := client.Do(req)
  1479. defer resp.Body.Close()
  1480. body, ioErr := ioutil.ReadAll(resp.Body)
  1481. if ioErr != nil {
  1482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1483. }
  1484. var respJSON map[string]interface{}
  1485. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1488. return
  1489. }
  1490. var resSix10265 ResultSix10265 //1101结果
  1491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1492. result, _ := json.Marshal(respJSON)
  1493. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1494. utils.ErrorLog("解析失败:%v", err)
  1495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1496. return
  1497. }
  1498. res.InfRefmsgid = resSix10265.InfRefmsgid
  1499. //res.Output = resSix10265.Output
  1500. res.ErrMsg = resSix10265.ErrMsg
  1501. res.Cainfo = resSix10265.Cainfo
  1502. res.WarnMsg = resSix10265.WarnMsg
  1503. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1504. res.Infcode = infocode
  1505. }
  1506. if res.Infcode == 0 {
  1507. item.IsPc = 0
  1508. item.Bchno = ""
  1509. item.BgBchno = ""
  1510. item.PcDate = 0
  1511. service.SaveW(item)
  1512. } else {
  1513. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1514. }
  1515. }
  1516. if item.IsPc == 0 && item.IsBg == 1 {
  1517. var res FJ3507Result
  1518. var struct3507 models.Struct3507
  1519. struct3507.FixmedinsBchno = item.BgBchno
  1520. struct3507.InvDataType = "2"
  1521. struct3507.Opter = roles.UserName
  1522. struct3507.FixmedinsCode = miConfig.Code
  1523. struct3507.OrgName = miConfig.OrgName
  1524. struct3507.AccessKey = miConfig.AccessKey
  1525. struct3507.RequestUrl = miConfig.Url
  1526. struct3507.SecretKey = miConfig.SecretKey
  1527. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1528. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1529. struct3507.Url = miConfig.Url
  1530. struct3507.AppId = miConfig.Cainfo
  1531. struct3507.AppSecret = miConfig.AppSecret
  1532. struct3507.Enckey = miConfig.EncKey
  1533. struct3507.SignKey = miConfig.SignKey
  1534. struct3507.SecretKey = miConfig.SecretKey
  1535. //result, result1, _ := service.FJyb3507(struct3507)
  1536. //saveLog(result, result1, "3507", "3507")
  1537. if miConfig.MdtrtareaAdmvs == "350500" {
  1538. result, result1, _ := service.FJyb3507(struct3507)
  1539. saveLog(result, result1, "3507", "3507")
  1540. var respJSON2 map[string]interface{}
  1541. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1544. return
  1545. }
  1546. userJSONBytes2, _ := json.Marshal(respJSON2)
  1547. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1548. utils.ErrorLog("解析失败:%v", err)
  1549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1550. return
  1551. }
  1552. } else {
  1553. data := make(map[string]interface{})
  1554. data["struct_3507s"] = struct3507
  1555. client := &http.Client{}
  1556. bytesData, _ := json.Marshal(data)
  1557. var req *http.Request
  1558. if miConfig.MdtrtareaAdmvs == "320921" {
  1559. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1560. } else {
  1561. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1562. }
  1563. resp, _ := client.Do(req)
  1564. defer resp.Body.Close()
  1565. body, ioErr := ioutil.ReadAll(resp.Body)
  1566. if ioErr != nil {
  1567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1568. }
  1569. var respJSON map[string]interface{}
  1570. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1573. return
  1574. }
  1575. var resSix10265 ResultSix10265 //1101结果
  1576. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1577. result, _ := json.Marshal(respJSON)
  1578. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1579. utils.ErrorLog("解析失败:%v", err)
  1580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1581. return
  1582. }
  1583. res.InfRefmsgid = resSix10265.InfRefmsgid
  1584. //res.Output = resSix10265.Output
  1585. res.ErrMsg = resSix10265.ErrMsg
  1586. res.Cainfo = resSix10265.Cainfo
  1587. res.WarnMsg = resSix10265.WarnMsg
  1588. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1589. res.Infcode = infocode
  1590. }
  1591. if res.Infcode == 0 {
  1592. item.IsBg = 0
  1593. item.Bchno = ""
  1594. item.BgBchno = ""
  1595. item.PcDate = 0
  1596. service.SaveW(item)
  1597. } else {
  1598. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1599. }
  1600. }
  1601. }
  1602. if len(err) == 0 {
  1603. c.ServeSuccessJSON(map[string]interface{}{
  1604. "msg": "删除盘存变更成功",
  1605. })
  1606. } else {
  1607. c.ServeSuccessJSON(map[string]interface{}{
  1608. "failed_code": -10,
  1609. "msg": err,
  1610. })
  1611. }
  1612. }
  1613. func (c *HisApiController) DeleteXSandBG() {
  1614. ids := c.GetString("ids")
  1615. id_arr := strings.Split(ids, ",")
  1616. admin_user_id, _ := c.GetInt64("admin_user_id")
  1617. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1618. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1619. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1620. var err []string
  1621. for _, item := range flows {
  1622. if item.IsSale == 1 && item.IsChange == 1 {
  1623. var res FJ3507Result
  1624. var res2 FJ3507Result
  1625. var struct3507 models.Struct3507
  1626. struct3507.FixmedinsBchno = item.Bchno
  1627. struct3507.InvDataType = "4"
  1628. struct3507.Opter = roles.UserName
  1629. struct3507.OrgName = miConfig.OrgName
  1630. struct3507.AccessKey = miConfig.AccessKey
  1631. struct3507.RequestUrl = miConfig.Url
  1632. struct3507.FixmedinsCode = miConfig.Code
  1633. struct3507.SecretKey = miConfig.SecretKey
  1634. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1635. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1636. struct3507.Url = miConfig.Url
  1637. struct3507.AppId = miConfig.Cainfo
  1638. struct3507.AppSecret = miConfig.AppSecret
  1639. struct3507.Enckey = miConfig.EncKey
  1640. struct3507.SignKey = miConfig.SignKey
  1641. struct3507.SecretKey = miConfig.SecretKey
  1642. //result, result1, _ := service.FJyb3507(struct3507)
  1643. //saveLog(result, result1, "3507", "3507")
  1644. if miConfig.MdtrtareaAdmvs == "350500" {
  1645. result, result1, _ := service.FJyb3507(struct3507)
  1646. saveLog(result, result1, "3507", "3507")
  1647. var respJSON2 map[string]interface{}
  1648. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1651. return
  1652. }
  1653. userJSONBytes2, _ := json.Marshal(respJSON2)
  1654. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1655. utils.ErrorLog("解析失败:%v", err)
  1656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1657. return
  1658. }
  1659. } else {
  1660. data := make(map[string]interface{})
  1661. data["struct_3507s"] = struct3507
  1662. client := &http.Client{}
  1663. bytesData, _ := json.Marshal(data)
  1664. var req *http.Request
  1665. if miConfig.MdtrtareaAdmvs == "320921" {
  1666. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1667. } else {
  1668. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1669. }
  1670. resp, _ := client.Do(req)
  1671. defer resp.Body.Close()
  1672. body, ioErr := ioutil.ReadAll(resp.Body)
  1673. if ioErr != nil {
  1674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1675. }
  1676. var respJSON map[string]interface{}
  1677. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1680. return
  1681. }
  1682. var resSix10265 ResultSix10265 //1101结果
  1683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1684. result, _ := json.Marshal(respJSON)
  1685. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1686. utils.ErrorLog("解析失败:%v", err)
  1687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1688. return
  1689. }
  1690. res.InfRefmsgid = resSix10265.InfRefmsgid
  1691. //res.Output = resSix10265.Output
  1692. res.ErrMsg = resSix10265.ErrMsg
  1693. res.Cainfo = resSix10265.Cainfo
  1694. res.WarnMsg = resSix10265.WarnMsg
  1695. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1696. res.Infcode = infocode
  1697. }
  1698. if res.Infcode == 0 {
  1699. item.IsSale = 0
  1700. item.SaleDate = ""
  1701. item.Bchno = ""
  1702. err2 := service.SaveDF(item)
  1703. if err2 == nil {
  1704. var struct3507_2 models.Struct3507
  1705. struct3507_2.OrgName = miConfig.OrgName
  1706. struct3507_2.AccessKey = miConfig.AccessKey
  1707. struct3507_2.RequestUrl = miConfig.Url
  1708. struct3507_2.Opter = roles.UserName
  1709. struct3507_2.FixmedinsCode = miConfig.Code
  1710. struct3507_2.Code = miConfig.Code
  1711. struct3507_2.SecretKey = miConfig.SecretKey
  1712. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1713. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1714. struct3507_2.Url = miConfig.Url
  1715. struct3507_2.AppId = miConfig.Cainfo
  1716. struct3507_2.AppSecret = miConfig.AppSecret
  1717. struct3507_2.Enckey = miConfig.EncKey
  1718. struct3507_2.SignKey = miConfig.SignKey
  1719. struct3507_2.SecretKey = miConfig.SecretKey
  1720. struct3507_2.FixmedinsBchno = item.BgBchno
  1721. struct3507_2.InvDataType = "2"
  1722. if miConfig.MdtrtareaAdmvs == "350500" {
  1723. result11, result22, _ := service.FJyb3507(struct3507_2)
  1724. saveLog(result11, result22, "3507", "3507")
  1725. var respJSON3 map[string]interface{}
  1726. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1729. return
  1730. }
  1731. userJSONBytes3, _ := json.Marshal(respJSON3)
  1732. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1733. utils.ErrorLog("解析失败:%v", err)
  1734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1735. return
  1736. }
  1737. } else {
  1738. data := make(map[string]interface{})
  1739. data["struct_3507s"] = struct3507_2
  1740. client := &http.Client{}
  1741. bytesData, _ := json.Marshal(data)
  1742. var req *http.Request
  1743. if miConfig.MdtrtareaAdmvs == "320921" {
  1744. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1745. } else {
  1746. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1747. }
  1748. resp, _ := client.Do(req)
  1749. defer resp.Body.Close()
  1750. body, ioErr := ioutil.ReadAll(resp.Body)
  1751. if ioErr != nil {
  1752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1753. }
  1754. var respJSON map[string]interface{}
  1755. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1758. return
  1759. }
  1760. var resSix10265 ResultSix10265 //1101结果
  1761. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1762. result, _ := json.Marshal(respJSON)
  1763. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1764. utils.ErrorLog("解析失败:%v", err)
  1765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1766. return
  1767. }
  1768. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1769. //res.Output = resSix10265.Output
  1770. res2.ErrMsg = resSix10265.ErrMsg
  1771. res2.Cainfo = resSix10265.Cainfo
  1772. res2.WarnMsg = resSix10265.WarnMsg
  1773. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1774. res2.Infcode = infocode
  1775. }
  1776. if res2.Infcode == 0 {
  1777. item.IsChange = 0
  1778. item.BgBchno = ""
  1779. service.SaveDF2(item)
  1780. } else {
  1781. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1782. }
  1783. }
  1784. } else {
  1785. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1786. }
  1787. }
  1788. if item.IsSale == 2 && item.IsChange == 1 {
  1789. var res FJ3507Result
  1790. var res2 FJ3507Result
  1791. var struct3507 models.Struct3507
  1792. struct3507.FixmedinsBchno = item.Bchno
  1793. struct3507.InvDataType = "4"
  1794. struct3507.Opter = roles.UserName
  1795. struct3507.OrgName = miConfig.OrgName
  1796. struct3507.AccessKey = miConfig.AccessKey
  1797. struct3507.RequestUrl = miConfig.Url
  1798. struct3507.FixmedinsCode = miConfig.Code
  1799. struct3507.Code = miConfig.Code
  1800. struct3507.SecretKey = miConfig.SecretKey
  1801. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1802. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1803. struct3507.Url = miConfig.Url
  1804. struct3507.AppId = miConfig.Cainfo
  1805. struct3507.AppSecret = miConfig.AppSecret
  1806. struct3507.Enckey = miConfig.EncKey
  1807. struct3507.SignKey = miConfig.SignKey
  1808. struct3507.SecretKey = miConfig.SecretKey
  1809. //result, result1, _ := service.FJyb3507(struct3507)
  1810. //saveLog(result, result1, "3507", "3507")
  1811. //
  1812. //var respJSON2 map[string]interface{}
  1813. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1814. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1816. // return
  1817. //}
  1818. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1819. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1820. // utils.ErrorLog("解析失败:%v", err)
  1821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1822. // return
  1823. //}
  1824. if miConfig.MdtrtareaAdmvs == "350500" {
  1825. result, result1, _ := service.FJyb3507(struct3507)
  1826. saveLog(result, result1, "3507", "3507")
  1827. var respJSON2 map[string]interface{}
  1828. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1831. return
  1832. }
  1833. userJSONBytes2, _ := json.Marshal(respJSON2)
  1834. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1835. utils.ErrorLog("解析失败:%v", err)
  1836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1837. return
  1838. }
  1839. } else {
  1840. data := make(map[string]interface{})
  1841. data["struct_3507s"] = struct3507
  1842. client := &http.Client{}
  1843. bytesData, _ := json.Marshal(data)
  1844. var req *http.Request
  1845. if miConfig.MdtrtareaAdmvs == "320921" {
  1846. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1847. } else {
  1848. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1849. }
  1850. resp, _ := client.Do(req)
  1851. defer resp.Body.Close()
  1852. body, ioErr := ioutil.ReadAll(resp.Body)
  1853. if ioErr != nil {
  1854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1855. }
  1856. var respJSON map[string]interface{}
  1857. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1860. return
  1861. }
  1862. var resSix10265 ResultSix10265 //1101结果
  1863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1864. result, _ := json.Marshal(respJSON)
  1865. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1866. utils.ErrorLog("解析失败:%v", err)
  1867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1868. return
  1869. }
  1870. res.InfRefmsgid = resSix10265.InfRefmsgid
  1871. //res.Output = resSix10265.Output
  1872. res.ErrMsg = resSix10265.ErrMsg
  1873. res.Cainfo = resSix10265.Cainfo
  1874. res.WarnMsg = resSix10265.WarnMsg
  1875. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1876. res.Infcode = infocode
  1877. }
  1878. if res.Infcode == 0 {
  1879. item.IsSale = 0
  1880. item.SaleDate = ""
  1881. item.Bchno = ""
  1882. err2 := service.SaveDF(item)
  1883. if err2 == nil {
  1884. var struct3507_2 models.Struct3507
  1885. struct3507_2.OrgName = miConfig.OrgName
  1886. struct3507_2.AccessKey = miConfig.AccessKey
  1887. struct3507_2.RequestUrl = miConfig.Url
  1888. struct3507_2.Opter = roles.UserName
  1889. struct3507_2.FixmedinsCode = miConfig.Code
  1890. struct3507_2.Code = miConfig.Code
  1891. struct3507_2.SecretKey = miConfig.SecretKey
  1892. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1893. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1894. struct3507_2.Url = miConfig.Url
  1895. struct3507_2.AppId = miConfig.Cainfo
  1896. struct3507_2.AppSecret = miConfig.AppSecret
  1897. struct3507_2.Enckey = miConfig.EncKey
  1898. struct3507_2.SignKey = miConfig.SignKey
  1899. struct3507_2.SecretKey = miConfig.SecretKey
  1900. struct3507_2.FixmedinsBchno = item.BgBchno
  1901. struct3507_2.InvDataType = "2"
  1902. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1903. //saveLog(result11, result22, "3507", "3507")
  1904. //var respJSON3 map[string]interface{}
  1905. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1906. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1908. // return
  1909. //}
  1910. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1911. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1912. // utils.ErrorLog("解析失败:%v", err)
  1913. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1914. // return
  1915. //}
  1916. if miConfig.MdtrtareaAdmvs == "350500" {
  1917. result11, result22, _ := service.FJyb3507(struct3507_2)
  1918. saveLog(result11, result22, "3507", "3507")
  1919. var respJSON3 map[string]interface{}
  1920. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1923. return
  1924. }
  1925. userJSONBytes3, _ := json.Marshal(respJSON3)
  1926. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1927. utils.ErrorLog("解析失败:%v", err)
  1928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1929. return
  1930. }
  1931. } else {
  1932. data := make(map[string]interface{})
  1933. data["struct_3507s"] = struct3507_2
  1934. client := &http.Client{}
  1935. bytesData, _ := json.Marshal(data)
  1936. var req *http.Request
  1937. if miConfig.MdtrtareaAdmvs == "320921" {
  1938. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1939. } else {
  1940. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1941. }
  1942. resp, _ := client.Do(req)
  1943. defer resp.Body.Close()
  1944. body, ioErr := ioutil.ReadAll(resp.Body)
  1945. if ioErr != nil {
  1946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1947. }
  1948. var respJSON map[string]interface{}
  1949. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1952. return
  1953. }
  1954. var resSix10265 ResultSix10265 //1101结果
  1955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1956. result, _ := json.Marshal(respJSON)
  1957. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1958. utils.ErrorLog("解析失败:%v", err)
  1959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1960. return
  1961. }
  1962. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1963. //res.Output = resSix10265.Output
  1964. res2.ErrMsg = resSix10265.ErrMsg
  1965. res2.Cainfo = resSix10265.Cainfo
  1966. res2.WarnMsg = resSix10265.WarnMsg
  1967. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1968. res2.Infcode = infocode
  1969. }
  1970. if res2.Infcode == 0 {
  1971. item.IsChange = 0
  1972. item.BgBchno = ""
  1973. service.SaveDF2(item)
  1974. } else {
  1975. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1976. }
  1977. }
  1978. } else {
  1979. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1980. }
  1981. }
  1982. if item.IsSale == 1 && item.IsChange == 0 {
  1983. var res FJ3507Result
  1984. var struct3507 models.Struct3507
  1985. struct3507.FixmedinsBchno = item.Bchno
  1986. struct3507.InvDataType = "4"
  1987. struct3507.Opter = roles.UserName
  1988. struct3507.FixmedinsCode = miConfig.Code
  1989. struct3507.Code = miConfig.Code
  1990. struct3507.OrgName = miConfig.OrgName
  1991. struct3507.AccessKey = miConfig.AccessKey
  1992. struct3507.RequestUrl = miConfig.Url
  1993. struct3507.SecretKey = miConfig.SecretKey
  1994. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1995. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1996. struct3507.Url = miConfig.Url
  1997. struct3507.AppId = miConfig.Cainfo
  1998. struct3507.AppSecret = miConfig.AppSecret
  1999. struct3507.Enckey = miConfig.EncKey
  2000. struct3507.SignKey = miConfig.SignKey
  2001. struct3507.SecretKey = miConfig.SecretKey
  2002. //result, result1, _ := service.FJyb3507(struct3507)
  2003. //saveLog(result, result1, "3507", "3507")
  2004. //
  2005. //var respJSON3 map[string]interface{}
  2006. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2007. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2008. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2009. // return
  2010. //}
  2011. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2012. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2013. // utils.ErrorLog("解析失败:%v", err)
  2014. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2015. // return
  2016. //}
  2017. if miConfig.MdtrtareaAdmvs == "350500" {
  2018. result, result1, _ := service.FJyb3507(struct3507)
  2019. saveLog(result, result1, "3507", "3507")
  2020. var respJSON2 map[string]interface{}
  2021. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2024. return
  2025. }
  2026. userJSONBytes2, _ := json.Marshal(respJSON2)
  2027. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2028. utils.ErrorLog("解析失败:%v", err)
  2029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2030. return
  2031. }
  2032. } else {
  2033. data := make(map[string]interface{})
  2034. data["struct_3507s"] = struct3507
  2035. client := &http.Client{}
  2036. bytesData, _ := json.Marshal(data)
  2037. var req *http.Request
  2038. if miConfig.MdtrtareaAdmvs == "320921" {
  2039. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2040. } else {
  2041. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2042. }
  2043. resp, _ := client.Do(req)
  2044. defer resp.Body.Close()
  2045. body, ioErr := ioutil.ReadAll(resp.Body)
  2046. if ioErr != nil {
  2047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2048. }
  2049. var respJSON map[string]interface{}
  2050. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2053. return
  2054. }
  2055. var resSix10265 ResultSix10265 //1101结果
  2056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2057. result, _ := json.Marshal(respJSON)
  2058. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2059. utils.ErrorLog("解析失败:%v", err)
  2060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2061. return
  2062. }
  2063. res.InfRefmsgid = resSix10265.InfRefmsgid
  2064. //res.Output = resSix10265.Output
  2065. res.ErrMsg = resSix10265.ErrMsg
  2066. res.Cainfo = resSix10265.Cainfo
  2067. res.WarnMsg = resSix10265.WarnMsg
  2068. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2069. res.Infcode = infocode
  2070. }
  2071. if res.Infcode == 0 {
  2072. item.IsSale = 0
  2073. item.SaleDate = ""
  2074. service.SaveDF(item)
  2075. } else {
  2076. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2077. }
  2078. }
  2079. if item.IsSale == 2 && item.IsChange == 0 {
  2080. var res FJ3507Result
  2081. var struct3507 models.Struct3507
  2082. struct3507.FixmedinsBchno = item.Bchno
  2083. struct3507.InvDataType = "4"
  2084. struct3507.Opter = roles.UserName
  2085. struct3507.FixmedinsCode = miConfig.Code
  2086. struct3507.Code = miConfig.Code
  2087. struct3507.OrgName = miConfig.OrgName
  2088. struct3507.AccessKey = miConfig.AccessKey
  2089. struct3507.RequestUrl = miConfig.Url
  2090. struct3507.SecretKey = miConfig.SecretKey
  2091. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2092. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2093. struct3507.Url = miConfig.Url
  2094. struct3507.AppId = miConfig.Cainfo
  2095. struct3507.AppSecret = miConfig.AppSecret
  2096. struct3507.Enckey = miConfig.EncKey
  2097. struct3507.SignKey = miConfig.SignKey
  2098. struct3507.SecretKey = miConfig.SecretKey
  2099. //result, result1, _ := service.FJyb3507(struct3507)
  2100. //saveLog(result, result1, "3507", "3507")
  2101. //
  2102. //var respJSON3 map[string]interface{}
  2103. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2104. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2106. // return
  2107. //}
  2108. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2109. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2110. // utils.ErrorLog("解析失败:%v", err)
  2111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2112. // return
  2113. //}
  2114. if miConfig.MdtrtareaAdmvs == "350500" {
  2115. result, result1, _ := service.FJyb3507(struct3507)
  2116. saveLog(result, result1, "3507", "3507")
  2117. var respJSON2 map[string]interface{}
  2118. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2121. return
  2122. }
  2123. userJSONBytes2, _ := json.Marshal(respJSON2)
  2124. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2125. utils.ErrorLog("解析失败:%v", err)
  2126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2127. return
  2128. }
  2129. } else {
  2130. data := make(map[string]interface{})
  2131. data["struct_3507s"] = struct3507
  2132. client := &http.Client{}
  2133. bytesData, _ := json.Marshal(data)
  2134. var req *http.Request
  2135. if miConfig.MdtrtareaAdmvs == "320921" {
  2136. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2137. } else {
  2138. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2139. }
  2140. resp, _ := client.Do(req)
  2141. defer resp.Body.Close()
  2142. body, ioErr := ioutil.ReadAll(resp.Body)
  2143. if ioErr != nil {
  2144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2145. }
  2146. var respJSON map[string]interface{}
  2147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2150. return
  2151. }
  2152. var resSix10265 ResultSix10265 //1101结果
  2153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2154. result, _ := json.Marshal(respJSON)
  2155. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2156. utils.ErrorLog("解析失败:%v", err)
  2157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2158. return
  2159. }
  2160. res.InfRefmsgid = resSix10265.InfRefmsgid
  2161. //res.Output = resSix10265.Output
  2162. res.ErrMsg = resSix10265.ErrMsg
  2163. res.Cainfo = resSix10265.Cainfo
  2164. res.WarnMsg = resSix10265.WarnMsg
  2165. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2166. res.Infcode = infocode
  2167. }
  2168. if res.Infcode == 0 {
  2169. item.IsSale = 0
  2170. item.SaleDate = ""
  2171. item.Bchno = ""
  2172. service.SaveDF(item)
  2173. } else {
  2174. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2175. }
  2176. }
  2177. if item.IsSale == 0 && item.IsChange == 1 {
  2178. var res FJ3507Result
  2179. var struct3507 models.Struct3507
  2180. struct3507.FixmedinsBchno = item.BgBchno
  2181. struct3507.InvDataType = "2"
  2182. struct3507.Opter = roles.UserName
  2183. struct3507.FixmedinsCode = miConfig.Code
  2184. struct3507.Code = miConfig.Code
  2185. struct3507.OrgName = miConfig.OrgName
  2186. struct3507.AccessKey = miConfig.AccessKey
  2187. struct3507.RequestUrl = miConfig.Url
  2188. struct3507.SecretKey = miConfig.SecretKey
  2189. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2190. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2191. struct3507.Url = miConfig.Url
  2192. struct3507.AppId = miConfig.Cainfo
  2193. struct3507.AppSecret = miConfig.AppSecret
  2194. struct3507.Enckey = miConfig.EncKey
  2195. struct3507.SignKey = miConfig.SignKey
  2196. struct3507.SecretKey = miConfig.SecretKey
  2197. //result, result1, _ := service.FJyb3507(struct3507)
  2198. //saveLog(result, result1, "3507", "3507")
  2199. //
  2200. //var respJSON3 map[string]interface{}
  2201. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2202. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2204. // return
  2205. //}
  2206. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2207. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2208. // utils.ErrorLog("解析失败:%v", err)
  2209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2210. // return
  2211. //}
  2212. if miConfig.MdtrtareaAdmvs == "350500" {
  2213. result, result1, _ := service.FJyb3507(struct3507)
  2214. saveLog(result, result1, "3507", "3507")
  2215. var respJSON2 map[string]interface{}
  2216. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2219. return
  2220. }
  2221. userJSONBytes2, _ := json.Marshal(respJSON2)
  2222. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2223. utils.ErrorLog("解析失败:%v", err)
  2224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2225. return
  2226. }
  2227. } else {
  2228. data := make(map[string]interface{})
  2229. data["struct_3507s"] = struct3507
  2230. client := &http.Client{}
  2231. bytesData, _ := json.Marshal(data)
  2232. var req *http.Request
  2233. if miConfig.MdtrtareaAdmvs == "320921" {
  2234. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2235. } else {
  2236. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2237. }
  2238. resp, _ := client.Do(req)
  2239. defer resp.Body.Close()
  2240. body, ioErr := ioutil.ReadAll(resp.Body)
  2241. if ioErr != nil {
  2242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2243. }
  2244. var respJSON map[string]interface{}
  2245. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2248. return
  2249. }
  2250. var resSix10265 ResultSix10265 //1101结果
  2251. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2252. result, _ := json.Marshal(respJSON)
  2253. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2254. utils.ErrorLog("解析失败:%v", err)
  2255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2256. return
  2257. }
  2258. res.InfRefmsgid = resSix10265.InfRefmsgid
  2259. //res.Output = resSix10265.Output
  2260. res.ErrMsg = resSix10265.ErrMsg
  2261. res.Cainfo = resSix10265.Cainfo
  2262. res.WarnMsg = resSix10265.WarnMsg
  2263. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2264. res.Infcode = infocode
  2265. }
  2266. if res.Infcode == 0 {
  2267. item.IsChange = 0
  2268. item.BgBchno = ""
  2269. service.SaveDF2(item)
  2270. } else {
  2271. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2272. }
  2273. }
  2274. }
  2275. if len(err) == 0 {
  2276. c.ServeSuccessJSON(map[string]interface{}{
  2277. "msg": "删除销售变更成功",
  2278. })
  2279. } else {
  2280. c.ServeSuccessJSON(map[string]interface{}{
  2281. "failed_code": -10,
  2282. "msg": err,
  2283. })
  2284. }
  2285. }
  2286. //func (c *HisApiController) BatchFJ3501AND3502() {
  2287. // //ids := c.GetString("ids")
  2288. // start_time := c.GetString("start_time")
  2289. // end_time := c.GetString("end_time")
  2290. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2291. //
  2292. //
  2293. // timeLayout := "2006-01-02"
  2294. // loc, _ := time.LoadLocation("Local")
  2295. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2296. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2297. //
  2298. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2299. // //id_arr := strings.Split(ids, ",")
  2300. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2301. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2302. // //库盘
  2303. // var errs []string
  2304. // for _, drug := range drugs {
  2305. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2306. // var res2 ResultSix
  2307. // var res3 ResultSix
  2308. //
  2309. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2310. // var struct3501 models.Struct3501
  2311. // struct3501.Code = miConfig.Code
  2312. // struct3501.OrgName = miConfig.OrgName
  2313. // struct3501.AccessKey = miConfig.AccessKey
  2314. // struct3501.Opter = roles.UserName
  2315. // struct3501.RequestUrl = miConfig.Url
  2316. // struct3501.Url = miConfig.Url
  2317. // struct3501.AppId = miConfig.Cainfo
  2318. // struct3501.AppSecret = miConfig.AppSecret
  2319. // struct3501.Enckey = miConfig.EncKey
  2320. // struct3501.SignKey = miConfig.SignKey
  2321. // struct3501.SecretKey = miConfig.SecretKey
  2322. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2323. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2324. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2325. // struct3501.RxFlag = "1"
  2326. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2327. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2328. //
  2329. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2330. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2331. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2332. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2333. // struct3501.FixmedinsBchno = number
  2334. // struct3501.DrugTracCodg = drug.DrugCode
  2335. // memo := make(map[string]interface{})
  2336. // memo["pric"] = drug.Price
  2337. // bytesData, _ := json.Marshal(memo)
  2338. // struct3501.Memo = string(bytesData)
  2339. //
  2340. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2341. //
  2342. // result1, result2, _ := service.FJyb3501(struct3501)
  2343. // saveLog(result1, result2, "3501", "3501")
  2344. // //saveLog(result, requestLog, "2201", "挂号")
  2345. //
  2346. // var respJSON2 map[string]interface{}
  2347. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2348. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2350. // return
  2351. // }
  2352. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2353. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2354. // utils.ErrorLog("解析失败:%v", err)
  2355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2356. // return
  2357. // }
  2358. //
  2359. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2360. // data := make(map[string]interface{})
  2361. // data["struct_3501s"] = struct3501
  2362. // client := &http.Client{}
  2363. // bytesData, _ := json.Marshal(data)
  2364. // var req *http.Request
  2365. // if miConfig.MdtrtareaAdmvs == "320921" {
  2366. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2367. // } else {
  2368. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2369. // }
  2370. //
  2371. // resp, _ := client.Do(req)
  2372. // defer resp.Body.Close()
  2373. // body, ioErr := ioutil.ReadAll(resp.Body)
  2374. // if ioErr != nil {
  2375. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2376. // }
  2377. // var respJSON map[string]interface{}
  2378. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2379. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2381. // return
  2382. // }
  2383. // var resSix10265 ResultSix10265 //1101结果
  2384. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2385. // result, _ := json.Marshal(respJSON)
  2386. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2387. // utils.ErrorLog("解析失败:%v", err)
  2388. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2389. // return
  2390. // }
  2391. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2392. // res2.Output = resSix10265.Output
  2393. // res2.ErrMsg = resSix10265.ErrMsg
  2394. // res2.Cainfo = resSix10265.Cainfo
  2395. // res2.WarnMsg = resSix10265.WarnMsg
  2396. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2397. // res2.Infcode = infocode
  2398. //
  2399. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2400. // data := make(map[string]interface{})
  2401. // data["struct_3501s"] = struct3501
  2402. // client := &http.Client{}
  2403. // bytesData, _ := json.Marshal(data)
  2404. // var req *http.Request
  2405. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2406. // resp, _ := client.Do(req)
  2407. // defer resp.Body.Close()
  2408. // body, ioErr := ioutil.ReadAll(resp.Body)
  2409. // if ioErr != nil {
  2410. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2411. // }
  2412. // var respJSON map[string]interface{}
  2413. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2414. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2416. // return
  2417. // }
  2418. // var resSix10265 ResultSix10265 //1101结果
  2419. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2420. // result, _ := json.Marshal(respJSON)
  2421. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2422. // utils.ErrorLog("解析失败:%v", err)
  2423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2424. // return
  2425. // }
  2426. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2427. // res2.Output = resSix10265.Output
  2428. // res2.ErrMsg = resSix10265.ErrMsg
  2429. // res2.Cainfo = resSix10265.Cainfo
  2430. // res2.WarnMsg = resSix10265.WarnMsg
  2431. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2432. // res2.Infcode = infocode
  2433. //
  2434. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2435. // data := make(map[string]interface{})
  2436. // data["struct_3501s"] = struct3501
  2437. // client := &http.Client{}
  2438. // bytesData, _ := json.Marshal(data)
  2439. // var req *http.Request
  2440. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2441. // resp, _ := client.Do(req)
  2442. // defer resp.Body.Close()
  2443. // body, ioErr := ioutil.ReadAll(resp.Body)
  2444. // if ioErr != nil {
  2445. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2446. // }
  2447. // var respJSON map[string]interface{}
  2448. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2449. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2451. // return
  2452. // }
  2453. // var resSix10265 ResultSix10265 //1101结果
  2454. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2455. // result, _ := json.Marshal(respJSON)
  2456. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2457. // utils.ErrorLog("解析失败:%v", err)
  2458. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2459. // return
  2460. // }
  2461. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2462. // res2.Output = resSix10265.Output
  2463. // res2.ErrMsg = resSix10265.ErrMsg
  2464. // res2.Cainfo = resSix10265.Cainfo
  2465. // res2.WarnMsg = resSix10265.WarnMsg
  2466. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2467. // res2.Infcode = infocode
  2468. //
  2469. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2470. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2471. // saveLog(result1, result2, "3501", "3501")
  2472. // //saveLog(result, requestLog, "2201", "挂号")
  2473. //
  2474. // var respJSON2 map[string]interface{}
  2475. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2476. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2478. // return
  2479. // }
  2480. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2481. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2482. // utils.ErrorLog("解析失败:%v", err)
  2483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2484. // return
  2485. // }
  2486. //
  2487. // }
  2488. //
  2489. // if res2.Infcode != -1 {
  2490. // drug.IsPc = 1
  2491. // drug.Bchno = number
  2492. // drug.PcDate = time.Now().Unix()
  2493. // err := service.SaveW(drug)
  2494. // if err == nil {
  2495. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2496. // var struct3502 models.Struct3502
  2497. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2498. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2499. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2500. // struct3502.FixmedinsCode = miConfig.Code
  2501. // struct3502.Code = miConfig.Code
  2502. //
  2503. // struct3502.RxFlag = "0"
  2504. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2505. // struct3502.OrgName = miConfig.OrgName
  2506. // struct3502.Opter = roles.UserName
  2507. // struct3502.AccessKey = miConfig.AccessKey
  2508. // struct3502.RequestUrl = miConfig.Url
  2509. // struct3502.SecretKey = miConfig.SecretKey
  2510. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2511. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2512. // struct3502.Url = miConfig.Url
  2513. // struct3502.AppId = miConfig.Cainfo
  2514. // struct3502.AppSecret = miConfig.AppSecret
  2515. // struct3502.Enckey = miConfig.EncKey
  2516. // struct3502.SignKey = miConfig.SignKey
  2517. // struct3502.SecretKey = miConfig.SecretKey
  2518. // struct3502.DrugTracCodg = drug.DrugCode
  2519. //
  2520. // struct3502.Memo = ""
  2521. // struct3502.InvChgType = "108"
  2522. // struct3502.FixmedinsBchno = bg_number
  2523. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2524. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2525. //
  2526. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2527. // result11, result22, _ := service.FJyb3502(struct3502)
  2528. // saveLog(result11, result22, "3502", "3502")
  2529. //
  2530. // var respJSON3 map[string]interface{}
  2531. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2532. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2534. // return
  2535. // }
  2536. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2537. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2538. // utils.ErrorLog("解析失败:%v", err)
  2539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2540. // return
  2541. // }
  2542. //
  2543. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2544. // data := make(map[string]interface{})
  2545. // data["struct_3502s"] = struct3502
  2546. // client := &http.Client{}
  2547. // bytesData, _ := json.Marshal(data)
  2548. // var req *http.Request
  2549. // if miConfig.MdtrtareaAdmvs == "320921" {
  2550. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2551. // } else {
  2552. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2553. // }
  2554. //
  2555. // resp, _ := client.Do(req)
  2556. // defer resp.Body.Close()
  2557. // body, ioErr := ioutil.ReadAll(resp.Body)
  2558. // if ioErr != nil {
  2559. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2560. // }
  2561. // var respJSON map[string]interface{}
  2562. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2563. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2564. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2565. // return
  2566. // }
  2567. // var resSix10265 ResultSix10265 //1101结果
  2568. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2569. // result, _ := json.Marshal(respJSON)
  2570. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2571. // utils.ErrorLog("解析失败:%v", err)
  2572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2573. // return
  2574. // }
  2575. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2576. // res3.Output = resSix10265.Output
  2577. // res3.ErrMsg = resSix10265.ErrMsg
  2578. // res3.Cainfo = resSix10265.Cainfo
  2579. // res3.WarnMsg = resSix10265.WarnMsg
  2580. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2581. // res3.Infcode = infocode
  2582. //
  2583. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2584. //
  2585. // data := make(map[string]interface{})
  2586. // data["struct_3502s"] = struct3502
  2587. // client := &http.Client{}
  2588. // bytesData, _ := json.Marshal(data)
  2589. // var req *http.Request
  2590. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2591. // resp, _ := client.Do(req)
  2592. // defer resp.Body.Close()
  2593. // body, ioErr := ioutil.ReadAll(resp.Body)
  2594. // if ioErr != nil {
  2595. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2596. // }
  2597. // var respJSON map[string]interface{}
  2598. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2599. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2601. // return
  2602. // }
  2603. // var resSix10265 ResultSix10265 //1101结果
  2604. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2605. // result, _ := json.Marshal(respJSON)
  2606. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2607. // utils.ErrorLog("解析失败:%v", err)
  2608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2609. // return
  2610. // }
  2611. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2612. // res3.Output = resSix10265.Output
  2613. // res3.ErrMsg = resSix10265.ErrMsg
  2614. // res3.Cainfo = resSix10265.Cainfo
  2615. // res3.WarnMsg = resSix10265.WarnMsg
  2616. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2617. // res3.Infcode = infocode
  2618. //
  2619. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2620. //
  2621. // data := make(map[string]interface{})
  2622. // data["struct_3501s"] = struct3501
  2623. // client := &http.Client{}
  2624. // bytesData, _ := json.Marshal(data)
  2625. // var req *http.Request
  2626. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2627. // resp, _ := client.Do(req)
  2628. // defer resp.Body.Close()
  2629. // body, ioErr := ioutil.ReadAll(resp.Body)
  2630. // if ioErr != nil {
  2631. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2632. // }
  2633. // var respJSON map[string]interface{}
  2634. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2635. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2637. // return
  2638. // }
  2639. // var resSix10265 ResultSix10265 //1101结果
  2640. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2641. // result, _ := json.Marshal(respJSON)
  2642. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2643. // utils.ErrorLog("解析失败:%v", err)
  2644. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2645. // return
  2646. // }
  2647. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2648. // res2.Output = resSix10265.Output
  2649. // res2.ErrMsg = resSix10265.ErrMsg
  2650. // res2.Cainfo = resSix10265.Cainfo
  2651. // res2.WarnMsg = resSix10265.WarnMsg
  2652. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2653. // res2.Infcode = infocode
  2654. //
  2655. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2656. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2657. // saveLog(result11, result22, "3502", "3502")
  2658. //
  2659. // var respJSON3 map[string]interface{}
  2660. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2661. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2663. // return
  2664. // }
  2665. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2666. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2667. // utils.ErrorLog("解析失败:%v", err)
  2668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2669. // return
  2670. // }
  2671. // }
  2672. // if res3.Infcode == -1 {
  2673. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2674. // c.ServeSuccessJSON(map[string]interface{}{
  2675. // "failed_code": -10,
  2676. // "msg": res3.ErrMsg,
  2677. // })
  2678. // } else {
  2679. // drug.IsBg = 1
  2680. // drug.BgBchno = bg_number
  2681. // service.SaveW(drug)
  2682. // }
  2683. // }
  2684. // } else {
  2685. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2686. // }
  2687. // }
  2688. // //变更
  2689. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2690. // var res3 ResultSix
  2691. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2692. //
  2693. // var struct3502 models.Struct3502
  2694. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2695. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2696. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2697. // struct3502.FixmedinsCode = miConfig.Code
  2698. // struct3502.Code = miConfig.Code
  2699. //
  2700. // struct3502.Opter = roles.UserName
  2701. // struct3502.RxFlag = "0"
  2702. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2703. // struct3502.OrgName = miConfig.OrgName
  2704. // struct3502.AccessKey = miConfig.AccessKey
  2705. // struct3502.RequestUrl = miConfig.Url
  2706. // struct3502.SecretKey = miConfig.SecretKey
  2707. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2708. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2709. // struct3502.InvChgType = "108"
  2710. // struct3502.DrugTracCodg = drug.DrugCode
  2711. //
  2712. // struct3502.Url = miConfig.Url
  2713. // struct3502.AppId = miConfig.Cainfo
  2714. // struct3502.AppSecret = miConfig.AppSecret
  2715. // struct3502.Enckey = miConfig.EncKey
  2716. // struct3502.SignKey = miConfig.SignKey
  2717. // struct3502.SecretKey = miConfig.SecretKey
  2718. //
  2719. // struct3502.FixmedinsBchno = bg_number
  2720. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2721. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2722. //
  2723. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2724. // result1, result2, _ := service.FJyb3502(struct3502)
  2725. // saveLog(result1, result2, "3502", "3502")
  2726. // var respJSON3 map[string]interface{}
  2727. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2728. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2730. // return
  2731. // }
  2732. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2733. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2734. // utils.ErrorLog("解析失败:%v", err)
  2735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2736. // return
  2737. // }
  2738. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2739. // data := make(map[string]interface{})
  2740. // data["struct_3502s"] = struct3502
  2741. // client := &http.Client{}
  2742. // bytesData, _ := json.Marshal(data)
  2743. // var req *http.Request
  2744. // if miConfig.MdtrtareaAdmvs == "320921" {
  2745. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2746. // } else {
  2747. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2748. // }
  2749. // resp, _ := client.Do(req)
  2750. // defer resp.Body.Close()
  2751. // body, ioErr := ioutil.ReadAll(resp.Body)
  2752. // if ioErr != nil {
  2753. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2754. // }
  2755. // var respJSON map[string]interface{}
  2756. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2757. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2759. // return
  2760. // }
  2761. // var resSix10265 ResultSix10265 //1101结果
  2762. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2763. // result, _ := json.Marshal(respJSON)
  2764. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2765. // utils.ErrorLog("解析失败:%v", err)
  2766. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2767. // return
  2768. // }
  2769. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2770. // res3.Output = resSix10265.Output
  2771. // res3.ErrMsg = resSix10265.ErrMsg
  2772. // res3.Cainfo = resSix10265.Cainfo
  2773. // res3.WarnMsg = resSix10265.WarnMsg
  2774. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2775. // res3.Infcode = infocode
  2776. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2777. //
  2778. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2779. //
  2780. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2781. //
  2782. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2783. //
  2784. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2785. // saveLog(result1, result2, "3501", "3501")
  2786. // //saveLog(result, requestLog, "2201", "挂号")
  2787. //
  2788. // var respJSON2 map[string]interface{}
  2789. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2790. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2792. // return
  2793. // }
  2794. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2795. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2796. // utils.ErrorLog("解析失败:%v", err)
  2797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2798. // return
  2799. // }
  2800. //
  2801. // }
  2802. // if res3.Infcode == -1 {
  2803. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2804. // } else {
  2805. // drug.IsBg = 1
  2806. // drug.BgBchno = bg_number
  2807. // service.SaveW(drug)
  2808. // }
  2809. // }
  2810. // }
  2811. //
  2812. // if len(errs) == 0 {
  2813. // c.ServeSuccessJSON(map[string]interface{}{
  2814. // "msg": "盘存变更成功",
  2815. // })
  2816. // } else {
  2817. // c.ServeSuccessJSON(map[string]interface{}{
  2818. // "failed_code": -10,
  2819. // "msg": errs,
  2820. // })
  2821. // }
  2822. //}
  2823. func (c *HisApiController) DeleteXSandBGTwo() {
  2824. patient_id, _ := c.GetInt64("patient_id")
  2825. admin_user_id, _ := c.GetInt64("admin_user_id")
  2826. times := c.GetString("time", "")
  2827. timeLayout := "2006-01-02"
  2828. loc, _ := time.LoadLocation("Local")
  2829. var stime, etime int64
  2830. if times == "" {
  2831. stime, etime = GetNowTime()
  2832. } else {
  2833. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2834. stime = stmp.Unix()
  2835. etime = stime + 86399
  2836. }
  2837. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2838. var flows []*models.DrugFlow
  2839. for _, item := range advicelist {
  2840. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2841. flows = append(flows, flow...)
  2842. }
  2843. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2844. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2845. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2846. var err []string
  2847. for _, item := range flows {
  2848. if item.IsSale == 1 {
  2849. var res FJ3507Result
  2850. var struct3507 models.Struct3507
  2851. struct3507.FixmedinsBchno = item.Bchno
  2852. struct3507.InvDataType = "4"
  2853. struct3507.Opter = roles.UserName
  2854. struct3507.OrgName = miConfig.OrgName
  2855. struct3507.AccessKey = miConfig.AccessKey
  2856. struct3507.RequestUrl = miConfig.Url
  2857. struct3507.FixmedinsCode = miConfig.Code
  2858. struct3507.SecretKey = miConfig.SecretKey
  2859. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2860. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2861. struct3507.Url = miConfig.Url
  2862. struct3507.AppId = miConfig.Cainfo
  2863. struct3507.AppSecret = miConfig.AppSecret
  2864. struct3507.Enckey = miConfig.EncKey
  2865. struct3507.SignKey = miConfig.SignKey
  2866. struct3507.SecretKey = miConfig.SecretKey
  2867. if miConfig.MdtrtareaAdmvs == "350500" {
  2868. result, result1, _ := service.FJyb3507(struct3507)
  2869. saveLog(result, result1, "3507", "3507")
  2870. var respJSON2 map[string]interface{}
  2871. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. return
  2875. }
  2876. userJSONBytes2, _ := json.Marshal(respJSON2)
  2877. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2878. utils.ErrorLog("解析失败:%v", err)
  2879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2880. return
  2881. }
  2882. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2883. data := make(map[string]interface{})
  2884. data["struct_3507s"] = struct3507
  2885. client := &http.Client{}
  2886. bytesData, _ := json.Marshal(data)
  2887. var req *http.Request
  2888. if miConfig.MdtrtareaAdmvs == "320921" {
  2889. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2890. } else {
  2891. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2892. }
  2893. resp, _ := client.Do(req)
  2894. defer resp.Body.Close()
  2895. body, ioErr := ioutil.ReadAll(resp.Body)
  2896. if ioErr != nil {
  2897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2898. }
  2899. var respJSON map[string]interface{}
  2900. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2903. return
  2904. }
  2905. var resSix10265 ResultSix10265 //1101结果
  2906. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2907. result, _ := json.Marshal(respJSON)
  2908. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2909. utils.ErrorLog("解析失败:%v", err)
  2910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2911. return
  2912. }
  2913. res.InfRefmsgid = resSix10265.InfRefmsgid
  2914. //res.Output = resSix10265.Output
  2915. res.ErrMsg = resSix10265.ErrMsg
  2916. res.Cainfo = resSix10265.Cainfo
  2917. res.WarnMsg = resSix10265.WarnMsg
  2918. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2919. res.Infcode = infocode
  2920. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2921. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2922. saveLog(result2, result1, "3507", "3507")
  2923. var respJSON2 map[string]interface{}
  2924. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2927. return
  2928. }
  2929. userJSONBytes2, _ := json.Marshal(respJSON2)
  2930. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2931. utils.ErrorLog("解析失败:%v", err)
  2932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2933. return
  2934. }
  2935. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2936. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2937. saveLog(result2, result1, "3507", "3507")
  2938. var respJSON2 map[string]interface{}
  2939. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2942. return
  2943. }
  2944. userJSONBytes2, _ := json.Marshal(respJSON2)
  2945. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2946. utils.ErrorLog("解析失败:%v", err)
  2947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2948. return
  2949. }
  2950. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2951. result1, result2 := service.Jxyb3507(struct3507)
  2952. saveLog(result2, result1, "3507", "3507")
  2953. var respJSON2 map[string]interface{}
  2954. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2957. return
  2958. }
  2959. userJSONBytes2, _ := json.Marshal(respJSON2)
  2960. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2961. utils.ErrorLog("解析失败:%v", err)
  2962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2963. return
  2964. }
  2965. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2966. result1, result2 := service.AHyb3507(struct3507)
  2967. saveLog(result2, result1, "3507", "3507")
  2968. var respJSON2 map[string]interface{}
  2969. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2972. return
  2973. }
  2974. userJSONBytes2, _ := json.Marshal(respJSON2)
  2975. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2976. utils.ErrorLog("解析失败:%v", err)
  2977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2978. return
  2979. }
  2980. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2981. data := make(map[string]interface{})
  2982. data["struct_3507s"] = struct3507
  2983. client := &http.Client{}
  2984. bytesData, _ := json.Marshal(data)
  2985. var req *http.Request
  2986. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2987. resp, _ := client.Do(req)
  2988. defer resp.Body.Close()
  2989. body, ioErr := ioutil.ReadAll(resp.Body)
  2990. if ioErr != nil {
  2991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2992. }
  2993. var respJSON map[string]interface{}
  2994. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2996. }
  2997. var resSix10265 ResultSix10265 //1101结果
  2998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2999. result, _ := json.Marshal(respJSON)
  3000. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3001. utils.ErrorLog("解析失败:%v", err)
  3002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3003. return
  3004. }
  3005. res.InfRefmsgid = resSix10265.InfRefmsgid
  3006. res.ErrMsg = resSix10265.ErrMsg
  3007. res.Cainfo = resSix10265.Cainfo
  3008. res.WarnMsg = resSix10265.WarnMsg
  3009. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3010. res.Infcode = infocode
  3011. }
  3012. if res.Infcode == 0 {
  3013. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3014. item.IsSale = 0
  3015. item.SaleDate = ""
  3016. item.Bchno = ""
  3017. service.SaveDF(item)
  3018. } else {
  3019. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3020. }
  3021. }
  3022. }
  3023. c.ServeSuccessJSON(map[string]interface{}{
  3024. "msg": "删除销售数据成功",
  3025. })
  3026. }
  3027. // 删除
  3028. func (c *HisApiController) DeleteXSandBGThree() {
  3029. id, _ := c.GetInt64("id")
  3030. admin_user_id, _ := c.GetInt64("admin_user_id")
  3031. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3032. var flows []*models.DrugFlow
  3033. for _, item := range advicelist {
  3034. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3035. flows = append(flows, flow...)
  3036. }
  3037. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3038. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3039. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3040. var err []string
  3041. for _, item := range flows {
  3042. if item.IsSale == 1 {
  3043. var res FJ3507Result
  3044. var struct3507 models.Struct3507
  3045. struct3507.FixmedinsBchno = item.Bchno
  3046. struct3507.InvDataType = "4"
  3047. struct3507.Opter = roles.UserName
  3048. struct3507.OrgName = miConfig.OrgName
  3049. struct3507.AccessKey = miConfig.AccessKey
  3050. struct3507.RequestUrl = miConfig.Url
  3051. struct3507.FixmedinsCode = miConfig.Code
  3052. struct3507.SecretKey = miConfig.SecretKey
  3053. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3054. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3055. struct3507.Url = miConfig.Url
  3056. struct3507.AppId = miConfig.Cainfo
  3057. struct3507.AppSecret = miConfig.AppSecret
  3058. struct3507.Enckey = miConfig.EncKey
  3059. struct3507.SignKey = miConfig.SignKey
  3060. struct3507.SecretKey = miConfig.SecretKey
  3061. if miConfig.MdtrtareaAdmvs == "350500" {
  3062. result, result1, _ := service.FJyb3507(struct3507)
  3063. saveLog(result, result1, "3507", "3507")
  3064. var respJSON2 map[string]interface{}
  3065. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3068. return
  3069. }
  3070. userJSONBytes2, _ := json.Marshal(respJSON2)
  3071. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3072. utils.ErrorLog("解析失败:%v", err)
  3073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3074. return
  3075. }
  3076. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3077. data := make(map[string]interface{})
  3078. data["struct_3507s"] = struct3507
  3079. client := &http.Client{}
  3080. bytesData, _ := json.Marshal(data)
  3081. var req *http.Request
  3082. if miConfig.MdtrtareaAdmvs == "320921" {
  3083. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3084. } else {
  3085. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3086. }
  3087. resp, _ := client.Do(req)
  3088. defer resp.Body.Close()
  3089. body, ioErr := ioutil.ReadAll(resp.Body)
  3090. if ioErr != nil {
  3091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3092. }
  3093. var respJSON map[string]interface{}
  3094. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3097. return
  3098. }
  3099. var resSix10265 ResultSix10265 //1101结果
  3100. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3101. result, _ := json.Marshal(respJSON)
  3102. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3103. utils.ErrorLog("解析失败:%v", err)
  3104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3105. return
  3106. }
  3107. res.InfRefmsgid = resSix10265.InfRefmsgid
  3108. //res.Output = resSix10265.Output
  3109. res.ErrMsg = resSix10265.ErrMsg
  3110. res.Cainfo = resSix10265.Cainfo
  3111. res.WarnMsg = resSix10265.WarnMsg
  3112. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3113. res.Infcode = infocode
  3114. } else if miConfig.MdtrtareaAdmvs == "440100" {
  3115. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3116. saveLog(result2, result1, "3507", "3507")
  3117. var respJSON2 map[string]interface{}
  3118. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3121. return
  3122. }
  3123. userJSONBytes2, _ := json.Marshal(respJSON2)
  3124. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3125. utils.ErrorLog("解析失败:%v", err)
  3126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3127. return
  3128. }
  3129. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3130. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3131. saveLog(result2, result1, "3507", "3507")
  3132. var respJSON2 map[string]interface{}
  3133. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3136. return
  3137. }
  3138. userJSONBytes2, _ := json.Marshal(respJSON2)
  3139. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3140. utils.ErrorLog("解析失败:%v", err)
  3141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3142. return
  3143. }
  3144. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3145. result1, result2 := service.Jxyb3507(struct3507)
  3146. saveLog(result2, result1, "3507", "3507")
  3147. var respJSON2 map[string]interface{}
  3148. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3151. return
  3152. }
  3153. userJSONBytes2, _ := json.Marshal(respJSON2)
  3154. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3155. utils.ErrorLog("解析失败:%v", err)
  3156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3157. return
  3158. }
  3159. } else if miConfig.MdtrtareaAdmvs == "340699" {
  3160. result1, result2 := service.AHyb3507(struct3507)
  3161. saveLog(result2, result1, "3507", "3507")
  3162. var respJSON2 map[string]interface{}
  3163. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3166. return
  3167. }
  3168. userJSONBytes2, _ := json.Marshal(respJSON2)
  3169. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3170. utils.ErrorLog("解析失败:%v", err)
  3171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3172. return
  3173. }
  3174. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3175. data := make(map[string]interface{})
  3176. data["struct_3507s"] = struct3507
  3177. client := &http.Client{}
  3178. bytesData, _ := json.Marshal(data)
  3179. var req *http.Request
  3180. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3181. resp, _ := client.Do(req)
  3182. defer resp.Body.Close()
  3183. body, ioErr := ioutil.ReadAll(resp.Body)
  3184. if ioErr != nil {
  3185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3186. }
  3187. var respJSON map[string]interface{}
  3188. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3190. }
  3191. var resSix10265 ResultSix10265 //1101结果
  3192. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3193. result, _ := json.Marshal(respJSON)
  3194. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3195. utils.ErrorLog("解析失败:%v", err)
  3196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3197. return
  3198. }
  3199. res.InfRefmsgid = resSix10265.InfRefmsgid
  3200. res.ErrMsg = resSix10265.ErrMsg
  3201. res.Cainfo = resSix10265.Cainfo
  3202. res.WarnMsg = resSix10265.WarnMsg
  3203. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3204. res.Infcode = infocode
  3205. }
  3206. if res.Infcode == 0 {
  3207. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3208. item.IsSale = 0
  3209. item.SaleDate = ""
  3210. item.Bchno = ""
  3211. service.SaveDF(item)
  3212. } else {
  3213. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3214. }
  3215. }
  3216. }
  3217. c.ServeSuccessJSON(map[string]interface{}{
  3218. "msg": "删除销售数据成功",
  3219. })
  3220. }
  3221. // 获取当天起止时间戳
  3222. func GetNowTime() (int64, int64) {
  3223. t := time.Now()
  3224. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3225. timesamp := addTime.Unix()
  3226. return timesamp, timesamp + 86399
  3227. }
  3228. func (c *HisApiController) ChangeDrugfour() {
  3229. patient_id, _ := c.GetInt64("patient_id")
  3230. admin_user_id, _ := c.GetInt64("admin_user_id")
  3231. times := c.GetString("time", "")
  3232. timeLayout := "2006-01-02"
  3233. loc, _ := time.LoadLocation("Local")
  3234. var stime, etime int64
  3235. if times == "" {
  3236. stime, etime = GetNowTime()
  3237. } else {
  3238. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3239. stime = stmp.Unix()
  3240. etime = stime + 86399
  3241. }
  3242. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3243. var flows []*models.DrugFlow
  3244. for _, item := range advicelist {
  3245. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  3246. flows = append(flows, flow...)
  3247. }
  3248. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3249. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3250. var err []string
  3251. for _, item := range flows {
  3252. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3253. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3254. if prescription.OrderStatus == 2 {
  3255. if item.IsSale == 0 {
  3256. var res FJ3507Result
  3257. var res3507for10188 FJ3507ResultFor10188
  3258. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3259. //进行商品销售接口
  3260. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3261. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3262. var respJSON3 map[string]interface{}
  3263. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3266. return
  3267. }
  3268. userJSONBytes3, _ := json.Marshal(respJSON3)
  3269. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3270. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3271. utils.ErrorLog("解析失败:%v", err)
  3272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3273. return
  3274. }
  3275. //if res3507for10188.Infcode
  3276. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3277. //res.Output = resSix10265.Output
  3278. res.ErrMsg = res3507for10188.ErrMsg
  3279. res.Cainfo = res3507for10188.Cainfo
  3280. res.WarnMsg = res3507for10188.WarnMsg
  3281. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3282. res.Infcode = infocode
  3283. } else {
  3284. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3285. utils.ErrorLog("解析失败:%v", err)
  3286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3287. return
  3288. }
  3289. }
  3290. if res.Infcode == 0 {
  3291. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3292. item.IsSale = 1
  3293. item.Bchno = number
  3294. item.SaleDate = time.Now().Format("2006-01-02")
  3295. service.SaveDF(item)
  3296. } else {
  3297. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3298. }
  3299. }
  3300. } else { //还没结,提示用户去结算,并药品追溯上传
  3301. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3302. }
  3303. }
  3304. }
  3305. str := strings.Join(err, " ")
  3306. saveLog(str, str, "3505", "3505自动上传日志")
  3307. c.ServeSuccessJSON(map[string]interface{}{
  3308. "status": "1",
  3309. "msg": err,
  3310. })
  3311. }
  3312. func (c *HisApiController) ChangeDrugFive() {
  3313. id := c.GetString("id")
  3314. ids := strings.Split(id, ",")
  3315. admin_user_id, _ := c.GetInt64("admin_user_id")
  3316. var err []string
  3317. for _, value := range ids{
  3318. intValue, _ := strconv.ParseInt(value, 10, 64)
  3319. //file := strconv.FormatInt(int64(num), 10)
  3320. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3321. var flows []*models.DrugFlow
  3322. for _, item := range advicelist {
  3323. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3324. flows = append(flows, flow...)
  3325. }
  3326. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3327. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3328. for _, item := range flows {
  3329. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3330. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3331. if prescription.OrderStatus == 2 {
  3332. if item.IsSale == 0 {
  3333. var res FJ3507Result
  3334. var res3507for10188 FJ3507ResultFor10188
  3335. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3336. //进行商品销售接口
  3337. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3338. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3339. var respJSON3 map[string]interface{}
  3340. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3343. return
  3344. }
  3345. userJSONBytes3, _ := json.Marshal(respJSON3)
  3346. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3347. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3348. utils.ErrorLog("解析失败:%v", err)
  3349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3350. return
  3351. }
  3352. //if res3507for10188.Infcode
  3353. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3354. //res.Output = resSix10265.Output
  3355. res.ErrMsg = res3507for10188.ErrMsg
  3356. res.Cainfo = res3507for10188.Cainfo
  3357. res.WarnMsg = res3507for10188.WarnMsg
  3358. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3359. res.Infcode = infocode
  3360. } else {
  3361. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3362. utils.ErrorLog("解析失败:%v", err)
  3363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3364. return
  3365. }
  3366. }
  3367. if res.Infcode == 0 {
  3368. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3369. item.IsSale = 1
  3370. item.Bchno = number
  3371. item.SaleDate = time.Now().Format("2006-01-02")
  3372. service.SaveDF(item)
  3373. } else {
  3374. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3375. }
  3376. }
  3377. } else { //还没结,提示用户去结算,并药品追溯上传
  3378. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3379. }
  3380. }
  3381. }
  3382. str := strings.Join(err, " ")
  3383. saveLog(str, str, "3505", "3505自动上传日志")
  3384. }
  3385. c.ServeSuccessJSON(map[string]interface{}{
  3386. "status": "1",
  3387. "msg": err,
  3388. })
  3389. }
  3390. //func (c *HisApiController) ChangeDrugfour() {
  3391. // patient_id, _ := c.GetInt64("patient_id")
  3392. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3393. // //id_arr := strings.Split(ids, ",")
  3394. // times := c.GetString("time", "")
  3395. // timeLayout := "2006-01-02"
  3396. // loc, _ := time.LoadLocation("Local")
  3397. // var stime, etime int64
  3398. // if times == "" {
  3399. // stime, etime = GetNowTime()
  3400. // } else {
  3401. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3402. // stime = stmp.Unix()
  3403. // etime = stime + 86399
  3404. // }
  3405. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3406. // var flows []*models.DrugFlow
  3407. // for _, item := range advicelist {
  3408. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3409. // flows = append(flows, flow...)
  3410. // }
  3411. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3412. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3413. // var err []string
  3414. //
  3415. // for _, item := range flows {
  3416. // var res3 ResultSix
  3417. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3418. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3419. // if prescription.OrderStatus == 2 {
  3420. // //已经结算
  3421. // //判断是否已经销售
  3422. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3423. // //是否已经变更 1是 0否
  3424. // if item.IsChange == 0 { //没变更,进行变更操作
  3425. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3426. //
  3427. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3428. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3429. // var respJSON3 map[string]interface{}
  3430. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3431. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3433. // return
  3434. // }
  3435. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3436. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3437. // utils.ErrorLog("解析失败:%v", err)
  3438. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3439. // return
  3440. // }
  3441. // if res3.Infcode == 0 {
  3442. // item.IsChange = 1
  3443. // item.BgBchno = bg_number
  3444. // service.SaveDF2(item)
  3445. // } else {
  3446. //
  3447. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3448. // }
  3449. // }
  3450. // } else { //没销售,
  3451. // var res FJ3507Result
  3452. // var res3507for10188 FJ3507ResultFor10188
  3453. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3454. //
  3455. // //进行商品销售接口
  3456. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3457. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3458. // var respJSON3 map[string]interface{}
  3459. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3460. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3461. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3462. // return
  3463. // }
  3464. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3465. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3466. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3467. // utils.ErrorLog("解析失败:%v", err)
  3468. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3469. // return
  3470. // }
  3471. // //if res3507for10188.Infcode
  3472. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3473. // //res.Output = resSix10265.Output
  3474. // res.ErrMsg = res3507for10188.ErrMsg
  3475. // res.Cainfo = res3507for10188.Cainfo
  3476. // res.WarnMsg = res3507for10188.WarnMsg
  3477. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3478. // res.Infcode = infocode
  3479. // } else {
  3480. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3481. // utils.ErrorLog("解析失败:%v", err)
  3482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3483. // return
  3484. // }
  3485. //
  3486. // }
  3487. // if res.Infcode == 0 {
  3488. // item.IsSale = 1
  3489. // item.Bchno = number
  3490. // item.SaleDate = time.Now().Format("2006-01-02")
  3491. //
  3492. // err5 := service.SaveDF(item)
  3493. // if err5 == nil {
  3494. // if item.IsChange == 0 { //没变更,进行变更操作
  3495. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3496. //
  3497. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3498. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3499. //
  3500. // var respJSON3 map[string]interface{}
  3501. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3502. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3504. // return
  3505. // }
  3506. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3507. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3508. // utils.ErrorLog("解析失败:%v", err)
  3509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3510. // return
  3511. // }
  3512. // //if res3507for10188.Infcode
  3513. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3514. // //res.Output = resSix10265.Output
  3515. // res3.ErrMsg = res3507for10188.ErrMsg
  3516. // res3.Cainfo = res3507for10188.Cainfo
  3517. // res3.WarnMsg = res3507for10188.WarnMsg
  3518. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3519. // res3.Infcode = infocode
  3520. // } else {
  3521. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3522. // utils.ErrorLog("解析失败:%v", err)
  3523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3524. // return
  3525. // }
  3526. // }
  3527. // if res3.Infcode == 0 {
  3528. // item.IsChange = 1
  3529. // item.BgBchno = bg_number
  3530. // service.SaveDF2(item)
  3531. // } else {
  3532. //
  3533. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3534. // }
  3535. // }
  3536. // }
  3537. // } else {
  3538. //
  3539. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3540. // }
  3541. // }
  3542. //
  3543. // } else { //还没结,提示用户去结算,并药品追溯上传
  3544. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3545. // }
  3546. // }
  3547. // }
  3548. // if len(err) == 0 {
  3549. // c.ServeSuccessJSON(map[string]interface{}{
  3550. // "msg": "销售变更成功",
  3551. // })
  3552. // } else {
  3553. // c.ServeSuccessJSON(map[string]interface{}{
  3554. // "failed_code": -10,
  3555. // "msg": err,
  3556. // })
  3557. // }
  3558. //}
  3559. func (c *HisApiController) ChangeDrug() {
  3560. ids := c.GetString("ids")
  3561. id_arr := strings.Split(ids, ",")
  3562. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3563. admin_user_id, _ := c.GetInt64("admin_user_id")
  3564. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3565. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3566. var err []string
  3567. for _, item := range flows {
  3568. var res3 ResultSix
  3569. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3570. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3571. if prescription.OrderStatus == 2 {
  3572. //已经结算
  3573. //判断是否已经销售
  3574. if item.IsSale == 1 { //是否已经销售,1是 0否
  3575. //是否已经变更 1是 0否
  3576. if item.IsChange == 0 { //没变更,进行变更操作
  3577. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3578. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3579. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3580. var respJSON3 map[string]interface{}
  3581. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3584. return
  3585. }
  3586. userJSONBytes3, _ := json.Marshal(respJSON3)
  3587. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3588. utils.ErrorLog("解析失败:%v", err)
  3589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3590. return
  3591. }
  3592. if res3.Infcode == 0 {
  3593. item.IsChange = 1
  3594. item.BgBchno = bg_number
  3595. service.SaveDF2(item)
  3596. } else {
  3597. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3598. }
  3599. }
  3600. } else { //没销售,
  3601. var res FJ3507Result
  3602. var res3507for10188 FJ3507ResultFor10188
  3603. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3604. //进行商品销售接口
  3605. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3606. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3607. var respJSON3 map[string]interface{}
  3608. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3611. return
  3612. }
  3613. userJSONBytes3, _ := json.Marshal(respJSON3)
  3614. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3615. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3616. utils.ErrorLog("解析失败:%v", err)
  3617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3618. return
  3619. }
  3620. //if res3507for10188.Infcode
  3621. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3622. //res.Output = resSix10265.Output
  3623. res.ErrMsg = res3507for10188.ErrMsg
  3624. res.Cainfo = res3507for10188.Cainfo
  3625. res.WarnMsg = res3507for10188.WarnMsg
  3626. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3627. res.Infcode = infocode
  3628. } else {
  3629. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3630. utils.ErrorLog("解析失败:%v", err)
  3631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3632. return
  3633. }
  3634. }
  3635. if res.Infcode == 0 {
  3636. item.IsSale = 1
  3637. item.Bchno = number
  3638. item.SaleDate = time.Now().Format("2006-01-02")
  3639. err5 := service.SaveDF(item)
  3640. if err5 == nil {
  3641. if item.IsChange == 0 { //没变更,进行变更操作
  3642. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3643. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3644. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3645. var respJSON3 map[string]interface{}
  3646. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3649. return
  3650. }
  3651. userJSONBytes3, _ := json.Marshal(respJSON3)
  3652. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3653. utils.ErrorLog("解析失败:%v", err)
  3654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3655. return
  3656. }
  3657. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3658. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3659. utils.ErrorLog("解析失败:%v", err)
  3660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3661. return
  3662. }
  3663. //if res3507for10188.Infcode
  3664. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3665. //res.Output = resSix10265.Output
  3666. res3.ErrMsg = res3507for10188.ErrMsg
  3667. res3.Cainfo = res3507for10188.Cainfo
  3668. res3.WarnMsg = res3507for10188.WarnMsg
  3669. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3670. res3.Infcode = infocode
  3671. } else {
  3672. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3673. utils.ErrorLog("解析失败:%v", err)
  3674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3675. return
  3676. }
  3677. }
  3678. if res3.Infcode == 0 {
  3679. item.IsChange = 1
  3680. item.BgBchno = bg_number
  3681. service.SaveDF2(item)
  3682. } else {
  3683. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3684. }
  3685. }
  3686. }
  3687. } else {
  3688. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3689. }
  3690. }
  3691. } else { //还没结算
  3692. var res3507for10188 FJ3507ResultFor10188
  3693. if item.IsChange == 0 { //没变更,进行变更操作
  3694. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3695. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3696. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3697. var respJSON3 map[string]interface{}
  3698. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3701. return
  3702. }
  3703. userJSONBytes3, _ := json.Marshal(respJSON3)
  3704. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3705. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3706. utils.ErrorLog("解析失败:%v", err)
  3707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3708. return
  3709. }
  3710. //if res3507for10188.Infcode
  3711. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3712. //res.Output = resSix10265.Output
  3713. res3.ErrMsg = res3507for10188.ErrMsg
  3714. res3.Cainfo = res3507for10188.Cainfo
  3715. res3.WarnMsg = res3507for10188.WarnMsg
  3716. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3717. res3.Infcode = infocode
  3718. } else {
  3719. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3720. utils.ErrorLog("解析失败:%v", err)
  3721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3722. return
  3723. }
  3724. }
  3725. if res3.Infcode == 0 {
  3726. item.IsChange = 1
  3727. item.BgBchno = bg_number
  3728. service.SaveDF2(item)
  3729. } else {
  3730. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3731. }
  3732. }
  3733. }
  3734. } else if item.ConsumableType == 7 {
  3735. var res3507for10188 FJ3507ResultFor10188
  3736. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3737. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3738. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3739. //判断是否已经销售
  3740. if item.IsSale == 2 { //是否已经销售,1是 0否
  3741. //是否已经变更 1是 0否
  3742. if item.IsChange == 0 { //没变更,进行变更操作
  3743. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3744. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3745. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3746. var respJSON3 map[string]interface{}
  3747. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3750. return
  3751. }
  3752. userJSONBytes3, _ := json.Marshal(respJSON3)
  3753. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3754. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3755. utils.ErrorLog("解析失败:%v", err)
  3756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3757. return
  3758. }
  3759. //if res3507for10188.Infcode
  3760. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3761. //res.Output = resSix10265.Output
  3762. res3.ErrMsg = res3507for10188.ErrMsg
  3763. res3.Cainfo = res3507for10188.Cainfo
  3764. res3.WarnMsg = res3507for10188.WarnMsg
  3765. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3766. res3.Infcode = infocode
  3767. } else {
  3768. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3769. utils.ErrorLog("解析失败:%v", err)
  3770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3771. return
  3772. }
  3773. }
  3774. if res3.Infcode == 0 {
  3775. item.IsChange = 1
  3776. item.BgBchno = bg_number
  3777. service.SaveDF2(item)
  3778. } else {
  3779. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3780. }
  3781. }
  3782. } else { //没销售,
  3783. //进行商品销售退货接口
  3784. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3785. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3786. saveLog(result111, result222, "3506", "销售退货")
  3787. var res7 FJ3507Result
  3788. //进行商品销售接口
  3789. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3790. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3791. var respJSON3 map[string]interface{}
  3792. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3795. return
  3796. }
  3797. userJSONBytes3, _ := json.Marshal(respJSON3)
  3798. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3799. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3800. utils.ErrorLog("解析失败:%v", err)
  3801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3802. return
  3803. }
  3804. //if res3507for10188.Infcode
  3805. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3806. //res.Output = resSix10265.Output
  3807. res7.ErrMsg = res3507for10188.ErrMsg
  3808. res7.Cainfo = res3507for10188.Cainfo
  3809. res7.WarnMsg = res3507for10188.WarnMsg
  3810. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3811. res7.Infcode = infocode
  3812. } else {
  3813. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3814. utils.ErrorLog("解析失败:%v", err)
  3815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3816. return
  3817. }
  3818. }
  3819. if res7.Infcode == 0 {
  3820. item.IsSale = 2
  3821. item.SaleDate = item.SaleDate
  3822. item.Bchno = number
  3823. service.SaveDF(item)
  3824. if item.IsChange == 0 { //没变更,进行变更操作
  3825. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3826. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3827. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3828. var respJSON3 map[string]interface{}
  3829. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3832. return
  3833. }
  3834. userJSONBytes3, _ := json.Marshal(respJSON3)
  3835. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3836. // utils.ErrorLog("解析失败:%v", err)
  3837. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3838. // return
  3839. //}
  3840. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3841. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3842. utils.ErrorLog("解析失败:%v", err)
  3843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3844. return
  3845. }
  3846. //if res3507for10188.Infcode
  3847. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3848. //res.Output = resSix10265.Output
  3849. res3.ErrMsg = res3507for10188.ErrMsg
  3850. res3.Cainfo = res3507for10188.Cainfo
  3851. res3.WarnMsg = res3507for10188.WarnMsg
  3852. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3853. res3.Infcode = infocode
  3854. } else {
  3855. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3856. utils.ErrorLog("解析失败:%v", err)
  3857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3858. return
  3859. }
  3860. }
  3861. if res3.Infcode == 0 {
  3862. item.IsChange = 1
  3863. item.BgBchno = bg_number
  3864. service.SaveDF2(item)
  3865. } else {
  3866. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3867. }
  3868. }
  3869. } else {
  3870. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3871. }
  3872. }
  3873. } else { //还没结算
  3874. if item.IsChange == 0 { //没变更,进行变更操作
  3875. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3876. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3877. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3878. var respJSON3 map[string]interface{}
  3879. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3882. return
  3883. }
  3884. userJSONBytes3, _ := json.Marshal(respJSON3)
  3885. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3886. // utils.ErrorLog("解析失败:%v", err)
  3887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3888. // return
  3889. //}
  3890. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3891. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3892. utils.ErrorLog("解析失败:%v", err)
  3893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3894. return
  3895. }
  3896. //if res3507for10188.Infcode
  3897. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3898. //res.Output = resSix10265.Output
  3899. res3.ErrMsg = res3507for10188.ErrMsg
  3900. res3.Cainfo = res3507for10188.Cainfo
  3901. res3.WarnMsg = res3507for10188.WarnMsg
  3902. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3903. res3.Infcode = infocode
  3904. } else {
  3905. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3906. utils.ErrorLog("解析失败:%v", err)
  3907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3908. return
  3909. }
  3910. }
  3911. if res3.Infcode == 0 {
  3912. item.IsChange = 1
  3913. item.BgBchno = bg_number
  3914. service.SaveDF2(item)
  3915. } else {
  3916. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3917. }
  3918. }
  3919. }
  3920. }
  3921. }
  3922. if len(err) == 0 {
  3923. c.ServeSuccessJSON(map[string]interface{}{
  3924. "msg": "销售变更成功",
  3925. })
  3926. } else {
  3927. c.ServeSuccessJSON(map[string]interface{}{
  3928. "failed_code": -10,
  3929. "msg": err,
  3930. })
  3931. }
  3932. }
  3933. func (c *HisApiController) ChangeDrugtwo() {
  3934. //ids := c.GetString("ids")
  3935. //id_arr := strings.Split(ids, ",")
  3936. flows, _ := service.GetNewDrugFlowInfothree123()
  3937. admin_user_id, _ := c.GetInt64("admin_user_id")
  3938. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3939. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3940. var err []string
  3941. for _, item := range flows {
  3942. var res3 ResultSix
  3943. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3944. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3945. if prescription.OrderStatus == 2 {
  3946. //已经结算
  3947. //判断是否已经销售
  3948. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3949. // //是否已经变更 1是 0否
  3950. // if item.IsChange == 0 { //没变更,进行变更操作
  3951. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3952. //
  3953. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3954. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3955. // var respJSON3 map[string]interface{}
  3956. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3957. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3958. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3959. // return
  3960. // }
  3961. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3962. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3963. // utils.ErrorLog("解析失败:%v", err)
  3964. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3965. // return
  3966. // }
  3967. // if res3.Infcode == 0 {
  3968. // item.IsChange = 1
  3969. // item.BgBchno = bg_number
  3970. // service.SaveDF2(item)
  3971. // } else {
  3972. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3973. // }
  3974. // }
  3975. //}
  3976. //else
  3977. { //没销售,
  3978. var res FJ3507Result
  3979. var res3507for10188 FJ3507ResultFor10188
  3980. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3981. //进行商品销售接口
  3982. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3983. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3984. var respJSON3 map[string]interface{}
  3985. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. return
  3989. }
  3990. userJSONBytes3, _ := json.Marshal(respJSON3)
  3991. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3992. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3993. utils.ErrorLog("解析失败:%v", err)
  3994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. return
  3996. }
  3997. //if res3507for10188.Infcode
  3998. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3999. //res.Output = resSix10265.Output
  4000. res.ErrMsg = res3507for10188.ErrMsg
  4001. res.Cainfo = res3507for10188.Cainfo
  4002. res.WarnMsg = res3507for10188.WarnMsg
  4003. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4004. res.Infcode = infocode
  4005. } else {
  4006. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4007. utils.ErrorLog("解析失败:%v", err)
  4008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4009. return
  4010. }
  4011. }
  4012. if res.Infcode == 0 {
  4013. item.IsSale = 1
  4014. item.Bchno = number
  4015. item.SaleDate = time.Now().Format("2006-01-02")
  4016. service.SaveDF(item)
  4017. //if err5 == nil {
  4018. // if item.IsChange == 0 { //没变更,进行变更操作
  4019. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4020. //
  4021. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4022. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4023. //
  4024. // var respJSON3 map[string]interface{}
  4025. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4026. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4027. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4028. // return
  4029. // }
  4030. //
  4031. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4032. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4033. // utils.ErrorLog("解析失败:%v", err)
  4034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4035. // return
  4036. // }
  4037. // //if res3507for10188.Infcode
  4038. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4039. // //res.Output = resSix10265.Output
  4040. // res3.ErrMsg = res3507for10188.ErrMsg
  4041. // res3.Cainfo = res3507for10188.Cainfo
  4042. // res3.WarnMsg = res3507for10188.WarnMsg
  4043. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4044. // res3.Infcode = infocode
  4045. // } else {
  4046. //
  4047. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4048. // utils.ErrorLog("解析失败:%v", err)
  4049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4050. // return
  4051. // }
  4052. //
  4053. // }
  4054. //
  4055. // if res3.Infcode == 0 {
  4056. // item.IsChange = 1
  4057. // item.BgBchno = bg_number
  4058. // service.SaveDF2(item)
  4059. // } else {
  4060. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4061. // }
  4062. // }
  4063. //}
  4064. } else {
  4065. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4066. }
  4067. }
  4068. } else { //还没结算
  4069. var res3507for10188 FJ3507ResultFor10188
  4070. if item.IsChange == 0 { //没变更,进行变更操作
  4071. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4072. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4073. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4074. var respJSON3 map[string]interface{}
  4075. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4078. return
  4079. }
  4080. userJSONBytes3, _ := json.Marshal(respJSON3)
  4081. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4082. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4083. utils.ErrorLog("解析失败:%v", err)
  4084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4085. return
  4086. }
  4087. //if res3507for10188.Infcode
  4088. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4089. //res.Output = resSix10265.Output
  4090. res3.ErrMsg = res3507for10188.ErrMsg
  4091. res3.Cainfo = res3507for10188.Cainfo
  4092. res3.WarnMsg = res3507for10188.WarnMsg
  4093. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4094. res3.Infcode = infocode
  4095. } else {
  4096. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4097. utils.ErrorLog("解析失败:%v", err)
  4098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4099. return
  4100. }
  4101. }
  4102. if res3.Infcode == 0 {
  4103. item.IsChange = 1
  4104. item.BgBchno = bg_number
  4105. service.SaveDF2(item)
  4106. } else {
  4107. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4108. }
  4109. }
  4110. }
  4111. }
  4112. //if item.ConsumableType == 7 {
  4113. // var res3507for10188 FJ3507ResultFor10188
  4114. //
  4115. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4116. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4117. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4118. // //判断是否已经销售
  4119. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4120. // //是否已经变更 1是 0否
  4121. // if item.IsChange == 0 { //没变更,进行变更操作
  4122. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4123. //
  4124. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4125. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4126. //
  4127. // var respJSON3 map[string]interface{}
  4128. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4129. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4131. // return
  4132. // }
  4133. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4134. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4135. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4136. // utils.ErrorLog("解析失败:%v", err)
  4137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4138. // return
  4139. // }
  4140. // //if res3507for10188.Infcode
  4141. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4142. // //res.Output = resSix10265.Output
  4143. // res3.ErrMsg = res3507for10188.ErrMsg
  4144. // res3.Cainfo = res3507for10188.Cainfo
  4145. // res3.WarnMsg = res3507for10188.WarnMsg
  4146. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4147. // res3.Infcode = infocode
  4148. // } else {
  4149. //
  4150. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4151. // utils.ErrorLog("解析失败:%v", err)
  4152. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4153. // return
  4154. // }
  4155. //
  4156. // }
  4157. // if res3.Infcode == 0 {
  4158. // item.IsChange = 1
  4159. // item.BgBchno = bg_number
  4160. // service.SaveDF2(item)
  4161. // } else {
  4162. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4163. // }
  4164. // }
  4165. // } else { //没销售,
  4166. // //进行商品销售退货接口
  4167. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4168. //
  4169. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4170. // saveLog(result111, result222, "3506", "销售退货")
  4171. // var res7 FJ3507Result
  4172. //
  4173. // //进行商品销售接口
  4174. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4175. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4176. // var respJSON3 map[string]interface{}
  4177. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4178. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4180. // return
  4181. // }
  4182. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4183. //
  4184. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4185. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4186. // utils.ErrorLog("解析失败:%v", err)
  4187. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4188. // return
  4189. // }
  4190. // //if res3507for10188.Infcode
  4191. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4192. // //res.Output = resSix10265.Output
  4193. // res7.ErrMsg = res3507for10188.ErrMsg
  4194. // res7.Cainfo = res3507for10188.Cainfo
  4195. // res7.WarnMsg = res3507for10188.WarnMsg
  4196. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4197. // res7.Infcode = infocode
  4198. // } else {
  4199. //
  4200. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4201. // utils.ErrorLog("解析失败:%v", err)
  4202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4203. // return
  4204. // }
  4205. //
  4206. // }
  4207. // if res7.Infcode == 0 {
  4208. // item.IsSale = 2
  4209. // item.SaleDate = item.SaleDate
  4210. // item.Bchno = number
  4211. // service.SaveDF(item)
  4212. // if item.IsChange == 0 { //没变更,进行变更操作
  4213. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4214. //
  4215. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4216. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4217. //
  4218. // var respJSON3 map[string]interface{}
  4219. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4220. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4222. // return
  4223. // }
  4224. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4225. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4226. // // utils.ErrorLog("解析失败:%v", err)
  4227. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4228. // // return
  4229. // //}
  4230. //
  4231. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4232. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4233. // utils.ErrorLog("解析失败:%v", err)
  4234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4235. // return
  4236. // }
  4237. // //if res3507for10188.Infcode
  4238. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4239. // //res.Output = resSix10265.Output
  4240. // res3.ErrMsg = res3507for10188.ErrMsg
  4241. // res3.Cainfo = res3507for10188.Cainfo
  4242. // res3.WarnMsg = res3507for10188.WarnMsg
  4243. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4244. // res3.Infcode = infocode
  4245. // } else {
  4246. //
  4247. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4248. // utils.ErrorLog("解析失败:%v", err)
  4249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4250. // return
  4251. // }
  4252. //
  4253. // }
  4254. // if res3.Infcode == 0 {
  4255. // item.IsChange = 1
  4256. // item.BgBchno = bg_number
  4257. // service.SaveDF2(item)
  4258. // } else {
  4259. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4260. // }
  4261. // }
  4262. // } else {
  4263. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4264. // }
  4265. // }
  4266. // } else { //还没结算
  4267. // if item.IsChange == 0 { //没变更,进行变更操作
  4268. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4269. //
  4270. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4271. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4272. //
  4273. // var respJSON3 map[string]interface{}
  4274. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4275. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4277. // return
  4278. // }
  4279. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4280. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4281. // // utils.ErrorLog("解析失败:%v", err)
  4282. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4283. // // return
  4284. // //}
  4285. //
  4286. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  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 {
  4301. //
  4302. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4303. // utils.ErrorLog("解析失败:%v", err)
  4304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4305. // return
  4306. // }
  4307. //
  4308. // }
  4309. // if res3.Infcode == 0 {
  4310. // item.IsChange = 1
  4311. // item.BgBchno = bg_number
  4312. // service.SaveDF2(item)
  4313. // } else {
  4314. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4315. // }
  4316. // }
  4317. // }
  4318. //}
  4319. }
  4320. if len(err) == 0 {
  4321. c.ServeSuccessJSON(map[string]interface{}{
  4322. "msg": "销售变更成功",
  4323. })
  4324. } else {
  4325. c.ServeSuccessJSON(map[string]interface{}{
  4326. "failed_code": -10,
  4327. "msg": err,
  4328. })
  4329. }
  4330. }
  4331. func (c *HisApiController) ChangeDrugthree() {
  4332. //ids := c.GetString("ids")
  4333. //id_arr := strings.Split(ids, ",")
  4334. flows, _ := service.GetNewDrugFlowInfothree()
  4335. admin_user_id, _ := c.GetInt64("admin_user_id")
  4336. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4337. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4338. var err []string
  4339. for _, item := range flows {
  4340. var res3 ResultSix
  4341. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4342. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4343. if prescription.OrderStatus == 2 {
  4344. //已经结算
  4345. //判断是否已经销售
  4346. if item.IsSale == 1 { //是否已经销售,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, "102", 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 err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4360. utils.ErrorLog("解析失败:%v", err)
  4361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4362. return
  4363. }
  4364. if res3.Infcode == 0 {
  4365. item.IsChange = 1
  4366. item.BgBchno = bg_number
  4367. service.SaveDF2(item)
  4368. } else {
  4369. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4370. }
  4371. }
  4372. } else { //没销售,
  4373. var res FJ3507Result
  4374. var res3507for10188 FJ3507ResultFor10188
  4375. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4376. //进行商品销售接口
  4377. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4378. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4379. var respJSON3 map[string]interface{}
  4380. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4383. return
  4384. }
  4385. userJSONBytes3, _ := json.Marshal(respJSON3)
  4386. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4387. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4388. utils.ErrorLog("解析失败:%v", err)
  4389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4390. return
  4391. }
  4392. //if res3507for10188.Infcode
  4393. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4394. //res.Output = resSix10265.Output
  4395. res.ErrMsg = res3507for10188.ErrMsg
  4396. res.Cainfo = res3507for10188.Cainfo
  4397. res.WarnMsg = res3507for10188.WarnMsg
  4398. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4399. res.Infcode = infocode
  4400. } else {
  4401. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4402. utils.ErrorLog("解析失败:%v", err)
  4403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4404. return
  4405. }
  4406. }
  4407. if res.Infcode == 0 {
  4408. item.IsSale = 1
  4409. item.Bchno = number
  4410. item.SaleDate = time.Now().Format("2006-01-02")
  4411. err5 := service.SaveDF(item)
  4412. if err5 == nil {
  4413. if item.IsChange == 0 { //没变更,进行变更操作
  4414. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4415. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4416. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4417. var respJSON3 map[string]interface{}
  4418. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4421. return
  4422. }
  4423. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4424. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4425. utils.ErrorLog("解析失败:%v", err)
  4426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4427. return
  4428. }
  4429. //if res3507for10188.Infcode
  4430. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4431. //res.Output = resSix10265.Output
  4432. res3.ErrMsg = res3507for10188.ErrMsg
  4433. res3.Cainfo = res3507for10188.Cainfo
  4434. res3.WarnMsg = res3507for10188.WarnMsg
  4435. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4436. res3.Infcode = infocode
  4437. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4438. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4439. utils.ErrorLog("解析失败:%v", err)
  4440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4441. return
  4442. }
  4443. //if res3507for10188.Infcode
  4444. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4445. //res.Output = resSix10265.Output
  4446. res3.ErrMsg = res3507for10188.ErrMsg
  4447. res3.Cainfo = res3507for10188.Cainfo
  4448. res3.WarnMsg = res3507for10188.WarnMsg
  4449. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4450. res3.Infcode = infocode
  4451. } else {
  4452. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4453. utils.ErrorLog("解析失败:%v", err)
  4454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4455. return
  4456. }
  4457. }
  4458. if res3.Infcode == 0 {
  4459. item.IsChange = 1
  4460. item.BgBchno = bg_number
  4461. service.SaveDF2(item)
  4462. } else {
  4463. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4464. }
  4465. }
  4466. }
  4467. } else {
  4468. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4469. }
  4470. }
  4471. } else { //还没结算
  4472. var res3507for10188 FJ3507ResultFor10188
  4473. if item.IsChange == 0 { //没变更,进行变更操作
  4474. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4475. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4476. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4477. var respJSON3 map[string]interface{}
  4478. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4481. return
  4482. }
  4483. userJSONBytes3, _ := json.Marshal(respJSON3)
  4484. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4485. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4486. utils.ErrorLog("解析失败:%v", err)
  4487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4488. return
  4489. }
  4490. //if res3507for10188.Infcode
  4491. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4492. //res.Output = resSix10265.Output
  4493. res3.ErrMsg = res3507for10188.ErrMsg
  4494. res3.Cainfo = res3507for10188.Cainfo
  4495. res3.WarnMsg = res3507for10188.WarnMsg
  4496. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4497. res3.Infcode = infocode
  4498. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4499. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4500. utils.ErrorLog("解析失败:%v", err)
  4501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4502. return
  4503. }
  4504. //if res3507for10188.Infcode
  4505. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4506. //res.Output = resSix10265.Output
  4507. res3.ErrMsg = res3507for10188.ErrMsg
  4508. res3.Cainfo = res3507for10188.Cainfo
  4509. res3.WarnMsg = res3507for10188.WarnMsg
  4510. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4511. res3.Infcode = infocode
  4512. } else {
  4513. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4514. utils.ErrorLog("解析失败:%v", err)
  4515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4516. return
  4517. }
  4518. }
  4519. if res3.Infcode == 0 {
  4520. item.IsChange = 1
  4521. item.BgBchno = bg_number
  4522. service.SaveDF2(item)
  4523. } else {
  4524. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4525. }
  4526. }
  4527. }
  4528. } else if item.ConsumableType == 7 {
  4529. var res3507for10188 FJ3507ResultFor10188
  4530. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4531. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4532. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4533. //判断是否已经销售
  4534. if item.IsSale == 2 { //是否已经销售,1是 0否
  4535. //是否已经变更 1是 0否
  4536. if item.IsChange == 0 { //没变更,进行变更操作
  4537. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4538. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4539. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4540. var respJSON3 map[string]interface{}
  4541. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4544. return
  4545. }
  4546. userJSONBytes3, _ := json.Marshal(respJSON3)
  4547. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4548. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4549. utils.ErrorLog("解析失败:%v", err)
  4550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4551. return
  4552. }
  4553. //if res3507for10188.Infcode
  4554. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4555. //res.Output = resSix10265.Output
  4556. res3.ErrMsg = res3507for10188.ErrMsg
  4557. res3.Cainfo = res3507for10188.Cainfo
  4558. res3.WarnMsg = res3507for10188.WarnMsg
  4559. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4560. res3.Infcode = infocode
  4561. } else {
  4562. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4563. utils.ErrorLog("解析失败:%v", err)
  4564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4565. return
  4566. }
  4567. }
  4568. if res3.Infcode == 0 {
  4569. item.IsChange = 1
  4570. item.BgBchno = bg_number
  4571. service.SaveDF2(item)
  4572. } else {
  4573. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4574. }
  4575. }
  4576. } else { //没销售,
  4577. //进行商品销售退货接口
  4578. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4579. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4580. saveLog(result111, result222, "3506", "销售退货")
  4581. var res7 FJ3507Result
  4582. //进行商品销售接口
  4583. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4584. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4585. var respJSON3 map[string]interface{}
  4586. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4589. return
  4590. }
  4591. userJSONBytes3, _ := json.Marshal(respJSON3)
  4592. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4593. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4594. utils.ErrorLog("解析失败:%v", err)
  4595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4596. return
  4597. }
  4598. //if res3507for10188.Infcode
  4599. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4600. //res.Output = resSix10265.Output
  4601. res7.ErrMsg = res3507for10188.ErrMsg
  4602. res7.Cainfo = res3507for10188.Cainfo
  4603. res7.WarnMsg = res3507for10188.WarnMsg
  4604. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4605. res7.Infcode = infocode
  4606. } else {
  4607. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4608. utils.ErrorLog("解析失败:%v", err)
  4609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4610. return
  4611. }
  4612. }
  4613. if res7.Infcode == 0 {
  4614. item.IsSale = 2
  4615. item.SaleDate = item.SaleDate
  4616. item.Bchno = number
  4617. service.SaveDF(item)
  4618. if item.IsChange == 0 { //没变更,进行变更操作
  4619. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4620. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4621. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4622. var respJSON3 map[string]interface{}
  4623. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4626. return
  4627. }
  4628. userJSONBytes3, _ := json.Marshal(respJSON3)
  4629. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4630. // utils.ErrorLog("解析失败:%v", err)
  4631. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4632. // return
  4633. //}
  4634. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4635. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4636. utils.ErrorLog("解析失败:%v", err)
  4637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4638. return
  4639. }
  4640. //if res3507for10188.Infcode
  4641. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4642. //res.Output = resSix10265.Output
  4643. res3.ErrMsg = res3507for10188.ErrMsg
  4644. res3.Cainfo = res3507for10188.Cainfo
  4645. res3.WarnMsg = res3507for10188.WarnMsg
  4646. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4647. res3.Infcode = infocode
  4648. } else {
  4649. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4650. utils.ErrorLog("解析失败:%v", err)
  4651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4652. return
  4653. }
  4654. }
  4655. if res3.Infcode == 0 {
  4656. item.IsChange = 1
  4657. item.BgBchno = bg_number
  4658. service.SaveDF2(item)
  4659. } else {
  4660. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4661. }
  4662. }
  4663. } else {
  4664. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4665. }
  4666. }
  4667. } else { //还没结算
  4668. if item.IsChange == 0 { //没变更,进行变更操作
  4669. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4670. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4671. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4672. var respJSON3 map[string]interface{}
  4673. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4676. return
  4677. }
  4678. userJSONBytes3, _ := json.Marshal(respJSON3)
  4679. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4680. // utils.ErrorLog("解析失败:%v", err)
  4681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4682. // return
  4683. //}
  4684. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4685. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4686. utils.ErrorLog("解析失败:%v", err)
  4687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4688. return
  4689. }
  4690. //if res3507for10188.Infcode
  4691. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4692. //res.Output = resSix10265.Output
  4693. res3.ErrMsg = res3507for10188.ErrMsg
  4694. res3.Cainfo = res3507for10188.Cainfo
  4695. res3.WarnMsg = res3507for10188.WarnMsg
  4696. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4697. res3.Infcode = infocode
  4698. } else {
  4699. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4700. utils.ErrorLog("解析失败:%v", err)
  4701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4702. return
  4703. }
  4704. }
  4705. if res3.Infcode == 0 {
  4706. item.IsChange = 1
  4707. item.BgBchno = bg_number
  4708. service.SaveDF2(item)
  4709. } else {
  4710. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4711. }
  4712. }
  4713. }
  4714. }
  4715. }
  4716. if len(err) == 0 {
  4717. c.ServeSuccessJSON(map[string]interface{}{
  4718. "msg": "销售变更成功",
  4719. })
  4720. } else {
  4721. c.ServeSuccessJSON(map[string]interface{}{
  4722. "failed_code": -10,
  4723. "msg": err,
  4724. })
  4725. }
  4726. }
  4727. func (c *HisApiController) ChangeDrugTen() {
  4728. start_time_str := c.GetString("start_time")
  4729. end_time_str := c.GetString("end_time")
  4730. //ids := c.GetString("ids")
  4731. //id_arr := strings.Split(ids, ",")
  4732. timeLayout := "2006-01-02"
  4733. loc, _ := time.LoadLocation("Local")
  4734. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4735. recordStartTime := theStartTime.Unix()
  4736. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4737. recordEndTime := theEndTime.Unix()
  4738. //timestamp := int64(1729612800)
  4739. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4740. admin_user_id, _ := c.GetInt64("admin_user_id")
  4741. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4742. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4743. var err []string
  4744. for _, item := range flows {
  4745. var res3 ResultSix
  4746. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4747. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4748. continue
  4749. }
  4750. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4751. continue
  4752. }
  4753. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4754. if prescription.OrderStatus == 2 {
  4755. //已经结算
  4756. //判断 是否已经销售
  4757. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4758. ////是否已经变更 1是 0否
  4759. //if item.IsChange == 0 { //没变更,进行变更操作
  4760. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4761. //
  4762. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4763. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4764. // var respJSON3 map[string]interface{}
  4765. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4766. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4767. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4768. // return
  4769. // }
  4770. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4771. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4772. // utils.ErrorLog("解析失败:%v", err)
  4773. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4774. // return
  4775. // }
  4776. // if res3.Infcode == 0 {
  4777. // item.IsChange = 1
  4778. // item.BgBchno = bg_number
  4779. // service.SaveDF2(item)
  4780. // } else {
  4781. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4782. // }
  4783. //}
  4784. //} else
  4785. if item.IsSale == 0 { //没销售,
  4786. var res FJ3507Result
  4787. var res3507for10188 FJ3507ResultFor10188
  4788. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4789. //进行商品销售接口
  4790. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4791. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4792. var respJSON3 map[string]interface{}
  4793. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4796. return
  4797. }
  4798. userJSONBytes3, _ := json.Marshal(respJSON3)
  4799. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4800. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4801. utils.ErrorLog("解析失败:%v", err)
  4802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4803. return
  4804. }
  4805. //if res3507for10188.Infcode
  4806. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4807. //res.Output = resSix10265.Output
  4808. res.ErrMsg = res3507for10188.ErrMsg
  4809. res.Cainfo = res3507for10188.Cainfo
  4810. res.WarnMsg = res3507for10188.WarnMsg
  4811. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4812. res.Infcode = infocode
  4813. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4814. } else {
  4815. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4816. utils.ErrorLog("解析失败:%v", err)
  4817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4818. return
  4819. }
  4820. }
  4821. if res.Infcode == 0 {
  4822. item.IsSale = 1
  4823. item.Bchno = number
  4824. item.SaleDate = time.Now().Format("2006-01-02")
  4825. err5 := service.SaveDF(item)
  4826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4827. //if err5 == nil {
  4828. //
  4829. // if item.IsChange == 1 { //没变更,进行变更操作
  4830. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4831. //
  4832. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4833. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4834. //
  4835. // var respJSON3 map[string]interface{}
  4836. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4837. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4838. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4839. // return
  4840. // }
  4841. //
  4842. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4843. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4844. // utils.ErrorLog("解析失败:%v", err)
  4845. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4846. // return
  4847. // }
  4848. // //if res3507for10188.Infcode
  4849. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4850. // //res.Output = resSix10265.Output
  4851. // res3.ErrMsg = res3507for10188.ErrMsg
  4852. // res3.Cainfo = res3507for10188.Cainfo
  4853. // res3.WarnMsg = res3507for10188.WarnMsg
  4854. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4855. // res3.Infcode = infocode
  4856. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4857. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4858. // utils.ErrorLog("解析失败:%v", err)
  4859. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4860. // return
  4861. // }
  4862. // //if res3507for10188.Infcode
  4863. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4864. // //res.Output = resSix10265.Output
  4865. // res3.ErrMsg = res3507for10188.ErrMsg
  4866. // res3.Cainfo = res3507for10188.Cainfo
  4867. // res3.WarnMsg = res3507for10188.WarnMsg
  4868. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4869. // res3.Infcode = infocode
  4870. //
  4871. // } else {
  4872. //
  4873. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4874. // utils.ErrorLog("解析失败:%v", err)
  4875. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4876. // return
  4877. // }
  4878. //
  4879. // }
  4880. //
  4881. // if res3.Infcode == 0 {
  4882. // item.IsChange = 1
  4883. // item.BgBchno = bg_number
  4884. // service.SaveDF2(item)
  4885. // return
  4886. // } else {
  4887. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4888. // }
  4889. // }
  4890. //}
  4891. } else {
  4892. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4893. }
  4894. }
  4895. }
  4896. } else if item.ConsumableType == 7 {
  4897. var res3507for10188 FJ3507ResultFor10188
  4898. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4899. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4900. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4901. //判断是否已经销售
  4902. if item.IsSale == 2 { //是否已经销售,1是 0否
  4903. //是否已经变更 1是 0否
  4904. if item.IsChange == 0 { //没变更,进行变更操作
  4905. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4906. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4907. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4908. var respJSON3 map[string]interface{}
  4909. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4912. return
  4913. }
  4914. userJSONBytes3, _ := json.Marshal(respJSON3)
  4915. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4916. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4917. utils.ErrorLog("解析失败:%v", err)
  4918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4919. return
  4920. }
  4921. //if res3507for10188.Infcode
  4922. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4923. //res.Output = resSix10265.Output
  4924. res3.ErrMsg = res3507for10188.ErrMsg
  4925. res3.Cainfo = res3507for10188.Cainfo
  4926. res3.WarnMsg = res3507for10188.WarnMsg
  4927. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4928. res3.Infcode = infocode
  4929. } else {
  4930. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4931. utils.ErrorLog("解析失败:%v", err)
  4932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4933. return
  4934. }
  4935. }
  4936. if res3.Infcode == 0 {
  4937. item.IsChange = 1
  4938. item.BgBchno = bg_number
  4939. service.SaveDF2(item)
  4940. } else {
  4941. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4942. }
  4943. }
  4944. } else { //没销售,
  4945. //进行商品销售退货接口
  4946. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4947. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4948. saveLog(result111, result222, "3506", "销售退货")
  4949. var res7 FJ3507Result
  4950. //进行商品销售接口
  4951. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4952. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4953. var respJSON3 map[string]interface{}
  4954. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4957. return
  4958. }
  4959. userJSONBytes3, _ := json.Marshal(respJSON3)
  4960. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4961. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4962. utils.ErrorLog("解析失败:%v", err)
  4963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4964. return
  4965. }
  4966. //if res3507for10188.Infcode
  4967. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4968. //res.Output = resSix10265.Output
  4969. res7.ErrMsg = res3507for10188.ErrMsg
  4970. res7.Cainfo = res3507for10188.Cainfo
  4971. res7.WarnMsg = res3507for10188.WarnMsg
  4972. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4973. res7.Infcode = infocode
  4974. } else {
  4975. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4976. utils.ErrorLog("解析失败:%v", err)
  4977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4978. return
  4979. }
  4980. }
  4981. if res7.Infcode == 0 {
  4982. item.IsSale = 2
  4983. item.SaleDate = item.SaleDate
  4984. item.Bchno = number
  4985. service.SaveDF(item)
  4986. if item.IsChange == 0 { //没变更,进行变更操作
  4987. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4988. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4989. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4990. var respJSON3 map[string]interface{}
  4991. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4994. return
  4995. }
  4996. userJSONBytes3, _ := json.Marshal(respJSON3)
  4997. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4998. // utils.ErrorLog("解析失败:%v", err)
  4999. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5000. // return
  5001. //}
  5002. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5003. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5004. utils.ErrorLog("解析失败:%v", err)
  5005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5006. return
  5007. }
  5008. //if res3507for10188.Infcode
  5009. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5010. //res.Output = resSix10265.Output
  5011. res3.ErrMsg = res3507for10188.ErrMsg
  5012. res3.Cainfo = res3507for10188.Cainfo
  5013. res3.WarnMsg = res3507for10188.WarnMsg
  5014. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5015. res3.Infcode = infocode
  5016. } else {
  5017. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5018. utils.ErrorLog("解析失败:%v", err)
  5019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5020. return
  5021. }
  5022. }
  5023. if res3.Infcode == 0 {
  5024. item.IsChange = 1
  5025. item.BgBchno = bg_number
  5026. service.SaveDF2(item)
  5027. } else {
  5028. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5029. }
  5030. }
  5031. } else {
  5032. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5033. }
  5034. }
  5035. } else { //还没结算
  5036. if item.IsChange == 0 { //没变更,进行变更操作
  5037. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5038. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5039. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5040. var respJSON3 map[string]interface{}
  5041. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5044. return
  5045. }
  5046. userJSONBytes3, _ := json.Marshal(respJSON3)
  5047. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5048. // utils.ErrorLog("解析失败:%v", err)
  5049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5050. // return
  5051. //}
  5052. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5053. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5054. utils.ErrorLog("解析失败:%v", err)
  5055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5056. return
  5057. }
  5058. //if res3507for10188.Infcode
  5059. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5060. //res.Output = resSix10265.Output
  5061. res3.ErrMsg = res3507for10188.ErrMsg
  5062. res3.Cainfo = res3507for10188.Cainfo
  5063. res3.WarnMsg = res3507for10188.WarnMsg
  5064. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5065. res3.Infcode = infocode
  5066. } else {
  5067. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5068. utils.ErrorLog("解析失败:%v", err)
  5069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5070. return
  5071. }
  5072. }
  5073. if res3.Infcode == 0 {
  5074. item.IsChange = 1
  5075. item.BgBchno = bg_number
  5076. service.SaveDF2(item)
  5077. } else {
  5078. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5079. }
  5080. }
  5081. }
  5082. }
  5083. }
  5084. if len(err) == 0 {
  5085. c.ServeSuccessJSON(map[string]interface{}{
  5086. "msg": "销售变更成功",
  5087. })
  5088. } else {
  5089. c.ServeSuccessJSON(map[string]interface{}{
  5090. "failed_code": -10,
  5091. "msg": err,
  5092. })
  5093. }
  5094. }
  5095. func ChangeDrugTenone() {
  5096. //ids := c.GetString("ids")
  5097. //id_arr := strings.Split(ids, ",")
  5098. now := time.Now()
  5099. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  5100. //timestamp := int64(1729612800)
  5101. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  5102. admin_user_id := int64(2463)
  5103. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  5104. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  5105. var err []string
  5106. for _, item := range flows {
  5107. var res3 ResultSix
  5108. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  5109. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5110. continue
  5111. }
  5112. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5113. continue
  5114. }
  5115. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5116. if prescription.OrderStatus == 2 {
  5117. //已经结算
  5118. //判断是否已经销售
  5119. if item.IsSale == 1 { //是否已经销售,1是 0否
  5120. //是否已经变更 1是 0否
  5121. if item.IsChange == 0 { //没变更,进行变更操作
  5122. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5123. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5124. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  5125. var respJSON3 map[string]interface{}
  5126. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5128. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5129. return
  5130. }
  5131. userJSONBytes3, _ := json.Marshal(respJSON3)
  5132. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5133. utils.ErrorLog("解析失败:%v", err)
  5134. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5135. return
  5136. }
  5137. if res3.Infcode == 0 {
  5138. item.IsChange = 1
  5139. item.BgBchno = bg_number
  5140. service.SaveDF2(item)
  5141. } else {
  5142. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5143. }
  5144. }
  5145. } else { //没销售,
  5146. var res FJ3507Result
  5147. var res3507for10188 FJ3507ResultFor10188
  5148. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  5149. //进行商品销售接口
  5150. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  5151. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  5152. var respJSON3 map[string]interface{}
  5153. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  5154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5155. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5156. return
  5157. }
  5158. userJSONBytes3, _ := json.Marshal(respJSON3)
  5159. {
  5160. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5161. utils.ErrorLog("解析失败:%v", err)
  5162. return
  5163. }
  5164. //if res3507for10188.Infcode
  5165. res.InfRefmsgid = res3507for10188.InfRefmsgid
  5166. //res.Output = resSix10265.Output
  5167. res.ErrMsg = res3507for10188.ErrMsg
  5168. res.Cainfo = res3507for10188.Cainfo
  5169. res.WarnMsg = res3507for10188.WarnMsg
  5170. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5171. res.Infcode = infocode
  5172. }
  5173. if res.Infcode == 0 {
  5174. item.IsSale = 1
  5175. item.Bchno = number
  5176. item.SaleDate = time.Now().Format("2006-01-02")
  5177. err5 := service.SaveDF(item)
  5178. if err5 == nil {
  5179. if item.IsChange == 1 { //没变更,进行变更操作
  5180. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5181. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5182. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5183. var respJSON3 map[string]interface{}
  5184. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5186. return
  5187. }
  5188. {
  5189. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5190. utils.ErrorLog("解析失败:%v", err)
  5191. return
  5192. }
  5193. //if res3507for10188.Infcode
  5194. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5195. //res.Output = resSix10265.Output
  5196. res3.ErrMsg = res3507for10188.ErrMsg
  5197. res3.Cainfo = res3507for10188.Cainfo
  5198. res3.WarnMsg = res3507for10188.WarnMsg
  5199. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5200. res3.Infcode = infocode
  5201. }
  5202. if res3.Infcode == 0 {
  5203. item.IsChange = 1
  5204. item.BgBchno = bg_number
  5205. service.SaveDF2(item)
  5206. } else {
  5207. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5208. }
  5209. }
  5210. }
  5211. } else {
  5212. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5213. }
  5214. }
  5215. }
  5216. }
  5217. }
  5218. }
  5219. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5220. var struct3502 models.Struct3502
  5221. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5222. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5223. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5224. struct3502.FixmedinsCode = miConfig.Code
  5225. struct3502.Code = miConfig.Code
  5226. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5227. struct3502.Opter = role.UserName
  5228. struct3502.RxFlag = "1"
  5229. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5230. struct3502.OrgName = miConfig.OrgName
  5231. struct3502.AccessKey = miConfig.AccessKey
  5232. struct3502.RequestUrl = miConfig.Url
  5233. struct3502.SecretKey = miConfig.SecretKey
  5234. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5235. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5236. struct3502.Url = miConfig.Url
  5237. struct3502.AppId = miConfig.Cainfo
  5238. struct3502.AppSecret = miConfig.AppSecret
  5239. struct3502.Enckey = miConfig.EncKey
  5240. struct3502.SignKey = miConfig.SignKey
  5241. struct3502.SecretKey = miConfig.SecretKey
  5242. struct3502.InvChgType = chgType
  5243. struct3502.FixmedinsBchno = number
  5244. struct3502.Cnt = strconv.FormatInt(count, 10)
  5245. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5246. //result1, result2, _ := service.FJyb3502(struct3502)
  5247. if miConfig.MdtrtareaAdmvs == "350500" {
  5248. result1, result2, _ := service.FJyb3502(struct3502)
  5249. //saveLog(result1, result2, "3502", "3502")
  5250. return result1, result2
  5251. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5252. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5253. return result1, result2
  5254. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5255. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5256. return result1, result2
  5257. } else {
  5258. data := make(map[string]interface{})
  5259. data["struct_3502s"] = struct3502
  5260. client := &http.Client{}
  5261. bytesData, _ := json.Marshal(data)
  5262. var req *http.Request
  5263. if miConfig.MdtrtareaAdmvs == "320921" {
  5264. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5265. } else {
  5266. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5267. }
  5268. resp, _ := client.Do(req)
  5269. defer resp.Body.Close()
  5270. body, ioErr := ioutil.ReadAll(resp.Body)
  5271. if ioErr != nil {
  5272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5273. }
  5274. var respJSON map[string]interface{}
  5275. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5277. }
  5278. //var resSix10265 ResultSix10265 //1101结果
  5279. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5280. result, _ := json.Marshal(respJSON)
  5281. return string(result), ""
  5282. }
  5283. }
  5284. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5285. var struct3505 models.Struct3505
  5286. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5287. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5288. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5289. struct3505.FixmedinsBchno = number
  5290. struct3505.Opter = role.UserName
  5291. struct3505.Bchno = "---"
  5292. struct3505.FixmedinsCode = miConfig.Code
  5293. struct3505.Code = miConfig.Code
  5294. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.HisDoctorAdviceInfo.Price, 'f', -1, 64)
  5295. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5296. struct3505.PrscDrName = roles.UserName
  5297. if org_id == 10191 {
  5298. struct3505.PharName = "刘水山"
  5299. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5300. }
  5301. if org_id == 10188 {
  5302. struct3505.PharName = "李汉清"
  5303. struct3505.PharPracCertNo = "30220200932022010034"
  5304. }
  5305. if org_id == 10217 {
  5306. struct3505.PharName = "张敏"
  5307. struct3505.PharPracCertNo = "30220230432090100108"
  5308. }
  5309. if org_id == 10318 {
  5310. struct3505.PharName = "邹刘阳"
  5311. struct3505.PharPracCertNo = "210441200001378"
  5312. }
  5313. if org_id == 10402 {
  5314. struct3505.PharName = "刘韶健"
  5315. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5316. }
  5317. if org_id == 9919 {
  5318. struct3505.PharName = "周君权"
  5319. struct3505.PharPracCertNo = "089644396094401375"
  5320. }
  5321. if org_id == 10644 {
  5322. struct3505.PharName = "陈金娣"
  5323. struct3505.PharPracCertNo = "20181441500320100066"
  5324. }
  5325. if org_id == 10567 {
  5326. struct3505.PharName = "范小兰"
  5327. struct3505.PharPracCertNo = "0200102079485"
  5328. }
  5329. if org_id == 10721 {
  5330. struct3505.PharName = "孙莉侠"
  5331. struct3505.PharPracCertNo = "060399"
  5332. }
  5333. if org_id == 10726 {
  5334. struct3505.PharName = "彭建福"
  5335. struct3505.PharPracCertNo = "D445281006261"
  5336. }
  5337. if org_id == 10697 {
  5338. struct3505.PharName = "陶海兰"
  5339. struct3505.PharPracCertNo = "0010933"
  5340. }
  5341. if org_id == 10265 {
  5342. struct3505.PharName = "李彩星"
  5343. struct3505.PharPracCertNo = "20171110600110100019"
  5344. }
  5345. if org_id == 10028 {
  5346. struct3505.PharName = "曾细平"
  5347. struct3505.PharPracCertNo = "D440307022134"
  5348. }
  5349. if org_id == 10138 {
  5350. struct3505.PharName = "彭斯遥"
  5351. struct3505.PharPracCertNo = "30220200943042010052"
  5352. }
  5353. if org_id == 10278 {
  5354. struct3505.PharName = "彭斯遥"
  5355. struct3505.PharPracCertNo = "30220200943042010052"
  5356. }
  5357. if org_id == 10610 {
  5358. struct3505.PharName = "彭斯遥"
  5359. struct3505.PharPracCertNo = "30220200943042010052"
  5360. }
  5361. if org_id == 10537 {
  5362. struct3505.PharName = "彭斯遥"
  5363. struct3505.PharPracCertNo = "30220200943042010052"
  5364. }
  5365. if org_id == 9504 {
  5366. struct3505.PharName = "资美红"
  5367. struct3505.PharPracCertNo = "D440904006635"
  5368. }
  5369. if org_id == 10480 {
  5370. struct3505.PharName = "陈思"
  5371. struct3505.PharPracCertNo = "30220240434110010470"
  5372. }
  5373. if org_id == 10653 {
  5374. struct3505.PharName = "邓树英"
  5375. struct3505.PharPracCertNo = "201910026440004734"
  5376. }
  5377. if org_id == 10571 {
  5378. struct3505.PharName = "廖志平"
  5379. struct3505.PharPracCertNo = "0136425"
  5380. }
  5381. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5382. struct3505.SetlId = order.SetlId
  5383. struct3505.MdtrtSn = order.MdtrtId
  5384. struct3505.ManuLotnum = drug.BatchNumber
  5385. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5386. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5387. struct3505.RxFlag = "1"
  5388. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5389. struct3505.TrdnFlag = "0"
  5390. } else {
  5391. struct3505.TrdnFlag = "1"
  5392. }
  5393. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5394. struct3505.TrdnFlag = "1"
  5395. }
  5396. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5397. struct3505.TrdnFlag = "0"
  5398. }
  5399. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 {
  5400. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 1 {
  5401. struct3505.TrdnFlag = "1"
  5402. }
  5403. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 2 {
  5404. struct3505.TrdnFlag = "0"
  5405. }
  5406. }
  5407. struct3505.RtalDocno = order.Number
  5408. struct3505.PsnCertType = "01"
  5409. struct3505.CertNo = order.Certno
  5410. struct3505.PsnNo = order.PsnNo
  5411. struct3505.PsnName = order.PsnName
  5412. struct3505.Url = miConfig.Url
  5413. struct3505.AppId = miConfig.Cainfo
  5414. struct3505.AppSecret = miConfig.AppSecret
  5415. struct3505.Enckey = miConfig.EncKey
  5416. struct3505.SignKey = miConfig.SignKey
  5417. struct3505.SecretKey = miConfig.SecretKey
  5418. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5419. struct3505.SelRetnCnt = strValue
  5420. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5421. struct3505.SelRetnOpterName = role.UserName
  5422. if order.IsMedicineInsurance == 1 {
  5423. struct3505.MdtrtSetlType = "1"
  5424. } else {
  5425. struct3505.MdtrtSetlType = "2"
  5426. }
  5427. struct3505.OrgName = miConfig.OrgName
  5428. struct3505.AccessKey = miConfig.AccessKey
  5429. struct3505.RequestUrl = miConfig.Url
  5430. struct3505.SecretKey = miConfig.SecretKey
  5431. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5432. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5433. struct3505.Cainfo = miConfig.Cainfo
  5434. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5435. if miConfig.MdtrtareaAdmvs == "350500" {
  5436. result1, result2, _ := service.FJyb3505(struct3505)
  5437. return result1, result2
  5438. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5439. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5440. return result1, result2
  5441. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5442. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5443. return result1, result2
  5444. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5445. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5446. return result1, result2
  5447. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5448. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5449. return result1, result2
  5450. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5451. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5452. return result1, result2
  5453. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5454. data := make(map[string]interface{})
  5455. data["struct_3505s"] = struct3505
  5456. client := &http.Client{}
  5457. bytesData, _ := json.Marshal(data)
  5458. var req *http.Request
  5459. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5460. resp, _ := client.Do(req)
  5461. defer resp.Body.Close()
  5462. body, ioErr := ioutil.ReadAll(resp.Body)
  5463. if ioErr != nil {
  5464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5465. }
  5466. var respJSON map[string]interface{}
  5467. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5469. }
  5470. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5471. result, _ := json.Marshal(respJSON)
  5472. return string(result), ""
  5473. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5474. data := make(map[string]interface{})
  5475. data["struct_3505s"] = struct3505
  5476. client := &http.Client{}
  5477. bytesData, _ := json.Marshal(data)
  5478. var req *http.Request
  5479. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5480. resp, _ := client.Do(req)
  5481. defer resp.Body.Close()
  5482. body, ioErr := ioutil.ReadAll(resp.Body)
  5483. if ioErr != nil {
  5484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5485. }
  5486. var respJSON map[string]interface{}
  5487. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5489. }
  5490. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5491. if status == "0" {
  5492. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5493. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5494. }
  5495. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5496. result, _ := json.Marshal(respJSON)
  5497. return string(result), ""
  5498. } else {
  5499. data := make(map[string]interface{})
  5500. data["struct_3505s"] = struct3505
  5501. client := &http.Client{}
  5502. bytesData, _ := json.Marshal(data)
  5503. var req *http.Request
  5504. if miConfig.MdtrtareaAdmvs == "320921" {
  5505. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5506. } else {
  5507. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5508. }
  5509. resp, _ := client.Do(req)
  5510. defer resp.Body.Close()
  5511. body, ioErr := ioutil.ReadAll(resp.Body)
  5512. if ioErr != nil {
  5513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5514. }
  5515. var respJSON map[string]interface{}
  5516. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5518. }
  5519. //var resSix10265 ResultSix10265 //1101结果
  5520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5521. result, _ := json.Marshal(respJSON)
  5522. return string(result), ""
  5523. }
  5524. }
  5525. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5526. var struct3505 models.Struct3505
  5527. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5528. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5529. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5530. struct3505.FixmedinsBchno = number
  5531. struct3505.Opter = role.UserName
  5532. struct3505.FixmedinsCode = miConfig.Code
  5533. struct3505.Code = miConfig.Code
  5534. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5535. struct3505.PrscDrName = roles.UserName
  5536. if org_id == 10191 {
  5537. struct3505.PharName = "刘水山"
  5538. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5539. }
  5540. if org_id == 10188 {
  5541. struct3505.PharName = "李汉清"
  5542. struct3505.PharPracCertNo = "30220200932022010034"
  5543. }
  5544. if org_id == 10217 {
  5545. struct3505.PharName = "张敏"
  5546. struct3505.PharPracCertNo = "30220230432090100108"
  5547. }
  5548. if org_id == 10318 {
  5549. struct3505.PharName = "邹刘阳"
  5550. struct3505.PharPracCertNo = "210441200001378"
  5551. }
  5552. if org_id == 10402 {
  5553. struct3505.PharName = "刘韶健"
  5554. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5555. }
  5556. if org_id == 9919 {
  5557. struct3505.PharName = "周君权"
  5558. struct3505.PharPracCertNo = "089644396094401375"
  5559. }
  5560. if org_id == 10644 {
  5561. struct3505.PharName = "陈金娣"
  5562. struct3505.PharPracCertNo = "20181441500320100066"
  5563. }
  5564. if org_id == 10567 {
  5565. struct3505.PharName = "范小兰"
  5566. struct3505.PharPracCertNo = "0200102079485"
  5567. }
  5568. if org_id == 10721 {
  5569. struct3505.PharName = "孙莉侠"
  5570. struct3505.PharPracCertNo = "060399"
  5571. }
  5572. if org_id == 10726 {
  5573. struct3505.PharName = "彭建福"
  5574. struct3505.PharPracCertNo = "D445281006261"
  5575. }
  5576. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5577. struct3505.SetlId = order.SetlId
  5578. struct3505.MdtrtSn = order.MdtrtId
  5579. struct3505.ManuLotnum = drug.Number
  5580. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5581. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5582. struct3505.RxFlag = "1"
  5583. struct3505.TrdnFlag = "0"
  5584. struct3505.RtalDocno = order.Number
  5585. struct3505.PsnCertType = "01"
  5586. struct3505.CertNo = order.Certno
  5587. struct3505.PsnNo = order.PsnNo
  5588. struct3505.PsnName = order.PsnName
  5589. struct3505.Url = miConfig.Url
  5590. struct3505.AppId = miConfig.Cainfo
  5591. struct3505.AppSecret = miConfig.AppSecret
  5592. struct3505.Enckey = miConfig.EncKey
  5593. struct3505.SignKey = miConfig.SignKey
  5594. struct3505.SecretKey = miConfig.SecretKey
  5595. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5596. struct3505.SelRetnCnt = strValue
  5597. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5598. struct3505.SelRetnOpterName = role.UserName
  5599. if order.IsMedicineInsurance == 1 {
  5600. struct3505.MdtrtSetlType = "1"
  5601. } else {
  5602. struct3505.MdtrtSetlType = "2"
  5603. }
  5604. struct3505.OrgName = miConfig.OrgName
  5605. struct3505.AccessKey = miConfig.AccessKey
  5606. struct3505.RequestUrl = miConfig.Url
  5607. struct3505.SecretKey = miConfig.SecretKey
  5608. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5609. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5610. struct3505.Cainfo = miConfig.Cainfo
  5611. struct3505.DrugTracCodg = drug.DrugCode
  5612. if miConfig.MdtrtareaAdmvs == "350500" {
  5613. result1, result2, _ := service.FJyb3505(struct3505)
  5614. return result1, result2
  5615. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5616. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5617. return result1, result2
  5618. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5619. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5620. return result1, result2
  5621. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5622. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5623. return result1, result2
  5624. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5625. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5626. return result1, result2
  5627. } else {
  5628. data := make(map[string]interface{})
  5629. data["struct_3505s"] = struct3505
  5630. client := &http.Client{}
  5631. bytesData, _ := json.Marshal(data)
  5632. var req *http.Request
  5633. if miConfig.MdtrtareaAdmvs == "320921" {
  5634. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5635. } else {
  5636. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5637. }
  5638. resp, _ := client.Do(req)
  5639. defer resp.Body.Close()
  5640. body, ioErr := ioutil.ReadAll(resp.Body)
  5641. if ioErr != nil {
  5642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5643. }
  5644. var respJSON map[string]interface{}
  5645. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5647. }
  5648. //var resSix10265 ResultSix10265 //1101结果
  5649. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5650. result, _ := json.Marshal(respJSON)
  5651. return string(result), ""
  5652. }
  5653. }
  5654. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5655. var struct3506 models.Struct3506
  5656. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5657. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5658. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5659. struct3506.FixmedinsCode = miConfig.Code
  5660. struct3506.Code = miConfig.Code
  5661. struct3506.FixmedinsBchno = number
  5662. struct3506.Opter = role.UserName
  5663. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5664. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5665. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5666. struct3506.MdtrtSn = order.MdtrtId
  5667. struct3506.ExpyEnd = ""
  5668. struct3506.RxFlag = "0"
  5669. struct3506.TrdnFlag = "1"
  5670. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5671. struct3506.SelRetnCnt = strValue
  5672. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5673. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5674. struct3506.SelRetnOpterName = role.UserName
  5675. struct3506.OrgName = miConfig.OrgName
  5676. struct3506.AccessKey = miConfig.AccessKey
  5677. struct3506.RequestUrl = miConfig.Url
  5678. struct3506.SecretKey = miConfig.SecretKey
  5679. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5680. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5681. struct3506.Url = miConfig.Url
  5682. struct3506.AppId = miConfig.Cainfo
  5683. struct3506.AppSecret = miConfig.AppSecret
  5684. struct3506.Enckey = miConfig.EncKey
  5685. struct3506.SignKey = miConfig.SignKey
  5686. struct3506.SecretKey = miConfig.SecretKey
  5687. struct3506.DrugTracCodg = drug.DrugCode
  5688. if miConfig.MdtrtareaAdmvs == "350500" {
  5689. result1, result2, _ := service.FJyb3506(struct3506)
  5690. return result1, result2
  5691. } else {
  5692. data := make(map[string]interface{})
  5693. data["struct_3506s"] = struct3506
  5694. client := &http.Client{}
  5695. bytesData, _ := json.Marshal(data)
  5696. var req *http.Request
  5697. if miConfig.MdtrtareaAdmvs == "320921" {
  5698. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5699. } else {
  5700. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5701. }
  5702. resp, _ := client.Do(req)
  5703. defer resp.Body.Close()
  5704. body, ioErr := ioutil.ReadAll(resp.Body)
  5705. if ioErr != nil {
  5706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5707. }
  5708. var respJSON map[string]interface{}
  5709. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5711. }
  5712. //var resSix10265 ResultSix10265 //1101结果
  5713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5714. result, _ := json.Marshal(respJSON)
  5715. return string(result), ""
  5716. }
  5717. }
  5718. func (c *HisApiController) Get1318() {
  5719. adminUser := c.GetAdminUserInfo()
  5720. admin_user_id, _ := c.GetInt64("admin_user_id")
  5721. code := c.GetString("code")
  5722. code = ""
  5723. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5724. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5725. api := ""
  5726. if miConfig.MdtrtareaAdmvs == "320921" {
  5727. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5728. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5729. } else {
  5730. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5731. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5732. }
  5733. resp, requestErr := http.Get(api)
  5734. if requestErr != nil {
  5735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5736. return
  5737. }
  5738. body, ioErr := ioutil.ReadAll(resp.Body)
  5739. if ioErr != nil {
  5740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5742. return
  5743. }
  5744. var respJSON map[string]interface{}
  5745. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5748. return
  5749. }
  5750. //var res Result2406
  5751. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5752. result, _ := json.Marshal(respJSON)
  5753. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5754. utils.ErrorLog("解析失败:%v", err)
  5755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5756. return
  5757. }
  5758. if res.Infcode == "0" {
  5759. c.ServeSuccessJSON(map[string]interface{}{
  5760. "result": "",
  5761. })
  5762. } else {
  5763. c.ServeSuccessJSON(map[string]interface{}{
  5764. "failed_code": -10,
  5765. "msg": res.ErrMsg,
  5766. })
  5767. */return
  5768. //}
  5769. }
  5770. func (c *HisApiController) Get2503() {
  5771. adminUser := c.GetAdminUserInfo()
  5772. admin_user_id, _ := c.GetInt64("admin_user_id")
  5773. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5774. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5775. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5776. }
  5777. func (c *HisApiController) Get2406() {
  5778. id, _ := c.GetInt64("id")
  5779. record_time := c.GetString("record_time")
  5780. his_patient_id, _ := c.GetInt64("his_patient_id")
  5781. admin_user_id, _ := c.GetInt64("admin_user_id")
  5782. diagnosis_id := c.GetString("diagnosis")
  5783. timeLayout := "2006-01-02"
  5784. loc, _ := time.LoadLocation("Local")
  5785. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5786. if err != nil {
  5787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5788. return
  5789. }
  5790. recordDateTime := theTime.Unix()
  5791. adminUser := c.GetAdminUserInfo()
  5792. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5793. var config []*models.HisXtDiagnoseConfig
  5794. for _, item := range diagnosis_ids {
  5795. id, _ := strconv.ParseInt(item, 10, 64)
  5796. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5797. config = append(config, &diagnosisConfig)
  5798. }
  5799. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5800. fmt.Println(his_patient_id)
  5801. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5802. //timestamp := time.Now().Unix()
  5803. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5804. var patientPrescription models.HisPrescriptionInfo
  5805. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5806. if patientPrescription.ID == 0 {
  5807. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5808. }
  5809. var res2 Result2406
  5810. if miConfig.MdtrtareaAdmvs == "341203" {
  5811. data := make(map[string]interface{})
  5812. client := &http.Client{}
  5813. data["psn_no"] = his.PsnNo
  5814. data["mdtrt_id"] = his.Number
  5815. data["operator"] = roles.UserName
  5816. data["cert_no"] = his.IdCardNo
  5817. data["org_name"] = miConfig.OrgName
  5818. data["psn_name"] = his.Name
  5819. data["ipt_otp_no"] = his.IptOtpNo
  5820. data["ipt_psn_sp_flag_type"] = "0901"
  5821. data["ipt_psn_sp_flag"] = "1"
  5822. data["fixmedins_code"] = miConfig.Code
  5823. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5824. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5825. data["url"] = miConfig.Url
  5826. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5827. bytesData, _ := json.Marshal(data)
  5828. var req *http.Request
  5829. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5830. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5831. resp, _ := client.Do(req)
  5832. defer resp.Body.Close()
  5833. body, ioErr := ioutil.ReadAll(resp.Body)
  5834. if ioErr != nil {
  5835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5837. return
  5838. }
  5839. var respJSON map[string]interface{}
  5840. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5843. return
  5844. }
  5845. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5846. if status == "0" {
  5847. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5848. c.ServeSuccessJSON(map[string]interface{}{
  5849. "failed_code": -10,
  5850. "msg": err_msg,
  5851. })
  5852. return
  5853. }
  5854. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5855. userJSONBytes, _ := json.Marshal(respJSON)
  5856. fmt.Println("log")
  5857. fmt.Println(string(userJSONBytes))
  5858. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5859. utils.ErrorLog("解析失败:%v", err)
  5860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5861. return
  5862. }
  5863. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5864. data := make(map[string]interface{})
  5865. client := &http.Client{}
  5866. data["psn_no"] = his.PsnNo
  5867. data["mdtrt_id"] = his.Number
  5868. data["operator"] = roles.UserName
  5869. data["cert_no"] = his.IdCardNo
  5870. data["org_name"] = miConfig.OrgName
  5871. data["psn_name"] = his.Name
  5872. data["ipt_otp_no"] = his.IptOtpNo
  5873. data["ipt_psn_sp_flag_type"] = "0901"
  5874. data["ipt_psn_sp_flag"] = "1"
  5875. data["fixmedins_code"] = miConfig.Code
  5876. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5877. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5878. data["url"] = miConfig.Url
  5879. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5880. bytesData, _ := json.Marshal(data)
  5881. var req *http.Request
  5882. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5883. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5884. resp, _ := client.Do(req)
  5885. defer resp.Body.Close()
  5886. body, ioErr := ioutil.ReadAll(resp.Body)
  5887. if ioErr != nil {
  5888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5890. return
  5891. }
  5892. var respJSON map[string]interface{}
  5893. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5896. return
  5897. }
  5898. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5899. if status == "0" {
  5900. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5901. c.ServeSuccessJSON(map[string]interface{}{
  5902. "failed_code": -10,
  5903. "msg": err_msg,
  5904. })
  5905. return
  5906. }
  5907. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5908. userJSONBytes, _ := json.Marshal(respJSON)
  5909. fmt.Println("log")
  5910. fmt.Println(string(userJSONBytes))
  5911. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5912. utils.ErrorLog("解析失败:%v", err)
  5913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5914. return
  5915. }
  5916. }
  5917. if res2.Infcode != 0 {
  5918. adminUser := c.GetAdminUserInfo()
  5919. errlog := &models.HisOrderError{
  5920. UserOrgId: adminUser.CurrentOrgId,
  5921. Ctime: time.Now().Unix(),
  5922. Mtime: time.Now().Unix(),
  5923. ErrMsg: res2.ErrMsg,
  5924. Status: 1,
  5925. PatientId: id,
  5926. RecordTime: recordDateTime,
  5927. Stage: 3,
  5928. }
  5929. service.CreateErrMsgLog(errlog)
  5930. c.ServeSuccessJSON(map[string]interface{}{
  5931. "failed_code": -10,
  5932. "msg": res2.ErrMsg,
  5933. })
  5934. return
  5935. } else {
  5936. c.ServeSuccessJSON(map[string]interface{}{
  5937. "msg": "上传成功",
  5938. })
  5939. return
  5940. }
  5941. }
  5942. func (c *HisApiController) Get4105() {
  5943. }
  5944. func (c *HisApiController) Post5302() {
  5945. patient_id, _ := c.GetInt64("id")
  5946. admin_user_id, _ := c.GetInt64("admin_user_id")
  5947. p, _ := service.GetHisPatientById(patient_id)
  5948. adminUser := c.GetAdminUserInfo()
  5949. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5950. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5951. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5952. }
  5953. func (c *HisApiController) Get4104() {
  5954. }
  5955. type Output struct {
  5956. CertNo string `json:"certno"`
  5957. PsnName string `json:"psn_name"`
  5958. CardNo string `json:"card_no"`
  5959. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5960. CardSN string `json:"card_sn"`
  5961. PsnCertType string `json:"psn_cert_type"`
  5962. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5963. MdtrtCertType string `json:"mdtrt_cert_type"`
  5964. QRCode string `json:"qrCode"`
  5965. EcToken string `json:"ecToken"`
  5966. }
  5967. type AHResponse struct {
  5968. Body AHBody `json:"body"`
  5969. Code int `json:"code"`
  5970. CSBCode int `json:"csbCode"`
  5971. Message string `json:"message"`
  5972. RequestID string `json:"requestId"`
  5973. State struct{} `json:"state"`
  5974. }
  5975. type AHBody struct {
  5976. ErrMsg string `json:"err_msg"`
  5977. InfRefMsgID string `json:"inf_refmsgid"`
  5978. InfCode int `json:"infcode"`
  5979. Output struct {
  5980. Result []struct {
  5981. BasMednFlag string `json:"bas_medn_flag"`
  5982. ChldMedcFlag string `json:"chld_medc_flag"`
  5983. ChrgitmLv string `json:"chrgitm_lv"`
  5984. Cnt float64 `json:"cnt"`
  5985. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5986. DrtReimFlag string `json:"drt_reim_flag"`
  5987. FeedetlSn string `json:"feedetl_sn"`
  5988. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5989. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5990. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5991. ListSpItemFlag string `json:"list_sp_item_flag"`
  5992. LmtUsedFlag string `json:"lmt_used_flag"`
  5993. MedChrgitmType string `json:"med_chrgitm_type"`
  5994. Memo string `json:"memo"`
  5995. OverlmtAmt float64 `json:"overlmt_amt"`
  5996. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5997. Pric float64 `json:"pric"`
  5998. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5999. SelfpayProp float64 `json:"selfpay_prop"`
  6000. } `json:"result"`
  6001. } `json:"output"`
  6002. }
  6003. type Response struct {
  6004. Output Output `json:"output"`
  6005. Infcode int `json:"infcode"`
  6006. InfRefMsgID string `json:"inf_refmsgid"`
  6007. RefMsgTime string `json:"refmsg_time"`
  6008. RespondTime string `json:"respond_time"`
  6009. ErrMsg string `json:"err_msg"`
  6010. WarnMsg string `json:"warn_msg"`
  6011. SignType string `json:"signtype"`
  6012. CAInfo string `json:"cainfo"`
  6013. }
  6014. func (c *HisApiController) Getquerydata() {
  6015. query_type, _ := c.GetInt64("type")
  6016. refd_setl_flag := c.GetString("refd_setl_flag")
  6017. med_type := c.GetString("med_type")
  6018. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6019. cert_no := c.GetString("cert_no")
  6020. psn_no := c.GetString("psn_no")
  6021. start_time := c.GetString("start_time")
  6022. end_time := c.GetString("end_time")
  6023. page, _ := c.GetInt64("page")
  6024. limit, _ := c.GetInt64("limit")
  6025. var bp models.BusinessParams5262
  6026. bp.RefdSetlFlag = refd_setl_flag
  6027. bp.MedType = med_type
  6028. bp.Certno = cert_no
  6029. bp.Psnno = psn_no
  6030. bp.QBegntime = start_time
  6031. bp.QEndtime = end_time
  6032. if query_type == 1 { //本地
  6033. Post5262(c, bp, page, limit)
  6034. } else { //异地
  6035. Post5267(c, bp, page, limit)
  6036. }
  6037. }
  6038. func (c *HisApiController) Drugscheck() {
  6039. admin_user_id, _ := c.GetInt64("admin_user_id")
  6040. adminUser := c.GetAdminUserInfo()
  6041. var queryResult []QueryResult
  6042. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6043. for _, item := range drugs {
  6044. result := QueryResult{
  6045. ID: item.ID,
  6046. Name: item.DrugName,
  6047. Code: item.MedicalInsuranceNumber,
  6048. List_type_code: "101",
  6049. }
  6050. queryResult = append(queryResult, result)
  6051. }
  6052. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6053. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6054. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6055. for _, item := range queryResult {
  6056. 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)
  6057. }
  6058. }
  6059. func (c *HisApiController) Goodcheck() {
  6060. admin_user_id, _ := c.GetInt64("admin_user_id")
  6061. adminUser := c.GetAdminUserInfo()
  6062. var queryResult []QueryResult
  6063. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6064. for _, item := range goods {
  6065. result := QueryResult{
  6066. ID: item.ID,
  6067. Name: item.GoodName,
  6068. Code: item.SocialSecurityDirectoryCode,
  6069. List_type_code: "301",
  6070. }
  6071. queryResult = append(queryResult, result)
  6072. }
  6073. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6074. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6075. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6076. for _, item := range queryResult {
  6077. 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)
  6078. //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)
  6079. }
  6080. }
  6081. func (c *HisApiController) Projectcheck() {
  6082. admin_user_id, _ := c.GetInt64("admin_user_id")
  6083. adminUser := c.GetAdminUserInfo()
  6084. var queryResult []QueryResult
  6085. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6086. for _, item := range projects {
  6087. result := QueryResult{
  6088. ID: item.ID,
  6089. Name: item.ProjectName,
  6090. Code: item.MedicalCode,
  6091. List_type_code: "201",
  6092. }
  6093. queryResult = append(queryResult, result)
  6094. }
  6095. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6096. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6097. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6098. for _, item := range queryResult {
  6099. 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)
  6100. }
  6101. }
  6102. //func (c *HisApiController)CancleDia(){
  6103. //
  6104. // id, _ := c.GetInt64("id")
  6105. // record_time := c.GetString("record_time")
  6106. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6107. //
  6108. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6109. //
  6110. // diagnosis_id := c.GetString("diagnosis")
  6111. // sick_type, _ := c.GetInt64("sick_type")
  6112. // reg_type, _ := c.GetInt64("p_type")
  6113. // begin_time := c.GetString("begin_time")
  6114. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6115. //
  6116. //
  6117. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6118. //
  6119. // fmt.Println(acct_used_flag)
  6120. //
  6121. //
  6122. // timeLayout := "2006-01-02"
  6123. // loc, _ := time.LoadLocation("Local")
  6124. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6125. // if err != nil {
  6126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6127. // return
  6128. // }
  6129. // recordDateTime := theTime.Unix()
  6130. // adminUser := c.GetAdminUserInfo()
  6131. //
  6132. //
  6133. //
  6134. //
  6135. //
  6136. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6137. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6138. // var patientPrescription models.HisPrescriptionInfo
  6139. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6140. // if patientPrescription.ID == 0 {
  6141. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6142. // }
  6143. // //if patientPrescription.Do
  6144. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6145. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6146. //
  6147. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6148. //
  6149. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6150. //
  6151. // var config []*models.HisXtDiagnoseConfig
  6152. // for _, item := range diagnosis_ids {
  6153. // id, _ := strconv.ParseInt(item, 10, 64)
  6154. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6155. // config = append(config, &diagnosisConfig)
  6156. // }
  6157. //
  6158. // sickConfig, _ := service.FindSickById(sick_type)
  6159. //
  6160. //
  6161. // data := make(map[string]interface{})
  6162. // client := &http.Client{}
  6163. // data["psn_no"] = his.PsnNo
  6164. // data["mdtrt_id"] = his.Number
  6165. // data["doctor"] = roles.UserName
  6166. // data["department"] = department.Name
  6167. // data["org_name"] = miConfig.OrgName
  6168. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6169. // data["doctor_id"] = doctor_info.DoctorNumber
  6170. // data["new_doctor_name"] = doctor_info.UserName
  6171. // data["fixmedins_code"] = miConfig.Code
  6172. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6173. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6174. // data["secret_key"] = miConfig.SecretKey
  6175. // data["sick_code"] = sickConfig.CountryCode
  6176. // data["sick_name"] = sickConfig.ClassName
  6177. // data["url"] = miConfig.Url
  6178. // data["ak"] = miConfig.AccessKey
  6179. // data["begin_time"] = begin_time
  6180. // data["cainfo"] = miConfig.Cainfo
  6181. // data["is_vaild"] = "0"
  6182. //
  6183. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6184. // data["config"] = config
  6185. // bytesData, _ := json.Marshal(data)
  6186. //
  6187. // var req *http.Request
  6188. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6189. // resp, _ := client.Do(req)
  6190. // defer resp.Body.Close()
  6191. // body, ioErr := ioutil.ReadAll(resp.Body)
  6192. // if ioErr != nil {
  6193. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6195. // return
  6196. // }
  6197. // var respJSON map[string]interface{}
  6198. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6199. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6201. // return
  6202. // }
  6203. //
  6204. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6205. // userJSONBytes, _ := json.Marshal(respJSON)
  6206. // fmt.Println("log")
  6207. // fmt.Println(string(userJSONBytes))
  6208. //
  6209. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6210. // utils.ErrorLog("解析失败:%v", err)
  6211. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6212. // return
  6213. // }
  6214. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6215. // res2.Output = ressix10265.Output
  6216. // res2.ErrMsg = ressix10265.ErrMsg
  6217. // res2.Cainfo = ressix10265.Cainfo
  6218. // res2.WarnMsg = ressix10265.WarnMsg
  6219. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6220. // res2.Infcode = infocode
  6221. //
  6222. //}
  6223. func (c *HisApiController) Get4102() {
  6224. order_id, _ := c.GetInt64("order_id")
  6225. admin_user_id, _ := c.GetInt64("admin_user_id")
  6226. stas_type := c.GetString("stas_type")
  6227. order, _ := service.GetHisOrderByIDTwo(order_id)
  6228. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6229. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6230. var pp models.PublicParams
  6231. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6232. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6233. pp.FixmedinsName = miConfig.OrgName
  6234. pp.FixmedinsCode = miConfig.Code
  6235. pp.RequestUrl = miConfig.Url
  6236. pp.Cainfo = miConfig.Cainfo
  6237. pp.SecretKey = miConfig.SecretKey
  6238. pp.AccessKey = miConfig.AccessKey
  6239. pp.OpterName = curRoles.UserName
  6240. if miConfig.MdtrtareaAdmvs == "350500" {
  6241. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6242. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6243. saveLog(result, request, "4102", "清单确认")
  6244. var dat map[string]interface{}
  6245. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6246. fmt.Println(dat)
  6247. } else {
  6248. fmt.Println(err)
  6249. }
  6250. var empty ResultFourteen
  6251. userJSONBytes, _ := json.Marshal(dat)
  6252. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6253. utils.ErrorLog("解析失败:%v", err)
  6254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6255. return
  6256. }
  6257. if empty.Infcode == 0 {
  6258. c.ServeSuccessJSON(map[string]interface{}{
  6259. "msg": "确认成功",
  6260. })
  6261. return
  6262. }
  6263. } else {
  6264. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6265. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6266. result3, request3 := service.Jxyb4105(pp)
  6267. saveLog(result, request, "4102", "清单确认")
  6268. saveLog(result2, request2, "4103", "清单确认")
  6269. saveLog(result3, request3, "4105", "清单统计")
  6270. var dat map[string]interface{}
  6271. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6272. fmt.Println(dat)
  6273. } else {
  6274. fmt.Println(err)
  6275. }
  6276. var empty ResultFourteen
  6277. userJSONBytes, _ := json.Marshal(dat)
  6278. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6279. utils.ErrorLog("解析失败:%v", err)
  6280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6281. return
  6282. }
  6283. if empty.Infcode == 0 {
  6284. c.ServeSuccessJSON(map[string]interface{}{
  6285. "msg": "确认成功",
  6286. })
  6287. return
  6288. }
  6289. }
  6290. }
  6291. // 对账权限查询
  6292. func (c *HisApiController) Get3260() {
  6293. admin_user_id, _ := c.GetInt64("admin_user_id")
  6294. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6295. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6296. var api string
  6297. var res models.JSResult3260
  6298. if miConfig.MdtrtareaAdmvs == "320921" {
  6299. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6300. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6301. } else {
  6302. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6303. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6304. }
  6305. resp, requestErr := http.Get(api)
  6306. if requestErr != nil {
  6307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6308. return
  6309. }
  6310. body, ioErr := ioutil.ReadAll(resp.Body)
  6311. if ioErr != nil {
  6312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6314. return
  6315. }
  6316. var respJSON map[string]interface{}
  6317. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6320. return
  6321. }
  6322. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6323. result, _ := json.Marshal(respJSON)
  6324. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6325. utils.ErrorLog("解析失败:%v", err)
  6326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6327. return
  6328. }
  6329. if res.Infcode == "0" {
  6330. c.ServeSuccessJSON(map[string]interface{}{
  6331. "result": res.Output.Data,
  6332. })
  6333. } else {
  6334. c.ServeSuccessJSON(map[string]interface{}{
  6335. "failed_code": -10,
  6336. "msg": res.ErrMsg,
  6337. })
  6338. return
  6339. }
  6340. }
  6341. func (c *HisApiController) Get3261() {
  6342. admin_user_id, _ := c.GetInt64("admin_user_id")
  6343. //month := c.GetString("month")
  6344. startTime := c.GetString("start_time")
  6345. //endTime, _ := c.GetString("end_time")
  6346. times := strings.Split(startTime, "-")
  6347. stmt_mon := times[0] + times[1]
  6348. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6349. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6350. var api string
  6351. var res models.JSResult3261
  6352. //var res10265 Result5301For10265
  6353. if miConfig.MdtrtareaAdmvs == "320921" {
  6354. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6355. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6356. } else {
  6357. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6358. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6359. }
  6360. resp, requestErr := http.Get(api)
  6361. if requestErr != nil {
  6362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6363. return
  6364. }
  6365. body, ioErr := ioutil.ReadAll(resp.Body)
  6366. if ioErr != nil {
  6367. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6369. return
  6370. }
  6371. var respJSON map[string]interface{}
  6372. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6375. return
  6376. }
  6377. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6378. result, _ := json.Marshal(respJSON)
  6379. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6380. utils.ErrorLog("解析失败:%v", err)
  6381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6382. return
  6383. }
  6384. if res.Infcode == "0" {
  6385. c.ServeSuccessJSON(map[string]interface{}{
  6386. "result": res.Output,
  6387. })
  6388. } else {
  6389. c.ServeSuccessJSON(map[string]interface{}{
  6390. "failed_code": -10,
  6391. "msg": res.ErrMsg,
  6392. })
  6393. return
  6394. }
  6395. }
  6396. type TempFun struct {
  6397. FundKey string
  6398. FundCode string
  6399. }
  6400. func (c *HisApiController) Get3262() {
  6401. admin_user_id, _ := c.GetInt64("admin_user_id")
  6402. startTime := c.GetString("start_time")
  6403. endTime := c.GetString("end_time")
  6404. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6405. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6406. //timeLayout := "2006-01-02"
  6407. //loc, _ := time.LoadLocation("Local")
  6408. //var theStartTIme int64
  6409. //if len(startTime) > 0 {
  6410. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6411. // if err != nil {
  6412. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6413. // return
  6414. // }
  6415. // theStartTIme = theTime.Unix()
  6416. //}
  6417. //var theEndtTIme int64
  6418. //if len(endTime) > 0 {
  6419. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6420. // if err != nil {
  6421. // utils.ErrorLog(err.Error())
  6422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6423. // return
  6424. // }
  6425. // theEndtTIme = theTime.Unix()
  6426. //}
  6427. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6428. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6429. for _, team := range datas {
  6430. fmt.Println(team.PsnTime)
  6431. for _, team_two := range datas_two {
  6432. fmt.Println(team_two.PsnTime)
  6433. if team.FundKey == team_two.FundKey {
  6434. fmt.Println(team_two.PsnTime)
  6435. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6436. fmt.Println(team.PsnTime)
  6437. }
  6438. }
  6439. }
  6440. fmt.Println("1111")
  6441. fmt.Println(datas)
  6442. fmt.Println("1111")
  6443. var twos []models.FixMonRecDetailFileInTwo
  6444. for _, team := range datas {
  6445. var two models.FixMonRecDetailFileInTwo
  6446. two.MedType = team.MedType
  6447. two.Insutype = team.Insutype
  6448. two.PsnType = team.PsnType
  6449. two.MedType = team.MedType
  6450. two.FixBlngAdmdvs = "999999"
  6451. two.InsuAdmdvs = "555555"
  6452. two.PsnTime = team.PsnTime
  6453. two.PsnCnt = team.PsnCnt
  6454. two.FundKey = team.FundKey
  6455. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6456. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6457. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6458. two.MedfeeSumAmt = ms
  6459. two.InscpAmt = ia
  6460. two.FundPaySumAmt = fps
  6461. twos = append(twos, two)
  6462. }
  6463. //startTime := c.GetString("start_time")
  6464. //endTime, _ := c.GetString("end_time")
  6465. times := strings.Split(startTime, "-")
  6466. stmt_mon := times[0] + times[1]
  6467. var funs []models.FundDetail
  6468. for _, item := range datas {
  6469. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6470. funs = append(funs, fun...)
  6471. }
  6472. var funInfos []models.Fund
  6473. //for _, item := range funs {
  6474. // var rf []models.FundInfo
  6475. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6476. // for _, subitem := range rf {
  6477. // var fund models.Fund
  6478. // fund.FundCode = subitem.FundPayType
  6479. // fund.FundName = subitem.FundPayTypeName
  6480. // fund.FundAmt = subitem.FundPayAmt
  6481. // fund.FundKey = item.FundKey
  6482. // fund.InsuAdmdvs = "555555"
  6483. // fund.FixBlngAdmdvs = "999999"
  6484. // funInfos = append(funInfos, fund)
  6485. // }
  6486. //}
  6487. var tempFuns []TempFun
  6488. for _, funInfo := range funInfos {
  6489. var tempFun TempFun
  6490. tempFun.FundKey = funInfo.FundKey
  6491. tempFun.FundCode = funInfo.FundCode
  6492. tempFuns = append(tempFuns, tempFun)
  6493. }
  6494. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6495. fmt.Println(tempFuns)
  6496. var funInfosTwo []models.Fund
  6497. decimal.DivisionPrecision = 2
  6498. for _, item := range tempFuns {
  6499. var fund models.Fund
  6500. for _, subItem := range funInfos {
  6501. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6502. fund.FundKey = subItem.FundKey
  6503. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6504. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6505. fund.FundName = subItem.FundName
  6506. fund.FundCode = subItem.FundCode
  6507. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6508. }
  6509. }
  6510. funInfosTwo = append(funInfosTwo, fund)
  6511. }
  6512. fmt.Println("funInfosTwo")
  6513. fmt.Println(funInfosTwo)
  6514. var upld_btch string
  6515. var empty models.JSResultEmpty
  6516. data := make(map[string]interface{})
  6517. data["org_name"] = miConfig.OrgName
  6518. data["doctor"] = curRoles.UserName
  6519. data["doctor_name"] = curRoles.UserName
  6520. data["fixmedins_code"] = miConfig.Code
  6521. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6522. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6523. data["secret_key"] = miConfig.SecretKey
  6524. data["url"] = miConfig.Url
  6525. data["ak"] = miConfig.AccessKey
  6526. data["cainfo"] = miConfig.Cainfo
  6527. data["datas"] = twos
  6528. data["fund"] = funInfosTwo
  6529. fmt.Println(twos)
  6530. month := time.Unix(1557042972, 0).Format("1")
  6531. year := time.Now().Format("2006")
  6532. month = time.Now().Format("01")
  6533. day := time.Now().Format("02")
  6534. hour := time.Now().Format("15")
  6535. min := time.Now().Format("04")
  6536. sec := time.Now().Format("05")
  6537. fix_fill_date := year + month + day + hour + min + sec
  6538. data["fix_fill_dept"] = miConfig.OrgName
  6539. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6540. data["fix_fill_psn"] = curRoles.UserName
  6541. data["fix_fill_date"] = fix_fill_date
  6542. data["stmt_loc"] = "2"
  6543. data["setl_mon"] = stmt_mon
  6544. upld_btch = "0"
  6545. data["upld_btch"] = upld_btch
  6546. //fmt.Println(data)
  6547. client := &http.Client{}
  6548. bytesData, _ := json.Marshal(data)
  6549. var req *http.Request
  6550. if miConfig.MdtrtareaAdmvs == "320921" {
  6551. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6552. } else {
  6553. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6554. }
  6555. resp, _ := client.Do(req)
  6556. defer resp.Body.Close()
  6557. body, ioErr := ioutil.ReadAll(resp.Body)
  6558. if ioErr != nil {
  6559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6561. }
  6562. var respJSON map[string]interface{}
  6563. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6566. }
  6567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6568. //fmt.Println(respJSON)
  6569. result, _ := json.Marshal(respJSON)
  6570. //fmt.Println(result)
  6571. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6572. utils.ErrorLog("解析失败:%v", err)
  6573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6574. }
  6575. if empty.Infcode != "0" {
  6576. c.ServeSuccessJSON(map[string]interface{}{
  6577. "failed_code": -10,
  6578. "msg": empty.ErrMsg,
  6579. })
  6580. return
  6581. } else {
  6582. c.ServeSuccessJSON(map[string]interface{}{
  6583. "msg": "上传成功",
  6584. })
  6585. return
  6586. }
  6587. }
  6588. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6589. newArr = make([]TempFun, 0)
  6590. for i := 0; i < len(arr); i++ {
  6591. repeat := false
  6592. for j := i + 1; j < len(arr); j++ {
  6593. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6594. repeat = true
  6595. break
  6596. }
  6597. }
  6598. if !repeat {
  6599. newArr = append(newArr, arr[i])
  6600. }
  6601. }
  6602. return
  6603. }
  6604. func (c *HisApiController) Get3263() {
  6605. admin_user_id, _ := c.GetInt64("admin_user_id")
  6606. startTime := c.GetString("start_time")
  6607. //endTime, _ := c.GetString("end_time")
  6608. times := strings.Split(startTime, "-")
  6609. setl_mon := times[0] + times[1]
  6610. upld_btch := "0"
  6611. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6612. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6613. var result3263 models.JSResult3263
  6614. data := make(map[string]interface{})
  6615. data["org_name"] = miConfig.OrgName
  6616. data["doctor"] = curRoles.UserName
  6617. data["doctor_name"] = curRoles.UserName
  6618. data["fixmedins_code"] = miConfig.Code
  6619. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6620. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6621. data["secret_key"] = miConfig.SecretKey
  6622. data["url"] = miConfig.Url
  6623. data["ak"] = miConfig.AccessKey
  6624. data["cainfo"] = miConfig.Cainfo
  6625. data["setl_mon"] = setl_mon
  6626. data["stmt_loc"] = "2"
  6627. data["upld_btch"] = upld_btch
  6628. client := &http.Client{}
  6629. bytesData, _ := json.Marshal(data)
  6630. var req *http.Request
  6631. if miConfig.MdtrtareaAdmvs == "320921" {
  6632. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6633. } else {
  6634. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6635. }
  6636. resp, _ := client.Do(req)
  6637. defer resp.Body.Close()
  6638. body, ioErr := ioutil.ReadAll(resp.Body)
  6639. if ioErr != nil {
  6640. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6642. }
  6643. var respJSON map[string]interface{}
  6644. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6647. }
  6648. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6649. fmt.Println(respJSON)
  6650. result, _ := json.Marshal(respJSON)
  6651. fmt.Println(result)
  6652. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6653. utils.ErrorLog("解析失败:%v", err)
  6654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6655. }
  6656. if result3263.Infcode != "0" {
  6657. c.ServeSuccessJSON(map[string]interface{}{
  6658. "failed_code": -10,
  6659. "msg": result3263.ErrMsg,
  6660. })
  6661. return
  6662. } else {
  6663. c.ServeSuccessJSON(map[string]interface{}{
  6664. "list": result3263.Output,
  6665. })
  6666. return
  6667. }
  6668. }
  6669. func (c *HisApiController) Get3264() {
  6670. admin_user_id, _ := c.GetInt64("admin_user_id")
  6671. startTime := c.GetString("start_time")
  6672. //endTime, _ := c.GetString("end_time")
  6673. times := strings.Split(startTime, "-")
  6674. setl_mon := times[0] + times[1]
  6675. upld_btch := "0"
  6676. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6677. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6678. //solidify_id := []
  6679. var result3263 models.JSResult3263
  6680. data := make(map[string]interface{})
  6681. data["org_name"] = miConfig.OrgName
  6682. data["doctor"] = curRoles.UserName
  6683. data["doctor_name"] = curRoles.UserName
  6684. data["fixmedins_code"] = miConfig.Code
  6685. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6686. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6687. data["secret_key"] = miConfig.SecretKey
  6688. data["url"] = miConfig.Url
  6689. data["ak"] = miConfig.AccessKey
  6690. data["cainfo"] = miConfig.Cainfo
  6691. data["setl_mon"] = setl_mon
  6692. data["stmt_loc"] = "2"
  6693. data["upld_btch"] = upld_btch
  6694. client := &http.Client{}
  6695. bytesData, _ := json.Marshal(data)
  6696. var req3263 *http.Request
  6697. if miConfig.MdtrtareaAdmvs == "320921" {
  6698. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6699. } else {
  6700. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6701. }
  6702. resp, _ := client.Do(req3263)
  6703. defer resp.Body.Close()
  6704. body, ioErr := ioutil.ReadAll(resp.Body)
  6705. if ioErr != nil {
  6706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6708. }
  6709. var respJSON3263 map[string]interface{}
  6710. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6713. }
  6714. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6715. fmt.Println(respJSON3263)
  6716. result, _ := json.Marshal(respJSON3263)
  6717. fmt.Println(result)
  6718. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6719. utils.ErrorLog("解析失败:%v", err)
  6720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6721. }
  6722. var ids []string
  6723. for _, item := range result3263.Output {
  6724. ids = append(ids, item.SolidifyID)
  6725. }
  6726. var empty models.JSResultEmpty
  6727. data2 := make(map[string]interface{})
  6728. data2["org_name"] = miConfig.OrgName
  6729. data2["doctor"] = curRoles.UserName
  6730. data2["doctor_name"] = curRoles.UserName
  6731. data2["fixmedins_code"] = miConfig.Code
  6732. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6733. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6734. data2["secret_key"] = miConfig.SecretKey
  6735. data2["url"] = miConfig.Url
  6736. data2["ak"] = miConfig.AccessKey
  6737. data2["cainfo"] = miConfig.Cainfo
  6738. data2["setl_mon"] = setl_mon
  6739. data2["stmt_loc"] = "2"
  6740. data2["upld_btch"] = upld_btch
  6741. data2["solidify_id"] = ids
  6742. client2 := &http.Client{}
  6743. bytesData2, _ := json.Marshal(data2)
  6744. var req *http.Request
  6745. if miConfig.MdtrtareaAdmvs == "320921" {
  6746. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6747. } else {
  6748. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6749. }
  6750. resp2, _ := client2.Do(req)
  6751. defer resp.Body.Close()
  6752. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6753. if ioErr2 != nil {
  6754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6756. }
  6757. var respJSON map[string]interface{}
  6758. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6761. }
  6762. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6763. fmt.Println(respJSON)
  6764. result2, _ := json.Marshal(respJSON)
  6765. fmt.Println(result2)
  6766. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6767. utils.ErrorLog("解析失败:%v", err)
  6768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6769. }
  6770. if empty.Infcode != "0" {
  6771. c.ServeSuccessJSON(map[string]interface{}{
  6772. "failed_code": -10,
  6773. "msg": empty.ErrMsg,
  6774. })
  6775. return
  6776. } else {
  6777. c.ServeSuccessJSON(map[string]interface{}{
  6778. "msg": "",
  6779. })
  6780. return
  6781. }
  6782. }
  6783. func (c *HisApiController) Get3265() {
  6784. admin_user_id, _ := c.GetInt64("admin_user_id")
  6785. startTime := c.GetString("start_time")
  6786. //endTime, _ := c.GetString("end_time")
  6787. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6788. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6789. times := strings.Split(startTime, "-")
  6790. setl_mon := times[0] + times[1]
  6791. var upld_btch string
  6792. upld_btch = "0"
  6793. //var empty models.JSResultEmpty
  6794. var result3265 models.JSResult3264
  6795. var result3263 models.JSResult3263
  6796. data2 := make(map[string]interface{})
  6797. data2["org_name"] = miConfig.OrgName
  6798. data2["doctor"] = curRoles.UserName
  6799. data2["doctor_name"] = curRoles.UserName
  6800. data2["fixmedins_code"] = miConfig.Code
  6801. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6802. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6803. data2["secret_key"] = miConfig.SecretKey
  6804. data2["url"] = miConfig.Url
  6805. data2["ak"] = miConfig.AccessKey
  6806. data2["cainfo"] = miConfig.Cainfo
  6807. data2["setl_mon"] = setl_mon
  6808. data2["stmt_loc"] = "2"
  6809. data2["upld_btch"] = upld_btch
  6810. client2 := &http.Client{}
  6811. bytesData2, _ := json.Marshal(data2)
  6812. var req3263 *http.Request
  6813. if miConfig.MdtrtareaAdmvs == "320921" {
  6814. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6815. } else {
  6816. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6817. }
  6818. resp2, _ := client2.Do(req3263)
  6819. defer resp2.Body.Close()
  6820. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6821. if ioErr2 != nil {
  6822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6824. }
  6825. var respJSON3263 map[string]interface{}
  6826. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6829. }
  6830. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6831. fmt.Println(respJSON3263)
  6832. result2, _ := json.Marshal(respJSON3263)
  6833. fmt.Println(result2)
  6834. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6835. utils.ErrorLog("解析失败:%v", err)
  6836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6837. }
  6838. var ids []string
  6839. for _, item := range result3263.Output {
  6840. ids = append(ids, item.SolidifyID)
  6841. }
  6842. data := make(map[string]interface{})
  6843. data["org_name"] = miConfig.OrgName
  6844. data["doctor"] = curRoles.UserName
  6845. data["doctor_name"] = curRoles.UserName
  6846. data["fixmedins_code"] = miConfig.Code
  6847. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6848. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6849. data["secret_key"] = miConfig.SecretKey
  6850. data["url"] = miConfig.Url
  6851. data["ak"] = miConfig.AccessKey
  6852. data["cainfo"] = miConfig.Cainfo
  6853. data["setl_mon"] = setl_mon
  6854. data["solidify_id"] = ids
  6855. month := time.Unix(1557042972, 0).Format("1")
  6856. year := time.Now().Format("2006")
  6857. month = time.Now().Format("01")
  6858. day := time.Now().Format("02")
  6859. hour := time.Now().Format("15")
  6860. min := time.Now().Format("04")
  6861. sec := time.Now().Format("05")
  6862. fix_fill_date := year + month + day + hour + min + sec
  6863. data["fix_fill_dept"] = miConfig.OrgName
  6864. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6865. data["fix_fill_psn"] = curRoles.UserName
  6866. data["fix_fill_date"] = fix_fill_date
  6867. data["stmt_loc"] = "2"
  6868. data["upld_btch"] = upld_btch
  6869. client := &http.Client{}
  6870. bytesData, _ := json.Marshal(data)
  6871. var req *http.Request
  6872. if miConfig.MdtrtareaAdmvs == "320921" {
  6873. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6874. } else {
  6875. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6876. }
  6877. resp, _ := client.Do(req)
  6878. defer resp.Body.Close()
  6879. body, ioErr := ioutil.ReadAll(resp.Body)
  6880. if ioErr != nil {
  6881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6883. }
  6884. var respJSON map[string]interface{}
  6885. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6888. }
  6889. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6890. fmt.Println(respJSON)
  6891. result, _ := json.Marshal(respJSON)
  6892. fmt.Println(result)
  6893. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6894. utils.ErrorLog("解析失败:%v", err)
  6895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6896. }
  6897. if result3265.Infcode != "0" {
  6898. c.ServeSuccessJSON(map[string]interface{}{
  6899. "failed_code": -10,
  6900. "msg": result3265.ErrMsg,
  6901. })
  6902. return
  6903. } else {
  6904. c.ServeSuccessJSON(map[string]interface{}{
  6905. "info": result3265.Output,
  6906. })
  6907. return
  6908. }
  6909. }
  6910. func (c *HisApiController) Get3266() {
  6911. admin_user_id, _ := c.GetInt64("admin_user_id")
  6912. startTime := c.GetString("start_time")
  6913. //endTime, _ := c.GetString("end_time")
  6914. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6915. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6916. times := strings.Split(startTime, "-")
  6917. stmt_mon := times[0] + times[1]
  6918. var upld_btch string
  6919. //var empty models.JSResultEmpty
  6920. var result3265 models.JSResult3264
  6921. data := make(map[string]interface{})
  6922. data["org_name"] = miConfig.OrgName
  6923. data["doctor"] = curRoles.UserName
  6924. data["doctor_name"] = curRoles.UserName
  6925. data["fixmedins_code"] = miConfig.Code
  6926. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6927. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6928. data["secret_key"] = miConfig.SecretKey
  6929. data["url"] = miConfig.Url
  6930. data["ak"] = miConfig.AccessKey
  6931. data["cainfo"] = miConfig.Cainfo
  6932. data["setl_mon"] = stmt_mon
  6933. month := time.Unix(1557042972, 0).Format("1")
  6934. year := time.Now().Format("2006")
  6935. month = time.Now().Format("01")
  6936. day := time.Now().Format("02")
  6937. hour := time.Now().Format("15")
  6938. min := time.Now().Format("04")
  6939. sec := time.Now().Format("05")
  6940. fix_fill_date := year + month + day + hour + min + sec
  6941. data["fix_fill_dept"] = miConfig.OrgName
  6942. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6943. data["fix_fill_psn"] = curRoles.UserName
  6944. data["fix_fill_date"] = fix_fill_date
  6945. data["stmt_loc"] = "2"
  6946. upld_btch = "0"
  6947. data["upld_btch"] = upld_btch
  6948. client := &http.Client{}
  6949. bytesData, _ := json.Marshal(data)
  6950. var req *http.Request
  6951. if miConfig.MdtrtareaAdmvs == "320921" {
  6952. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6953. } else {
  6954. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6955. }
  6956. resp, _ := client.Do(req)
  6957. defer resp.Body.Close()
  6958. body, ioErr := ioutil.ReadAll(resp.Body)
  6959. if ioErr != nil {
  6960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6962. }
  6963. var respJSON map[string]interface{}
  6964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6967. }
  6968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6969. fmt.Println(respJSON)
  6970. result, _ := json.Marshal(respJSON)
  6971. fmt.Println(result)
  6972. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6973. utils.ErrorLog("解析失败:%v", err)
  6974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6975. }
  6976. if result3265.Infcode != "0" {
  6977. c.ServeSuccessJSON(map[string]interface{}{
  6978. "failed_code": -10,
  6979. "msg": result3265.ErrMsg,
  6980. })
  6981. return
  6982. } else {
  6983. c.ServeSuccessJSON(map[string]interface{}{
  6984. "info": result3265.Output,
  6985. })
  6986. return
  6987. }
  6988. }
  6989. func (c *HisApiController) Get3267() {
  6990. admin_user_id, _ := c.GetInt64("admin_user_id")
  6991. startTime := c.GetString("start_time")
  6992. //endTime, _ := c.GetString("end_time")
  6993. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6994. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6995. times := strings.Split(startTime, "-")
  6996. setl_mon := times[0] + times[1]
  6997. var upld_btch string
  6998. //var empty models.JSResultEmpty
  6999. var result3265 models.JSResult3264
  7000. upld_btch = "0"
  7001. data := make(map[string]interface{})
  7002. data["org_name"] = miConfig.OrgName
  7003. data["doctor"] = curRoles.UserName
  7004. data["doctor_name"] = curRoles.UserName
  7005. data["fixmedins_code"] = miConfig.Code
  7006. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7007. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7008. data["secret_key"] = miConfig.SecretKey
  7009. data["url"] = miConfig.Url
  7010. data["ak"] = miConfig.AccessKey
  7011. data["cainfo"] = miConfig.Cainfo
  7012. data["setl_mon"] = setl_mon
  7013. data["stmt_loc"] = "2"
  7014. data["upld_btch"] = upld_btch
  7015. client := &http.Client{}
  7016. bytesData, _ := json.Marshal(data)
  7017. var req *http.Request
  7018. if miConfig.MdtrtareaAdmvs == "320921" {
  7019. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7020. } else {
  7021. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7022. }
  7023. resp, _ := client.Do(req)
  7024. defer resp.Body.Close()
  7025. body, ioErr := ioutil.ReadAll(resp.Body)
  7026. if ioErr != nil {
  7027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7029. }
  7030. var respJSON map[string]interface{}
  7031. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7034. }
  7035. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7036. fmt.Println(respJSON)
  7037. result, _ := json.Marshal(respJSON)
  7038. fmt.Println(result)
  7039. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7040. utils.ErrorLog("解析失败:%v", err)
  7041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7042. }
  7043. if result3265.Infcode != "0" {
  7044. c.ServeSuccessJSON(map[string]interface{}{
  7045. "failed_code": -10,
  7046. "msg": result3265.ErrMsg,
  7047. })
  7048. return
  7049. } else {
  7050. c.ServeSuccessJSON(map[string]interface{}{
  7051. "info": result3265.Output.Data,
  7052. })
  7053. return
  7054. }
  7055. }
  7056. func (c *HisApiController) Get3268() {
  7057. admin_user_id, _ := c.GetInt64("admin_user_id")
  7058. startTime := c.GetString("start_time")
  7059. endTime := c.GetString("end_time")
  7060. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7061. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7062. times := strings.Split(startTime, "-")
  7063. setl_mon := times[0] + times[1]
  7064. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7065. var twos []models.FixMonRecDetailFileInTwo
  7066. var funs []models.FundDetail
  7067. for _, item := range datas {
  7068. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7069. funs = append(funs, fun...)
  7070. }
  7071. var funInfos []models.Fund
  7072. //for _, item := range funs {
  7073. // var rf []models.FundInfo
  7074. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7075. // for _, subitem := range rf {
  7076. // var fund models.Fund
  7077. // fund.FundCode = subitem.FundPayType
  7078. // fund.FundName = subitem.FundPayTypeName
  7079. // fund.FundAmt = subitem.FundPayAmt
  7080. // fund.FundKey = item.FundKey
  7081. // fund.InsuAdmdvs = "555555"
  7082. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7083. // funInfos = append(funInfos, fund)
  7084. // }
  7085. //}
  7086. for _, team := range datas {
  7087. var two models.FixMonRecDetailFileInTwo
  7088. two.SetlDate = time.Now().Format("2006-01-02")
  7089. two.MedType = team.MedType
  7090. two.Insutype = team.Insutype
  7091. two.PsnType = team.PsnType
  7092. two.MedType = team.MedType
  7093. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7094. two.InsuAdmdvs = team.InsuAdmdvs
  7095. two.PsnTime = team.PsnTime
  7096. two.PsnCnt = team.PsnCnt
  7097. two.FundKey = team.FundKey
  7098. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7099. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7100. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7101. two.MedfeeSumAmt = ms
  7102. two.InscpAmt = ia
  7103. two.FundPaySumAmt = fps
  7104. twos = append(twos, two)
  7105. }
  7106. var upld_btch string
  7107. upld_btch = "0"
  7108. var empty models.JSResultEmpty
  7109. data := make(map[string]interface{})
  7110. data["org_name"] = miConfig.OrgName
  7111. data["doctor"] = curRoles.UserName
  7112. data["doctor_name"] = curRoles.UserName
  7113. data["fixmedins_code"] = miConfig.Code
  7114. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7115. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7116. data["secret_key"] = miConfig.SecretKey
  7117. data["url"] = miConfig.Url
  7118. data["ak"] = miConfig.AccessKey
  7119. data["cainfo"] = miConfig.Cainfo
  7120. data["datas"] = twos
  7121. data["fund"] = funInfos
  7122. data["setl_mon"] = setl_mon
  7123. month := time.Unix(1557042972, 0).Format("1")
  7124. year := time.Now().Format("2006")
  7125. month = time.Now().Format("01")
  7126. day := time.Now().Format("02")
  7127. hour := time.Now().Format("15")
  7128. min := time.Now().Format("04")
  7129. sec := time.Now().Format("05")
  7130. fix_fill_date := year + month + day + hour + min + sec
  7131. data["fix_fill_dept"] = miConfig.OrgName
  7132. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7133. data["fix_fill_psn"] = curRoles.UserName
  7134. data["fix_fill_date"] = fix_fill_date
  7135. data["stmt_loc"] = "2"
  7136. data["upld_btch"] = upld_btch
  7137. client := &http.Client{}
  7138. bytesData, _ := json.Marshal(data)
  7139. var req *http.Request
  7140. if miConfig.MdtrtareaAdmvs == "320921" {
  7141. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7142. } else {
  7143. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7144. }
  7145. resp, _ := client.Do(req)
  7146. defer resp.Body.Close()
  7147. body, ioErr := ioutil.ReadAll(resp.Body)
  7148. if ioErr != nil {
  7149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7151. }
  7152. var respJSON map[string]interface{}
  7153. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7156. }
  7157. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7158. fmt.Println(respJSON)
  7159. result, _ := json.Marshal(respJSON)
  7160. fmt.Println(result)
  7161. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7162. utils.ErrorLog("解析失败:%v", err)
  7163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7164. }
  7165. if empty.Infcode != "0" {
  7166. c.ServeSuccessJSON(map[string]interface{}{
  7167. "failed_code": -10,
  7168. "msg": empty.ErrMsg,
  7169. })
  7170. return
  7171. } else {
  7172. c.ServeSuccessJSON(map[string]interface{}{
  7173. "msg": "上传成功",
  7174. })
  7175. return
  7176. }
  7177. }
  7178. func (c *HisApiController) Get3269() {
  7179. admin_user_id, _ := c.GetInt64("admin_user_id")
  7180. startTime := c.GetString("start_time")
  7181. //endTime, _ := c.GetString("end_time")
  7182. times := strings.Split(startTime, "-")
  7183. setl_mon := times[0] + times[1]
  7184. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7185. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7186. var result3263 models.JSResult3263
  7187. data := make(map[string]interface{})
  7188. data["org_name"] = miConfig.OrgName
  7189. data["doctor"] = curRoles.UserName
  7190. data["doctor_name"] = curRoles.UserName
  7191. data["fixmedins_code"] = miConfig.Code
  7192. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7193. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7194. data["secret_key"] = miConfig.SecretKey
  7195. data["url"] = miConfig.Url
  7196. data["ak"] = miConfig.AccessKey
  7197. data["cainfo"] = miConfig.Cainfo
  7198. data["setl_mon"] = setl_mon
  7199. data["stmt_loc"] = "2"
  7200. client := &http.Client{}
  7201. bytesData, _ := json.Marshal(data)
  7202. var req *http.Request
  7203. if miConfig.MdtrtareaAdmvs == "320921" {
  7204. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7205. } else {
  7206. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7207. }
  7208. resp, _ := client.Do(req)
  7209. defer resp.Body.Close()
  7210. body, ioErr := ioutil.ReadAll(resp.Body)
  7211. if ioErr != nil {
  7212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7214. }
  7215. var respJSON map[string]interface{}
  7216. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7219. }
  7220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7221. fmt.Println(respJSON)
  7222. result, _ := json.Marshal(respJSON)
  7223. fmt.Println(result)
  7224. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7225. utils.ErrorLog("解析失败:%v", err)
  7226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7227. }
  7228. if result3263.Infcode != "0" {
  7229. c.ServeSuccessJSON(map[string]interface{}{
  7230. "failed_code": -10,
  7231. "msg": result3263.ErrMsg,
  7232. })
  7233. return
  7234. } else {
  7235. c.ServeSuccessJSON(map[string]interface{}{
  7236. "msg": "上传成功",
  7237. })
  7238. return
  7239. }
  7240. }
  7241. func (c *HisApiController) Get3270() {
  7242. admin_user_id, _ := c.GetInt64("admin_user_id")
  7243. startTime := c.GetString("start_time")
  7244. //endTime, _ := c.GetString("end_time")
  7245. times := strings.Split(startTime, "-")
  7246. setl_mon := times[0] + times[1]
  7247. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7248. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7249. var result3263 models.JSResult3263
  7250. data2 := make(map[string]interface{})
  7251. data2["org_name"] = miConfig.OrgName
  7252. data2["doctor"] = curRoles.UserName
  7253. data2["doctor_name"] = curRoles.UserName
  7254. data2["fixmedins_code"] = miConfig.Code
  7255. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7256. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7257. data2["secret_key"] = miConfig.SecretKey
  7258. data2["url"] = miConfig.Url
  7259. data2["ak"] = miConfig.AccessKey
  7260. data2["cainfo"] = miConfig.Cainfo
  7261. data2["setl_mon"] = setl_mon
  7262. data2["stmt_loc"] = "2"
  7263. client2 := &http.Client{}
  7264. bytesData2, _ := json.Marshal(data2)
  7265. var req3263 *http.Request
  7266. if miConfig.MdtrtareaAdmvs == "320921" {
  7267. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7268. } else {
  7269. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7270. }
  7271. resp2, _ := client2.Do(req3263)
  7272. defer resp2.Body.Close()
  7273. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7274. if ioErr2 != nil {
  7275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7277. }
  7278. var respJSON3263 map[string]interface{}
  7279. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7282. }
  7283. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7284. fmt.Println(respJSON3263)
  7285. result2, _ := json.Marshal(respJSON3263)
  7286. fmt.Println(result2)
  7287. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7288. utils.ErrorLog("解析失败:%v", err)
  7289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7290. }
  7291. var ids []string
  7292. for _, item := range result3263.Output {
  7293. ids = append(ids, item.SolidifyID)
  7294. }
  7295. var result3264 models.JSResult3264
  7296. data := make(map[string]interface{})
  7297. data["org_name"] = miConfig.OrgName
  7298. data["doctor"] = curRoles.UserName
  7299. data["doctor_name"] = curRoles.UserName
  7300. data["fixmedins_code"] = miConfig.Code
  7301. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7302. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7303. data["secret_key"] = miConfig.SecretKey
  7304. data["url"] = miConfig.Url
  7305. data["ak"] = miConfig.AccessKey
  7306. data["cainfo"] = miConfig.Cainfo
  7307. data["setl_mon"] = setl_mon
  7308. data["stmt_loc"] = "2"
  7309. data["solidify_id"] = ids
  7310. client := &http.Client{}
  7311. bytesData, _ := json.Marshal(data)
  7312. var req *http.Request
  7313. if miConfig.MdtrtareaAdmvs == "320921" {
  7314. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7315. } else {
  7316. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7317. }
  7318. resp, _ := client.Do(req)
  7319. defer resp.Body.Close()
  7320. body, ioErr := ioutil.ReadAll(resp.Body)
  7321. if ioErr != nil {
  7322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7324. }
  7325. var respJSON map[string]interface{}
  7326. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7329. }
  7330. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7331. fmt.Println(respJSON)
  7332. result, _ := json.Marshal(respJSON)
  7333. fmt.Println(result)
  7334. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7335. utils.ErrorLog("解析失败:%v", err)
  7336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7337. }
  7338. if result3264.Infcode != "0" {
  7339. c.ServeSuccessJSON(map[string]interface{}{
  7340. "failed_code": -10,
  7341. "msg": result3264.ErrMsg,
  7342. })
  7343. return
  7344. } else {
  7345. c.ServeSuccessJSON(map[string]interface{}{
  7346. "info": result3264.Output,
  7347. })
  7348. return
  7349. }
  7350. }
  7351. func (c *HisApiController) Get3271() {
  7352. admin_user_id, _ := c.GetInt64("admin_user_id")
  7353. startTime := c.GetString("start_time")
  7354. //endTime, _ := c.GetString("end_time")
  7355. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7356. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7357. times := strings.Split(startTime, "-")
  7358. setl_mon := times[0] + times[1]
  7359. //var empty models.JSResultEmpty
  7360. var result3265 models.JSResult3264
  7361. var result3263 models.JSResult3263
  7362. data2 := make(map[string]interface{})
  7363. data2["org_name"] = miConfig.OrgName
  7364. data2["doctor"] = curRoles.UserName
  7365. data2["doctor_name"] = curRoles.UserName
  7366. data2["fixmedins_code"] = miConfig.Code
  7367. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7368. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7369. data2["secret_key"] = miConfig.SecretKey
  7370. data2["url"] = miConfig.Url
  7371. data2["ak"] = miConfig.AccessKey
  7372. data2["cainfo"] = miConfig.Cainfo
  7373. data2["setl_mon"] = setl_mon
  7374. data2["stmt_loc"] = "2"
  7375. client2 := &http.Client{}
  7376. bytesData2, _ := json.Marshal(data2)
  7377. var req3263 *http.Request
  7378. if miConfig.MdtrtareaAdmvs == "320921" {
  7379. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7380. } else {
  7381. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7382. }
  7383. resp2, _ := client2.Do(req3263)
  7384. defer resp2.Body.Close()
  7385. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7386. if ioErr2 != nil {
  7387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7389. }
  7390. var respJSON3263 map[string]interface{}
  7391. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7394. }
  7395. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7396. fmt.Println(respJSON3263)
  7397. result2, _ := json.Marshal(respJSON3263)
  7398. fmt.Println(result2)
  7399. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7400. utils.ErrorLog("解析失败:%v", err)
  7401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7402. }
  7403. var ids []string
  7404. for _, item := range result3263.Output {
  7405. ids = append(ids, item.SolidifyID)
  7406. }
  7407. data := make(map[string]interface{})
  7408. data["org_name"] = miConfig.OrgName
  7409. data["doctor"] = curRoles.UserName
  7410. data["doctor_name"] = curRoles.UserName
  7411. data["fixmedins_code"] = miConfig.Code
  7412. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7413. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7414. data["secret_key"] = miConfig.SecretKey
  7415. data["url"] = miConfig.Url
  7416. data["ak"] = miConfig.AccessKey
  7417. data["cainfo"] = miConfig.Cainfo
  7418. data["setl_mon"] = setl_mon
  7419. data["solidify_id"] = ids
  7420. month := time.Unix(1557042972, 0).Format("1")
  7421. year := time.Now().Format("2006")
  7422. month = time.Now().Format("01")
  7423. day := time.Now().Format("02")
  7424. hour := time.Now().Format("15")
  7425. min := time.Now().Format("04")
  7426. sec := time.Now().Format("05")
  7427. fix_fill_date := year + month + day + hour + min + sec
  7428. data["fix_fill_dept"] = miConfig.OrgName
  7429. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7430. data["fix_fill_psn"] = curRoles.UserName
  7431. data["fix_fill_date"] = fix_fill_date
  7432. data["stmt_loc"] = "2"
  7433. client := &http.Client{}
  7434. bytesData, _ := json.Marshal(data)
  7435. var req *http.Request
  7436. if miConfig.MdtrtareaAdmvs == "320921" {
  7437. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7438. } else {
  7439. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7440. }
  7441. resp, _ := client.Do(req)
  7442. defer resp.Body.Close()
  7443. body, ioErr := ioutil.ReadAll(resp.Body)
  7444. if ioErr != nil {
  7445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7447. }
  7448. var respJSON map[string]interface{}
  7449. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7452. }
  7453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7454. fmt.Println(respJSON)
  7455. result, _ := json.Marshal(respJSON)
  7456. fmt.Println(result)
  7457. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7458. utils.ErrorLog("解析失败:%v", err)
  7459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7460. }
  7461. if result3265.Infcode != "0" {
  7462. c.ServeSuccessJSON(map[string]interface{}{
  7463. "failed_code": -10,
  7464. "msg": result3265.ErrMsg,
  7465. })
  7466. return
  7467. } else {
  7468. c.ServeSuccessJSON(map[string]interface{}{
  7469. "info": result3265.Output.Data,
  7470. })
  7471. return
  7472. }
  7473. }
  7474. func (c *HisApiController) Get3272() {
  7475. admin_user_id, _ := c.GetInt64("admin_user_id")
  7476. startTime := c.GetString("start_time")
  7477. //endTime, _ := c.GetString("end_time")
  7478. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7479. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7480. times := strings.Split(startTime, "-")
  7481. setl_mon := times[0] + times[1]
  7482. var upld_btch string
  7483. //var empty models.JSResultEmpty
  7484. var result3265 models.JSResult3264
  7485. data := make(map[string]interface{})
  7486. data["org_name"] = miConfig.OrgName
  7487. data["doctor"] = curRoles.UserName
  7488. data["doctor_name"] = curRoles.UserName
  7489. data["fixmedins_code"] = miConfig.Code
  7490. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7491. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7492. data["secret_key"] = miConfig.SecretKey
  7493. data["url"] = miConfig.Url
  7494. data["ak"] = miConfig.AccessKey
  7495. data["cainfo"] = miConfig.Cainfo
  7496. data["setl_mon"] = setl_mon
  7497. month := time.Unix(1557042972, 0).Format("1")
  7498. year := time.Now().Format("2006")
  7499. month = time.Now().Format("01")
  7500. day := time.Now().Format("02")
  7501. hour := time.Now().Format("15")
  7502. min := time.Now().Format("04")
  7503. sec := time.Now().Format("05")
  7504. fix_fill_date := year + month + day + hour + min + sec
  7505. data["fix_fill_dept"] = miConfig.OrgName
  7506. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7507. data["fix_fill_psn"] = curRoles.UserName
  7508. data["fix_fill_date"] = fix_fill_date
  7509. data["stmt_loc"] = "2"
  7510. data["upld_btch"] = upld_btch
  7511. client := &http.Client{}
  7512. bytesData, _ := json.Marshal(data)
  7513. var req *http.Request
  7514. if miConfig.MdtrtareaAdmvs == "320921" {
  7515. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7516. } else {
  7517. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7518. }
  7519. resp, _ := client.Do(req)
  7520. defer resp.Body.Close()
  7521. body, ioErr := ioutil.ReadAll(resp.Body)
  7522. if ioErr != nil {
  7523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7525. }
  7526. var respJSON map[string]interface{}
  7527. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7530. }
  7531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7532. fmt.Println(respJSON)
  7533. result, _ := json.Marshal(respJSON)
  7534. fmt.Println(result)
  7535. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7536. utils.ErrorLog("解析失败:%v", err)
  7537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7538. }
  7539. if result3265.Infcode != "0" {
  7540. c.ServeSuccessJSON(map[string]interface{}{
  7541. "failed_code": -10,
  7542. "msg": result3265.ErrMsg,
  7543. })
  7544. return
  7545. } else {
  7546. c.ServeSuccessJSON(map[string]interface{}{
  7547. "info": result3265.Output,
  7548. })
  7549. return
  7550. }
  7551. }
  7552. func (c *HisApiController) Get3273() {
  7553. admin_user_id, _ := c.GetInt64("admin_user_id")
  7554. startTime := c.GetString("start_time")
  7555. //endTime, _ := c.GetString("end_time")
  7556. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7557. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7558. times := strings.Split(startTime, "-")
  7559. setl_mon := times[0] + times[1]
  7560. var result3265 models.JSResult3264
  7561. data := make(map[string]interface{})
  7562. data["org_name"] = miConfig.OrgName
  7563. data["doctor"] = curRoles.UserName
  7564. data["doctor_name"] = curRoles.UserName
  7565. data["fixmedins_code"] = miConfig.Code
  7566. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7567. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7568. data["secret_key"] = miConfig.SecretKey
  7569. data["url"] = miConfig.Url
  7570. data["ak"] = miConfig.AccessKey
  7571. data["cainfo"] = miConfig.Cainfo
  7572. data["setl_mon"] = setl_mon
  7573. data["stmt_loc"] = "2"
  7574. client := &http.Client{}
  7575. bytesData, _ := json.Marshal(data)
  7576. var req *http.Request
  7577. if miConfig.MdtrtareaAdmvs == "320921" {
  7578. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7579. } else {
  7580. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7581. }
  7582. resp, _ := client.Do(req)
  7583. defer resp.Body.Close()
  7584. body, ioErr := ioutil.ReadAll(resp.Body)
  7585. if ioErr != nil {
  7586. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7588. }
  7589. var respJSON map[string]interface{}
  7590. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7593. }
  7594. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7595. fmt.Println(respJSON)
  7596. result, _ := json.Marshal(respJSON)
  7597. fmt.Println(result)
  7598. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7599. utils.ErrorLog("解析失败:%v", err)
  7600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7601. }
  7602. if result3265.Infcode != "0" {
  7603. c.ServeSuccessJSON(map[string]interface{}{
  7604. "failed_code": -10,
  7605. "msg": result3265.ErrMsg,
  7606. })
  7607. return
  7608. } else {
  7609. c.ServeSuccessJSON(map[string]interface{}{
  7610. "info": result3265.Output.Data,
  7611. })
  7612. return
  7613. }
  7614. }
  7615. func (c *HisApiController) Get3274() {
  7616. //if miConfig.MdtrtareaAdmvs == "320921" {
  7617. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7618. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7619. // "&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
  7620. //
  7621. //} else {
  7622. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7623. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7624. // "&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
  7625. //
  7626. //}
  7627. }
  7628. func (c *HisApiController) Get3275() {
  7629. //if miConfig.MdtrtareaAdmvs == "320921" {
  7630. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7631. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7632. // "&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
  7633. //
  7634. //} else {
  7635. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7636. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7637. // "&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
  7638. //
  7639. //}
  7640. }
  7641. func (c *HisApiController) Get3276() {
  7642. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7643. //month := c.GetString("month")
  7644. //
  7645. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7646. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7647. //var api string
  7648. //var res Result5301
  7649. //
  7650. //if miConfig.MdtrtareaAdmvs == "320921" {
  7651. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7652. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7653. //} else {
  7654. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7655. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7656. //}
  7657. //
  7658. //resp, requestErr := http.Get(api)
  7659. //if requestErr != nil {
  7660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7661. // return
  7662. //}
  7663. //
  7664. //body, ioErr := ioutil.ReadAll(resp.Body)
  7665. //if ioErr != nil {
  7666. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7668. // return
  7669. //}
  7670. //var respJSON map[string]interface{}
  7671. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7672. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7673. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7674. // return
  7675. //}
  7676. //
  7677. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7678. //result, _ := json.Marshal(respJSON)
  7679. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7680. // utils.ErrorLog("解析失败:%v", err)
  7681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7682. // return
  7683. //}
  7684. }
  7685. func (c *HisApiController) Get3277() {
  7686. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7687. //month := c.GetString("month")
  7688. //
  7689. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7690. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7691. //var api string
  7692. //var res Result5301
  7693. //
  7694. //if miConfig.MdtrtareaAdmvs == "320921" {
  7695. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7696. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7697. //} else {
  7698. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7699. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7700. //}
  7701. //
  7702. //resp, requestErr := http.Get(api)
  7703. //if requestErr != nil {
  7704. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7705. // return
  7706. //}
  7707. //
  7708. //body, ioErr := ioutil.ReadAll(resp.Body)
  7709. //if ioErr != nil {
  7710. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7711. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7712. // return
  7713. //}
  7714. //var respJSON map[string]interface{}
  7715. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7716. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7717. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7718. // return
  7719. //}
  7720. //
  7721. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7722. //result, _ := json.Marshal(respJSON)
  7723. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7724. // utils.ErrorLog("解析失败:%v", err)
  7725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7726. // return
  7727. //}
  7728. }
  7729. func (c *HisApiController) GetCFYLJG001() {
  7730. admin_user_id, _ := c.GetInt64("admin_user_id")
  7731. patient_id, _ := c.GetInt64("patient_id")
  7732. his_patient_id, _ := c.GetInt64("his_patient_id")
  7733. record_time := c.GetString("record_time")
  7734. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7735. psn, _ := service.GetPsnByPatientId(patient_id)
  7736. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7737. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7738. var cFYLJG001 models.CFYLJG001
  7739. timeLayout := "2006-01-02"
  7740. loc, _ := time.LoadLocation("Local")
  7741. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7742. if err != nil {
  7743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7744. return
  7745. }
  7746. recordDateTime := theTime.Unix()
  7747. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7748. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7749. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7750. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7751. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7752. for _, item := range prescriptions {
  7753. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7754. if his.IdCardType == 1 {
  7755. bas := strings.Split(psn.CardInfo, "|")
  7756. basNumber := bas[1]
  7757. fmt.Println(basNumber)
  7758. card_sn := bas[3]
  7759. card_no := bas[2]
  7760. cFYLJG001.MdtrtCertType = "03"
  7761. cFYLJG001.CardSn = card_sn
  7762. cFYLJG001.MdtrtCertNo = card_no
  7763. cFYLJG001.EcToken = ""
  7764. cFYLJG001.AuthNo = ""
  7765. } else if his.IdCardType == 2 {
  7766. cFYLJG001.MdtrtCertType = "02"
  7767. cFYLJG001.CardSn = ""
  7768. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7769. cFYLJG001.EcToken = ""
  7770. cFYLJG001.AuthNo = ""
  7771. } else if his.IdCardType == 4 {
  7772. cFYLJG001.MdtrtCertType = "01"
  7773. cFYLJG001.CardSn = ""
  7774. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7775. cFYLJG001.EcToken = psn.VerifyNumber
  7776. cFYLJG001.AuthNo = ""
  7777. }
  7778. cFYLJG001.BizTypeCode = "01"
  7779. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7780. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7781. cFYLJG001.RxTypeCode = "1"
  7782. tempTime := time.Unix(item.PreTime, 0)
  7783. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7784. cFYLJG001.PrscTime = timeFormatOne
  7785. var count float64
  7786. if item.Type == 1 {
  7787. for _, sumItem := range item.HisDoctorAdviceInfo {
  7788. count = count + sumItem.PrescribingNumber
  7789. }
  7790. }
  7791. cFYLJG001.RxDrugCnt = count
  7792. cFYLJG001.ValiDays = "2"
  7793. ts := time.Unix(item.PreTime, 0)
  7794. record_time2 := ts.AddDate(0, 0, int(2)).Unix()
  7795. tempTime3 := time.Unix(record_time2, 0)
  7796. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7797. cFYLJG001.ValiEndTime = timeFormat3
  7798. cFYLJG001.RxCotnFlag = "0"
  7799. for _, subItem := range item.HisDoctorAdviceInfo {
  7800. var drug models.RxDrug
  7801. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7802. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7803. drug.RxItemTypeCode = "11"
  7804. drug.DrugDosform = "剂" //TODO
  7805. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7806. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7807. }
  7808. drug.MedcWayDscr = subItem.DeliveryWay
  7809. tempTime2 := time.Unix(subItem.StartTime, 0)
  7810. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7811. drug.MedcBegntime = timeFormatTwo
  7812. if subItem.Day > 0 {
  7813. ts := time.Unix(subItem.StartTime, 0)
  7814. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7815. tempTime4 := time.Unix(record_time, 0)
  7816. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7817. drug.MedcEndtime = timeFormat5
  7818. } else {
  7819. tempTime2 := time.Unix(subItem.StartTime, 0)
  7820. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7821. drug.MedcEndtime = timeFormatTwo
  7822. }
  7823. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7824. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7825. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7826. drug.DrugCnt = subItem.PrescribingNumber
  7827. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7828. drug.DrugGenname = subItem.AdviceName
  7829. drug.MedcWayCodg = subItem.DeliveryWay
  7830. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7831. drug.SinDoscnt = subItem.SingleDose
  7832. drug.SinDosunt = subItem.SingleDoseUnit
  7833. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7834. drug.UsedFrquName = subItem.ExecutionFrequency
  7835. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7836. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7837. drug.HospApprFlag = "1"
  7838. cFYLJG001.List = append(cFYLJG001.List, drug)
  7839. }
  7840. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7841. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  7842. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7843. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7844. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7845. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7846. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7847. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7848. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7849. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7850. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7851. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7852. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7853. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7854. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7855. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7856. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7857. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7858. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7859. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7860. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7861. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7862. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7863. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7864. tempTime2 := time.Now().Unix()
  7865. tempTime6 := time.Unix(tempTime2, 0)
  7866. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7867. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7868. cFYLJG001.Mdtrtinfo.DiseCodg = ""
  7869. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7870. cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
  7871. cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
  7872. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7873. var config []*models.HisXtDiagnoseConfig
  7874. for _, item := range diagnosis_ids {
  7875. id, _ := strconv.ParseInt(item, 10, 64)
  7876. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7877. config = append(config, &diagnosisConfig)
  7878. }
  7879. for index, subitem := range config {
  7880. if index == 0 {
  7881. var dia models.DiseInfo
  7882. dia.DiagType = "1"
  7883. dia.MaindiagFlag = "1"
  7884. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7885. dia.DiagCode = subitem.CountryCode
  7886. dia.DiagName = subitem.ClassName
  7887. dia.DiagDept = "肾内科"
  7888. dia.DiagDrNo = doctor.DoctorNumber
  7889. dia.DiagDrName = doctor.UserName
  7890. tempTime3 := time.Unix(item.PreTime, 0)
  7891. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7892. dia.DiagTime = timeFormatTwo
  7893. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7894. } else {
  7895. var dia models.DiseInfo
  7896. dia.DiagType = "1"
  7897. dia.MaindiagFlag = "0"
  7898. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7899. dia.DiagCode = subitem.CountryCode
  7900. dia.DiagName = subitem.ClassName
  7901. dia.DiagDept = "肾内科"
  7902. dia.DiagDrNo = doctor.DoctorNumber
  7903. dia.DiagDrName = doctor.UserName
  7904. tempTime3 := time.Unix(item.PreTime, 0)
  7905. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7906. dia.DiagTime = timeFormatTwo
  7907. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7908. }
  7909. }
  7910. if miConfig.MdtrtareaAdmvs == "340699" {
  7911. result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
  7912. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7913. var res ResultCFYLJG001AH
  7914. var respJSON2 map[string]interface{}
  7915. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7918. return
  7919. }
  7920. userJSONBytes2, _ := json.Marshal(respJSON2)
  7921. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7922. utils.ErrorLog("解析失败:%v", err)
  7923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7924. return
  7925. }
  7926. var flow models.HisPrescriptionFlow
  7927. flow.Ctime = time.Now().Unix()
  7928. flow.SignDigest = ""
  7929. flow.RxTraceCode = res.RxTraceCode
  7930. flow.HiRxno = res.HiRxno
  7931. flow.MID = his.Number
  7932. flow.Status = 1
  7933. flow.DCode = doctor_info.DoctorNumber
  7934. flow.OriginalRxFile = ""
  7935. flow.OriginalValue = ""
  7936. flow.SignCertDn = ""
  7937. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  7938. flow.SignCertSn = ""
  7939. flow.Mtime = time.Now().Unix()
  7940. service.Createflow(&flow)
  7941. c.ServeSuccessJSON(map[string]interface{}{
  7942. "msg": "上传成功",
  7943. })
  7944. } else {
  7945. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7946. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7947. var res ResultCFYLJG001
  7948. var respJSON2 map[string]interface{}
  7949. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7952. return
  7953. }
  7954. userJSONBytes2, _ := json.Marshal(respJSON2)
  7955. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7956. utils.ErrorLog("解析失败:%v", err)
  7957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7958. return
  7959. }
  7960. if res.Infcode == -1 {
  7961. c.ServeSuccessJSON(map[string]interface{}{
  7962. "failed_code": -10,
  7963. "msg": res.ErrMsg,
  7964. })
  7965. return
  7966. } else {
  7967. var flow models.HisPrescriptionFlow
  7968. flow.Ctime = time.Now().Unix()
  7969. flow.SignDigest = ""
  7970. flow.RxTraceCode = res.Output.RxTraceCode
  7971. flow.HiRxno = res.Output.HiRxno
  7972. flow.MID = his.Number
  7973. flow.Status = 1
  7974. flow.DCode = doctor_info.DoctorNumber
  7975. flow.OriginalRxFile = ""
  7976. flow.OriginalValue = ""
  7977. flow.SignCertDn = ""
  7978. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  7979. flow.SignCertSn = ""
  7980. flow.Mtime = time.Now().Unix()
  7981. service.Createflow(&flow)
  7982. c.ServeSuccessJSON(map[string]interface{}{
  7983. "msg": "上传成功",
  7984. })
  7985. }
  7986. }
  7987. }
  7988. }
  7989. func (c *HisApiController) GetCFYLJG12() {
  7990. admin_user_id, _ := c.GetInt64("admin_user_id")
  7991. his_patient_id, _ := c.GetInt64("his_patient_id")
  7992. record_time := c.GetString("record_time")
  7993. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7994. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7995. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7996. flow, _ := service.Getflowtwo(his.Number)
  7997. patient_id, _ := c.GetInt64("patient_id")
  7998. timeLayout := "2006-01-02"
  7999. loc, _ := time.LoadLocation("Local")
  8000. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8001. if err != nil {
  8002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8003. return
  8004. }
  8005. recordDateTime := theTime.Unix()
  8006. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8007. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8008. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8009. dept, _ := service.GetDepartMentDetail(info.Departments)
  8010. inputData := make(map[string]interface{})
  8011. inputData["rxTraceCode"] = flow.RxTraceCode
  8012. inputData["hiRxno"] = flow.HiRxno
  8013. inputData["mdtrtId"] = flow.MID
  8014. inputData["patnName"] = his.PsnName
  8015. inputData["psnCertType"] = his.PsnCertType
  8016. inputData["certno"] = his.Certno
  8017. inputData["fixmedinsName"] = miConfig.OrgName
  8018. inputData["fixmedinsCode"] = miConfig.Code
  8019. inputData["drCode"] = doctor_info.DoctorNumber
  8020. inputData["prscDrName"] = doctor_info.UserName
  8021. inputData["pharDeptName"] = dept.Name
  8022. inputData["pharDeptCode"] = dept.Number
  8023. inputData["pharProfttlCodg"] = ""
  8024. inputData["pharProfttlName"] = ""
  8025. inputData["pharCode"] = "HY340621000425"
  8026. inputData["pharCertType"] = "01"
  8027. inputData["pharCertno"] = ""
  8028. inputData["pharName"] = "孙莉侠"
  8029. inputData["pharPracCertNo"] = ""
  8030. tempTime2 := time.Unix(info.Ctime, 0)
  8031. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8032. inputData["pharChkTime"] = timeFormatTwo
  8033. bytesData, _ := json.Marshal(inputData)
  8034. fmt.Println(string(bytesData))
  8035. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8036. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8037. if err != nil {
  8038. fmt.Println("Error reading PDF file:", err)
  8039. return
  8040. }
  8041. // 将 PDF 文件内容进行 Base64 编码
  8042. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8043. fmt.Println(err)
  8044. if miConfig.MdtrtareaAdmvs == "340699" {
  8045. data := make(map[string]interface{})
  8046. data["rx_encoded"] = rx_encoded
  8047. data["code"] = miConfig.Code
  8048. data["url"] = "http://10.66.149.64:8080/epc/api"
  8049. data["encoded"] = encoded
  8050. client := &http.Client{}
  8051. bytesData, _ := json.Marshal(data)
  8052. var req *http.Request
  8053. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/02", bytes.NewReader(bytesData))
  8054. resp, _ := client.Do(req)
  8055. defer resp.Body.Close()
  8056. body, ioErr := ioutil.ReadAll(resp.Body)
  8057. if ioErr != nil {
  8058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8059. }
  8060. var respJSON map[string]interface{}
  8061. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8064. return
  8065. }
  8066. var resSix10265 ResultSix10265 //1101结果
  8067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8068. result, _ := json.Marshal(respJSON)
  8069. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8070. utils.ErrorLog("解析失败:%v", err)
  8071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8072. return
  8073. }
  8074. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8075. //saveLog(result, "", "GetCFYLJG002", "GetCFYLJG002")
  8076. } else {
  8077. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8078. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8079. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8080. var res2 AhResult002
  8081. var respJSON2 map[string]interface{}
  8082. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8085. return
  8086. }
  8087. userJSONBytes2, _ := json.Marshal(respJSON2)
  8088. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8089. utils.ErrorLog("解析失败:%v", err)
  8090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8091. return
  8092. }
  8093. flow.Ctime = time.Now().Unix()
  8094. flow.SignDigest = res2.SignDigest
  8095. flow.RxFile = res2.RxFile
  8096. flow.MID = his.Number
  8097. flow.Status = 1
  8098. flow.DCode = doctor_info.DoctorNumber
  8099. flow.OriginalRxFile = rx_encoded
  8100. flow.OriginalValue = encoded
  8101. flow.SignCertDn = res2.SignCertDn
  8102. flow.SignCertSn = res2.SignCertSn
  8103. flow.Mtime = time.Now().Unix()
  8104. service.Saveflow(flow)
  8105. c.ServeSuccessJSON(map[string]interface{}{
  8106. "msg": "预签名成功",
  8107. })
  8108. }
  8109. }
  8110. func (c *HisApiController) GetCFYLJG13() {
  8111. admin_user_id, _ := c.GetInt64("admin_user_id")
  8112. his_patient_id, _ := c.GetInt64("his_patient_id")
  8113. record_time := c.GetString("record_time")
  8114. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8115. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8116. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8117. flow, _ := service.Getflowtwo(his.Number)
  8118. patient_id, _ := c.GetInt64("patient_id")
  8119. timeLayout := "2006-01-02"
  8120. loc, _ := time.LoadLocation("Local")
  8121. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8122. if err != nil {
  8123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8124. return
  8125. }
  8126. recordDateTime := theTime.Unix()
  8127. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8128. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8129. dept, _ := service.GetDepartMentDetail(info.Departments)
  8130. var cFYLJG003 models.CFYLJG003
  8131. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8132. cFYLJG003.HiRxno = flow.HiRxno
  8133. cFYLJG003.MdtrtID = flow.MID
  8134. cFYLJG003.PatnName = his.Name
  8135. cFYLJG003.Certno = his.Certno
  8136. cFYLJG003.FixmedinsName = miConfig.OrgName
  8137. cFYLJG003.FixmedinsCode = miConfig.Code
  8138. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8139. cFYLJG003.PrscDrName = doctor_info.UserName
  8140. cFYLJG003.PharDeptName = dept.Name
  8141. cFYLJG003.PharDeptCode = dept.Number
  8142. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8143. cFYLJG003.PharName = "孙莉侠"
  8144. cFYLJG003.PharPracCertNo = "060399"
  8145. cFYLJG003.PharCode = "HY340621000425"
  8146. cFYLJG003.PharCertType = "01"
  8147. cFYLJG003.PharCertno = ""
  8148. } else {
  8149. cFYLJG003.PharName = "彭斯遥"
  8150. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8151. cFYLJG003.PharCode = "HY440309002107"
  8152. cFYLJG003.PharCertType = "01"
  8153. cFYLJG003.PharCertno = "430482199408260023"
  8154. }
  8155. cFYLJG003.PsnCertType = "01"
  8156. cFYLJG003.RxFile = flow.RxFile
  8157. cFYLJG003.SignDigest = flow.SignDigest
  8158. cFYLJG003.FixmedinsCode = miConfig.Code
  8159. cFYLJG003.PsnCertType = "01"
  8160. cFYLJG003.PharProfttlCodg = dept.Name
  8161. tempTime2 := time.Unix(info.Ctime, 0)
  8162. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8163. cFYLJG003.PharChkTime = timeFormatTwo
  8164. if miConfig.MdtrtareaAdmvs == "340699" {
  8165. data := make(map[string]interface{})
  8166. data["url"] = "http://10.66.149.64:8080/epc/api"
  8167. data["13"] = cFYLJG003
  8168. client := &http.Client{}
  8169. bytesData, _ := json.Marshal(data)
  8170. var req *http.Request
  8171. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/03", bytes.NewReader(bytesData))
  8172. resp, _ := client.Do(req)
  8173. defer resp.Body.Close()
  8174. body, ioErr := ioutil.ReadAll(resp.Body)
  8175. if ioErr != nil {
  8176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8177. }
  8178. var respJSON map[string]interface{}
  8179. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8182. return
  8183. }
  8184. var resSix10265 ResultSix10265 //1101结果
  8185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8186. result, _ := json.Marshal(respJSON)
  8187. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8188. utils.ErrorLog("解析失败:%v", err)
  8189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8190. return
  8191. }
  8192. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8193. //saveLog(result, "", "GetCFYLJG013", "GetCFYLJG013")
  8194. } else {
  8195. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8196. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8197. var res ResultCFYLJG003
  8198. var respJSON2 map[string]interface{}
  8199. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8202. return
  8203. }
  8204. userJSONBytes2, _ := json.Marshal(respJSON2)
  8205. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8206. utils.ErrorLog("解析失败:%v", err)
  8207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8208. return
  8209. }
  8210. if res.Infcode == -1 {
  8211. c.ServeSuccessJSON(map[string]interface{}{
  8212. "failed_code": -10,
  8213. "msg": res.ErrMsg,
  8214. })
  8215. return
  8216. } else {
  8217. c.ServeSuccessJSON(map[string]interface{}{
  8218. "info": res.Output,
  8219. })
  8220. }
  8221. }
  8222. }
  8223. func (c *HisApiController) GetCFYLJG002() {
  8224. admin_user_id, _ := c.GetInt64("admin_user_id")
  8225. his_patient_id, _ := c.GetInt64("his_patient_id")
  8226. record_time := c.GetString("record_time")
  8227. admin_user_id = 3626
  8228. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8229. //id, _ := c.GetInt64("id")
  8230. admin_user_id = 3626
  8231. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8232. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8233. flow, _ := service.Getflowtwo(his.Number)
  8234. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8235. //record_time := c.GetString("record_time")
  8236. patient_id, _ := c.GetInt64("patient_id")
  8237. //patient_id = 23834
  8238. //record_time = "2023-09-18"
  8239. timeLayout := "2006-01-02"
  8240. loc, _ := time.LoadLocation("Local")
  8241. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8242. if err != nil {
  8243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8244. return
  8245. }
  8246. recordDateTime := theTime.Unix()
  8247. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8248. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8249. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8250. dept, _ := service.GetDepartMentDetail(info.Departments)
  8251. inputData := make(map[string]interface{})
  8252. inputData["rxTraceCode"] = flow.RxTraceCode
  8253. inputData["hiRxno"] = flow.HiRxno
  8254. inputData["mdtrtId"] = flow.MID
  8255. inputData["patnName"] = his.PsnName
  8256. inputData["psnCertType"] = his.PsnCertType
  8257. inputData["certno"] = his.Certno
  8258. inputData["fixmedinsName"] = miConfig.OrgName
  8259. inputData["fixmedinsCode"] = miConfig.Code
  8260. inputData["drCode"] = doctor_info.DoctorNumber
  8261. inputData["prscDrName"] = doctor_info.UserName
  8262. inputData["pharDeptName"] = dept.Name
  8263. inputData["pharDeptCode"] = dept.Number
  8264. inputData["pharProfttlCodg"] = ""
  8265. inputData["pharProfttlName"] = ""
  8266. inputData["pharCode"] = "HY340621000425"
  8267. inputData["pharCertType"] = "01"
  8268. inputData["pharCertno"] = ""
  8269. inputData["pharName"] = "孙莉侠"
  8270. inputData["pharPracCertNo"] = "060399"
  8271. tempTime2 := time.Unix(info.Ctime, 0)
  8272. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8273. inputData["pharChkTime"] = timeFormatTwo
  8274. bytesData, _ := json.Marshal(inputData)
  8275. fmt.Println(string(bytesData))
  8276. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8277. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8278. if err != nil {
  8279. fmt.Println("Error reading PDF file:", err)
  8280. return
  8281. }
  8282. // 将 PDF 文件内容进行 Base64 编码
  8283. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8284. fmt.Println(err)
  8285. if miConfig.MdtrtareaAdmvs == "340699" {
  8286. result, request := service.GetAHCFYLJG002(miConfig.Code, "http://10.66.149.64:8080/epc/api", encoded, rx_encoded, "")
  8287. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8288. var res2 AhResult002
  8289. var respJSON2 map[string]interface{}
  8290. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8293. return
  8294. }
  8295. userJSONBytes2, _ := json.Marshal(respJSON2)
  8296. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8297. utils.ErrorLog("解析失败:%v", err)
  8298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8299. return
  8300. }
  8301. flow.Ctime = time.Now().Unix()
  8302. flow.SignDigest = res2.SignDigest
  8303. flow.RxFile = res2.RxFile
  8304. flow.MID = his.Number
  8305. flow.Status = 1
  8306. flow.DCode = doctor_info.DoctorNumber
  8307. flow.OriginalRxFile = rx_encoded
  8308. flow.OriginalValue = encoded
  8309. flow.SignCertDn = res2.SignCertDn
  8310. flow.SignCertSn = res2.SignCertSn
  8311. flow.Mtime = time.Now().Unix()
  8312. service.Saveflow(flow)
  8313. c.ServeSuccessJSON(map[string]interface{}{
  8314. "msg": "预签名成功",
  8315. })
  8316. } else {
  8317. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8318. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8319. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8320. var res2 Result002
  8321. var respJSON2 map[string]interface{}
  8322. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8325. return
  8326. }
  8327. userJSONBytes2, _ := json.Marshal(respJSON2)
  8328. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8329. utils.ErrorLog("解析失败:%v", err)
  8330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8331. return
  8332. }
  8333. if res2.Infcode == 0 {
  8334. flow.Ctime = time.Now().Unix()
  8335. flow.SignDigest = res2.Output.SignDigest
  8336. flow.RxFile = res2.Output.RxFile
  8337. flow.MID = his.Number
  8338. flow.Status = 1
  8339. flow.DCode = doctor_info.DoctorNumber
  8340. flow.OriginalRxFile = rx_encoded
  8341. flow.OriginalValue = encoded
  8342. flow.SignCertDn = res2.Output.SignCertDn
  8343. flow.SignCertSn = res2.Output.SignCertSn
  8344. flow.Mtime = time.Now().Unix()
  8345. service.Saveflow(flow)
  8346. c.ServeSuccessJSON(map[string]interface{}{
  8347. "msg": "预签名成功",
  8348. })
  8349. } else {
  8350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8351. return
  8352. }
  8353. }
  8354. }
  8355. func (c *HisApiController) GetCFYLJG003() {
  8356. admin_user_id, _ := c.GetInt64("admin_user_id")
  8357. his_patient_id, _ := c.GetInt64("his_patient_id")
  8358. record_time := c.GetString("record_time")
  8359. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8360. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8361. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8362. flow, _ := service.Getflowtwo(his.Number)
  8363. patient_id, _ := c.GetInt64("patient_id")
  8364. timeLayout := "2006-01-02"
  8365. loc, _ := time.LoadLocation("Local")
  8366. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8367. if err != nil {
  8368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8369. return
  8370. }
  8371. recordDateTime := theTime.Unix()
  8372. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8373. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8374. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8375. dept, _ := service.GetDepartMentDetail(info.Departments)
  8376. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8377. var cFYLJG003 models.CFYLJG003
  8378. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8379. cFYLJG003.HiRxno = flow.HiRxno
  8380. cFYLJG003.MdtrtID = flow.MID
  8381. cFYLJG003.PatnName = his.PsnName
  8382. cFYLJG003.Certno = his.Certno
  8383. cFYLJG003.FixmedinsName = miConfig.OrgName
  8384. cFYLJG003.FixmedinsCode = miConfig.Code
  8385. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8386. cFYLJG003.PrscDrName = doctor_info.UserName
  8387. cFYLJG003.PharDeptName = dept.Name
  8388. cFYLJG003.PharDeptCode = dept.Number
  8389. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8390. cFYLJG003.PharName = "孙莉侠"
  8391. cFYLJG003.PharPracCertNo = "060399"
  8392. cFYLJG003.PharCode = "HY340621000425"
  8393. cFYLJG003.PharCertType = "01"
  8394. cFYLJG003.PharCertno = ""
  8395. } else {
  8396. cFYLJG003.PharName = "彭斯遥"
  8397. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8398. cFYLJG003.PharCode = "HY440309002107"
  8399. cFYLJG003.PharCertType = "01"
  8400. cFYLJG003.PharCertno = "430482199408260023"
  8401. }
  8402. cFYLJG003.RxFile = flow.RxFile
  8403. cFYLJG003.SignDigest = flow.SignDigest
  8404. cFYLJG003.FixmedinsCode = miConfig.Code
  8405. cFYLJG003.PsnCertType = his.PsnCertType
  8406. tempTime2 := time.Unix(info.Ctime, 0)
  8407. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8408. cFYLJG003.PharChkTime = timeFormatTwo
  8409. if miConfig.MdtrtareaAdmvs == "340699" {
  8410. result, request := service.GetAHCFYLJG003("http://10.66.149.64:8080/epc/api", cFYLJG003)
  8411. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  8412. var res AHResult003
  8413. var respJSON2 map[string]interface{}
  8414. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8417. return
  8418. }
  8419. userJSONBytes2, _ := json.Marshal(respJSON2)
  8420. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8421. utils.ErrorLog("解析失败:%v", err)
  8422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8423. return
  8424. }
  8425. {
  8426. c.ServeSuccessJSON(map[string]interface{}{
  8427. "info": res,
  8428. })
  8429. }
  8430. } else {
  8431. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8432. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8433. var res ResultCFYLJG003
  8434. var respJSON2 map[string]interface{}
  8435. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8438. return
  8439. }
  8440. userJSONBytes2, _ := json.Marshal(respJSON2)
  8441. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8442. utils.ErrorLog("解析失败:%v", err)
  8443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8444. return
  8445. }
  8446. if res.Infcode == -1 {
  8447. c.ServeSuccessJSON(map[string]interface{}{
  8448. "failed_code": -10,
  8449. "msg": res.ErrMsg,
  8450. })
  8451. return
  8452. } else {
  8453. c.ServeSuccessJSON(map[string]interface{}{
  8454. "info": res.Output,
  8455. })
  8456. }
  8457. }
  8458. }
  8459. func (c *HisApiController) GetCFYLJG004() {
  8460. admin_user_id, _ := c.GetInt64("admin_user_id")
  8461. his_patient_id, _ := c.GetInt64("his_patient_id")
  8462. record_time := c.GetString("record_time")
  8463. admin_user_id = 3626
  8464. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8465. //id, _ := c.GetInt64("id")
  8466. admin_user_id = 3626
  8467. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8468. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8469. flow, _ := service.Getflowtwo(his.Number)
  8470. //id = 3
  8471. patient_id, _ := c.GetInt64("patient_id")
  8472. //patient_id = 23834
  8473. //record_time = "2023-09-18"
  8474. timeLayout := "2006-01-02"
  8475. loc, _ := time.LoadLocation("Local")
  8476. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8477. if err != nil {
  8478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8479. return
  8480. }
  8481. recordDateTime := theTime.Unix()
  8482. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8483. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8484. var cFYLJG004 models.CFYLJG004
  8485. cFYLJG004.HiRxno = flow.HiRxno
  8486. cFYLJG004.FixmedinsCode = miConfig.Code
  8487. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8488. cFYLJG004.UndoDrCertType = "01"
  8489. cFYLJG004.UndoRea = "撤销处方"
  8490. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8491. cFYLJG004.UndoDrName = doctor_info.UserName
  8492. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8493. if miConfig.MdtrtareaAdmvs == "340699" {
  8494. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8495. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8496. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  8497. } else {
  8498. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8499. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8500. var res ResultCFYLJG004
  8501. var respJSON2 map[string]interface{}
  8502. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8505. return
  8506. }
  8507. userJSONBytes2, _ := json.Marshal(respJSON2)
  8508. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8509. utils.ErrorLog("解析失败:%v", err)
  8510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8511. return
  8512. }
  8513. if res.Infcode == -1 {
  8514. c.ServeSuccessJSON(map[string]interface{}{
  8515. "failed_code": -10,
  8516. "msg": res.ErrMsg,
  8517. })
  8518. return
  8519. } else {
  8520. flow.Status = 0
  8521. service.Saveflow(flow)
  8522. c.ServeSuccessJSON(map[string]interface{}{
  8523. "msg": "撤销成功",
  8524. })
  8525. return
  8526. }
  8527. }
  8528. }
  8529. func (c *HisApiController) GetCFYLJG005() {
  8530. admin_user_id, _ := c.GetInt64("admin_user_id")
  8531. his_patient_id, _ := c.GetInt64("his_patient_id")
  8532. //record_time := c.GetString("record_time")
  8533. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8534. //id, _ := c.GetInt64("id")
  8535. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8536. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8537. flow, _ := service.Getflowtwo(his.Number)
  8538. //id = 3
  8539. var cFYLJG005 models.CFYLJG005
  8540. //patient_id, _ := c.GetInt64("patient_id")
  8541. cFYLJG005.HiRxno = flow.HiRxno
  8542. cFYLJG005.MdtrtID = flow.MID
  8543. cFYLJG005.EcToken = ""
  8544. cFYLJG005.PsnName = his.Name
  8545. cFYLJG005.PsnCertType = "01"
  8546. cFYLJG005.Certno = his.IdCardNo
  8547. if miConfig.MdtrtareaAdmvs == "340699" {
  8548. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8549. result, request := service.GetAHCFYLJG005(miConfig.Code, cFYLJG005)
  8550. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8551. } else {
  8552. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8553. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8554. var res ResultCFYLJG005
  8555. var respJSON2 map[string]interface{}
  8556. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8559. return
  8560. }
  8561. userJSONBytes2, _ := json.Marshal(respJSON2)
  8562. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8563. utils.ErrorLog("解析失败:%v", err)
  8564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8565. return
  8566. }
  8567. if res.Infcode == -1 {
  8568. c.ServeSuccessJSON(map[string]interface{}{
  8569. "failed_code": -10,
  8570. "msg": res.ErrMsg,
  8571. })
  8572. return
  8573. } else {
  8574. c.ServeSuccessJSON(map[string]interface{}{
  8575. "info": res.Output,
  8576. })
  8577. return
  8578. }
  8579. }
  8580. }
  8581. func (c *HisApiController) GetCFYLJG006() {
  8582. admin_user_id, _ := c.GetInt64("admin_user_id")
  8583. his_patient_id, _ := c.GetInt64("his_patient_id")
  8584. admin_user_id = 3626
  8585. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8586. //id, _ := c.GetInt64("id")
  8587. admin_user_id = 3626
  8588. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8589. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8590. flow, _ := service.Getflowtwo(his.Number)
  8591. //id = 3
  8592. patient_id, _ := c.GetInt64("patient_id")
  8593. var cFYLJG006 models.CFYLJG006
  8594. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8595. cFYLJG006.HiRxno = flow.HiRxno
  8596. cFYLJG006.MdtrtID = flow.MID
  8597. cFYLJG006.PsnName = patient.Name
  8598. cFYLJG006.PsnCertType = "01"
  8599. cFYLJG006.Certno = patient.IdCardNo
  8600. if miConfig.MdtrtareaAdmvs == "340699" {
  8601. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8602. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8603. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8604. } else {
  8605. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8606. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8607. var res ResultCFYLJG006
  8608. var respJSON2 map[string]interface{}
  8609. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8612. return
  8613. }
  8614. userJSONBytes2, _ := json.Marshal(respJSON2)
  8615. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8616. utils.ErrorLog("解析失败:%v", err)
  8617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8618. return
  8619. }
  8620. if res.Infcode == -1 {
  8621. c.ServeSuccessJSON(map[string]interface{}{
  8622. "failed_code": -10,
  8623. "msg": res.ErrMsg,
  8624. })
  8625. return
  8626. } else {
  8627. c.ServeSuccessJSON(map[string]interface{}{
  8628. "info": res.Output,
  8629. })
  8630. return
  8631. }
  8632. }
  8633. }
  8634. func (c *HisApiController) GetCFYLJG007() {
  8635. admin_user_id, _ := c.GetInt64("admin_user_id")
  8636. his_patient_id, _ := c.GetInt64("his_patient_id")
  8637. admin_user_id = 3626
  8638. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8639. //id, _ := c.GetInt64("id")
  8640. admin_user_id = 3626
  8641. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8642. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8643. flow, _ := service.Getflowtwo(his.Number)
  8644. //id = 3
  8645. patient_id, _ := c.GetInt64("patient_id")
  8646. var cFYLJG007 models.CFYLJG007
  8647. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8648. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8649. cFYLJG007.HiRxno = flow.HiRxno
  8650. cFYLJG007.MdtrtID = flow.MID
  8651. cFYLJG007.PsnNo = his.PsnNo
  8652. cFYLJG007.PsnCertType = "01"
  8653. cFYLJG007.Certno = patient.IdCardNo
  8654. cFYLJG007.PsnName = patient.Name
  8655. if miConfig.MdtrtareaAdmvs == "340699" {
  8656. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8657. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8658. } else {
  8659. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8660. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8661. var res ResultCFYLJG007
  8662. var respJSON2 map[string]interface{}
  8663. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8664. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8666. return
  8667. }
  8668. userJSONBytes2, _ := json.Marshal(respJSON2)
  8669. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8670. utils.ErrorLog("解析失败:%v", err)
  8671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8672. return
  8673. }
  8674. if res.Infcode == -1 {
  8675. c.ServeSuccessJSON(map[string]interface{}{
  8676. "failed_code": -10,
  8677. "msg": res.ErrMsg,
  8678. })
  8679. return
  8680. } else {
  8681. c.ServeSuccessJSON(map[string]interface{}{
  8682. "info": res,
  8683. })
  8684. return
  8685. }
  8686. }
  8687. }
  8688. func (c *HisApiController) GetCFYLJG008() {
  8689. admin_user_id, _ := c.GetInt64("admin_user_id")
  8690. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8691. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8692. var cFYLJG008 models.CFYLJG008
  8693. //id, _ := c.GetInt64("id")
  8694. patient_id, _ := c.GetInt64("patient_id")
  8695. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8696. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8697. //id = 3
  8698. //flow, _ := service.Getflow(id)
  8699. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8700. //
  8701. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8702. //patient_id, _ := c.GetInt64("patient_id")
  8703. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8704. record_time := c.GetString("record_time")
  8705. admin_user_id = 3626
  8706. patient_id = 19424
  8707. //his_patient_id = 263947
  8708. record_time = "2023-08-29"
  8709. timeLayout := "2006-01-02"
  8710. loc, _ := time.LoadLocation("Local")
  8711. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8712. if err != nil {
  8713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8714. return
  8715. }
  8716. recordDateTime := theTime.Unix()
  8717. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8718. cFYLJG008.FixmedinsName = ""
  8719. cFYLJG008.Lat = ""
  8720. cFYLJG008.Lng = ""
  8721. cFYLJG008.OrderType = "1"
  8722. cFYLJG008.PoolareaNo = ""
  8723. cFYLJG008.Lng = ""
  8724. cFYLJG008.PageNum = 1
  8725. cFYLJG008.PageSize = 10
  8726. var MPI models.MedinsProdInvChgDDTO
  8727. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8728. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8729. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8730. if miConfig.MdtrtareaAdmvs == "340699" {
  8731. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8732. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8733. } else {
  8734. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8735. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8736. var res ResultCFYLJG008
  8737. var respJSON2 map[string]interface{}
  8738. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8741. return
  8742. }
  8743. userJSONBytes2, _ := json.Marshal(respJSON2)
  8744. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8745. utils.ErrorLog("解析失败:%v", err)
  8746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8747. return
  8748. }
  8749. if res.Infcode == -1 {
  8750. c.ServeSuccessJSON(map[string]interface{}{
  8751. "failed_code": -10,
  8752. "msg": res.ErrMsg,
  8753. })
  8754. return
  8755. } else {
  8756. c.ServeSuccessJSON(map[string]interface{}{
  8757. "info": res.Output,
  8758. })
  8759. return
  8760. }
  8761. }
  8762. }
  8763. func (c *HisApiController) GetBL4201A() {
  8764. order_id, _ := c.GetInt64("order_id")
  8765. admin_user_id, _ := c.GetInt64("admin_user_id")
  8766. order, _ := service.GetHisOrderByIDTwo(order_id)
  8767. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8768. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8769. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8770. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8771. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8772. department, _ := service.GetDepartMentDetail(his.Departments)
  8773. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8774. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8775. if order.ID == 0 {
  8776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8777. return
  8778. }
  8779. var struct4201A models.Struct4201A
  8780. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8781. for _, items := range order_info {
  8782. memo := make(map[string]interface{})
  8783. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8784. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8785. fsiOPFLD.MedType = "14"
  8786. fsiOPFLD.BkkpSn = items.FeedetlSn
  8787. fsiOPFLD.FixmedinsCode = miConfig.Code
  8788. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8789. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8790. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8791. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8792. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8793. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8794. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8795. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8796. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8797. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8798. fsiOPFLD.BilgDeptName = department.Name
  8799. fsiOPFLD.BilgDeptCodg = department.Number
  8800. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8801. fsiOPFLD.BilgDrName = doctor.UserName
  8802. fsiOPFLD.MedChrgitmType = "09"
  8803. memo["hosp_appr_flag"] = "1"
  8804. memo["invoice_no"] = order.MdtrtId
  8805. memo["memo"] = "自费"
  8806. bytesData, _ := json.Marshal(memo)
  8807. fsiOPFLD.Memo = string(bytesData)
  8808. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8809. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8810. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8811. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8812. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8813. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8814. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8815. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8816. fsiOPFLD.BilgDeptName = department.Name
  8817. fsiOPFLD.BilgDeptCodg = department.Number
  8818. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8819. fsiOPFLD.BilgDrName = doctor.UserName
  8820. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8821. case 0:
  8822. break
  8823. case 1:
  8824. fsiOPFLD.MedChrgitmType = "14"
  8825. break
  8826. case 2:
  8827. fsiOPFLD.MedChrgitmType = "05"
  8828. break
  8829. case 3:
  8830. fsiOPFLD.MedChrgitmType = "03"
  8831. break
  8832. case 4:
  8833. fsiOPFLD.MedChrgitmType = "03"
  8834. break
  8835. case 5:
  8836. fsiOPFLD.MedChrgitmType = "08"
  8837. break
  8838. case 6:
  8839. fsiOPFLD.MedChrgitmType = "14"
  8840. break
  8841. case 7:
  8842. fsiOPFLD.MedChrgitmType = "14"
  8843. break
  8844. case 8:
  8845. fsiOPFLD.MedChrgitmType = "03"
  8846. break
  8847. case 9:
  8848. fsiOPFLD.MedChrgitmType = "14"
  8849. break
  8850. case 10:
  8851. fsiOPFLD.MedChrgitmType = "14"
  8852. break
  8853. case 11:
  8854. fsiOPFLD.MedChrgitmType = "06"
  8855. break
  8856. case 12:
  8857. fsiOPFLD.MedChrgitmType = "12"
  8858. break
  8859. case 13:
  8860. fsiOPFLD.MedChrgitmType = "01"
  8861. break
  8862. case 14:
  8863. fsiOPFLD.MedChrgitmType = "04"
  8864. break
  8865. case 15:
  8866. fsiOPFLD.MedChrgitmType = "14"
  8867. break
  8868. }
  8869. memo["hosp_appr_flag"] = "1"
  8870. memo["invoice_no"] = order.MdtrtId
  8871. memo["memo"] = "自费"
  8872. bytesData, _ := json.Marshal(memo)
  8873. fsiOPFLD.Memo = string(bytesData)
  8874. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8875. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8876. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8877. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8878. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8879. fsiOPFLD.BilgDeptName = department.Name
  8880. fsiOPFLD.BilgDeptCodg = department.Number
  8881. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8882. fsiOPFLD.BilgDrName = doctor.UserName
  8883. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8884. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8885. fsiOPFLD.MedChrgitmType = "08"
  8886. memo["hosp_appr_flag"] = "1"
  8887. memo["invoice_no"] = order.MdtrtId
  8888. memo["memo"] = "自费"
  8889. bytesData, _ := json.Marshal(memo)
  8890. fsiOPFLD.Memo = string(bytesData)
  8891. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8892. }
  8893. }
  8894. }
  8895. for _, items := range order_info_two {
  8896. memo := make(map[string]interface{})
  8897. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8898. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8899. fsiOPFLD.MedType = "14"
  8900. fsiOPFLD.BkkpSn = items.FeedetlSn
  8901. fsiOPFLD.FixmedinsCode = miConfig.Code
  8902. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8903. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8904. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8905. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8906. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8907. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8908. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8909. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8910. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8911. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8912. fsiOPFLD.BilgDeptName = department.Name
  8913. fsiOPFLD.BilgDeptCodg = department.Number
  8914. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8915. fsiOPFLD.BilgDrName = doctor.UserName
  8916. fsiOPFLD.MedChrgitmType = "09"
  8917. memo["hosp_appr_flag"] = "1"
  8918. memo["invoice_no"] = order.MdtrtId
  8919. memo["memo"] = "自费"
  8920. bytesData, _ := json.Marshal(memo)
  8921. fsiOPFLD.Memo = string(bytesData)
  8922. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8923. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8924. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8925. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8926. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8927. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8928. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8929. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8930. fsiOPFLD.BilgDeptName = department.Name
  8931. fsiOPFLD.BilgDeptCodg = department.Number
  8932. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8933. fsiOPFLD.BilgDrName = doctor.UserName
  8934. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8935. case 0:
  8936. break
  8937. case 1:
  8938. fsiOPFLD.MedChrgitmType = "14"
  8939. break
  8940. case 2:
  8941. fsiOPFLD.MedChrgitmType = "05"
  8942. break
  8943. case 3:
  8944. fsiOPFLD.MedChrgitmType = "03"
  8945. break
  8946. case 4:
  8947. fsiOPFLD.MedChrgitmType = "03"
  8948. break
  8949. case 5:
  8950. fsiOPFLD.MedChrgitmType = "08"
  8951. break
  8952. case 6:
  8953. fsiOPFLD.MedChrgitmType = "14"
  8954. break
  8955. case 7:
  8956. fsiOPFLD.MedChrgitmType = "14"
  8957. break
  8958. case 8:
  8959. fsiOPFLD.MedChrgitmType = "03"
  8960. break
  8961. case 9:
  8962. fsiOPFLD.MedChrgitmType = "14"
  8963. break
  8964. case 10:
  8965. fsiOPFLD.MedChrgitmType = "14"
  8966. break
  8967. case 11:
  8968. fsiOPFLD.MedChrgitmType = "06"
  8969. break
  8970. case 12:
  8971. fsiOPFLD.MedChrgitmType = "12"
  8972. break
  8973. case 13:
  8974. fsiOPFLD.MedChrgitmType = "01"
  8975. break
  8976. case 14:
  8977. fsiOPFLD.MedChrgitmType = "04"
  8978. break
  8979. case 15:
  8980. fsiOPFLD.MedChrgitmType = "14"
  8981. break
  8982. }
  8983. memo["hosp_appr_flag"] = "1"
  8984. memo["invoice_no"] = order.MdtrtId
  8985. memo["memo"] = "自费"
  8986. bytesData, _ := json.Marshal(memo)
  8987. fsiOPFLD.Memo = string(bytesData)
  8988. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8989. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8990. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8991. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8992. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8993. fsiOPFLD.BilgDeptName = department.Name
  8994. fsiOPFLD.BilgDeptCodg = department.Number
  8995. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8996. fsiOPFLD.BilgDrName = doctor.UserName
  8997. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8998. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8999. fsiOPFLD.MedChrgitmType = "08"
  9000. memo["hosp_appr_flag"] = "1"
  9001. memo["invoice_no"] = order.MdtrtId
  9002. memo["memo"] = "自费"
  9003. bytesData, _ := json.Marshal(memo)
  9004. fsiOPFLD.Memo = string(bytesData)
  9005. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9006. }
  9007. }
  9008. }
  9009. fmt.Println(fsiOPFLDs)
  9010. struct4201A.Fopfd = fsiOPFLDs
  9011. fmt.Println(struct4201A.Fopfd)
  9012. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9013. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9014. var res2 ResultSix
  9015. var respJSON2 map[string]interface{}
  9016. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9019. return
  9020. }
  9021. userJSONBytes2, _ := json.Marshal(respJSON2)
  9022. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9023. utils.ErrorLog("解析失败:%v", err)
  9024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9025. return
  9026. }
  9027. if res2.Infcode != 0 {
  9028. c.ServeSuccessJSON(map[string]interface{}{
  9029. "failed_code": -10,
  9030. "msg": res2.ErrMsg,
  9031. })
  9032. return
  9033. } else {
  9034. order.IsUploadOrderInfo = 1
  9035. service.UpdateOrder(order)
  9036. c.ServeSuccessJSON(map[string]interface{}{
  9037. "msg": "上传成功",
  9038. })
  9039. }
  9040. }
  9041. func (c *HisApiController) Get3103() {
  9042. admin_user_id, _ := c.GetInt64("admin_user_id")
  9043. warm_type, _ := c.GetInt64("warm_type")
  9044. fk_state, _ := c.GetInt64("fk_state")
  9045. warm_ids := c.GetString("warm_ids")
  9046. desc := c.GetString("desc")
  9047. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9048. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9049. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  9050. saveLog(result, requestLog, "3103", "反馈")
  9051. var res2 ResultSix3103
  9052. var respJSON2 map[string]interface{}
  9053. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9056. return
  9057. }
  9058. userJSONBytes2, _ := json.Marshal(respJSON2)
  9059. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9060. utils.ErrorLog("解析失败:%v", err)
  9061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9062. return
  9063. }
  9064. if res2.Infcode != 0 {
  9065. c.ServeSuccessJSON(map[string]interface{}{
  9066. "failed_code": -10,
  9067. "msg": res2.ErrMsg,
  9068. })
  9069. return
  9070. } else {
  9071. c.ServeSuccessJSON(map[string]interface{}{
  9072. "msg": "反馈成功",
  9073. })
  9074. return
  9075. }
  9076. }
  9077. func (c *HisApiController) Get4201A() {
  9078. order_id, _ := c.GetInt64("order_id")
  9079. admin_user_id, _ := c.GetInt64("admin_user_id")
  9080. order, _ := service.GetHisOrderByIDTwo(order_id)
  9081. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9082. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9083. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9084. //order_info = append(order_info, order_info_two...)
  9085. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9086. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9087. department, _ := service.GetDepartMentDetail(his.Departments)
  9088. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9089. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9090. if order.ID == 0 {
  9091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9092. return
  9093. }
  9094. var struct4201A models.Struct4201A
  9095. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9096. for _, items := range order_info {
  9097. memo := make(map[string]interface{})
  9098. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9099. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9100. fsiOPFLD.MedType = "14"
  9101. fsiOPFLD.BkkpSn = items.FeedetlSn
  9102. fsiOPFLD.FixmedinsCode = miConfig.Code
  9103. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9104. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9105. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9106. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9107. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9108. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9109. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9110. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9111. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9112. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9113. fsiOPFLD.BilgDeptName = department.Name
  9114. fsiOPFLD.BilgDeptCodg = department.Number
  9115. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9116. fsiOPFLD.BilgDrName = doctor.UserName
  9117. fsiOPFLD.MedChrgitmType = "09"
  9118. memo["hosp_appr_flag"] = "1"
  9119. memo["invoice_no"] = order.MdtrtId
  9120. memo["memo"] = "自费"
  9121. bytesData, _ := json.Marshal(memo)
  9122. fsiOPFLD.Memo = string(bytesData)
  9123. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9124. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9125. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9126. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9127. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9128. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9129. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9130. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9131. fsiOPFLD.BilgDeptName = department.Name
  9132. fsiOPFLD.BilgDeptCodg = department.Number
  9133. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9134. fsiOPFLD.BilgDrName = doctor.UserName
  9135. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9136. case 0:
  9137. break
  9138. case 1:
  9139. fsiOPFLD.MedChrgitmType = "14"
  9140. break
  9141. case 2:
  9142. fsiOPFLD.MedChrgitmType = "05"
  9143. break
  9144. case 3:
  9145. fsiOPFLD.MedChrgitmType = "03"
  9146. break
  9147. case 4:
  9148. fsiOPFLD.MedChrgitmType = "03"
  9149. break
  9150. case 5:
  9151. fsiOPFLD.MedChrgitmType = "08"
  9152. break
  9153. case 6:
  9154. fsiOPFLD.MedChrgitmType = "14"
  9155. break
  9156. case 7:
  9157. fsiOPFLD.MedChrgitmType = "14"
  9158. break
  9159. case 8:
  9160. fsiOPFLD.MedChrgitmType = "03"
  9161. break
  9162. case 9:
  9163. fsiOPFLD.MedChrgitmType = "14"
  9164. break
  9165. case 10:
  9166. fsiOPFLD.MedChrgitmType = "14"
  9167. break
  9168. case 11:
  9169. fsiOPFLD.MedChrgitmType = "06"
  9170. break
  9171. case 12:
  9172. fsiOPFLD.MedChrgitmType = "12"
  9173. break
  9174. case 13:
  9175. fsiOPFLD.MedChrgitmType = "01"
  9176. break
  9177. case 14:
  9178. fsiOPFLD.MedChrgitmType = "04"
  9179. break
  9180. case 15:
  9181. fsiOPFLD.MedChrgitmType = "14"
  9182. break
  9183. }
  9184. memo["hosp_appr_flag"] = "1"
  9185. memo["invoice_no"] = order.MdtrtId
  9186. memo["memo"] = "自费"
  9187. bytesData, _ := json.Marshal(memo)
  9188. fsiOPFLD.Memo = string(bytesData)
  9189. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9190. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9191. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9192. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9193. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9194. fsiOPFLD.BilgDeptName = department.Name
  9195. fsiOPFLD.BilgDeptCodg = department.Number
  9196. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9197. fsiOPFLD.BilgDrName = doctor.UserName
  9198. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9199. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9200. fsiOPFLD.MedChrgitmType = "08"
  9201. memo["hosp_appr_flag"] = "1"
  9202. memo["invoice_no"] = order.MdtrtId
  9203. memo["memo"] = "自费"
  9204. bytesData, _ := json.Marshal(memo)
  9205. fsiOPFLD.Memo = string(bytesData)
  9206. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9207. }
  9208. }
  9209. }
  9210. for _, items := range order_info_two {
  9211. memo := make(map[string]interface{})
  9212. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9213. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9214. fsiOPFLD.MedType = "14"
  9215. fsiOPFLD.BkkpSn = items.FeedetlSn
  9216. fsiOPFLD.FixmedinsCode = miConfig.Code
  9217. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9218. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9219. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9220. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9221. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9222. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9223. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9224. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9225. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9226. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9227. fsiOPFLD.BilgDeptName = department.Name
  9228. fsiOPFLD.BilgDeptCodg = department.Number
  9229. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9230. fsiOPFLD.BilgDrName = doctor.UserName
  9231. fsiOPFLD.MedChrgitmType = "09"
  9232. memo["hosp_appr_flag"] = "1"
  9233. memo["invoice_no"] = order.MdtrtId
  9234. memo["memo"] = "自费"
  9235. bytesData, _ := json.Marshal(memo)
  9236. fsiOPFLD.Memo = string(bytesData)
  9237. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9238. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9239. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9240. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9241. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9242. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9243. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9244. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9245. fsiOPFLD.BilgDeptName = department.Name
  9246. fsiOPFLD.BilgDeptCodg = department.Number
  9247. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9248. fsiOPFLD.BilgDrName = doctor.UserName
  9249. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9250. case 0:
  9251. break
  9252. case 1:
  9253. fsiOPFLD.MedChrgitmType = "14"
  9254. break
  9255. case 2:
  9256. fsiOPFLD.MedChrgitmType = "05"
  9257. break
  9258. case 3:
  9259. fsiOPFLD.MedChrgitmType = "03"
  9260. break
  9261. case 4:
  9262. fsiOPFLD.MedChrgitmType = "03"
  9263. break
  9264. case 5:
  9265. fsiOPFLD.MedChrgitmType = "08"
  9266. break
  9267. case 6:
  9268. fsiOPFLD.MedChrgitmType = "14"
  9269. break
  9270. case 7:
  9271. fsiOPFLD.MedChrgitmType = "14"
  9272. break
  9273. case 8:
  9274. fsiOPFLD.MedChrgitmType = "03"
  9275. break
  9276. case 9:
  9277. fsiOPFLD.MedChrgitmType = "14"
  9278. break
  9279. case 10:
  9280. fsiOPFLD.MedChrgitmType = "14"
  9281. break
  9282. case 11:
  9283. fsiOPFLD.MedChrgitmType = "06"
  9284. break
  9285. case 12:
  9286. fsiOPFLD.MedChrgitmType = "12"
  9287. break
  9288. case 13:
  9289. fsiOPFLD.MedChrgitmType = "01"
  9290. break
  9291. case 14:
  9292. fsiOPFLD.MedChrgitmType = "04"
  9293. break
  9294. case 15:
  9295. fsiOPFLD.MedChrgitmType = "14"
  9296. break
  9297. }
  9298. memo["hosp_appr_flag"] = "1"
  9299. memo["invoice_no"] = order.MdtrtId
  9300. memo["memo"] = "自费"
  9301. bytesData, _ := json.Marshal(memo)
  9302. fsiOPFLD.Memo = string(bytesData)
  9303. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9304. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9305. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9306. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9307. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9308. fsiOPFLD.BilgDeptName = department.Name
  9309. fsiOPFLD.BilgDeptCodg = department.Number
  9310. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9311. fsiOPFLD.BilgDrName = doctor.UserName
  9312. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9313. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9314. fsiOPFLD.MedChrgitmType = "08"
  9315. memo["hosp_appr_flag"] = "1"
  9316. memo["invoice_no"] = order.MdtrtId
  9317. memo["memo"] = "自费"
  9318. bytesData, _ := json.Marshal(memo)
  9319. fsiOPFLD.Memo = string(bytesData)
  9320. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9321. }
  9322. }
  9323. }
  9324. fmt.Println(fsiOPFLDs)
  9325. struct4201A.Fopfd = fsiOPFLDs
  9326. fmt.Println(struct4201A.Fopfd)
  9327. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9328. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9329. var res2 ResultSix
  9330. var respJSON2 map[string]interface{}
  9331. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9334. return
  9335. }
  9336. userJSONBytes2, _ := json.Marshal(respJSON2)
  9337. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9338. utils.ErrorLog("解析失败:%v", err)
  9339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9340. return
  9341. }
  9342. if res2.Infcode != 0 {
  9343. c.ServeSuccessJSON(map[string]interface{}{
  9344. "failed_code": -10,
  9345. "msg": res2.ErrMsg,
  9346. })
  9347. return
  9348. } else {
  9349. order.IsUploadOrderInfo = 1
  9350. service.UpdateOrder(order)
  9351. c.ServeSuccessJSON(map[string]interface{}{
  9352. "msg": "上传成功",
  9353. })
  9354. }
  9355. }
  9356. func (c *HisApiController) Get4202() {
  9357. order_id, _ := c.GetInt64("order_id")
  9358. admin_user_id, _ := c.GetInt64("admin_user_id")
  9359. order, _ := service.GetHisOrderByIDTwo(order_id)
  9360. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9361. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9362. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9363. if order.ID == 0 {
  9364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9365. return
  9366. }
  9367. var struct4202 models.Struct4202
  9368. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9369. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9370. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9371. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9372. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9373. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9374. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9375. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9376. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9377. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9378. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9379. var config []*models.HisXtDiagnoseConfig
  9380. for _, item := range diagnosis_ids {
  9381. id, _ := strconv.ParseInt(item, 10, 64)
  9382. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9383. config = append(config, &diagnosisConfig)
  9384. }
  9385. var tempDiaginfos []models.OwnPayPatnDiagListD
  9386. for index, item := range config {
  9387. if index == 0 {
  9388. var tempDiaginfo models.OwnPayPatnDiagListD
  9389. tempDiaginfo.InoutDiagType = "1"
  9390. tempDiaginfo.DiagCode = item.CountryCode
  9391. tempDiaginfo.DiagName = item.CountryContentName
  9392. tempDiaginfo.DiagType = "1"
  9393. tempDiaginfo.DiagSrtNo = "1"
  9394. tempDiaginfo.MaindiagFlag = "1"
  9395. tempDiaginfo.ValiFlag = "1"
  9396. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9397. } else {
  9398. var tempDiaginfo models.OwnPayPatnDiagListD
  9399. tempDiaginfo.DiagCode = item.CountryCode
  9400. tempDiaginfo.DiagName = item.CountryContentName
  9401. tempDiaginfo.DiagType = "2"
  9402. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9403. tempDiaginfo.MaindiagFlag = "0"
  9404. tempDiaginfo.ValiFlag = "1"
  9405. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9406. }
  9407. }
  9408. struct4202.ODiagListD = tempDiaginfos
  9409. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9410. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9411. var res2 ResultSix
  9412. var respJSON2 map[string]interface{}
  9413. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9416. return
  9417. }
  9418. userJSONBytes2, _ := json.Marshal(respJSON2)
  9419. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9420. utils.ErrorLog("解析失败:%v", err)
  9421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9422. return
  9423. }
  9424. if res2.Infcode != 0 {
  9425. c.ServeSuccessJSON(map[string]interface{}{
  9426. "failed_code": -10,
  9427. "msg": res2.ErrMsg,
  9428. })
  9429. return
  9430. } else {
  9431. order.IsUploadDiagnose = 1
  9432. service.UpdateOrder(order)
  9433. c.ServeSuccessJSON(map[string]interface{}{
  9434. "msg": "上传成功",
  9435. })
  9436. }
  9437. }
  9438. func (c *HisApiController) Get4203() {
  9439. admin_user_id, _ := c.GetInt64("admin_user_id")
  9440. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9441. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9442. order_id, _ := c.GetInt64("order_id")
  9443. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9444. number := ""
  9445. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9446. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9447. if his.ID == 0 {
  9448. number = hospital.Number
  9449. } else {
  9450. number = his.Number
  9451. }
  9452. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9453. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9454. var res2 ResultSix
  9455. var respJSON2 map[string]interface{}
  9456. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9459. return
  9460. }
  9461. userJSONBytes2, _ := json.Marshal(respJSON2)
  9462. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9463. utils.ErrorLog("解析失败:%v", err)
  9464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9465. return
  9466. }
  9467. if res2.Infcode != 0 {
  9468. c.ServeSuccessJSON(map[string]interface{}{
  9469. "failed_code": -10,
  9470. "msg": res2.ErrMsg,
  9471. })
  9472. return
  9473. } else {
  9474. order.IsUploadSuccess = 1
  9475. service.UpdateOrderTwo(order)
  9476. c.ServeSuccessJSON(map[string]interface{}{
  9477. "msg": "上传成功",
  9478. })
  9479. }
  9480. }
  9481. func (c *HisApiController) Get4205() {
  9482. order_id, _ := c.GetInt64("order_id")
  9483. admin_user_id, _ := c.GetInt64("admin_user_id")
  9484. fapiao_code := c.GetString("fapiao_code")
  9485. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9486. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9487. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9488. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9489. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9490. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9491. //order_info = append(order_info, order_info_two...)
  9492. department, _ := service.GetDepartMentDetail(his.Departments)
  9493. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9494. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9495. if order.ID == 0 {
  9496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9497. return
  9498. }
  9499. var struct4201A models.Struct4201A
  9500. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9501. for _, items := range order_info {
  9502. memo := make(map[string]interface{})
  9503. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9504. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9505. fsiOPFLD.MedType = pre.MedType
  9506. fsiOPFLD.FixmedinsCode = miConfig.Code
  9507. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9508. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9509. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9510. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9511. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9512. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.StartTime, 0).Format("2006-01-02 15:04:05")
  9513. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9514. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9515. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9516. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9517. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9518. fsiOPFLD.BilgDeptName = department.Name
  9519. fsiOPFLD.BilgDeptCodg = department.Number
  9520. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9521. fsiOPFLD.BilgDrName = doctor.UserName
  9522. fsiOPFLD.MedChrgitmType = "09"
  9523. memo["hosp_appr_flag"] = "1"
  9524. memo["invoice_no"] = fapiao_code
  9525. memo["memo"] = "自费"
  9526. bytesData, _ := json.Marshal(memo)
  9527. fsiOPFLD.Memo = string(bytesData)
  9528. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9529. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9530. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9531. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9532. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.StartTime, 0).Format("2006-01-02 15:04:05")
  9533. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9534. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9535. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9536. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9537. fsiOPFLD.BilgDeptName = department.Name
  9538. fsiOPFLD.BilgDeptCodg = department.Number
  9539. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9540. fsiOPFLD.BilgDrName = doctor.UserName
  9541. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9542. case 0:
  9543. break
  9544. case 1:
  9545. fsiOPFLD.MedChrgitmType = "14"
  9546. break
  9547. case 2:
  9548. fsiOPFLD.MedChrgitmType = "05"
  9549. break
  9550. case 3:
  9551. fsiOPFLD.MedChrgitmType = "03"
  9552. break
  9553. case 4:
  9554. fsiOPFLD.MedChrgitmType = "03"
  9555. break
  9556. case 5:
  9557. fsiOPFLD.MedChrgitmType = "08"
  9558. break
  9559. case 6:
  9560. fsiOPFLD.MedChrgitmType = "14"
  9561. break
  9562. case 7:
  9563. fsiOPFLD.MedChrgitmType = "14"
  9564. break
  9565. case 8:
  9566. fsiOPFLD.MedChrgitmType = "03"
  9567. break
  9568. case 9:
  9569. fsiOPFLD.MedChrgitmType = "14"
  9570. break
  9571. case 10:
  9572. fsiOPFLD.MedChrgitmType = "14"
  9573. break
  9574. case 11:
  9575. fsiOPFLD.MedChrgitmType = "06"
  9576. break
  9577. case 12:
  9578. fsiOPFLD.MedChrgitmType = "12"
  9579. break
  9580. case 13:
  9581. fsiOPFLD.MedChrgitmType = "01"
  9582. break
  9583. case 14:
  9584. fsiOPFLD.MedChrgitmType = "04"
  9585. break
  9586. case 15:
  9587. fsiOPFLD.MedChrgitmType = "14"
  9588. break
  9589. }
  9590. memo["hosp_appr_flag"] = "1"
  9591. memo["invoice_no"] = fapiao_code
  9592. memo["memo"] = "自费"
  9593. bytesData, _ := json.Marshal(memo)
  9594. fsiOPFLD.Memo = string(bytesData)
  9595. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9596. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9597. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9598. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9599. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9600. fsiOPFLD.BilgDeptName = department.Name
  9601. fsiOPFLD.BilgDeptCodg = department.Number
  9602. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9603. fsiOPFLD.BilgDrName = doctor.UserName
  9604. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9605. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9606. fsiOPFLD.MedChrgitmType = "08"
  9607. memo["hosp_appr_flag"] = "1"
  9608. memo["invoice_no"] = fapiao_code
  9609. memo["memo"] = "自费"
  9610. bytesData, _ := json.Marshal(memo)
  9611. fsiOPFLD.Memo = string(bytesData)
  9612. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9613. }
  9614. }
  9615. }
  9616. for _, items := range order_info_two {
  9617. memo := make(map[string]interface{})
  9618. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9619. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9620. fsiOPFLD.MedType = pre.MedType
  9621. fsiOPFLD.BkkpSn = items.FeedetlSn
  9622. fsiOPFLD.FixmedinsCode = miConfig.Code
  9623. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9624. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9625. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9626. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9627. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9628. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9629. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9630. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9631. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9632. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9633. fsiOPFLD.BilgDeptName = department.Name
  9634. fsiOPFLD.BilgDeptCodg = department.Number
  9635. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9636. fsiOPFLD.BilgDrName = doctor.UserName
  9637. fsiOPFLD.MedChrgitmType = "09"
  9638. memo["hosp_appr_flag"] = "1"
  9639. memo["invoice_no"] = fapiao_code
  9640. memo["memo"] = "自费"
  9641. bytesData, _ := json.Marshal(memo)
  9642. fsiOPFLD.Memo = string(bytesData)
  9643. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9644. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9645. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9646. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9647. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9648. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9649. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9650. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9651. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9652. fsiOPFLD.BilgDeptName = department.Name
  9653. fsiOPFLD.BilgDeptCodg = department.Number
  9654. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9655. fsiOPFLD.BilgDrName = doctor.UserName
  9656. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9657. case 0:
  9658. break
  9659. case 1:
  9660. fsiOPFLD.MedChrgitmType = "14"
  9661. break
  9662. case 2:
  9663. fsiOPFLD.MedChrgitmType = "05"
  9664. break
  9665. case 3:
  9666. fsiOPFLD.MedChrgitmType = "03"
  9667. break
  9668. case 4:
  9669. fsiOPFLD.MedChrgitmType = "03"
  9670. break
  9671. case 5:
  9672. fsiOPFLD.MedChrgitmType = "08"
  9673. break
  9674. case 6:
  9675. fsiOPFLD.MedChrgitmType = "14"
  9676. break
  9677. case 7:
  9678. fsiOPFLD.MedChrgitmType = "14"
  9679. break
  9680. case 8:
  9681. fsiOPFLD.MedChrgitmType = "03"
  9682. break
  9683. case 9:
  9684. fsiOPFLD.MedChrgitmType = "14"
  9685. break
  9686. case 10:
  9687. fsiOPFLD.MedChrgitmType = "14"
  9688. break
  9689. case 11:
  9690. fsiOPFLD.MedChrgitmType = "06"
  9691. break
  9692. case 12:
  9693. fsiOPFLD.MedChrgitmType = "12"
  9694. break
  9695. case 13:
  9696. fsiOPFLD.MedChrgitmType = "01"
  9697. break
  9698. case 14:
  9699. fsiOPFLD.MedChrgitmType = "04"
  9700. break
  9701. case 15:
  9702. fsiOPFLD.MedChrgitmType = "14"
  9703. break
  9704. }
  9705. memo["hosp_appr_flag"] = "1"
  9706. memo["invoice_no"] = fapiao_code
  9707. memo["memo"] = "自费"
  9708. bytesData, _ := json.Marshal(memo)
  9709. fsiOPFLD.Memo = string(bytesData)
  9710. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9711. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9712. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9713. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9714. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9715. fsiOPFLD.BilgDeptName = department.Name
  9716. fsiOPFLD.BilgDeptCodg = department.Number
  9717. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9718. fsiOPFLD.BilgDrName = doctor.UserName
  9719. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9720. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9721. fsiOPFLD.MedChrgitmType = "08"
  9722. memo["hosp_appr_flag"] = "1"
  9723. memo["invoice_no"] = fapiao_code
  9724. memo["memo"] = "自费"
  9725. bytesData, _ := json.Marshal(memo)
  9726. fsiOPFLD.Memo = string(bytesData)
  9727. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9728. }
  9729. }
  9730. }
  9731. fmt.Println(fsiOPFLDs)
  9732. struct4201A.Fopfd = fsiOPFLDs
  9733. fmt.Println(struct4201A.Fopfd)
  9734. var struct4202 models.Struct4202
  9735. timeLayout := "2006-01-02 15:04:05"
  9736. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9737. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9738. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9739. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9740. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9741. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9742. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9743. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9744. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9745. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9746. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9747. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9748. var config []*models.HisXtDiagnoseConfig
  9749. for _, item := range diagnosis_ids {
  9750. id, _ := strconv.ParseInt(item, 10, 64)
  9751. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9752. config = append(config, &diagnosisConfig)
  9753. }
  9754. var tempDiaginfos []models.OwnPayPatnDiagListD
  9755. for index, item := range config {
  9756. if index == 0 {
  9757. var tempDiaginfo models.OwnPayPatnDiagListD
  9758. tempDiaginfo.InoutDiagType = "1"
  9759. tempDiaginfo.DiagCode = item.CountryCode
  9760. tempDiaginfo.DiagName = item.CountryContentName
  9761. tempDiaginfo.DiagType = "1"
  9762. tempDiaginfo.DiagSrtNo = "1"
  9763. tempDiaginfo.MaindiagFlag = "1"
  9764. tempDiaginfo.ValiFlag = "1"
  9765. tempDiaginfo.DiagDrName = doctor.UserName
  9766. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9767. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9768. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9769. } else {
  9770. var tempDiaginfo models.OwnPayPatnDiagListD
  9771. tempDiaginfo.DiagCode = item.CountryCode
  9772. tempDiaginfo.DiagName = item.CountryContentName
  9773. tempDiaginfo.DiagType = "2"
  9774. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9775. tempDiaginfo.MaindiagFlag = "0"
  9776. tempDiaginfo.ValiFlag = "1"
  9777. tempDiaginfo.DiagDrName = doctor.UserName
  9778. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9779. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9780. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9781. }
  9782. }
  9783. struct4202.ODiagListD = tempDiaginfos
  9784. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9785. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9786. var res2 ResultSix
  9787. var respJSON2 map[string]interface{}
  9788. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9791. return
  9792. }
  9793. userJSONBytes2, _ := json.Marshal(respJSON2)
  9794. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9795. utils.ErrorLog("解析失败:%v", err)
  9796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9797. return
  9798. }
  9799. if res2.Infcode != 0 {
  9800. c.ServeSuccessJSON(map[string]interface{}{
  9801. "failed_code": -10,
  9802. "msg": res2.ErrMsg,
  9803. })
  9804. return
  9805. } else {
  9806. order.IsUploadDiagnose = 1
  9807. order.IsUploadOrderInfo = 1
  9808. service.UpdateOrderTwo(order)
  9809. c.ServeSuccessJSON(map[string]interface{}{
  9810. "msg": "上传成功",
  9811. })
  9812. }
  9813. }
  9814. func (c *HisApiController) Get4207() {
  9815. admin_user_id, _ := c.GetInt64("admin_user_id")
  9816. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9817. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9818. order_id, _ := c.GetInt64("order_id")
  9819. order, _ := service.GetHisOrderByIDTwo(order_id)
  9820. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9821. var struct4207 models.Struct4207
  9822. struct4207.PageNum = "1"
  9823. struct4207.PageSize = "1000"
  9824. struct4207.FixmedinsCode = miConfig.Code
  9825. struct4207.FixmedinsMdtrtID = order.Number
  9826. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9827. saveLog(result, requestLog, "4207", "查询")
  9828. var res2 ResultSix
  9829. var respJSON2 map[string]interface{}
  9830. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9833. return
  9834. }
  9835. userJSONBytes2, _ := json.Marshal(respJSON2)
  9836. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9837. utils.ErrorLog("解析失败:%v", err)
  9838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9839. return
  9840. }
  9841. if res2.Infcode != 0 {
  9842. c.ServeSuccessJSON(map[string]interface{}{
  9843. "failed_code": -10,
  9844. "msg": res2.ErrMsg,
  9845. })
  9846. return
  9847. } else {
  9848. c.ServeSuccessJSON(map[string]interface{}{
  9849. "msg": "查询成功",
  9850. })
  9851. }
  9852. }
  9853. func (c *HisApiController) Get4208() {
  9854. admin_user_id, _ := c.GetInt64("admin_user_id")
  9855. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9856. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9857. order_id, _ := c.GetInt64("order_id")
  9858. order, _ := service.GetHisOrderByIDTwo(order_id)
  9859. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9860. var struct4208 models.Struct4208
  9861. struct4208.PageNum = "1"
  9862. struct4208.PageSize = "1000"
  9863. struct4208.PsnCertType = "01"
  9864. struct4208.Certno = his.Certno
  9865. struct4208.MedType = order.MedType
  9866. struct4208.PsnName = his.Name
  9867. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9868. saveLog(result, requestLog, "4208", "查询")
  9869. var res2 ResultSix
  9870. var respJSON2 map[string]interface{}
  9871. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9874. return
  9875. }
  9876. userJSONBytes2, _ := json.Marshal(respJSON2)
  9877. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9878. utils.ErrorLog("解析失败:%v", err)
  9879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9880. return
  9881. }
  9882. if res2.Infcode != 0 {
  9883. c.ServeSuccessJSON(map[string]interface{}{
  9884. "failed_code": -10,
  9885. "msg": res2.ErrMsg,
  9886. })
  9887. return
  9888. } else {
  9889. c.ServeSuccessJSON(map[string]interface{}{
  9890. "msg": "查询成功",
  9891. })
  9892. }
  9893. }
  9894. func (c *HisApiController) Get4209() {
  9895. admin_user_id, _ := c.GetInt64("admin_user_id")
  9896. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9897. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9898. order_id, _ := c.GetInt64("order_id")
  9899. order, _ := service.GetHisOrderByIDTwo(order_id)
  9900. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9901. var struct4209 models.Struct4209
  9902. struct4209.FixmedinsMdtrtID = order.Number
  9903. struct4209.FixmedinsCode = miConfig.Code
  9904. struct4209.PageSize = "1000"
  9905. struct4209.PageNum = "1"
  9906. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9907. saveLog(result, requestLog, "4209", "查询")
  9908. var res2 ResultSix
  9909. var respJSON2 map[string]interface{}
  9910. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9913. return
  9914. }
  9915. userJSONBytes2, _ := json.Marshal(respJSON2)
  9916. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9917. utils.ErrorLog("解析失败:%v", err)
  9918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9919. return
  9920. }
  9921. if res2.Infcode != 0 {
  9922. c.ServeSuccessJSON(map[string]interface{}{
  9923. "failed_code": -10,
  9924. "msg": res2.ErrMsg,
  9925. })
  9926. return
  9927. } else {
  9928. c.ServeSuccessJSON(map[string]interface{}{
  9929. "msg": "查询成功",
  9930. })
  9931. }
  9932. }
  9933. type Result3101 struct {
  9934. Infcode string `json:"infcode"`
  9935. InfRefmsgid string `json:"inf_refmsgid"`
  9936. RefmsgTime string `json:"refmsg_time"`
  9937. RespondTime string `json:"respond_time"`
  9938. Enctype string `json:"enctype"`
  9939. Signtype string `json:"signtype"`
  9940. ErrMsg string `json:"err_msg"`
  9941. Output struct {
  9942. Result []struct {
  9943. JudgeResultDetailDtos []struct {
  9944. VolaItemType string `json:"vola_item_type"`
  9945. MdtrtID string `json:"mdtrt_id"`
  9946. JrdID string `json:"jrd_id"`
  9947. PatnID string `json:"patn_id"`
  9948. RxID string `json:"rx_id"`
  9949. VolaAmt interface{} `json:"vola_amt"`
  9950. } `json:"judge_result_detail_dtos"`
  9951. RuleID string `json:"rule_id"`
  9952. VolaEvid string `json:"vola_evid"`
  9953. MdtrtID string `json:"mdtrt_id"`
  9954. RuleName string `json:"rule_name"`
  9955. VolaAmtStas string `json:"vola_amt_stas"`
  9956. JrID string `json:"jr_id"`
  9957. PatnID string `json:"patn_id"`
  9958. SevDeg string `json:"sev_deg"`
  9959. VolaAmt float64 `json:"vola_amt"`
  9960. VolaBhvrType string `json:"vola_bhvr_type"`
  9961. VolaCont string `json:"vola_cont"`
  9962. } `json:"result"`
  9963. } `json:"output"`
  9964. }
  9965. type Resultgd3101 struct {
  9966. Infcode int64 `json:"infcode"`
  9967. InfRefmsgid string `json:"inf_refmsgid"`
  9968. RefmsgTime string `json:"refmsg_time"`
  9969. RespondTime string `json:"respond_time"`
  9970. Enctype string `json:"enctype"`
  9971. Signtype string `json:"signtype"`
  9972. ErrMsg string `json:"err_msg"`
  9973. Output struct {
  9974. Result []struct {
  9975. JudgeResultDetailDtos []struct {
  9976. VolaItemType string `json:"vola_item_type"`
  9977. MdtrtID string `json:"mdtrt_id"`
  9978. JrdID string `json:"jrd_id"`
  9979. PatnID string `json:"patn_id"`
  9980. RxID string `json:"rx_id"`
  9981. VolaAmt interface{} `json:"vola_amt"`
  9982. } `json:"judge_result_detail_dtos"`
  9983. RuleID string `json:"rule_id"`
  9984. VolaEvid string `json:"vola_evid"`
  9985. MdtrtID string `json:"mdtrt_id"`
  9986. RuleName string `json:"rule_name"`
  9987. VolaAmtStas string `json:"vola_amt_stas"`
  9988. JrID string `json:"jr_id"`
  9989. PatnID string `json:"patn_id"`
  9990. SevDeg string `json:"sev_deg"`
  9991. VolaAmt float64 `json:"vola_amt"`
  9992. VolaBhvrType string `json:"vola_bhvr_type"`
  9993. VolaCont string `json:"vola_cont"`
  9994. } `json:"result"`
  9995. } `json:"output"`
  9996. }
  9997. func (c *HisApiController) ReadEleToken() {
  9998. admin_user_id, _ := c.GetInt64("admin_user_id")
  9999. his_patient_id, _ := c.GetInt64("his_patient_id")
  10000. adminUser := c.GetAdminUserInfo()
  10001. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10002. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10003. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10004. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10005. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10006. if len(tokens) > 0 {
  10007. c.ServeSuccessJSON(map[string]interface{}{
  10008. "msg": "读取成功",
  10009. })
  10010. } else {
  10011. c.ServeSuccessJSON(map[string]interface{}{
  10012. "failed_code": -10,
  10013. "msg": "读取失败",
  10014. })
  10015. }
  10016. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10017. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10018. if len(tokens) > 0 {
  10019. c.ServeSuccessJSON(map[string]interface{}{
  10020. "msg": "读取成功",
  10021. })
  10022. } else {
  10023. c.ServeSuccessJSON(map[string]interface{}{
  10024. "failed_code": -10,
  10025. "msg": "读取失败",
  10026. })
  10027. }
  10028. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10029. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10030. if len(tokens) > 0 {
  10031. c.ServeSuccessJSON(map[string]interface{}{
  10032. "msg": "读取成功",
  10033. })
  10034. } else {
  10035. c.ServeSuccessJSON(map[string]interface{}{
  10036. "failed_code": -10,
  10037. "msg": "读取失败",
  10038. })
  10039. }
  10040. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10041. var api string
  10042. 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 +
  10043. "&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"
  10044. resp, requestErr := http.Get(api)
  10045. if requestErr != nil {
  10046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10047. }
  10048. body, ioErr := ioutil.ReadAll(resp.Body)
  10049. if ioErr != nil {
  10050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10052. }
  10053. var respJSON map[string]interface{}
  10054. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10057. return
  10058. }
  10059. var status string
  10060. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10061. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10062. var token string
  10063. var res ResultTwo //1101结果
  10064. var res10265 ResultTwo10265 //1101结果
  10065. if status == "0" { //读卡成功
  10066. var card_info string //卡信息
  10067. var busi_card_info string
  10068. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10069. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10070. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10071. fmt.Println(card_info)
  10072. fmt.Println(busi_card_info)
  10073. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10074. result, _ := json.Marshal(respJSON)
  10075. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10076. utils.ErrorLog("解析失败:%v", err)
  10077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10078. return
  10079. }
  10080. res.ErrMsg = res10265.ErrMsg
  10081. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10082. res.Infcode = infocode
  10083. res.Output = res10265.Output
  10084. res.InfRefmsgid = res10265.InfRefmsgid
  10085. if res.Infcode == 0 {
  10086. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10087. if err == gorm.ErrRecordNotFound {
  10088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10089. return
  10090. } else if err != nil {
  10091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10092. return
  10093. } else {
  10094. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10095. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10096. infoStr := string(Iinfos)
  10097. idetinfoStr := string(Idetinfos)
  10098. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  10099. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10100. psn := &models.HisPsn{
  10101. PsnNo: res.Output.Baseinfo.PsnNo,
  10102. PatientId: patient.ID,
  10103. Certno: res.Output.Baseinfo.Certno,
  10104. Gend: res.Output.Baseinfo.Gend,
  10105. Naty: res.Output.Baseinfo.Naty,
  10106. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10107. PsnName: res.Output.Baseinfo.PsnName,
  10108. Age: float64(age),
  10109. Brdy: b,
  10110. Idetinfo: idetinfoStr,
  10111. Insuinfo: infoStr,
  10112. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10113. CardInfo: card_info,
  10114. VerifyNumber: token,
  10115. IdCardType: 4,
  10116. }
  10117. var rf []*ResultFive
  10118. json.Unmarshal([]byte(infoStr), &rf)
  10119. var insutypes []*ResultFive
  10120. var insutype string
  10121. var is390 int = 0
  10122. var is310 int = 0
  10123. for _, item := range rf {
  10124. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10125. insutypes = append(insutypes, item)
  10126. }
  10127. }
  10128. if len(insutypes) == 1 {
  10129. insutype = insutypes[0].Insutype
  10130. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10131. } else {
  10132. for _, i := range insutypes {
  10133. if i.Insutype == "390" {
  10134. is390 = 1
  10135. }
  10136. if i.Insutype == "310" {
  10137. is310 = 1
  10138. }
  10139. }
  10140. }
  10141. if is390 == 1 {
  10142. insutype = "390"
  10143. }
  10144. if is310 == 1 {
  10145. insutype = "310"
  10146. }
  10147. if len(insutypes) == 0 {
  10148. insutype = "310"
  10149. }
  10150. service.CreateHisPsn(psn)
  10151. c.ServeSuccessJSON(map[string]interface{}{
  10152. "patient": patient,
  10153. "number": token,
  10154. "insutype": insutype,
  10155. })
  10156. }
  10157. } else {
  10158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10159. return
  10160. }
  10161. } else { //读卡失败
  10162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10163. return
  10164. }
  10165. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10166. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  10167. if len(errMsg) == 0 {
  10168. type ELeData struct {
  10169. Data struct {
  10170. IdNo string `json:"idNo"`
  10171. IdType string `json:"idType"`
  10172. UserName string `json:"userName"`
  10173. EcToken string `json:"ecToken"`
  10174. InsuOrg string `json:"insuOrg"`
  10175. Gender string `json:"gender"`
  10176. Birthday string `json:"birthday"`
  10177. Nationality string `json:"nationality"`
  10178. Email string `json:"email"`
  10179. Extra string `json:"extra"`
  10180. } `json:"data"`
  10181. Code int `json:"code"`
  10182. Message string `json:"message"`
  10183. }
  10184. var ele ELeData
  10185. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10186. if err != nil {
  10187. utils.ErrorLog("解析失败:%v", err)
  10188. }
  10189. token := ele.Data.EcToken
  10190. if len(token) > 0 {
  10191. psn := &models.HisPsn{
  10192. PsnNo: his.PsnNo,
  10193. Age: 0,
  10194. PatientId: his.PatientId,
  10195. Certno: his.Certno,
  10196. Brdy: his.Brdy,
  10197. Gend: his.Gend,
  10198. Naty: his.Naty,
  10199. PsnCertType: his.PsnCertType,
  10200. PsnName: his.PsnName,
  10201. Idetinfo: his.Idetinfo,
  10202. Insuinfo: his.Iinfo,
  10203. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10204. CardInfo: outPutInfo,
  10205. VerifyNumber: token,
  10206. }
  10207. service.CreateHisPsn(psn)
  10208. }
  10209. if len(token) > 0 {
  10210. c.ServeSuccessJSON(map[string]interface{}{
  10211. "msg": "读取成功",
  10212. })
  10213. } else {
  10214. c.ServeSuccessJSON(map[string]interface{}{
  10215. "failed_code": -10,
  10216. "msg": "读取失败",
  10217. })
  10218. }
  10219. }
  10220. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10221. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10222. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10223. type ELeData struct {
  10224. Data struct {
  10225. IdNo string `json:"idNo"`
  10226. IdType string `json:"idType"`
  10227. UserName string `json:"userName"`
  10228. EcToken string `json:"ecToken"`
  10229. InsuOrg string `json:"insuOrg"`
  10230. Gender string `json:"gender"`
  10231. Birthday string `json:"birthday"`
  10232. Nationality string `json:"nationality"`
  10233. Email string `json:"email"`
  10234. Extra string `json:"extra"`
  10235. } `json:"data"`
  10236. Code int `json:"code"`
  10237. Message string `json:"message"`
  10238. }
  10239. var ele ELeData
  10240. err := json.Unmarshal([]byte(result), &ele)
  10241. if err != nil {
  10242. utils.ErrorLog("解析失败:%v", err)
  10243. }
  10244. token := ele.Data.EcToken
  10245. token = Remove0000(token)
  10246. fmt.Println(ele.Data.UserName)
  10247. 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)
  10248. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10249. var res ResultTwo
  10250. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10251. utils.ErrorLog("解析失败:%v", err)
  10252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10253. return
  10254. }
  10255. if res.Infcode == 0 {
  10256. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10257. if err == gorm.ErrRecordNotFound {
  10258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10259. return
  10260. } else if err != nil {
  10261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10262. return
  10263. } else {
  10264. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10265. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10266. infoStr := string(Iinfos)
  10267. idetinfoStr := string(Idetinfos)
  10268. psn := &models.HisPsn{
  10269. PsnNo: res.Output.Baseinfo.PsnNo,
  10270. PatientId: patient.ID,
  10271. Certno: res.Output.Baseinfo.Certno,
  10272. Gend: res.Output.Baseinfo.Gend,
  10273. Naty: res.Output.Baseinfo.Naty,
  10274. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10275. PsnName: res.Output.Baseinfo.PsnName,
  10276. Idetinfo: idetinfoStr,
  10277. Insuinfo: infoStr,
  10278. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10279. CardInfo: "",
  10280. VerifyNumber: token,
  10281. }
  10282. service.CreateHisPsn(psn)
  10283. c.ServeSuccessJSON(map[string]interface{}{
  10284. "patient": patient,
  10285. "number": token,
  10286. })
  10287. }
  10288. } else {
  10289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10290. return
  10291. }
  10292. } else if miConfig.MdtrtareaAdmvs == "361025" {
  10293. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10294. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10295. type ELeData struct {
  10296. Data struct {
  10297. IdNo string `json:"idNo"`
  10298. IdType string `json:"idType"`
  10299. UserName string `json:"userName"`
  10300. EcToken string `json:"ecToken"`
  10301. InsuOrg string `json:"insuOrg"`
  10302. Gender string `json:"gender"`
  10303. Birthday string `json:"birthday"`
  10304. Nationality string `json:"nationality"`
  10305. Email string `json:"email"`
  10306. Extra string `json:"extra"`
  10307. } `json:"data"`
  10308. Code int `json:"code"`
  10309. Message string `json:"message"`
  10310. }
  10311. var ele ELeData
  10312. err := json.Unmarshal([]byte(result), &ele)
  10313. if err != nil {
  10314. utils.ErrorLog("解析失败:%v", err)
  10315. }
  10316. token := ele.Data.EcToken
  10317. token = Remove0000(token)
  10318. fmt.Println(ele.Data.UserName)
  10319. 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)
  10320. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10321. var res ResultTwo
  10322. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10323. utils.ErrorLog("解析失败:%v", err)
  10324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10325. return
  10326. }
  10327. if res.Infcode == 0 {
  10328. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10329. if err == gorm.ErrRecordNotFound {
  10330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10331. return
  10332. } else if err != nil {
  10333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10334. return
  10335. } else {
  10336. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10337. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10338. infoStr := string(Iinfos)
  10339. idetinfoStr := string(Idetinfos)
  10340. psn := &models.HisPsn{
  10341. PsnNo: res.Output.Baseinfo.PsnNo,
  10342. PatientId: patient.ID,
  10343. Certno: res.Output.Baseinfo.Certno,
  10344. Gend: res.Output.Baseinfo.Gend,
  10345. Naty: res.Output.Baseinfo.Naty,
  10346. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10347. PsnName: res.Output.Baseinfo.PsnName,
  10348. Idetinfo: idetinfoStr,
  10349. Insuinfo: infoStr,
  10350. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10351. CardInfo: "",
  10352. VerifyNumber: token,
  10353. }
  10354. service.CreateHisPsn(psn)
  10355. c.ServeSuccessJSON(map[string]interface{}{
  10356. "patient": patient,
  10357. "number": token,
  10358. })
  10359. }
  10360. } else {
  10361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10362. return
  10363. }
  10364. } else if miConfig.MdtrtareaAdmvs == "360100" {
  10365. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10366. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10367. type ELeData struct {
  10368. Data struct {
  10369. IdNo string `json:"idNo"`
  10370. IdType string `json:"idType"`
  10371. UserName string `json:"userName"`
  10372. EcToken string `json:"ecToken"`
  10373. InsuOrg string `json:"insuOrg"`
  10374. Gender string `json:"gender"`
  10375. Birthday string `json:"birthday"`
  10376. Nationality string `json:"nationality"`
  10377. Email string `json:"email"`
  10378. Extra string `json:"extra"`
  10379. } `json:"data"`
  10380. Code int `json:"code"`
  10381. Message string `json:"message"`
  10382. }
  10383. var ele ELeData
  10384. err := json.Unmarshal([]byte(result), &ele)
  10385. if err != nil {
  10386. utils.ErrorLog("解析失败:%v", err)
  10387. }
  10388. token := ele.Data.EcToken
  10389. token = Remove0000(token)
  10390. fmt.Println(ele.Data.UserName)
  10391. 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)
  10392. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10393. var res ResultTwo
  10394. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10395. utils.ErrorLog("解析失败:%v", err)
  10396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10397. return
  10398. }
  10399. if res.Infcode == 0 {
  10400. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10401. if err == gorm.ErrRecordNotFound {
  10402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10403. return
  10404. } else if err != nil {
  10405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10406. return
  10407. } else {
  10408. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10409. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10410. infoStr := string(Iinfos)
  10411. idetinfoStr := string(Idetinfos)
  10412. psn := &models.HisPsn{
  10413. PsnNo: res.Output.Baseinfo.PsnNo,
  10414. PatientId: patient.ID,
  10415. Certno: res.Output.Baseinfo.Certno,
  10416. Gend: res.Output.Baseinfo.Gend,
  10417. Naty: res.Output.Baseinfo.Naty,
  10418. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10419. PsnName: res.Output.Baseinfo.PsnName,
  10420. Idetinfo: idetinfoStr,
  10421. Insuinfo: infoStr,
  10422. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10423. CardInfo: "",
  10424. VerifyNumber: token,
  10425. }
  10426. service.CreateHisPsn(psn)
  10427. c.ServeSuccessJSON(map[string]interface{}{
  10428. "patient": patient,
  10429. "number": token,
  10430. })
  10431. }
  10432. } else {
  10433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10434. return
  10435. }
  10436. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10437. //if initFlag == 0 {
  10438. //c.TestGetJiangXiBasBaseInit()
  10439. //}
  10440. //if initEleFlag == 0 {
  10441. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10442. //}
  10443. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10444. utils.ErrorLog("解析失败:%v", json_result)
  10445. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10446. type ELeData struct {
  10447. Data struct {
  10448. IdNo string `json:"idNo"`
  10449. IdType string `json:"idType"`
  10450. UserName string `json:"userName"`
  10451. EcToken string `json:"ecToken"`
  10452. InsuOrg string `json:"insuOrg"`
  10453. Gender string `json:"gender"`
  10454. Birthday string `json:"birthday"`
  10455. Nationality string `json:"nationality"`
  10456. Email string `json:"email"`
  10457. Extra string `json:"extra"`
  10458. } `json:"data"`
  10459. Code int `json:"code"`
  10460. Message string `json:"message"`
  10461. }
  10462. var ele ELeData
  10463. err := json.Unmarshal([]byte(json_result), &ele)
  10464. if err != nil {
  10465. utils.ErrorLog("解析失败:%v", err)
  10466. }
  10467. token := ele.Data.EcToken
  10468. token = Remove0000(token)
  10469. //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)
  10470. 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)
  10471. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10472. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10473. var res ResultTwo
  10474. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10475. utils.ErrorLog("解析失败:%v", err)
  10476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10477. return
  10478. }
  10479. if res.Infcode == 0 {
  10480. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10481. if err == gorm.ErrRecordNotFound {
  10482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10483. return
  10484. } else if err != nil {
  10485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10486. return
  10487. } else {
  10488. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10489. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10490. infoStr := string(Iinfos)
  10491. idetinfoStr := string(Idetinfos)
  10492. psn := &models.HisPsn{
  10493. PsnNo: res.Output.Baseinfo.PsnNo,
  10494. PatientId: patient.ID,
  10495. Certno: res.Output.Baseinfo.Certno,
  10496. Gend: res.Output.Baseinfo.Gend,
  10497. Naty: res.Output.Baseinfo.Naty,
  10498. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10499. PsnName: res.Output.Baseinfo.PsnName,
  10500. Idetinfo: idetinfoStr,
  10501. Insuinfo: infoStr,
  10502. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10503. CardInfo: "",
  10504. VerifyNumber: token,
  10505. InsuplcAdmdvs: ele.Data.InsuOrg,
  10506. }
  10507. service.CreateHisPsn(psn)
  10508. c.ServeSuccessJSON(map[string]interface{}{
  10509. "patient": patient,
  10510. "number": token,
  10511. })
  10512. }
  10513. } else {
  10514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10515. return
  10516. }
  10517. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10518. res := c.GetoleInfo()
  10519. if res.Infcode == 0 {
  10520. var result string
  10521. if res.Output.MdtrtCertType == "01" {
  10522. 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)
  10523. } else if res.Output.MdtrtCertType == "02" {
  10524. 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)
  10525. } else if res.Output.MdtrtCertType == "03" {
  10526. 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)
  10527. }
  10528. var dat map[string]interface{}
  10529. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10530. fmt.Println(dat)
  10531. } else {
  10532. fmt.Println(err)
  10533. }
  10534. userJSONBytes, _ := json.Marshal(dat)
  10535. var res2 ResultTwo
  10536. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10537. utils.ErrorLog("解析失败:%v", err)
  10538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10539. return
  10540. }
  10541. if res2.Infcode == 0 {
  10542. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10543. if err == gorm.ErrRecordNotFound {
  10544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10545. return
  10546. } else if err != nil {
  10547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10548. return
  10549. } else {
  10550. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10551. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10552. infoStr := string(Iinfos)
  10553. idetinfoStr := string(Idetinfos)
  10554. var rf []*ResultFive
  10555. json.Unmarshal([]byte(infoStr), &rf)
  10556. var insutypes []*ResultFive
  10557. var insutype string
  10558. var is390 int = 0
  10559. var is310 int = 0
  10560. //var insuplc_admdvs string
  10561. for _, item := range rf {
  10562. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10563. insutypes = append(insutypes, item)
  10564. }
  10565. }
  10566. if len(insutypes) == 1 {
  10567. insutype = insutypes[0].Insutype
  10568. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10569. } else {
  10570. for _, i := range insutypes {
  10571. if i.Insutype == "390" {
  10572. is390 = 1
  10573. }
  10574. if i.Insutype == "310" {
  10575. is310 = 1
  10576. }
  10577. }
  10578. }
  10579. if is390 == 1 {
  10580. insutype = "390"
  10581. }
  10582. if is310 == 1 {
  10583. insutype = "310"
  10584. }
  10585. if len(insutypes) == 0 {
  10586. insutype = "310"
  10587. }
  10588. psn := &models.HisPsn{
  10589. PsnNo: res2.Output.Baseinfo.PsnNo,
  10590. PatientId: patient.ID,
  10591. Certno: res2.Output.Baseinfo.Certno,
  10592. Gend: res2.Output.Baseinfo.Gend,
  10593. Naty: res2.Output.Baseinfo.Naty,
  10594. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10595. PsnName: res2.Output.Baseinfo.PsnName,
  10596. Idetinfo: idetinfoStr,
  10597. Insuinfo: infoStr,
  10598. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10599. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10600. VerifyNumber: res.Output.EcToken,
  10601. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10602. }
  10603. service.CreateHisPsn(psn)
  10604. c.ServeSuccessJSON(map[string]interface{}{
  10605. "patient": patient,
  10606. "number": res.Output.CardNo,
  10607. "insutype": insutype,
  10608. })
  10609. }
  10610. } else {
  10611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10612. return
  10613. }
  10614. } else {
  10615. c.ServeSuccessJSON(map[string]interface{}{
  10616. "failed_code": -10,
  10617. "msg": res.ErrMsg,
  10618. })
  10619. }
  10620. } else {
  10621. //if initFlag == 0 {
  10622. // c.TestGetBasBaseInit()
  10623. //}
  10624. //token := c.GetEleBaseInfo()
  10625. //token = Remove0000(token)
  10626. type ELeData struct {
  10627. Code string `json:"code"`
  10628. Data struct {
  10629. Aac002 string `json:"aac002"`
  10630. Aaz500 string `json:"aaz500"`
  10631. ActCardNo string `json:"actCardNo"`
  10632. Bab520 string `json:"bab520"`
  10633. Bkz543 string `json:"bkz543"`
  10634. BusinessType string `json:"businessType"`
  10635. CertfCodg string `json:"certfCodg"`
  10636. EcIndexNo string `json:"ecIndexNo"`
  10637. EcToken string `json:"ecToken"`
  10638. ID0000 string `json:"id0000"`
  10639. IDNo string `json:"idNo"`
  10640. IDType string `json:"idType"`
  10641. Idcode string `json:"idcode"`
  10642. IdentityToken string `json:"identity_token"`
  10643. InsuOrg string `json:"insuOrg"`
  10644. OfficeID string `json:"officeId"`
  10645. OfficeName string `json:"officeName"`
  10646. OperatorID string `json:"operatorId"`
  10647. OperatorName string `json:"operatorName"`
  10648. OrgID string `json:"orgId"`
  10649. UserName string `json:"userName"`
  10650. } `json:"data"`
  10651. Infno interface{} `json:"infno"`
  10652. Message string `json:"message"`
  10653. OrgID string `json:"orgId"`
  10654. TransType string `json:"transType"`
  10655. }
  10656. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10657. fmt.Println(result)
  10658. outPutInfo := Remove0000(result)
  10659. fmt.Println(outPutInfo)
  10660. var ele ELeData
  10661. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10662. if err != nil {
  10663. utils.ErrorLog("解析失败:%v", err)
  10664. }
  10665. token := ele.Data.EcToken
  10666. var result2 string
  10667. var requestLog2 string
  10668. if len(token) > 0 {
  10669. if strings.Contains(ele.Data.IDNo, "HKG") {
  10670. 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)
  10671. } else {
  10672. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10673. }
  10674. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10675. var res ResultTwo
  10676. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10677. utils.ErrorLog("解析失败:%v", err)
  10678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10679. return
  10680. }
  10681. if res.Infcode == 0 {
  10682. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10683. if err == gorm.ErrRecordNotFound {
  10684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10685. return
  10686. } else if err != nil {
  10687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10688. return
  10689. } else {
  10690. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10691. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10692. infoStr := string(Iinfos)
  10693. idetinfoStr := string(Idetinfos)
  10694. psn := &models.HisPsn{
  10695. PsnNo: res.Output.Baseinfo.PsnNo,
  10696. PatientId: patient.ID,
  10697. Certno: res.Output.Baseinfo.Certno,
  10698. Gend: res.Output.Baseinfo.Gend,
  10699. Naty: res.Output.Baseinfo.Naty,
  10700. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10701. PsnName: res.Output.Baseinfo.PsnName,
  10702. Idetinfo: idetinfoStr,
  10703. Insuinfo: infoStr,
  10704. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10705. CardInfo: "",
  10706. VerifyNumber: token,
  10707. }
  10708. service.CreateHisPsn(psn)
  10709. c.ServeSuccessJSON(map[string]interface{}{
  10710. "msg": "读取成功",
  10711. })
  10712. }
  10713. } else {
  10714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10715. return
  10716. }
  10717. } else {
  10718. c.ServeSuccessJSON(map[string]interface{}{
  10719. "failed_code": -10,
  10720. "msg": "读取失败",
  10721. })
  10722. }
  10723. }
  10724. }
  10725. func (c *HisApiController) ReadEleFace() {
  10726. admin_user_id, _ := c.GetInt64("admin_user_id")
  10727. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10728. adminUser := c.GetAdminUserInfo()
  10729. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10730. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10731. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10732. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10733. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10734. if len(tokens) > 0 {
  10735. c.ServeSuccessJSON(map[string]interface{}{
  10736. "msg": "读取成功",
  10737. })
  10738. } else {
  10739. c.ServeSuccessJSON(map[string]interface{}{
  10740. "failed_code": -10,
  10741. "msg": "读取失败",
  10742. })
  10743. }
  10744. }
  10745. }
  10746. func timestampToBirthdayString(timestamp int64) string {
  10747. // 将时间戳转换为 time.Time
  10748. t := time.Unix(timestamp, 0)
  10749. // 格式化时间为生日字符串,例如 "2006-01-02"
  10750. birthday := t.Format("2006-01-02")
  10751. return birthday
  10752. }
  10753. func (c *HisApiController) Get9001() {
  10754. adminUser := c.GetAdminUserInfo()
  10755. admin_user_id, _ := c.GetInt64("admin_user_id")
  10756. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10757. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10758. if miConfig.MdtrtareaAdmvs == "350500" {
  10759. service.GetFjAuthorizationInfo(miConfig.Code)
  10760. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10761. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10762. var dat map[string]interface{}
  10763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10764. fmt.Println(dat)
  10765. } else {
  10766. fmt.Println(err)
  10767. }
  10768. userJSONBytes, _ := json.Marshal(dat)
  10769. var res models.Result9001
  10770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10771. utils.ErrorLog("解析失败:%v", err)
  10772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10773. return
  10774. }
  10775. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10776. fmt.Println(miConfig.SecretKey)
  10777. var res models.Result9001Two
  10778. 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 +
  10779. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10780. resp, requestErr := http.Get(api)
  10781. if requestErr != nil {
  10782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10783. return
  10784. }
  10785. body, ioErr := ioutil.ReadAll(resp.Body)
  10786. if ioErr != nil {
  10787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10789. return
  10790. }
  10791. var respJSON map[string]interface{}
  10792. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10795. return
  10796. }
  10797. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10798. if status == "0" {
  10799. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10800. c.ServeSuccessJSON(map[string]interface{}{
  10801. "failed_code": -10,
  10802. "msg": err_msg,
  10803. })
  10804. return
  10805. }
  10806. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10807. result, _ := json.Marshal(respJSON)
  10808. fmt.Println("log")
  10809. fmt.Println(string(result))
  10810. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10811. utils.ErrorLog("解析失败:%v", err)
  10812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10813. return
  10814. }
  10815. if res.Infcode == 0 {
  10816. sign := models.HisSignIn{
  10817. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10818. SignNo: res.Output.Signinoutb.SignNo,
  10819. SignTime: "",
  10820. Ctime: time.Now().Unix(),
  10821. Mtime: time.Now().Unix(),
  10822. Status: 1,
  10823. InputLog: "",
  10824. OutputLog: "",
  10825. FixmedinsCode: miConfig.Code,
  10826. }
  10827. err := service.CreateSignIn(&sign)
  10828. if err == nil {
  10829. c.ServeSuccessJSON(map[string]interface{}{
  10830. "msg": "签到成功",
  10831. })
  10832. }
  10833. } else {
  10834. c.ServeSuccessJSON(map[string]interface{}{
  10835. "failed_code": -10,
  10836. "msg": res.ErrMsg,
  10837. })
  10838. return
  10839. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10840. //return
  10841. }
  10842. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10843. fmt.Println(miConfig.SecretKey)
  10844. var res models.Result9001Two
  10845. 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 +
  10846. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10847. resp, requestErr := http.Get(api)
  10848. if requestErr != nil {
  10849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10850. return
  10851. }
  10852. body, ioErr := ioutil.ReadAll(resp.Body)
  10853. if ioErr != nil {
  10854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10856. return
  10857. }
  10858. var respJSON map[string]interface{}
  10859. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10862. return
  10863. }
  10864. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10865. if status == "0" {
  10866. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10867. c.ServeSuccessJSON(map[string]interface{}{
  10868. "failed_code": -10,
  10869. "msg": err_msg,
  10870. })
  10871. return
  10872. }
  10873. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10874. result, _ := json.Marshal(respJSON)
  10875. fmt.Println("log")
  10876. fmt.Println(string(result))
  10877. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10878. utils.ErrorLog("解析失败:%v", err)
  10879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10880. return
  10881. }
  10882. if res.Infcode == 0 {
  10883. sign := models.HisSignIn{
  10884. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10885. SignNo: res.Output.Signinoutb.SignNo,
  10886. SignTime: "",
  10887. Ctime: time.Now().Unix(),
  10888. Mtime: time.Now().Unix(),
  10889. Status: 1,
  10890. InputLog: "",
  10891. OutputLog: "",
  10892. FixmedinsCode: miConfig.Code,
  10893. }
  10894. err := service.CreateSignIn(&sign)
  10895. if err == nil {
  10896. c.ServeSuccessJSON(map[string]interface{}{
  10897. "msg": "签到成功",
  10898. })
  10899. }
  10900. } else {
  10901. c.ServeSuccessJSON(map[string]interface{}{
  10902. "failed_code": -10,
  10903. "msg": res.ErrMsg,
  10904. })
  10905. return
  10906. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10907. //return
  10908. }
  10909. } else {
  10910. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10911. var dat map[string]interface{}
  10912. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10913. fmt.Println(dat)
  10914. } else {
  10915. fmt.Println(err)
  10916. }
  10917. userJSONBytes, _ := json.Marshal(dat)
  10918. var res models.Result9001
  10919. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10920. utils.ErrorLog("解析失败:%v", err)
  10921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10922. return
  10923. }
  10924. if res.Infcode == 0 {
  10925. sign := models.HisSignIn{
  10926. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10927. SignNo: res.Output.Signinoutb.SignNo,
  10928. SignTime: res.Output.Signinoutb.SignTime,
  10929. Ctime: time.Now().Unix(),
  10930. Mtime: time.Now().Unix(),
  10931. Status: 1,
  10932. InputLog: "",
  10933. OutputLog: "",
  10934. FixmedinsCode: miConfig.Code,
  10935. }
  10936. err := service.CreateSignIn(&sign)
  10937. if err == nil {
  10938. c.ServeSuccessJSON(map[string]interface{}{
  10939. "msg": "签到成功",
  10940. })
  10941. }
  10942. }
  10943. }
  10944. }
  10945. 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) {
  10946. var res Result3101
  10947. adminUser := c.GetAdminUserInfo()
  10948. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10949. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10950. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10951. //record_time := c.GetString("record_time")
  10952. //trig_scen := c.GetString("trig_scen")
  10953. timeLayout := "2006-01-02"
  10954. loc, _ := time.LoadLocation("Local")
  10955. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10956. if err != nil {
  10957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10958. return res
  10959. }
  10960. recordDateTime := theTime.Unix()
  10961. var patientPrescription models.HisPrescriptionInfo
  10962. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10963. //if patientPrescription.ID == 0 {
  10964. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10965. //}
  10966. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10967. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10968. //
  10969. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10970. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10971. var pp models.PublicParams
  10972. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10973. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10974. pp.FixmedinsName = miConfig.OrgName
  10975. pp.FixmedinsCode = miConfig.Code
  10976. pp.RequestUrl = miConfig.Url
  10977. pp.Cainfo = miConfig.Cainfo
  10978. pp.SecretKey = miConfig.SecretKey
  10979. pp.AccessKey = miConfig.AccessKey
  10980. pp.OpterName = roles.UserName
  10981. var config []*models.HisXtDiagnoseConfig
  10982. for _, item := range diagnosis_ids {
  10983. id, _ := strconv.ParseInt(item, 10, 64)
  10984. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10985. config = append(config, &diagnosisConfig)
  10986. }
  10987. var pd models.PatientDtos
  10988. pd.PatnID = his.PsnNo
  10989. pd.PatnName = his.Name
  10990. pd.Gend = his.Gend
  10991. pd.Brdy = his.Brdy
  10992. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10993. pd.CurrMdtrtID = his.Number
  10994. var fed models.FsiEncounterDtos
  10995. fed.MdtrtID = his.Number
  10996. fed.MedinsID = miConfig.Code
  10997. fed.MedinsName = miConfig.OrgName
  10998. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10999. fed.MedMdtrtType = "1"
  11000. fed.MedinsType = "1"
  11001. fed.MedinsLv = "11"
  11002. tm := time.Unix(his.RecordDate, 0)
  11003. s_tm := tm.Format("2006-01-02 15:04:05")
  11004. fed.AdmDate = s_tm
  11005. fed.DscgDate = s_tm
  11006. fed.DscgMainDiseCodg = config[0].CountryCode
  11007. fed.DscgMainDiseName = config[0].CountryContentName
  11008. //诊断信息
  11009. var fdds []*models.FsiDiagnoseDtos
  11010. for index, item := range config {
  11011. if index == 0 {
  11012. var fdd models.FsiDiagnoseDtos
  11013. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11014. fdd.InoutDiseType = "1"
  11015. fdd.MaindiseFlag = "1"
  11016. fdd.DiseDate = s_tm
  11017. fdd.DiasSrtNo = "1"
  11018. fdd.DiseName = item.CountryContentName
  11019. fdd.DiseCodg = item.CountryCode
  11020. fdds = append(fdds, &fdd)
  11021. } else {
  11022. var fdd models.FsiDiagnoseDtos
  11023. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11024. fdd.InoutDiseType = "1"
  11025. fdd.MaindiseFlag = "1"
  11026. fdd.DiseDate = s_tm
  11027. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11028. fdd.DiseName = item.CountryContentName
  11029. fdd.DiseCodg = item.CountryCode
  11030. fdds = append(fdds, &fdd)
  11031. }
  11032. }
  11033. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11034. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11035. fed.AdmDeptName = de.Name
  11036. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11037. fed.DscgDeptName = de.Name
  11038. fed.MedMdtrtType = "1"
  11039. fed.MedType = "11"
  11040. //if his.Insutype == "390" {
  11041. // fed.MedType = "1402"
  11042. //} else {
  11043. // fed.MedType = "9933"
  11044. //}
  11045. var orders []*models.FsiOrderDtos
  11046. if trig_scen == "2" {
  11047. //处方医嘱信息
  11048. for _, item := range prescriptions {
  11049. for _, subItem := range item.HisDoctorAdviceInfo {
  11050. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11051. var order models.FsiOrderDtos
  11052. order.RxID = strconv.FormatInt(item.ID, 10)
  11053. order.Rxno = strconv.FormatInt(item.ID, 10)
  11054. order.LongDrordFlag = "0"
  11055. order.HilistType = "1"
  11056. order.ChrgType = "1"
  11057. order.DrordBhvr = "-"
  11058. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11059. order.HosplistName = subItem.BaseDrugLib.DrugName
  11060. order.HilistLv = "1"
  11061. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11062. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11063. order.HosplistName = subItem.BaseDrugLib.DrugName
  11064. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11065. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11066. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11067. order.OwnpayAmt = ""
  11068. order.SelfpayAmt = ""
  11069. order.Spec = ""
  11070. order.SpecUnt = ""
  11071. order.DrordBegnDate = s_tm
  11072. order.DrordStopDate = ""
  11073. order.DrordDrCodg = doctor_info.DoctorNumber
  11074. order.DrordDeptName = department.Name
  11075. order.DrordDeptCodg = department.Number
  11076. order.DrordDrName = doctor_info.UserName
  11077. order.DrordDrProfttl = "234"
  11078. order.CurrDrordFlag = "1"
  11079. orders = append(orders, &order)
  11080. }
  11081. }
  11082. for _, subItem := range item.HisPrescriptionProject {
  11083. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11084. var order models.FsiOrderDtos
  11085. order.RxID = strconv.FormatInt(item.ID, 10)
  11086. order.Rxno = strconv.FormatInt(item.ID, 10)
  11087. order.LongDrordFlag = "0"
  11088. order.HilistType = "1"
  11089. order.ChrgType = "1"
  11090. order.DrordBhvr = "-"
  11091. order.HilistCode = subItem.HisProject.MedicalCode
  11092. order.HosplistName = subItem.HisProject.ProjectName
  11093. order.HilistLv = "1"
  11094. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11095. order.HosplistCode = subItem.HisProject.MedicalCode
  11096. order.HosplistName = subItem.HisProject.ProjectName
  11097. order.Cnt = subItem.Count
  11098. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11099. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11100. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11101. order.OwnpayAmt = ""
  11102. order.SelfpayAmt = ""
  11103. order.Spec = ""
  11104. order.SpecUnt = ""
  11105. order.DrordBegnDate = s_tm
  11106. order.DrordStopDate = ""
  11107. order.DrordDrCodg = doctor_info.DoctorNumber
  11108. order.DrordDeptName = department.Name
  11109. order.DrordDeptCodg = department.Number
  11110. order.DrordDrName = doctor_info.UserName
  11111. order.DrordDrProfttl = "234"
  11112. order.CurrDrordFlag = "1"
  11113. orders = append(orders, &order)
  11114. }
  11115. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11116. var order models.FsiOrderDtos
  11117. order.RxID = strconv.FormatInt(item.ID, 10)
  11118. order.Rxno = strconv.FormatInt(item.ID, 10)
  11119. order.LongDrordFlag = "0"
  11120. order.HilistType = "1"
  11121. order.ChrgType = "1"
  11122. order.DrordBhvr = "-"
  11123. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11124. order.HosplistName = subItem.GoodInfo.GoodName
  11125. order.HilistLv = "1"
  11126. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11127. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11128. order.HosplistName = subItem.GoodInfo.GoodName
  11129. order.Cnt = subItem.Count
  11130. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11131. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11132. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11133. order.OwnpayAmt = ""
  11134. order.SelfpayAmt = ""
  11135. order.Spec = ""
  11136. order.SpecUnt = ""
  11137. order.DrordBegnDate = s_tm
  11138. order.DrordStopDate = ""
  11139. order.DrordDrCodg = doctor_info.DoctorNumber
  11140. order.DrordDeptName = department.Name
  11141. order.DrordDeptCodg = department.Number
  11142. order.DrordDrName = doctor_info.UserName
  11143. order.DrordDrProfttl = "234"
  11144. order.CurrDrordFlag = "1"
  11145. orders = append(orders, &order)
  11146. }
  11147. }
  11148. }
  11149. //处方医嘱信息
  11150. }
  11151. fed.MatnStas = "0"
  11152. fed.MedfeeSumamt = "0"
  11153. fed.OwnpayAmt = "0"
  11154. fed.SelfpayAmt = "0"
  11155. fed.AcctPayamt = "0"
  11156. fed.MaAmt = "0"
  11157. fed.HifpPayamt = "0"
  11158. fed.SetlTotlnum = "1"
  11159. fed.Insutype = his.Insutype
  11160. fed.ReimFlag = "0"
  11161. fed.OutSetlFlag = "0"
  11162. var fopd []*models.FsiOperationDtosData
  11163. data := make(map[string]interface{})
  11164. data["fed"] = fed
  11165. data["fdd"] = fdds
  11166. data["fod"] = orders
  11167. data["pd"] = pd
  11168. data["pp"] = pp
  11169. data["fopd"] = fopd
  11170. data["trig_scen"] = trig_scen
  11171. fmt.Println(data)
  11172. fmt.Println(fed)
  11173. fmt.Println(fdds)
  11174. fmt.Println(orders)
  11175. fmt.Println(pd)
  11176. fmt.Println(pp)
  11177. fmt.Println(fopd)
  11178. client := &http.Client{}
  11179. bytesData, _ := json.Marshal(data)
  11180. var req *http.Request
  11181. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11182. if miConfig.MdtrtareaAdmvs == "320921" {
  11183. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11184. } else {
  11185. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11186. }
  11187. resp, _ := client.Do(req)
  11188. defer resp.Body.Close()
  11189. body, ioErr := ioutil.ReadAll(resp.Body)
  11190. if ioErr != nil {
  11191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11193. return res
  11194. }
  11195. var respJSON map[string]interface{}
  11196. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11199. return res
  11200. }
  11201. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11202. fmt.Println(respJSON)
  11203. result, _ := json.Marshal(respJSON)
  11204. fmt.Println(result)
  11205. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11206. utils.ErrorLog("解析失败:%v", err)
  11207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11208. return res
  11209. }
  11210. return res
  11211. } else {
  11212. //if miConfig.MdtrtareaAdmvs == "441202" {
  11213. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11214. saveLog(output, input, "3101", "事前")
  11215. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11216. utils.ErrorLog("解析失败:%v", err)
  11217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11218. return
  11219. }
  11220. return res
  11221. //}
  11222. }
  11223. }
  11224. 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) {
  11225. adminUser := c.GetAdminUserInfo()
  11226. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11227. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11228. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11229. //record_time := c.GetString("record_time")
  11230. //trig_scen := c.GetString("trig_scen")
  11231. timeLayout := "2006-01-02"
  11232. loc, _ := time.LoadLocation("Local")
  11233. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11234. if err != nil {
  11235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11236. return res
  11237. }
  11238. recordDateTime := theTime.Unix()
  11239. var patientPrescription models.HisPrescriptionInfo
  11240. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11241. if patientPrescription.ID == 0 {
  11242. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11243. }
  11244. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11245. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11246. //
  11247. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11248. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11249. var pp models.PublicParams
  11250. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11251. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11252. pp.FixmedinsName = miConfig.OrgName
  11253. pp.FixmedinsCode = miConfig.Code
  11254. pp.RequestUrl = miConfig.Url
  11255. pp.Cainfo = miConfig.Cainfo
  11256. pp.SecretKey = miConfig.SecretKey
  11257. pp.AccessKey = miConfig.AccessKey
  11258. pp.OpterName = roles.UserName
  11259. var config []*models.HisXtDiagnoseConfig
  11260. for _, item := range diagnosis_ids {
  11261. id, _ := strconv.ParseInt(item, 10, 64)
  11262. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11263. config = append(config, &diagnosisConfig)
  11264. }
  11265. var pd models.PatientDtos
  11266. pd.PatnID = his.PsnNo
  11267. pd.PatnName = his.Name
  11268. pd.Gend = his.Gend
  11269. pd.Brdy = his.Brdy
  11270. pd.Poolarea = his.InsuplcAdmdvs
  11271. pd.CurrMdtrtID = his.Number
  11272. var fed models.FsiEncounterDtos
  11273. fed.MdtrtID = his.Number
  11274. fed.MedinsID = miConfig.Code
  11275. fed.MedinsName = miConfig.OrgName
  11276. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11277. fed.MedMdtrtType = "1"
  11278. fed.MedinsType = "1"
  11279. fed.MedinsLv = "11"
  11280. tm := time.Unix(his.RecordDate, 0)
  11281. s_tm := tm.Format("2006-01-02 15:04:05")
  11282. fed.AdmDate = s_tm
  11283. fed.DscgDate = s_tm
  11284. fed.DscgMainDiseCodg = config[0].CountryCode
  11285. fed.DscgMainDiseName = config[0].CountryContentName
  11286. //诊断信息
  11287. var fdds []*models.FsiDiagnoseDtos
  11288. for index, item := range config {
  11289. if index == 0 {
  11290. var fdd models.FsiDiagnoseDtos
  11291. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11292. fdd.InoutDiseType = "1"
  11293. fdd.MaindiseFlag = "1"
  11294. fdd.DiseDate = s_tm
  11295. fdd.DiasSrtNo = "1"
  11296. fdd.DiseName = item.CountryContentName
  11297. fdd.DiseCodg = item.CountryCode
  11298. fdds = append(fdds, &fdd)
  11299. } else {
  11300. var fdd models.FsiDiagnoseDtos
  11301. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11302. fdd.InoutDiseType = "1"
  11303. fdd.MaindiseFlag = "1"
  11304. fdd.DiseDate = s_tm
  11305. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11306. fdd.DiseName = item.CountryContentName
  11307. fdd.DiseCodg = item.CountryCode
  11308. fdds = append(fdds, &fdd)
  11309. }
  11310. }
  11311. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11312. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11313. fed.AdmDeptName = department.Name
  11314. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11315. fed.DscgDeptName = department.Name
  11316. fed.MedMdtrtType = "1"
  11317. fed.MedType = "11"
  11318. //if his.Insutype == "390" {
  11319. // fed.MedType = "1402"
  11320. //} else {
  11321. // fed.MedType = "9933"
  11322. //}
  11323. var orders []*models.FsiOrderDtos
  11324. if trig_scen == "2" {
  11325. //处方医嘱信息
  11326. for _, item := range prescriptions {
  11327. for _, subItem := range item.HisDoctorAdviceInfo {
  11328. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11329. var order models.FsiOrderDtos
  11330. order.RxID = strconv.FormatInt(item.ID, 10)
  11331. order.Rxno = strconv.FormatInt(item.ID, 10)
  11332. order.LongDrordFlag = "0"
  11333. order.HilistType = "1"
  11334. order.ChrgType = "1"
  11335. order.DrordBhvr = "-"
  11336. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11337. order.HosplistName = subItem.BaseDrugLib.DrugName
  11338. order.HilistLv = "1"
  11339. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11340. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11341. order.HosplistName = subItem.BaseDrugLib.DrugName
  11342. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11343. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11344. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11345. order.OwnpayAmt = ""
  11346. order.SelfpayAmt = ""
  11347. order.Spec = ""
  11348. order.SpecUnt = ""
  11349. order.DrordBegnDate = s_tm
  11350. order.DrordStopDate = ""
  11351. order.DrordDrCodg = doctor_info.DoctorNumber
  11352. order.DrordDeptName = department.Name
  11353. order.DrordDeptCodg = department.Number
  11354. order.DrordDrName = doctor_info.UserName
  11355. order.DrordDrProfttl = "234"
  11356. order.CurrDrordFlag = "1"
  11357. orders = append(orders, &order)
  11358. }
  11359. }
  11360. for _, subItem := range item.HisPrescriptionProject {
  11361. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11362. var order models.FsiOrderDtos
  11363. order.RxID = strconv.FormatInt(item.ID, 10)
  11364. order.Rxno = strconv.FormatInt(item.ID, 10)
  11365. order.LongDrordFlag = "0"
  11366. order.HilistType = "1"
  11367. order.ChrgType = "1"
  11368. order.DrordBhvr = "-"
  11369. order.HilistCode = subItem.HisProject.MedicalCode
  11370. order.HosplistName = subItem.HisProject.ProjectName
  11371. order.HilistLv = "1"
  11372. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11373. order.HosplistCode = subItem.HisProject.MedicalCode
  11374. order.HosplistName = subItem.HisProject.ProjectName
  11375. order.Cnt = subItem.Count
  11376. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11377. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11378. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11379. order.OwnpayAmt = ""
  11380. order.SelfpayAmt = ""
  11381. order.Spec = ""
  11382. order.SpecUnt = ""
  11383. order.DrordBegnDate = s_tm
  11384. order.DrordStopDate = ""
  11385. order.DrordDrCodg = doctor_info.DoctorNumber
  11386. order.DrordDeptName = department.Name
  11387. order.DrordDeptCodg = department.Number
  11388. order.DrordDrName = doctor_info.UserName
  11389. order.DrordDrProfttl = "234"
  11390. order.CurrDrordFlag = "1"
  11391. orders = append(orders, &order)
  11392. }
  11393. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11394. var order models.FsiOrderDtos
  11395. order.RxID = strconv.FormatInt(item.ID, 10)
  11396. order.Rxno = strconv.FormatInt(item.ID, 10)
  11397. order.LongDrordFlag = "0"
  11398. order.HilistType = "1"
  11399. order.ChrgType = "1"
  11400. order.DrordBhvr = "-"
  11401. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11402. order.HosplistName = subItem.GoodInfo.GoodName
  11403. order.HilistLv = "1"
  11404. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11405. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11406. order.HosplistName = subItem.GoodInfo.GoodName
  11407. order.Cnt = subItem.Count
  11408. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11409. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11410. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11411. order.OwnpayAmt = ""
  11412. order.SelfpayAmt = ""
  11413. order.Spec = ""
  11414. order.SpecUnt = ""
  11415. order.DrordBegnDate = s_tm
  11416. order.DrordStopDate = ""
  11417. order.DrordDrCodg = doctor_info.DoctorNumber
  11418. order.DrordDeptName = department.Name
  11419. order.DrordDeptCodg = department.Number
  11420. order.DrordDrName = doctor_info.UserName
  11421. order.DrordDrProfttl = "234"
  11422. order.CurrDrordFlag = "1"
  11423. orders = append(orders, &order)
  11424. }
  11425. }
  11426. }
  11427. //处方医嘱信息
  11428. }
  11429. fed.MatnStas = "0"
  11430. fed.MedfeeSumamt = "0"
  11431. fed.OwnpayAmt = "0"
  11432. fed.SelfpayAmt = "0"
  11433. fed.AcctPayamt = "0"
  11434. fed.MaAmt = "0"
  11435. fed.HifpPayamt = "0"
  11436. fed.SetlTotlnum = "1"
  11437. fed.Insutype = his.Insutype
  11438. fed.ReimFlag = "0"
  11439. fed.OutSetlFlag = "0"
  11440. var fopd []*models.FsiOperationDtosData
  11441. data := make(map[string]interface{})
  11442. data["fed"] = fed
  11443. data["fdd"] = fdds
  11444. data["fod"] = orders
  11445. data["pd"] = pd
  11446. data["pp"] = pp
  11447. data["fopd"] = fopd
  11448. data["trig_scen"] = trig_scen
  11449. fmt.Println(data)
  11450. fmt.Println(fed)
  11451. fmt.Println(fdds)
  11452. fmt.Println(orders)
  11453. fmt.Println(pd)
  11454. fmt.Println(pp)
  11455. fmt.Println(fopd)
  11456. client := &http.Client{}
  11457. bytesData, _ := json.Marshal(data)
  11458. var req *http.Request
  11459. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11460. if miConfig.MdtrtareaAdmvs == "320921" {
  11461. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11462. } else {
  11463. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11464. }
  11465. resp, _ := client.Do(req)
  11466. defer resp.Body.Close()
  11467. body, ioErr := ioutil.ReadAll(resp.Body)
  11468. if ioErr != nil {
  11469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11471. return res
  11472. }
  11473. var respJSON map[string]interface{}
  11474. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11477. return res
  11478. }
  11479. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11480. fmt.Println(respJSON)
  11481. result, _ := json.Marshal(respJSON)
  11482. fmt.Println(result)
  11483. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11484. utils.ErrorLog("解析失败:%v", err)
  11485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11486. return res
  11487. }
  11488. return res
  11489. } else {
  11490. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11491. saveLog(output, input, "3101", "事前")
  11492. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11493. utils.ErrorLog("解析失败:%v", err)
  11494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11495. return
  11496. }
  11497. return res
  11498. }
  11499. return res
  11500. }
  11501. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11502. ////patient_id, _ := c.GetInt64("patient_id")
  11503. //order_id, _ := c.GetInt64("order_id")
  11504. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11505. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11506. //trig_scen := c.GetString("trig_scen")
  11507. adminUser := c.GetAdminUserInfo()
  11508. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11509. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11510. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11511. record_time := c.GetString("record_time")
  11512. order, _ := service.GetHisOrderByID(order_id)
  11513. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11514. timeLayout := "2006-01-02"
  11515. loc, _ := time.LoadLocation("Local")
  11516. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11517. if err != nil {
  11518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11519. return
  11520. }
  11521. recordDateTime := theTime.Unix()
  11522. var patientPrescription models.HisPrescriptionInfo
  11523. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11524. if patientPrescription.ID == 0 {
  11525. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11526. }
  11527. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11528. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11529. //
  11530. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11531. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11532. var pp models.PublicParams
  11533. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11534. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11535. pp.FixmedinsName = miConfig.OrgName
  11536. pp.FixmedinsCode = miConfig.Code
  11537. pp.RequestUrl = miConfig.Url
  11538. pp.Cainfo = miConfig.Cainfo
  11539. pp.SecretKey = miConfig.SecretKey
  11540. pp.AccessKey = miConfig.AccessKey
  11541. pp.OpterName = roles.UserName
  11542. var config []*models.HisXtDiagnoseConfig
  11543. for _, item := range diagnosis_ids {
  11544. id, _ := strconv.ParseInt(item, 10, 64)
  11545. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11546. config = append(config, &diagnosisConfig)
  11547. }
  11548. var pd models.PatientDtos
  11549. pd.PatnID = his.PsnNo
  11550. pd.PatnName = his.Name
  11551. pd.Gend = his.Gend
  11552. pd.Brdy = psn_info.Brdy
  11553. pd.Poolarea = his.InsuplcAdmdvs
  11554. pd.CurrMdtrtID = his.Number
  11555. var fed models.FsiEncounterDtos
  11556. fed.MdtrtID = his.Number
  11557. fed.MedinsID = miConfig.Code
  11558. fed.MedinsName = miConfig.OrgName
  11559. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11560. fed.MedMdtrtType = "1"
  11561. fed.MedinsType = "1"
  11562. fed.MedinsLv = "11"
  11563. tm := time.Unix(his.RecordDate, 0)
  11564. s_tm := tm.Format("2006-01-02 15:04:05")
  11565. fed.AdmDate = s_tm
  11566. fed.DscgDate = s_tm
  11567. fed.DscgMainDiseCodg = config[0].CountryCode
  11568. fed.DscgMainDiseName = config[0].CountryContentName
  11569. //诊断信息
  11570. var fdds []*models.FsiDiagnoseDtos
  11571. for index, item := range config {
  11572. if index == 0 {
  11573. var fdd models.FsiDiagnoseDtos
  11574. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11575. fdd.InoutDiseType = "1"
  11576. fdd.MaindiseFlag = "1"
  11577. fdd.DiseDate = s_tm
  11578. fdd.DiasSrtNo = "1"
  11579. fdd.DiseName = item.CountryContentName
  11580. fdd.DiseCodg = item.CountryCode
  11581. fdds = append(fdds, &fdd)
  11582. } else {
  11583. var fdd models.FsiDiagnoseDtos
  11584. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11585. fdd.InoutDiseType = "1"
  11586. fdd.MaindiseFlag = "1"
  11587. fdd.DiseDate = s_tm
  11588. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11589. fdd.DiseName = item.CountryContentName
  11590. fdd.DiseCodg = item.CountryCode
  11591. fdds = append(fdds, &fdd)
  11592. }
  11593. }
  11594. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11595. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11596. fed.AdmDeptName = department.Name
  11597. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11598. fed.DscgDeptName = department.Name
  11599. fed.MedType = order.MedType
  11600. //处方医嘱信息
  11601. var orders []*models.FsiOrderDtos
  11602. //for _, item := range prescriptions {
  11603. // for _, subItem := range item.HisDoctorAdviceInfo {
  11604. // var order models.FsiOrderDtos
  11605. // order.RxID = strconv.FormatInt(item.ID, 10)
  11606. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11607. // order.LongDrordFlag = "0"
  11608. // order.HilistType = "1"
  11609. // order.ChrgType = "1"
  11610. // order.DrordBhvr = "-"
  11611. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11612. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11613. // order.HilistLv = "1"
  11614. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11615. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11616. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11617. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11618. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11619. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11620. // order.OwnpayAmt = ""
  11621. // order.SelfpayAmt = ""
  11622. // order.Spec = ""
  11623. // order.SpecUnt = ""
  11624. // order.DrordBegnDate = s_tm
  11625. // order.DrordStopDate = ""
  11626. // order.DrordDrCodg = "1"
  11627. // order.DrordDeptName = department.Name
  11628. // order.DrordDrCodg = "1"
  11629. // order.DrordDrName = doctor_info.UserName
  11630. // order.DrordDrProfttl = ""
  11631. // order.CurrDrordFlag = "1"
  11632. // orders = append(orders, &order)
  11633. // }
  11634. // for _, subItem := range item.HisPrescriptionProject {
  11635. // if subItem.Type == 2 {
  11636. // var order models.FsiOrderDtos
  11637. // order.RxID = strconv.FormatInt(item.ID, 10)
  11638. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11639. // order.LongDrordFlag = "0"
  11640. // order.HilistType = "1"
  11641. // order.ChrgType = "1"
  11642. // order.DrordBhvr = "-"
  11643. // order.HilistCode = subItem.HisProject.MedicalCode
  11644. // order.HosplistName = subItem.HisProject.ProjectName
  11645. // order.HilistLv = "1"
  11646. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11647. // order.HosplistCode = subItem.HisProject.MedicalCode
  11648. // order.HosplistName = subItem.HisProject.ProjectName
  11649. // order.Cnt = subItem.Count
  11650. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11651. //
  11652. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11653. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11654. // order.OwnpayAmt = ""
  11655. // order.SelfpayAmt = ""
  11656. // order.Spec = ""
  11657. // order.SpecUnt = ""
  11658. // order.DrordBegnDate = s_tm
  11659. // order.DrordStopDate = ""
  11660. // order.DrordDrCodg = "1"
  11661. // order.DrordDeptName = department.Name
  11662. // order.DrordDrCodg = "1"
  11663. // order.DrordDrName = doctor_info.UserName
  11664. // order.DrordDrProfttl = ""
  11665. // order.CurrDrordFlag = "1"
  11666. // orders = append(orders, &order)
  11667. //
  11668. // }
  11669. // if subItem.Type == 3 {
  11670. //
  11671. // var order models.FsiOrderDtos
  11672. // order.RxID = strconv.FormatInt(item.ID, 10)
  11673. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11674. // order.LongDrordFlag = "0"
  11675. // order.HilistType = "1"
  11676. // order.ChrgType = "1"
  11677. // order.DrordBhvr = "-"
  11678. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11679. // order.HosplistName = subItem.GoodInfo.GoodName
  11680. // order.HilistLv = "1"
  11681. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11682. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11683. // order.HosplistName = subItem.GoodInfo.GoodName
  11684. // order.Cnt = subItem.Count
  11685. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11686. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11687. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11688. // order.OwnpayAmt = ""
  11689. // order.SelfpayAmt = ""
  11690. // order.Spec = ""
  11691. // order.SpecUnt = ""
  11692. // order.DrordBegnDate = s_tm
  11693. // order.DrordStopDate = ""
  11694. // order.DrordDrCodg = "1"
  11695. // order.DrordDeptName = department.Name
  11696. // order.DrordDrCodg = "1"
  11697. // order.DrordDrName = doctor_info.UserName
  11698. // order.DrordDrProfttl = ""
  11699. // order.CurrDrordFlag = "1"
  11700. // orders = append(orders, &order)
  11701. //
  11702. // }
  11703. // }
  11704. //}
  11705. for _, item := range prescriptions {
  11706. for _, subItem := range item.HisDoctorAdviceInfo {
  11707. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11708. var order models.FsiOrderDtos
  11709. order.RxID = strconv.FormatInt(item.ID, 10)
  11710. order.Rxno = strconv.FormatInt(item.ID, 10)
  11711. order.LongDrordFlag = "0"
  11712. order.HilistType = "101"
  11713. order.ChrgType = "1"
  11714. order.DrordBhvr = "-"
  11715. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11716. order.HosplistName = subItem.BaseDrugLib.DrugName
  11717. order.HilistLv = "1"
  11718. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11719. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11720. order.HosplistName = subItem.BaseDrugLib.DrugName
  11721. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11722. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11723. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11724. order.OwnpayAmt = ""
  11725. order.SelfpayAmt = ""
  11726. order.Spec = ""
  11727. order.SpecUnt = ""
  11728. order.DrordBegnDate = s_tm
  11729. order.DrordStopDate = ""
  11730. order.DrordDrCodg = doctor_info.DoctorNumber
  11731. order.DrordDeptName = department.Name
  11732. order.DrordDeptCodg = department.Number
  11733. order.DrordDrName = doctor_info.UserName
  11734. order.DrordDrProfttl = "234"
  11735. order.CurrDrordFlag = "1"
  11736. orders = append(orders, &order)
  11737. }
  11738. }
  11739. for _, subItem := range item.HisPrescriptionProject {
  11740. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11741. var order models.FsiOrderDtos
  11742. order.RxID = strconv.FormatInt(item.ID, 10)
  11743. order.Rxno = strconv.FormatInt(item.ID, 10)
  11744. order.LongDrordFlag = "0"
  11745. order.HilistType = "201"
  11746. order.ChrgType = "1"
  11747. order.DrordBhvr = "-"
  11748. order.HilistCode = subItem.HisProject.MedicalCode
  11749. order.HosplistName = subItem.HisProject.ProjectName
  11750. order.HilistLv = "1"
  11751. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11752. order.HosplistCode = subItem.HisProject.MedicalCode
  11753. order.HosplistName = subItem.HisProject.ProjectName
  11754. order.Cnt = subItem.Count
  11755. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11756. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11757. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11758. order.OwnpayAmt = ""
  11759. order.SelfpayAmt = ""
  11760. order.Spec = ""
  11761. order.SpecUnt = ""
  11762. order.DrordBegnDate = s_tm
  11763. order.DrordStopDate = ""
  11764. order.DrordDrCodg = doctor_info.DoctorNumber
  11765. order.DrordDeptName = department.Name
  11766. order.DrordDeptCodg = department.Number
  11767. order.DrordDrName = doctor_info.UserName
  11768. order.DrordDrProfttl = "234"
  11769. order.CurrDrordFlag = "1"
  11770. orders = append(orders, &order)
  11771. }
  11772. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11773. var order models.FsiOrderDtos
  11774. order.RxID = strconv.FormatInt(item.ID, 10)
  11775. order.Rxno = strconv.FormatInt(item.ID, 10)
  11776. order.LongDrordFlag = "0"
  11777. order.HilistType = "301"
  11778. order.ChrgType = "1"
  11779. order.DrordBhvr = "0"
  11780. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11781. order.HosplistName = subItem.GoodInfo.GoodName
  11782. order.HilistLv = "1"
  11783. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11784. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11785. order.HosplistName = subItem.GoodInfo.GoodName
  11786. order.Cnt = subItem.Count
  11787. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11788. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11789. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11790. order.OwnpayAmt = ""
  11791. order.SelfpayAmt = ""
  11792. order.Spec = ""
  11793. order.SpecUnt = ""
  11794. order.DrordBegnDate = s_tm
  11795. order.DrordStopDate = ""
  11796. order.DrordDrCodg = doctor_info.DoctorNumber
  11797. order.DrordDeptName = department.Name
  11798. order.DrordDeptCodg = department.Number
  11799. order.DrordDrName = doctor_info.UserName
  11800. order.DrordDrProfttl = "234"
  11801. order.CurrDrordFlag = "1"
  11802. orders = append(orders, &order)
  11803. }
  11804. }
  11805. }
  11806. //处方医嘱信息
  11807. fed.MatnStas = "0"
  11808. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11809. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11810. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11811. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11812. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11813. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11814. fed.SetlTotlnum = "1"
  11815. fed.Insutype = his.Insutype
  11816. fed.ReimFlag = "0"
  11817. fed.OutSetlFlag = "0"
  11818. var fopd []*models.FsiOperationDtosData
  11819. data := make(map[string]interface{})
  11820. data["fed"] = fed
  11821. data["fdd"] = fdds
  11822. data["fod"] = orders
  11823. data["pd"] = pd
  11824. data["pp"] = pp
  11825. data["fopd"] = fopd
  11826. data["trig_scen"] = trig_scen
  11827. client := &http.Client{}
  11828. bytesData, _ := json.Marshal(data)
  11829. var req *http.Request
  11830. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11831. if miConfig.MdtrtareaAdmvs == "320921" {
  11832. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11833. } else {
  11834. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11835. }
  11836. resp, _ := client.Do(req)
  11837. defer resp.Body.Close()
  11838. body, ioErr := ioutil.ReadAll(resp.Body)
  11839. if ioErr != nil {
  11840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11842. return res
  11843. }
  11844. var respJSON map[string]interface{}
  11845. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11848. return res
  11849. }
  11850. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11851. result, _ := json.Marshal(respJSON)
  11852. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11853. utils.ErrorLog("解析失败:%v", err)
  11854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11855. return res
  11856. }
  11857. return res
  11858. } else {
  11859. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11860. saveLog(output, input, "3102", "事中")
  11861. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11862. utils.ErrorLog("解析失败:%v", err)
  11863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11864. return
  11865. }
  11866. return res
  11867. }
  11868. return res
  11869. }
  11870. 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) {
  11871. var res Resultgd3101
  11872. adminUser := c.GetAdminUserInfo()
  11873. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11874. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11875. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11876. //record_time := c.GetString("record_time")
  11877. //trig_scen := c.GetString("trig_scen")
  11878. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11879. //psn_info, _ := service.GetPatientId(patient_id)
  11880. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11881. timeLayout := "2006-01-02"
  11882. loc, _ := time.LoadLocation("Local")
  11883. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11884. if err != nil {
  11885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11886. return res
  11887. }
  11888. recordDateTime := theTime.Unix()
  11889. var patientPrescription models.HisPrescriptionInfo
  11890. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11891. //if patientPrescription.ID == 0 {
  11892. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11893. //}
  11894. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11895. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11896. //
  11897. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11898. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11899. var str string
  11900. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  11901. str = timestampToBirthdayString(patient.Birthday)
  11902. }else{
  11903. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  11904. }
  11905. var pp models.PublicParams
  11906. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11907. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11908. pp.FixmedinsName = miConfig.OrgName
  11909. pp.FixmedinsCode = miConfig.Code
  11910. pp.RequestUrl = miConfig.Url
  11911. pp.Cainfo = miConfig.Cainfo
  11912. pp.SecretKey = miConfig.SecretKey
  11913. pp.AccessKey = miConfig.AccessKey
  11914. pp.OpterName = roles.UserName
  11915. var config []*models.HisXtDiagnoseConfig
  11916. for _, item := range diagnosis_ids {
  11917. id, _ := strconv.ParseInt(item, 10, 64)
  11918. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11919. config = append(config, &diagnosisConfig)
  11920. }
  11921. var pd models.PatientDtos
  11922. pd.PatnID = his.PsnNo
  11923. pd.PatnName = his.Name
  11924. pd.Gend = his.Gend
  11925. pd.Brdy = str
  11926. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11927. pd.CurrMdtrtID = his.Number
  11928. var fed models.FsiEncounterDtos
  11929. fed.MdtrtID = his.Number
  11930. fed.MedinsID = miConfig.Code
  11931. fed.MedinsName = miConfig.OrgName
  11932. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11933. fed.MedMdtrtType = "1"
  11934. fed.MedinsType = "1"
  11935. fed.MedinsLv = "11"
  11936. tm := time.Unix(his.RecordDate, 0)
  11937. s_tm := tm.Format("2006-01-02 15:04:05")
  11938. fed.AdmDate = s_tm
  11939. fed.DscgDate = s_tm
  11940. fed.DscgMainDiseCodg = config[0].CountryCode
  11941. fed.DscgMainDiseName = config[0].CountryContentName
  11942. //诊断信息
  11943. var fdds []*models.FsiDiagnoseDtos
  11944. for index, item := range config {
  11945. if index == 0 {
  11946. var fdd models.FsiDiagnoseDtos
  11947. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11948. fdd.InoutDiseType = "1"
  11949. fdd.MaindiseFlag = "1"
  11950. fdd.DiseDate = s_tm
  11951. fdd.DiasSrtNo = "1"
  11952. fdd.DiseName = item.CountryContentName
  11953. fdd.DiseCodg = item.CountryCode
  11954. fdds = append(fdds, &fdd)
  11955. } else {
  11956. var fdd models.FsiDiagnoseDtos
  11957. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11958. fdd.InoutDiseType = "1"
  11959. fdd.MaindiseFlag = "1"
  11960. fdd.DiseDate = s_tm
  11961. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11962. fdd.DiseName = item.CountryContentName
  11963. fdd.DiseCodg = item.CountryCode
  11964. fdds = append(fdds, &fdd)
  11965. }
  11966. }
  11967. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11968. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11969. fed.AdmDeptName = de.Name
  11970. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11971. fed.DscgDeptName = de.Name
  11972. fed.MedMdtrtType = "1"
  11973. fed.MedType = "11"
  11974. //if his.Insutype == "390" {
  11975. // fed.MedType = "1402"
  11976. //} else {
  11977. // fed.MedType = "9933"
  11978. //}
  11979. var orders []*models.FsiOrderDtos
  11980. if trig_scen == "2" {
  11981. //处方医嘱信息
  11982. for _, item := range prescriptions {
  11983. for _, subItem := range item.HisDoctorAdviceInfo {
  11984. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11985. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11986. var order models.FsiOrderDtos
  11987. order.RxID = strconv.FormatInt(item.ID, 10)
  11988. order.Rxno = strconv.FormatInt(item.ID, 10)
  11989. order.LongDrordFlag = "0"
  11990. order.HilistType = "101"
  11991. order.ChrgType = "1"
  11992. order.DrordBhvr = "0"
  11993. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11994. order.HosplistName = subItem.BaseDrugLib.DrugName
  11995. order.HilistLv = "1"
  11996. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11997. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11998. order.HosplistName = subItem.BaseDrugLib.DrugName
  11999. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12000. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12001. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12002. order.OwnpayAmt = ""
  12003. order.SelfpayAmt = ""
  12004. order.Spec = spec
  12005. order.SpecUnt = subItem.PrescribingNumberUnit
  12006. order.DrordBegnDate = s_tm
  12007. order.DrordStopDate = ""
  12008. order.DrordDrCodg = doctor_info.DoctorNumber
  12009. order.DrordDeptName = department.Name
  12010. order.DrordDeptCodg = department.Number
  12011. order.DrordDrName = doctor_info.UserName
  12012. order.DrordDrProfttl = "234"
  12013. order.CurrDrordFlag = "1"
  12014. orders = append(orders, &order)
  12015. }
  12016. }
  12017. for _, subItem := range item.HisPrescriptionProject {
  12018. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12019. var order models.FsiOrderDtos
  12020. order.RxID = strconv.FormatInt(item.ID, 10)
  12021. order.Rxno = strconv.FormatInt(item.ID, 10)
  12022. order.LongDrordFlag = "0"
  12023. order.HilistType = "201"
  12024. order.ChrgType = "1"
  12025. order.DrordBhvr = "0"
  12026. order.HilistCode = subItem.HisProject.MedicalCode
  12027. order.HosplistName = subItem.HisProject.ProjectName
  12028. order.HilistLv = "1"
  12029. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12030. order.HosplistCode = subItem.HisProject.MedicalCode
  12031. order.HosplistName = subItem.HisProject.ProjectName
  12032. order.Cnt = subItem.Count
  12033. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12034. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12035. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12036. order.OwnpayAmt = ""
  12037. order.SelfpayAmt = ""
  12038. order.Spec = subItem.Unit
  12039. order.SpecUnt = subItem.Unit
  12040. order.DrordBegnDate = s_tm
  12041. order.DrordStopDate = ""
  12042. order.DrordDrCodg = doctor_info.DoctorNumber
  12043. order.DrordDeptName = department.Name
  12044. order.DrordDeptCodg = department.Number
  12045. order.DrordDrName = doctor_info.UserName
  12046. order.DrordDrProfttl = "234"
  12047. order.CurrDrordFlag = "1"
  12048. orders = append(orders, &order)
  12049. }
  12050. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12051. var order models.FsiOrderDtos
  12052. order.RxID = strconv.FormatInt(item.ID, 10)
  12053. order.Rxno = strconv.FormatInt(item.ID, 10)
  12054. order.LongDrordFlag = "0"
  12055. order.HilistType = "301"
  12056. order.ChrgType = "1"
  12057. order.DrordBhvr = "0"
  12058. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12059. order.HosplistName = subItem.GoodInfo.GoodName
  12060. order.HilistLv = "1"
  12061. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12062. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12063. order.HosplistName = subItem.GoodInfo.GoodName
  12064. order.Cnt = subItem.Count
  12065. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12066. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12067. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12068. order.OwnpayAmt = ""
  12069. order.SelfpayAmt = ""
  12070. order.Spec = subItem.GoodInfo.SpecificationName
  12071. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12072. order.DrordBegnDate = s_tm
  12073. order.DrordStopDate = ""
  12074. order.DrordDrCodg = doctor_info.DoctorNumber
  12075. order.DrordDeptName = department.Name
  12076. order.DrordDeptCodg = department.Number
  12077. order.DrordDrName = doctor_info.UserName
  12078. order.DrordDrProfttl = "234"
  12079. order.CurrDrordFlag = "1"
  12080. orders = append(orders, &order)
  12081. }
  12082. }
  12083. }
  12084. //处方医嘱信息
  12085. }
  12086. fed.MatnStas = "0"
  12087. fed.MedfeeSumamt = "0"
  12088. fed.OwnpayAmt = "0"
  12089. fed.SelfpayAmt = "0"
  12090. fed.AcctPayamt = "0"
  12091. fed.MaAmt = "0"
  12092. fed.HifpPayamt = "0"
  12093. fed.SetlTotlnum = "1"
  12094. fed.Insutype = his.Insutype
  12095. fed.ReimFlag = "0"
  12096. fed.OutSetlFlag = "0"
  12097. var fopd []*models.FsiOperationDtosData
  12098. data := make(map[string]interface{})
  12099. data["fed"] = fed
  12100. data["fdd"] = fdds
  12101. data["fod"] = orders
  12102. data["pd"] = pd
  12103. data["pp"] = pp
  12104. data["fopd"] = fopd
  12105. data["trig_scen"] = trig_scen
  12106. fmt.Println(data)
  12107. fmt.Println(fed)
  12108. fmt.Println(fdds)
  12109. fmt.Println(orders)
  12110. fmt.Println(pd)
  12111. fmt.Println(pp)
  12112. fmt.Println(fopd)
  12113. client := &http.Client{}
  12114. bytesData, _ := json.Marshal(data)
  12115. var req *http.Request
  12116. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12117. if miConfig.MdtrtareaAdmvs == "320921" {
  12118. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12119. } else {
  12120. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12121. }
  12122. resp, _ := client.Do(req)
  12123. defer resp.Body.Close()
  12124. body, ioErr := ioutil.ReadAll(resp.Body)
  12125. if ioErr != nil {
  12126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12128. return res
  12129. }
  12130. var respJSON map[string]interface{}
  12131. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12134. return res
  12135. }
  12136. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12137. fmt.Println(respJSON)
  12138. result, _ := json.Marshal(respJSON)
  12139. fmt.Println(result)
  12140. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12141. utils.ErrorLog("解析失败:%v", err)
  12142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12143. return res
  12144. }
  12145. return res
  12146. } else {
  12147. //if miConfig.MdtrtareaAdmvs == "441202" {
  12148. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12149. saveLog(output, input, "3101", "事前")
  12150. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12151. utils.ErrorLog("解析失败:%v", err)
  12152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12153. return
  12154. }
  12155. return res
  12156. //}
  12157. }
  12158. }
  12159. 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) {
  12160. adminUser := c.GetAdminUserInfo()
  12161. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12162. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12163. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12164. //record_time := c.GetString("record_time")
  12165. //trig_scen := c.GetString("trig_scen")
  12166. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12167. timeLayout := "2006-01-02"
  12168. loc, _ := time.LoadLocation("Local")
  12169. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12170. if err != nil {
  12171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12172. return res
  12173. }
  12174. recordDateTime := theTime.Unix()
  12175. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12176. var patientPrescription models.HisPrescriptionInfo
  12177. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12178. if patientPrescription.ID == 0 {
  12179. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12180. }
  12181. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12182. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12183. //
  12184. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12185. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12186. var pp models.PublicParams
  12187. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12188. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12189. pp.FixmedinsName = miConfig.OrgName
  12190. pp.FixmedinsCode = miConfig.Code
  12191. pp.RequestUrl = miConfig.Url
  12192. pp.Cainfo = miConfig.Cainfo
  12193. pp.SecretKey = miConfig.SecretKey
  12194. pp.AccessKey = miConfig.AccessKey
  12195. pp.OpterName = roles.UserName
  12196. var config []*models.HisXtDiagnoseConfig
  12197. for _, item := range diagnosis_ids {
  12198. id, _ := strconv.ParseInt(item, 10, 64)
  12199. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12200. config = append(config, &diagnosisConfig)
  12201. }
  12202. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12203. var str string
  12204. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12205. str = timestampToBirthdayString(patient.Birthday)
  12206. }else{
  12207. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12208. }
  12209. var pd models.PatientDtos
  12210. pd.PatnID = his.PsnNo
  12211. pd.PatnName = his.Name
  12212. pd.Gend = his.Gend
  12213. pd.Brdy = str
  12214. pd.Poolarea = his.InsuplcAdmdvs
  12215. pd.CurrMdtrtID = his.Number
  12216. var fed models.FsiEncounterDtos
  12217. fed.MdtrtID = his.Number
  12218. fed.MedinsID = miConfig.Code
  12219. fed.MedinsName = miConfig.OrgName
  12220. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12221. fed.MedMdtrtType = "1"
  12222. fed.MedinsType = "1"
  12223. fed.MedinsLv = "11"
  12224. tm := time.Unix(his.RecordDate, 0)
  12225. s_tm := tm.Format("2006-01-02 15:04:05")
  12226. fed.AdmDate = s_tm
  12227. fed.DscgDate = s_tm
  12228. fed.DscgMainDiseCodg = config[0].CountryCode
  12229. fed.DscgMainDiseName = config[0].CountryContentName
  12230. //诊断信息
  12231. var fdds []*models.FsiDiagnoseDtos
  12232. for index, item := range config {
  12233. if index == 0 {
  12234. var fdd models.FsiDiagnoseDtos
  12235. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12236. fdd.InoutDiseType = "1"
  12237. fdd.MaindiseFlag = "1"
  12238. fdd.DiseDate = s_tm
  12239. fdd.DiasSrtNo = "1"
  12240. fdd.DiseName = item.CountryContentName
  12241. fdd.DiseCodg = item.CountryCode
  12242. fdds = append(fdds, &fdd)
  12243. } else {
  12244. var fdd models.FsiDiagnoseDtos
  12245. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12246. fdd.InoutDiseType = "1"
  12247. fdd.MaindiseFlag = "1"
  12248. fdd.DiseDate = s_tm
  12249. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12250. fdd.DiseName = item.CountryContentName
  12251. fdd.DiseCodg = item.CountryCode
  12252. fdds = append(fdds, &fdd)
  12253. }
  12254. }
  12255. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12256. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12257. fed.AdmDeptName = department.Name
  12258. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12259. fed.DscgDeptName = department.Name
  12260. fed.MedMdtrtType = "1"
  12261. fed.MedType = "11"
  12262. //if his.Insutype == "390" {
  12263. // fed.MedType = "1402"
  12264. //} else {
  12265. // fed.MedType = "9933"
  12266. //}
  12267. var orders []*models.FsiOrderDtos
  12268. if trig_scen == "2" {
  12269. //处方医嘱信息
  12270. for _, item := range prescriptions {
  12271. for _, subItem := range item.HisDoctorAdviceInfo {
  12272. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12273. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12274. var order models.FsiOrderDtos
  12275. order.RxID = strconv.FormatInt(item.ID, 10)
  12276. order.Rxno = strconv.FormatInt(item.ID, 10)
  12277. order.LongDrordFlag = "0"
  12278. order.HilistType = "101"
  12279. order.ChrgType = "1"
  12280. order.DrordBhvr = "0"
  12281. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12282. order.HosplistName = subItem.BaseDrugLib.DrugName
  12283. order.HilistLv = "1"
  12284. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12285. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12286. order.HosplistName = subItem.BaseDrugLib.DrugName
  12287. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12288. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12289. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12290. order.OwnpayAmt = ""
  12291. order.SelfpayAmt = ""
  12292. order.Spec = spec
  12293. order.SpecUnt = subItem.PrescribingNumberUnit
  12294. order.DrordBegnDate = s_tm
  12295. order.DrordStopDate = ""
  12296. order.DrordDrCodg = doctor_info.DoctorNumber
  12297. order.DrordDeptName = department.Name
  12298. order.DrordDeptCodg = department.Number
  12299. order.DrordDrName = doctor_info.UserName
  12300. order.DrordDrProfttl = "234"
  12301. order.CurrDrordFlag = "1"
  12302. orders = append(orders, &order)
  12303. }
  12304. }
  12305. for _, subItem := range item.HisPrescriptionProject {
  12306. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12307. var order models.FsiOrderDtos
  12308. order.RxID = strconv.FormatInt(item.ID, 10)
  12309. order.Rxno = strconv.FormatInt(item.ID, 10)
  12310. order.LongDrordFlag = "0"
  12311. order.HilistType = "201"
  12312. order.ChrgType = "1"
  12313. order.DrordBhvr = "0"
  12314. order.HilistCode = subItem.HisProject.MedicalCode
  12315. order.HosplistName = subItem.HisProject.ProjectName
  12316. order.HilistLv = "1"
  12317. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12318. order.HosplistCode = subItem.HisProject.MedicalCode
  12319. order.HosplistName = subItem.HisProject.ProjectName
  12320. order.Cnt = subItem.Count
  12321. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12322. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12323. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12324. order.OwnpayAmt = ""
  12325. order.SelfpayAmt = ""
  12326. order.Spec = subItem.Unit
  12327. order.SpecUnt = subItem.Unit
  12328. order.DrordBegnDate = s_tm
  12329. order.DrordStopDate = ""
  12330. order.DrordDrCodg = doctor_info.DoctorNumber
  12331. order.DrordDeptName = department.Name
  12332. order.DrordDeptCodg = department.Number
  12333. order.DrordDrName = doctor_info.UserName
  12334. order.DrordDrProfttl = "234"
  12335. order.CurrDrordFlag = "1"
  12336. orders = append(orders, &order)
  12337. }
  12338. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12339. var order models.FsiOrderDtos
  12340. order.RxID = strconv.FormatInt(item.ID, 10)
  12341. order.Rxno = strconv.FormatInt(item.ID, 10)
  12342. order.LongDrordFlag = "0"
  12343. order.HilistType = "301"
  12344. order.ChrgType = "1"
  12345. order.DrordBhvr = "0"
  12346. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12347. order.HosplistName = subItem.GoodInfo.GoodName
  12348. order.HilistLv = "1"
  12349. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12350. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12351. order.HosplistName = subItem.GoodInfo.GoodName
  12352. order.Cnt = subItem.Count
  12353. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12354. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12355. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12356. order.OwnpayAmt = ""
  12357. order.SelfpayAmt = ""
  12358. order.Spec = subItem.GoodInfo.SpecificationName
  12359. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12360. order.DrordBegnDate = s_tm
  12361. order.DrordStopDate = ""
  12362. order.DrordDrCodg = doctor_info.DoctorNumber
  12363. order.DrordDeptName = department.Name
  12364. order.DrordDeptCodg = department.Number
  12365. order.DrordDrName = doctor_info.UserName
  12366. order.DrordDrProfttl = "234"
  12367. order.CurrDrordFlag = "1"
  12368. orders = append(orders, &order)
  12369. }
  12370. }
  12371. }
  12372. //处方医嘱信息
  12373. }
  12374. fed.MatnStas = "0"
  12375. fed.MedfeeSumamt = "0"
  12376. fed.OwnpayAmt = "0"
  12377. fed.SelfpayAmt = "0"
  12378. fed.AcctPayamt = "0"
  12379. fed.MaAmt = "0"
  12380. fed.HifpPayamt = "0"
  12381. fed.SetlTotlnum = "1"
  12382. fed.Insutype = his.Insutype
  12383. fed.ReimFlag = "0"
  12384. fed.OutSetlFlag = "0"
  12385. var fopd []*models.FsiOperationDtosData
  12386. data := make(map[string]interface{})
  12387. data["fed"] = fed
  12388. data["fdd"] = fdds
  12389. data["fod"] = orders
  12390. data["pd"] = pd
  12391. data["pp"] = pp
  12392. data["fopd"] = fopd
  12393. data["trig_scen"] = trig_scen
  12394. fmt.Println(data)
  12395. fmt.Println(fed)
  12396. fmt.Println(fdds)
  12397. fmt.Println(orders)
  12398. fmt.Println(pd)
  12399. fmt.Println(pp)
  12400. fmt.Println(fopd)
  12401. client := &http.Client{}
  12402. bytesData, _ := json.Marshal(data)
  12403. var req *http.Request
  12404. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12405. if miConfig.MdtrtareaAdmvs == "320921" {
  12406. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12407. } else {
  12408. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12409. }
  12410. resp, _ := client.Do(req)
  12411. defer resp.Body.Close()
  12412. body, ioErr := ioutil.ReadAll(resp.Body)
  12413. if ioErr != nil {
  12414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12416. return res
  12417. }
  12418. var respJSON map[string]interface{}
  12419. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12422. return res
  12423. }
  12424. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12425. fmt.Println(respJSON)
  12426. result, _ := json.Marshal(respJSON)
  12427. fmt.Println(result)
  12428. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12429. utils.ErrorLog("解析失败:%v", err)
  12430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12431. return res
  12432. }
  12433. return res
  12434. } else {
  12435. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12436. saveLog(output, input, "3101", "事前")
  12437. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12438. utils.ErrorLog("解析失败:%v", err)
  12439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12440. return
  12441. }
  12442. return res
  12443. }
  12444. return res
  12445. }
  12446. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12447. adminUser := c.GetAdminUserInfo()
  12448. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12449. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12450. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12451. record_time := c.GetString("record_time")
  12452. order, _ := service.GetHisOrderByID(order_id)
  12453. timeLayout := "2006-01-02"
  12454. loc, _ := time.LoadLocation("Local")
  12455. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12456. if err != nil {
  12457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12458. return
  12459. }
  12460. recordDateTime := theTime.Unix()
  12461. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12462. var patientPrescription models.HisPrescriptionInfo
  12463. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12464. if patientPrescription.ID == 0 {
  12465. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12466. }
  12467. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12468. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12469. //
  12470. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12471. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12472. var pp models.PublicParams
  12473. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12474. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12475. pp.FixmedinsName = miConfig.OrgName
  12476. pp.FixmedinsCode = miConfig.Code
  12477. pp.RequestUrl = miConfig.Url
  12478. pp.Cainfo = miConfig.Cainfo
  12479. pp.SecretKey = miConfig.SecretKey
  12480. pp.AccessKey = miConfig.AccessKey
  12481. pp.OpterName = roles.UserName
  12482. var config []*models.HisXtDiagnoseConfig
  12483. for _, item := range diagnosis_ids {
  12484. id, _ := strconv.ParseInt(item, 10, 64)
  12485. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12486. config = append(config, &diagnosisConfig)
  12487. }
  12488. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12489. var str string
  12490. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12491. str = timestampToBirthdayString(patient.Birthday)
  12492. }else{
  12493. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12494. }
  12495. var pd models.PatientDtos
  12496. pd.PatnID = his.PsnNo
  12497. pd.PatnName = his.Name
  12498. pd.Gend = his.Gend
  12499. pd.Brdy = str
  12500. pd.Poolarea = his.InsuplcAdmdvs
  12501. pd.CurrMdtrtID = his.Number
  12502. var fed models.FsiEncounterDtos
  12503. fed.MdtrtID = his.Number
  12504. fed.MedinsID = miConfig.Code
  12505. fed.MedinsName = miConfig.OrgName
  12506. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12507. fed.MedMdtrtType = "1"
  12508. fed.MedinsType = "1"
  12509. fed.MedinsLv = "11"
  12510. tm := time.Unix(his.RecordDate, 0)
  12511. s_tm := tm.Format("2006-01-02 15:04:05")
  12512. fed.AdmDate = s_tm
  12513. fed.DscgDate = s_tm
  12514. fed.DscgMainDiseCodg = config[0].CountryCode
  12515. fed.DscgMainDiseName = config[0].CountryContentName
  12516. //诊断信息
  12517. var fdds []*models.FsiDiagnoseDtos
  12518. for index, item := range config {
  12519. if index == 0 {
  12520. var fdd models.FsiDiagnoseDtos
  12521. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12522. fdd.InoutDiseType = "1"
  12523. fdd.MaindiseFlag = "1"
  12524. fdd.DiseDate = s_tm
  12525. fdd.DiasSrtNo = "1"
  12526. fdd.DiseName = item.CountryContentName
  12527. fdd.DiseCodg = item.CountryCode
  12528. fdds = append(fdds, &fdd)
  12529. } else {
  12530. var fdd models.FsiDiagnoseDtos
  12531. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12532. fdd.InoutDiseType = "1"
  12533. fdd.MaindiseFlag = "1"
  12534. fdd.DiseDate = s_tm
  12535. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12536. fdd.DiseName = item.CountryContentName
  12537. fdd.DiseCodg = item.CountryCode
  12538. fdds = append(fdds, &fdd)
  12539. }
  12540. }
  12541. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12542. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12543. fed.AdmDeptName = department.Name
  12544. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12545. fed.DscgDeptName = department.Name
  12546. fed.MedType = order.MedType
  12547. //处方医嘱信息
  12548. var orders []*models.FsiOrderDtos
  12549. //for _, item := range prescriptions {
  12550. // for _, subItem := range item.HisDoctorAdviceInfo {
  12551. // var order models.FsiOrderDtos
  12552. // order.RxID = strconv.FormatInt(item.ID, 10)
  12553. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12554. // order.LongDrordFlag = "0"
  12555. // order.HilistType = "1"
  12556. // order.ChrgType = "1"
  12557. // order.DrordBhvr = "-"
  12558. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12559. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12560. // order.HilistLv = "1"
  12561. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12562. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12563. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12564. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12565. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12566. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12567. // order.OwnpayAmt = ""
  12568. // order.SelfpayAmt = ""
  12569. // order.Spec = ""
  12570. // order.SpecUnt = ""
  12571. // order.DrordBegnDate = s_tm
  12572. // order.DrordStopDate = ""
  12573. // order.DrordDrCodg = "1"
  12574. // order.DrordDeptName = department.Name
  12575. // order.DrordDrCodg = "1"
  12576. // order.DrordDrName = doctor_info.UserName
  12577. // order.DrordDrProfttl = ""
  12578. // order.CurrDrordFlag = "1"
  12579. // orders = append(orders, &order)
  12580. // }
  12581. // for _, subItem := range item.HisPrescriptionProject {
  12582. // if subItem.Type == 2 {
  12583. // var order models.FsiOrderDtos
  12584. // order.RxID = strconv.FormatInt(item.ID, 10)
  12585. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12586. // order.LongDrordFlag = "0"
  12587. // order.HilistType = "1"
  12588. // order.ChrgType = "1"
  12589. // order.DrordBhvr = "-"
  12590. // order.HilistCode = subItem.HisProject.MedicalCode
  12591. // order.HosplistName = subItem.HisProject.ProjectName
  12592. // order.HilistLv = "1"
  12593. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12594. // order.HosplistCode = subItem.HisProject.MedicalCode
  12595. // order.HosplistName = subItem.HisProject.ProjectName
  12596. // order.Cnt = subItem.Count
  12597. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12598. //
  12599. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12600. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12601. // order.OwnpayAmt = ""
  12602. // order.SelfpayAmt = ""
  12603. // order.Spec = ""
  12604. // order.SpecUnt = ""
  12605. // order.DrordBegnDate = s_tm
  12606. // order.DrordStopDate = ""
  12607. // order.DrordDrCodg = "1"
  12608. // order.DrordDeptName = department.Name
  12609. // order.DrordDrCodg = "1"
  12610. // order.DrordDrName = doctor_info.UserName
  12611. // order.DrordDrProfttl = ""
  12612. // order.CurrDrordFlag = "1"
  12613. // orders = append(orders, &order)
  12614. //
  12615. // }
  12616. // if subItem.Type == 3 {
  12617. //
  12618. // var order models.FsiOrderDtos
  12619. // order.RxID = strconv.FormatInt(item.ID, 10)
  12620. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12621. // order.LongDrordFlag = "0"
  12622. // order.HilistType = "1"
  12623. // order.ChrgType = "1"
  12624. // order.DrordBhvr = "-"
  12625. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12626. // order.HosplistName = subItem.GoodInfo.GoodName
  12627. // order.HilistLv = "1"
  12628. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12629. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12630. // order.HosplistName = subItem.GoodInfo.GoodName
  12631. // order.Cnt = subItem.Count
  12632. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12633. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12634. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12635. // order.OwnpayAmt = ""
  12636. // order.SelfpayAmt = ""
  12637. // order.Spec = ""
  12638. // order.SpecUnt = ""
  12639. // order.DrordBegnDate = s_tm
  12640. // order.DrordStopDate = ""
  12641. // order.DrordDrCodg = "1"
  12642. // order.DrordDeptName = department.Name
  12643. // order.DrordDrCodg = "1"
  12644. // order.DrordDrName = doctor_info.UserName
  12645. // order.DrordDrProfttl = ""
  12646. // order.CurrDrordFlag = "1"
  12647. // orders = append(orders, &order)
  12648. //
  12649. // }
  12650. // }
  12651. //}
  12652. for _, item := range prescriptions {
  12653. for _, subItem := range item.HisDoctorAdviceInfo {
  12654. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12655. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12656. var order models.FsiOrderDtos
  12657. order.RxID = strconv.FormatInt(item.ID, 10)
  12658. order.Rxno = strconv.FormatInt(item.ID, 10)
  12659. order.LongDrordFlag = "0"
  12660. order.HilistType = "101"
  12661. order.ChrgType = "01"
  12662. order.DrordBhvr = "0"
  12663. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12664. order.HosplistName = subItem.BaseDrugLib.DrugName
  12665. order.HilistLv = "1"
  12666. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12667. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12668. order.HosplistName = subItem.BaseDrugLib.DrugName
  12669. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12670. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12671. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12672. order.OwnpayAmt = ""
  12673. order.SelfpayAmt = ""
  12674. order.Spec = spec
  12675. order.SpecUnt = subItem.PrescribingNumberUnit
  12676. order.DrordBegnDate = s_tm
  12677. order.DrordStopDate = ""
  12678. order.DrordDrCodg = doctor_info.DoctorNumber
  12679. order.DrordDeptName = department.Name
  12680. order.DrordDeptCodg = department.Number
  12681. order.DrordDrName = doctor_info.UserName
  12682. order.DrordDrProfttl = "234"
  12683. order.CurrDrordFlag = "1"
  12684. orders = append(orders, &order)
  12685. }
  12686. }
  12687. for _, subItem := range item.HisPrescriptionProject {
  12688. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12689. var order models.FsiOrderDtos
  12690. order.RxID = strconv.FormatInt(item.ID, 10)
  12691. order.Rxno = strconv.FormatInt(item.ID, 10)
  12692. order.LongDrordFlag = "0"
  12693. order.HilistType = "201"
  12694. order.ChrgType = "05"
  12695. order.DrordBhvr = "0"
  12696. order.HilistCode = subItem.HisProject.MedicalCode
  12697. order.HosplistName = subItem.HisProject.ProjectName
  12698. order.HilistLv = "1"
  12699. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12700. order.HosplistCode = subItem.HisProject.MedicalCode
  12701. order.HosplistName = subItem.HisProject.ProjectName
  12702. order.Cnt = subItem.Count
  12703. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12704. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12705. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12706. order.OwnpayAmt = ""
  12707. order.SelfpayAmt = ""
  12708. order.Spec = subItem.Unit
  12709. order.SpecUnt = subItem.Unit
  12710. order.DrordBegnDate = s_tm
  12711. order.DrordStopDate = ""
  12712. order.DrordDrCodg = doctor_info.DoctorNumber
  12713. order.DrordDeptName = department.Name
  12714. order.DrordDeptCodg = department.Number
  12715. order.DrordDrName = doctor_info.UserName
  12716. order.DrordDrProfttl = "234"
  12717. order.CurrDrordFlag = "1"
  12718. orders = append(orders, &order)
  12719. }
  12720. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12721. var order models.FsiOrderDtos
  12722. order.RxID = strconv.FormatInt(item.ID, 10)
  12723. order.Rxno = strconv.FormatInt(item.ID, 10)
  12724. order.LongDrordFlag = "0"
  12725. order.HilistType = "301"
  12726. order.ChrgType = "08"
  12727. order.DrordBhvr = "0"
  12728. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12729. order.HosplistName = subItem.GoodInfo.GoodName
  12730. order.HilistLv = "1"
  12731. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12732. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12733. order.HosplistName = subItem.GoodInfo.GoodName
  12734. order.Cnt = subItem.Count
  12735. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12736. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12737. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12738. order.OwnpayAmt = ""
  12739. order.SelfpayAmt = ""
  12740. order.Spec = subItem.GoodInfo.SpecificationName
  12741. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12742. order.DrordBegnDate = s_tm
  12743. order.DrordStopDate = ""
  12744. order.DrordDrCodg = doctor_info.DoctorNumber
  12745. order.DrordDeptName = department.Name
  12746. order.DrordDeptCodg = department.Number
  12747. order.DrordDrName = doctor_info.UserName
  12748. order.DrordDrProfttl = "234"
  12749. order.CurrDrordFlag = "1"
  12750. orders = append(orders, &order)
  12751. }
  12752. }
  12753. }
  12754. //处方医嘱信息
  12755. fed.MatnStas = "0"
  12756. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12757. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12758. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12759. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12760. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12761. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12762. fed.SetlTotlnum = "1"
  12763. fed.Insutype = his.Insutype
  12764. fed.ReimFlag = "0"
  12765. fed.OutSetlFlag = "0"
  12766. var fopd []*models.FsiOperationDtosData
  12767. data := make(map[string]interface{})
  12768. data["fed"] = fed
  12769. data["fdd"] = fdds
  12770. data["fod"] = orders
  12771. data["pd"] = pd
  12772. data["pp"] = pp
  12773. data["fopd"] = fopd
  12774. data["trig_scen"] = trig_scen
  12775. client := &http.Client{}
  12776. bytesData, _ := json.Marshal(data)
  12777. var req *http.Request
  12778. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12779. if miConfig.MdtrtareaAdmvs == "320921" {
  12780. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12781. } else {
  12782. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12783. }
  12784. resp, _ := client.Do(req)
  12785. defer resp.Body.Close()
  12786. body, ioErr := ioutil.ReadAll(resp.Body)
  12787. if ioErr != nil {
  12788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12790. return res
  12791. }
  12792. var respJSON map[string]interface{}
  12793. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12796. return res
  12797. }
  12798. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12799. result, _ := json.Marshal(respJSON)
  12800. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12801. utils.ErrorLog("解析失败:%v", err)
  12802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12803. return res
  12804. }
  12805. return res
  12806. } else {
  12807. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12808. saveLog(output, input, "3102", "事中")
  12809. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12810. utils.ErrorLog("解析失败:%v", err)
  12811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12812. return
  12813. }
  12814. return res
  12815. }
  12816. return res
  12817. }
  12818. func (c *HisApiController) Check() {
  12819. psn_no := c.GetString("psn_no")
  12820. in := c.GetString("in")
  12821. mt := c.GetString("mt")
  12822. baseParams := models.BaseParams{
  12823. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12824. FixmedinsCode: "H15049901371",
  12825. InsuplcAdmdvs: "150499",
  12826. MdtrtareaAdmvs: "150499",
  12827. OrgName: "赤峰费森血液透析中心",
  12828. Doctor: "1111",
  12829. }
  12830. service.Gdyb2001(baseParams, psn_no, in, mt)
  12831. }
  12832. func (c *HisApiController) GetPsnNcdsInfo() {
  12833. admin_user_id, _ := c.GetInt64("admin_user_id")
  12834. patient_id, _ := c.GetInt64("patient_id")
  12835. //id, _ := c.GetInt64("id")
  12836. adminUser := c.GetAdminUserInfo()
  12837. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12838. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12839. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12840. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12841. //psn_record, _ := service.GetP(id)
  12842. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12843. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12844. //
  12845. //if psn_record.ID == 0 {
  12846. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12847. // return
  12848. //}
  12849. var res Result5301
  12850. var res10265 Result5301For10265
  12851. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12852. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12853. var api string
  12854. if miConfig.MdtrtareaAdmvs == "320921" {
  12855. 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 +
  12856. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12857. } else {
  12858. 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 +
  12859. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12860. }
  12861. resp, requestErr := http.Get(api)
  12862. if requestErr != nil {
  12863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12864. return
  12865. }
  12866. body, ioErr := ioutil.ReadAll(resp.Body)
  12867. if ioErr != nil {
  12868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12870. return
  12871. }
  12872. var respJSON map[string]interface{}
  12873. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12876. return
  12877. }
  12878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12879. result, _ := json.Marshal(respJSON)
  12880. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12881. utils.ErrorLog("解析失败:%v", err)
  12882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12883. return
  12884. }
  12885. res.ErrMsg = res10265.ErrMsg
  12886. res.Output = res10265.Output
  12887. res.InfRefmsgid = res10265.InfRefmsgid
  12888. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12889. res.Infcode = infocode
  12890. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12891. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12892. var api string
  12893. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12894. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12895. resp, requestErr := http.Get(api)
  12896. if requestErr != nil {
  12897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12898. return
  12899. }
  12900. body, ioErr := ioutil.ReadAll(resp.Body)
  12901. if ioErr != nil {
  12902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12904. return
  12905. }
  12906. var respJSON map[string]interface{}
  12907. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12910. return
  12911. }
  12912. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12913. if status == "0" {
  12914. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12915. c.ServeSuccessJSON(map[string]interface{}{
  12916. "failed_code": -10,
  12917. "msg": err_msg,
  12918. })
  12919. return
  12920. }
  12921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12922. result, _ := json.Marshal(respJSON)
  12923. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12924. utils.ErrorLog("解析失败:%v", err)
  12925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12926. return
  12927. }
  12928. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12929. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12930. var api string
  12931. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12932. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12933. resp, requestErr := http.Get(api)
  12934. if requestErr != nil {
  12935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12936. return
  12937. }
  12938. body, ioErr := ioutil.ReadAll(resp.Body)
  12939. if ioErr != nil {
  12940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12942. return
  12943. }
  12944. var respJSON map[string]interface{}
  12945. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12948. return
  12949. }
  12950. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12951. if status == "0" {
  12952. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12953. c.ServeSuccessJSON(map[string]interface{}{
  12954. "failed_code": -10,
  12955. "msg": err_msg,
  12956. })
  12957. return
  12958. }
  12959. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12960. result, _ := json.Marshal(respJSON)
  12961. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12962. utils.ErrorLog("解析失败:%v", err)
  12963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12964. return
  12965. }
  12966. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12967. p, _ := service.GetHisPatientById(patient_id)
  12968. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12969. var dat map[string]interface{}
  12970. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12971. fmt.Println(dat)
  12972. } else {
  12973. fmt.Println(err)
  12974. }
  12975. userJSONBytes, _ := json.Marshal(dat)
  12976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12977. utils.ErrorLog("解析失败:%v", err)
  12978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12979. return
  12980. }
  12981. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12982. p, _ := service.GetHisPatientById(patient_id)
  12983. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12984. var dat map[string]interface{}
  12985. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12986. fmt.Println(dat)
  12987. } else {
  12988. fmt.Println(err)
  12989. }
  12990. userJSONBytes, _ := json.Marshal(dat)
  12991. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12992. utils.ErrorLog("解析失败:%v", err)
  12993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12994. return
  12995. }
  12996. } else if miConfig.MdtrtareaAdmvs == "360100" {
  12997. p, _ := service.GetHisPatientById(patient_id)
  12998. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12999. var dat map[string]interface{}
  13000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13001. fmt.Println(dat)
  13002. } else {
  13003. fmt.Println(err)
  13004. }
  13005. userJSONBytes, _ := json.Marshal(dat)
  13006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13007. utils.ErrorLog("解析失败:%v", err)
  13008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13009. return
  13010. }
  13011. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13012. p, _ := service.GetHisPatientById(patient_id)
  13013. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13014. var dat map[string]interface{}
  13015. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13016. fmt.Println(dat)
  13017. } else {
  13018. fmt.Println(err)
  13019. }
  13020. userJSONBytes, _ := json.Marshal(dat)
  13021. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13022. utils.ErrorLog("解析失败:%v", err)
  13023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13024. return
  13025. }
  13026. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13027. p, _ := service.GetHisPatientById(patient_id)
  13028. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13029. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13030. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13031. resp, requestErr := http.Get(api)
  13032. if requestErr != nil {
  13033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13034. return
  13035. }
  13036. body, ioErr := ioutil.ReadAll(resp.Body)
  13037. if ioErr != nil {
  13038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13040. return
  13041. }
  13042. var respJSON map[string]interface{}
  13043. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13046. return
  13047. }
  13048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13049. result, _ := json.Marshal(respJSON)
  13050. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13051. utils.ErrorLog("解析失败:%v", err)
  13052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13053. return
  13054. }
  13055. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13056. p, _ := service.GetHisPatientById(patient_id)
  13057. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  13058. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13059. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13060. resp, requestErr := http.Get(api)
  13061. if requestErr != nil {
  13062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13063. return
  13064. }
  13065. body, ioErr := ioutil.ReadAll(resp.Body)
  13066. if ioErr != nil {
  13067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13069. return
  13070. }
  13071. var respJSON map[string]interface{}
  13072. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13075. return
  13076. }
  13077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13078. result, _ := json.Marshal(respJSON)
  13079. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13080. utils.ErrorLog("解析失败:%v", err)
  13081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13082. return
  13083. }
  13084. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13085. p, _ := service.GetHisPatientById(patient_id)
  13086. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13087. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13088. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13089. resp, requestErr := http.Get(api)
  13090. if requestErr != nil {
  13091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13092. return
  13093. }
  13094. body, ioErr := ioutil.ReadAll(resp.Body)
  13095. if ioErr != nil {
  13096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13098. return
  13099. }
  13100. var respJSON map[string]interface{}
  13101. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13104. return
  13105. }
  13106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13107. result, _ := json.Marshal(respJSON)
  13108. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13109. utils.ErrorLog("解析失败:%v", err)
  13110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13111. return
  13112. }
  13113. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13114. p, _ := service.GetHisPatientById(patient_id)
  13115. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13116. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13117. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13118. resp, requestErr := http.Get(api)
  13119. if requestErr != nil {
  13120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13121. return
  13122. }
  13123. body, ioErr := ioutil.ReadAll(resp.Body)
  13124. if ioErr != nil {
  13125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13127. return
  13128. }
  13129. var respJSON map[string]interface{}
  13130. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13133. return
  13134. }
  13135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13136. result, _ := json.Marshal(respJSON)
  13137. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13138. utils.ErrorLog("解析失败:%v", err)
  13139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13140. return
  13141. }
  13142. } else if miConfig.MdtrtareaAdmvs == "421300" {
  13143. p, _ := service.GetHisPatientById(patient_id)
  13144. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13145. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13146. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13147. resp, requestErr := http.Get(api)
  13148. if requestErr != nil {
  13149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13150. return
  13151. }
  13152. body, ioErr := ioutil.ReadAll(resp.Body)
  13153. if ioErr != nil {
  13154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13156. return
  13157. }
  13158. var respJSON map[string]interface{}
  13159. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13162. return
  13163. }
  13164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13165. result, _ := json.Marshal(respJSON)
  13166. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13167. utils.ErrorLog("解析失败:%v", err)
  13168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13169. return
  13170. }
  13171. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13172. p, _ := service.GetHisPatientById(patient_id)
  13173. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  13174. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13175. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13176. resp, requestErr := http.Get(api)
  13177. if requestErr != nil {
  13178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13179. return
  13180. }
  13181. body, ioErr := ioutil.ReadAll(resp.Body)
  13182. if ioErr != nil {
  13183. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13185. return
  13186. }
  13187. var respJSON map[string]interface{}
  13188. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13191. return
  13192. }
  13193. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13194. result, _ := json.Marshal(respJSON)
  13195. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13196. utils.ErrorLog("解析失败:%v", err)
  13197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13198. return
  13199. }
  13200. } else {
  13201. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  13202. var dat map[string]interface{}
  13203. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13204. fmt.Println(dat)
  13205. } else {
  13206. fmt.Println(err)
  13207. }
  13208. userJSONBytes, _ := json.Marshal(dat)
  13209. if miConfig.Code == "H15049901371" {
  13210. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13211. utils.ErrorLog("解析失败:%v", err)
  13212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13213. return
  13214. }
  13215. res.InfRefmsgid = res10265.InfRefmsgid
  13216. res.Output = res10265.Output
  13217. res.ErrMsg = res10265.ErrMsg
  13218. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13219. res.Infcode = infocode
  13220. } else {
  13221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13222. utils.ErrorLog("解析失败:%v", err)
  13223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13224. return
  13225. }
  13226. }
  13227. }
  13228. if res.Infcode == 0 {
  13229. c.ServeSuccessJSON(map[string]interface{}{
  13230. "result": res.Output.Result,
  13231. })
  13232. }
  13233. }
  13234. func (c *HisApiController) CheckInsutype() {
  13235. his_patient_id, _ := c.GetInt64("his_patient_id")
  13236. admin_user_id, _ := c.GetInt64("admin_user_id")
  13237. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13238. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13239. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13240. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13241. var dat map[string]interface{}
  13242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13243. fmt.Println(dat)
  13244. } else {
  13245. fmt.Println(err)
  13246. }
  13247. userJSONBytes, _ := json.Marshal(dat)
  13248. var res Result90100
  13249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13250. utils.ErrorLog("解析失败:%v", err)
  13251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13252. return
  13253. }
  13254. if res.Infcode != 0 {
  13255. c.ServeSuccessJSON(map[string]interface{}{
  13256. "failed_code": -10,
  13257. "msg": res.ErrMsg,
  13258. })
  13259. return
  13260. } else {
  13261. fmt.Println(res)
  13262. }
  13263. }
  13264. func (c *HisApiController) CheckCardPWD() {
  13265. card_pwd := c.GetString("card_pwd")
  13266. his_patient_id, _ := c.GetInt64("his_patient_id")
  13267. admin_user_id, _ := c.GetInt64("admin_user_id")
  13268. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13269. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13270. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13271. psn, _ := service.GetPsnByPatientId(his.PatientId)
  13272. bas := strings.Split(psn.CardInfo, "|")
  13273. basNumber := bas[2]
  13274. if psn.InsuplcAdmdvs[:4] == "4403" {
  13275. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  13276. var dat map[string]interface{}
  13277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13278. fmt.Println(dat)
  13279. } else {
  13280. fmt.Println(err)
  13281. }
  13282. userJSONBytes, _ := json.Marshal(dat)
  13283. var res Result90991
  13284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13285. utils.ErrorLog("解析失败:%v", err)
  13286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13287. return
  13288. }
  13289. if res.Infcode != 0 {
  13290. c.ServeSuccessJSON(map[string]interface{}{
  13291. "failed_code": -10,
  13292. "msg": res.ErrMsg,
  13293. })
  13294. return
  13295. } else {
  13296. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  13297. var msg string
  13298. switch res.Output.Result.CardStat {
  13299. case "00":
  13300. msg = "未激活"
  13301. break
  13302. case "10":
  13303. msg = "激活"
  13304. break
  13305. case "20":
  13306. msg = "窗口挂失"
  13307. break
  13308. case "21":
  13309. msg = "电话挂失"
  13310. break
  13311. case "22":
  13312. msg = "单位网上申报挂失"
  13313. break
  13314. case "23":
  13315. msg = "保健办挂失"
  13316. break
  13317. case "24":
  13318. msg = "个人网上挂失"
  13319. break
  13320. case "25":
  13321. msg = "网上服务大厅挂失"
  13322. break
  13323. case "30":
  13324. msg = "注销"
  13325. break
  13326. case "40":
  13327. msg = "回收"
  13328. break
  13329. case "99":
  13330. msg = "制卡中(无效卡)"
  13331. break
  13332. }
  13333. c.ServeSuccessJSON(map[string]interface{}{
  13334. "failed_code": -10,
  13335. "msg": msg,
  13336. })
  13337. return
  13338. } else {
  13339. c.ServeSuccessJSON(map[string]interface{}{
  13340. "msg": "校验成功",
  13341. })
  13342. return
  13343. }
  13344. }
  13345. } else {
  13346. c.ServeSuccessJSON(map[string]interface{}{
  13347. "msg": "校验成功",
  13348. })
  13349. return
  13350. }
  13351. }
  13352. func (c *HisApiController) CheckCardPWDTwo() {
  13353. //card_pwd := c.GetString("card_pwd")
  13354. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13355. admin_user_id, _ := c.GetInt64("admin_user_id")
  13356. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13357. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13358. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  13359. var dat map[string]interface{}
  13360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13361. fmt.Println(dat)
  13362. } else {
  13363. fmt.Println(err)
  13364. }
  13365. userJSONBytes, _ := json.Marshal(dat)
  13366. var res Result90991
  13367. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13368. utils.ErrorLog("解析失败:%v", err)
  13369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13370. return
  13371. }
  13372. if res.Infcode != 0 {
  13373. c.ServeSuccessJSON(map[string]interface{}{
  13374. "failed_code": -10,
  13375. "msg": res.ErrMsg,
  13376. })
  13377. return
  13378. } else {
  13379. if res.Output.Result.SscnoCheckStat == "0" {
  13380. var msg string
  13381. switch res.Output.Result.CardStat {
  13382. case "00":
  13383. msg = "未激活"
  13384. break
  13385. case "10":
  13386. msg = "激活"
  13387. break
  13388. case "20":
  13389. msg = "窗口挂失"
  13390. break
  13391. case "21":
  13392. msg = "电话挂失"
  13393. break
  13394. case "22":
  13395. msg = "单位网上申报挂失"
  13396. break
  13397. case "23":
  13398. msg = "保健办挂失"
  13399. break
  13400. case "24":
  13401. msg = "个人网上挂失"
  13402. break
  13403. case "25":
  13404. msg = "网上服务大厅挂失"
  13405. break
  13406. case "30":
  13407. msg = "注销"
  13408. break
  13409. case "40":
  13410. msg = "回收"
  13411. break
  13412. case "99":
  13413. msg = "制卡中(无效卡)"
  13414. break
  13415. }
  13416. c.ServeSuccessJSON(map[string]interface{}{
  13417. "failed_code": -10,
  13418. "msg": msg,
  13419. })
  13420. return
  13421. } else {
  13422. c.ServeSuccessJSON(map[string]interface{}{
  13423. "msg": "校验成功",
  13424. })
  13425. return
  13426. }
  13427. }
  13428. }
  13429. type ELeCertData struct {
  13430. Data struct {
  13431. Extra string `json:"extra"`
  13432. IDNo string `json:"idNo"`
  13433. IDType string `json:"idType"`
  13434. EcToken string `json:"ecToken"`
  13435. InsuOrg string `json:"insuOrg"`
  13436. UserName string `json:"userName"`
  13437. EcIndexNo string `json:"ecIndexNo"`
  13438. Gender string `json:"gender"`
  13439. Birthday string `json:"birthday"`
  13440. Nationality string `json:"nationality"`
  13441. Email string `json:"email"`
  13442. } `json:"OutData"`
  13443. }
  13444. func (c *HisApiController) ReadCard() {
  13445. id_card_type, _ := c.GetInt64("id_card_type")
  13446. admin_user_id, _ := c.GetInt64("admin_user_id")
  13447. certificates, _ := c.GetInt64("certificates")
  13448. //
  13449. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13450. id_card_no := c.GetString("id_card_no")
  13451. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13452. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13453. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13454. switch id_card_type {
  13455. case 1:
  13456. if miConfig.MdtrtareaAdmvs == "421300" {
  13457. var res ResultTwo
  13458. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13459. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13460. "&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)
  13461. resp, requestErr := http.Get(api)
  13462. if requestErr != nil {
  13463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13464. return
  13465. }
  13466. body, ioErr := ioutil.ReadAll(resp.Body)
  13467. if ioErr != nil {
  13468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13470. return
  13471. }
  13472. var respJSON map[string]interface{}
  13473. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13476. return
  13477. }
  13478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13479. result, _ := json.Marshal(respJSON)
  13480. fmt.Println("log")
  13481. fmt.Println(string(result))
  13482. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13483. utils.ErrorLog("解析失败:%v", err)
  13484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13485. return
  13486. }
  13487. if res.Infcode == 0 {
  13488. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13489. if err == gorm.ErrRecordNotFound {
  13490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13491. return
  13492. } else if err != nil {
  13493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13494. return
  13495. } else {
  13496. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13497. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13498. infoStr := string(Iinfos)
  13499. idetinfoStr := string(Idetinfos)
  13500. var rf []*ResultFive
  13501. json.Unmarshal([]byte(infoStr), &rf)
  13502. var insutypes []*ResultFive
  13503. var insutype string
  13504. var is390 int = 0
  13505. var is310 int = 0
  13506. for _, item := range rf {
  13507. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13508. insutypes = append(insutypes, item)
  13509. }
  13510. }
  13511. if len(insutypes) == 1 {
  13512. insutype = insutypes[0].Insutype
  13513. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13514. } else {
  13515. for _, i := range insutypes {
  13516. if i.Insutype == "390" {
  13517. is390 = 1
  13518. }
  13519. if i.Insutype == "310" {
  13520. is310 = 1
  13521. }
  13522. }
  13523. }
  13524. if is390 == 1 {
  13525. insutype = "390"
  13526. }
  13527. if is310 == 1 {
  13528. insutype = "310"
  13529. }
  13530. if len(insutypes) == 0 {
  13531. insutype = "390"
  13532. }
  13533. var insuplc_admdvs string
  13534. for _, item := range rf {
  13535. if item.Insutype == insutype {
  13536. insuplc_admdvs = item.InsuplcAdmdvs
  13537. }
  13538. }
  13539. if strings.Contains(insuplc_admdvs, "4213") {
  13540. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13541. }
  13542. psn := &models.HisPsn{
  13543. PsnNo: res.Output.Baseinfo.PsnNo,
  13544. PatientId: patient.ID,
  13545. Certno: res.Output.Baseinfo.Certno,
  13546. Gend: res.Output.Baseinfo.Gend,
  13547. Naty: res.Output.Baseinfo.Naty,
  13548. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13549. PsnName: res.Output.Baseinfo.PsnName,
  13550. Idetinfo: idetinfoStr,
  13551. Insuinfo: infoStr,
  13552. InsuplcAdmdvs: insuplc_admdvs,
  13553. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13554. }
  13555. service.CreateHisPsn(psn)
  13556. c.ServeSuccessJSON(map[string]interface{}{
  13557. "patient": patient,
  13558. "number": res.Output.Baseinfo.Certno,
  13559. })
  13560. }
  13561. } else {
  13562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13563. return
  13564. }
  13565. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13566. var res ResultTwo
  13567. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13568. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13569. "&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)
  13570. resp, requestErr := http.Get(api)
  13571. if requestErr != nil {
  13572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13573. return
  13574. }
  13575. body, ioErr := ioutil.ReadAll(resp.Body)
  13576. if ioErr != nil {
  13577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13579. return
  13580. }
  13581. var respJSON map[string]interface{}
  13582. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13585. return
  13586. }
  13587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13588. result, _ := json.Marshal(respJSON)
  13589. fmt.Println("log")
  13590. fmt.Println(string(result))
  13591. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13592. utils.ErrorLog("解析失败:%v", err)
  13593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13594. return
  13595. }
  13596. if res.Infcode == 0 {
  13597. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13598. if err == gorm.ErrRecordNotFound {
  13599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13600. return
  13601. } else if err != nil {
  13602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13603. return
  13604. } else {
  13605. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13606. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13607. infoStr := string(Iinfos)
  13608. idetinfoStr := string(Idetinfos)
  13609. psn := &models.HisPsn{
  13610. PsnNo: res.Output.Baseinfo.PsnNo,
  13611. PatientId: patient.ID,
  13612. Certno: res.Output.Baseinfo.Certno,
  13613. Gend: res.Output.Baseinfo.Gend,
  13614. Naty: res.Output.Baseinfo.Naty,
  13615. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13616. PsnName: res.Output.Baseinfo.PsnName,
  13617. Idetinfo: idetinfoStr,
  13618. Insuinfo: infoStr,
  13619. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13620. }
  13621. service.CreateHisPsn(psn)
  13622. var rf []*ResultFive
  13623. json.Unmarshal([]byte(infoStr), &rf)
  13624. var insutypes []*ResultFive
  13625. var insutype string
  13626. var is390 int = 0
  13627. var is310 int = 0
  13628. for _, item := range rf {
  13629. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13630. insutypes = append(insutypes, item)
  13631. }
  13632. }
  13633. if len(insutypes) == 1 {
  13634. insutype = insutypes[0].Insutype
  13635. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13636. } else {
  13637. for _, i := range insutypes {
  13638. if i.Insutype == "390" {
  13639. is390 = 1
  13640. }
  13641. if i.Insutype == "310" {
  13642. is310 = 1
  13643. }
  13644. }
  13645. }
  13646. if is390 == 1 {
  13647. insutype = "390"
  13648. }
  13649. if is310 == 1 {
  13650. insutype = "310"
  13651. }
  13652. if len(insutypes) == 0 {
  13653. insutype = "310"
  13654. }
  13655. c.ServeSuccessJSON(map[string]interface{}{
  13656. "patient": patient,
  13657. "number": res.Output.Baseinfo.Certno,
  13658. "insutype": insutype,
  13659. })
  13660. }
  13661. } else {
  13662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13663. return
  13664. }
  13665. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13666. var res ResultTwo
  13667. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13668. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13669. "&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)
  13670. resp, requestErr := http.Get(api)
  13671. if requestErr != nil {
  13672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13673. return
  13674. }
  13675. body, ioErr := ioutil.ReadAll(resp.Body)
  13676. if ioErr != nil {
  13677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13679. return
  13680. }
  13681. var respJSON map[string]interface{}
  13682. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13685. return
  13686. }
  13687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13688. result, _ := json.Marshal(respJSON)
  13689. fmt.Println("log")
  13690. fmt.Println(string(result))
  13691. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13692. utils.ErrorLog("解析失败:%v", err)
  13693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13694. return
  13695. }
  13696. if res.Infcode == 0 {
  13697. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13698. if err == gorm.ErrRecordNotFound {
  13699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13700. return
  13701. } else if err != nil {
  13702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13703. return
  13704. } else {
  13705. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13706. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13707. infoStr := string(Iinfos)
  13708. idetinfoStr := string(Idetinfos)
  13709. var rf []*ResultFive
  13710. json.Unmarshal([]byte(infoStr), &rf)
  13711. var insutypes []*ResultFive
  13712. var insutype string
  13713. var is390 int = 0
  13714. var is310 int = 0
  13715. for _, item := range rf {
  13716. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13717. insutypes = append(insutypes, item)
  13718. }
  13719. }
  13720. if len(insutypes) == 1 {
  13721. insutype = insutypes[0].Insutype
  13722. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13723. } else {
  13724. for _, i := range insutypes {
  13725. if i.Insutype == "390" {
  13726. is390 = 1
  13727. }
  13728. if i.Insutype == "310" {
  13729. is310 = 1
  13730. }
  13731. }
  13732. }
  13733. if is390 == 1 {
  13734. insutype = "390"
  13735. }
  13736. if is310 == 1 {
  13737. insutype = "310"
  13738. }
  13739. if len(insutypes) == 0 {
  13740. insutype = "390"
  13741. }
  13742. var insuplc_admdvs string
  13743. for _, item := range rf {
  13744. if item.Insutype == insutype {
  13745. insuplc_admdvs = item.InsuplcAdmdvs
  13746. }
  13747. }
  13748. psn := &models.HisPsn{
  13749. PsnNo: res.Output.Baseinfo.PsnNo,
  13750. PatientId: patient.ID,
  13751. Certno: res.Output.Baseinfo.Certno,
  13752. Gend: res.Output.Baseinfo.Gend,
  13753. Naty: res.Output.Baseinfo.Naty,
  13754. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13755. PsnName: res.Output.Baseinfo.PsnName,
  13756. Idetinfo: idetinfoStr,
  13757. Insuinfo: infoStr,
  13758. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13759. InsuplcAdmdvs: insuplc_admdvs,
  13760. }
  13761. service.CreateHisPsn(psn)
  13762. for _, item := range rf {
  13763. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13764. insutypes = append(insutypes, item)
  13765. }
  13766. }
  13767. if len(insutypes) == 1 {
  13768. insutype = insutypes[0].Insutype
  13769. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13770. } else {
  13771. for _, i := range insutypes {
  13772. if i.Insutype == "390" {
  13773. is390 = 1
  13774. }
  13775. if i.Insutype == "310" {
  13776. is310 = 1
  13777. }
  13778. }
  13779. }
  13780. if is390 == 1 {
  13781. insutype = "390"
  13782. }
  13783. if is310 == 1 {
  13784. insutype = "310"
  13785. }
  13786. if len(insutypes) == 0 {
  13787. insutype = "310"
  13788. }
  13789. c.ServeSuccessJSON(map[string]interface{}{
  13790. "patient": patient,
  13791. "number": res.Output.Baseinfo.Certno,
  13792. "insutype": insutype,
  13793. })
  13794. }
  13795. } else {
  13796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13797. return
  13798. }
  13799. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13800. var res ResultTwo
  13801. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13802. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13803. "&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)
  13804. resp, requestErr := http.Get(api)
  13805. if requestErr != nil {
  13806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13807. return
  13808. }
  13809. body, ioErr := ioutil.ReadAll(resp.Body)
  13810. if ioErr != nil {
  13811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13813. return
  13814. }
  13815. var respJSON map[string]interface{}
  13816. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13819. return
  13820. }
  13821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13822. result, _ := json.Marshal(respJSON)
  13823. fmt.Println("log")
  13824. fmt.Println(string(result))
  13825. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13826. utils.ErrorLog("解析失败:%v", err)
  13827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13828. return
  13829. }
  13830. if res.Infcode == 0 {
  13831. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13832. if err == gorm.ErrRecordNotFound {
  13833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13834. return
  13835. } else if err != nil {
  13836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13837. return
  13838. } else {
  13839. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13840. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13841. infoStr := string(Iinfos)
  13842. idetinfoStr := string(Idetinfos)
  13843. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13844. psn := &models.HisPsn{
  13845. PsnNo: res.Output.Baseinfo.PsnNo,
  13846. PatientId: patient.ID,
  13847. Certno: res.Output.Baseinfo.Certno,
  13848. Brdy: b,
  13849. Age: float64(age),
  13850. Gend: res.Output.Baseinfo.Gend,
  13851. Naty: res.Output.Baseinfo.Naty,
  13852. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13853. PsnName: res.Output.Baseinfo.PsnName,
  13854. Idetinfo: idetinfoStr,
  13855. Insuinfo: infoStr,
  13856. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13857. }
  13858. service.CreateHisPsn(psn)
  13859. var rf []*ResultFive
  13860. json.Unmarshal([]byte(infoStr), &rf)
  13861. var insutypes []*ResultFive
  13862. var insutype string
  13863. var is390 int = 0
  13864. var is310 int = 0
  13865. for _, item := range rf {
  13866. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13867. insutypes = append(insutypes, item)
  13868. }
  13869. }
  13870. if len(insutypes) == 1 {
  13871. insutype = insutypes[0].Insutype
  13872. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13873. } else {
  13874. for _, i := range insutypes {
  13875. if i.Insutype == "390" {
  13876. is390 = 1
  13877. }
  13878. if i.Insutype == "310" {
  13879. is310 = 1
  13880. }
  13881. }
  13882. }
  13883. if is390 == 1 {
  13884. insutype = "390"
  13885. }
  13886. if is310 == 1 {
  13887. insutype = "310"
  13888. }
  13889. if len(insutypes) == 0 {
  13890. insutype = "310"
  13891. }
  13892. c.ServeSuccessJSON(map[string]interface{}{
  13893. "patient": patient,
  13894. "number": res.Output.Baseinfo.Certno,
  13895. "insutype": insutype,
  13896. })
  13897. }
  13898. } else {
  13899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13900. return
  13901. }
  13902. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13903. var api string
  13904. if miConfig.MdtrtareaAdmvs == "320921" {
  13905. 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 +
  13906. "&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
  13907. fmt.Println(api)
  13908. } else {
  13909. 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 +
  13910. "&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)
  13911. }
  13912. resp, requestErr := http.Get(api)
  13913. if requestErr != nil {
  13914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13915. return
  13916. }
  13917. body, ioErr := ioutil.ReadAll(resp.Body)
  13918. if ioErr != nil {
  13919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13921. return
  13922. }
  13923. var respJSON map[string]interface{}
  13924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13927. return
  13928. }
  13929. var status string
  13930. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13931. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13932. //console.log()
  13933. fmt.Println("type===")
  13934. fmt.Println(card_type)
  13935. var token string
  13936. var res ResultTwo //1101结果
  13937. var res10265 ResultTwo10265 //1101结果
  13938. var card_info string //卡信息
  13939. var busi_card_info string
  13940. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13941. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13942. if status == "0" { //读卡成功
  13943. if card_type == "1" {
  13944. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13945. result, _ := json.Marshal(respJSON)
  13946. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13947. utils.ErrorLog("解析失败:%v", err)
  13948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13949. return
  13950. }
  13951. res.ErrMsg = res10265.ErrMsg
  13952. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13953. res.Infcode = infocode
  13954. res.Output = res10265.Output
  13955. res.InfRefmsgid = res10265.InfRefmsgid
  13956. } else {
  13957. //var card_info string //卡信息
  13958. //var busi_card_info string
  13959. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13960. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13961. //fmt.Println(card_info)
  13962. //fmt.Println(busi_card_info)
  13963. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13964. result, _ := json.Marshal(respJSON)
  13965. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13966. utils.ErrorLog("解析失败:%v", err)
  13967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13968. return
  13969. }
  13970. res.ErrMsg = res10265.ErrMsg
  13971. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13972. res.Infcode = infocode
  13973. res.Output = res10265.Output
  13974. res.InfRefmsgid = res10265.InfRefmsgid
  13975. }
  13976. if res.Infcode == 0 {
  13977. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13978. if err == gorm.ErrRecordNotFound {
  13979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13980. return
  13981. } else if err != nil {
  13982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13983. return
  13984. } else {
  13985. if card_type == "1" {
  13986. bas := strings.Split(card_info, "|")
  13987. basNumber := bas[2]
  13988. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13989. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13990. infoStr := string(Iinfos)
  13991. idetinfoStr := string(Idetinfos)
  13992. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13993. psn := &models.HisPsn{
  13994. PsnNo: res.Output.Baseinfo.PsnNo,
  13995. PatientId: patient.ID,
  13996. Certno: res.Output.Baseinfo.Certno,
  13997. Brdy: b,
  13998. Age: float64(age),
  13999. Gend: res.Output.Baseinfo.Gend,
  14000. Naty: res.Output.Baseinfo.Naty,
  14001. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14002. PsnName: res.Output.Baseinfo.PsnName,
  14003. Idetinfo: idetinfoStr,
  14004. Insuinfo: infoStr,
  14005. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14006. CardInfo: card_info,
  14007. VerifyNumber: busi_card_info,
  14008. }
  14009. service.CreateHisPsn(psn)
  14010. var rf []*ResultFive
  14011. json.Unmarshal([]byte(infoStr), &rf)
  14012. var insutypes []*ResultFive
  14013. var insutype string
  14014. var is390 int = 0
  14015. var is310 int = 0
  14016. for _, item := range rf {
  14017. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14018. insutypes = append(insutypes, item)
  14019. }
  14020. }
  14021. if len(insutypes) == 1 {
  14022. insutype = insutypes[0].Insutype
  14023. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14024. } else {
  14025. for _, i := range insutypes {
  14026. if i.Insutype == "390" {
  14027. is390 = 1
  14028. }
  14029. if i.Insutype == "310" {
  14030. is310 = 1
  14031. }
  14032. }
  14033. }
  14034. if is390 == 1 {
  14035. insutype = "390"
  14036. }
  14037. if is310 == 1 {
  14038. insutype = "310"
  14039. }
  14040. if len(insutypes) == 0 {
  14041. insutype = "310"
  14042. }
  14043. c.ServeSuccessJSON(map[string]interface{}{
  14044. "patient": patient,
  14045. "number": basNumber,
  14046. "insutype": insutype,
  14047. })
  14048. } else {
  14049. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14050. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14051. infoStr := string(Iinfos)
  14052. idetinfoStr := string(Idetinfos)
  14053. psn := &models.HisPsn{
  14054. PsnNo: res.Output.Baseinfo.PsnNo,
  14055. PatientId: patient.ID,
  14056. Certno: res.Output.Baseinfo.Certno,
  14057. Gend: res.Output.Baseinfo.Gend,
  14058. Naty: res.Output.Baseinfo.Naty,
  14059. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14060. PsnName: res.Output.Baseinfo.PsnName,
  14061. Idetinfo: idetinfoStr,
  14062. Insuinfo: infoStr,
  14063. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14064. CardInfo: card_info,
  14065. VerifyNumber: token,
  14066. }
  14067. service.CreateHisPsn(psn)
  14068. c.ServeSuccessJSON(map[string]interface{}{
  14069. "patient": patient,
  14070. "number": token,
  14071. })
  14072. }
  14073. }
  14074. } else {
  14075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14076. return
  14077. }
  14078. } else { //读卡失败
  14079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14080. return
  14081. }
  14082. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14083. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  14084. cardnum = DeleteExtraSpaceTwo(cardnum)
  14085. cardCode = DeleteExtraSpaceTwo(cardCode)
  14086. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  14087. name = DeleteExtraSpaceTwo(name)
  14088. errmsg = DeleteExtraSpaceTwo(errmsg)
  14089. cardnum = Remove0000(cardnum)
  14090. cardCode = Remove0000(cardCode)
  14091. id_card_no = Remove0000(id_card_no)
  14092. name = Remove0000(name)
  14093. errmsg = Remove0000(errmsg)
  14094. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  14095. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  14096. //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)
  14097. //fmt.Println(result2)
  14098. //fmt.Println(requestLog2)
  14099. //fmt.Println(errMsgLog2)
  14100. 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)
  14101. saveLog(result, requestLog, "1101", "获取人员信息")
  14102. fmt.Println(errMsgLog)
  14103. if len(errMsgLog) > 0 {
  14104. } else {
  14105. var dat map[string]interface{}
  14106. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14107. fmt.Println(dat)
  14108. } else {
  14109. fmt.Println(err)
  14110. }
  14111. userJSONBytes, _ := json.Marshal(dat)
  14112. var res ResultTwo
  14113. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14114. utils.ErrorLog("解析失败:%v", err)
  14115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14116. return
  14117. }
  14118. res.ErrMsg = errMsgLog
  14119. if res.Infcode == 0 {
  14120. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14121. if err == gorm.ErrRecordNotFound {
  14122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14123. return
  14124. } else if err != nil {
  14125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14126. return
  14127. } else {
  14128. fmt.Println(res)
  14129. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14130. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14131. infoStr := string(Iinfos)
  14132. idetinfoStr := string(Idetinfos)
  14133. var rf []*ResultFive
  14134. json.Unmarshal([]byte(infoStr), &rf)
  14135. var insutypes []*ResultFive
  14136. var insutype string
  14137. var is390 int = 0
  14138. var is310 int = 0
  14139. for _, item := range rf {
  14140. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14141. insutypes = append(insutypes, item)
  14142. }
  14143. }
  14144. if len(insutypes) == 1 {
  14145. insutype = insutypes[0].Insutype
  14146. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14147. } else {
  14148. for _, i := range insutypes {
  14149. if i.Insutype == "390" {
  14150. is390 = 1
  14151. }
  14152. if i.Insutype == "310" {
  14153. is310 = 1
  14154. }
  14155. }
  14156. }
  14157. if is390 == 1 {
  14158. insutype = "390"
  14159. }
  14160. if is310 == 1 {
  14161. insutype = "310"
  14162. }
  14163. if len(insutypes) == 0 {
  14164. insutype = "390"
  14165. }
  14166. var insuplc_admdvs string
  14167. for _, item := range rf {
  14168. if item.Insutype == insutype {
  14169. insuplc_admdvs = item.InsuplcAdmdvs
  14170. }
  14171. }
  14172. psn := &models.HisPsn{
  14173. PsnNo: res.Output.Baseinfo.PsnNo,
  14174. PatientId: patient.ID,
  14175. Certno: res.Output.Baseinfo.Certno,
  14176. Gend: res.Output.Baseinfo.Gend,
  14177. Naty: res.Output.Baseinfo.Naty,
  14178. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14179. PsnName: res.Output.Baseinfo.PsnName,
  14180. Idetinfo: idetinfoStr,
  14181. Insuinfo: infoStr,
  14182. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14183. CardInfo: basStr,
  14184. VerifyNumber: "",
  14185. InsuplcAdmdvs: insuplc_admdvs,
  14186. }
  14187. service.CreateHisPsn(psn)
  14188. c.ServeSuccessJSON(map[string]interface{}{
  14189. "patient": patient,
  14190. "number": cardnum,
  14191. "insutype": insutype,
  14192. })
  14193. }
  14194. } else {
  14195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14196. return
  14197. }
  14198. }
  14199. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14200. fmt.Println(initFlag)
  14201. fmt.Println("initFlag")
  14202. if initFlag == 0 {
  14203. c.TestGetJiangXiBasBaseInit()
  14204. }
  14205. basStr := c.GetBasBaseInfo()
  14206. if len(basStr) == 0 {
  14207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14208. return
  14209. }
  14210. fmt.Println(basStr)
  14211. bas := strings.Split(basStr, "|")
  14212. basNumber := bas[1]
  14213. fmt.Println(basNumber)
  14214. card := bas[2]
  14215. card_sn := bas[3]
  14216. fmt.Println(card_sn)
  14217. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14218. result, _ := service.Jxyb11012(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, patient.Name, card)
  14219. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14220. var dat map[string]interface{}
  14221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14222. fmt.Println(dat)
  14223. } else {
  14224. fmt.Println(err)
  14225. }
  14226. userJSONBytes, _ := json.Marshal(dat)
  14227. var res ResultTwo
  14228. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14229. utils.ErrorLog("解析失败:%v", err)
  14230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14231. return
  14232. }
  14233. if res.Infcode == 0 {
  14234. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14235. if err == gorm.ErrRecordNotFound {
  14236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14237. return
  14238. } else if err != nil {
  14239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14240. return
  14241. } else {
  14242. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14243. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14244. infoStr := string(Iinfos)
  14245. idetinfoStr := string(Idetinfos)
  14246. var rf []*ResultFive
  14247. json.Unmarshal([]byte(infoStr), &rf)
  14248. var insutypes []*ResultFive
  14249. var insutype string
  14250. var is390 int = 0
  14251. var is310 int = 0
  14252. var insuplc_admdvs string
  14253. for _, item := range rf {
  14254. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14255. insutypes = append(insutypes, item)
  14256. }
  14257. }
  14258. if len(insutypes) == 1 {
  14259. insutype = insutypes[0].Insutype
  14260. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14261. } else {
  14262. for _, i := range insutypes {
  14263. if i.Insutype == "390" {
  14264. is390 = 1
  14265. }
  14266. if i.Insutype == "310" {
  14267. is310 = 1
  14268. }
  14269. }
  14270. }
  14271. if is390 == 1 {
  14272. insutype = "390"
  14273. }
  14274. if is310 == 1 {
  14275. insutype = "310"
  14276. }
  14277. if len(insutypes) == 0 {
  14278. insutype = "310"
  14279. }
  14280. for _, item := range rf {
  14281. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14282. insuplc_admdvs = item.InsuplcAdmdvs
  14283. }
  14284. }
  14285. psn := &models.HisPsn{
  14286. PsnNo: res.Output.Baseinfo.PsnNo,
  14287. PatientId: patient.ID,
  14288. Certno: res.Output.Baseinfo.Certno,
  14289. Gend: res.Output.Baseinfo.Gend,
  14290. Naty: res.Output.Baseinfo.Naty,
  14291. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14292. PsnName: res.Output.Baseinfo.PsnName,
  14293. Idetinfo: idetinfoStr,
  14294. Insuinfo: infoStr,
  14295. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14296. CardInfo: basStr,
  14297. InsuplcAdmdvs: insuplc_admdvs,
  14298. VerifyNumber: "",
  14299. }
  14300. service.CreateHisPsn(psn)
  14301. c.ServeSuccessJSON(map[string]interface{}{
  14302. "patient": patient,
  14303. "number": basNumber,
  14304. "insutype": insutype,
  14305. })
  14306. }
  14307. } else {
  14308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14309. return
  14310. }
  14311. } else if miConfig.MdtrtareaAdmvs == "361025" {
  14312. basStr := c.GetBasBaseInfo22222()
  14313. fmt.Println(basStr)
  14314. if len(basStr) == 0 {
  14315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14316. return
  14317. }
  14318. fmt.Println(basStr)
  14319. bas := strings.Split(basStr, "|")
  14320. basNumber := bas[2] //卡号
  14321. card_sn := bas[3] //
  14322. id_card_No := bas[1] //卡号
  14323. fmt.Println(basNumber)
  14324. fmt.Println(card_sn)
  14325. fmt.Println(id_card_No)
  14326. var patient service.Patients
  14327. if len(id_card_No) == 0 {
  14328. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14329. } else {
  14330. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14331. }
  14332. 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)
  14333. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14334. var dat map[string]interface{}
  14335. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14336. fmt.Println(dat)
  14337. } else {
  14338. fmt.Println(err)
  14339. }
  14340. userJSONBytes, _ := json.Marshal(dat)
  14341. var res ResultTwo
  14342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14343. utils.ErrorLog("解析失败:%v", err)
  14344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14345. return
  14346. }
  14347. if res.Infcode == 0 {
  14348. var pateint2 service.Patients
  14349. var err error
  14350. if len(id_card_No) == 0 {
  14351. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14352. } else {
  14353. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14354. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14355. }
  14356. if err == gorm.ErrRecordNotFound {
  14357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14358. return
  14359. } else if err != nil {
  14360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14361. return
  14362. } else {
  14363. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14364. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14365. infoStr := string(Iinfos)
  14366. idetinfoStr := string(Idetinfos)
  14367. var rf []*ResultFive
  14368. json.Unmarshal([]byte(infoStr), &rf)
  14369. var insutypes []*ResultFive
  14370. var insutype string
  14371. var is390 int = 0
  14372. var is310 int = 0
  14373. var insuplc_admdvs string
  14374. for _, item := range rf {
  14375. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14376. insutypes = append(insutypes, item)
  14377. }
  14378. }
  14379. if len(insutypes) == 1 {
  14380. insutype = insutypes[0].Insutype
  14381. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14382. } else {
  14383. for _, i := range insutypes {
  14384. if i.Insutype == "390" {
  14385. is390 = 1
  14386. }
  14387. if i.Insutype == "310" {
  14388. is310 = 1
  14389. }
  14390. }
  14391. }
  14392. if is390 == 1 {
  14393. insutype = "390"
  14394. }
  14395. if is310 == 1 {
  14396. insutype = "310"
  14397. }
  14398. if len(insutypes) == 0 {
  14399. insutype = "310"
  14400. }
  14401. for _, item := range rf {
  14402. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14403. insuplc_admdvs = item.InsuplcAdmdvs
  14404. }
  14405. }
  14406. psn := &models.HisPsn{
  14407. PsnNo: res.Output.Baseinfo.PsnNo,
  14408. PatientId: pateint2.ID,
  14409. Certno: res.Output.Baseinfo.Certno,
  14410. Gend: res.Output.Baseinfo.Gend,
  14411. Naty: res.Output.Baseinfo.Naty,
  14412. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14413. PsnName: res.Output.Baseinfo.PsnName,
  14414. Idetinfo: idetinfoStr,
  14415. Insuinfo: infoStr,
  14416. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14417. CardInfo: basStr,
  14418. InsuplcAdmdvs: insuplc_admdvs,
  14419. VerifyNumber: "",
  14420. }
  14421. service.CreateHisPsn(psn)
  14422. c.ServeSuccessJSON(map[string]interface{}{
  14423. "patient": patient,
  14424. "number": basNumber,
  14425. "insutype": insutype,
  14426. })
  14427. }
  14428. } else {
  14429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14430. return
  14431. }
  14432. } else if miConfig.MdtrtareaAdmvs == "360100" {
  14433. fmt.Println(initFlag)
  14434. fmt.Println("initFlag")
  14435. if initFlag == 0 {
  14436. c.TestGetJiangXiBasBaseInittwo()
  14437. }
  14438. basStr := c.GetBasBaseInfo()
  14439. if len(basStr) == 0 {
  14440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14441. return
  14442. }
  14443. fmt.Println(basStr)
  14444. bas := strings.Split(basStr, "|")
  14445. basNumber := bas[1]
  14446. fmt.Println(basNumber)
  14447. card_sn := bas[3]
  14448. fmt.Println(card_sn)
  14449. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14450. 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)
  14451. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14452. var dat map[string]interface{}
  14453. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14454. fmt.Println(dat)
  14455. } else {
  14456. fmt.Println(err)
  14457. }
  14458. userJSONBytes, _ := json.Marshal(dat)
  14459. var res ResultTwo
  14460. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14461. utils.ErrorLog("解析失败:%v", err)
  14462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14463. return
  14464. }
  14465. if res.Infcode == 0 {
  14466. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14467. if err == gorm.ErrRecordNotFound {
  14468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14469. return
  14470. } else if err != nil {
  14471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14472. return
  14473. } else {
  14474. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14475. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14476. infoStr := string(Iinfos)
  14477. idetinfoStr := string(Idetinfos)
  14478. var rf []*ResultFive
  14479. json.Unmarshal([]byte(infoStr), &rf)
  14480. var insutypes []*ResultFive
  14481. var insutype string
  14482. var is390 int = 0
  14483. var is310 int = 0
  14484. var insuplc_admdvs string
  14485. for _, item := range rf {
  14486. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14487. insutypes = append(insutypes, item)
  14488. }
  14489. }
  14490. if len(insutypes) == 1 {
  14491. insutype = insutypes[0].Insutype
  14492. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14493. } else {
  14494. for _, i := range insutypes {
  14495. if i.Insutype == "390" {
  14496. is390 = 1
  14497. }
  14498. if i.Insutype == "310" {
  14499. is310 = 1
  14500. }
  14501. }
  14502. }
  14503. if is390 == 1 {
  14504. insutype = "390"
  14505. }
  14506. if is310 == 1 {
  14507. insutype = "310"
  14508. }
  14509. if len(insutypes) == 0 {
  14510. insutype = "310"
  14511. }
  14512. for _, item := range rf {
  14513. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14514. insuplc_admdvs = item.InsuplcAdmdvs
  14515. }
  14516. }
  14517. psn := &models.HisPsn{
  14518. PsnNo: res.Output.Baseinfo.PsnNo,
  14519. PatientId: patient.ID,
  14520. Certno: res.Output.Baseinfo.Certno,
  14521. Gend: res.Output.Baseinfo.Gend,
  14522. Naty: res.Output.Baseinfo.Naty,
  14523. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14524. PsnName: res.Output.Baseinfo.PsnName,
  14525. Idetinfo: idetinfoStr,
  14526. Insuinfo: infoStr,
  14527. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14528. CardInfo: basStr,
  14529. InsuplcAdmdvs: insuplc_admdvs,
  14530. VerifyNumber: "",
  14531. }
  14532. service.CreateHisPsn(psn)
  14533. c.ServeSuccessJSON(map[string]interface{}{
  14534. "patient": patient,
  14535. "number": basNumber,
  14536. "insutype": insutype,
  14537. })
  14538. }
  14539. } else {
  14540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14541. return
  14542. }
  14543. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14544. fmt.Println(initFlag)
  14545. fmt.Println("initFlag")
  14546. if initFlag == 0 {
  14547. c.TestGetHnBasBaseInit()
  14548. }
  14549. basStr := c.GetBasBaseInfo()
  14550. if len(basStr) == 0 {
  14551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14552. return
  14553. }
  14554. fmt.Println(basStr)
  14555. bas := strings.Split(basStr, "|")
  14556. basNumber := bas[1]
  14557. fmt.Println(basNumber)
  14558. card_sn := bas[3]
  14559. card_no := bas[2]
  14560. fmt.Println(card_sn)
  14561. name := bas[4]
  14562. name = ConvertToString(name, "gbk", "utf-8")
  14563. 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)
  14564. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14565. var dat map[string]interface{}
  14566. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14567. fmt.Println(dat)
  14568. } else {
  14569. fmt.Println(err)
  14570. }
  14571. userJSONBytes, _ := json.Marshal(dat)
  14572. var res ResultTwo
  14573. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14574. utils.ErrorLog("解析失败:%v", err)
  14575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14576. return
  14577. }
  14578. if res.Infcode == 0 {
  14579. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14580. if err == gorm.ErrRecordNotFound {
  14581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14582. return
  14583. } else if err != nil {
  14584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14585. return
  14586. } else {
  14587. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14588. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14589. infoStr := string(Iinfos)
  14590. idetinfoStr := string(Idetinfos)
  14591. psn := &models.HisPsn{
  14592. PsnNo: res.Output.Baseinfo.PsnNo,
  14593. PatientId: patient.ID,
  14594. Certno: res.Output.Baseinfo.Certno,
  14595. Gend: res.Output.Baseinfo.Gend,
  14596. Naty: res.Output.Baseinfo.Naty,
  14597. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14598. PsnName: res.Output.Baseinfo.PsnName,
  14599. Idetinfo: idetinfoStr,
  14600. Insuinfo: infoStr,
  14601. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14602. CardInfo: basStr,
  14603. VerifyNumber: "",
  14604. }
  14605. service.CreateHisPsn(psn)
  14606. var rf []*ResultFive
  14607. json.Unmarshal([]byte(infoStr), &rf)
  14608. var insutypes []*ResultFive
  14609. var insutype string
  14610. var is390 int = 0
  14611. var is310 int = 0
  14612. for _, item := range rf {
  14613. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14614. insutypes = append(insutypes, item)
  14615. }
  14616. }
  14617. if len(insutypes) == 1 {
  14618. insutype = insutypes[0].Insutype
  14619. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14620. } else {
  14621. for _, i := range insutypes {
  14622. if i.Insutype == "390" {
  14623. is390 = 1
  14624. }
  14625. if i.Insutype == "310" {
  14626. is310 = 1
  14627. }
  14628. }
  14629. }
  14630. if is390 == 1 {
  14631. insutype = "390"
  14632. }
  14633. if is310 == 1 {
  14634. insutype = "310"
  14635. }
  14636. if len(insutypes) == 0 {
  14637. insutype = "310"
  14638. }
  14639. c.ServeSuccessJSON(map[string]interface{}{
  14640. "patient": patient,
  14641. "number": basNumber,
  14642. "insutype": insutype,
  14643. })
  14644. }
  14645. } else {
  14646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14647. return
  14648. }
  14649. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14650. var api string
  14651. 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 +
  14652. "&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
  14653. fmt.Println(api)
  14654. resp, requestErr := http.Get(api)
  14655. if requestErr != nil {
  14656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14657. return
  14658. }
  14659. body, ioErr := ioutil.ReadAll(resp.Body)
  14660. if ioErr != nil {
  14661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14663. return
  14664. }
  14665. var respJSON map[string]interface{}
  14666. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14669. return
  14670. }
  14671. var res ResultTwo //1101结果
  14672. var res10265 ResultTwo10265 //1101结果
  14673. var card_info string //卡信息
  14674. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14675. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14676. result, _ := json.Marshal(respJSON)
  14677. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14678. utils.ErrorLog("解析失败:%v", err)
  14679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14680. return
  14681. }
  14682. res.ErrMsg = res10265.ErrMsg
  14683. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14684. res.Infcode = infocode
  14685. res.Output = res10265.Output
  14686. res.InfRefmsgid = res10265.InfRefmsgid
  14687. if res.Infcode == 0 {
  14688. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14689. if err == gorm.ErrRecordNotFound {
  14690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14691. return
  14692. } else if err != nil {
  14693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14694. return
  14695. } else {
  14696. bas := strings.Split(card_info, "|")
  14697. basNumber := bas[2]
  14698. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14699. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14700. infoStr := string(Iinfos)
  14701. idetinfoStr := string(Idetinfos)
  14702. psn := &models.HisPsn{
  14703. PsnNo: res.Output.Baseinfo.PsnNo,
  14704. PatientId: patient.ID,
  14705. Certno: res.Output.Baseinfo.Certno,
  14706. Gend: res.Output.Baseinfo.Gend,
  14707. Naty: res.Output.Baseinfo.Naty,
  14708. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14709. PsnName: res.Output.Baseinfo.PsnName,
  14710. Idetinfo: idetinfoStr,
  14711. Insuinfo: infoStr,
  14712. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14713. CardInfo: card_info,
  14714. VerifyNumber: token,
  14715. }
  14716. service.CreateHisPsn(psn)
  14717. var rf []*ResultFive
  14718. json.Unmarshal([]byte(infoStr), &rf)
  14719. var insutypes []*ResultFive
  14720. var insutype string
  14721. var is390 int = 0
  14722. var is310 int = 0
  14723. for _, item := range rf {
  14724. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14725. insutypes = append(insutypes, item)
  14726. }
  14727. }
  14728. if len(insutypes) == 1 {
  14729. insutype = insutypes[0].Insutype
  14730. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14731. } else {
  14732. for _, i := range insutypes {
  14733. if i.Insutype == "390" {
  14734. is390 = 1
  14735. }
  14736. if i.Insutype == "310" {
  14737. is310 = 1
  14738. }
  14739. }
  14740. }
  14741. if is390 == 1 {
  14742. insutype = "390"
  14743. }
  14744. if is310 == 1 {
  14745. insutype = "310"
  14746. }
  14747. if len(insutypes) == 0 {
  14748. insutype = "310"
  14749. }
  14750. c.ServeSuccessJSON(map[string]interface{}{
  14751. "patient": patient,
  14752. "number": basNumber,
  14753. "insutype": insutype,
  14754. })
  14755. }
  14756. } else {
  14757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14758. return
  14759. }
  14760. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14761. res := c.GetoleInfo()
  14762. if res.Infcode == 0 {
  14763. var result string
  14764. if res.Output.MdtrtCertType == "01" {
  14765. 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)
  14766. } else if res.Output.MdtrtCertType == "02" {
  14767. 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)
  14768. } else if res.Output.MdtrtCertType == "03" {
  14769. 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)
  14770. }
  14771. var dat map[string]interface{}
  14772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14773. fmt.Println(dat)
  14774. } else {
  14775. fmt.Println(err)
  14776. }
  14777. userJSONBytes, _ := json.Marshal(dat)
  14778. var res2 ResultTwo
  14779. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14780. utils.ErrorLog("解析失败:%v", err)
  14781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14782. return
  14783. }
  14784. if res2.Infcode == 0 {
  14785. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14786. if err == gorm.ErrRecordNotFound {
  14787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14788. return
  14789. } else if err != nil {
  14790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14791. return
  14792. } else {
  14793. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14794. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14795. infoStr := string(Iinfos)
  14796. idetinfoStr := string(Idetinfos)
  14797. var rf []*ResultFive
  14798. json.Unmarshal([]byte(infoStr), &rf)
  14799. var insutypes []*ResultFive
  14800. var insutype string
  14801. var is390 int = 0
  14802. var is310 int = 0
  14803. //var insuplc_admdvs string
  14804. for _, item := range rf {
  14805. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14806. insutypes = append(insutypes, item)
  14807. }
  14808. }
  14809. if len(insutypes) == 1 {
  14810. insutype = insutypes[0].Insutype
  14811. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14812. } else {
  14813. for _, i := range insutypes {
  14814. if i.Insutype == "390" {
  14815. is390 = 1
  14816. }
  14817. if i.Insutype == "310" {
  14818. is310 = 1
  14819. }
  14820. }
  14821. }
  14822. if is390 == 1 {
  14823. insutype = "390"
  14824. }
  14825. if is310 == 1 {
  14826. insutype = "310"
  14827. }
  14828. if len(insutypes) == 0 {
  14829. insutype = "310"
  14830. }
  14831. psn := &models.HisPsn{
  14832. PsnNo: res2.Output.Baseinfo.PsnNo,
  14833. PatientId: patient.ID,
  14834. Certno: res2.Output.Baseinfo.Certno,
  14835. Gend: res2.Output.Baseinfo.Gend,
  14836. Naty: res2.Output.Baseinfo.Naty,
  14837. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14838. PsnName: res2.Output.Baseinfo.PsnName,
  14839. Idetinfo: idetinfoStr,
  14840. Insuinfo: infoStr,
  14841. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14842. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14843. VerifyNumber: res.Output.EcToken,
  14844. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14845. }
  14846. if res.Output.MdtrtCertType == "01" {
  14847. psn.VerifyNumber = res.Output.EcToken
  14848. //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)
  14849. } else if res.Output.MdtrtCertType == "02" {
  14850. psn.VerifyNumber = res.Output.MdtrtCertNo
  14851. //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)
  14852. } else if res.Output.MdtrtCertType == "03" {
  14853. psn.VerifyNumber = res.Output.MdtrtCertNo
  14854. //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)
  14855. }
  14856. var balc float64
  14857. for _, item := range rf {
  14858. if item.Insutype == insutype {
  14859. balc = item.Balc
  14860. }
  14861. }
  14862. service.CreateHisPsn(psn)
  14863. c.ServeSuccessJSON(map[string]interface{}{
  14864. "patient": patient,
  14865. "number": res.Output.CardNo,
  14866. "insutype": insutype,
  14867. "blac": balc,
  14868. "desc": idetinfoStr,
  14869. })
  14870. }
  14871. } else {
  14872. c.ServeSuccessJSON(map[string]interface{}{
  14873. "failed_code": -10,
  14874. "msg": res2.ErrMsg,
  14875. })
  14876. }
  14877. } else {
  14878. c.ServeSuccessJSON(map[string]interface{}{
  14879. "failed_code": -10,
  14880. "msg": res.ErrMsg,
  14881. })
  14882. }
  14883. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14884. var api string
  14885. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14886. "&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
  14887. fmt.Println(api)
  14888. resp, requestErr := http.Get(api)
  14889. if requestErr != nil {
  14890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14891. return
  14892. }
  14893. body, ioErr := ioutil.ReadAll(resp.Body)
  14894. if ioErr != nil {
  14895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14897. return
  14898. }
  14899. var respJSON map[string]interface{}
  14900. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14903. return
  14904. }
  14905. var status string
  14906. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14907. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14908. //console.log()
  14909. fmt.Println("type===")
  14910. fmt.Println(card_type)
  14911. var token string
  14912. var res ResultTwo //1101结果
  14913. //var res10265 ResultTwoesultTwo10265 //1101结果
  14914. var card_info string //卡信息
  14915. var busi_card_info string
  14916. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14917. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14918. if status == "0" { //读卡成功
  14919. if card_type == "1" {
  14920. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14921. result, _ := json.Marshal(respJSON)
  14922. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14923. utils.ErrorLog("解析失败:%v", err)
  14924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14925. return
  14926. }
  14927. } else {
  14928. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14929. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14930. result, _ := json.Marshal(respJSON)
  14931. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14932. utils.ErrorLog("解析失败:%v", err)
  14933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14934. return
  14935. }
  14936. }
  14937. if res.Infcode == 0 {
  14938. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14939. if err == gorm.ErrRecordNotFound {
  14940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14941. return
  14942. } else if err != nil {
  14943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14944. return
  14945. } else {
  14946. if card_type == "1" {
  14947. bas := strings.Split(card_info, "|")
  14948. basNumber := bas[2]
  14949. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14950. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14951. infoStr := string(Iinfos)
  14952. idetinfoStr := string(Idetinfos)
  14953. psn := &models.HisPsn{
  14954. PsnNo: res.Output.Baseinfo.PsnNo,
  14955. PatientId: patient.ID,
  14956. Certno: res.Output.Baseinfo.Certno,
  14957. Gend: res.Output.Baseinfo.Gend,
  14958. Naty: res.Output.Baseinfo.Naty,
  14959. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14960. PsnName: res.Output.Baseinfo.PsnName,
  14961. Idetinfo: idetinfoStr,
  14962. Insuinfo: infoStr,
  14963. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14964. CardInfo: card_info,
  14965. VerifyNumber: busi_card_info,
  14966. }
  14967. service.CreateHisPsn(psn)
  14968. var rf []*ResultFive
  14969. json.Unmarshal([]byte(infoStr), &rf)
  14970. var insutypes []*ResultFive
  14971. var insutype string
  14972. var is390 int = 0
  14973. var is310 int = 0
  14974. for _, item := range rf {
  14975. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14976. insutypes = append(insutypes, item)
  14977. }
  14978. }
  14979. if len(insutypes) == 1 {
  14980. insutype = insutypes[0].Insutype
  14981. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14982. } else {
  14983. for _, i := range insutypes {
  14984. if i.Insutype == "390" {
  14985. is390 = 1
  14986. }
  14987. if i.Insutype == "310" {
  14988. is310 = 1
  14989. }
  14990. }
  14991. }
  14992. if is390 == 1 {
  14993. insutype = "390"
  14994. }
  14995. if is310 == 1 {
  14996. insutype = "310"
  14997. }
  14998. if len(insutypes) == 0 {
  14999. insutype = "310"
  15000. }
  15001. c.ServeSuccessJSON(map[string]interface{}{
  15002. "patient": patient,
  15003. "number": basNumber,
  15004. "insutype": insutype,
  15005. })
  15006. } else {
  15007. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15008. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15009. infoStr := string(Iinfos)
  15010. idetinfoStr := string(Idetinfos)
  15011. psn := &models.HisPsn{
  15012. PsnNo: res.Output.Baseinfo.PsnNo,
  15013. PatientId: patient.ID,
  15014. Certno: res.Output.Baseinfo.Certno,
  15015. Gend: res.Output.Baseinfo.Gend,
  15016. Naty: res.Output.Baseinfo.Naty,
  15017. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15018. PsnName: res.Output.Baseinfo.PsnName,
  15019. Idetinfo: idetinfoStr,
  15020. Insuinfo: infoStr,
  15021. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15022. CardInfo: card_info,
  15023. VerifyNumber: token,
  15024. }
  15025. service.CreateHisPsn(psn)
  15026. c.ServeSuccessJSON(map[string]interface{}{
  15027. "patient": patient,
  15028. "number": token,
  15029. })
  15030. }
  15031. }
  15032. } else {
  15033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15034. return
  15035. }
  15036. } else { //读卡失败
  15037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15038. return
  15039. }
  15040. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15041. var api string
  15042. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15043. "&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
  15044. fmt.Println(api)
  15045. resp, requestErr := http.Get(api)
  15046. if requestErr != nil {
  15047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15048. return
  15049. }
  15050. body, ioErr := ioutil.ReadAll(resp.Body)
  15051. if ioErr != nil {
  15052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15054. return
  15055. }
  15056. var respJSON map[string]interface{}
  15057. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15060. return
  15061. }
  15062. var status string
  15063. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15064. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15065. //console.log()
  15066. fmt.Println("type===")
  15067. fmt.Println(card_type)
  15068. var token string
  15069. var res ResultTwo //1101结果
  15070. //var res10265 ResultTwoesultTwo10265 //1101结果
  15071. var card_info string //卡信息
  15072. //var busi_card_info string
  15073. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15074. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15075. if status == "0" { //读卡成功
  15076. if card_type == "1" {
  15077. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15078. result, _ := json.Marshal(respJSON)
  15079. fmt.Println(result)
  15080. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15081. utils.ErrorLog("解析失败:%v", err)
  15082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15083. return
  15084. }
  15085. fmt.Println(res)
  15086. } else {
  15087. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15088. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15089. result, _ := json.Marshal(respJSON)
  15090. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15091. utils.ErrorLog("解析失败:%v", err)
  15092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15093. return
  15094. }
  15095. }
  15096. if res.Infcode == 0 {
  15097. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15098. if err == gorm.ErrRecordNotFound {
  15099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15100. return
  15101. } else if err != nil {
  15102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15103. return
  15104. } else {
  15105. if card_type == "1" {
  15106. bas := strings.Split(card_info, "|")
  15107. basNumber := bas[2]
  15108. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15109. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15110. infoStr := string(Iinfos)
  15111. idetinfoStr := string(Idetinfos)
  15112. psn := &models.HisPsn{
  15113. PsnNo: res.Output.Baseinfo.PsnNo,
  15114. PatientId: patient.ID,
  15115. Certno: res.Output.Baseinfo.Certno,
  15116. Gend: res.Output.Baseinfo.Gend,
  15117. Naty: res.Output.Baseinfo.Naty,
  15118. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15119. PsnName: res.Output.Baseinfo.PsnName,
  15120. Idetinfo: idetinfoStr,
  15121. Insuinfo: infoStr,
  15122. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15123. CardInfo: card_info,
  15124. //VerifyNumber: busi_card_info,
  15125. }
  15126. service.CreateHisPsn(psn)
  15127. var rf []*ResultFive
  15128. json.Unmarshal([]byte(infoStr), &rf)
  15129. var insutypes []*ResultFive
  15130. var insutype string
  15131. var is390 int = 0
  15132. var is310 int = 0
  15133. for _, item := range rf {
  15134. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15135. insutypes = append(insutypes, item)
  15136. }
  15137. }
  15138. if len(insutypes) == 1 {
  15139. insutype = insutypes[0].Insutype
  15140. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15141. } else {
  15142. for _, i := range insutypes {
  15143. if i.Insutype == "390" {
  15144. is390 = 1
  15145. }
  15146. if i.Insutype == "310" {
  15147. is310 = 1
  15148. }
  15149. }
  15150. }
  15151. if is390 == 1 {
  15152. insutype = "390"
  15153. }
  15154. if is310 == 1 {
  15155. insutype = "310"
  15156. }
  15157. if len(insutypes) == 0 {
  15158. insutype = "310"
  15159. }
  15160. c.ServeSuccessJSON(map[string]interface{}{
  15161. "patient": patient,
  15162. "number": basNumber,
  15163. "insutype": insutype,
  15164. })
  15165. } else {
  15166. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15167. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15168. infoStr := string(Iinfos)
  15169. idetinfoStr := string(Idetinfos)
  15170. psn := &models.HisPsn{
  15171. PsnNo: res.Output.Baseinfo.PsnNo,
  15172. PatientId: patient.ID,
  15173. Certno: res.Output.Baseinfo.Certno,
  15174. Gend: res.Output.Baseinfo.Gend,
  15175. Naty: res.Output.Baseinfo.Naty,
  15176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15177. PsnName: res.Output.Baseinfo.PsnName,
  15178. Idetinfo: idetinfoStr,
  15179. Insuinfo: infoStr,
  15180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15181. CardInfo: card_info,
  15182. VerifyNumber: token,
  15183. }
  15184. service.CreateHisPsn(psn)
  15185. c.ServeSuccessJSON(map[string]interface{}{
  15186. "patient": patient,
  15187. "number": token,
  15188. })
  15189. }
  15190. }
  15191. } else {
  15192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15193. return
  15194. }
  15195. } else { //读卡失败
  15196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15197. return
  15198. }
  15199. } else {
  15200. if initFlag == 0 {
  15201. c.TestGetBasBaseInit()
  15202. }
  15203. basStr := c.GetBasBaseInfo()
  15204. if len(basStr) == 0 {
  15205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15206. return
  15207. }
  15208. fmt.Println(basStr)
  15209. bas := strings.Split(basStr, "|")
  15210. basNumber := bas[1]
  15211. fmt.Println(basNumber)
  15212. card_sn := bas[3]
  15213. fmt.Println(card_sn)
  15214. cardNumber := bas[2]
  15215. fmt.Println(cardNumber)
  15216. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  15217. var result string
  15218. if bas[0][:2] == "44" {
  15219. 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)
  15220. } else {
  15221. 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)
  15222. }
  15223. var dat map[string]interface{}
  15224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15225. fmt.Println(dat)
  15226. } else {
  15227. fmt.Println(err)
  15228. }
  15229. userJSONBytes, _ := json.Marshal(dat)
  15230. var res ResultTwo
  15231. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15232. utils.ErrorLog("解析失败:%v", err)
  15233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15234. return
  15235. }
  15236. if res.Infcode == 0 {
  15237. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15238. if err == gorm.ErrRecordNotFound {
  15239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15240. return
  15241. } else if err != nil {
  15242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15243. return
  15244. } else {
  15245. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15246. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15247. infoStr := string(Iinfos)
  15248. idetinfoStr := string(Idetinfos)
  15249. var rf []*ResultFive
  15250. json.Unmarshal([]byte(infoStr), &rf)
  15251. var insutypes []*ResultFive
  15252. var insutype string
  15253. var is390 int = 0
  15254. var is310 int = 0
  15255. var insuplc_admdvs string
  15256. for _, item := range rf {
  15257. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15258. insutypes = append(insutypes, item)
  15259. }
  15260. }
  15261. if len(insutypes) == 1 {
  15262. insutype = insutypes[0].Insutype
  15263. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15264. } else {
  15265. for _, i := range insutypes {
  15266. if i.Insutype == "390" {
  15267. is390 = 1
  15268. }
  15269. if i.Insutype == "310" {
  15270. is310 = 1
  15271. }
  15272. }
  15273. }
  15274. if is390 == 1 {
  15275. insutype = "390"
  15276. }
  15277. if is310 == 1 {
  15278. insutype = "310"
  15279. }
  15280. if len(insutypes) == 0 {
  15281. insutype = "310"
  15282. }
  15283. for _, item := range rf {
  15284. if item.Insutype == insutype {
  15285. insuplc_admdvs = item.InsuplcAdmdvs
  15286. }
  15287. }
  15288. psn := &models.HisPsn{
  15289. PsnNo: res.Output.Baseinfo.PsnNo,
  15290. PatientId: patient.ID,
  15291. Certno: res.Output.Baseinfo.Certno,
  15292. Gend: res.Output.Baseinfo.Gend,
  15293. Naty: res.Output.Baseinfo.Naty,
  15294. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15295. PsnName: res.Output.Baseinfo.PsnName,
  15296. Idetinfo: idetinfoStr,
  15297. Insuinfo: infoStr,
  15298. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15299. CardInfo: basStr,
  15300. VerifyNumber: "",
  15301. InsuplcAdmdvs: insuplc_admdvs,
  15302. }
  15303. service.CreateHisPsn(psn)
  15304. c.ServeSuccessJSON(map[string]interface{}{
  15305. "patient": patient,
  15306. "insutype": insutype,
  15307. "number": basNumber,
  15308. })
  15309. }
  15310. } else {
  15311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15312. return
  15313. }
  15314. break
  15315. }
  15316. case 2:
  15317. if miConfig.MdtrtareaAdmvs == "430800" {
  15318. if initFlag == 0 {
  15319. c.TestGetHnBasBaseInit()
  15320. }
  15321. SFZStr := c.GetSFZBaseInfo()
  15322. if len(SFZStr) == 0 {
  15323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15324. return
  15325. }
  15326. fmt.Println(SFZStr)
  15327. id_card_str := strings.Split(SFZStr, "^")
  15328. card_no := id_card_str[0]
  15329. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15330. //name := id_card_str[1]
  15331. //name = ConvertToString(name, "gbk", "utf-8")
  15332. 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)
  15333. var dat map[string]interface{}
  15334. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15335. fmt.Println(dat)
  15336. } else {
  15337. fmt.Println(err)
  15338. }
  15339. userJSONBytes, _ := json.Marshal(dat)
  15340. var res ResultTwo
  15341. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15342. utils.ErrorLog("解析失败:%v", err)
  15343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15344. return
  15345. }
  15346. if res.Infcode == 0 {
  15347. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15348. if err == gorm.ErrRecordNotFound {
  15349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15350. return
  15351. } else if err != nil {
  15352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15353. return
  15354. } else {
  15355. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15356. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15357. infoStr := string(Iinfos)
  15358. idetinfoStr := string(Idetinfos)
  15359. var rf []*ResultFive
  15360. json.Unmarshal([]byte(infoStr), &rf)
  15361. var insutypes []*ResultFive
  15362. var insutype string
  15363. var is390 int = 0
  15364. var is310 int = 0
  15365. for _, item := range rf {
  15366. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15367. insutypes = append(insutypes, item)
  15368. }
  15369. }
  15370. if len(insutypes) == 1 {
  15371. insutype = insutypes[0].Insutype
  15372. } else {
  15373. for _, i := range insutypes {
  15374. if i.Insutype == "390" {
  15375. is390 = 1
  15376. }
  15377. if i.Insutype == "310" {
  15378. is310 = 1
  15379. }
  15380. }
  15381. }
  15382. if is390 == 1 {
  15383. insutype = "390"
  15384. }
  15385. if is310 == 1 {
  15386. insutype = "310"
  15387. }
  15388. if len(insutypes) == 0 {
  15389. insutype = "310"
  15390. }
  15391. var InsuplcAdmdvs string
  15392. for _, item := range rf {
  15393. if item.Insutype == insutype {
  15394. InsuplcAdmdvs = item.InsuplcAdmdvs
  15395. }
  15396. }
  15397. psn := &models.HisPsn{
  15398. PsnNo: res.Output.Baseinfo.PsnNo,
  15399. PatientId: patient.ID,
  15400. Certno: res.Output.Baseinfo.Certno,
  15401. Gend: res.Output.Baseinfo.Gend,
  15402. Naty: res.Output.Baseinfo.Naty,
  15403. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15404. PsnName: res.Output.Baseinfo.PsnName,
  15405. Idetinfo: idetinfoStr,
  15406. Insuinfo: infoStr,
  15407. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15408. CardInfo: SFZStr,
  15409. VerifyNumber: "",
  15410. InsuplcAdmdvs: InsuplcAdmdvs,
  15411. }
  15412. service.CreateHisPsn(psn)
  15413. c.ServeSuccessJSON(map[string]interface{}{
  15414. "patient": patient,
  15415. "number": card_no,
  15416. "insutype": insutype,
  15417. })
  15418. }
  15419. } else {
  15420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15421. return
  15422. }
  15423. } else if miConfig.MdtrtareaAdmvs == "420200" {
  15424. var res ResultTwo
  15425. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  15426. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15427. "&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)
  15428. resp, requestErr := http.Get(api)
  15429. if requestErr != nil {
  15430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15431. return
  15432. }
  15433. body, ioErr := ioutil.ReadAll(resp.Body)
  15434. if ioErr != nil {
  15435. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15437. return
  15438. }
  15439. var respJSON map[string]interface{}
  15440. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15441. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15443. return
  15444. }
  15445. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15446. result, _ := json.Marshal(respJSON)
  15447. fmt.Println("log")
  15448. fmt.Println(string(result))
  15449. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15450. utils.ErrorLog("解析失败:%v", err)
  15451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15452. return
  15453. }
  15454. if res.Infcode == 0 {
  15455. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15456. if err == gorm.ErrRecordNotFound {
  15457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15458. return
  15459. } else if err != nil {
  15460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15461. return
  15462. } else {
  15463. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15464. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15465. infoStr := string(Iinfos)
  15466. idetinfoStr := string(Idetinfos)
  15467. psn := &models.HisPsn{
  15468. PsnNo: res.Output.Baseinfo.PsnNo,
  15469. PatientId: patient.ID,
  15470. Certno: res.Output.Baseinfo.Certno,
  15471. Gend: res.Output.Baseinfo.Gend,
  15472. Naty: res.Output.Baseinfo.Naty,
  15473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15474. PsnName: res.Output.Baseinfo.PsnName,
  15475. Idetinfo: idetinfoStr,
  15476. Insuinfo: infoStr,
  15477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15478. }
  15479. service.CreateHisPsn(psn)
  15480. c.ServeSuccessJSON(map[string]interface{}{
  15481. "patient": patient,
  15482. "number": res.Output.Baseinfo.Certno,
  15483. })
  15484. }
  15485. } else {
  15486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15487. return
  15488. }
  15489. } else if miConfig.MdtrtareaAdmvs == "421182" {
  15490. var res ResultTwo
  15491. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15492. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15493. "&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)
  15494. resp, requestErr := http.Get(api)
  15495. if requestErr != nil {
  15496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15497. return
  15498. }
  15499. body, ioErr := ioutil.ReadAll(resp.Body)
  15500. if ioErr != nil {
  15501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15503. return
  15504. }
  15505. var respJSON map[string]interface{}
  15506. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15509. return
  15510. }
  15511. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15512. result, _ := json.Marshal(respJSON)
  15513. fmt.Println("log")
  15514. fmt.Println(string(result))
  15515. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15516. utils.ErrorLog("解析失败:%v", err)
  15517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15518. return
  15519. }
  15520. if res.Infcode == 0 {
  15521. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15522. if err == gorm.ErrRecordNotFound {
  15523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15524. return
  15525. } else if err != nil {
  15526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15527. return
  15528. } else {
  15529. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15530. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15531. infoStr := string(Iinfos)
  15532. idetinfoStr := string(Idetinfos)
  15533. psn := &models.HisPsn{
  15534. PsnNo: res.Output.Baseinfo.PsnNo,
  15535. PatientId: patient.ID,
  15536. Certno: res.Output.Baseinfo.Certno,
  15537. Gend: res.Output.Baseinfo.Gend,
  15538. Naty: res.Output.Baseinfo.Naty,
  15539. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15540. PsnName: res.Output.Baseinfo.PsnName,
  15541. Idetinfo: idetinfoStr,
  15542. Insuinfo: infoStr,
  15543. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15544. }
  15545. service.CreateHisPsn(psn)
  15546. c.ServeSuccessJSON(map[string]interface{}{
  15547. "patient": patient,
  15548. "number": res.Output.Baseinfo.Certno,
  15549. })
  15550. }
  15551. } else {
  15552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15553. return
  15554. }
  15555. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15556. var res ResultTwo
  15557. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15558. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15559. "&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)
  15560. resp, requestErr := http.Get(api)
  15561. if requestErr != nil {
  15562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15563. return
  15564. }
  15565. body, ioErr := ioutil.ReadAll(resp.Body)
  15566. if ioErr != nil {
  15567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15569. return
  15570. }
  15571. var respJSON map[string]interface{}
  15572. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15575. return
  15576. }
  15577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15578. result, _ := json.Marshal(respJSON)
  15579. fmt.Println("log")
  15580. fmt.Println(string(result))
  15581. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15582. utils.ErrorLog("解析失败:%v", err)
  15583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15584. return
  15585. }
  15586. if res.Infcode == 0 {
  15587. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15588. if err == gorm.ErrRecordNotFound {
  15589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15590. return
  15591. } else if err != nil {
  15592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15593. return
  15594. } else {
  15595. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15596. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15597. infoStr := string(Iinfos)
  15598. idetinfoStr := string(Idetinfos)
  15599. var rf []*ResultFive
  15600. json.Unmarshal([]byte(infoStr), &rf)
  15601. var insutypes []*ResultFive
  15602. var insutype string
  15603. var is390 int = 0
  15604. var is310 int = 0
  15605. for _, item := range rf {
  15606. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15607. insutypes = append(insutypes, item)
  15608. }
  15609. }
  15610. if len(insutypes) == 1 {
  15611. insutype = insutypes[0].Insutype
  15612. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15613. } else {
  15614. for _, i := range insutypes {
  15615. if i.Insutype == "390" {
  15616. is390 = 1
  15617. }
  15618. if i.Insutype == "310" {
  15619. is310 = 1
  15620. }
  15621. }
  15622. }
  15623. if is390 == 1 {
  15624. insutype = "390"
  15625. }
  15626. if is310 == 1 {
  15627. insutype = "310"
  15628. }
  15629. if len(insutypes) == 0 {
  15630. insutype = "390"
  15631. }
  15632. var insuplc_admdvs string
  15633. for _, item := range rf {
  15634. if item.Insutype == insutype {
  15635. insuplc_admdvs = item.InsuplcAdmdvs
  15636. }
  15637. }
  15638. psn := &models.HisPsn{
  15639. PsnNo: res.Output.Baseinfo.PsnNo,
  15640. PatientId: patient.ID,
  15641. Certno: res.Output.Baseinfo.Certno,
  15642. Gend: res.Output.Baseinfo.Gend,
  15643. Naty: res.Output.Baseinfo.Naty,
  15644. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15645. PsnName: res.Output.Baseinfo.PsnName,
  15646. Idetinfo: idetinfoStr,
  15647. Insuinfo: infoStr,
  15648. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15649. InsuplcAdmdvs: insuplc_admdvs,
  15650. }
  15651. service.CreateHisPsn(psn)
  15652. c.ServeSuccessJSON(map[string]interface{}{
  15653. "patient": patient,
  15654. "number": res.Output.Baseinfo.Certno,
  15655. })
  15656. }
  15657. } else {
  15658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15659. return
  15660. }
  15661. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15662. res := c.GetoleInfo()
  15663. if res.Infcode == 0 {
  15664. var result string
  15665. if res.Output.MdtrtCertType == "01" {
  15666. 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)
  15667. } else if res.Output.MdtrtCertType == "02" {
  15668. 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)
  15669. } else if res.Output.MdtrtCertType == "03" {
  15670. 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)
  15671. }
  15672. var dat map[string]interface{}
  15673. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15674. fmt.Println(dat)
  15675. } else {
  15676. fmt.Println(err)
  15677. }
  15678. userJSONBytes, _ := json.Marshal(dat)
  15679. var res2 ResultTwo
  15680. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15681. utils.ErrorLog("解析失败:%v", err)
  15682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15683. return
  15684. }
  15685. if res2.Infcode == 0 {
  15686. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15687. if err == gorm.ErrRecordNotFound {
  15688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15689. return
  15690. } else if err != nil {
  15691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15692. return
  15693. } else {
  15694. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15695. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15696. infoStr := string(Iinfos)
  15697. idetinfoStr := string(Idetinfos)
  15698. var rf []*ResultFive
  15699. json.Unmarshal([]byte(infoStr), &rf)
  15700. var insutypes []*ResultFive
  15701. var insutype string
  15702. var is390 int = 0
  15703. var is310 int = 0
  15704. //var insuplc_admdvs string
  15705. for _, item := range rf {
  15706. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15707. insutypes = append(insutypes, item)
  15708. }
  15709. }
  15710. if len(insutypes) == 1 {
  15711. insutype = insutypes[0].Insutype
  15712. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15713. } else {
  15714. for _, i := range insutypes {
  15715. if i.Insutype == "390" {
  15716. is390 = 1
  15717. }
  15718. if i.Insutype == "310" {
  15719. is310 = 1
  15720. }
  15721. }
  15722. }
  15723. if is390 == 1 {
  15724. insutype = "390"
  15725. }
  15726. if is310 == 1 {
  15727. insutype = "310"
  15728. }
  15729. if len(insutypes) == 0 {
  15730. insutype = "310"
  15731. }
  15732. psn := &models.HisPsn{
  15733. PsnNo: res2.Output.Baseinfo.PsnNo,
  15734. PatientId: patient.ID,
  15735. //Brdy: res2.Output.Baseinfo.Brdy,
  15736. Certno: res2.Output.Baseinfo.Certno,
  15737. Gend: res2.Output.Baseinfo.Gend,
  15738. Naty: res2.Output.Baseinfo.Naty,
  15739. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15740. PsnName: res2.Output.Baseinfo.PsnName,
  15741. Idetinfo: idetinfoStr,
  15742. Insuinfo: infoStr,
  15743. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15744. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15745. VerifyNumber: res.Output.EcToken,
  15746. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15747. }
  15748. service.CreateHisPsn(psn)
  15749. var balc float64
  15750. for _, item := range rf {
  15751. if item.Insutype == insutype {
  15752. balc = item.Balc
  15753. }
  15754. }
  15755. c.ServeSuccessJSON(map[string]interface{}{
  15756. "patient": patient,
  15757. "number": res.Output.CardNo,
  15758. "insutype": insutype,
  15759. "blac": balc,
  15760. "desc": idetinfoStr,
  15761. })
  15762. }
  15763. } else {
  15764. c.ServeSuccessJSON(map[string]interface{}{
  15765. "failed_code": -10,
  15766. "msg": res2.ErrMsg,
  15767. })
  15768. }
  15769. } else {
  15770. c.ServeSuccessJSON(map[string]interface{}{
  15771. "failed_code": -10,
  15772. "msg": res.ErrMsg,
  15773. })
  15774. }
  15775. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15776. var insuplc_admdvs string
  15777. if len(patient.InsuplcAdmdvs) > 0 {
  15778. insuplc_admdvs = patient.InsuplcAdmdvs
  15779. } else {
  15780. if len(insuplc_admdvs_str) > 0 {
  15781. insuplc_admdvs = insuplc_admdvs_str
  15782. } else {
  15783. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15784. }
  15785. }
  15786. //请求内网数据
  15787. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15788. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15789. "&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=" + ""
  15790. resp, requestErr := http.Get(api)
  15791. if requestErr != nil {
  15792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15793. return
  15794. }
  15795. body, ioErr := ioutil.ReadAll(resp.Body)
  15796. if ioErr != nil {
  15797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15799. return
  15800. }
  15801. var respJSON map[string]interface{}
  15802. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15805. return
  15806. }
  15807. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15808. if status == "0" {
  15809. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15810. c.ServeSuccessJSON(map[string]interface{}{
  15811. "failed_code": -10,
  15812. "msg": err_msg,
  15813. })
  15814. return
  15815. }
  15816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15817. var res ResultTwo
  15818. result, _ := json.Marshal(respJSON)
  15819. fmt.Println("log")
  15820. fmt.Println(string(result))
  15821. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15822. utils.ErrorLog("解析失败:%v", err)
  15823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15824. return
  15825. }
  15826. if res.Infcode == 0 {
  15827. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15828. if err == gorm.ErrRecordNotFound {
  15829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15830. return
  15831. } else if err != nil {
  15832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15833. return
  15834. } else {
  15835. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15836. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15837. infoStr := string(Iinfos)
  15838. idetinfoStr := string(Idetinfos)
  15839. psn := &models.HisPsn{
  15840. PsnNo: res.Output.Baseinfo.PsnNo,
  15841. PatientId: patient.ID,
  15842. Certno: res.Output.Baseinfo.Certno,
  15843. Gend: res.Output.Baseinfo.Gend,
  15844. Naty: res.Output.Baseinfo.Naty,
  15845. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15846. PsnName: res.Output.Baseinfo.PsnName,
  15847. Idetinfo: idetinfoStr,
  15848. Insuinfo: infoStr,
  15849. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15850. }
  15851. service.CreateHisPsn(psn)
  15852. var rf []*ResultFive
  15853. json.Unmarshal([]byte(infoStr), &rf)
  15854. var insutypes []*ResultFive
  15855. var is390 int = 0
  15856. var is310 int = 0
  15857. var insutype string
  15858. for _, item := range rf {
  15859. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15860. insutypes = append(insutypes, item)
  15861. }
  15862. }
  15863. if len(insutypes) == 1 {
  15864. insutype = insutypes[0].Insutype
  15865. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15866. } else {
  15867. for _, i := range insutypes {
  15868. if i.Insutype == "390" {
  15869. is390 = 1
  15870. }
  15871. if i.Insutype == "310" {
  15872. is310 = 1
  15873. }
  15874. }
  15875. }
  15876. if is390 == 1 {
  15877. insutype = "390"
  15878. }
  15879. if is310 == 1 {
  15880. insutype = "310"
  15881. }
  15882. if len(insutypes) == 0 {
  15883. insutype = "390"
  15884. }
  15885. c.ServeSuccessJSON(map[string]interface{}{
  15886. "patient": patient,
  15887. "insutype": insutype,
  15888. "number": res.Output.Baseinfo.Certno,
  15889. "info": res,
  15890. })
  15891. }
  15892. } else {
  15893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15894. return
  15895. }
  15896. } else {
  15897. SFZStr := c.GetSFZBaseInfo()
  15898. id_card_str := strings.Split(SFZStr, "^")
  15899. id_card_number := id_card_str[0]
  15900. card_sn := ""
  15901. 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)
  15902. var dat map[string]interface{}
  15903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15904. fmt.Println(dat)
  15905. } else {
  15906. fmt.Println(err)
  15907. }
  15908. userJSONBytes, _ := json.Marshal(dat)
  15909. var res ResultTwo
  15910. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15911. utils.ErrorLog("解析失败:%v", err)
  15912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15913. return
  15914. }
  15915. if res.Infcode == 0 {
  15916. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15917. if err == gorm.ErrRecordNotFound {
  15918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15919. return
  15920. } else if err != nil {
  15921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15922. return
  15923. } else {
  15924. c.ServeSuccessJSON(map[string]interface{}{
  15925. "patient": patient,
  15926. "number": id_card_number,
  15927. })
  15928. }
  15929. } else {
  15930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15931. return
  15932. }
  15933. }
  15934. break
  15935. case 3:
  15936. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15937. var api string
  15938. if miConfig.MdtrtareaAdmvs == "320921" {
  15939. 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 +
  15940. "&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
  15941. fmt.Println(api)
  15942. } else {
  15943. 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 +
  15944. "&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)
  15945. }
  15946. resp, requestErr := http.Get(api)
  15947. if requestErr != nil {
  15948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15949. return
  15950. }
  15951. body, ioErr := ioutil.ReadAll(resp.Body)
  15952. if ioErr != nil {
  15953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15955. return
  15956. }
  15957. var respJSON map[string]interface{}
  15958. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15961. return
  15962. }
  15963. var status string
  15964. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15965. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15966. var token string
  15967. var res ResultTwo //1101结果
  15968. var res10265 ResultTwo10265 //1101结果
  15969. var card_info string //卡信息
  15970. var busi_card_info string
  15971. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15972. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15973. if status == "0" { //读卡成功
  15974. if card_type == "1" {
  15975. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15976. result, _ := json.Marshal(respJSON)
  15977. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15978. utils.ErrorLog("解析失败:%v", err)
  15979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15980. return
  15981. }
  15982. res.ErrMsg = res10265.ErrMsg
  15983. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15984. res.Infcode = infocode
  15985. res.Output = res10265.Output
  15986. res.InfRefmsgid = res10265.InfRefmsgid
  15987. } else {
  15988. //var card_info string //卡信息
  15989. //var busi_card_info string
  15990. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15991. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15992. //fmt.Println(card_info)
  15993. //fmt.Println(busi_card_info)
  15994. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15995. result, _ := json.Marshal(respJSON)
  15996. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15997. utils.ErrorLog("解析失败:%v", err)
  15998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15999. return
  16000. }
  16001. res.ErrMsg = res10265.ErrMsg
  16002. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16003. res.Infcode = infocode
  16004. res.Output = res10265.Output
  16005. res.InfRefmsgid = res10265.InfRefmsgid
  16006. }
  16007. if res.Infcode == 0 {
  16008. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16009. if err == gorm.ErrRecordNotFound {
  16010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16011. return
  16012. } else if err != nil {
  16013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16014. return
  16015. } else {
  16016. if card_type == "1" {
  16017. bas := strings.Split(card_info, "|")
  16018. basNumber := bas[2]
  16019. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16020. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16021. infoStr := string(Iinfos)
  16022. idetinfoStr := string(Idetinfos)
  16023. psn := &models.HisPsn{
  16024. PsnNo: res.Output.Baseinfo.PsnNo,
  16025. PatientId: patient.ID,
  16026. Certno: res.Output.Baseinfo.Certno,
  16027. //Brdy: res.Output.Baseinfo.Brdy,
  16028. Gend: res.Output.Baseinfo.Gend,
  16029. Naty: res.Output.Baseinfo.Naty,
  16030. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16031. PsnName: res.Output.Baseinfo.PsnName,
  16032. Idetinfo: idetinfoStr,
  16033. Insuinfo: infoStr,
  16034. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16035. CardInfo: card_info,
  16036. VerifyNumber: busi_card_info,
  16037. }
  16038. service.CreateHisPsn(psn)
  16039. c.ServeSuccessJSON(map[string]interface{}{
  16040. "patient": patient,
  16041. "number": basNumber,
  16042. })
  16043. } else {
  16044. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16045. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16046. infoStr := string(Iinfos)
  16047. idetinfoStr := string(Idetinfos)
  16048. psn := &models.HisPsn{
  16049. PsnNo: res.Output.Baseinfo.PsnNo,
  16050. PatientId: patient.ID,
  16051. Certno: res.Output.Baseinfo.Certno,
  16052. Gend: res.Output.Baseinfo.Gend,
  16053. Naty: res.Output.Baseinfo.Naty,
  16054. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16055. PsnName: res.Output.Baseinfo.PsnName,
  16056. Idetinfo: idetinfoStr,
  16057. Insuinfo: infoStr,
  16058. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16059. CardInfo: card_info,
  16060. VerifyNumber: token,
  16061. }
  16062. service.CreateHisPsn(psn)
  16063. var rf []*ResultFive
  16064. json.Unmarshal([]byte(infoStr), &rf)
  16065. var insutypes []*ResultFive
  16066. var insutype string
  16067. var is390 int = 0
  16068. var is310 int = 0
  16069. for _, item := range rf {
  16070. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16071. insutypes = append(insutypes, item)
  16072. }
  16073. }
  16074. if len(insutypes) == 1 {
  16075. insutype = insutypes[0].Insutype
  16076. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16077. } else {
  16078. for _, i := range insutypes {
  16079. if i.Insutype == "390" {
  16080. is390 = 1
  16081. }
  16082. if i.Insutype == "310" {
  16083. is310 = 1
  16084. }
  16085. }
  16086. }
  16087. if is390 == 1 {
  16088. insutype = "390"
  16089. }
  16090. if is310 == 1 {
  16091. insutype = "310"
  16092. }
  16093. if len(insutypes) == 0 {
  16094. insutype = "310"
  16095. }
  16096. c.ServeSuccessJSON(map[string]interface{}{
  16097. "patient": patient,
  16098. "number": token,
  16099. "insutype": insutype,
  16100. })
  16101. }
  16102. }
  16103. } else {
  16104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16105. return
  16106. }
  16107. } else { //读卡失败
  16108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16109. return
  16110. }
  16111. }
  16112. break
  16113. case 4:
  16114. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16115. var api string
  16116. if miConfig.MdtrtareaAdmvs == "320921" {
  16117. 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 +
  16118. "&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
  16119. fmt.Println(api)
  16120. } else {
  16121. 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 +
  16122. "&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)
  16123. }
  16124. resp, requestErr := http.Get(api)
  16125. if requestErr != nil {
  16126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16127. return
  16128. }
  16129. body, ioErr := ioutil.ReadAll(resp.Body)
  16130. if ioErr != nil {
  16131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16133. return
  16134. }
  16135. var respJSON map[string]interface{}
  16136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16139. return
  16140. }
  16141. var status string
  16142. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16143. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16144. var token string
  16145. var res ResultTwo //1101结果
  16146. var res10265 ResultTwo10265 //1101结果
  16147. if status == "0" { //读卡成功
  16148. var card_info string //卡信息
  16149. var busi_card_info string
  16150. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16151. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16152. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16153. fmt.Println(card_info)
  16154. fmt.Println(busi_card_info)
  16155. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16156. result, _ := json.Marshal(respJSON)
  16157. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16158. utils.ErrorLog("解析失败:%v", err)
  16159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16160. return
  16161. }
  16162. res.ErrMsg = res10265.ErrMsg
  16163. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16164. res.Infcode = infocode
  16165. res.Output = res10265.Output
  16166. res.InfRefmsgid = res10265.InfRefmsgid
  16167. if res.Infcode == 0 {
  16168. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16169. if err == gorm.ErrRecordNotFound {
  16170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16171. return
  16172. } else if err != nil {
  16173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16174. return
  16175. } else {
  16176. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16177. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16178. infoStr := string(Iinfos)
  16179. idetinfoStr := string(Idetinfos)
  16180. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16181. psn := &models.HisPsn{
  16182. PsnNo: res.Output.Baseinfo.PsnNo,
  16183. PatientId: patient.ID,
  16184. Certno: res.Output.Baseinfo.Certno,
  16185. Brdy: b,
  16186. Age: float64(age),
  16187. //Brdy: res.Output.Baseinfo.Brdy,
  16188. Gend: res.Output.Baseinfo.Gend,
  16189. Naty: res.Output.Baseinfo.Naty,
  16190. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16191. PsnName: res.Output.Baseinfo.PsnName,
  16192. Idetinfo: idetinfoStr,
  16193. Insuinfo: infoStr,
  16194. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16195. CardInfo: card_info,
  16196. VerifyNumber: token,
  16197. }
  16198. var rf []*ResultFive
  16199. json.Unmarshal([]byte(infoStr), &rf)
  16200. var insutypes []*ResultFive
  16201. var insutype string
  16202. var is390 int = 0
  16203. var is310 int = 0
  16204. for _, item := range rf {
  16205. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16206. insutypes = append(insutypes, item)
  16207. }
  16208. }
  16209. if len(insutypes) == 1 {
  16210. insutype = insutypes[0].Insutype
  16211. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16212. } else {
  16213. for _, i := range insutypes {
  16214. if i.Insutype == "390" {
  16215. is390 = 1
  16216. }
  16217. if i.Insutype == "310" {
  16218. is310 = 1
  16219. }
  16220. }
  16221. }
  16222. if is390 == 1 {
  16223. insutype = "390"
  16224. }
  16225. if is310 == 1 {
  16226. insutype = "310"
  16227. }
  16228. if len(insutypes) == 0 {
  16229. insutype = "310"
  16230. }
  16231. service.CreateHisPsn(psn)
  16232. c.ServeSuccessJSON(map[string]interface{}{
  16233. "patient": patient,
  16234. "number": token,
  16235. "insutype": insutype,
  16236. })
  16237. }
  16238. } else {
  16239. c.ServeSuccessJSON(map[string]interface{}{
  16240. "failed_code": -10,
  16241. "msg": res.ErrMsg,
  16242. })
  16243. }
  16244. } else { //读卡失败
  16245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16246. return
  16247. }
  16248. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16249. var api string
  16250. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16251. "&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
  16252. resp, requestErr := http.Get(api)
  16253. if requestErr != nil {
  16254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16255. return
  16256. }
  16257. body, ioErr := ioutil.ReadAll(resp.Body)
  16258. if ioErr != nil {
  16259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16261. return
  16262. }
  16263. var respJSON map[string]interface{}
  16264. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16267. return
  16268. }
  16269. var status string
  16270. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16271. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16272. var token string
  16273. var res ResultTwo //1101结果
  16274. if status == "1" { //读卡成功
  16275. var card_info string //卡信息
  16276. var busi_card_info string
  16277. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16278. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16279. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16280. fmt.Println(card_info)
  16281. fmt.Println(busi_card_info)
  16282. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16283. result, _ := json.Marshal(respJSON)
  16284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16285. utils.ErrorLog("解析失败:%v", err)
  16286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16287. return
  16288. }
  16289. if res.Infcode == 0 {
  16290. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16291. if err == gorm.ErrRecordNotFound {
  16292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16293. return
  16294. } else if err != nil {
  16295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16296. return
  16297. } else {
  16298. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16299. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16300. infoStr := string(Iinfos)
  16301. idetinfoStr := string(Idetinfos)
  16302. psn := &models.HisPsn{
  16303. PsnNo: res.Output.Baseinfo.PsnNo,
  16304. PatientId: patient.ID,
  16305. Certno: res.Output.Baseinfo.Certno,
  16306. Gend: res.Output.Baseinfo.Gend,
  16307. Naty: res.Output.Baseinfo.Naty,
  16308. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16309. PsnName: res.Output.Baseinfo.PsnName,
  16310. Idetinfo: idetinfoStr,
  16311. Insuinfo: infoStr,
  16312. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16313. CardInfo: card_info,
  16314. VerifyNumber: token,
  16315. }
  16316. var rf []*ResultFive
  16317. json.Unmarshal([]byte(infoStr), &rf)
  16318. var insutypes []*ResultFive
  16319. var insutype string
  16320. var is390 int = 0
  16321. var is310 int = 0
  16322. for _, item := range rf {
  16323. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16324. insutypes = append(insutypes, item)
  16325. }
  16326. }
  16327. if len(insutypes) == 1 {
  16328. insutype = insutypes[0].Insutype
  16329. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16330. } else {
  16331. for _, i := range insutypes {
  16332. if i.Insutype == "390" {
  16333. is390 = 1
  16334. }
  16335. if i.Insutype == "310" {
  16336. is310 = 1
  16337. }
  16338. }
  16339. }
  16340. if is390 == 1 {
  16341. insutype = "390"
  16342. }
  16343. if is310 == 1 {
  16344. insutype = "310"
  16345. }
  16346. if len(insutypes) == 0 {
  16347. insutype = "310"
  16348. }
  16349. service.CreateHisPsn(psn)
  16350. c.ServeSuccessJSON(map[string]interface{}{
  16351. "patient": patient,
  16352. "number": token,
  16353. "insutype": insutype,
  16354. })
  16355. }
  16356. } else {
  16357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16358. return
  16359. }
  16360. } else { //读卡失败
  16361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16362. return
  16363. }
  16364. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16365. var api string
  16366. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16367. "&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
  16368. resp, requestErr := http.Get(api)
  16369. if requestErr != nil {
  16370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16371. return
  16372. }
  16373. body, ioErr := ioutil.ReadAll(resp.Body)
  16374. if ioErr != nil {
  16375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16377. return
  16378. }
  16379. var respJSON map[string]interface{}
  16380. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16383. return
  16384. }
  16385. var status string
  16386. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16387. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16388. var token string
  16389. var res ResultTwo //1101结果
  16390. if status == "1" { //读卡成功
  16391. var card_info string //卡信息
  16392. var busi_card_info string
  16393. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16394. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16395. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16396. fmt.Println(card_info)
  16397. fmt.Println(busi_card_info)
  16398. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16399. result, _ := json.Marshal(respJSON)
  16400. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16401. utils.ErrorLog("解析失败:%v", err)
  16402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16403. return
  16404. }
  16405. if res.Infcode == 0 {
  16406. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16407. if err == gorm.ErrRecordNotFound {
  16408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16409. return
  16410. } else if err != nil {
  16411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16412. return
  16413. } else {
  16414. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16415. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16416. infoStr := string(Iinfos)
  16417. idetinfoStr := string(Idetinfos)
  16418. psn := &models.HisPsn{
  16419. PsnNo: res.Output.Baseinfo.PsnNo,
  16420. PatientId: patient.ID,
  16421. Certno: res.Output.Baseinfo.Certno,
  16422. Gend: res.Output.Baseinfo.Gend,
  16423. Naty: res.Output.Baseinfo.Naty,
  16424. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16425. PsnName: res.Output.Baseinfo.PsnName,
  16426. Idetinfo: idetinfoStr,
  16427. Insuinfo: infoStr,
  16428. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16429. CardInfo: card_info,
  16430. VerifyNumber: token,
  16431. }
  16432. var rf []*ResultFive
  16433. json.Unmarshal([]byte(infoStr), &rf)
  16434. var insutypes []*ResultFive
  16435. var insutype string
  16436. var is390 int = 0
  16437. var is310 int = 0
  16438. for _, item := range rf {
  16439. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16440. insutypes = append(insutypes, item)
  16441. }
  16442. }
  16443. if len(insutypes) == 1 {
  16444. insutype = insutypes[0].Insutype
  16445. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16446. } else {
  16447. for _, i := range insutypes {
  16448. if i.Insutype == "390" {
  16449. is390 = 1
  16450. }
  16451. if i.Insutype == "310" {
  16452. is310 = 1
  16453. }
  16454. }
  16455. }
  16456. if is390 == 1 {
  16457. insutype = "390"
  16458. }
  16459. if is310 == 1 {
  16460. insutype = "310"
  16461. }
  16462. if len(insutypes) == 0 {
  16463. insutype = "390"
  16464. }
  16465. service.CreateHisPsn(psn)
  16466. c.ServeSuccessJSON(map[string]interface{}{
  16467. "patient": patient,
  16468. "number": token,
  16469. "insutype": insutype,
  16470. })
  16471. }
  16472. } else {
  16473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16474. return
  16475. }
  16476. } else { //读卡失败
  16477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16478. return
  16479. }
  16480. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16481. //idNo := c.GetString("idNo")
  16482. //userName := c.GetString("userName")
  16483. //ecToken := c.GetString("ecToken")
  16484. //insuOrg := c.GetString("insuOrg")
  16485. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  16486. utils.ErrorLog("解析失败:%v", json_result)
  16487. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16488. type ELeData struct {
  16489. Data struct {
  16490. IdNo string `json:"idNo"`
  16491. IdType string `json:"idType"`
  16492. UserName string `json:"userName"`
  16493. EcToken string `json:"ecToken"`
  16494. InsuOrg string `json:"insuOrg"`
  16495. Gender string `json:"gender"`
  16496. Birthday string `json:"birthday"`
  16497. Nationality string `json:"nationality"`
  16498. Email string `json:"email"`
  16499. Extra string `json:"extra"`
  16500. } `json:"data"`
  16501. Code int `json:"code"`
  16502. Message string `json:"message"`
  16503. }
  16504. var ele ELeData
  16505. err := json.Unmarshal([]byte(json_result), &ele)
  16506. if err != nil {
  16507. utils.ErrorLog("解析失败:%v", err)
  16508. }
  16509. token := ele.Data.EcToken
  16510. token = Remove0000(token)
  16511. 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)
  16512. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16513. var res ResultTwo
  16514. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16515. utils.ErrorLog("解析失败:%v", err)
  16516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16517. return
  16518. }
  16519. if res.Infcode == 0 {
  16520. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16521. if err == gorm.ErrRecordNotFound {
  16522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16523. return
  16524. } else if err != nil {
  16525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16526. return
  16527. } else {
  16528. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16529. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16530. infoStr := string(Iinfos)
  16531. idetinfoStr := string(Idetinfos)
  16532. psn := &models.HisPsn{
  16533. PsnNo: res.Output.Baseinfo.PsnNo,
  16534. PatientId: patient.ID,
  16535. Certno: res.Output.Baseinfo.Certno,
  16536. Gend: res.Output.Baseinfo.Gend,
  16537. Naty: res.Output.Baseinfo.Naty,
  16538. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16539. PsnName: res.Output.Baseinfo.PsnName,
  16540. Idetinfo: idetinfoStr,
  16541. Insuinfo: infoStr,
  16542. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16543. CardInfo: "",
  16544. Stage: "1",
  16545. VerifyNumber: token,
  16546. InsuplcAdmdvs: ele.Data.InsuOrg,
  16547. }
  16548. service.CreateHisPsn(psn)
  16549. var rf []*ResultFive
  16550. json.Unmarshal([]byte(infoStr), &rf)
  16551. var insutypes []*ResultFive
  16552. var insutype string
  16553. var is390 int = 0
  16554. var is310 int = 0
  16555. for _, item := range rf {
  16556. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16557. insutypes = append(insutypes, item)
  16558. }
  16559. }
  16560. if len(insutypes) == 1 {
  16561. insutype = insutypes[0].Insutype
  16562. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16563. } else {
  16564. for _, i := range insutypes {
  16565. if i.Insutype == "390" {
  16566. is390 = 1
  16567. }
  16568. if i.Insutype == "310" {
  16569. is310 = 1
  16570. }
  16571. }
  16572. }
  16573. if is390 == 1 {
  16574. insutype = "390"
  16575. }
  16576. if is310 == 1 {
  16577. insutype = "310"
  16578. }
  16579. if len(insutypes) == 0 {
  16580. insutype = "310"
  16581. }
  16582. c.ServeSuccessJSON(map[string]interface{}{
  16583. "patient": patient,
  16584. "number": token,
  16585. "insutype": insutype,
  16586. })
  16587. }
  16588. } else {
  16589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16590. return
  16591. }
  16592. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16593. //if initFlag == 0 {
  16594. //c.TestGetJiangXiBasBaseInit()
  16595. //}
  16596. //if initEleFlag == 0 {
  16597. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16598. //}
  16599. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16600. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16601. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16602. type ELeData struct {
  16603. Data struct {
  16604. IdNo string `json:"idNo"`
  16605. IdType string `json:"idType"`
  16606. UserName string `json:"userName"`
  16607. EcToken string `json:"ecToken"`
  16608. InsuOrg string `json:"insuOrg"`
  16609. Gender string `json:"gender"`
  16610. Birthday string `json:"birthday"`
  16611. Nationality string `json:"nationality"`
  16612. Email string `json:"email"`
  16613. Extra string `json:"extra"`
  16614. } `json:"data"`
  16615. Code int `json:"code"`
  16616. Message string `json:"message"`
  16617. }
  16618. var ele ELeData
  16619. err := json.Unmarshal([]byte(result), &ele)
  16620. if err != nil {
  16621. utils.ErrorLog("解析失败:%v", err)
  16622. }
  16623. token := ele.Data.EcToken
  16624. token = Remove0000(token)
  16625. 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)
  16626. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16627. var res ResultTwo
  16628. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16629. utils.ErrorLog("解析失败:%v", err)
  16630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16631. return
  16632. }
  16633. if res.Infcode == 0 {
  16634. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16635. if err == gorm.ErrRecordNotFound {
  16636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16637. return
  16638. } else if err != nil {
  16639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16640. return
  16641. } else {
  16642. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16643. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16644. infoStr := string(Iinfos)
  16645. idetinfoStr := string(Idetinfos)
  16646. psn := &models.HisPsn{
  16647. PsnNo: res.Output.Baseinfo.PsnNo,
  16648. PatientId: patient.ID,
  16649. Certno: res.Output.Baseinfo.Certno,
  16650. Gend: res.Output.Baseinfo.Gend,
  16651. Naty: res.Output.Baseinfo.Naty,
  16652. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16653. PsnName: res.Output.Baseinfo.PsnName,
  16654. Idetinfo: idetinfoStr,
  16655. Insuinfo: infoStr,
  16656. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16657. CardInfo: "",
  16658. VerifyNumber: token,
  16659. InsuplcAdmdvs: ele.Data.InsuOrg,
  16660. }
  16661. service.CreateHisPsn(psn)
  16662. var rf []*ResultFive
  16663. json.Unmarshal([]byte(infoStr), &rf)
  16664. var insutypes []*ResultFive
  16665. var insutype string
  16666. var is390 int = 0
  16667. var is310 int = 0
  16668. for _, item := range rf {
  16669. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16670. insutypes = append(insutypes, item)
  16671. }
  16672. }
  16673. if len(insutypes) == 1 {
  16674. insutype = insutypes[0].Insutype
  16675. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16676. } else {
  16677. for _, i := range insutypes {
  16678. if i.Insutype == "390" {
  16679. is390 = 1
  16680. }
  16681. if i.Insutype == "310" {
  16682. is310 = 1
  16683. }
  16684. }
  16685. }
  16686. if is390 == 1 {
  16687. insutype = "390"
  16688. }
  16689. if is310 == 1 {
  16690. insutype = "310"
  16691. }
  16692. if len(insutypes) == 0 {
  16693. insutype = "310"
  16694. }
  16695. c.ServeSuccessJSON(map[string]interface{}{
  16696. "patient": patient,
  16697. "number": token,
  16698. "insutype": insutype,
  16699. })
  16700. }
  16701. } else {
  16702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16703. return
  16704. }
  16705. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16706. //if initFlag == 0 {
  16707. //c.TestGetJiangXiBasBaseInit()
  16708. //}
  16709. //if initEleFlag == 0 {
  16710. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16711. //}
  16712. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16713. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16714. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16715. type ELeData struct {
  16716. Data struct {
  16717. IdNo string `json:"idNo"`
  16718. IdType string `json:"idType"`
  16719. UserName string `json:"userName"`
  16720. EcToken string `json:"ecToken"`
  16721. InsuOrg string `json:"insuOrg"`
  16722. Gender string `json:"gender"`
  16723. Birthday string `json:"birthday"`
  16724. Nationality string `json:"nationality"`
  16725. Email string `json:"email"`
  16726. Extra string `json:"extra"`
  16727. } `json:"data"`
  16728. Code int `json:"code"`
  16729. Message string `json:"message"`
  16730. }
  16731. var ele ELeData
  16732. err := json.Unmarshal([]byte(result), &ele)
  16733. if err != nil {
  16734. utils.ErrorLog("解析失败:%v", err)
  16735. }
  16736. token := ele.Data.EcToken
  16737. token = Remove0000(token)
  16738. 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)
  16739. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16740. var res ResultTwo
  16741. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16742. utils.ErrorLog("解析失败:%v", err)
  16743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16744. return
  16745. }
  16746. if res.Infcode == 0 {
  16747. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16748. if err == gorm.ErrRecordNotFound {
  16749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16750. return
  16751. } else if err != nil {
  16752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16753. return
  16754. } else {
  16755. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16756. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16757. infoStr := string(Iinfos)
  16758. idetinfoStr := string(Idetinfos)
  16759. psn := &models.HisPsn{
  16760. PsnNo: res.Output.Baseinfo.PsnNo,
  16761. PatientId: patient.ID,
  16762. Certno: res.Output.Baseinfo.Certno,
  16763. Gend: res.Output.Baseinfo.Gend,
  16764. Naty: res.Output.Baseinfo.Naty,
  16765. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16766. PsnName: res.Output.Baseinfo.PsnName,
  16767. Idetinfo: idetinfoStr,
  16768. Insuinfo: infoStr,
  16769. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16770. CardInfo: "",
  16771. VerifyNumber: token,
  16772. InsuplcAdmdvs: ele.Data.InsuOrg,
  16773. }
  16774. service.CreateHisPsn(psn)
  16775. var rf []*ResultFive
  16776. json.Unmarshal([]byte(infoStr), &rf)
  16777. var insutypes []*ResultFive
  16778. var insutype string
  16779. var is390 int = 0
  16780. var is310 int = 0
  16781. for _, item := range rf {
  16782. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16783. insutypes = append(insutypes, item)
  16784. }
  16785. }
  16786. if len(insutypes) == 1 {
  16787. insutype = insutypes[0].Insutype
  16788. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16789. } else {
  16790. for _, i := range insutypes {
  16791. if i.Insutype == "390" {
  16792. is390 = 1
  16793. }
  16794. if i.Insutype == "310" {
  16795. is310 = 1
  16796. }
  16797. }
  16798. }
  16799. if is390 == 1 {
  16800. insutype = "390"
  16801. }
  16802. if is310 == 1 {
  16803. insutype = "310"
  16804. }
  16805. if len(insutypes) == 0 {
  16806. insutype = "310"
  16807. }
  16808. c.ServeSuccessJSON(map[string]interface{}{
  16809. "patient": patient,
  16810. "number": token,
  16811. "insutype": insutype,
  16812. })
  16813. }
  16814. } else {
  16815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16816. return
  16817. }
  16818. } else if miConfig.MdtrtareaAdmvs == "360100" {
  16819. //if initFlag == 0 {
  16820. //c.TestGetJiangXiBasBaseInit()
  16821. //}
  16822. //if initEleFlag == 0 {
  16823. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16824. //}
  16825. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16826. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16827. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16828. type ELeData struct {
  16829. Data struct {
  16830. IdNo string `json:"idNo"`
  16831. IdType string `json:"idType"`
  16832. UserName string `json:"userName"`
  16833. EcToken string `json:"ecToken"`
  16834. InsuOrg string `json:"insuOrg"`
  16835. Gender string `json:"gender"`
  16836. Birthday string `json:"birthday"`
  16837. Nationality string `json:"nationality"`
  16838. Email string `json:"email"`
  16839. Extra string `json:"extra"`
  16840. } `json:"data"`
  16841. Code int `json:"code"`
  16842. Message string `json:"message"`
  16843. }
  16844. var ele ELeData
  16845. err := json.Unmarshal([]byte(result), &ele)
  16846. if err != nil {
  16847. utils.ErrorLog("解析失败:%v", err)
  16848. }
  16849. token := ele.Data.EcToken
  16850. token = Remove0000(token)
  16851. 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)
  16852. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16853. var res ResultTwo
  16854. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16855. utils.ErrorLog("解析失败:%v", err)
  16856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16857. return
  16858. }
  16859. if res.Infcode == 0 {
  16860. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16861. if err == gorm.ErrRecordNotFound {
  16862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16863. return
  16864. } else if err != nil {
  16865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16866. return
  16867. } else {
  16868. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16869. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16870. infoStr := string(Iinfos)
  16871. idetinfoStr := string(Idetinfos)
  16872. psn := &models.HisPsn{
  16873. PsnNo: res.Output.Baseinfo.PsnNo,
  16874. PatientId: patient.ID,
  16875. Certno: res.Output.Baseinfo.Certno,
  16876. Gend: res.Output.Baseinfo.Gend,
  16877. Naty: res.Output.Baseinfo.Naty,
  16878. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16879. PsnName: res.Output.Baseinfo.PsnName,
  16880. Idetinfo: idetinfoStr,
  16881. Insuinfo: infoStr,
  16882. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16883. CardInfo: "",
  16884. VerifyNumber: token,
  16885. InsuplcAdmdvs: ele.Data.InsuOrg,
  16886. }
  16887. service.CreateHisPsn(psn)
  16888. var rf []*ResultFive
  16889. json.Unmarshal([]byte(infoStr), &rf)
  16890. var insutypes []*ResultFive
  16891. var insutype string
  16892. var is390 int = 0
  16893. var is310 int = 0
  16894. for _, item := range rf {
  16895. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16896. insutypes = append(insutypes, item)
  16897. }
  16898. }
  16899. if len(insutypes) == 1 {
  16900. insutype = insutypes[0].Insutype
  16901. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16902. } else {
  16903. for _, i := range insutypes {
  16904. if i.Insutype == "390" {
  16905. is390 = 1
  16906. }
  16907. if i.Insutype == "310" {
  16908. is310 = 1
  16909. }
  16910. }
  16911. }
  16912. if is390 == 1 {
  16913. insutype = "390"
  16914. }
  16915. if is310 == 1 {
  16916. insutype = "310"
  16917. }
  16918. if len(insutypes) == 0 {
  16919. insutype = "310"
  16920. }
  16921. c.ServeSuccessJSON(map[string]interface{}{
  16922. "patient": patient,
  16923. "number": token,
  16924. "insutype": insutype,
  16925. })
  16926. }
  16927. } else {
  16928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16929. return
  16930. }
  16931. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16932. //if initFlag == 0 {
  16933. c.TestGetJiangXiBasBaseInit()
  16934. //}
  16935. //if initEleFlag == 0 {
  16936. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16937. //}
  16938. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16939. type ELeData struct {
  16940. Data struct {
  16941. IdNo string `json:"idNo"`
  16942. IdType string `json:"idType"`
  16943. UserName string `json:"userName"`
  16944. EcToken string `json:"ecToken"`
  16945. InsuOrg string `json:"insuOrg"`
  16946. Gender string `json:"gender"`
  16947. Birthday string `json:"birthday"`
  16948. Nationality string `json:"nationality"`
  16949. Email string `json:"email"`
  16950. Extra string `json:"extra"`
  16951. } `json:"data"`
  16952. Code int `json:"code"`
  16953. Message string `json:"message"`
  16954. }
  16955. var ele ELeData
  16956. err := json.Unmarshal([]byte(json_result), &ele)
  16957. if err != nil {
  16958. utils.ErrorLog("解析失败:%v", err)
  16959. }
  16960. token := ele.Data.EcToken
  16961. token = Remove0000(token)
  16962. 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)
  16963. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16964. var res ResultTwo
  16965. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16966. utils.ErrorLog("解析失败:%v", err)
  16967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16968. return
  16969. }
  16970. if res.Infcode == 0 {
  16971. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16972. if err == gorm.ErrRecordNotFound {
  16973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16974. return
  16975. } else if err != nil {
  16976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16977. return
  16978. } else {
  16979. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16980. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16981. infoStr := string(Iinfos)
  16982. idetinfoStr := string(Idetinfos)
  16983. psn := &models.HisPsn{
  16984. PsnNo: res.Output.Baseinfo.PsnNo,
  16985. PatientId: patient.ID,
  16986. Certno: res.Output.Baseinfo.Certno,
  16987. Gend: res.Output.Baseinfo.Gend,
  16988. Naty: res.Output.Baseinfo.Naty,
  16989. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16990. PsnName: res.Output.Baseinfo.PsnName,
  16991. Idetinfo: idetinfoStr,
  16992. Insuinfo: infoStr,
  16993. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16994. CardInfo: "",
  16995. VerifyNumber: token,
  16996. }
  16997. service.CreateHisPsn(psn)
  16998. var rf []*ResultFive
  16999. json.Unmarshal([]byte(infoStr), &rf)
  17000. var insutypes []*ResultFive
  17001. var insutype string
  17002. var is390 int = 0
  17003. var is310 int = 0
  17004. for _, item := range rf {
  17005. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17006. insutypes = append(insutypes, item)
  17007. }
  17008. }
  17009. if len(insutypes) == 1 {
  17010. insutype = insutypes[0].Insutype
  17011. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17012. } else {
  17013. for _, i := range insutypes {
  17014. if i.Insutype == "390" {
  17015. is390 = 1
  17016. }
  17017. if i.Insutype == "310" {
  17018. is310 = 1
  17019. }
  17020. }
  17021. }
  17022. if is390 == 1 {
  17023. insutype = "390"
  17024. }
  17025. if is310 == 1 {
  17026. insutype = "310"
  17027. }
  17028. if len(insutypes) == 0 {
  17029. insutype = "310"
  17030. }
  17031. c.ServeSuccessJSON(map[string]interface{}{
  17032. "patient": patient,
  17033. "number": token,
  17034. "insutype": insutype,
  17035. })
  17036. }
  17037. } else {
  17038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17039. return
  17040. }
  17041. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17042. type ELeData struct {
  17043. Code string `json:"code"`
  17044. Data struct {
  17045. Aac002 string `json:"aac002"`
  17046. Aaz500 string `json:"aaz500"`
  17047. ActCardNo string `json:"actCardNo"`
  17048. Bab520 string `json:"bab520"`
  17049. Bkz543 string `json:"bkz543"`
  17050. BusinessType string `json:"businessType"`
  17051. CertfCodg string `json:"certfCodg"`
  17052. EcIndexNo string `json:"ecIndexNo"`
  17053. EcToken string `json:"ecToken"`
  17054. ID0000 string `json:"id0000"`
  17055. IDNo string `json:"idNo"`
  17056. IDType string `json:"idType"`
  17057. Idcode string `json:"idcode"`
  17058. IdentityToken string `json:"identity_token"`
  17059. InsuOrg string `json:"insuOrg"`
  17060. OfficeID string `json:"officeId"`
  17061. OfficeName string `json:"officeName"`
  17062. OperatorID string `json:"operatorId"`
  17063. OperatorName string `json:"operatorName"`
  17064. OrgID string `json:"orgId"`
  17065. UserName string `json:"userName"`
  17066. } `json:"data"`
  17067. Infno interface{} `json:"infno"`
  17068. Message string `json:"message"`
  17069. OrgID string `json:"orgId"`
  17070. TransType string `json:"transType"`
  17071. }
  17072. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  17073. outPutInfo = Remove0000(outPutInfo)
  17074. if len(outPutInfo) > 0 {
  17075. var ele ELeData
  17076. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17077. if err != nil {
  17078. utils.ErrorLog("解析失败:%v", err)
  17079. }
  17080. token := ele.Data.EcToken
  17081. fmt.Println(inputInfo)
  17082. fmt.Println(outPutInfo)
  17083. 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)
  17084. saveLog(result, requestLog, "1101", "获取人员信息")
  17085. var dat map[string]interface{}
  17086. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17087. fmt.Println(dat)
  17088. } else {
  17089. fmt.Println(err)
  17090. }
  17091. userJSONBytes, _ := json.Marshal(dat)
  17092. var res ResultTwo
  17093. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17094. utils.ErrorLog("解析失败:%v", err)
  17095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17096. return
  17097. }
  17098. res.ErrMsg = errMsgLog
  17099. if res.Infcode == 0 {
  17100. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17101. if err == gorm.ErrRecordNotFound {
  17102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17103. return
  17104. } else if err != nil {
  17105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17106. return
  17107. } else {
  17108. fmt.Println(res)
  17109. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17110. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17111. infoStr := string(Iinfos)
  17112. idetinfoStr := string(Idetinfos)
  17113. psn := &models.HisPsn{
  17114. PsnNo: res.Output.Baseinfo.PsnNo,
  17115. PatientId: patient.ID,
  17116. Certno: res.Output.Baseinfo.Certno,
  17117. Gend: res.Output.Baseinfo.Gend,
  17118. Naty: res.Output.Baseinfo.Naty,
  17119. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17120. PsnName: res.Output.Baseinfo.PsnName,
  17121. Idetinfo: idetinfoStr,
  17122. Insuinfo: infoStr,
  17123. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17124. CardInfo: outPutInfo,
  17125. VerifyNumber: token,
  17126. InsuplcAdmdvs: ele.Data.InsuOrg,
  17127. }
  17128. service.CreateHisPsn(psn)
  17129. var rf []*ResultFive
  17130. json.Unmarshal([]byte(infoStr), &rf)
  17131. var insutypes []*ResultFive
  17132. var insutype string
  17133. var is390 int = 0
  17134. var is310 int = 0
  17135. for _, item := range rf {
  17136. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17137. insutypes = append(insutypes, item)
  17138. }
  17139. }
  17140. if len(insutypes) == 1 {
  17141. insutype = insutypes[0].Insutype
  17142. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17143. } else {
  17144. for _, i := range insutypes {
  17145. if i.Insutype == "390" {
  17146. is390 = 1
  17147. }
  17148. if i.Insutype == "310" {
  17149. is310 = 1
  17150. }
  17151. }
  17152. }
  17153. if is390 == 1 {
  17154. insutype = "390"
  17155. }
  17156. if is310 == 1 {
  17157. insutype = "310"
  17158. }
  17159. if len(insutypes) == 0 {
  17160. insutype = "310"
  17161. }
  17162. c.ServeSuccessJSON(map[string]interface{}{
  17163. "patient": patient,
  17164. "number": token,
  17165. "insutype": insutype,
  17166. })
  17167. }
  17168. } else {
  17169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17170. return
  17171. }
  17172. }
  17173. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17174. var api string
  17175. 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 +
  17176. "&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
  17177. resp, requestErr := http.Get(api)
  17178. if requestErr != nil {
  17179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17180. return
  17181. }
  17182. body, ioErr := ioutil.ReadAll(resp.Body)
  17183. if ioErr != nil {
  17184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17186. return
  17187. }
  17188. var respJSON map[string]interface{}
  17189. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17192. return
  17193. }
  17194. var status string
  17195. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17196. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17197. var token string
  17198. var res ResultTwo //1101结果
  17199. var res10265 ResultTwo10265 //1101结果
  17200. if status == "0" { //读卡成功
  17201. var card_info string //卡信息
  17202. var busi_card_info string
  17203. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17204. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17205. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17206. fmt.Println(card_info)
  17207. fmt.Println(busi_card_info)
  17208. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17209. result, _ := json.Marshal(respJSON)
  17210. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17211. utils.ErrorLog("解析失败:%v", err)
  17212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17213. return
  17214. }
  17215. res.ErrMsg = res10265.ErrMsg
  17216. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17217. res.Infcode = infocode
  17218. res.Output = res10265.Output
  17219. res.InfRefmsgid = res10265.InfRefmsgid
  17220. if res.Infcode == 0 {
  17221. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17222. if err == gorm.ErrRecordNotFound {
  17223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17224. return
  17225. } else if err != nil {
  17226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17227. return
  17228. } else {
  17229. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17230. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17231. infoStr := string(Iinfos)
  17232. idetinfoStr := string(Idetinfos)
  17233. psn := &models.HisPsn{
  17234. PsnNo: res.Output.Baseinfo.PsnNo,
  17235. PatientId: patient.ID,
  17236. Certno: res.Output.Baseinfo.Certno,
  17237. Gend: res.Output.Baseinfo.Gend,
  17238. Naty: res.Output.Baseinfo.Naty,
  17239. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17240. PsnName: res.Output.Baseinfo.PsnName,
  17241. Idetinfo: idetinfoStr,
  17242. Insuinfo: infoStr,
  17243. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17244. CardInfo: card_info,
  17245. VerifyNumber: token,
  17246. }
  17247. var rf []*ResultFive
  17248. json.Unmarshal([]byte(infoStr), &rf)
  17249. var insutypes []*ResultFive
  17250. var insutype string
  17251. var is390 int = 0
  17252. var is310 int = 0
  17253. for _, item := range rf {
  17254. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17255. insutypes = append(insutypes, item)
  17256. }
  17257. }
  17258. if len(insutypes) == 1 {
  17259. insutype = insutypes[0].Insutype
  17260. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17261. } else {
  17262. for _, i := range insutypes {
  17263. if i.Insutype == "390" {
  17264. is390 = 1
  17265. }
  17266. if i.Insutype == "310" {
  17267. is310 = 1
  17268. }
  17269. }
  17270. }
  17271. if is390 == 1 {
  17272. insutype = "390"
  17273. }
  17274. if is310 == 1 {
  17275. insutype = "310"
  17276. }
  17277. if len(insutypes) == 0 {
  17278. insutype = "310"
  17279. }
  17280. service.CreateHisPsn(psn)
  17281. c.ServeSuccessJSON(map[string]interface{}{
  17282. "patient": patient,
  17283. "number": token,
  17284. "insutype": insutype,
  17285. })
  17286. }
  17287. } else {
  17288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17289. return
  17290. }
  17291. } else { //读卡失败
  17292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17293. return
  17294. }
  17295. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17296. res := c.GetoleInfo()
  17297. if res.Infcode == 0 {
  17298. var result string
  17299. if res.Output.MdtrtCertType == "01" {
  17300. 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)
  17301. } else if res.Output.MdtrtCertType == "02" {
  17302. 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)
  17303. } else if res.Output.MdtrtCertType == "03" {
  17304. 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)
  17305. }
  17306. var dat map[string]interface{}
  17307. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17308. fmt.Println(dat)
  17309. } else {
  17310. fmt.Println(err)
  17311. }
  17312. userJSONBytes, _ := json.Marshal(dat)
  17313. var res2 ResultTwo
  17314. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17315. utils.ErrorLog("解析失败:%v", err)
  17316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17317. return
  17318. }
  17319. if res2.Infcode == 0 {
  17320. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  17321. if err == gorm.ErrRecordNotFound {
  17322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17323. return
  17324. } else if err != nil {
  17325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17326. return
  17327. } else {
  17328. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  17329. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  17330. infoStr := string(Iinfos)
  17331. idetinfoStr := string(Idetinfos)
  17332. var rf []*ResultFive
  17333. json.Unmarshal([]byte(infoStr), &rf)
  17334. var insutypes []*ResultFive
  17335. var insutype string
  17336. var is390 int = 0
  17337. var is310 int = 0
  17338. //var insuplc_admdvs string
  17339. for _, item := range rf {
  17340. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17341. insutypes = append(insutypes, item)
  17342. }
  17343. }
  17344. if len(insutypes) == 1 {
  17345. insutype = insutypes[0].Insutype
  17346. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17347. } else {
  17348. for _, i := range insutypes {
  17349. if i.Insutype == "390" {
  17350. is390 = 1
  17351. }
  17352. if i.Insutype == "310" {
  17353. is310 = 1
  17354. }
  17355. }
  17356. }
  17357. if is390 == 1 {
  17358. insutype = "390"
  17359. }
  17360. if is310 == 1 {
  17361. insutype = "310"
  17362. }
  17363. if len(insutypes) == 0 {
  17364. insutype = "310"
  17365. }
  17366. psn := &models.HisPsn{
  17367. PsnNo: res2.Output.Baseinfo.PsnNo,
  17368. PatientId: patient.ID,
  17369. Certno: res2.Output.Baseinfo.Certno,
  17370. Gend: res2.Output.Baseinfo.Gend,
  17371. Naty: res2.Output.Baseinfo.Naty,
  17372. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  17373. PsnName: res2.Output.Baseinfo.PsnName,
  17374. Idetinfo: idetinfoStr,
  17375. Insuinfo: infoStr,
  17376. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17377. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  17378. VerifyNumber: res.Output.EcToken,
  17379. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  17380. }
  17381. if res.Output.MdtrtCertType == "01" {
  17382. psn.VerifyNumber = res.Output.EcToken
  17383. //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)
  17384. } else if res.Output.MdtrtCertType == "02" {
  17385. psn.VerifyNumber = res.Output.CardNo
  17386. //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)
  17387. } else if res.Output.MdtrtCertType == "03" {
  17388. psn.VerifyNumber = res.Output.MdtrtCertNo
  17389. //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)
  17390. }
  17391. service.CreateHisPsn(psn)
  17392. var balc float64
  17393. for _, item := range rf {
  17394. if item.Insutype == insutype {
  17395. balc = item.Balc
  17396. }
  17397. }
  17398. c.ServeSuccessJSON(map[string]interface{}{
  17399. "patient": patient,
  17400. "number": res.Output.CardNo,
  17401. "insutype": insutype,
  17402. "blac": balc,
  17403. "desc": idetinfoStr,
  17404. })
  17405. }
  17406. } else {
  17407. c.ServeSuccessJSON(map[string]interface{}{
  17408. "failed_code": -10,
  17409. "msg": res2.ErrMsg,
  17410. })
  17411. }
  17412. } else {
  17413. c.ServeSuccessJSON(map[string]interface{}{
  17414. "failed_code": -10,
  17415. "msg": res.ErrMsg,
  17416. })
  17417. }
  17418. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17419. var res ResultTwo
  17420. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  17421. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17422. "&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)
  17423. resp, requestErr := http.Get(api)
  17424. if requestErr != nil {
  17425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17426. return
  17427. }
  17428. body, ioErr := ioutil.ReadAll(resp.Body)
  17429. if ioErr != nil {
  17430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17432. return
  17433. }
  17434. var respJSON map[string]interface{}
  17435. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17438. return
  17439. }
  17440. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17441. result, _ := json.Marshal(respJSON)
  17442. fmt.Println("log")
  17443. fmt.Println(string(result))
  17444. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17445. utils.ErrorLog("解析失败:%v", err)
  17446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17447. return
  17448. }
  17449. if res.Infcode == 0 {
  17450. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17451. if err == gorm.ErrRecordNotFound {
  17452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17453. return
  17454. } else if err != nil {
  17455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17456. return
  17457. } else {
  17458. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17459. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17460. infoStr := string(Iinfos)
  17461. idetinfoStr := string(Idetinfos)
  17462. var rf []*ResultFive
  17463. json.Unmarshal([]byte(infoStr), &rf)
  17464. var insutypes []*ResultFive
  17465. var insutype string
  17466. var is390 int = 0
  17467. var is310 int = 0
  17468. for _, item := range rf {
  17469. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17470. insutypes = append(insutypes, item)
  17471. }
  17472. }
  17473. if len(insutypes) == 1 {
  17474. insutype = insutypes[0].Insutype
  17475. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17476. } else {
  17477. for _, i := range insutypes {
  17478. if i.Insutype == "390" {
  17479. is390 = 1
  17480. }
  17481. if i.Insutype == "310" {
  17482. is310 = 1
  17483. }
  17484. }
  17485. }
  17486. if is390 == 1 {
  17487. insutype = "390"
  17488. }
  17489. if is310 == 1 {
  17490. insutype = "310"
  17491. }
  17492. if len(insutypes) == 0 {
  17493. insutype = "390"
  17494. }
  17495. var insuplc_admdvs string
  17496. for _, item := range rf {
  17497. if item.Insutype == insutype {
  17498. insuplc_admdvs = item.InsuplcAdmdvs
  17499. }
  17500. }
  17501. psn := &models.HisPsn{
  17502. PsnNo: res.Output.Baseinfo.PsnNo,
  17503. PatientId: patient.ID,
  17504. Certno: res.Output.Baseinfo.Certno,
  17505. Gend: res.Output.Baseinfo.Gend,
  17506. Naty: res.Output.Baseinfo.Naty,
  17507. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17508. PsnName: res.Output.Baseinfo.PsnName,
  17509. Idetinfo: idetinfoStr,
  17510. Insuinfo: infoStr,
  17511. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17512. InsuplcAdmdvs: insuplc_admdvs,
  17513. }
  17514. service.CreateHisPsn(psn)
  17515. c.ServeSuccessJSON(map[string]interface{}{
  17516. "patient": patient,
  17517. "number": res.Output.Baseinfo.Certno,
  17518. })
  17519. }
  17520. } else {
  17521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17522. return
  17523. }
  17524. } else {
  17525. type ELeData struct {
  17526. Code string `json:"code"`
  17527. Data struct {
  17528. Aac002 string `json:"aac002"`
  17529. Aaz500 string `json:"aaz500"`
  17530. ActCardNo string `json:"actCardNo"`
  17531. Bab520 string `json:"bab520"`
  17532. Bkz543 string `json:"bkz543"`
  17533. BusinessType string `json:"businessType"`
  17534. CertfCodg string `json:"certfCodg"`
  17535. EcIndexNo string `json:"ecIndexNo"`
  17536. EcToken string `json:"ecToken"`
  17537. ID0000 string `json:"id0000"`
  17538. IDNo string `json:"idNo"`
  17539. IDType string `json:"idType"`
  17540. Idcode string `json:"idcode"`
  17541. IdentityToken string `json:"identity_token"`
  17542. InsuOrg string `json:"insuOrg"`
  17543. OfficeID string `json:"officeId"`
  17544. OfficeName string `json:"officeName"`
  17545. OperatorID string `json:"operatorId"`
  17546. OperatorName string `json:"operatorName"`
  17547. OrgID string `json:"orgId"`
  17548. UserName string `json:"userName"`
  17549. } `json:"data"`
  17550. Infno interface{} `json:"infno"`
  17551. Message string `json:"message"`
  17552. OrgID string `json:"orgId"`
  17553. TransType string `json:"transType"`
  17554. }
  17555. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17556. fmt.Println(result)
  17557. outPutInfo := Remove0000(result)
  17558. fmt.Println(outPutInfo)
  17559. if len(outPutInfo) > 0 {
  17560. var ele ELeData
  17561. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17562. if err != nil {
  17563. utils.ErrorLog("解析失败:%v", err)
  17564. }
  17565. token := ele.Data.EcToken
  17566. fmt.Println(outPutInfo)
  17567. 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)
  17568. saveLog(result, requestLog, "1101", "获取人员信息")
  17569. var dat map[string]interface{}
  17570. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17571. fmt.Println(dat)
  17572. } else {
  17573. fmt.Println(err)
  17574. }
  17575. userJSONBytes, _ := json.Marshal(dat)
  17576. var res ResultTwo
  17577. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17578. utils.ErrorLog("解析失败:%v", err)
  17579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17580. return
  17581. }
  17582. if res.Infcode == 0 {
  17583. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17584. if err == gorm.ErrRecordNotFound {
  17585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17586. return
  17587. } else if err != nil {
  17588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17589. return
  17590. } else {
  17591. fmt.Println(res)
  17592. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17593. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17594. infoStr := string(Iinfos)
  17595. idetinfoStr := string(Idetinfos)
  17596. psn := &models.HisPsn{
  17597. PsnNo: res.Output.Baseinfo.PsnNo,
  17598. PatientId: patient.ID,
  17599. Certno: res.Output.Baseinfo.Certno,
  17600. Gend: res.Output.Baseinfo.Gend,
  17601. Naty: res.Output.Baseinfo.Naty,
  17602. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17603. PsnName: res.Output.Baseinfo.PsnName,
  17604. Idetinfo: idetinfoStr,
  17605. Insuinfo: infoStr,
  17606. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17607. CardInfo: outPutInfo,
  17608. VerifyNumber: token,
  17609. InsuplcAdmdvs: ele.Data.InsuOrg,
  17610. }
  17611. service.CreateHisPsn(psn)
  17612. var rf []*ResultFive
  17613. json.Unmarshal([]byte(infoStr), &rf)
  17614. var insutypes []*ResultFive
  17615. var insutype string
  17616. var is390 int = 0
  17617. var is310 int = 0
  17618. for _, item := range rf {
  17619. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17620. insutypes = append(insutypes, item)
  17621. }
  17622. }
  17623. if len(insutypes) == 1 {
  17624. insutype = insutypes[0].Insutype
  17625. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17626. } else {
  17627. for _, i := range insutypes {
  17628. if i.Insutype == "390" {
  17629. is390 = 1
  17630. }
  17631. if i.Insutype == "310" {
  17632. is310 = 1
  17633. }
  17634. }
  17635. }
  17636. if is390 == 1 {
  17637. insutype = "390"
  17638. }
  17639. if is310 == 1 {
  17640. insutype = "310"
  17641. }
  17642. if len(insutypes) == 0 {
  17643. insutype = "310"
  17644. }
  17645. c.ServeSuccessJSON(map[string]interface{}{
  17646. "patient": patient,
  17647. "number": token,
  17648. "insutype": insutype,
  17649. })
  17650. }
  17651. } else {
  17652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17653. return
  17654. }
  17655. }
  17656. //fmt.Println(result)
  17657. //
  17658. //if initFlag == 0 {
  17659. // c.TestGetBasBaseInit()
  17660. //}
  17661. //token := c.GetEleBaseInfo()
  17662. //
  17663. //token = Remove0000(token)
  17664. //
  17665. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17666. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17667. ////
  17668. //var res ResultTwo
  17669. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17670. // utils.ErrorLog("解析失败:%v", err)
  17671. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17672. // return
  17673. //}
  17674. //
  17675. //if res.Infcode == 0 {
  17676. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17677. // if err == gorm.ErrRecordNotFound {
  17678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17679. // return
  17680. // } else if err != nil {
  17681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17682. // return
  17683. //
  17684. // } else {
  17685. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17686. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17687. // infoStr := string(Iinfos)
  17688. // idetinfoStr := string(Idetinfos)
  17689. //
  17690. //
  17691. //
  17692. //
  17693. // var rf []*ResultFive
  17694. // json.Unmarshal([]byte(infoStr), &rf)
  17695. //
  17696. // var insutypes []*ResultFive
  17697. // var insutype string
  17698. // var is390 int = 0
  17699. // var is310 int = 0
  17700. // var insuplc_admdvs string
  17701. //
  17702. // for _, item := range rf {
  17703. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17704. // insutypes = append(insutypes, item)
  17705. // }
  17706. // }
  17707. //
  17708. // if len(insutypes) == 1 {
  17709. // insutype = insutypes[0].Insutype
  17710. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17711. // } else {
  17712. // for _, i := range insutypes {
  17713. // if i.Insutype == "390" {
  17714. // is390 = 1
  17715. // }
  17716. //
  17717. // if i.Insutype == "310" {
  17718. // is310 = 1
  17719. // }
  17720. // }
  17721. // }
  17722. // if is390 == 1 {
  17723. // insutype = "390"
  17724. // }
  17725. //
  17726. // if is310 == 1 {
  17727. // insutype = "310"
  17728. // }
  17729. // if len(insutypes) == 0 {
  17730. // insutype = "310"
  17731. // }
  17732. // for _, item := range rf {
  17733. // if item.Insutype == insutype {
  17734. // insuplc_admdvs = item.InsuplcAdmdvs
  17735. // }
  17736. // }
  17737. // psn := &models.HisPsn{
  17738. // PsnNo: res.Output.Baseinfo.PsnNo,
  17739. // Age: res.Output.Baseinfo.Age,
  17740. // PatientId: patient.ID,
  17741. // Certno: res.Output.Baseinfo.Certno,
  17742. // Brdy: res.Output.Baseinfo.Brdy,
  17743. // Gend: res.Output.Baseinfo.Gend,
  17744. // Naty: res.Output.Baseinfo.Naty,
  17745. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17746. // PsnName: res.Output.Baseinfo.PsnName,
  17747. // Idetinfo: idetinfoStr,
  17748. // Insuinfo: infoStr,
  17749. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17750. // CardInfo: "",
  17751. // VerifyNumber: token,
  17752. // InsuplcAdmdvs: insuplc_admdvs,
  17753. // }
  17754. // service.CreateHisPsn(psn)
  17755. //
  17756. // c.ServeSuccessJSON(map[string]interface{}{
  17757. // "patient": patient,
  17758. // "number": token,
  17759. // })
  17760. // }
  17761. //} else {
  17762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17763. // return
  17764. //}
  17765. }
  17766. break
  17767. case 5:
  17768. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17769. var api string
  17770. if miConfig.MdtrtareaAdmvs == "320921" {
  17771. 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 +
  17772. "&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
  17773. fmt.Println(api)
  17774. } else {
  17775. 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 +
  17776. "&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)
  17777. }
  17778. resp, requestErr := http.Get(api)
  17779. if requestErr != nil {
  17780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17781. return
  17782. }
  17783. body, ioErr := ioutil.ReadAll(resp.Body)
  17784. if ioErr != nil {
  17785. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17787. return
  17788. }
  17789. var respJSON map[string]interface{}
  17790. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17793. return
  17794. }
  17795. var status string
  17796. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17797. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17798. var token string
  17799. var res ResultTwo //1101结果
  17800. var res10265 ResultTwo10265 //1101结果
  17801. if status == "0" { //读卡成功
  17802. var card_info string //卡信息
  17803. //var busi_card_info string
  17804. var auth_info string
  17805. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17806. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17807. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17808. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17809. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17810. result, _ := json.Marshal(respJSON)
  17811. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17812. utils.ErrorLog("解析失败:%v", err)
  17813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17814. return
  17815. }
  17816. res.ErrMsg = res10265.ErrMsg
  17817. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17818. res.Infcode = infocode
  17819. res.Output = res10265.Output
  17820. res.InfRefmsgid = res10265.InfRefmsgid
  17821. if res.Infcode == 0 {
  17822. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17823. if err == gorm.ErrRecordNotFound {
  17824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17825. return
  17826. } else if err != nil {
  17827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17828. return
  17829. } else {
  17830. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17831. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17832. infoStr := string(Iinfos)
  17833. idetinfoStr := string(Idetinfos)
  17834. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  17835. psn := &models.HisPsn{
  17836. PsnNo: res.Output.Baseinfo.PsnNo,
  17837. PatientId: patient.ID,
  17838. Certno: res.Output.Baseinfo.Certno,
  17839. Gend: res.Output.Baseinfo.Gend,
  17840. Brdy: b,
  17841. Age: float64(age),
  17842. Naty: res.Output.Baseinfo.Naty,
  17843. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17844. PsnName: res.Output.Baseinfo.PsnName,
  17845. Idetinfo: idetinfoStr,
  17846. Insuinfo: infoStr,
  17847. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17848. CardInfo: card_info,
  17849. VerifyNumber: token,
  17850. AuthInfo: auth_info,
  17851. }
  17852. var rf []*ResultFive
  17853. json.Unmarshal([]byte(infoStr), &rf)
  17854. var insutypes []*ResultFive
  17855. var insutype string
  17856. var is390 int = 0
  17857. var is310 int = 0
  17858. for _, item := range rf {
  17859. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17860. insutypes = append(insutypes, item)
  17861. }
  17862. }
  17863. if len(insutypes) == 1 {
  17864. insutype = insutypes[0].Insutype
  17865. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17866. } else {
  17867. for _, i := range insutypes {
  17868. if i.Insutype == "390" {
  17869. is390 = 1
  17870. }
  17871. if i.Insutype == "310" {
  17872. is310 = 1
  17873. }
  17874. }
  17875. }
  17876. if is390 == 1 {
  17877. insutype = "390"
  17878. }
  17879. if is310 == 1 {
  17880. insutype = "310"
  17881. }
  17882. if len(insutypes) == 0 {
  17883. insutype = "310"
  17884. }
  17885. service.CreateHisPsn(psn)
  17886. c.ServeSuccessJSON(map[string]interface{}{
  17887. "patient": patient,
  17888. "number": token,
  17889. "insutype": insutype,
  17890. })
  17891. }
  17892. } else {
  17893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17894. return
  17895. }
  17896. } else { //读卡失败
  17897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17898. return
  17899. }
  17900. }
  17901. break
  17902. }
  17903. }
  17904. var initFlag int64 = 0
  17905. var initEleFlag int64 = 0
  17906. func (c *HisApiController) TestGetBasBaseInit() {
  17907. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17908. Iinit := DllDef.MustFindProc("Init")
  17909. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17910. url := ""
  17911. if miConfig.InsuplcAdmdvs[:4] == "4403" {
  17912. url = "http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"
  17913. } else if miConfig.InsuplcAdmdvs[:4] == "4401" {
  17914. url = ""
  17915. } else {
  17916. url = "http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"
  17917. }
  17918. fmt.Println("SSCard的报错原因:", url)
  17919. fmt.Println("SSCard的报错原因:", miConfig.InsuplcAdmdvs)
  17920. ret, _, err := Iinit.Call(StrPtr(url), StrPtr(miConfig.InsuplcAdmdvs))
  17921. if ret != 0 {
  17922. fmt.Println("SSCard的报错原因:", err)
  17923. fmt.Println("SSCard的运算结果为:", ret)
  17924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17925. return
  17926. }
  17927. result := int(ret)
  17928. fmt.Println("SSCard的运算结果为1:", result)
  17929. initFlag = 1
  17930. return
  17931. }
  17932. func (c *HisApiController) HandleJiangXiReadCard() {
  17933. fmt.Println("~~~~~~")
  17934. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17935. admin_user_id, _ := c.GetInt64("admin_user_id")
  17936. id_card_type, _ := c.GetInt64("id_card_type")
  17937. //certificates, _ := c.GetInt64("certificates")
  17938. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17939. if initFlag == 0 {
  17940. c.TestGetJiangXiBasBaseInit()
  17941. }
  17942. basStr := c.GetBasBaseInfo()
  17943. if len(basStr) == 0 {
  17944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17945. return
  17946. }
  17947. fmt.Println(basStr)
  17948. bas := strings.Split(basStr, "|")
  17949. basNumber := bas[1]
  17950. fmt.Println(basNumber)
  17951. card_sn := bas[3]
  17952. fmt.Println(card_sn)
  17953. 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, "")
  17954. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  17955. var dat map[string]interface{}
  17956. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17957. fmt.Println(dat)
  17958. } else {
  17959. fmt.Println(err)
  17960. }
  17961. userJSONBytes, _ := json.Marshal(dat)
  17962. var res ResultTwo
  17963. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17964. utils.ErrorLog("解析失败:%v", err)
  17965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17966. return
  17967. }
  17968. if res.Infcode == 0 {
  17969. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  17970. if err == gorm.ErrRecordNotFound {
  17971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17972. return
  17973. } else if err != nil {
  17974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17975. return
  17976. } else {
  17977. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17978. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17979. infoStr := string(Iinfos)
  17980. idetinfoStr := string(Idetinfos)
  17981. psn := &models.HisPsn{
  17982. PsnNo: res.Output.Baseinfo.PsnNo,
  17983. PatientId: patient.ID,
  17984. Certno: res.Output.Baseinfo.Certno,
  17985. Gend: res.Output.Baseinfo.Gend,
  17986. Naty: res.Output.Baseinfo.Naty,
  17987. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17988. PsnName: res.Output.Baseinfo.PsnName,
  17989. Idetinfo: idetinfoStr,
  17990. Insuinfo: infoStr,
  17991. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17992. CardInfo: basStr,
  17993. VerifyNumber: "",
  17994. }
  17995. service.CreateHisPsn(psn)
  17996. c.ServeSuccessJSON(map[string]interface{}{
  17997. "patient": patient,
  17998. "number": basNumber,
  17999. })
  18000. }
  18001. } else {
  18002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18003. return
  18004. }
  18005. }
  18006. func (c *HisApiController) TestGetHnBasBaseInit() {
  18007. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18008. Iinit := DllDef.MustFindProc("Init")
  18009. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18010. //http://10.77.211.236/CSB/hsa-fsi-1303
  18011. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  18012. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  18013. // 调用 Init 函数
  18014. 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"))))
  18015. //if ret != 0 {
  18016. fmt.Println("SSCard的报错原因:", err)
  18017. fmt.Println("SSCard的运算结果为:", ret)
  18018. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18019. // return
  18020. //}
  18021. result := int(ret)
  18022. fmt.Println("SSCard的运算结果为1:", result)
  18023. initFlag = 1
  18024. return
  18025. }
  18026. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  18027. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18028. Iinit := DllDef.MustFindProc("Init")
  18029. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18030. //http://10.77.211.236/CSB/hsa-fsi-1303
  18031. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  18032. if ret != 0 {
  18033. fmt.Println("SSCard的报错原因:", err)
  18034. fmt.Println("SSCard的运算结果为:", ret)
  18035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18036. return
  18037. }
  18038. result := int(ret)
  18039. fmt.Println("SSCard的运算结果为1:", result)
  18040. initFlag = 1
  18041. return
  18042. }
  18043. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  18044. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18045. Iinit := DllDef.MustFindProc("Init")
  18046. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18047. //http://10.77.211.236/CSB/hsa-fsi-1303
  18048. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  18049. if ret != 0 {
  18050. fmt.Println("SSCard的报错原因:", err)
  18051. fmt.Println("SSCard的运算结果为:", ret)
  18052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18053. return
  18054. }
  18055. result := int(ret)
  18056. fmt.Println("SSCard的运算结果为1:", result)
  18057. initFlag = 1
  18058. return
  18059. }
  18060. func (c *HisApiController) GetSFZBaseInfo() string {
  18061. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18062. readCard := DllDef.MustFindProc("ReadSFZ")
  18063. if readCard == nil {
  18064. fmt.Println("readcard is nil")
  18065. readCard = DllDef.MustFindProc("ReadSFZ")
  18066. }
  18067. str := make([]byte, 8096)
  18068. str1 := make([]byte, 8096)
  18069. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  18070. fmt.Println(r)
  18071. return Remove0000(string(str))
  18072. }
  18073. func (c *HisApiController) GetEleBaseInfo() string {
  18074. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18075. readCard := DllDef.MustFindProc("GetQRBase")
  18076. fmt.Println(readCard)
  18077. if readCard == nil {
  18078. fmt.Println("readcard is nil")
  18079. readCard = DllDef.MustFindProc("GetQRBase")
  18080. }
  18081. str := make([]byte, 1024)
  18082. str1 := make([]byte, 1024)
  18083. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18084. fmt.Println(ret2)
  18085. fmt.Println(string(str1))
  18086. fmt.Println(string(str))
  18087. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18088. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18089. if ret2 != 0 {
  18090. return ""
  18091. }
  18092. return string(str)
  18093. }
  18094. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18095. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18096. readCard := DllDef.MustFindProc("NationEcTrans")
  18097. fmt.Println(readCard)
  18098. fmt.Println("!!!!!")
  18099. pBusiCardInfo := make([]byte, 2048)
  18100. input := make(map[string]interface{})
  18101. inputData := make(map[string]interface{})
  18102. inputData["orgId"] = code
  18103. inputData["businessType"] = "01101"
  18104. inputData["operatorId"] = "1"
  18105. inputData["operatorName"] = "admin"
  18106. inputData["officeId"] = "001"
  18107. inputData["officeName"] = "血透室"
  18108. inputData["deviceType"] = ""
  18109. input["data"] = inputData
  18110. input["orgId"] = code
  18111. input["transType"] = "ec.query"
  18112. bytesData, _ := json.Marshal(input)
  18113. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18114. fmt.Println(ret2)
  18115. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18116. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18117. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  18118. }
  18119. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18120. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18121. readCard := DllDef.MustFindProc("NationEcTrans")
  18122. fmt.Println(readCard)
  18123. fmt.Println("!!!!!")
  18124. pBusiCardInfo := make([]byte, 2048)
  18125. input := make(map[string]interface{})
  18126. inputData := make(map[string]interface{})
  18127. inputData["orgId"] = code
  18128. inputData["businessType"] = "01101"
  18129. inputData["operatorId"] = "9"
  18130. inputData["operatorName"] = "admin"
  18131. inputData["officeId"] = "001"
  18132. inputData["officeName"] = "血透室"
  18133. inputData["deviceType"] = ""
  18134. input["data"] = inputData
  18135. input["orgId"] = code
  18136. input["transType"] = "ec.query"
  18137. bytesData, _ := json.Marshal(input)
  18138. 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])))
  18139. fmt.Println(ret2)
  18140. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18141. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18142. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18143. }
  18144. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  18145. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18146. readCard := DllDef.MustFindProc("NationEcTrans")
  18147. fmt.Println(readCard)
  18148. fmt.Println("!!!!!")
  18149. pBusiCardInfo := make([]byte, 2048)
  18150. input := make(map[string]interface{})
  18151. inputData := make(map[string]interface{})
  18152. inputData["orgId"] = code
  18153. inputData["businessType"] = "01301"
  18154. inputData["operatorId"] = "9"
  18155. inputData["operatorName"] = "admin"
  18156. inputData["officeId"] = "001"
  18157. inputData["officeName"] = "血透室"
  18158. inputData["deviceType"] = ""
  18159. input["data"] = inputData
  18160. input["orgId"] = code
  18161. input["transType"] = "ec.query"
  18162. bytesData, _ := json.Marshal(input)
  18163. 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])))
  18164. fmt.Println(ret2)
  18165. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18166. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18167. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18168. }
  18169. func GetJxEleBaseInfo(org_id int64) string {
  18170. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18171. readCard := DllDef.MustFindProc("NationEcTrans")
  18172. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18173. if readCard == nil {
  18174. fmt.Println("readcard is nil")
  18175. readCard = DllDef.MustFindProc("NationEcTrans")
  18176. }
  18177. str1 := make([]byte, 1024)
  18178. data := make(map[string]interface{})
  18179. inputData := make(map[string]interface{})
  18180. inputData["orgId"] = miConfig.Code
  18181. inputData["businessType"] = "01101"
  18182. inputData["operatorId"] = "test001"
  18183. inputData["operatorName"] = "cn"
  18184. inputData["officeId"] = "32760"
  18185. inputData["officeName"] = "waike"
  18186. inputData["deviceType"] = ""
  18187. data["data"] = inputData
  18188. data["transType"] = "ec.query"
  18189. data["extra "] = ""
  18190. data["orgId"] = miConfig.Code
  18191. bytesData, _ := json.Marshal(data)
  18192. //bytesData, _ := json.Marshal(data)
  18193. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18194. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18195. fmt.Println(ret2)
  18196. fmt.Println(string(str1))
  18197. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18198. if ret2 != 0 {
  18199. return ""
  18200. }
  18201. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18202. }
  18203. //func GetJxEleBaseInfoTWO(org_id int64) string {
  18204. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  18205. // readCard := DllDef.MustFindProc("NationEcTrans")
  18206. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18207. //
  18208. // if readCard == nil {
  18209. // fmt.Println("readcard is nil")
  18210. // readCard = DllDef.MustFindProc("NationEcTrans")
  18211. // }
  18212. // str1 := make([]byte, 1024)
  18213. //
  18214. // data := make(map[string]interface{})
  18215. //
  18216. // inputData := make(map[string]interface{})
  18217. // inputData["orgId"] = miConfig.Code
  18218. // inputData["businessType"] = "01101"
  18219. // inputData["operatorId"] = "test001"
  18220. // inputData["operatorName"] = "cn"
  18221. // inputData["officeId"] = "32760"
  18222. // inputData["officeName"] = "waike"
  18223. // inputData["deviceType"] = ""
  18224. //
  18225. // data["data"] = inputData
  18226. // data["transType"] = "ec.query"
  18227. // data["extra "] = ""
  18228. // data["orgId"] = miConfig.Code
  18229. // bytesData, _ := json.Marshal(data)
  18230. // //bytesData, _ := json.Marshal(data)
  18231. //
  18232. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18233. //
  18234. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18235. // fmt.Println(ret2)
  18236. // fmt.Println(string(str1))
  18237. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18238. //
  18239. // if ret2 != 0 {
  18240. // return ""
  18241. // }
  18242. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18243. //}
  18244. func GetJxEleBaseInitInfo(org_id int64) string {
  18245. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18246. readCard := DllDef.MustFindProc("NationEcTrans")
  18247. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18248. if readCard == nil {
  18249. fmt.Println("readcard is nil")
  18250. readCard = DllDef.MustFindProc("NationEcTrans")
  18251. }
  18252. str1 := make([]byte, 2048)
  18253. data := make(map[string]interface{})
  18254. inputData := make(map[string]interface{})
  18255. inputData["orgId"] = miConfig.Code
  18256. inputData["businessType"] = "01101"
  18257. inputData["operatorId"] = "1"
  18258. inputData["operatorName"] = "huangchuang"
  18259. inputData["officeId"] = "101"
  18260. inputData["officeName"] = "xuetou"
  18261. inputData["deviceType"] = ""
  18262. data["data"] = inputData
  18263. data["transType"] = "ec.query"
  18264. data["orgId"] = miConfig.Code
  18265. bytesData, _ := json.Marshal(data)
  18266. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18267. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18268. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  18269. fmt.Println(ret2)
  18270. fmt.Println(string(str1))
  18271. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18272. if ret2 != 0 {
  18273. return ""
  18274. }
  18275. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  18276. initEleFlag = 1
  18277. }
  18278. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18279. }
  18280. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  18281. // // 构建命令
  18282. // cmd := exec.Command("python", "b.py")
  18283. //
  18284. // // 执行命令并等待完成
  18285. // output, err := cmd.CombinedOutput()
  18286. // if err != nil {
  18287. // fmt.Println("Error executing Python script:", err)
  18288. // return
  18289. // }
  18290. //
  18291. // // 打印Python脚本的输出
  18292. // fmt.Println(string(output))
  18293. //}
  18294. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  18295. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  18296. readCard := DllDef.MustFindProc("gxyb_call")
  18297. if readCard == nil {
  18298. fmt.Println("readcard is nil")
  18299. readCard = DllDef.MustFindProc("gxyb_call")
  18300. }
  18301. str := make([]byte, 1024)
  18302. str1 := make([]byte, 1024)
  18303. //data := make(map[string]interface{})
  18304. currentTime := time.Now()
  18305. // 格式化时间为 "YYYYMMDDHH24MISS"
  18306. formattedTime := currentTime.Format("20060102150405")
  18307. inputData := make(map[string]interface{})
  18308. inputData2 := make(map[string]interface{})
  18309. inputData["transNo"] = "1401"
  18310. inputData["transType"] = "passwordCheck"
  18311. inputData["timestamp"] = formattedTime
  18312. inputData2["fixmedinsCode"] = code
  18313. inputData2["psnNo"] = ""
  18314. inputData["data"] = inputData2
  18315. jsonBytes, err := json.Marshal(inputData)
  18316. if err != nil {
  18317. fmt.Println("Error encoding map to JSON:", err)
  18318. }
  18319. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18320. fmt.Println(string(str1))
  18321. fmt.Println(string(str))
  18322. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18323. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18324. if ret2 != 0 {
  18325. return ""
  18326. }
  18327. return string(str)
  18328. }
  18329. func (c *HisApiController) GetoleInfo() Response {
  18330. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  18331. defer ole.CoUninitialize()
  18332. // Replace with the ProgID or CLSID of your COM object
  18333. progID := "YinHai.XJ.Actual.Interface.New"
  18334. // Create COM object
  18335. unknown, err := oleutil.CreateObject(progID)
  18336. if err != nil {
  18337. fmt.Println("Unable to create COM object:", err)
  18338. }
  18339. defer unknown.Release()
  18340. // Query for the IDispatch interface
  18341. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  18342. if err != nil {
  18343. fmt.Println("Unable to get IDispatch interface:", err)
  18344. }
  18345. defer dispatch.Release()
  18346. // Prepare parameters
  18347. transNo := "1401"
  18348. transType := "passwordCheck"
  18349. timestamp := time.Now().Unix()
  18350. fixmedinsCode := "H45072101171"
  18351. psnNo := ""
  18352. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  18353. result2 := ""
  18354. // Call COM object's method using the IDispatch interface
  18355. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  18356. fmt.Println(resulr)
  18357. fmt.Println(result2)
  18358. if err != nil {
  18359. fmt.Println("调用COM对象方法失败:", err)
  18360. }
  18361. var response Response
  18362. err2 := json.Unmarshal([]byte(result2), &response)
  18363. if err2 != nil {
  18364. fmt.Println("解析JSON失败:", err)
  18365. }
  18366. return response
  18367. }
  18368. func (c *HisApiController) GetBasBaseInfo() string {
  18369. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18370. readCard := DllDef.MustFindProc("ReadCardBas")
  18371. if readCard == nil {
  18372. fmt.Println("readcard is nil")
  18373. readCard = DllDef.MustFindProc("ReadCardBas")
  18374. }
  18375. str := make([]byte, 1024)
  18376. str1 := make([]byte, 1024)
  18377. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18378. fmt.Println(string(str1))
  18379. fmt.Println(string(str))
  18380. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18381. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18382. if ret2 != 0 {
  18383. return ""
  18384. }
  18385. return string(str)
  18386. }
  18387. type Program struct {
  18388. FunctionID string `xml:"function_id"`
  18389. CardInfo string `xml:"cardinfo"`
  18390. User string `xml:"user"`
  18391. }
  18392. func (c *HisApiController) GetBasBaseInfo1111() string {
  18393. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  18394. readCard := DllDef.MustFindProc("ReadSICardInfo")
  18395. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  18396. if readCard == nil {
  18397. fmt.Println("readcard is nil")
  18398. readCard = DllDef.MustFindProc("ReadSICardInfo")
  18399. }
  18400. if readCard2 == nil {
  18401. fmt.Println("readcard is nil")
  18402. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  18403. }
  18404. str := make([]byte, 1024)
  18405. str1 := make([]byte, 1024)
  18406. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18407. str3 := make([]byte, 1024)
  18408. str4 := make([]byte, 1024)
  18409. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  18410. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18411. //if err != nil {
  18412. // fmt.Println("Error opening file:", err)
  18413. //}
  18414. //defer file.Close()
  18415. //
  18416. //var lastProgram Program
  18417. //scanner := bufio.NewScanner(file)
  18418. //inProgram := false
  18419. //
  18420. //for scanner.Scan() {
  18421. // line := scanner.Text()
  18422. // if strings.Contains(line, "<program>") {
  18423. // inProgram = true
  18424. // programXML := "<program>"
  18425. // for scanner.Scan() {
  18426. // line = scanner.Text()
  18427. // programXML += line
  18428. // if strings.Contains(line, "</program>") {
  18429. // programXML += "</program>"
  18430. // break
  18431. // }
  18432. // }
  18433. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18434. // // 解析成功,更新最后的 Program
  18435. // }
  18436. // inProgram = false
  18437. // }
  18438. //}
  18439. //
  18440. // fmt.Println("Error reading file:", inProgram)
  18441. //
  18442. //if err := scanner.Err(); err != nil {
  18443. // fmt.Println("Error reading file:", err)
  18444. //}
  18445. // 输出最后一次的 Program
  18446. //fmt.Printf("最后一次的 <program>:\n")
  18447. //fmt.Printf("<program>\n")
  18448. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18449. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18450. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18451. //fmt.Printf("</program>\n")
  18452. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18453. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18454. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18455. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18456. return ConvertToString(string(str), "gbk", "utf-8")
  18457. }
  18458. func (c *HisApiController) GetBasBaseInfo22222() string {
  18459. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18460. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18461. if readCard == nil {
  18462. fmt.Println("readcard is nil")
  18463. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18464. }
  18465. str := make([]byte, 1024)
  18466. str1 := make([]byte, 1024)
  18467. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  18468. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18469. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18470. //if err != nil {
  18471. // fmt.Println("Error opening file:", err)
  18472. //}
  18473. //defer file.Close()
  18474. //
  18475. //var lastProgram Program
  18476. //scanner := bufio.NewScanner(file)
  18477. //inProgram := false
  18478. //
  18479. //for scanner.Scan() {
  18480. // line := scanner.Text()
  18481. // if strings.Contains(line, "<program>") {
  18482. // inProgram = true
  18483. // programXML := "<program>"
  18484. // for scanner.Scan() {
  18485. // line = scanner.Text()
  18486. // programXML += line
  18487. // if strings.Contains(line, "</program>") {
  18488. // programXML += "</program>"
  18489. // break
  18490. // }
  18491. // }
  18492. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18493. // // 解析成功,更新最后的 Program
  18494. // }
  18495. // inProgram = false
  18496. // }
  18497. //}
  18498. //
  18499. // fmt.Println("Error reading file:", inProgram)
  18500. //
  18501. //if err := scanner.Err(); err != nil {
  18502. // fmt.Println("Error reading file:", err)
  18503. //}
  18504. // 输出最后一次的 Program
  18505. //fmt.Printf("最后一次的 <program>:\n")
  18506. //fmt.Printf("<program>\n")
  18507. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18508. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18509. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18510. //fmt.Printf("</program>\n")
  18511. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18512. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18513. return ConvertToString(string(str1), "gbk", "utf-8")
  18514. }
  18515. func (c *HisApiController) GetahBasBaseInfo() string {
  18516. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18517. readCard := DllDef.MustFindProc("iReadCardBas")
  18518. if readCard == nil {
  18519. fmt.Println("readcard is nil")
  18520. readCard = DllDef.MustFindProc("iReadCardBas")
  18521. }
  18522. //str := make([]byte, 1024)
  18523. str1 := make([]byte, 1024)
  18524. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18525. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18526. //if err != nil {
  18527. // fmt.Println("Error opening file:", err)
  18528. //}
  18529. //defer file.Close()
  18530. //
  18531. //var lastProgram Program
  18532. //scanner := bufio.NewScanner(file)
  18533. //inProgram := false
  18534. //
  18535. //for scanner.Scan() {
  18536. // line := scanner.Text()
  18537. // if strings.Contains(line, "<program>") {
  18538. // inProgram = true
  18539. // programXML := "<program>"
  18540. // for scanner.Scan() {
  18541. // line = scanner.Text()
  18542. // programXML += line
  18543. // if strings.Contains(line, "</program>") {
  18544. // programXML += "</program>"
  18545. // break
  18546. // }
  18547. // }
  18548. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18549. // // 解析成功,更新最后的 Program
  18550. // }
  18551. // inProgram = false
  18552. // }
  18553. //}
  18554. //
  18555. // fmt.Println("Error reading file:", inProgram)
  18556. //
  18557. //if err := scanner.Err(); err != nil {
  18558. // fmt.Println("Error reading file:", err)
  18559. //}
  18560. // 输出最后一次的 Program
  18561. //fmt.Printf("最后一次的 <program>:\n")
  18562. //fmt.Printf("<program>\n")
  18563. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18564. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18565. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18566. //fmt.Printf("</program>\n")
  18567. fmt.Println(string(str1))
  18568. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18569. if ret2 != 0 {
  18570. return ""
  18571. }
  18572. return string(str1)
  18573. }
  18574. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18575. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18576. readCard := DllDef.MustFindProc("read_cardinfo")
  18577. if readCard == nil {
  18578. fmt.Println("readcard is nil")
  18579. readCard = DllDef.MustFindProc("read_cardinfo")
  18580. }
  18581. str := make([]byte, 1024) //卡号
  18582. str1 := make([]byte, 1024) //卡识别码
  18583. str2 := make([]byte, 1024) //身份证号
  18584. str3 := make([]byte, 1024) //姓名
  18585. str4 := make([]byte, 1024) //错误信息
  18586. 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])))
  18587. fmt.Println(string(str1))
  18588. fmt.Println(string(str))
  18589. fmt.Println(string(str2))
  18590. fmt.Println(string(str3))
  18591. fmt.Println(string(str4))
  18592. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18593. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18594. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18595. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18596. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18597. if ret2 != 0 {
  18598. return "", "", "", "", ""
  18599. }
  18600. return string(str), string(str1), string(str2), string(str3), string(str4)
  18601. }
  18602. type CustomFundPay struct {
  18603. FundPayType string `json:"fund_pay_type"`
  18604. FundPayamt float64 `json:"fund_payamt"`
  18605. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18606. }
  18607. //func (c *HisApiController) GetBatchSettleList() {
  18608. // start_time_str := c.GetString("start_time")
  18609. // //end_time_str := c.GetString("end_time")
  18610. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18611. //
  18612. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18613. //
  18614. // for _, item := range orders {
  18615. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18616. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18617. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18618. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18619. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18620. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18621. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18622. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18623. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18624. //
  18625. // if order.ID == 0 {
  18626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18627. // return
  18628. // }
  18629. //
  18630. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18631. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18632. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18633. // //fmt.Println(count)
  18634. // //var zero string
  18635. // //number := count + 1
  18636. // //if number >= 1000 {
  18637. // // zero = "0000" + strconv.FormatInt(number, 10)
  18638. // //} else if number >= 10000 {
  18639. // // zero = "000" + strconv.FormatInt(number, 10)
  18640. // //} else if number >= 100000 {
  18641. // // zero = "00" + strconv.FormatInt(number, 10)
  18642. // //} else if number >= 1000000 {
  18643. // // zero = "0" + strconv.FormatInt(number, 10)
  18644. // //} else {
  18645. // // zero = strconv.FormatInt(number, 10)
  18646. // //}
  18647. // //fmt.Println(zero)
  18648. //
  18649. // struct4101 := service.Struct4101{
  18650. // PsnNo: order.PsnNo,
  18651. // MdtrtId: order.MdtrtId,
  18652. // SetlId: order.SetlId,
  18653. // PsnName: order.PsnName,
  18654. // Gend: order.Gend,
  18655. // Brdy: his.Brdy,
  18656. // Age: his.Age,
  18657. // Naty: order.Naty,
  18658. // PatnCertType: "01",
  18659. // Certno: order.Certno,
  18660. // Prfs: "90",
  18661. // ConerName: roles[0].UserName,
  18662. // PatnRlts: "99",
  18663. // ConerAddr: miConfig.OrgName,
  18664. // ConerTel: admin.Mobile,
  18665. // HiType: order.Insutype,
  18666. // Insuplc: miConfig.InsuplcAdmdvs,
  18667. // MaindiagFlag: "1",
  18668. // BillCode: order.SetlId,
  18669. // BillNo: order.SetlId,
  18670. // BizSn: order.Number,
  18671. // PsnSelfPay: order.PsnPartAmt,
  18672. // PsnOwnPay: order.PsnPartAmt,
  18673. // AcctPay: order.AcctPay,
  18674. // PsnCashpay: order.PsnCashPay,
  18675. // HiPaymtd: "1",
  18676. // Hsorg: miConfig.InsuplcAdmdvs,
  18677. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18678. // MedinsFillPsn: curRoles.UserName,
  18679. // MedinsFillDept: miConfig.OrgName,
  18680. // IptMedType: "2",
  18681. // }
  18682. // struct4101.SetlBegnDate = order.SetlTime
  18683. // struct4101.SetlEndDate = order.SetlTime
  18684. // time_arr := strings.Split(order.SetlTime, " ")
  18685. // struct4101.AdmTime = time_arr[0]
  18686. // struct4101.AdmEndTime = time_arr[0]
  18687. //
  18688. // var rf []CustomFundPay
  18689. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18690. //
  18691. // var tempFunPays []service.CustomStruct
  18692. // for _, item := range rf {
  18693. // var tempFunPay service.CustomStruct
  18694. // tempFunPay.FundPayamt = item.FundPayamt
  18695. // tempFunPay.FundPayType = item.FundPayType
  18696. // tempFunPays = append(tempFunPays, tempFunPay)
  18697. // }
  18698. // struct4101.CustomStruct = tempFunPays
  18699. //
  18700. // var tempDiaginfos []service.DiaginfoStructTwo
  18701. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18702. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18703. //
  18704. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18705. // var config []*models.HisXtDiagnoseConfig
  18706. // for _, item := range diagnosis_ids {
  18707. // id, _ := strconv.ParseInt(item, 10, 64)
  18708. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18709. // config = append(config, &diagnosisConfig)
  18710. // }
  18711. //
  18712. // for index, item := range config {
  18713. // if index == 0 {
  18714. // var tempDiaginfo service.DiaginfoStructTwo
  18715. // tempDiaginfo.DiagCode = item.CountryCode
  18716. // tempDiaginfo.DiagName = item.CountryContentName
  18717. // tempDiaginfo.DiagType = "1"
  18718. // tempDiaginfo.MaindiagFlag = "1"
  18719. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18720. // } else {
  18721. // var tempDiaginfo service.DiaginfoStructTwo
  18722. // tempDiaginfo.DiagCode = item.CountryCode
  18723. // tempDiaginfo.DiagName = item.CountryContentName
  18724. // tempDiaginfo.DiagType = "1"
  18725. // tempDiaginfo.MaindiagFlag = "0"
  18726. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18727. // }
  18728. // }
  18729. // struct4101.Diseinfo = tempDiaginfos
  18730. //
  18731. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18732. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18733. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18734. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18735. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18736. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18737. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18738. //
  18739. // var iteminfo service.IteminfoStruct
  18740. //
  18741. // var bedCostTotal float64 = 0 //床位总费
  18742. // var bedCostSelfTotal float64 = 0 //床位自费
  18743. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18744. //
  18745. // var operationCostTotal float64 = 0 //手术费
  18746. // var operationCostSelfTotal float64 = 0 //手术费
  18747. // var operationCostPartSelfTotal float64 = 0 //手术费
  18748. //
  18749. // var otherCostTotal float64 = 0 //其他费用
  18750. // var otherCostSelfTotal float64 = 0 //其他费用
  18751. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18752. //
  18753. // var materialCostTotal float64 = 0 //材料费
  18754. // var materialCostSelfTotal float64 = 0 //材料费
  18755. // var materialCostPartSelfTotal float64 = 0 //材料费
  18756. //
  18757. // var westernMedicineCostTotal float64 = 0 //西药费
  18758. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18759. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18760. //
  18761. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18762. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18763. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18764. //
  18765. // var checkCostTotal float64 = 0 //检查费
  18766. // var checkCostSelfTotal float64 = 0 //检查费
  18767. // var checkCostPartSelfTotal float64 = 0 //检查费
  18768. //
  18769. // var laboratoryCostTotal float64 = 0 //化验费
  18770. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18771. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18772. //
  18773. // var treatCostTotal float64 = 0 //治疗费用
  18774. // var treatCostSelfTotal float64 = 0 //治疗费用
  18775. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18776. //
  18777. // decimal.DivisionPrecision = 2
  18778. //
  18779. // var bed_fulamt_ownpay_amt float64 = 0
  18780. // var operation_fulamt_ownpay_amt float64 = 0
  18781. // var other_fulamt_ownpay_amt float64 = 0
  18782. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18783. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18784. // var check_fulamt_ownpay_amt float64 = 0
  18785. // var material_fulamt_ownpay_amt float64 = 0
  18786. // var laboratory_fulamt_ownpay_amt float64 = 0
  18787. // var treat_fulamt_ownpay_amt float64 = 0
  18788. //
  18789. // var bed_claa_sunmfee float64 = 0
  18790. // var bed_clab_amt float64 = 0
  18791. // var bed_other_amt float64 = 0
  18792. //
  18793. // var operation_claa_sunmfee float64 = 0
  18794. // var operation_clab_amt float64 = 0
  18795. // var operation_other_amt float64 = 0
  18796. //
  18797. // var other_claa_sunmfee float64 = 0
  18798. // var other_clab_amt float64 = 0
  18799. // var other_other_amt float64 = 0
  18800. //
  18801. // var westernMedicine_claa_sunmfee float64 = 0
  18802. // var westernMedicine_clab_amt float64 = 0
  18803. // var westernMedicine_other_amt float64 = 0
  18804. //
  18805. // var chineseTraditional_claa_sunmfee float64 = 0
  18806. // var chineseTraditional_clab_amt float64 = 0
  18807. // var chineseTraditional_other_amt float64 = 0
  18808. //
  18809. // var check_claa_sunmfee float64 = 0
  18810. // var check_clab_amt float64 = 0
  18811. // var check_other_amt float64 = 0
  18812. //
  18813. // var material_claa_sunmfee float64 = 0
  18814. // var material_clab_amt float64 = 0
  18815. // var material_other_amt float64 = 0
  18816. //
  18817. // var laboratory_claa_sunmfee float64 = 0
  18818. // var laboratory_clab_amt float64 = 0
  18819. // var laboratory_other_amt float64 = 0
  18820. //
  18821. // var treat_claa_sunmfee float64 = 0
  18822. // var treat_clab_amt float64 = 0
  18823. // var treat_other_amt float64 = 0
  18824. //
  18825. // for _, item := range order.HisOrderInfo {
  18826. // if item.MedChrgitmType == "01" { //床位费
  18827. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18828. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18829. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18830. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18831. // if item.ChrgitmLv == "1" {
  18832. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18833. // }
  18834. // if item.ChrgitmLv == "2" {
  18835. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18836. //
  18837. // }
  18838. // if item.ChrgitmLv == "3" {
  18839. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18840. // }
  18841. //
  18842. // }
  18843. //
  18844. // if item.MedChrgitmType == "03" { //检查费
  18845. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18846. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18847. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18848. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18849. // if item.ChrgitmLv == "1" {
  18850. //
  18851. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18852. //
  18853. // }
  18854. // if item.ChrgitmLv == "2" {
  18855. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18856. //
  18857. // }
  18858. // if item.ChrgitmLv == "3" {
  18859. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18860. // }
  18861. // }
  18862. //
  18863. // if item.MedChrgitmType == "04" { //化验费
  18864. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18865. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18866. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18867. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18868. // if item.ChrgitmLv == "1" {
  18869. //
  18870. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18871. //
  18872. // }
  18873. // if item.ChrgitmLv == "2" {
  18874. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18875. //
  18876. // }
  18877. // if item.ChrgitmLv == "3" {
  18878. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18879. // }
  18880. // }
  18881. //
  18882. // if item.MedChrgitmType == "05" { //治疗费
  18883. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18884. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18885. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18886. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18887. // if item.ChrgitmLv == "1" {
  18888. //
  18889. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18890. //
  18891. // }
  18892. // if item.ChrgitmLv == "2" {
  18893. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18894. //
  18895. // }
  18896. // if item.ChrgitmLv == "3" {
  18897. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18898. // }
  18899. // }
  18900. //
  18901. // if item.MedChrgitmType == "06" { //手术费
  18902. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18903. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18904. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18905. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18906. //
  18907. // if item.ChrgitmLv == "1" {
  18908. //
  18909. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18910. //
  18911. // }
  18912. // if item.ChrgitmLv == "2" {
  18913. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18914. //
  18915. // }
  18916. // if item.ChrgitmLv == "3" {
  18917. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18918. // }
  18919. // }
  18920. //
  18921. // if item.MedChrgitmType == "08" { //材料费
  18922. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18923. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18924. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18925. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18926. // if item.ChrgitmLv == "1" {
  18927. //
  18928. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18929. //
  18930. // }
  18931. // if item.ChrgitmLv == "2" {
  18932. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18933. //
  18934. // }
  18935. // if item.ChrgitmLv == "3" {
  18936. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18937. // }
  18938. // }
  18939. //
  18940. // if item.MedChrgitmType == "09" { //西药费
  18941. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18942. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18943. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18944. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18945. // if item.ChrgitmLv == "1" {
  18946. //
  18947. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18948. //
  18949. // }
  18950. // if item.ChrgitmLv == "2" {
  18951. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18952. //
  18953. // }
  18954. // if item.ChrgitmLv == "3" {
  18955. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18956. // }
  18957. // }
  18958. //
  18959. // if item.MedChrgitmType == "11" { //中成费
  18960. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18961. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18962. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18963. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18964. // if item.ChrgitmLv == "1" {
  18965. //
  18966. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18967. //
  18968. // }
  18969. // if item.ChrgitmLv == "2" {
  18970. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18971. //
  18972. // }
  18973. // if item.ChrgitmLv == "3" {
  18974. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18975. // }
  18976. // }
  18977. //
  18978. // if item.MedChrgitmType == "14" { //其他费
  18979. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18980. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18981. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18982. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18983. // if item.ChrgitmLv == "1" {
  18984. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18985. //
  18986. // }
  18987. // if item.ChrgitmLv == "2" {
  18988. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18989. //
  18990. // }
  18991. // if item.ChrgitmLv == "3" {
  18992. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18993. // }
  18994. // }
  18995. //
  18996. // }
  18997. //
  18998. // var iteminfoStructs []service.IteminfoStruct
  18999. //
  19000. // if bedCostTotal != 0 {
  19001. // iteminfo.MedChrgitm = "01"
  19002. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19003. // iteminfo.Amt = bedCostTotal
  19004. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19005. // iteminfo.ClabAmt = bed_clab_amt
  19006. // iteminfo.OthAmt = bed_other_amt
  19007. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19008. // }
  19009. //
  19010. // if checkCostTotal != 0 {
  19011. // iteminfo.MedChrgitm = "03"
  19012. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19013. // iteminfo.Amt = checkCostTotal
  19014. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19015. // iteminfo.ClabAmt = check_clab_amt
  19016. // iteminfo.OthAmt = check_other_amt
  19017. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19018. //
  19019. // }
  19020. //
  19021. // if laboratoryCostTotal != 0 {
  19022. // iteminfo.MedChrgitm = "04"
  19023. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19024. // iteminfo.Amt = laboratoryCostTotal
  19025. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19026. // iteminfo.ClabAmt = laboratory_clab_amt
  19027. // iteminfo.OthAmt = laboratory_other_amt
  19028. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19029. //
  19030. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19031. //
  19032. // }
  19033. //
  19034. // if treatCostTotal != 0 {
  19035. // iteminfo.MedChrgitm = "05"
  19036. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19037. // iteminfo.Amt = treatCostTotal
  19038. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19039. // iteminfo.ClabAmt = treat_clab_amt
  19040. // iteminfo.OthAmt = treat_other_amt
  19041. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19042. // //(struct4101.IteminfoStruct, iteminfo)
  19043. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19044. // }
  19045. //
  19046. // if operationCostTotal != 0 {
  19047. // iteminfo.MedChrgitm = "06"
  19048. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19049. // iteminfo.Amt = operationCostTotal
  19050. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19051. // iteminfo.ClabAmt = operation_clab_amt
  19052. // iteminfo.OthAmt = operation_other_amt
  19053. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19054. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19055. // }
  19056. //
  19057. // if materialCostTotal != 0 {
  19058. // iteminfo.MedChrgitm = "08"
  19059. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19060. // iteminfo.Amt = materialCostTotal
  19061. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19062. // iteminfo.ClabAmt = material_clab_amt
  19063. // iteminfo.OthAmt = material_other_amt
  19064. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19065. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19066. // }
  19067. //
  19068. // if westernMedicineCostTotal != 0 {
  19069. // iteminfo.MedChrgitm = "09"
  19070. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19071. // iteminfo.Amt = westernMedicineCostTotal
  19072. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19073. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19074. // iteminfo.OthAmt = westernMedicine_other_amt
  19075. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19076. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19077. //
  19078. // }
  19079. // if chineseTraditionalMedicineCostTotal != 0 {
  19080. // iteminfo.MedChrgitm = "11"
  19081. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19082. // iteminfo.Amt = westernMedicineCostTotal
  19083. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19084. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19085. // iteminfo.OthAmt = westernMedicine_other_amt
  19086. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19087. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19088. //
  19089. // }
  19090. // if otherCostTotal != 0 {
  19091. // iteminfo.MedChrgitm = "14"
  19092. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19093. // iteminfo.Amt = otherCostTotal
  19094. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19095. // iteminfo.ClabAmt = other_clab_amt
  19096. // iteminfo.OthAmt = other_other_amt
  19097. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19098. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19099. //
  19100. // }
  19101. // struct4101.IteminfoStruct = iteminfoStructs
  19102. // struct4101.Ntly = "中国"
  19103. // struct4101.AdmCaty = "A03.06"
  19104. //
  19105. // struct4101.DoctorName = doctor.UserName
  19106. // struct4101.DoctorCode = doctor.DoctorNumber
  19107. //
  19108. // var res ResultSeventeen
  19109. //
  19110. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19111. // struct4101.BillCode = order.Number
  19112. // struct4101.BillNo = order.SetlId
  19113. // var resOther ResultSeventeenOther
  19114. // var pp models.PublicParams
  19115. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19116. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19117. // pp.FixmedinsName = miConfig.OrgName
  19118. // pp.FixmedinsCode = miConfig.Code
  19119. // pp.RequestUrl = miConfig.Url
  19120. // pp.Cainfo = miConfig.Cainfo
  19121. // pp.SecretKey = miConfig.SecretKey
  19122. // pp.AccessKey = miConfig.AccessKey
  19123. // pp.OpterName = curRoles.UserName
  19124. //
  19125. // client := &http.Client{}
  19126. // var req *http.Request
  19127. // data := make(map[string]interface{})
  19128. // data["struct4101"] = struct4101
  19129. // data["pp"] = pp
  19130. // bytesData, _ := json.Marshal(data)
  19131. // if miConfig.MdtrtareaAdmvs == "320921" {
  19132. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19133. // } else {
  19134. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19135. // }
  19136. // resp, _ := client.Do(req)
  19137. // defer resp.Body.Close()
  19138. // body, ioErr := ioutil.ReadAll(resp.Body)
  19139. // if ioErr != nil {
  19140. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19142. // return
  19143. // }
  19144. // var respJSON map[string]interface{}
  19145. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19146. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19147. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19148. // return
  19149. // }
  19150. //
  19151. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19152. // userJSONBytes, _ := json.Marshal(respJSON)
  19153. // fmt.Println("log")
  19154. // fmt.Println(string(userJSONBytes))
  19155. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19156. // utils.ErrorLog("解析失败:%v", err)
  19157. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19158. // return
  19159. // }
  19160. // res.InfRefmsgid = resOther.InfRefmsgid
  19161. // res.Output = resOther.Output
  19162. // res.ErrMsg = resOther.ErrMsg
  19163. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19164. // res.Infcode = infocode
  19165. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  19166. //
  19167. // var pp models.PublicParams
  19168. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19169. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19170. // pp.FixmedinsName = miConfig.OrgName
  19171. // pp.FixmedinsCode = miConfig.Code
  19172. // pp.RequestUrl = miConfig.Url
  19173. // pp.Cainfo = miConfig.Cainfo
  19174. // pp.SecretKey = miConfig.SecretKey
  19175. // pp.AccessKey = miConfig.AccessKey
  19176. // pp.OpterName = curRoles.UserName
  19177. // result, _ := service.Jxyb4101(struct4101, pp)
  19178. // var dat map[string]interface{}
  19179. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19180. // fmt.Println(dat)
  19181. // } else {
  19182. // fmt.Println(err)
  19183. // }
  19184. // userJSONBytes, _ := json.Marshal(dat)
  19185. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19186. // utils.ErrorLog("解析失败:%v", err)
  19187. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19188. // return
  19189. // }
  19190. //
  19191. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  19192. // var pp models.PublicParams
  19193. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19194. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19195. // pp.FixmedinsName = miConfig.OrgName
  19196. // pp.FixmedinsCode = miConfig.Code
  19197. // pp.RequestUrl = miConfig.Url
  19198. // pp.Cainfo = miConfig.Cainfo
  19199. // pp.SecretKey = miConfig.SecretKey
  19200. // pp.AccessKey = miConfig.AccessKey
  19201. // pp.OpterName = curRoles.UserName
  19202. // result, _ := service.Hnyb4101(struct4101, pp)
  19203. // var dat map[string]interface{}
  19204. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19205. // fmt.Println(dat)
  19206. // } else {
  19207. // fmt.Println(err)
  19208. // }
  19209. // userJSONBytes, _ := json.Marshal(dat)
  19210. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19211. // utils.ErrorLog("解析失败:%v", err)
  19212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19213. // return
  19214. // }
  19215. //
  19216. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  19217. // var resOther ResultSeventeenOther
  19218. //
  19219. // var pp models.PublicParams
  19220. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19221. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19222. // pp.FixmedinsName = miConfig.OrgName
  19223. // pp.FixmedinsCode = miConfig.Code
  19224. // pp.RequestUrl = miConfig.Url
  19225. // pp.Cainfo = miConfig.Cainfo
  19226. // pp.SecretKey = miConfig.SecretKey
  19227. // pp.AccessKey = miConfig.AccessKey
  19228. // pp.OpterName = curRoles.UserName
  19229. // client := &http.Client{}
  19230. // var req *http.Request
  19231. // data := make(map[string]interface{})
  19232. // data["struct4101"] = struct4101
  19233. // data["pp"] = pp
  19234. // bytesData, _ := json.Marshal(data)
  19235. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19236. // resp, _ := client.Do(req)
  19237. // defer resp.Body.Close()
  19238. // body, ioErr := ioutil.ReadAll(resp.Body)
  19239. // if ioErr != nil {
  19240. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19242. // return
  19243. // }
  19244. // var respJSON map[string]interface{}
  19245. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19246. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19247. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19248. // return
  19249. // }
  19250. //
  19251. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19252. // userJSONBytes, _ := json.Marshal(respJSON)
  19253. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19254. // utils.ErrorLog("解析失败:%v", err)
  19255. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19256. // return
  19257. // }
  19258. // res.InfRefmsgid = resOther.InfRefmsgid
  19259. // res.Output = resOther.Output
  19260. // res.ErrMsg = resOther.ErrMsg
  19261. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19262. // res.Infcode = infocode
  19263. //
  19264. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  19265. // var pp models.PublicParams
  19266. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19267. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19268. // pp.FixmedinsName = miConfig.OrgName
  19269. // pp.FixmedinsCode = miConfig.Code
  19270. // pp.RequestUrl = miConfig.Url
  19271. // pp.Cainfo = miConfig.Cainfo
  19272. // pp.SecretKey = miConfig.SecretKey
  19273. // pp.AccessKey = miConfig.AccessKey
  19274. // pp.OpterName = curRoles.UserName
  19275. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19276. // fmt.Println(requestLog)
  19277. // fmt.Println(errMsgLog)
  19278. //
  19279. // saveLog(result, requestLog, "4101a", "上传清单")
  19280. //
  19281. // var dat map[string]interface{}
  19282. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19283. // fmt.Println(dat)
  19284. // } else {
  19285. // fmt.Println(err)
  19286. // }
  19287. // userJSONBytes, _ := json.Marshal(dat)
  19288. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19289. // utils.ErrorLog("解析失败:%v", err)
  19290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19291. // return
  19292. // }
  19293. //
  19294. // } else {
  19295. //
  19296. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  19297. // var dat map[string]interface{}
  19298. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19299. // fmt.Println(dat)
  19300. // } else {
  19301. // fmt.Println(err)
  19302. // }
  19303. // userJSONBytes, _ := json.Marshal(dat)
  19304. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19305. // utils.ErrorLog("解析失败:%v", err)
  19306. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19307. // return
  19308. // }
  19309. // }
  19310. //
  19311. // if res.Infcode != 0 {
  19312. // adminUser := c.GetAdminUserInfo()
  19313. // errlog := &models.HisOrderError{
  19314. // UserOrgId: adminUser.CurrentOrgId,
  19315. // Ctime: time.Now().Unix(),
  19316. // Mtime: time.Now().Unix(),
  19317. // ErrMsg: res.ErrMsg,
  19318. // Status: 1,
  19319. // PatientId: order.ID,
  19320. // Stage: 10265,
  19321. // }
  19322. // service.CreateErrMsgLog(errlog)
  19323. // continue
  19324. // } else {
  19325. // //order.FaPiaoNumber = zero
  19326. // //order.FaPiaoCode = last_order.FaPiaoCode
  19327. // //service.UpdateOrder(order)
  19328. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19329. // Number: res.Output.SetlListId,
  19330. // Status: 1,
  19331. // Ctime: time.Now().Unix(),
  19332. // Mtime: time.Now().Unix(),
  19333. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19334. // IsUpload: 1,
  19335. // OrderId: order.ID,
  19336. // }
  19337. // service.CreateUploadRecord(hisFundSettleListResult)
  19338. // c.ServeSuccessJSON(map[string]interface{}{
  19339. // "msg": "上传成功",
  19340. // "result": hisFundSettleListResult,
  19341. // })
  19342. // continue
  19343. // }
  19344. // }
  19345. //}
  19346. func (c *HisApiController) GetbatchSettleList() {
  19347. //order_id, _ := c.GetInt64("order_id")
  19348. admin_user_id, _ := c.GetInt64("admin_user_id")
  19349. orders, _ := service.GetAllHisOrderTwo10485()
  19350. for _, item := range orders {
  19351. order, _ := service.GetHisOrderByIDTwo(item.ID)
  19352. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19353. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19354. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19355. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19356. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19357. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19358. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19359. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19360. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19361. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19362. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19363. //fmt.Println(count)
  19364. //var zero string
  19365. //number := count + 1
  19366. //if number >= 1000 {
  19367. // zero = "0000" + strconv.FormatInt(number, 10)
  19368. //} else if number >= 10000 {
  19369. // zero = "000" + strconv.FormatInt(number, 10)
  19370. //} else if number >= 100000 {
  19371. // zero = "00" + strconv.FormatInt(number, 10)
  19372. //} else if number >= 1000000 {
  19373. // zero = "0" + strconv.FormatInt(number, 10)
  19374. //} else {
  19375. // zero = strconv.FormatInt(number, 10)
  19376. //}
  19377. //fmt.Println(zero)
  19378. struct4101 := service.Struct4101{
  19379. PsnNo: order.PsnNo,
  19380. MdtrtId: order.MdtrtId,
  19381. SetlId: order.SetlId,
  19382. PsnName: order.PsnName,
  19383. Gend: order.Gend,
  19384. Brdy: his.Brdy,
  19385. Age: his.Age,
  19386. Naty: order.Naty,
  19387. PatnCertType: "01",
  19388. Certno: order.Certno,
  19389. Prfs: "90",
  19390. ConerName: roles[0].UserName,
  19391. PatnRlts: "99",
  19392. ConerAddr: miConfig.OrgName,
  19393. ConerTel: admin.Mobile,
  19394. HiType: order.Insutype,
  19395. Insuplc: miConfig.InsuplcAdmdvs,
  19396. MaindiagFlag: "1",
  19397. BillCode: order.SetlId,
  19398. BillNo: order.SetlId,
  19399. BizSn: order.Number,
  19400. PsnSelfPay: order.PsnPartAmt,
  19401. PsnOwnPay: order.PsnPartAmt,
  19402. AcctPay: order.AcctPay,
  19403. PsnCashpay: order.PsnCashPay,
  19404. HiPaymtd: "1",
  19405. Hsorg: miConfig.InsuplcAdmdvs,
  19406. HsorgOpter: miConfig.InsuplcAdmdvs,
  19407. MedinsFillPsn: curRoles.UserName,
  19408. MedinsFillDept: miConfig.OrgName,
  19409. IptMedType: "2",
  19410. }
  19411. struct4101.SetlBegnDate = order.SetlTime
  19412. struct4101.SetlEndDate = order.SetlTime
  19413. time_arr := strings.Split(order.SetlTime, " ")
  19414. struct4101.AdmTime = time_arr[0]
  19415. struct4101.AdmEndTime = time_arr[0]
  19416. //var rf []CustomFundPay
  19417. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19418. //
  19419. //var tempFunPays []service.CustomStruct
  19420. //for _, item := range rf {
  19421. // var tempFunPay service.CustomStruct
  19422. // tempFunPay.FundPayamt = item.FundPayamt
  19423. // tempFunPay.FundPayType = item.FundPayType
  19424. // tempFunPays = append(tempFunPays, tempFunPay)
  19425. //}
  19426. //struct4101.CustomStruct = tempFunPays
  19427. var tempDiaginfos []service.DiaginfoStructTwo
  19428. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19429. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19430. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19431. var config []*models.HisXtDiagnoseConfig
  19432. for _, item := range diagnosis_ids {
  19433. id, _ := strconv.ParseInt(item, 10, 64)
  19434. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19435. config = append(config, &diagnosisConfig)
  19436. }
  19437. for index, item := range config {
  19438. if index == 0 {
  19439. var tempDiaginfo service.DiaginfoStructTwo
  19440. tempDiaginfo.DiagCode = item.CountryCode
  19441. tempDiaginfo.DiagName = item.CountryContentName
  19442. tempDiaginfo.DiagType = "1"
  19443. tempDiaginfo.MaindiagFlag = "1"
  19444. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19445. } else {
  19446. var tempDiaginfo service.DiaginfoStructTwo
  19447. tempDiaginfo.DiagCode = item.CountryCode
  19448. tempDiaginfo.DiagName = item.CountryContentName
  19449. tempDiaginfo.DiagType = "1"
  19450. tempDiaginfo.MaindiagFlag = "0"
  19451. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19452. }
  19453. }
  19454. struct4101.Diseinfo = tempDiaginfos
  19455. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19456. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19457. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19458. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19459. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19460. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19461. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19462. var iteminfo service.IteminfoStruct
  19463. var bedCostTotal float64 = 0 //床位总费
  19464. var bedCostSelfTotal float64 = 0 //床位自费
  19465. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19466. var operationCostTotal float64 = 0 //手术费
  19467. var operationCostSelfTotal float64 = 0 //手术费
  19468. var operationCostPartSelfTotal float64 = 0 //手术费
  19469. var otherCostTotal float64 = 0 //其他费用
  19470. var otherCostSelfTotal float64 = 0 //其他费用
  19471. var otherCostPartSelfTotal float64 = 0 //其他费用
  19472. var materialCostTotal float64 = 0 //材料费
  19473. var materialCostSelfTotal float64 = 0 //材料费
  19474. var materialCostPartSelfTotal float64 = 0 //材料费
  19475. var westernMedicineCostTotal float64 = 0 //西药费
  19476. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19477. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19478. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19479. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19480. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19481. var checkCostTotal float64 = 0 //检查费
  19482. var checkCostSelfTotal float64 = 0 //检查费
  19483. var checkCostPartSelfTotal float64 = 0 //检查费
  19484. var laboratoryCostTotal float64 = 0 //化验费
  19485. var laboratoryCostSelfTotal float64 = 0 //化验费
  19486. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19487. var treatCostTotal float64 = 0 //治疗费用
  19488. var treatCostSelfTotal float64 = 0 //治疗费用
  19489. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19490. decimal.DivisionPrecision = 2
  19491. var bed_fulamt_ownpay_amt float64 = 0
  19492. var operation_fulamt_ownpay_amt float64 = 0
  19493. var other_fulamt_ownpay_amt float64 = 0
  19494. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19495. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19496. var check_fulamt_ownpay_amt float64 = 0
  19497. var material_fulamt_ownpay_amt float64 = 0
  19498. var laboratory_fulamt_ownpay_amt float64 = 0
  19499. var treat_fulamt_ownpay_amt float64 = 0
  19500. var bed_claa_sunmfee float64 = 0
  19501. var bed_clab_amt float64 = 0
  19502. var bed_other_amt float64 = 0
  19503. var operation_claa_sunmfee float64 = 0
  19504. var operation_clab_amt float64 = 0
  19505. var operation_other_amt float64 = 0
  19506. var other_claa_sunmfee float64 = 0
  19507. var other_clab_amt float64 = 0
  19508. var other_other_amt float64 = 0
  19509. var westernMedicine_claa_sunmfee float64 = 0
  19510. var westernMedicine_clab_amt float64 = 0
  19511. var westernMedicine_other_amt float64 = 0
  19512. var chineseTraditional_claa_sunmfee float64 = 0
  19513. var chineseTraditional_clab_amt float64 = 0
  19514. var chineseTraditional_other_amt float64 = 0
  19515. var check_claa_sunmfee float64 = 0
  19516. var check_clab_amt float64 = 0
  19517. var check_other_amt float64 = 0
  19518. var material_claa_sunmfee float64 = 0
  19519. var material_clab_amt float64 = 0
  19520. var material_other_amt float64 = 0
  19521. var laboratory_claa_sunmfee float64 = 0
  19522. var laboratory_clab_amt float64 = 0
  19523. var laboratory_other_amt float64 = 0
  19524. var treat_claa_sunmfee float64 = 0
  19525. var treat_clab_amt float64 = 0
  19526. var treat_other_amt float64 = 0
  19527. for _, item := range order.HisOrderInfo {
  19528. if item.MedChrgitmType == "01" { //床位费
  19529. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19530. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19531. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19532. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19533. if item.ChrgitmLv == "1" {
  19534. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19535. }
  19536. if item.ChrgitmLv == "2" {
  19537. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19538. }
  19539. if item.ChrgitmLv == "3" {
  19540. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19541. }
  19542. }
  19543. if item.MedChrgitmType == "03" { //检查费
  19544. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19545. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19546. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19547. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19548. if item.ChrgitmLv == "1" {
  19549. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19550. }
  19551. if item.ChrgitmLv == "2" {
  19552. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19553. }
  19554. if item.ChrgitmLv == "3" {
  19555. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19556. }
  19557. }
  19558. if item.MedChrgitmType == "04" { //化验费
  19559. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19560. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19561. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19562. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19563. if item.ChrgitmLv == "1" {
  19564. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19565. }
  19566. if item.ChrgitmLv == "2" {
  19567. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19568. }
  19569. if item.ChrgitmLv == "3" {
  19570. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19571. }
  19572. }
  19573. if item.MedChrgitmType == "05" { //治疗费
  19574. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19575. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19576. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19577. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19578. if item.ChrgitmLv == "1" {
  19579. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19580. }
  19581. if item.ChrgitmLv == "2" {
  19582. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19583. }
  19584. if item.ChrgitmLv == "3" {
  19585. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19586. }
  19587. }
  19588. if item.MedChrgitmType == "06" { //手术费
  19589. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19590. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19591. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19592. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19593. if item.ChrgitmLv == "1" {
  19594. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19595. }
  19596. if item.ChrgitmLv == "2" {
  19597. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19598. }
  19599. if item.ChrgitmLv == "3" {
  19600. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19601. }
  19602. }
  19603. if item.MedChrgitmType == "08" { //材料费
  19604. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19605. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19606. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19607. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19608. if item.ChrgitmLv == "1" {
  19609. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19610. }
  19611. if item.ChrgitmLv == "2" {
  19612. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19613. }
  19614. if item.ChrgitmLv == "3" {
  19615. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19616. }
  19617. }
  19618. if item.MedChrgitmType == "09" { //西药费
  19619. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19620. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19621. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19622. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19623. if item.ChrgitmLv == "1" {
  19624. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19625. }
  19626. if item.ChrgitmLv == "2" {
  19627. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19628. }
  19629. if item.ChrgitmLv == "3" {
  19630. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19631. }
  19632. }
  19633. if item.MedChrgitmType == "11" { //中成费
  19634. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19635. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19636. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19637. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19638. if item.ChrgitmLv == "1" {
  19639. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19640. }
  19641. if item.ChrgitmLv == "2" {
  19642. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19643. }
  19644. if item.ChrgitmLv == "3" {
  19645. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19646. }
  19647. }
  19648. if item.MedChrgitmType == "14" { //其他费
  19649. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19650. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19651. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19652. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19653. if item.ChrgitmLv == "1" {
  19654. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19655. }
  19656. if item.ChrgitmLv == "2" {
  19657. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19658. }
  19659. if item.ChrgitmLv == "3" {
  19660. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19661. }
  19662. }
  19663. }
  19664. var iteminfoStructs []service.IteminfoStruct
  19665. if bedCostTotal != 0 {
  19666. iteminfo.MedChrgitm = "01"
  19667. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19668. iteminfo.Amt = bedCostTotal
  19669. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19670. iteminfo.ClabAmt = bed_clab_amt
  19671. iteminfo.OthAmt = bed_other_amt
  19672. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19673. }
  19674. if checkCostTotal != 0 {
  19675. iteminfo.MedChrgitm = "03"
  19676. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19677. iteminfo.Amt = checkCostTotal
  19678. iteminfo.ClaaSumfee = check_claa_sunmfee
  19679. iteminfo.ClabAmt = check_clab_amt
  19680. iteminfo.OthAmt = check_other_amt
  19681. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19682. }
  19683. if laboratoryCostTotal != 0 {
  19684. iteminfo.MedChrgitm = "04"
  19685. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19686. iteminfo.Amt = laboratoryCostTotal
  19687. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19688. iteminfo.ClabAmt = laboratory_clab_amt
  19689. iteminfo.OthAmt = laboratory_other_amt
  19690. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19691. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19692. }
  19693. if treatCostTotal != 0 {
  19694. iteminfo.MedChrgitm = "05"
  19695. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19696. iteminfo.Amt = treatCostTotal
  19697. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19698. iteminfo.ClabAmt = treat_clab_amt
  19699. iteminfo.OthAmt = treat_other_amt
  19700. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19701. //(struct4101.IteminfoStruct, iteminfo)
  19702. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19703. }
  19704. if operationCostTotal != 0 {
  19705. iteminfo.MedChrgitm = "06"
  19706. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19707. iteminfo.Amt = operationCostTotal
  19708. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19709. iteminfo.ClabAmt = operation_clab_amt
  19710. iteminfo.OthAmt = operation_other_amt
  19711. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19712. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19713. }
  19714. if materialCostTotal != 0 {
  19715. iteminfo.MedChrgitm = "08"
  19716. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19717. iteminfo.Amt = materialCostTotal
  19718. iteminfo.ClaaSumfee = material_claa_sunmfee
  19719. iteminfo.ClabAmt = material_clab_amt
  19720. iteminfo.OthAmt = material_other_amt
  19721. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19722. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19723. }
  19724. if westernMedicineCostTotal != 0 {
  19725. iteminfo.MedChrgitm = "09"
  19726. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19727. iteminfo.Amt = westernMedicineCostTotal
  19728. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19729. iteminfo.ClabAmt = westernMedicine_clab_amt
  19730. iteminfo.OthAmt = westernMedicine_other_amt
  19731. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19732. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19733. }
  19734. if chineseTraditionalMedicineCostTotal != 0 {
  19735. iteminfo.MedChrgitm = "11"
  19736. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19737. iteminfo.Amt = westernMedicineCostTotal
  19738. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19739. iteminfo.ClabAmt = westernMedicine_clab_amt
  19740. iteminfo.OthAmt = westernMedicine_other_amt
  19741. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19742. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19743. }
  19744. if otherCostTotal != 0 {
  19745. iteminfo.MedChrgitm = "14"
  19746. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19747. iteminfo.Amt = otherCostTotal
  19748. iteminfo.ClaaSumfee = other_claa_sunmfee
  19749. iteminfo.ClabAmt = other_clab_amt
  19750. iteminfo.OthAmt = other_other_amt
  19751. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19752. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19753. }
  19754. struct4101.IteminfoStruct = iteminfoStructs
  19755. struct4101.Ntly = "中国"
  19756. struct4101.AdmCaty = "A03.06"
  19757. struct4101.DoctorName = doctor.UserName
  19758. struct4101.DoctorCode = doctor.DoctorNumber
  19759. var res ResultSeventeen
  19760. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19761. struct4101.BillCode = order.Number
  19762. struct4101.BillNo = order.SetlId
  19763. var resOther ResultSeventeenOther
  19764. var pp models.PublicParams
  19765. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19766. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19767. pp.FixmedinsName = miConfig.OrgName
  19768. pp.FixmedinsCode = miConfig.Code
  19769. pp.RequestUrl = miConfig.Url
  19770. pp.Cainfo = miConfig.Cainfo
  19771. pp.SecretKey = miConfig.SecretKey
  19772. pp.AccessKey = miConfig.AccessKey
  19773. pp.OpterName = curRoles.UserName
  19774. client := &http.Client{}
  19775. var req *http.Request
  19776. data := make(map[string]interface{})
  19777. data["struct4101"] = struct4101
  19778. data["pp"] = pp
  19779. bytesData, _ := json.Marshal(data)
  19780. if miConfig.MdtrtareaAdmvs == "320921" {
  19781. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19782. } else {
  19783. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19784. }
  19785. resp, _ := client.Do(req)
  19786. defer resp.Body.Close()
  19787. body, ioErr := ioutil.ReadAll(resp.Body)
  19788. if ioErr != nil {
  19789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19791. return
  19792. }
  19793. var respJSON map[string]interface{}
  19794. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19797. return
  19798. }
  19799. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19800. userJSONBytes, _ := json.Marshal(respJSON)
  19801. fmt.Println("log")
  19802. fmt.Println(string(userJSONBytes))
  19803. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19804. utils.ErrorLog("解析失败:%v", err)
  19805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19806. return
  19807. }
  19808. res.InfRefmsgid = resOther.InfRefmsgid
  19809. res.Output = resOther.Output
  19810. res.ErrMsg = resOther.ErrMsg
  19811. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19812. res.Infcode = infocode
  19813. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19814. var pp models.PublicParams
  19815. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19816. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19817. pp.FixmedinsName = miConfig.OrgName
  19818. pp.FixmedinsCode = miConfig.Code
  19819. pp.RequestUrl = miConfig.Url
  19820. pp.Cainfo = miConfig.Cainfo
  19821. pp.SecretKey = miConfig.SecretKey
  19822. pp.AccessKey = miConfig.AccessKey
  19823. pp.OpterName = curRoles.UserName
  19824. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19825. result, _ := service.Jxyb4101(struct4101, pp)
  19826. var dat map[string]interface{}
  19827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19828. fmt.Println(dat)
  19829. } else {
  19830. fmt.Println(err)
  19831. }
  19832. userJSONBytes, _ := json.Marshal(dat)
  19833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19834. utils.ErrorLog("解析失败:%v", err)
  19835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19836. return
  19837. }
  19838. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19839. var pp models.PublicParams
  19840. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19841. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19842. pp.FixmedinsName = miConfig.OrgName
  19843. pp.FixmedinsCode = miConfig.Code
  19844. pp.RequestUrl = miConfig.Url
  19845. pp.Cainfo = miConfig.Cainfo
  19846. pp.SecretKey = miConfig.SecretKey
  19847. pp.AccessKey = miConfig.AccessKey
  19848. pp.OpterName = curRoles.UserName
  19849. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19850. result, _ := service.Jxyb4101(struct4101, pp)
  19851. var dat map[string]interface{}
  19852. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19853. fmt.Println(dat)
  19854. } else {
  19855. fmt.Println(err)
  19856. }
  19857. userJSONBytes, _ := json.Marshal(dat)
  19858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19859. utils.ErrorLog("解析失败:%v", err)
  19860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19861. return
  19862. }
  19863. } else if miConfig.MdtrtareaAdmvs == "360100" {
  19864. var pp models.PublicParams
  19865. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19866. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19867. pp.FixmedinsName = miConfig.OrgName
  19868. pp.FixmedinsCode = miConfig.Code
  19869. pp.RequestUrl = miConfig.Url
  19870. pp.Cainfo = miConfig.Cainfo
  19871. pp.SecretKey = miConfig.SecretKey
  19872. pp.AccessKey = miConfig.AccessKey
  19873. pp.OpterName = curRoles.UserName
  19874. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19875. result, _ := service.Jxyb4101(struct4101, pp)
  19876. var dat map[string]interface{}
  19877. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19878. fmt.Println(dat)
  19879. } else {
  19880. fmt.Println(err)
  19881. }
  19882. userJSONBytes, _ := json.Marshal(dat)
  19883. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19884. utils.ErrorLog("解析失败:%v", err)
  19885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19886. return
  19887. }
  19888. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19889. var pp models.PublicParams
  19890. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19891. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19892. pp.FixmedinsName = miConfig.OrgName
  19893. pp.FixmedinsCode = miConfig.Code
  19894. pp.RequestUrl = miConfig.Url
  19895. pp.Cainfo = miConfig.Cainfo
  19896. pp.SecretKey = miConfig.SecretKey
  19897. pp.AccessKey = miConfig.AccessKey
  19898. pp.OpterName = curRoles.UserName
  19899. result, _ := service.Hnyb4101(struct4101, pp)
  19900. var dat map[string]interface{}
  19901. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19902. fmt.Println(dat)
  19903. } else {
  19904. fmt.Println(err)
  19905. }
  19906. userJSONBytes, _ := json.Marshal(dat)
  19907. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19908. utils.ErrorLog("解析失败:%v", err)
  19909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19910. return
  19911. }
  19912. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19913. var resOther ResultSeventeenOther
  19914. var pp models.PublicParams
  19915. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19916. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19917. pp.FixmedinsName = miConfig.OrgName
  19918. pp.FixmedinsCode = miConfig.Code
  19919. pp.RequestUrl = miConfig.Url
  19920. pp.Cainfo = miConfig.Cainfo
  19921. pp.SecretKey = miConfig.SecretKey
  19922. pp.AccessKey = miConfig.AccessKey
  19923. pp.OpterName = curRoles.UserName
  19924. client := &http.Client{}
  19925. var req *http.Request
  19926. data := make(map[string]interface{})
  19927. data["struct4101"] = struct4101
  19928. data["pp"] = pp
  19929. bytesData, _ := json.Marshal(data)
  19930. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19931. resp, _ := client.Do(req)
  19932. defer resp.Body.Close()
  19933. body, ioErr := ioutil.ReadAll(resp.Body)
  19934. if ioErr != nil {
  19935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19937. return
  19938. }
  19939. var respJSON map[string]interface{}
  19940. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19943. return
  19944. }
  19945. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19946. userJSONBytes, _ := json.Marshal(respJSON)
  19947. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19948. utils.ErrorLog("解析失败:%v", err)
  19949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19950. return
  19951. }
  19952. res.InfRefmsgid = resOther.InfRefmsgid
  19953. res.Output = resOther.Output
  19954. res.ErrMsg = resOther.ErrMsg
  19955. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19956. res.Infcode = infocode
  19957. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19958. var pp models.PublicParams
  19959. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19960. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19961. pp.FixmedinsName = miConfig.OrgName
  19962. pp.FixmedinsCode = miConfig.Code
  19963. pp.RequestUrl = miConfig.Url
  19964. pp.Cainfo = miConfig.Cainfo
  19965. pp.SecretKey = miConfig.SecretKey
  19966. pp.AccessKey = miConfig.AccessKey
  19967. pp.OpterName = curRoles.UserName
  19968. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19969. fmt.Println(requestLog)
  19970. fmt.Println(errMsgLog)
  19971. saveLog(result, requestLog, "4101a", "上传清单")
  19972. var dat map[string]interface{}
  19973. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19974. fmt.Println(dat)
  19975. } else {
  19976. fmt.Println(err)
  19977. }
  19978. userJSONBytes, _ := json.Marshal(dat)
  19979. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19980. utils.ErrorLog("解析失败:%v", err)
  19981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19982. return
  19983. }
  19984. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19985. var pp models.PublicParams
  19986. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19987. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19988. pp.FixmedinsName = miConfig.OrgName
  19989. pp.FixmedinsCode = miConfig.Code
  19990. pp.RequestUrl = miConfig.Url
  19991. pp.Cainfo = miConfig.Cainfo
  19992. pp.SecretKey = miConfig.SecretKey
  19993. pp.AccessKey = miConfig.AccessKey
  19994. pp.OpterName = curRoles.UserName
  19995. client := &http.Client{}
  19996. var req *http.Request
  19997. data := make(map[string]interface{})
  19998. data["struct4101"] = struct4101
  19999. data["pp"] = pp
  20000. bytesData, _ := json.Marshal(data)
  20001. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20002. resp, _ := client.Do(req)
  20003. defer resp.Body.Close()
  20004. body, ioErr := ioutil.ReadAll(resp.Body)
  20005. if ioErr != nil {
  20006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20008. return
  20009. }
  20010. var respJSON map[string]interface{}
  20011. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20014. return
  20015. }
  20016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20017. userJSONBytes, _ := json.Marshal(respJSON)
  20018. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20019. utils.ErrorLog("解析失败:%v", err)
  20020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20021. return
  20022. }
  20023. } else {
  20024. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20025. var dat map[string]interface{}
  20026. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20027. fmt.Println(dat)
  20028. } else {
  20029. fmt.Println(err)
  20030. }
  20031. userJSONBytes, _ := json.Marshal(dat)
  20032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20033. utils.ErrorLog("解析失败:%v", err)
  20034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20035. return
  20036. }
  20037. }
  20038. if res.Infcode != 0 {
  20039. errlog := &models.HisOrderError{
  20040. UserOrgId: order.UserOrgId,
  20041. Ctime: time.Now().Unix(),
  20042. Mtime: time.Now().Unix(),
  20043. ErrMsg: res.ErrMsg + "解析失败",
  20044. Status: 1,
  20045. PatientId: order.ID,
  20046. Stage: 10485,
  20047. }
  20048. service.CreateErrMsgLog(errlog)
  20049. continue
  20050. //c.ServeSuccessJSON(map[string]interface{}{
  20051. // "failed_code": -10,
  20052. // "msg": res.ErrMsg,
  20053. //})
  20054. } else {
  20055. //order.FaPiaoNumber = zero
  20056. //order.FaPiaoCode = last_order.FaPiaoCode
  20057. //service.UpdateOrder(order)
  20058. hisFundSettleListResult := &models.HisFundSettleListResult{
  20059. Number: res.Output.SetlListId,
  20060. Status: 1,
  20061. Ctime: time.Now().Unix(),
  20062. Mtime: time.Now().Unix(),
  20063. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20064. IsUpload: 1,
  20065. OrderId: order.ID,
  20066. }
  20067. service.CreateUploadRecord(hisFundSettleListResult)
  20068. continue
  20069. }
  20070. }
  20071. }
  20072. func (c *HisApiController) GetSettleList() {
  20073. order_id, _ := c.GetInt64("order_id")
  20074. admin_user_id, _ := c.GetInt64("admin_user_id")
  20075. order, _ := service.GetHisOrderByIDTwo(order_id)
  20076. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20077. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20078. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20079. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20080. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20081. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20082. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20083. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20084. if order.ID == 0 {
  20085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20086. return
  20087. }
  20088. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20089. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20090. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20091. //fmt.Println(count)
  20092. //var zero string
  20093. //number := count + 1
  20094. //if number >= 1000 {
  20095. // zero = "0000" + strconv.FormatInt(number, 10)
  20096. //} else if number >= 10000 {
  20097. // zero = "000" + strconv.FormatInt(number, 10)
  20098. //} else if number >= 100000 {
  20099. // zero = "00" + strconv.FormatInt(number, 10)
  20100. //} else if number >= 1000000 {
  20101. // zero = "0" + strconv.FormatInt(number, 10)
  20102. //} else {
  20103. // zero = strconv.FormatInt(number, 10)
  20104. //}
  20105. //fmt.Println(zero)
  20106. struct4101 := service.Struct4101{
  20107. PsnNo: order.PsnNo,
  20108. MdtrtId: order.MdtrtId,
  20109. SetlId: order.SetlId,
  20110. PsnName: order.PsnName,
  20111. Gend: order.Gend,
  20112. Brdy: his.Brdy,
  20113. Age: his.Age,
  20114. Naty: order.Naty,
  20115. PatnCertType: "01",
  20116. Certno: order.Certno,
  20117. Prfs: "90",
  20118. ConerName: roles[0].UserName,
  20119. PatnRlts: "99",
  20120. ConerAddr: miConfig.OrgName,
  20121. ConerTel: admin.Mobile,
  20122. HiType: order.Insutype,
  20123. Insuplc: miConfig.InsuplcAdmdvs,
  20124. MaindiagFlag: "1",
  20125. BillCode: order.SetlId,
  20126. BillNo: order.SetlId,
  20127. BizSn: order.Number,
  20128. PsnSelfPay: order.PsnPartAmt,
  20129. PsnOwnPay: order.PsnPartAmt,
  20130. AcctPay: order.AcctPay,
  20131. PsnCashpay: order.PsnCashPay,
  20132. HiPaymtd: "1",
  20133. Hsorg: miConfig.InsuplcAdmdvs,
  20134. HsorgOpter: miConfig.InsuplcAdmdvs,
  20135. MedinsFillPsn: curRoles.UserName,
  20136. MedinsFillDept: miConfig.OrgName,
  20137. IptMedType: "2",
  20138. }
  20139. struct4101.SetlBegnDate = order.SetlTime
  20140. struct4101.SetlEndDate = order.SetlTime
  20141. time_arr := strings.Split(order.SetlTime, " ")
  20142. struct4101.AdmTime = time_arr[0]
  20143. struct4101.AdmEndTime = time_arr[0]
  20144. //
  20145. //var rf []CustomFundPay
  20146. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20147. //
  20148. //var tempFunPays []service.CustomStruct
  20149. //for _, item := range rf {
  20150. // var tempFunPay service.CustomStruct
  20151. // tempFunPay.FundPayamt = item.FundPayamt
  20152. // tempFunPay.FundPayType = item.FundPayType
  20153. // tempFunPays = append(tempFunPays, tempFunPay)
  20154. //}
  20155. //struct4101.CustomStruct = tempFunPays
  20156. var tempDiaginfos []service.DiaginfoStructTwo
  20157. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20158. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20159. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  20160. var config []*models.HisXtDiagnoseConfig
  20161. for _, item := range diagnosis_ids {
  20162. id, _ := strconv.ParseInt(item, 10, 64)
  20163. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20164. config = append(config, &diagnosisConfig)
  20165. }
  20166. if miConfig.Code == "H15049901371" {
  20167. //for _, item := range config {
  20168. // if item.ID == 138 {
  20169. diagnosisConfig, _ := service.FindDiagnoseById(138)
  20170. var tempDiaginfo service.DiaginfoStructTwo
  20171. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  20172. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  20173. tempDiaginfo.DiagType = "1"
  20174. tempDiaginfo.MaindiagFlag = "1"
  20175. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20176. //}
  20177. //}
  20178. for _, item := range config {
  20179. if item.ID != 138 {
  20180. var tempDiaginfo service.DiaginfoStructTwo
  20181. tempDiaginfo.DiagCode = item.CountryCode
  20182. tempDiaginfo.DiagName = item.CountryContentName
  20183. tempDiaginfo.DiagType = "1"
  20184. tempDiaginfo.MaindiagFlag = "0"
  20185. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20186. }
  20187. }
  20188. } else {
  20189. for index, item := range config {
  20190. if index == 0 {
  20191. var tempDiaginfo service.DiaginfoStructTwo
  20192. tempDiaginfo.DiagCode = item.CountryCode
  20193. tempDiaginfo.DiagName = item.CountryContentName
  20194. tempDiaginfo.DiagType = "1"
  20195. tempDiaginfo.MaindiagFlag = "1"
  20196. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20197. } else {
  20198. var tempDiaginfo service.DiaginfoStructTwo
  20199. tempDiaginfo.DiagCode = item.CountryCode
  20200. tempDiaginfo.DiagName = item.CountryContentName
  20201. tempDiaginfo.DiagType = "1"
  20202. tempDiaginfo.MaindiagFlag = "0"
  20203. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20204. }
  20205. }
  20206. }
  20207. struct4101.Diseinfo = tempDiaginfos
  20208. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20209. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20210. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20211. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  20212. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  20213. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20214. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20215. var iteminfo service.IteminfoStruct
  20216. var bedCostTotal float64 = 0 //床位总费
  20217. var bedCostSelfTotal float64 = 0 //床位自费
  20218. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20219. var operationCostTotal float64 = 0 //手术费
  20220. var operationCostSelfTotal float64 = 0 //手术费
  20221. var operationCostPartSelfTotal float64 = 0 //手术费
  20222. var otherCostTotal float64 = 0 //其他费用
  20223. var otherCostSelfTotal float64 = 0 //其他费用
  20224. var otherCostPartSelfTotal float64 = 0 //其他费用
  20225. var materialCostTotal float64 = 0 //材料费
  20226. var materialCostSelfTotal float64 = 0 //材料费
  20227. var materialCostPartSelfTotal float64 = 0 //材料费
  20228. var westernMedicineCostTotal float64 = 0 //西药费
  20229. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20230. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20231. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20232. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20233. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20234. var checkCostTotal float64 = 0 //检查费
  20235. var checkCostSelfTotal float64 = 0 //检查费
  20236. var checkCostPartSelfTotal float64 = 0 //检查费
  20237. var laboratoryCostTotal float64 = 0 //化验费
  20238. var laboratoryCostSelfTotal float64 = 0 //化验费
  20239. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20240. var treatCostTotal float64 = 0 //治疗费用
  20241. var treatCostSelfTotal float64 = 0 //治疗费用
  20242. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20243. decimal.DivisionPrecision = 2
  20244. var bed_fulamt_ownpay_amt float64 = 0
  20245. var operation_fulamt_ownpay_amt float64 = 0
  20246. var other_fulamt_ownpay_amt float64 = 0
  20247. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20248. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20249. var check_fulamt_ownpay_amt float64 = 0
  20250. var material_fulamt_ownpay_amt float64 = 0
  20251. var laboratory_fulamt_ownpay_amt float64 = 0
  20252. var treat_fulamt_ownpay_amt float64 = 0
  20253. var bed_claa_sunmfee float64 = 0
  20254. var bed_clab_amt float64 = 0
  20255. var bed_other_amt float64 = 0
  20256. var operation_claa_sunmfee float64 = 0
  20257. var operation_clab_amt float64 = 0
  20258. var operation_other_amt float64 = 0
  20259. var other_claa_sunmfee float64 = 0
  20260. var other_clab_amt float64 = 0
  20261. var other_other_amt float64 = 0
  20262. var westernMedicine_claa_sunmfee float64 = 0
  20263. var westernMedicine_clab_amt float64 = 0
  20264. var westernMedicine_other_amt float64 = 0
  20265. var chineseTraditional_claa_sunmfee float64 = 0
  20266. var chineseTraditional_clab_amt float64 = 0
  20267. var chineseTraditional_other_amt float64 = 0
  20268. var check_claa_sunmfee float64 = 0
  20269. var check_clab_amt float64 = 0
  20270. var check_other_amt float64 = 0
  20271. var material_claa_sunmfee float64 = 0
  20272. var material_clab_amt float64 = 0
  20273. var material_other_amt float64 = 0
  20274. var laboratory_claa_sunmfee float64 = 0
  20275. var laboratory_clab_amt float64 = 0
  20276. var laboratory_other_amt float64 = 0
  20277. var treat_claa_sunmfee float64 = 0
  20278. var treat_clab_amt float64 = 0
  20279. var treat_other_amt float64 = 0
  20280. for _, item := range order.HisOrderInfo {
  20281. if item.MedChrgitmType == "01" { //床位费
  20282. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20283. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20284. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20285. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20286. if item.ChrgitmLv == "1" {
  20287. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20288. }
  20289. if item.ChrgitmLv == "2" {
  20290. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20291. }
  20292. if item.ChrgitmLv == "3" {
  20293. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20294. }
  20295. }
  20296. if item.MedChrgitmType == "03" { //检查费
  20297. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20298. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20299. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20300. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20301. if item.ChrgitmLv == "1" {
  20302. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20303. }
  20304. if item.ChrgitmLv == "2" {
  20305. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20306. }
  20307. if item.ChrgitmLv == "3" {
  20308. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20309. }
  20310. }
  20311. if item.MedChrgitmType == "04" { //化验费
  20312. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20313. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20314. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20315. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20316. if item.ChrgitmLv == "1" {
  20317. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20318. }
  20319. if item.ChrgitmLv == "2" {
  20320. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20321. }
  20322. if item.ChrgitmLv == "3" {
  20323. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20324. }
  20325. }
  20326. if item.MedChrgitmType == "05" { //治疗费
  20327. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20328. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20329. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20330. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20331. if item.ChrgitmLv == "1" {
  20332. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20333. }
  20334. if item.ChrgitmLv == "2" {
  20335. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20336. }
  20337. if item.ChrgitmLv == "3" {
  20338. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20339. }
  20340. }
  20341. if item.MedChrgitmType == "06" { //手术费
  20342. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20343. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20344. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20345. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20346. if item.ChrgitmLv == "1" {
  20347. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20348. }
  20349. if item.ChrgitmLv == "2" {
  20350. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20351. }
  20352. if item.ChrgitmLv == "3" {
  20353. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20354. }
  20355. }
  20356. if item.MedChrgitmType == "08" { //材料费
  20357. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20358. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20359. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20360. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20361. if item.ChrgitmLv == "1" {
  20362. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20363. }
  20364. if item.ChrgitmLv == "2" {
  20365. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20366. }
  20367. if item.ChrgitmLv == "3" {
  20368. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20369. }
  20370. }
  20371. if item.MedChrgitmType == "09" { //西药费
  20372. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20373. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20374. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20375. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20376. if item.ChrgitmLv == "1" {
  20377. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20378. }
  20379. if item.ChrgitmLv == "2" {
  20380. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20381. }
  20382. if item.ChrgitmLv == "3" {
  20383. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20384. }
  20385. }
  20386. if item.MedChrgitmType == "11" { //中成费
  20387. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20388. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20389. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20390. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20391. if item.ChrgitmLv == "1" {
  20392. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20393. }
  20394. if item.ChrgitmLv == "2" {
  20395. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20396. }
  20397. if item.ChrgitmLv == "3" {
  20398. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20399. }
  20400. }
  20401. if item.MedChrgitmType == "14" { //其他费
  20402. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20403. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20404. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20405. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20406. if item.ChrgitmLv == "1" {
  20407. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20408. }
  20409. if item.ChrgitmLv == "2" {
  20410. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20411. }
  20412. if item.ChrgitmLv == "3" {
  20413. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20414. }
  20415. }
  20416. }
  20417. var iteminfoStructs []service.IteminfoStruct
  20418. if bedCostTotal != 0 {
  20419. iteminfo.MedChrgitm = "01"
  20420. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20421. iteminfo.Amt = bedCostTotal
  20422. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20423. iteminfo.ClabAmt = bed_clab_amt
  20424. iteminfo.OthAmt = bed_other_amt
  20425. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20426. }
  20427. if checkCostTotal != 0 {
  20428. iteminfo.MedChrgitm = "03"
  20429. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20430. iteminfo.Amt = checkCostTotal
  20431. iteminfo.ClaaSumfee = check_claa_sunmfee
  20432. iteminfo.ClabAmt = check_clab_amt
  20433. iteminfo.OthAmt = check_other_amt
  20434. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20435. }
  20436. if laboratoryCostTotal != 0 {
  20437. iteminfo.MedChrgitm = "04"
  20438. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20439. iteminfo.Amt = laboratoryCostTotal
  20440. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20441. iteminfo.ClabAmt = laboratory_clab_amt
  20442. iteminfo.OthAmt = laboratory_other_amt
  20443. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20444. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20445. }
  20446. if treatCostTotal != 0 {
  20447. iteminfo.MedChrgitm = "05"
  20448. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20449. iteminfo.Amt = treatCostTotal
  20450. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20451. iteminfo.ClabAmt = treat_clab_amt
  20452. iteminfo.OthAmt = treat_other_amt
  20453. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20454. //(struct4101.IteminfoStruct, iteminfo)
  20455. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20456. }
  20457. if operationCostTotal != 0 {
  20458. iteminfo.MedChrgitm = "06"
  20459. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20460. iteminfo.Amt = operationCostTotal
  20461. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20462. iteminfo.ClabAmt = operation_clab_amt
  20463. iteminfo.OthAmt = operation_other_amt
  20464. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20465. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20466. }
  20467. if materialCostTotal != 0 {
  20468. iteminfo.MedChrgitm = "08"
  20469. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20470. iteminfo.Amt = materialCostTotal
  20471. iteminfo.ClaaSumfee = material_claa_sunmfee
  20472. iteminfo.ClabAmt = material_clab_amt
  20473. iteminfo.OthAmt = material_other_amt
  20474. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20475. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20476. }
  20477. if westernMedicineCostTotal != 0 {
  20478. iteminfo.MedChrgitm = "09"
  20479. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20480. iteminfo.Amt = westernMedicineCostTotal
  20481. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20482. iteminfo.ClabAmt = westernMedicine_clab_amt
  20483. iteminfo.OthAmt = westernMedicine_other_amt
  20484. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20485. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20486. }
  20487. if chineseTraditionalMedicineCostTotal != 0 {
  20488. iteminfo.MedChrgitm = "11"
  20489. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20490. iteminfo.Amt = westernMedicineCostTotal
  20491. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20492. iteminfo.ClabAmt = westernMedicine_clab_amt
  20493. iteminfo.OthAmt = westernMedicine_other_amt
  20494. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20495. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20496. }
  20497. if otherCostTotal != 0 {
  20498. iteminfo.MedChrgitm = "14"
  20499. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20500. iteminfo.Amt = otherCostTotal
  20501. iteminfo.ClaaSumfee = other_claa_sunmfee
  20502. iteminfo.ClabAmt = other_clab_amt
  20503. iteminfo.OthAmt = other_other_amt
  20504. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20505. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20506. }
  20507. struct4101.IteminfoStruct = iteminfoStructs
  20508. struct4101.Ntly = "中国"
  20509. struct4101.AdmCaty = "A03.06"
  20510. struct4101.DoctorName = doctor.UserName
  20511. struct4101.DoctorCode = doctor.DoctorNumber
  20512. var res ResultSeventeen
  20513. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20514. struct4101.BillCode = order.Number
  20515. struct4101.BillNo = order.SetlId
  20516. var resOther ResultSeventeenOther
  20517. var pp models.PublicParams
  20518. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20519. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20520. pp.FixmedinsName = miConfig.OrgName
  20521. pp.FixmedinsCode = miConfig.Code
  20522. pp.RequestUrl = miConfig.Url
  20523. pp.Cainfo = miConfig.Cainfo
  20524. pp.SecretKey = miConfig.SecretKey
  20525. pp.AccessKey = miConfig.AccessKey
  20526. pp.OpterName = curRoles.UserName
  20527. client := &http.Client{}
  20528. var req *http.Request
  20529. data := make(map[string]interface{})
  20530. data["struct4101"] = struct4101
  20531. data["pp"] = pp
  20532. bytesData, _ := json.Marshal(data)
  20533. if miConfig.MdtrtareaAdmvs == "320921" {
  20534. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20535. } else {
  20536. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20537. }
  20538. resp, _ := client.Do(req)
  20539. defer resp.Body.Close()
  20540. body, ioErr := ioutil.ReadAll(resp.Body)
  20541. if ioErr != nil {
  20542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20544. return
  20545. }
  20546. var respJSON map[string]interface{}
  20547. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20550. return
  20551. }
  20552. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20553. userJSONBytes, _ := json.Marshal(respJSON)
  20554. fmt.Println("log")
  20555. fmt.Println(string(userJSONBytes))
  20556. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20557. utils.ErrorLog("解析失败:%v", err)
  20558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20559. return
  20560. }
  20561. res.InfRefmsgid = resOther.InfRefmsgid
  20562. res.Output = resOther.Output
  20563. res.ErrMsg = resOther.ErrMsg
  20564. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20565. res.Infcode = infocode
  20566. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20567. var pp models.PublicParams
  20568. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20569. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20570. pp.FixmedinsName = miConfig.OrgName
  20571. pp.FixmedinsCode = miConfig.Code
  20572. pp.RequestUrl = miConfig.Url
  20573. pp.Cainfo = miConfig.Cainfo
  20574. pp.SecretKey = miConfig.SecretKey
  20575. pp.AccessKey = miConfig.AccessKey
  20576. pp.OpterName = curRoles.UserName
  20577. result, _ := service.Jxyb4101(struct4101, pp)
  20578. var dat map[string]interface{}
  20579. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20580. fmt.Println(dat)
  20581. } else {
  20582. fmt.Println(err)
  20583. }
  20584. userJSONBytes, _ := json.Marshal(dat)
  20585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20586. utils.ErrorLog("解析失败:%v", err)
  20587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20588. return
  20589. }
  20590. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20591. var pp models.PublicParams
  20592. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20593. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20594. pp.FixmedinsName = miConfig.OrgName
  20595. pp.FixmedinsCode = miConfig.Code
  20596. pp.RequestUrl = miConfig.Url
  20597. pp.Cainfo = miConfig.Cainfo
  20598. pp.SecretKey = miConfig.SecretKey
  20599. pp.AccessKey = miConfig.AccessKey
  20600. pp.OpterName = curRoles.UserName
  20601. result, _ := service.Jxyb4101(struct4101, pp)
  20602. var dat map[string]interface{}
  20603. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20604. fmt.Println(dat)
  20605. } else {
  20606. fmt.Println(err)
  20607. }
  20608. userJSONBytes, _ := json.Marshal(dat)
  20609. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20610. utils.ErrorLog("解析失败:%v", err)
  20611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20612. return
  20613. }
  20614. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20615. var pp models.PublicParams
  20616. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20617. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20618. pp.FixmedinsName = miConfig.OrgName
  20619. pp.FixmedinsCode = miConfig.Code
  20620. pp.RequestUrl = miConfig.Url
  20621. pp.Cainfo = miConfig.Cainfo
  20622. pp.SecretKey = miConfig.SecretKey
  20623. pp.AccessKey = miConfig.AccessKey
  20624. pp.OpterName = curRoles.UserName
  20625. result, _ := service.Jxyb4101(struct4101, pp)
  20626. var dat map[string]interface{}
  20627. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20628. fmt.Println(dat)
  20629. } else {
  20630. fmt.Println(err)
  20631. }
  20632. userJSONBytes, _ := json.Marshal(dat)
  20633. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20634. utils.ErrorLog("解析失败:%v", err)
  20635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20636. return
  20637. }
  20638. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20639. var pp models.PublicParams
  20640. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20641. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20642. pp.FixmedinsName = miConfig.OrgName
  20643. pp.FixmedinsCode = miConfig.Code
  20644. pp.RequestUrl = miConfig.Url
  20645. pp.Cainfo = miConfig.Cainfo
  20646. pp.SecretKey = miConfig.SecretKey
  20647. pp.AccessKey = miConfig.AccessKey
  20648. pp.OpterName = curRoles.UserName
  20649. result, _ := service.Hnyb4101(struct4101, pp)
  20650. var dat map[string]interface{}
  20651. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20652. fmt.Println(dat)
  20653. } else {
  20654. fmt.Println(err)
  20655. }
  20656. userJSONBytes, _ := json.Marshal(dat)
  20657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20658. utils.ErrorLog("解析失败:%v", err)
  20659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20660. return
  20661. }
  20662. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20663. var resOther ResultSeventeenOther
  20664. var pp models.PublicParams
  20665. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20666. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20667. pp.FixmedinsName = miConfig.OrgName
  20668. pp.FixmedinsCode = miConfig.Code
  20669. pp.RequestUrl = miConfig.Url
  20670. pp.Cainfo = miConfig.Cainfo
  20671. pp.SecretKey = miConfig.SecretKey
  20672. pp.AccessKey = miConfig.AccessKey
  20673. pp.OpterName = curRoles.UserName
  20674. client := &http.Client{}
  20675. var req *http.Request
  20676. data := make(map[string]interface{})
  20677. data["struct4101"] = struct4101
  20678. data["pp"] = pp
  20679. bytesData, _ := json.Marshal(data)
  20680. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20681. resp, _ := client.Do(req)
  20682. defer resp.Body.Close()
  20683. body, ioErr := ioutil.ReadAll(resp.Body)
  20684. if ioErr != nil {
  20685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20687. return
  20688. }
  20689. var respJSON map[string]interface{}
  20690. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20693. return
  20694. }
  20695. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20696. userJSONBytes, _ := json.Marshal(respJSON)
  20697. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20698. utils.ErrorLog("解析失败:%v", err)
  20699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20700. return
  20701. }
  20702. res.InfRefmsgid = resOther.InfRefmsgid
  20703. res.Output = resOther.Output
  20704. res.ErrMsg = resOther.ErrMsg
  20705. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20706. res.Infcode = infocode
  20707. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20708. var pp models.PublicParams
  20709. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20710. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20711. pp.FixmedinsName = miConfig.OrgName
  20712. pp.FixmedinsCode = miConfig.Code
  20713. pp.RequestUrl = miConfig.Url
  20714. pp.Cainfo = miConfig.Cainfo
  20715. pp.SecretKey = miConfig.SecretKey
  20716. pp.AccessKey = miConfig.AccessKey
  20717. pp.OpterName = curRoles.UserName
  20718. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20719. fmt.Println(requestLog)
  20720. fmt.Println(errMsgLog)
  20721. saveLog(result, requestLog, "4101a", "上传清单")
  20722. var dat map[string]interface{}
  20723. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20724. fmt.Println(dat)
  20725. } else {
  20726. fmt.Println(err)
  20727. }
  20728. userJSONBytes, _ := json.Marshal(dat)
  20729. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20730. utils.ErrorLog("解析失败:%v", err)
  20731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20732. return
  20733. }
  20734. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20735. var pp models.PublicParams
  20736. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20737. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20738. pp.FixmedinsName = miConfig.OrgName
  20739. pp.FixmedinsCode = miConfig.Code
  20740. pp.RequestUrl = miConfig.Url
  20741. pp.Cainfo = miConfig.Cainfo
  20742. pp.SecretKey = miConfig.SecretKey
  20743. pp.AccessKey = miConfig.AccessKey
  20744. pp.OpterName = curRoles.UserName
  20745. client := &http.Client{}
  20746. var req *http.Request
  20747. data := make(map[string]interface{})
  20748. data["struct4101"] = struct4101
  20749. data["pp"] = pp
  20750. bytesData, _ := json.Marshal(data)
  20751. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20752. resp, _ := client.Do(req)
  20753. defer resp.Body.Close()
  20754. body, ioErr := ioutil.ReadAll(resp.Body)
  20755. if ioErr != nil {
  20756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20758. return
  20759. }
  20760. var respJSON map[string]interface{}
  20761. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20764. return
  20765. }
  20766. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20767. userJSONBytes, _ := json.Marshal(respJSON)
  20768. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20769. utils.ErrorLog("解析失败:%v", err)
  20770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20771. return
  20772. }
  20773. } else {
  20774. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20775. var dat map[string]interface{}
  20776. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20777. fmt.Println(dat)
  20778. } else {
  20779. fmt.Println(err)
  20780. }
  20781. userJSONBytes, _ := json.Marshal(dat)
  20782. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20783. utils.ErrorLog("解析失败:%v", err)
  20784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20785. return
  20786. }
  20787. }
  20788. if res.Infcode != 0 {
  20789. c.ServeSuccessJSON(map[string]interface{}{
  20790. "failed_code": -10,
  20791. "msg": res.ErrMsg,
  20792. })
  20793. return
  20794. } else {
  20795. //order.FaPiaoNumber = zero
  20796. //order.FaPiaoCode = last_order.FaPiaoCode
  20797. //service.UpdateOrder(order)
  20798. hisFundSettleListResult := &models.HisFundSettleListResult{
  20799. Number: res.Output.SetlListId,
  20800. Status: 1,
  20801. Ctime: time.Now().Unix(),
  20802. Mtime: time.Now().Unix(),
  20803. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20804. IsUpload: 1,
  20805. OrderId: order_id,
  20806. }
  20807. service.CreateUploadRecord(hisFundSettleListResult)
  20808. c.ServeSuccessJSON(map[string]interface{}{
  20809. "msg": "上传成功",
  20810. "result": hisFundSettleListResult,
  20811. })
  20812. return
  20813. }
  20814. }
  20815. func (c *HisApiController) GetSettleListHospital() {
  20816. order_id, _ := c.GetInt64("order_id")
  20817. admin_user_id, _ := c.GetInt64("admin_user_id")
  20818. order, _ := service.GetHisOrderByIDTwo(order_id)
  20819. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20820. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  20821. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20822. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20823. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20824. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20825. if order.ID == 0 {
  20826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20827. return
  20828. }
  20829. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20830. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20831. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20832. fmt.Println(count)
  20833. var zero string
  20834. number := count + 1
  20835. if number >= 1000 {
  20836. zero = "0000" + strconv.FormatInt(number, 10)
  20837. } else if number >= 10000 {
  20838. zero = "000" + strconv.FormatInt(number, 10)
  20839. } else if number >= 100000 {
  20840. zero = "00" + strconv.FormatInt(number, 10)
  20841. } else if number >= 1000000 {
  20842. zero = "0" + strconv.FormatInt(number, 10)
  20843. } else {
  20844. zero = strconv.FormatInt(number, 10)
  20845. }
  20846. fmt.Println(zero)
  20847. struct4101 := service.Struct4101{
  20848. PsnNo: order.PsnNo,
  20849. MdtrtId: order.MdtrtId,
  20850. SetlId: order.SetlId,
  20851. PsnName: order.PsnName,
  20852. Gend: order.Gend,
  20853. Brdy: his.Brdy,
  20854. Age: int64(order.Age),
  20855. Naty: order.Naty,
  20856. PatnCertType: "01",
  20857. Certno: order.Certno,
  20858. Prfs: "90",
  20859. ConerName: roles[0].UserName,
  20860. PatnRlts: "99",
  20861. ConerAddr: miConfig.OrgName,
  20862. ConerTel: admin.Mobile,
  20863. HiType: order.Insutype,
  20864. Insuplc: miConfig.InsuplcAdmdvs,
  20865. MaindiagFlag: "1",
  20866. BillCode: order.SetlId,
  20867. BillNo: order.SetlId,
  20868. BizSn: order.Number,
  20869. PsnSelfPay: order.PsnPartAmt,
  20870. PsnOwnPay: order.PsnPartAmt,
  20871. AcctPay: order.AcctPay,
  20872. PsnCashpay: order.PsnCashPay,
  20873. HiPaymtd: "1",
  20874. Hsorg: miConfig.InsuplcAdmdvs,
  20875. HsorgOpter: miConfig.InsuplcAdmdvs,
  20876. MedinsFillPsn: curRoles.UserName,
  20877. MedinsFillDept: depart.Name,
  20878. IptMedType: "2",
  20879. AdmTime: his.InHosptialTime,
  20880. AdmEndTime: his.OutHosptialTime,
  20881. }
  20882. struct4101.SetlBegnDate = order.SetlTime
  20883. struct4101.SetlEndDate = order.SetlTime
  20884. //var rf []CustomFundPay
  20885. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20886. //
  20887. //var tempFunPays []service.CustomStruct
  20888. //for _, item := range rf {
  20889. // var tempFunPay service.CustomStruct
  20890. // tempFunPay.FundPayamt = item.FundPayamt
  20891. // tempFunPay.FundPayType = item.FundPayType
  20892. // tempFunPays = append(tempFunPays, tempFunPay)
  20893. //}
  20894. //struct4101.CustomStruct = tempFunPays
  20895. var tempDiaginfos []service.DiaginfoStructTwo
  20896. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20897. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20898. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  20899. //for _, item := range infos {
  20900. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  20901. //}
  20902. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  20903. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  20904. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20905. fmt.Println(diagnosis_ids_arr)
  20906. if order.UserOrgId == 10210 {
  20907. var diagnosis_ids_arr_two []int64
  20908. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  20909. var config []*models.HisXtDiagnoseConfig
  20910. for _, id := range diagnosis_ids_arr_two {
  20911. //id, _ := strconv.ParseInt(item, 10, 64)
  20912. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20913. if diagnosisConfig.ID > 0 {
  20914. config = append(config, &diagnosisConfig)
  20915. }
  20916. }
  20917. for index, item := range config {
  20918. if item.ID > 0 {
  20919. if index == 0 {
  20920. var tempDiaginfo service.DiaginfoStructTwo
  20921. tempDiaginfo.DiagCode = item.CountryCode
  20922. tempDiaginfo.DiagName = item.CountryContentName
  20923. tempDiaginfo.DiagType = "1"
  20924. tempDiaginfo.MaindiagFlag = "1"
  20925. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20926. } else {
  20927. var tempDiaginfo service.DiaginfoStructTwo
  20928. tempDiaginfo.DiagCode = item.CountryCode
  20929. tempDiaginfo.DiagName = item.CountryContentName
  20930. tempDiaginfo.DiagType = "1"
  20931. tempDiaginfo.MaindiagFlag = "0"
  20932. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20933. }
  20934. }
  20935. }
  20936. struct4101.Diseinfo = tempDiaginfos
  20937. } else {
  20938. var config []*models.HisXtDiagnoseConfig
  20939. for _, item := range diagnosis_ids_arr {
  20940. id, _ := strconv.ParseInt(item, 10, 64)
  20941. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20942. if diagnosisConfig.ID > 0 {
  20943. config = append(config, &diagnosisConfig)
  20944. }
  20945. }
  20946. for index, item := range config {
  20947. if item.ID > 0 {
  20948. if index == 0 {
  20949. var tempDiaginfo service.DiaginfoStructTwo
  20950. tempDiaginfo.DiagCode = item.CountryCode
  20951. tempDiaginfo.DiagName = item.CountryContentName
  20952. tempDiaginfo.DiagType = "1"
  20953. tempDiaginfo.MaindiagFlag = "1"
  20954. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20955. } else {
  20956. var tempDiaginfo service.DiaginfoStructTwo
  20957. tempDiaginfo.DiagCode = item.CountryCode
  20958. tempDiaginfo.DiagName = item.CountryContentName
  20959. tempDiaginfo.DiagType = "1"
  20960. tempDiaginfo.MaindiagFlag = "0"
  20961. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20962. }
  20963. }
  20964. }
  20965. struct4101.Diseinfo = tempDiaginfos
  20966. }
  20967. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20968. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20969. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20970. tempOpspdiseinfo2.OprnOprtCode = ""
  20971. tempOpspdiseinfo2.OprnOprtName = ""
  20972. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20973. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20974. var iteminfo service.IteminfoStruct
  20975. var bedCostTotal float64 = 0 //床位总费
  20976. var bedCostSelfTotal float64 = 0 //床位自费
  20977. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20978. var operationCostTotal float64 = 0 //手术费
  20979. var operationCostSelfTotal float64 = 0 //手术费
  20980. var operationCostPartSelfTotal float64 = 0 //手术费
  20981. var otherCostTotal float64 = 0 //其他费用
  20982. var otherCostSelfTotal float64 = 0 //其他费用
  20983. var otherCostPartSelfTotal float64 = 0 //其他费用
  20984. var materialCostTotal float64 = 0 //材料费
  20985. var materialCostSelfTotal float64 = 0 //材料费
  20986. var materialCostPartSelfTotal float64 = 0 //材料费
  20987. var westernMedicineCostTotal float64 = 0 //西药费
  20988. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20989. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20990. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20991. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20992. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20993. var checkCostTotal float64 = 0 //检查费
  20994. var checkCostSelfTotal float64 = 0 //检查费
  20995. var checkCostPartSelfTotal float64 = 0 //检查费
  20996. var laboratoryCostTotal float64 = 0 //化验费
  20997. var laboratoryCostSelfTotal float64 = 0 //化验费
  20998. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20999. var treatCostTotal float64 = 0 //治疗费用
  21000. var treatCostSelfTotal float64 = 0 //治疗费用
  21001. var treatCostPartSelfTotal float64 = 0 //治疗费用
  21002. decimal.DivisionPrecision = 2
  21003. var bed_fulamt_ownpay_amt float64 = 0
  21004. var operation_fulamt_ownpay_amt float64 = 0
  21005. var other_fulamt_ownpay_amt float64 = 0
  21006. var westernMedicine_fulamt_ownpay_amt float64 = 0
  21007. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21008. var check_fulamt_ownpay_amt float64 = 0
  21009. var material_fulamt_ownpay_amt float64 = 0
  21010. var laboratory_fulamt_ownpay_amt float64 = 0
  21011. var treat_fulamt_ownpay_amt float64 = 0
  21012. var bed_claa_sunmfee float64 = 0
  21013. var bed_clab_amt float64 = 0
  21014. var bed_other_amt float64 = 0
  21015. var operation_claa_sunmfee float64 = 0
  21016. var operation_clab_amt float64 = 0
  21017. var operation_other_amt float64 = 0
  21018. var other_claa_sunmfee float64 = 0
  21019. var other_clab_amt float64 = 0
  21020. var other_other_amt float64 = 0
  21021. var westernMedicine_claa_sunmfee float64 = 0
  21022. var westernMedicine_clab_amt float64 = 0
  21023. var westernMedicine_other_amt float64 = 0
  21024. var chineseTraditional_claa_sunmfee float64 = 0
  21025. var chineseTraditional_clab_amt float64 = 0
  21026. var chineseTraditional_other_amt float64 = 0
  21027. var check_claa_sunmfee float64 = 0
  21028. var check_clab_amt float64 = 0
  21029. var check_other_amt float64 = 0
  21030. var material_claa_sunmfee float64 = 0
  21031. var material_clab_amt float64 = 0
  21032. var material_other_amt float64 = 0
  21033. var laboratory_claa_sunmfee float64 = 0
  21034. var laboratory_clab_amt float64 = 0
  21035. var laboratory_other_amt float64 = 0
  21036. var treat_claa_sunmfee float64 = 0
  21037. var treat_clab_amt float64 = 0
  21038. var treat_other_amt float64 = 0
  21039. for _, item := range order.HisOrderInfo {
  21040. if item.MedChrgitmType == "01" { //床位费
  21041. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21042. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21043. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21044. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21045. if item.ChrgitmLv == "1" {
  21046. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21047. }
  21048. if item.ChrgitmLv == "2" {
  21049. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21050. }
  21051. if item.ChrgitmLv == "3" {
  21052. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21053. }
  21054. }
  21055. if item.MedChrgitmType == "03" { //检查费
  21056. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21057. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21058. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21059. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21060. if item.ChrgitmLv == "1" {
  21061. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21062. }
  21063. if item.ChrgitmLv == "2" {
  21064. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21065. }
  21066. if item.ChrgitmLv == "3" {
  21067. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21068. }
  21069. }
  21070. if item.MedChrgitmType == "04" { //化验费
  21071. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21072. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21073. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21074. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21075. if item.ChrgitmLv == "1" {
  21076. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21077. }
  21078. if item.ChrgitmLv == "2" {
  21079. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21080. }
  21081. if item.ChrgitmLv == "3" {
  21082. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21083. }
  21084. }
  21085. if item.MedChrgitmType == "05" { //治疗费
  21086. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21087. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21088. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21089. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21090. if item.ChrgitmLv == "1" {
  21091. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21092. }
  21093. if item.ChrgitmLv == "2" {
  21094. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21095. }
  21096. if item.ChrgitmLv == "3" {
  21097. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21098. }
  21099. }
  21100. if item.MedChrgitmType == "06" { //手术费
  21101. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21102. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21103. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21104. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21105. if item.ChrgitmLv == "1" {
  21106. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21107. }
  21108. if item.ChrgitmLv == "2" {
  21109. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21110. }
  21111. if item.ChrgitmLv == "3" {
  21112. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21113. }
  21114. }
  21115. if item.MedChrgitmType == "08" { //材料费
  21116. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21117. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21118. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21119. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21120. if item.ChrgitmLv == "1" {
  21121. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21122. }
  21123. if item.ChrgitmLv == "2" {
  21124. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21125. }
  21126. if item.ChrgitmLv == "3" {
  21127. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21128. }
  21129. }
  21130. if item.MedChrgitmType == "09" { //西药费
  21131. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21132. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21133. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21134. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21135. if item.ChrgitmLv == "1" {
  21136. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21137. }
  21138. if item.ChrgitmLv == "2" {
  21139. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21140. }
  21141. if item.ChrgitmLv == "3" {
  21142. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21143. }
  21144. }
  21145. if item.MedChrgitmType == "11" { //中成费
  21146. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21147. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21148. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21149. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21150. if item.ChrgitmLv == "1" {
  21151. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21152. }
  21153. if item.ChrgitmLv == "2" {
  21154. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21155. }
  21156. if item.ChrgitmLv == "3" {
  21157. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21158. }
  21159. }
  21160. if item.MedChrgitmType == "14" { //其他费
  21161. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21162. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21163. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21164. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21165. if item.ChrgitmLv == "1" {
  21166. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21167. }
  21168. if item.ChrgitmLv == "2" {
  21169. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21170. }
  21171. if item.ChrgitmLv == "3" {
  21172. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21173. }
  21174. }
  21175. }
  21176. var iteminfoStructs []service.IteminfoStruct
  21177. if bedCostTotal != 0 {
  21178. iteminfo.MedChrgitm = "01"
  21179. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21180. iteminfo.Amt = bedCostTotal
  21181. iteminfo.ClaaSumfee = bed_claa_sunmfee
  21182. iteminfo.ClabAmt = bed_clab_amt
  21183. iteminfo.OthAmt = bed_other_amt
  21184. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21185. }
  21186. if checkCostTotal != 0 {
  21187. iteminfo.MedChrgitm = "03"
  21188. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21189. iteminfo.Amt = checkCostTotal
  21190. iteminfo.ClaaSumfee = check_claa_sunmfee
  21191. iteminfo.ClabAmt = check_clab_amt
  21192. iteminfo.OthAmt = check_other_amt
  21193. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21194. }
  21195. if laboratoryCostTotal != 0 {
  21196. iteminfo.MedChrgitm = "04"
  21197. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21198. iteminfo.Amt = laboratoryCostTotal
  21199. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21200. iteminfo.ClabAmt = laboratory_clab_amt
  21201. iteminfo.OthAmt = laboratory_other_amt
  21202. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21203. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21204. }
  21205. if treatCostTotal != 0 {
  21206. iteminfo.MedChrgitm = "05"
  21207. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21208. iteminfo.Amt = treatCostTotal
  21209. iteminfo.ClaaSumfee = treat_claa_sunmfee
  21210. iteminfo.ClabAmt = treat_clab_amt
  21211. iteminfo.OthAmt = treat_other_amt
  21212. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21213. //(struct4101.IteminfoStruct, iteminfo)
  21214. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21215. }
  21216. if operationCostTotal != 0 {
  21217. iteminfo.MedChrgitm = "06"
  21218. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21219. iteminfo.Amt = operationCostTotal
  21220. iteminfo.ClaaSumfee = operation_claa_sunmfee
  21221. iteminfo.ClabAmt = operation_clab_amt
  21222. iteminfo.OthAmt = operation_other_amt
  21223. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21224. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21225. }
  21226. if materialCostTotal != 0 {
  21227. iteminfo.MedChrgitm = "08"
  21228. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21229. iteminfo.Amt = materialCostTotal
  21230. iteminfo.ClaaSumfee = material_claa_sunmfee
  21231. iteminfo.ClabAmt = material_clab_amt
  21232. iteminfo.OthAmt = material_other_amt
  21233. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21234. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21235. }
  21236. if westernMedicineCostTotal != 0 {
  21237. iteminfo.MedChrgitm = "09"
  21238. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21239. iteminfo.Amt = westernMedicineCostTotal
  21240. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21241. iteminfo.ClabAmt = westernMedicine_clab_amt
  21242. iteminfo.OthAmt = westernMedicine_other_amt
  21243. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21244. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21245. }
  21246. if chineseTraditionalMedicineCostTotal != 0 {
  21247. iteminfo.MedChrgitm = "11"
  21248. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21249. iteminfo.Amt = westernMedicineCostTotal
  21250. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21251. iteminfo.ClabAmt = westernMedicine_clab_amt
  21252. iteminfo.OthAmt = westernMedicine_other_amt
  21253. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21254. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21255. }
  21256. if otherCostTotal != 0 {
  21257. iteminfo.MedChrgitm = "14"
  21258. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21259. iteminfo.Amt = otherCostTotal
  21260. iteminfo.ClaaSumfee = other_claa_sunmfee
  21261. iteminfo.ClabAmt = other_clab_amt
  21262. iteminfo.OthAmt = other_other_amt
  21263. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21264. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21265. }
  21266. struct4101.IteminfoStruct = iteminfoStructs
  21267. struct4101.Ntly = "中国"
  21268. struct4101.AdmCaty = "A03.06"
  21269. var resOther ResultSeventeenOther
  21270. var res ResultSeventeen
  21271. if miConfig.MdtrtareaAdmvs == "150499" {
  21272. var pp models.PublicParams
  21273. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21274. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21275. pp.FixmedinsName = miConfig.OrgName
  21276. pp.FixmedinsCode = miConfig.Code
  21277. pp.RequestUrl = miConfig.Url
  21278. pp.Cainfo = miConfig.Cainfo
  21279. pp.SecretKey = miConfig.SecretKey
  21280. pp.AccessKey = miConfig.AccessKey
  21281. pp.OpterName = curRoles.UserName
  21282. client := &http.Client{}
  21283. var req *http.Request
  21284. data := make(map[string]interface{})
  21285. data["struct4101"] = struct4101
  21286. data["pp"] = pp
  21287. bytesData, _ := json.Marshal(data)
  21288. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  21289. resp, _ := client.Do(req)
  21290. defer resp.Body.Close()
  21291. body, ioErr := ioutil.ReadAll(resp.Body)
  21292. if ioErr != nil {
  21293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21295. return
  21296. }
  21297. var respJSON map[string]interface{}
  21298. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21301. return
  21302. }
  21303. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21304. userJSONBytes, _ := json.Marshal(respJSON)
  21305. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  21306. utils.ErrorLog("解析失败:%v", err)
  21307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21308. return
  21309. }
  21310. res.InfRefmsgid = resOther.InfRefmsgid
  21311. res.Output = resOther.Output
  21312. res.ErrMsg = resOther.ErrMsg
  21313. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  21314. res.Infcode = infocode
  21315. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21316. var pp models.PublicParams
  21317. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21318. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21319. pp.FixmedinsName = miConfig.OrgName
  21320. pp.FixmedinsCode = miConfig.Code
  21321. pp.RequestUrl = miConfig.Url
  21322. pp.Cainfo = miConfig.Cainfo
  21323. pp.SecretKey = miConfig.SecretKey
  21324. pp.AccessKey = miConfig.AccessKey
  21325. pp.OpterName = curRoles.UserName
  21326. result, _ := service.Jxyb4101(struct4101, pp)
  21327. var dat map[string]interface{}
  21328. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21329. fmt.Println(dat)
  21330. } else {
  21331. fmt.Println(err)
  21332. }
  21333. userJSONBytes, _ := json.Marshal(dat)
  21334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21335. utils.ErrorLog("解析失败:%v", err)
  21336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21337. return
  21338. }
  21339. } else if miConfig.MdtrtareaAdmvs == "361025" {
  21340. var pp models.PublicParams
  21341. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21342. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21343. pp.FixmedinsName = miConfig.OrgName
  21344. pp.FixmedinsCode = miConfig.Code
  21345. pp.RequestUrl = miConfig.Url
  21346. pp.Cainfo = miConfig.Cainfo
  21347. pp.SecretKey = miConfig.SecretKey
  21348. pp.AccessKey = miConfig.AccessKey
  21349. pp.OpterName = curRoles.UserName
  21350. result, _ := service.Jxyb4101(struct4101, pp)
  21351. var dat map[string]interface{}
  21352. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21353. fmt.Println(dat)
  21354. } else {
  21355. fmt.Println(err)
  21356. }
  21357. userJSONBytes, _ := json.Marshal(dat)
  21358. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21359. utils.ErrorLog("解析失败:%v", err)
  21360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21361. return
  21362. }
  21363. } else if miConfig.MdtrtareaAdmvs == "360100" {
  21364. var pp models.PublicParams
  21365. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21366. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21367. pp.FixmedinsName = miConfig.OrgName
  21368. pp.FixmedinsCode = miConfig.Code
  21369. pp.RequestUrl = miConfig.Url
  21370. pp.Cainfo = miConfig.Cainfo
  21371. pp.SecretKey = miConfig.SecretKey
  21372. pp.AccessKey = miConfig.AccessKey
  21373. pp.OpterName = curRoles.UserName
  21374. result, _ := service.Jxyb4101(struct4101, pp)
  21375. var dat map[string]interface{}
  21376. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21377. fmt.Println(dat)
  21378. } else {
  21379. fmt.Println(err)
  21380. }
  21381. userJSONBytes, _ := json.Marshal(dat)
  21382. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21383. utils.ErrorLog("解析失败:%v", err)
  21384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21385. return
  21386. }
  21387. } else {
  21388. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21389. var dat map[string]interface{}
  21390. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21391. fmt.Println(dat)
  21392. } else {
  21393. fmt.Println(err)
  21394. }
  21395. userJSONBytes, _ := json.Marshal(dat)
  21396. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21397. utils.ErrorLog("解析失败:%v", err)
  21398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21399. return
  21400. }
  21401. }
  21402. if res.Infcode != 0 {
  21403. c.ServeSuccessJSON(map[string]interface{}{
  21404. "failed_code": -10,
  21405. "msg": res.ErrMsg,
  21406. })
  21407. return
  21408. } else {
  21409. if miConfig.MdtrtareaAdmvs != "150499" {
  21410. order.FaPiaoNumber = zero
  21411. order.FaPiaoCode = last_order.FaPiaoCode
  21412. service.UpdateOrder(order)
  21413. }
  21414. hisFundSettleListResult := &models.HisFundSettleListResult{
  21415. Number: res.Output.SetlListId,
  21416. Status: 1,
  21417. Ctime: time.Now().Unix(),
  21418. Mtime: time.Now().Unix(),
  21419. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21420. IsUpload: 1,
  21421. OrderId: order_id,
  21422. }
  21423. service.CreateUploadRecord(hisFundSettleListResult)
  21424. c.ServeSuccessJSON(map[string]interface{}{
  21425. "msg": "上传成功",
  21426. "result": hisFundSettleListResult,
  21427. })
  21428. return
  21429. }
  21430. }
  21431. //func (c *HisApiController) GetBatchSettleList() {
  21432. // orders, _ := service.GetAllHisOrder(10106)
  21433. // for _, item := range orders {
  21434. // order_id := item.ID
  21435. // order, _ := service.GetHisOrderByIDTwo(order_id)
  21436. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21437. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  21438. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21439. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  21440. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21441. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21442. //
  21443. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  21444. //
  21445. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  21446. //
  21447. // if order.ID == 0 {
  21448. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21449. // return
  21450. // }
  21451. // if his.BalanceAccountsType == 2 {
  21452. // continue
  21453. // }
  21454. // struct4101 := service.Struct4101{
  21455. // PsnNo: order.PsnNo,
  21456. // MdtrtId: order.MdtrtId,
  21457. // SetlId: order.SetlId,
  21458. // PsnName: order.PsnName,
  21459. // Gend: order.Gend,
  21460. // Brdy: his.Brdy,
  21461. // Age: his.Age,
  21462. // Naty: order.Naty,
  21463. // PatnCertType: "01",
  21464. // Certno: order.Certno,
  21465. // Prfs: "90",
  21466. // ConerName: roles[0].UserName,
  21467. // PatnRlts: "99",
  21468. // ConerAddr: miConfig.OrgName,
  21469. // ConerTel: admin.Mobile,
  21470. // HiType: order.Insutype,
  21471. // Insuplc: his.InsuplcAdmdvs,
  21472. // MaindiagFlag: "1",
  21473. // BillCode: order.SetlId,
  21474. // BillNo: order.SetlId,
  21475. // BizSn: order.Number,
  21476. // PsnSelfPay: order.PsnPartAmt,
  21477. // PsnOwnPay: order.PsnPartAmt,
  21478. // AcctPay: order.AcctPay,
  21479. // PsnCashpay: order.PsnCashPay,
  21480. // HiPaymtd: "1",
  21481. // Hsorg: his.InsuplcAdmdvs,
  21482. // HsorgOpter: his.InsuplcAdmdvs,
  21483. // MedinsFillPsn: curRoles.UserName,
  21484. // MedinsFillDept: depart.Name,
  21485. // IptMedType: "2",
  21486. // }
  21487. // struct4101.SetlBegnDate = order.SetlTime
  21488. // struct4101.SetlEndDate = order.SetlTime
  21489. // //if order.SettleType == 1 {
  21490. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  21491. // // dateStr := t.Format("2006-01-02")
  21492. // // struct4101.SetlBegnDate = dateStr
  21493. // // struct4101.SetlEndDate = dateStr
  21494. // //} else {
  21495. // // t := time.Unix(int64(order.SettleStartTime), 0)
  21496. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  21497. // // dateStartStr := t.Format("2006-01-02")
  21498. // // dateEndStr := t2.Format("2006-01-02")
  21499. // // struct4101.SetlBegnDate = dateStartStr
  21500. // // struct4101.SetlEndDate = dateEndStr
  21501. // //}
  21502. //
  21503. // var rf []CustomFundPay
  21504. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  21505. //
  21506. // var tempFunPays []service.CustomStruct
  21507. // var tempFunPay610100 service.CustomStruct
  21508. //
  21509. // for _, item := range rf {
  21510. // if item.FundPayType == "610100" {
  21511. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  21512. // tempFunPay610100.FundPayType = item.FundPayType
  21513. // } else {
  21514. // var tempFunPay service.CustomStruct
  21515. // tempFunPay.FundPayamt = item.FundPayamt
  21516. // tempFunPay.FundPayType = item.FundPayType
  21517. // tempFunPays = append(tempFunPays, tempFunPay)
  21518. // }
  21519. // }
  21520. // tempFunPays = append(tempFunPays, tempFunPay610100)
  21521. // struct4101.CustomStruct = tempFunPays
  21522. //
  21523. // var tempDiaginfos []service.DiaginfoStructTwo
  21524. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21525. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21526. //
  21527. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21528. // var config []*models.HisXtDiagnoseConfig
  21529. // for _, item := range diagnosis_ids {
  21530. // id, _ := strconv.ParseInt(item, 10, 64)
  21531. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  21532. // config = append(config, &diagnosisConfig)
  21533. // }
  21534. //
  21535. // for index, item := range config {
  21536. // if index == 0 {
  21537. // var tempDiaginfo service.DiaginfoStructTwo
  21538. // tempDiaginfo.DiagCode = item.CountryCode
  21539. // tempDiaginfo.DiagName = item.CountryContentName
  21540. // tempDiaginfo.DiagType = "1"
  21541. // tempDiaginfo.MaindiagFlag = "1"
  21542. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21543. // } else {
  21544. //
  21545. // var tempDiaginfo service.DiaginfoStructTwo
  21546. // tempDiaginfo.DiagCode = item.CountryCode
  21547. // tempDiaginfo.DiagName = item.CountryContentName
  21548. // tempDiaginfo.DiagType = "2"
  21549. // tempDiaginfo.MaindiagFlag = "0"
  21550. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21551. // }
  21552. // }
  21553. // struct4101.Diseinfo = tempDiaginfos
  21554. //
  21555. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  21556. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21557. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21558. // tempOpspdiseinfo2.OprnOprtCode = ""
  21559. // tempOpspdiseinfo2.OprnOprtName = ""
  21560. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21561. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21562. //
  21563. // var iteminfo service.IteminfoStruct
  21564. //
  21565. // var bedCostTotal float64 = 0 //床位总费
  21566. // var bedCostSelfTotal float64 = 0 //床位自费
  21567. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21568. //
  21569. // var examineCostTotal float64 = 0 //诊查总费
  21570. // var examineCostSelfTotal float64 = 0 //诊查自费
  21571. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21572. //
  21573. // var nursingCostTotal float64 = 0 //护理总费
  21574. // var nursingCostSelfTotal float64 = 0 //护理自费
  21575. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21576. //
  21577. // var chineseMedicineCostTotal float64 = 0 //中成药
  21578. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21579. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21580. //
  21581. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21582. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21583. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21584. //
  21585. // var registerCostTotal float64 = 0 //一般诊疗费
  21586. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21587. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21588. //
  21589. // var operationCostTotal float64 = 0 //手术费
  21590. // var operationCostSelfTotal float64 = 0 //手术费
  21591. // var operationCostPartSelfTotal float64 = 0 //手术费
  21592. //
  21593. // var otherCostTotal float64 = 0 //其他费用
  21594. // var otherCostSelfTotal float64 = 0 //其他费用
  21595. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21596. //
  21597. // var materialCostTotal float64 = 0 //材料费
  21598. // var materialCostSelfTotal float64 = 0 //材料费
  21599. // var materialCostPartSelfTotal float64 = 0 //材料费
  21600. //
  21601. // var westernMedicineCostTotal float64 = 0 //西药费
  21602. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21603. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21604. //
  21605. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21606. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21607. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21608. //
  21609. // var checkCostTotal float64 = 0 //检查费
  21610. // var checkCostSelfTotal float64 = 0 //检查费
  21611. // var checkCostPartSelfTotal float64 = 0 //检查费
  21612. //
  21613. // var laboratoryCostTotal float64 = 0 //化验费
  21614. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21615. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21616. //
  21617. // var treatCostTotal float64 = 0 //治疗费用
  21618. // var treatCostSelfTotal float64 = 0 //治疗费用
  21619. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21620. //
  21621. // decimal.DivisionPrecision = 2
  21622. //
  21623. // var bed_fulamt_ownpay_amt float64 = 0
  21624. //
  21625. // var examine_fulamt_ownpay_amt float64 = 0
  21626. //
  21627. // var nursing_fulamt_ownpay_amt float64 = 0
  21628. //
  21629. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21630. //
  21631. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21632. //
  21633. // var register_fulamt_ownpay_amt float64 = 0
  21634. //
  21635. // var operation_fulamt_ownpay_amt float64 = 0
  21636. // var other_fulamt_ownpay_amt float64 = 0
  21637. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21638. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21639. // var check_fulamt_ownpay_amt float64 = 0
  21640. // var material_fulamt_ownpay_amt float64 = 0
  21641. // var laboratory_fulamt_ownpay_amt float64 = 0
  21642. // var treat_fulamt_ownpay_amt float64 = 0
  21643. //
  21644. // var bed_claa_sunmfee float64 = 0
  21645. // var bed_clab_amt float64 = 0
  21646. // var bed_other_amt float64 = 0
  21647. //
  21648. // var examine_claa_sunmfee float64 = 0
  21649. // var examine_clab_amt float64 = 0
  21650. // var examine_other_amt float64 = 0
  21651. //
  21652. // var nursing_claa_sunmfee float64 = 0
  21653. // var nursing_clab_amt float64 = 0
  21654. // var nursing_other_amt float64 = 0
  21655. //
  21656. // var chinese_medicine_claa_sunmfee float64 = 0
  21657. // var chinese_medicine_clab_amt float64 = 0
  21658. // var chinese_medicine_other_amt float64 = 0
  21659. //
  21660. // var commonly_treatment_claa_sunmfee float64 = 0
  21661. // var commonly_treatment_clab_amt float64 = 0
  21662. // var commonly_treatment_other_amt float64 = 0
  21663. //
  21664. // var operation_claa_sunmfee float64 = 0
  21665. // var operation_clab_amt float64 = 0
  21666. // var operation_other_amt float64 = 0
  21667. //
  21668. // var other_claa_sunmfee float64 = 0
  21669. // var other_clab_amt float64 = 0
  21670. // var other_other_amt float64 = 0
  21671. //
  21672. // var westernMedicine_claa_sunmfee float64 = 0
  21673. // var westernMedicine_clab_amt float64 = 0
  21674. // var westernMedicine_other_amt float64 = 0
  21675. //
  21676. // var chineseTraditional_claa_sunmfee float64 = 0
  21677. // var chineseTraditional_clab_amt float64 = 0
  21678. // var chineseTraditional_other_amt float64 = 0
  21679. //
  21680. // var check_claa_sunmfee float64 = 0
  21681. // var check_clab_amt float64 = 0
  21682. // var check_other_amt float64 = 0
  21683. //
  21684. // var material_claa_sunmfee float64 = 0
  21685. // var material_clab_amt float64 = 0
  21686. // var material_other_amt float64 = 0
  21687. //
  21688. // var laboratory_claa_sunmfee float64 = 0
  21689. // var laboratory_clab_amt float64 = 0
  21690. // var laboratory_other_amt float64 = 0
  21691. //
  21692. // var treat_claa_sunmfee float64 = 0
  21693. // var treat_clab_amt float64 = 0
  21694. // var treat_other_amt float64 = 0
  21695. //
  21696. // var register_claa_sunmfee float64 = 0
  21697. // var register_clab_amt float64 = 0
  21698. // var register_other_amt float64 = 0
  21699. //
  21700. // for _, item := range order.HisOrderInfo {
  21701. // if item.MedChrgitmType == "01" { //床位费
  21702. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21703. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21704. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21705. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21706. // if item.ChrgitmLv == "1" {
  21707. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21708. // }
  21709. // if item.ChrgitmLv == "2" {
  21710. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21711. //
  21712. // }
  21713. // if item.ChrgitmLv == "3" {
  21714. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21715. // }
  21716. //
  21717. // }
  21718. //
  21719. // if item.MedChrgitmType == "02" { //诊查
  21720. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21721. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21722. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21723. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21724. // if item.ChrgitmLv == "1" {
  21725. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21726. // }
  21727. // if item.ChrgitmLv == "2" {
  21728. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21729. //
  21730. // }
  21731. // if item.ChrgitmLv == "3" {
  21732. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21733. // }
  21734. //
  21735. // }
  21736. //
  21737. // if item.MedChrgitmType == "03" { //检查费
  21738. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21739. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21740. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21741. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21742. // if item.ChrgitmLv == "1" {
  21743. //
  21744. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21745. //
  21746. // }
  21747. // if item.ChrgitmLv == "2" {
  21748. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21749. //
  21750. // }
  21751. // if item.ChrgitmLv == "3" {
  21752. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21753. // }
  21754. // }
  21755. //
  21756. // if item.MedChrgitmType == "04" { //化验费
  21757. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21758. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21759. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21760. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21761. // if item.ChrgitmLv == "1" {
  21762. //
  21763. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21764. //
  21765. // }
  21766. // if item.ChrgitmLv == "2" {
  21767. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21768. //
  21769. // }
  21770. // if item.ChrgitmLv == "3" {
  21771. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21772. // }
  21773. // }
  21774. //
  21775. // if item.MedChrgitmType == "05" { //治疗费
  21776. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21777. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21778. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21779. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21780. // if item.ChrgitmLv == "1" {
  21781. //
  21782. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21783. //
  21784. // }
  21785. // if item.ChrgitmLv == "2" {
  21786. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21787. //
  21788. // }
  21789. // if item.ChrgitmLv == "3" {
  21790. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21791. // }
  21792. // }
  21793. //
  21794. // if item.MedChrgitmType == "06" { //手术费
  21795. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21796. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21797. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21798. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21799. //
  21800. // if item.ChrgitmLv == "1" {
  21801. //
  21802. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21803. //
  21804. // }
  21805. // if item.ChrgitmLv == "2" {
  21806. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21807. //
  21808. // }
  21809. // if item.ChrgitmLv == "3" {
  21810. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21811. // }
  21812. // }
  21813. //
  21814. // if item.MedChrgitmType == "07" { //手术费
  21815. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21816. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21817. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21818. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21819. //
  21820. // if item.ChrgitmLv == "1" {
  21821. //
  21822. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21823. //
  21824. // }
  21825. // if item.ChrgitmLv == "2" {
  21826. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21827. //
  21828. // }
  21829. // if item.ChrgitmLv == "3" {
  21830. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21831. // }
  21832. // }
  21833. //
  21834. // if item.MedChrgitmType == "08" { //材料费
  21835. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21836. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21837. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21838. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21839. // if item.ChrgitmLv == "1" {
  21840. //
  21841. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21842. //
  21843. // }
  21844. // if item.ChrgitmLv == "2" {
  21845. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21846. //
  21847. // }
  21848. // if item.ChrgitmLv == "3" {
  21849. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21850. // }
  21851. // }
  21852. // if item.MedChrgitmType == "09" { //西药费
  21853. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21854. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21855. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21856. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21857. // if item.ChrgitmLv == "1" {
  21858. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21859. // }
  21860. // if item.ChrgitmLv == "2" {
  21861. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21862. // }
  21863. // if item.ChrgitmLv == "3" {
  21864. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21865. // }
  21866. // }
  21867. // if item.MedChrgitmType == "10" { //中药饮片
  21868. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21869. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21870. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21871. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21872. // if item.ChrgitmLv == "1" {
  21873. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21874. // }
  21875. // if item.ChrgitmLv == "2" {
  21876. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21877. // }
  21878. // if item.ChrgitmLv == "3" {
  21879. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21880. // }
  21881. // }
  21882. //
  21883. // if item.MedChrgitmType == "11" { //中成费
  21884. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21885. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21886. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21887. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21888. // if item.ChrgitmLv == "1" {
  21889. //
  21890. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21891. //
  21892. // }
  21893. // if item.ChrgitmLv == "2" {
  21894. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21895. //
  21896. // }
  21897. // if item.ChrgitmLv == "3" {
  21898. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21899. // }
  21900. // }
  21901. //
  21902. // if item.MedChrgitmType == "12" { //中成费
  21903. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21904. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21905. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21906. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21907. // if item.ChrgitmLv == "1" {
  21908. //
  21909. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21910. //
  21911. // }
  21912. // if item.ChrgitmLv == "2" {
  21913. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21914. //
  21915. // }
  21916. // if item.ChrgitmLv == "3" {
  21917. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21918. // }
  21919. // }
  21920. //
  21921. // if item.MedChrgitmType == "13" { //中成费
  21922. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21923. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21924. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21925. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21926. // if item.ChrgitmLv == "1" {
  21927. //
  21928. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21929. //
  21930. // }
  21931. // if item.ChrgitmLv == "2" {
  21932. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21933. //
  21934. // }
  21935. // if item.ChrgitmLv == "3" {
  21936. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21937. // }
  21938. // }
  21939. //
  21940. // if item.MedChrgitmType == "14" { //其他费
  21941. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21942. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21943. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21944. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21945. // if item.ChrgitmLv == "1" {
  21946. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21947. //
  21948. // }
  21949. // if item.ChrgitmLv == "2" {
  21950. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21951. //
  21952. // }
  21953. // if item.ChrgitmLv == "3" {
  21954. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21955. // }
  21956. // }
  21957. //
  21958. // }
  21959. //
  21960. // var iteminfoStructs []service.IteminfoStruct
  21961. //
  21962. // if bedCostTotal != 0 {
  21963. // iteminfo.MedChrgitm = "01"
  21964. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21965. // iteminfo.Amt = bedCostTotal
  21966. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  21967. // iteminfo.ClabAmt = bed_clab_amt
  21968. // iteminfo.OthAmt = bed_other_amt
  21969. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21970. // }
  21971. //
  21972. // if examineCostTotal != 0 {
  21973. // iteminfo.MedChrgitm = "02"
  21974. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  21975. // iteminfo.Amt = examineCostTotal
  21976. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  21977. // iteminfo.ClabAmt = examine_clab_amt
  21978. // iteminfo.OthAmt = examine_other_amt
  21979. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21980. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21981. // }
  21982. //
  21983. // if checkCostTotal != 0 {
  21984. // iteminfo.MedChrgitm = "03"
  21985. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21986. // iteminfo.Amt = checkCostTotal
  21987. // iteminfo.ClaaSumfee = check_claa_sunmfee
  21988. // iteminfo.ClabAmt = check_clab_amt
  21989. // iteminfo.OthAmt = check_other_amt
  21990. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21991. //
  21992. // }
  21993. //
  21994. // if laboratoryCostTotal != 0 {
  21995. // iteminfo.MedChrgitm = "04"
  21996. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21997. // iteminfo.Amt = laboratoryCostTotal
  21998. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21999. // iteminfo.ClabAmt = laboratory_clab_amt
  22000. // iteminfo.OthAmt = laboratory_other_amt
  22001. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22002. //
  22003. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22004. //
  22005. // }
  22006. //
  22007. // if treatCostTotal != 0 {
  22008. // iteminfo.MedChrgitm = "05"
  22009. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  22010. // iteminfo.Amt = treatCostTotal
  22011. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  22012. // iteminfo.ClabAmt = treat_clab_amt
  22013. // iteminfo.OthAmt = treat_other_amt
  22014. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22015. // //(struct4101.IteminfoStruct, iteminfo)
  22016. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22017. // }
  22018. //
  22019. // if operationCostTotal != 0 {
  22020. // iteminfo.MedChrgitm = "06"
  22021. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22022. // iteminfo.Amt = operationCostTotal
  22023. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  22024. // iteminfo.ClabAmt = operation_clab_amt
  22025. // iteminfo.OthAmt = operation_other_amt
  22026. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22027. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22028. // }
  22029. //
  22030. // if nursingCostTotal != 0 {
  22031. // iteminfo.MedChrgitm = "07"
  22032. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  22033. // iteminfo.Amt = nursingCostTotal
  22034. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  22035. // iteminfo.ClabAmt = nursing_clab_amt
  22036. // iteminfo.OthAmt = nursing_other_amt
  22037. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22038. // }
  22039. //
  22040. // if materialCostTotal != 0 {
  22041. // iteminfo.MedChrgitm = "08"
  22042. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  22043. // iteminfo.Amt = materialCostTotal
  22044. // iteminfo.ClaaSumfee = material_claa_sunmfee
  22045. // iteminfo.ClabAmt = material_clab_amt
  22046. // iteminfo.OthAmt = material_other_amt
  22047. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22048. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22049. // }
  22050. //
  22051. // if westernMedicineCostTotal != 0 {
  22052. // iteminfo.MedChrgitm = "09"
  22053. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22054. // iteminfo.Amt = westernMedicineCostTotal
  22055. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22056. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22057. // iteminfo.OthAmt = westernMedicine_other_amt
  22058. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22059. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22060. //
  22061. // }
  22062. //
  22063. // if chineseMedicineCostTotal != 0 {
  22064. // iteminfo.MedChrgitm = "10"
  22065. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  22066. // iteminfo.Amt = chineseMedicineCostTotal
  22067. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  22068. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  22069. // iteminfo.OthAmt = chinese_medicine_other_amt
  22070. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22071. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22072. //
  22073. // }
  22074. //
  22075. // if chineseTraditionalMedicineCostTotal != 0 {
  22076. // iteminfo.MedChrgitm = "11"
  22077. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22078. // iteminfo.Amt = westernMedicineCostTotal
  22079. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22080. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22081. // iteminfo.OthAmt = westernMedicine_other_amt
  22082. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22083. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22084. //
  22085. // }
  22086. //
  22087. // if commonlyTreatmentCostTotal != 0 {
  22088. // iteminfo.MedChrgitm = "12"
  22089. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  22090. // iteminfo.Amt = commonlyTreatmentCostTotal
  22091. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  22092. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  22093. // iteminfo.OthAmt = commonly_treatment_other_amt
  22094. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22095. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22096. //
  22097. // }
  22098. //
  22099. // if registerCostTotal != 0 {
  22100. // iteminfo.MedChrgitm = "13"
  22101. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  22102. // iteminfo.Amt = registerCostTotal
  22103. // iteminfo.ClaaSumfee = register_claa_sunmfee
  22104. // iteminfo.ClabAmt = register_clab_amt
  22105. // iteminfo.OthAmt = register_other_amt
  22106. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22107. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22108. //
  22109. // }
  22110. //
  22111. // if otherCostTotal != 0 {
  22112. // iteminfo.MedChrgitm = "14"
  22113. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  22114. // iteminfo.Amt = otherCostTotal
  22115. // iteminfo.ClaaSumfee = other_claa_sunmfee
  22116. // iteminfo.ClabAmt = other_clab_amt
  22117. // iteminfo.OthAmt = other_other_amt
  22118. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22119. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22120. //
  22121. // }
  22122. // struct4101.IteminfoStruct = iteminfoStructs
  22123. // time_arr := strings.Split(order.SetlTime, " ")
  22124. // struct4101.AdmTime = time_arr[0]
  22125. // struct4101.AdmEndTime = time_arr[0]
  22126. //
  22127. // struct4101.DoctorName = doctor.UserName
  22128. // struct4101.DoctorCode = doctor.DoctorNumber
  22129. //
  22130. // struct4101.Ntly = "中国"
  22131. // struct4101.AdmCaty = "A03.06"
  22132. // var res ResultSeventeen
  22133. // if miConfig.MdtrtareaAdmvs == "421300" {
  22134. // data := make(map[string]interface{})
  22135. // data["struct4101"] = struct4101
  22136. // data["secret_key"] = miConfig.SecretKey
  22137. // data["org_name"] = miConfig.OrgName
  22138. // data["opera"] = curRoles.UserName
  22139. // data["code"] = miConfig.Code
  22140. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22141. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22142. //
  22143. // client := &http.Client{}
  22144. // bytesData, _ := json.Marshal(data)
  22145. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22146. // resp, _ := client.Do(req)
  22147. // defer resp.Body.Close()
  22148. // body, ioErr := ioutil.ReadAll(resp.Body)
  22149. // if ioErr != nil {
  22150. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22151. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22152. // return
  22153. // }
  22154. // var respJSON map[string]interface{}
  22155. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22156. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22157. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22158. // return
  22159. // }
  22160. //
  22161. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22162. // userJSONBytes, _ := json.Marshal(respJSON)
  22163. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22164. // utils.ErrorLog("解析失败:%v", err)
  22165. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22166. // adminUser := c.GetAdminUserInfo()
  22167. // errlog := &models.HisOrderError{
  22168. // UserOrgId: adminUser.CurrentOrgId,
  22169. // Ctime: time.Now().Unix(),
  22170. // Mtime: time.Now().Unix(),
  22171. // ErrMsg: res.ErrMsg + "解析失败",
  22172. // Status: 1,
  22173. // PatientId: order_id,
  22174. // Stage: 10088,
  22175. // }
  22176. // service.CreateErrMsgLog(errlog)
  22177. // continue
  22178. // }
  22179. //
  22180. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  22181. // data := make(map[string]interface{})
  22182. // data["struct4101"] = struct4101
  22183. // data["secret_key"] = miConfig.SecretKey
  22184. // data["org_name"] = miConfig.OrgName
  22185. // data["opera"] = curRoles.UserName
  22186. // data["code"] = miConfig.Code
  22187. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22188. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22189. //
  22190. // client := &http.Client{}
  22191. // bytesData, _ := json.Marshal(data)
  22192. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22193. // resp, _ := client.Do(req)
  22194. // defer resp.Body.Close()
  22195. // body, ioErr := ioutil.ReadAll(resp.Body)
  22196. // if ioErr != nil {
  22197. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22198. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22199. // return
  22200. // }
  22201. // var respJSON map[string]interface{}
  22202. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22203. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22205. // return
  22206. // }
  22207. //
  22208. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22209. // userJSONBytes, _ := json.Marshal(respJSON)
  22210. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22211. // utils.ErrorLog("解析失败:%v", err)
  22212. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22213. // adminUser := c.GetAdminUserInfo()
  22214. // errlog := &models.HisOrderError{
  22215. // UserOrgId: adminUser.CurrentOrgId,
  22216. // Ctime: time.Now().Unix(),
  22217. // Mtime: time.Now().Unix(),
  22218. // ErrMsg: res.ErrMsg + "解析失败",
  22219. // Status: 1,
  22220. // PatientId: order_id,
  22221. // Stage: 10088,
  22222. // }
  22223. // service.CreateErrMsgLog(errlog)
  22224. // continue
  22225. // }
  22226. //
  22227. // } else {
  22228. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  22229. // fmt.Println(result)
  22230. //
  22231. // var dat map[string]interface{}
  22232. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22233. // fmt.Println(dat)
  22234. // } else {
  22235. // fmt.Println(err)
  22236. // }
  22237. // userJSONBytes, _ := json.Marshal(dat)
  22238. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22239. // utils.ErrorLog("解析失败:%v", err)
  22240. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22241. // adminUser := c.GetAdminUserInfo()
  22242. // errlog := &models.HisOrderError{
  22243. // UserOrgId: adminUser.CurrentOrgId,
  22244. // Ctime: time.Now().Unix(),
  22245. // Mtime: time.Now().Unix(),
  22246. // ErrMsg: res.ErrMsg + "解析失败",
  22247. // Status: 1,
  22248. // PatientId: order_id,
  22249. // Stage: 10106,
  22250. // }
  22251. // service.CreateErrMsgLog(errlog)
  22252. // continue
  22253. // }
  22254. // }
  22255. //
  22256. // if res.Infcode != 0 {
  22257. // adminUser := c.GetAdminUserInfo()
  22258. // errlog := &models.HisOrderError{
  22259. // UserOrgId: adminUser.CurrentOrgId,
  22260. // Ctime: time.Now().Unix(),
  22261. // Mtime: time.Now().Unix(),
  22262. // ErrMsg: res.ErrMsg,
  22263. // Status: 1,
  22264. // PatientId: order_id,
  22265. // Stage: 10106,
  22266. // }
  22267. // service.CreateErrMsgLog(errlog)
  22268. // continue
  22269. // } else {
  22270. // hisFundSettleListResult := &models.HisFundSettleListResult{
  22271. // Number: res.Output.SetlListId,
  22272. // Status: 1,
  22273. // Ctime: time.Now().Unix(),
  22274. // Mtime: time.Now().Unix(),
  22275. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  22276. // IsUpload: 1,
  22277. // OrderId: order_id,
  22278. // }
  22279. // service.CreateUploadRecord(hisFundSettleListResult)
  22280. // continue
  22281. // }
  22282. // }
  22283. //}
  22284. func (c *HisApiController) GetOrgInfo() {
  22285. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  22286. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  22287. }
  22288. func (c *HisApiController) GetHisPatientInfo() {
  22289. medical_insurance_card := c.GetString("medical_insurance_card")
  22290. id_card_type, _ := c.GetInt64("id_card_type")
  22291. id_card := c.GetString("id_card")
  22292. adminInfo := c.GetAdminUserInfo()
  22293. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22294. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22295. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  22296. IdCardNo := ""
  22297. if id_card_type == 1 {
  22298. IdCardNo = medical_insurance_card
  22299. } else if id_card_type == 2 {
  22300. IdCardNo = id_card
  22301. }
  22302. if config.IsOpen == 1 {
  22303. 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
  22304. resp, requestErr := http.Get(api)
  22305. if requestErr != nil {
  22306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22307. return
  22308. }
  22309. defer resp.Body.Close()
  22310. body, ioErr := ioutil.ReadAll(resp.Body)
  22311. if ioErr != nil {
  22312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22314. return
  22315. }
  22316. var respJSON map[string]interface{}
  22317. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22320. return
  22321. }
  22322. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22323. userJSONBytes, _ := json.Marshal(userJSON)
  22324. var res ResultTwo
  22325. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22326. utils.ErrorLog("解析失败:%v", err)
  22327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22328. return
  22329. }
  22330. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22331. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22332. infoStr := string(Iinfos)
  22333. idetinfoStr := string(Idetinfos)
  22334. if res.Infcode == 0 {
  22335. his := models.VMHisPatient{
  22336. Status: 1,
  22337. Ctime: time.Now().Unix(),
  22338. Mtime: time.Now().Unix(),
  22339. PsnNo: res.Output.Baseinfo.PsnNo,
  22340. PsnCertType: res.Output.Baseinfo.PsnCertType,
  22341. Certno: res.Output.Baseinfo.Certno,
  22342. PsnName: res.Output.Baseinfo.PsnName,
  22343. Gend: res.Output.Baseinfo.Gend,
  22344. Naty: res.Output.Baseinfo.Naty,
  22345. Iinfo: infoStr,
  22346. Idetinfo: idetinfoStr,
  22347. UserOrgId: adminInfo.CurrentOrgId,
  22348. IsReturn: 1,
  22349. IdCardType: id_card_type,
  22350. }
  22351. c.ServeSuccessJSON(map[string]interface{}{
  22352. "info": his,
  22353. })
  22354. } else {
  22355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  22356. return
  22357. }
  22358. }
  22359. }
  22360. //func GetBasBaseInfo() (jsonStr string, err error) {
  22361. //
  22362. // handle := syscall.NewLazyDLL("SSCard.dll")
  22363. // add := handle.NewProc("ReadCardBas")
  22364. // str := make([]byte, 1024)
  22365. // str1 := make([]byte, 1024)
  22366. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22367. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  22368. //
  22369. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  22370. //
  22371. // fmt.Println("> Add(4,5)的结果为:", ret)
  22372. // handle.Release()
  22373. //
  22374. // return "", nil
  22375. //
  22376. //}
  22377. //func GetQRBaseInfo() (jsonStr string, err error) {
  22378. // handle := syscall.LoadDLL("SSCard.dll")
  22379. // ReadCardBas := handle.FindProc("GetQRBase")
  22380. //
  22381. // str := make([]byte, 256)
  22382. // str1 := make([]byte, 256)
  22383. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22384. //
  22385. // fmt.Println(string(str))
  22386. // fmt.Println(r)
  22387. // return string(str), nil
  22388. //}
  22389. //func CardInit() int {
  22390. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  22391. // add := DllTestDef.MustFindProc("Init")
  22392. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22393. // if err != nil {
  22394. // fmt.Println("SSCard的运算结果为:", ret)
  22395. // }
  22396. // result := int(ret)
  22397. // return result
  22398. //}
  22399. //func CardInit() int {
  22400. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22401. // if err != nil {
  22402. // fmt.Println("SSCard的运算结果为:", ret)
  22403. // }
  22404. // fmt.Println(err)
  22405. // result := int(ret)
  22406. // return result
  22407. //}
  22408. func IntPtr(n int) uintptr {
  22409. return uintptr(n)
  22410. }
  22411. func StrPtr(s string) uintptr {
  22412. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  22413. }
  22414. type Result2001 struct {
  22415. Cainfo interface{} `json:"cainfo"`
  22416. ErrMsg string `json:"err_msg"`
  22417. InfRefmsgid string `json:"inf_refmsgid"`
  22418. Infcode int64 `json:"infcode"`
  22419. Output struct {
  22420. Trtinfo struct {
  22421. PsnNo string `json:"psn_no"`
  22422. TrtChkType string `json:"trt_chk_type"`
  22423. FundPayType string `json:"fund_pay_type"`
  22424. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22425. Begndate string `json:"begndate"`
  22426. Enddate string `json:"enddate"`
  22427. TrtChkRslt string `json:"trt_chk_rslt"`
  22428. } `json:"trtinfo"`
  22429. } `json:"output"`
  22430. RefmsgTime string `json:"refmsg_time"`
  22431. RespondTime string `json:"respond_time"`
  22432. Signtype interface{} `json:"signtype"`
  22433. WarnMsg interface{} `json:"warn_msg"`
  22434. }
  22435. type Result2001Org10265 struct {
  22436. Cainfo interface{} `json:"cainfo"`
  22437. ErrMsg string `json:"err_msg"`
  22438. InfRefmsgid string `json:"inf_refmsgid"`
  22439. Infcode string `json:"infcode"`
  22440. Output struct {
  22441. Trtinfo struct {
  22442. PsnNo string `json:"psn_no"`
  22443. TrtChkType string `json:"trt_chk_type"`
  22444. FundPayType string `json:"fund_pay_type"`
  22445. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22446. Begndate string `json:"begndate"`
  22447. Enddate string `json:"enddate"`
  22448. TrtChkRslt string `json:"trt_chk_rslt"`
  22449. } `json:"trtinfo"`
  22450. } `json:"output"`
  22451. RefmsgTime string `json:"refmsg_time"`
  22452. RespondTime string `json:"respond_time"`
  22453. Signtype interface{} `json:"signtype"`
  22454. WarnMsg interface{} `json:"warn_msg"`
  22455. }
  22456. type ResultTwo struct {
  22457. ErrMsg string `json:"err_msg"`
  22458. InfRefmsgid string `json:"inf_refmsgid"`
  22459. Infcode int64 `json:"infcode"`
  22460. Output struct {
  22461. Baseinfo struct {
  22462. //Brdy string `json:"brdy"`
  22463. Certno string `json:"certno"`
  22464. Gend string `json:"gend"`
  22465. Naty string `json:"naty"`
  22466. PsnCertType string `json:"psn_cert_type"`
  22467. PsnName string `json:"psn_name"`
  22468. PsnNo string `json:"psn_no"`
  22469. } `json:"baseinfo"`
  22470. Idetinfo []interface{} `json:"idetinfo"`
  22471. Iinfo []struct {
  22472. Balc float64 `json:"balc"`
  22473. CvlservFlag string `json:"cvlserv_flag"`
  22474. EmpName string `json:"emp_name"`
  22475. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22476. Insutype string `json:"insutype"`
  22477. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22478. //PausInsuDate string `json:"paus_insu_date"`
  22479. //PsnInsuDate string `json:"psn_insu_date"`
  22480. PsnInsuStas string `json:"psn_insu_stas"`
  22481. PsnType string `json:"psn_type"`
  22482. } `json:"insuinfo"`
  22483. } `json:"output"`
  22484. RefmsgTime string `json:"refmsg_time"`
  22485. RespondTime string `json:"respond_time"`
  22486. Signtype interface{} `json:"signtype"`
  22487. WarnInfo interface{} `json:"warn_info"`
  22488. }
  22489. type ResultTwo10265 struct {
  22490. ErrMsg string `json:"err_msg"`
  22491. InfRefmsgid string `json:"inf_refmsgid"`
  22492. Infcode string `json:"infcode"`
  22493. Output struct {
  22494. Baseinfo struct {
  22495. //Brdy string `json:"brdy"`
  22496. Certno string `json:"certno"`
  22497. Gend string `json:"gend"`
  22498. Naty string `json:"naty"`
  22499. PsnCertType string `json:"psn_cert_type"`
  22500. PsnName string `json:"psn_name"`
  22501. PsnNo string `json:"psn_no"`
  22502. } `json:"baseinfo"`
  22503. Idetinfo []interface{} `json:"idetinfo"`
  22504. Iinfo []struct {
  22505. Balc float64 `json:"balc"`
  22506. CvlservFlag string `json:"cvlserv_flag"`
  22507. EmpName string `json:"emp_name"`
  22508. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22509. Insutype string `json:"insutype"`
  22510. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22511. PsnInsuStas string `json:"psn_insu_stas"`
  22512. PsnType string `json:"psn_type"`
  22513. } `json:"insuinfo"`
  22514. } `json:"output"`
  22515. RefmsgTime string `json:"refmsg_time"`
  22516. RespondTime string `json:"respond_time"`
  22517. Signtype interface{} `json:"signtype"`
  22518. WarnInfo interface{} `json:"warn_info"`
  22519. }
  22520. type ResultThree struct {
  22521. Cainfo interface{} `json:"cainfo"`
  22522. ErrMsg string `json:"err_msg"`
  22523. InfRefmsgid string `json:"inf_refmsgid"`
  22524. Infcode int64 `json:"infcode"`
  22525. Output struct {
  22526. Data struct {
  22527. IptOtpNo string `json:"ipt_otp_no"`
  22528. MdtrtID string `json:"mdtrt_id"`
  22529. PsnNo string `json:"psn_no"`
  22530. } `json:"data"`
  22531. } `json:"output"`
  22532. RefmsgTime string `json:"refmsg_time"`
  22533. RespondTime string `json:"respond_time"`
  22534. Signtype interface{} `json:"signtype"`
  22535. WarnMsg interface{} `json:"warn_msg"`
  22536. }
  22537. type ResultThree10265 struct {
  22538. Cainfo interface{} `json:"cainfo"`
  22539. ErrMsg string `json:"err_msg"`
  22540. InfRefmsgid string `json:"inf_refmsgid"`
  22541. Infcode string `json:"infcode"`
  22542. Output struct {
  22543. Data struct {
  22544. IptOtpNo string `json:"ipt_otp_no"`
  22545. MdtrtID string `json:"mdtrt_id"`
  22546. PsnNo string `json:"psn_no"`
  22547. } `json:"data"`
  22548. } `json:"output"`
  22549. RefmsgTime string `json:"refmsg_time"`
  22550. RespondTime string `json:"respond_time"`
  22551. Signtype interface{} `json:"signtype"`
  22552. WarnMsg interface{} `json:"warn_msg"`
  22553. }
  22554. type ResultFour struct {
  22555. Cainfo string `json:"cainfo"`
  22556. ErrMsg string `json:"err_msg"`
  22557. InfRefmsgid string `json:"inf_refmsgid"`
  22558. Infcode int64 `json:"infcode"`
  22559. Output struct {
  22560. Result []struct {
  22561. BasMednFlag string `json:"bas_medn_flag"`
  22562. ChldMedcFlag string `json:"chld_medc_flag"`
  22563. ChrgitmLv string `json:"chrgitm_lv"`
  22564. Cnt float64 `json:"cnt"`
  22565. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22566. DrtReimFlag string `json:"drt_reim_flag"`
  22567. FeedetlSn string `json:"feedetl_sn"`
  22568. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22569. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22570. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22571. ListSpItemFlag string `json:"list_sp_item_flag"`
  22572. LmtUsedFlag string `json:"lmt_used_flag"`
  22573. MedChrgitmType string `json:"med_chrgitm_type"`
  22574. Memo string `json:"memo"`
  22575. OverlmtAmt float64 `json:"overlmt_amt"`
  22576. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22577. Pric float64 `json:"pric"`
  22578. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22579. SelfpayProp float64 `json:"selfpay_prop"`
  22580. } `json:"result"`
  22581. } `json:"output"`
  22582. RefmsgTime string `json:"refmsg_time"`
  22583. RespondTime string `json:"respond_time"`
  22584. Signtype string `json:"signtype"`
  22585. WarnMsg string `json:"warn_msg"`
  22586. }
  22587. type ResultFour10265 struct {
  22588. Cainfo string `json:"cainfo"`
  22589. ErrMsg string `json:"err_msg"`
  22590. InfRefmsgid string `json:"inf_refmsgid"`
  22591. Infcode string `json:"infcode"`
  22592. Output struct {
  22593. Result []struct {
  22594. BasMednFlag string `json:"bas_medn_flag"`
  22595. ChldMedcFlag string `json:"chld_medc_flag"`
  22596. ChrgitmLv string `json:"chrgitm_lv"`
  22597. Cnt float64 `json:"cnt"`
  22598. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22599. DrtReimFlag string `json:"drt_reim_flag"`
  22600. FeedetlSn string `json:"feedetl_sn"`
  22601. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22602. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22603. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22604. ListSpItemFlag string `json:"list_sp_item_flag"`
  22605. LmtUsedFlag string `json:"lmt_used_flag"`
  22606. MedChrgitmType string `json:"med_chrgitm_type"`
  22607. Memo string `json:"memo"`
  22608. OverlmtAmt float64 `json:"overlmt_amt"`
  22609. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22610. Pric float64 `json:"pric"`
  22611. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22612. SelfpayProp float64 `json:"selfpay_prop"`
  22613. } `json:"result"`
  22614. } `json:"output"`
  22615. RefmsgTime string `json:"refmsg_time"`
  22616. RespondTime string `json:"respond_time"`
  22617. Signtype string `json:"signtype"`
  22618. WarnMsg string `json:"warn_msg"`
  22619. }
  22620. type ResultMemo struct {
  22621. InsuAdmdvs string `json:"insuAdmdvs"`
  22622. }
  22623. // [{"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}]
  22624. type ResultIDInfo struct {
  22625. Begntime string `json:"begntime"`
  22626. Endtime string `json:"endtime"`
  22627. Memo string `json:"memo"`
  22628. }
  22629. type ResultFive struct {
  22630. Balc float64 `json:"balc"`
  22631. CvlservFlag string `json:"cvlserv_flag"`
  22632. EmpName string `json:"emp_name"`
  22633. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22634. Insutype string `json:"insutype"`
  22635. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22636. PausInsuDate string `json:"paus_insu_date"`
  22637. PsnInsuDate string `json:"psn_insu_date"`
  22638. PsnInsuStas string `json:"psn_insu_stas"`
  22639. PsnType string `json:"psn_type"`
  22640. }
  22641. type ResultSix struct {
  22642. Cainfo interface{} `json:"cainfo"`
  22643. ErrMsg string `json:"err_msg"`
  22644. InfRefmsgid string `json:"inf_refmsgid"`
  22645. Infcode int64 `json:"infcode"`
  22646. Output struct {
  22647. } `json:"output"`
  22648. RefmsgTime string `json:"refmsg_time"`
  22649. RespondTime string `json:"respond_time"`
  22650. Signtype interface{} `json:"signtype"`
  22651. WarnMsg interface{} `json:"warn_msg"`
  22652. }
  22653. type ResultSix3103 struct {
  22654. Cainfo interface{} `json:"cainfo"`
  22655. ErrMsg string `json:"err_msg"`
  22656. InfRefmsgid string `json:"inf_refmsgid"`
  22657. Infcode int64 `json:"infcode"`
  22658. RefmsgTime string `json:"refmsg_time"`
  22659. RespondTime string `json:"respond_time"`
  22660. Signtype interface{} `json:"signtype"`
  22661. WarnMsg interface{} `json:"warn_msg"`
  22662. }
  22663. type FJ3507Result struct {
  22664. Cainfo interface{} `json:"cainfo"`
  22665. ErrMsg string `json:"err_msg"`
  22666. InfRefmsgid string `json:"inf_refmsgid"`
  22667. Infcode int64 `json:"infcode"`
  22668. Output struct {
  22669. retRslt string `json:"retRslt"`
  22670. msgRslt string `json:"msgRslt"`
  22671. } `json:"output"`
  22672. RefmsgTime string `json:"refmsg_time"`
  22673. RespondTime string `json:"respond_time"`
  22674. Signtype interface{} `json:"signtype"`
  22675. WarnMsg interface{} `json:"warn_msg"`
  22676. }
  22677. type FJ3507ResultFor10188 struct {
  22678. Cainfo interface{} `json:"cainfo"`
  22679. ErrMsg string `json:"err_msg"`
  22680. InfRefmsgid string `json:"inf_refmsgid"`
  22681. Infcode string `json:"infcode"`
  22682. RefmsgTime string `json:"refmsg_time"`
  22683. RespondTime string `json:"respond_time"`
  22684. Signtype interface{} `json:"signtype"`
  22685. WarnMsg interface{} `json:"warn_msg"`
  22686. }
  22687. type Result2406 struct {
  22688. Cainfo interface{} `json:"cainfo"`
  22689. ErrMsg string `json:"err_msg"`
  22690. InfRefmsgid string `json:"inf_refmsgid"`
  22691. Infcode int64 `json:"infcode"`
  22692. Output struct {
  22693. Result struct {
  22694. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22695. } `json:"result"`
  22696. } `json:"output"`
  22697. RefmsgTime string `json:"refmsg_time"`
  22698. RespondTime string `json:"respond_time"`
  22699. Signtype interface{} `json:"signtype"`
  22700. WarnMsg interface{} `json:"warn_msg"`
  22701. }
  22702. type GZResultSix struct {
  22703. Cainfo interface{} `json:"cainfo"`
  22704. ErrMsg string `json:"err_msg"`
  22705. InfRefmsgid string `json:"inf_refmsgid"`
  22706. Infcode int64 `json:"infcode"`
  22707. Output string `json:"output"`
  22708. RefmsgTime string `json:"refmsg_time"`
  22709. RespondTime string `json:"respond_time"`
  22710. Signtype interface{} `json:"signtype"`
  22711. WarnMsg interface{} `json:"warn_msg"`
  22712. }
  22713. type ResultSix10265 struct {
  22714. Cainfo interface{} `json:"cainfo"`
  22715. ErrMsg string `json:"err_msg"`
  22716. InfRefmsgid string `json:"inf_refmsgid"`
  22717. Infcode string `json:"infcode"`
  22718. Output struct {
  22719. } `json:"output"`
  22720. RefmsgTime string `json:"refmsg_time"`
  22721. RespondTime string `json:"respond_time"`
  22722. Signtype interface{} `json:"signtype"`
  22723. WarnMsg interface{} `json:"warn_msg"`
  22724. }
  22725. type ResultSeven struct {
  22726. Cainfo string `json:"cainfo"`
  22727. ErrMsg string `json:"err_msg"`
  22728. InfRefmsgid string `json:"inf_refmsgid"`
  22729. Infcode int64 `json:"infcode"`
  22730. Output struct {
  22731. Setlinfo struct {
  22732. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22733. AcctPay float64 `json:"acct_pay"`
  22734. ActPayDedc float64 `json:"act_pay_dedc"`
  22735. Age float64 `json:"age"`
  22736. Balc float64 `json:"balc"`
  22737. Certno string `json:"certno"`
  22738. ClrOptins string `json:"clr_optins"`
  22739. ClrType string `json:"clr_type"`
  22740. ClrWay string `json:"clr_way"`
  22741. CvlservFlag string `json:"cvlserv_flag"`
  22742. CvlservPay float64 `json:"cvlserv_pay"`
  22743. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22744. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22745. Gend string `json:"gend"`
  22746. HifesPay float64 `json:"hifes_pay"`
  22747. HifmiPay float64 `json:"hifmi_pay"`
  22748. HifpPay float64 `json:"hifp_pay"`
  22749. HospPartAmt float64 `json:"hosp_part_amt"`
  22750. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22751. Insutype string `json:"insutype"`
  22752. MafPay float64 `json:"maf_pay"`
  22753. MdtrtCertType string `json:"mdtrt_cert_type"`
  22754. HifobPay float64 `json:"hifob_pay"`
  22755. MdtrtID string `json:"mdtrt_id"`
  22756. MedType string `json:"med_type"`
  22757. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22758. MedinsSetlID string `json:"medins_setl_id"`
  22759. Naty string `json:"naty"`
  22760. OthPay float64 `json:"oth_pay"`
  22761. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22762. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22763. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22764. PsnCashPay float64 `json:"psn_cash_pay"`
  22765. PsnCertType string `json:"psn_cert_type"`
  22766. PsnName string `json:"psn_name"`
  22767. PsnNo string `json:"psn_no"`
  22768. PsnPartAmt float64 `json:"psn_part_amt"`
  22769. PsnType string `json:"psn_type"`
  22770. SetlID string `json:"setl_id"`
  22771. SetlTime string `json:"setl_time"`
  22772. } `json:"setlinfo"`
  22773. Setldetail interface{} `json:"setldetail"`
  22774. } `json:"output"`
  22775. RefmsgTime string `json:"refmsg_time"`
  22776. RespondTime string `json:"respond_time"`
  22777. Signtype interface{} `json:"signtype"`
  22778. WarnMsg interface{} `json:"warn_msg"`
  22779. }
  22780. type ResultSevenAH struct {
  22781. Cainfo string `json:"cainfo"`
  22782. ErrMsg string `json:"err_msg"`
  22783. InfRefmsgid string `json:"inf_refmsgid"`
  22784. Infcode int64 `json:"infcode"`
  22785. Output struct {
  22786. Setlinfo struct {
  22787. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22788. AcctPay float64 `json:"acct_pay"`
  22789. ActPayDedc float64 `json:"act_pay_dedc"`
  22790. Age float64 `json:"age"`
  22791. Balc float64 `json:"balc"`
  22792. Certno string `json:"certno"`
  22793. ClrOptins string `json:"clr_optins"`
  22794. ClrType string `json:"clr_type"`
  22795. ClrWay string `json:"clr_way"`
  22796. CvlservFlag string `json:"cvlserv_flag"`
  22797. CvlservPay float64 `json:"cvlserv_pay"`
  22798. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22799. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22800. Gend string `json:"gend"`
  22801. HifesPay float64 `json:"hifes_pay"`
  22802. HifmiPay float64 `json:"hifmi_pay"`
  22803. HifpPay float64 `json:"hifp_pay"`
  22804. HospPartAmt float64 `json:"hosp_part_amt"`
  22805. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22806. Insutype string `json:"insutype"`
  22807. MafPay float64 `json:"maf_pay"`
  22808. MdtrtCertType string `json:"mdtrt_cert_type"`
  22809. HifobPay float64 `json:"hifob_pay"`
  22810. MdtrtID string `json:"mdtrt_id"`
  22811. MedType string `json:"med_type"`
  22812. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22813. MedinsSetlID string `json:"medins_setl_id"`
  22814. Naty string `json:"naty"`
  22815. OthPay float64 `json:"oth_pay"`
  22816. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22817. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22818. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22819. PsnCashPay float64 `json:"psn_cash_pay"`
  22820. PsnCertType string `json:"psn_cert_type"`
  22821. PsnName string `json:"psn_name"`
  22822. PsnNo string `json:"psn_no"`
  22823. PsnPartAmt float64 `json:"psn_part_amt"`
  22824. PsnType string `json:"psn_type"`
  22825. SetlID string `json:"setl_id"`
  22826. SetlTime int64 `json:"setl_time"`
  22827. } `json:"setlinfo"`
  22828. Setldetail interface{} `json:"setldetail"`
  22829. } `json:"output"`
  22830. RefmsgTime string `json:"refmsg_time"`
  22831. RespondTime string `json:"respond_time"`
  22832. Signtype interface{} `json:"signtype"`
  22833. WarnMsg interface{} `json:"warn_msg"`
  22834. }
  22835. type ResultSeven10265 struct {
  22836. Cainfo string `json:"cainfo"`
  22837. ErrMsg string `json:"err_msg"`
  22838. InfRefmsgid string `json:"inf_refmsgid"`
  22839. Infcode string `json:"infcode"`
  22840. Output struct {
  22841. Setlinfo struct {
  22842. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22843. AcctPay float64 `json:"acct_pay"`
  22844. ActPayDedc float64 `json:"act_pay_dedc"`
  22845. Age float64 `json:"age"`
  22846. Balc float64 `json:"balc"`
  22847. Certno string `json:"certno"`
  22848. ClrOptins string `json:"clr_optins"`
  22849. ClrType string `json:"clr_type"`
  22850. ClrWay string `json:"clr_way"`
  22851. CvlservFlag string `json:"cvlserv_flag"`
  22852. CvlservPay float64 `json:"cvlserv_pay"`
  22853. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22854. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22855. Gend string `json:"gend"`
  22856. HifesPay float64 `json:"hifes_pay"`
  22857. HifmiPay float64 `json:"hifmi_pay"`
  22858. HifpPay float64 `json:"hifp_pay"`
  22859. HospPartAmt float64 `json:"hosp_part_amt"`
  22860. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22861. Insutype string `json:"insutype"`
  22862. MafPay float64 `json:"maf_pay"`
  22863. MdtrtCertType string `json:"mdtrt_cert_type"`
  22864. HifobPay float64 `json:"hifob_pay"`
  22865. MdtrtID string `json:"mdtrt_id"`
  22866. MedType string `json:"med_type"`
  22867. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22868. MedinsSetlID string `json:"medins_setl_id"`
  22869. Naty string `json:"naty"`
  22870. OthPay float64 `json:"oth_pay"`
  22871. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22872. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22873. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22874. PsnCashPay float64 `json:"psn_cash_pay"`
  22875. PsnCertType string `json:"psn_cert_type"`
  22876. PsnName string `json:"psn_name"`
  22877. PsnNo string `json:"psn_no"`
  22878. PsnPartAmt float64 `json:"psn_part_amt"`
  22879. PsnType string `json:"psn_type"`
  22880. SetlID string `json:"setl_id"`
  22881. SetlTime string `json:"setl_time"`
  22882. } `json:"setlinfo"`
  22883. Setldetail interface{} `json:"setldetail"`
  22884. } `json:"output"`
  22885. RefmsgTime string `json:"refmsg_time"`
  22886. RespondTime string `json:"respond_time"`
  22887. Signtype interface{} `json:"signtype"`
  22888. WarnMsg interface{} `json:"warn_msg"`
  22889. }
  22890. type ResultSeven10265Two struct {
  22891. Cainfo string `json:"cainfo"`
  22892. ErrMsg string `json:"err_msg"`
  22893. InfRefmsgid string `json:"inf_refmsgid"`
  22894. Infcode string `json:"infcode"`
  22895. Output struct {
  22896. Setlinfo struct {
  22897. AcctMulaidPay string `json:"acct_mulaid_pay"`
  22898. AcctPay float64 `json:"acct_pay"`
  22899. ActPayDedc float64 `json:"act_pay_dedc"`
  22900. Age float64 `json:"age"`
  22901. Balc float64 `json:"balc"`
  22902. Certno string `json:"certno"`
  22903. ClrOptins string `json:"clr_optins"`
  22904. ClrType string `json:"clr_type"`
  22905. ClrWay string `json:"clr_way"`
  22906. CvlservFlag string `json:"cvlserv_flag"`
  22907. CvlservPay float64 `json:"cvlserv_pay"`
  22908. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22909. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22910. Gend string `json:"gend"`
  22911. HifesPay float64 `json:"hifes_pay"`
  22912. HifmiPay float64 `json:"hifmi_pay"`
  22913. HifpPay float64 `json:"hifp_pay"`
  22914. HospPartAmt string `json:"hosp_part_amt"`
  22915. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22916. Insutype string `json:"insutype"`
  22917. MafPay float64 `json:"maf_pay"`
  22918. MdtrtCertType string `json:"mdtrt_cert_type"`
  22919. HifobPay float64 `json:"hifob_pay"`
  22920. MdtrtID string `json:"mdtrt_id"`
  22921. MedType string `json:"med_type"`
  22922. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22923. MedinsSetlID string `json:"medins_setl_id"`
  22924. Naty string `json:"naty"`
  22925. OthPay float64 `json:"oth_pay"`
  22926. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22927. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22928. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22929. PsnCashPay float64 `json:"psn_cash_pay"`
  22930. PsnCertType string `json:"psn_cert_type"`
  22931. PsnName string `json:"psn_name"`
  22932. PsnNo string `json:"psn_no"`
  22933. PsnPartAmt float64 `json:"psn_part_amt"`
  22934. PsnType string `json:"psn_type"`
  22935. SetlID string `json:"setl_id"`
  22936. SetlTime string `json:"setl_time"`
  22937. } `json:"setlinfo"`
  22938. Setldetail interface{} `json:"setldetail"`
  22939. } `json:"output"`
  22940. RefmsgTime string `json:"refmsg_time"`
  22941. RespondTime string `json:"respond_time"`
  22942. Signtype interface{} `json:"signtype"`
  22943. WarnMsg interface{} `json:"warn_msg"`
  22944. }
  22945. type GZResultSeven10265Two struct {
  22946. Cainfo string `json:"cainfo"`
  22947. ErrMsg string `json:"err_msg"`
  22948. InfRefmsgid string `json:"inf_refmsgid"`
  22949. Infcode int64 `json:"infcode"`
  22950. Output struct {
  22951. Setlinfo struct {
  22952. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22953. AcctPay float64 `json:"acct_pay"`
  22954. ActPayDedc float64 `json:"act_pay_dedc"`
  22955. Age float64 `json:"age"`
  22956. Balc float64 `json:"balc"`
  22957. Certno string `json:"certno"`
  22958. ClrOptins string `json:"clr_optins"`
  22959. ClrType string `json:"clr_type"`
  22960. ClrWay string `json:"clr_way"`
  22961. CvlservFlag string `json:"cvlserv_flag"`
  22962. CvlservPay float64 `json:"cvlserv_pay"`
  22963. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22964. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22965. Gend string `json:"gend"`
  22966. HifesPay float64 `json:"hifes_pay"`
  22967. HifmiPay float64 `json:"hifmi_pay"`
  22968. HifpPay float64 `json:"hifp_pay"`
  22969. HospPartAmt float64 `json:"hosp_part_amt"`
  22970. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22971. Insutype string `json:"insutype"`
  22972. MafPay float64 `json:"maf_pay"`
  22973. MdtrtCertType string `json:"mdtrt_cert_type"`
  22974. HifobPay float64 `json:"hifob_pay"`
  22975. MdtrtID string `json:"mdtrt_id"`
  22976. MedType string `json:"med_type"`
  22977. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22978. MedinsSetlID string `json:"medins_setl_id"`
  22979. Naty string `json:"naty"`
  22980. OthPay float64 `json:"oth_pay"`
  22981. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22982. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  22983. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22984. PsnCashPay float64 `json:"psn_cash_pay"`
  22985. PsnCertType string `json:"psn_cert_type"`
  22986. PsnName string `json:"psn_name"`
  22987. PsnNo string `json:"psn_no"`
  22988. PsnPartAmt float64 `json:"psn_part_amt"`
  22989. PsnType string `json:"psn_type"`
  22990. SetlID string `json:"setl_id"`
  22991. SetlTime string `json:"setl_time"`
  22992. } `json:"setlinfo"`
  22993. Setldetail interface{} `json:"setldetail"`
  22994. } `json:"output"`
  22995. RefmsgTime string `json:"refmsg_time"`
  22996. RespondTime string `json:"respond_time"`
  22997. Signtype interface{} `json:"signtype"`
  22998. WarnMsg interface{} `json:"warn_msg"`
  22999. }
  23000. type ResultEight struct {
  23001. Cainfo string `json:"cainfo"`
  23002. ErrMsg string `json:"err_msg"`
  23003. InfRefmsgid string `json:"inf_refmsgid"`
  23004. Infcode int64 `json:"infcode"`
  23005. Output struct {
  23006. Stmtinfo struct {
  23007. SetlOptins string `json:"setl_optins"`
  23008. StmtRslt string `json:"stmt_rslt"`
  23009. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23010. } `json:"stmtinfo"`
  23011. } `json:"output"`
  23012. RefmsgTime string `json:"refmsg_time"`
  23013. RespondTime string `json:"respond_time"`
  23014. Signtype interface{} `json:"signtype"`
  23015. WarnMsg interface{} `json:"warn_msg"`
  23016. }
  23017. type ResultEightFor10188 struct {
  23018. Cainfo string `json:"cainfo"`
  23019. ErrMsg string `json:"err_msg"`
  23020. InfRefmsgid string `json:"inf_refmsgid"`
  23021. Infcode string `json:"infcode"`
  23022. Output struct {
  23023. Stmtinfo struct {
  23024. SetlOptins string `json:"setl_optins"`
  23025. StmtRslt string `json:"stmt_rslt"`
  23026. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23027. } `json:"stmtinfo"`
  23028. } `json:"output"`
  23029. RefmsgTime string `json:"refmsg_time"`
  23030. RespondTime string `json:"respond_time"`
  23031. Signtype interface{} `json:"signtype"`
  23032. WarnMsg interface{} `json:"warn_msg"`
  23033. }
  23034. type ResultNine struct {
  23035. Cainfo string `json:"cainfo"`
  23036. ErrMsg string `json:"err_msg"`
  23037. InfRefmsgid string `json:"inf_refmsgid"`
  23038. Infcode int64 `json:"infcode"`
  23039. Output struct {
  23040. FileQuryNo string `json:"file_qury_no"`
  23041. } `json:"output"`
  23042. RefmsgTime string `json:"refmsg_time"`
  23043. RespondTime string `json:"respond_time"`
  23044. Signtype interface{} `json:"signtype"`
  23045. WarnMsg interface{} `json:"warn_msg"`
  23046. }
  23047. type ResultTen struct {
  23048. Cainfo string `json:"cainfo"`
  23049. ErrMsg string `json:"err_msg"`
  23050. InfRefmsgid string `json:"inf_refmsgid"`
  23051. Infcode int64 `json:"infcode"`
  23052. Output struct {
  23053. Fileinfo struct {
  23054. DldEndtime string `json:"dld_endtime"`
  23055. FileQuryNo string `json:"file_qury_no"`
  23056. Filename string `json:"filename"`
  23057. } `json:"fileinfo"`
  23058. } `json:"output"`
  23059. RefmsgTime string `json:"refmsg_time"`
  23060. RespondTime string `json:"respond_time"`
  23061. Signtype interface{} `json:"signtype"`
  23062. WarnMsg interface{} `json:"warn_msg"`
  23063. }
  23064. type Result5262 struct {
  23065. ErrMsg string `json:"err_msg"`
  23066. InfRefmsgid string `json:"inf_refmsgid"`
  23067. Infcode int64 `json:"infcode"`
  23068. Output struct {
  23069. PageInfo struct {
  23070. Size int `json:"size"`
  23071. RecordCounts int `json:"record_counts"`
  23072. } `json:"page_info"`
  23073. Idetinfo []interface{} `json:"idetinfo"`
  23074. Result []struct {
  23075. SetlID string `json:"setl_id"`
  23076. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23077. MdtrtID string `json:"mdtrt_id"`
  23078. InitSetlID string `json:"init_setl_id,omitempty"`
  23079. PsnNo string `json:"psn_no"`
  23080. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23081. PsnName string `json:"psn_name"`
  23082. PsnCertType string `json:"psn_cert_type"`
  23083. Certno string `json:"certno"`
  23084. Gend string `json:"gend,omitempty"`
  23085. Naty string `json:"naty,omitempty"`
  23086. Brdy string `json:"brdy,omitempty"`
  23087. Age float64 `json:"age,omitempty"`
  23088. Insutype string `json:"insutype,omitempty"`
  23089. PsnType string `json:"psn_type"`
  23090. CvlservFlag string `json:"cvlserv_flag"`
  23091. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23092. SpPsnType string `json:"sp_psn_type,omitempty"`
  23093. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23094. ClctGrde string `json:"clct_grde,omitempty"`
  23095. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23096. NwbFlag string `json:"nwb_flag,omitempty"`
  23097. InsuAdmdvs string `json:"insu_admdvs"`
  23098. EmpNo string `json:"emp_no,omitempty"`
  23099. EmpName string `json:"emp_name,omitempty"`
  23100. EmpType string `json:"emp_type,omitempty"`
  23101. EconType string `json:"econ_type,omitempty"`
  23102. AfilIndu string `json:"afil_indu,omitempty"`
  23103. AfilRlts string `json:"afil_rlts,omitempty"`
  23104. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23105. PayLoc string `json:"pay_loc,omitempty"`
  23106. FixmedinsCode string `json:"fixmedins_code"`
  23107. FixmedinsName string `json:"fixmedins_name"`
  23108. HospLv string `json:"hosp_lv,omitempty"`
  23109. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23110. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23111. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23112. Begndate string `json:"begndate"`
  23113. Enddate string `json:"enddate"`
  23114. SetlTime string `json:"setl_time"`
  23115. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23116. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23117. MedType string `json:"med_type"`
  23118. SetlType string `json:"setl_type,omitempty"`
  23119. ClrType string `json:"clr_type,omitempty"`
  23120. ClrWay string `json:"clr_way,omitempty"`
  23121. PsnSetlway string `json:"psn_setlway,omitempty"`
  23122. ClrOptins string `json:"clr_optins,omitempty"`
  23123. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23124. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23125. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23126. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23127. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23128. DedcStd float64 `json:"dedc_std,omitempty"`
  23129. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23130. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23131. HifpPay float64 `json:"hifp_pay,omitempty"`
  23132. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23133. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23134. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23135. HifesPay float64 `json:"hifes_pay,omitempty"`
  23136. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23137. HifobPay float64 `json:"hifob_pay,omitempty"`
  23138. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23139. MafPay float64 `json:"maf_pay,omitempty"`
  23140. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23141. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23142. PsnPay float64 `json:"psn_pay,omitempty"`
  23143. AcctPay float64 `json:"acct_pay,omitempty"`
  23144. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23145. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23146. Balc float64 `json:"balc,omitempty"`
  23147. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23148. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23149. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23150. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23151. Year string `json:"year,omitempty"`
  23152. DiseNo string `json:"dise_no,omitempty"`
  23153. DiseName string `json:"dise_name,omitempty"`
  23154. Invono string `json:"invono,omitempty"`
  23155. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23156. ValiFlag string `json:"vali_flag,omitempty"`
  23157. Memo string `json:"memo,omitempty"`
  23158. Rid string `json:"rid"`
  23159. UpdtTime string `json:"updt_time,omitempty"`
  23160. CrterID string `json:"crter_id,omitempty"`
  23161. CrterName string `json:"crter_name,omitempty"`
  23162. CrteTime string `json:"crte_time,omitempty"`
  23163. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  23164. OpterID string `json:"opter_id,omitempty"`
  23165. OpterName string `json:"opter_name,omitempty"`
  23166. OptTime string `json:"opt_time,omitempty"`
  23167. OptinsNo string `json:"optins_no,omitempty"`
  23168. PoolareaNo string `json:"poolarea_no,omitempty"`
  23169. } `json:"result"`
  23170. } `json:"output"`
  23171. RefmsgTime string `json:"refmsg_time"`
  23172. RespondTime string `json:"respond_time"`
  23173. Signtype interface{} `json:"signtype"`
  23174. WarnInfo interface{} `json:"warn_info"`
  23175. }
  23176. type Result5267 struct {
  23177. ErrMsg string `json:"err_msg"`
  23178. InfRefmsgid string `json:"inf_refmsgid"`
  23179. Infcode int64 `json:"infcode"`
  23180. Output struct {
  23181. PageInfo struct {
  23182. Size int `json:"size"`
  23183. RecordCounts int `json:"record_counts"`
  23184. } `json:"pageinfo"`
  23185. Result []struct {
  23186. SetlID string `json:"setl_id"`
  23187. ClrOptins string `json:"clr_optins"`
  23188. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23189. MdtrtID string `json:"mdtrt_id"`
  23190. InitSetlID string `json:"init_setl_id,omitempty"`
  23191. PsnNo string `json:"psn_no"`
  23192. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23193. PsnName string `json:"psn_name"`
  23194. PsnCertType string `json:"psn_cert_type"`
  23195. Certno string `json:"certno"`
  23196. Gend string `json:"gend,omitempty"`
  23197. Naty string `json:"naty,omitempty"`
  23198. Brdy string `json:"brdy,omitempty"`
  23199. Age float64 `json:"age,omitempty"`
  23200. Insutype string `json:"insutype,omitempty"`
  23201. PsnType string `json:"psn_type"`
  23202. CvlservFlag string `json:"cvlserv_flag"`
  23203. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23204. SpPsnType string `json:"sp_psn_type,omitempty"`
  23205. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23206. ClctGrde string `json:"clct_grde,omitempty"`
  23207. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23208. NwbFlag string `json:"nwb_flag,omitempty"`
  23209. InsuAdmdvs string `json:"insu_admdvs"`
  23210. EmpNo string `json:"emp_no,omitempty"`
  23211. EmpName string `json:"emp_name,omitempty"`
  23212. EmpType string `json:"emp_type,omitempty"`
  23213. EconType string `json:"econ_type,omitempty"`
  23214. AfilIndu string `json:"afil_indu,omitempty"`
  23215. AfilRlts string `json:"afil_rlts,omitempty"`
  23216. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23217. PayLoc string `json:"pay_loc,omitempty"`
  23218. FixmedinsCode string `json:"fixmedins_code"`
  23219. FixmedinsName string `json:"fixmedins_name"`
  23220. HospLv string `json:"hosp_lv,omitempty"`
  23221. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23222. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23223. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23224. Begndate string `json:"begndate,omitempty"`
  23225. Enddate string `json:"enddate,omitempty"`
  23226. SetlTime string `json:"setl_time,omitempty"`
  23227. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23228. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23229. MedType string `json:"med_type"`
  23230. SetlType string `json:"setl_type,omitempty"`
  23231. ClrType string `json:"clr_type,omitempty"`
  23232. ClrWay string `json:"clr_way,omitempty"`
  23233. PsnSetlway string `json:"psn_setlway,omitempty"`
  23234. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23235. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23236. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23237. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23238. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23239. DedcStd float64 `json:"dedc_std,omitempty"`
  23240. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23241. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23242. HifpPay float64 `json:"hifp_pay,omitempty"`
  23243. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23244. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23245. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23246. HifesPay float64 `json:"hifes_pay,omitempty"`
  23247. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23248. HifobPay float64 `json:"hifob_pay,omitempty"`
  23249. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23250. MafPay float64 `json:"maf_pay,omitempty"`
  23251. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23252. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23253. PsnPay float64 `json:"psn_pay,omitempty"`
  23254. AcctPay float64 `json:"acct_pay,omitempty"`
  23255. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23256. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23257. Balc float64 `json:"balc,omitempty"`
  23258. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23259. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23260. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23261. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23262. Year string `json:"year,omitempty"`
  23263. DiseNo string `json:"dise_no,omitempty"`
  23264. DiseName string `json:"dise_name,omitempty"`
  23265. Invono string `json:"invono,omitempty"`
  23266. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23267. Memo string `json:"memo,omitempty"`
  23268. UpdtTime string `json:"updt_time,omitempty"`
  23269. OpterID string `json:"opter_id,omitempty"`
  23270. OpterName string `json:"opter_name,omitempty"`
  23271. OptTime string `json:"opt_time,omitempty"`
  23272. OptinsNo string `json:"optins_no,omitempty"`
  23273. PoolareaNo string `json:"poolarea_no,omitempty"`
  23274. } `json:"result"`
  23275. } `json:"output"`
  23276. RefmsgTime string `json:"refmsg_time"`
  23277. RespondTime string `json:"respond_time"`
  23278. Signtype interface{} `json:"signtype"`
  23279. WarnInfo interface{} `json:"warn_info"`
  23280. }
  23281. // type Autogenerated struct {
  23282. // Output struct {
  23283. // Setlinfo struct {
  23284. // SetlTime string `json:"setl_time"`
  23285. // CvlservPay float64 `json:"cvlserv_pay"`
  23286. // Year string `json:"year"`
  23287. // MedType string `json:"med_type"`
  23288. // PsnPay float64 `json:"psn_pay"`
  23289. // OpterID string `json:"opter_id"`
  23290. // Begndate string `json:"begndate"`
  23291. // FlxempeFlag string `json:"flxempe_flag"`
  23292. // HifmiPay float64 `json:"hifmi_pay"`
  23293. // PsnNo string `json:"psn_no"`
  23294. // ActPayDedc float64 `json:"act_pay_dedc"`
  23295. // MedinsSetlID interface{} `json:"medins_setl_id"`
  23296. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23297. // ClrWay string `json:"clr_way"`
  23298. // OthPay float64 `json:"oth_pay"`
  23299. // Gend string `json:"gend"`
  23300. // MdtrtID string `json:"mdtrt_id"`
  23301. // AcctPay float64 `json:"acct_pay"`
  23302. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  23303. // Insutype string `json:"insutype"`
  23304. // Invono interface{} `json:"invono"`
  23305. // Enddate string `json:"enddate"`
  23306. // CashPayamt float64 `json:"cash_payamt"`
  23307. // PsnType string `json:"psn_type"`
  23308. // FixmedinsName string `json:"fixmedins_name"`
  23309. // HifpPay float64 `json:"hifp_pay"`
  23310. // NewFlag interface{} `json:"new_flag"`
  23311. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23312. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  23313. // PayLoc string `json:"pay_loc"`
  23314. // ClrType string `json:"clr_type"`
  23315. // RefdSetlFlag string `json:"refd_setl_flag"`
  23316. // CvlservFlag string `json:"cvlserv_flag"`
  23317. // EmpName string `json:"emp_name"`
  23318. // Brdy string `json:"brdy"`
  23319. // Naty string `json:"naty"`
  23320. // Certno string `json:"certno"`
  23321. // DiseCode string `json:"dise_code"`
  23322. // FixmedinsCode string `json:"fixmedins_code"`
  23323. // DedcHospLv string `json:"dedc_hosp_lv"`
  23324. // OpterName string `json:"opter_name"`
  23325. // Balc float64 `json:"balc"`
  23326. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23327. // PsnCertType string `json:"psn_cert_type"`
  23328. // HifobPay float64 `json:"hifob_pay"`
  23329. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  23330. // HifesPay float64 `json:"hifes_pay"`
  23331. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23332. // OptTime string `json:"opt_time"`
  23333. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23334. // SetlID string `json:"setl_id"`
  23335. // MafPay float64 `json:"maf_pay"`
  23336. // PsnName string `json:"psn_name"`
  23337. // InsuOptins interface{} `json:"insu_optins"`
  23338. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23339. // ClrOptins string `json:"clr_optins"`
  23340. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23341. // DiseName string `json:"dise_name"`
  23342. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23343. // Age float64 `json:"age"`
  23344. // DtrtCertType string `json:"dtrt_cert_type"`
  23345. // HospLv string `json:"hosp_lv"`
  23346. // } `json:"setlinfo"`
  23347. // Setldetail []struct {
  23348. // FundPayType string `json:"fund_pay_type"`
  23349. // FundPayamt float64 `json:"fund_payamt"`
  23350. // SetlProcInfo interface{} `json:"setl_proc_info"`
  23351. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  23352. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  23353. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  23354. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23355. // } `json:"setldetail"`
  23356. // } `json:"output"`
  23357. // Infcode int `json:"infcode"`
  23358. // WarnMsg interface{} `json:"warn_msg"`
  23359. // Cainfo interface{} `json:"cainfo"`
  23360. // ErrMsg interface{} `json:"err_msg"`
  23361. // RefmsgTime string `json:"refmsg_time"`
  23362. // Signtype interface{} `json:"signtype"`
  23363. // RespondTime string `json:"respond_time"`
  23364. // InfRefmsgid string `json:"inf_refmsgid"`
  23365. // }
  23366. type Result002 struct {
  23367. Cainfo interface{} `json:"cainfo"`
  23368. ErrMsg string `json:"err_msg"`
  23369. InfRefmsgid string `json:"inf_refmsgid"`
  23370. Infcode int64 `json:"infcode"`
  23371. Output struct {
  23372. RxFile string `json:"rx_file"`
  23373. SignDigest string `json:"sign_digest"`
  23374. SignCertSn string `json:"sign_cert_sn"`
  23375. SignCertDn string `json:"sign_cert_dn"`
  23376. } `json:"output"`
  23377. RefmsgTime string `json:"refmsg_time"`
  23378. RespondTime string `json:"respond_time"`
  23379. Signtype interface{} `json:"signtype"`
  23380. WarnMsg interface{} `json:"warn_msg"`
  23381. }
  23382. type AhResult002 struct {
  23383. RxFile string `json:"rxFile"`
  23384. SignDigest string `json:"signDigest"`
  23385. SignCertSn string `json:"signCertSn"`
  23386. SignCertDn string `json:"signCertDn"`
  23387. }
  23388. type Result003 struct {
  23389. Cainfo interface{} `json:"cainfo"`
  23390. ErrMsg string `json:"err_msg"`
  23391. InfRefmsgid string `json:"inf_refmsgid"`
  23392. Infcode int64 `json:"infcode"`
  23393. Output struct {
  23394. HiRxno string `json:"hi_rxno"`
  23395. RxStasCodg string `json:"rx_stas_codg"`
  23396. RxStasName string `json:"rx_stas_name"`
  23397. } `json:"output"`
  23398. RefmsgTime string `json:"refmsg_time"`
  23399. RespondTime string `json:"respond_time"`
  23400. Signtype interface{} `json:"signtype"`
  23401. WarnMsg interface{} `json:"warn_msg"`
  23402. }
  23403. type AHResult003 struct {
  23404. HiRxno string `json:"hiRxno"`
  23405. RxStasCodg string `json:"rxStasCodg"`
  23406. RxStasName string `json:"rxStasName"`
  23407. }
  23408. type ResultEleven struct {
  23409. Cainfo string `json:"cainfo"`
  23410. ErrMsg string `json:"err_msg"`
  23411. InfRefmsgid string `json:"inf_refmsgid"`
  23412. Infcode int64 `json:"infcode"`
  23413. Output struct {
  23414. Setlinfo struct {
  23415. SetlTime string `json:"setl_time"`
  23416. CvlservPay float64 `json:"cvlserv_pay"`
  23417. Year string `json:"year"`
  23418. MedType string `json:"med_type"`
  23419. PsnPay float64 `json:"psn_pay"`
  23420. OpterID string `json:"opter_id"`
  23421. Begndate string `json:"begndate"`
  23422. FlxempeFlag string `json:"flxempe_flag"`
  23423. HifmiPay float64 `json:"hifmi_pay"`
  23424. PsnNo string `json:"psn_no"`
  23425. ActPayDedc float64 `json:"act_pay_dedc"`
  23426. MedinsSetlID interface{} `json:"medins_setl_id"`
  23427. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23428. ClrWay string `json:"clr_way"`
  23429. OthPay float64 `json:"oth_pay"`
  23430. Gend string `json:"gend"`
  23431. MdtrtID string `json:"mdtrt_id"`
  23432. AcctPay float64 `json:"acct_pay"`
  23433. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23434. Insutype string `json:"insutype"`
  23435. Invono interface{} `json:"invono"`
  23436. Enddate string `json:"enddate"`
  23437. CashPayamt float64 `json:"cash_payamt"`
  23438. PsnType string `json:"psn_type"`
  23439. FixmedinsName string `json:"fixmedins_name"`
  23440. HifpPay float64 `json:"hifp_pay"`
  23441. NewFlag interface{} `json:"new_flag"`
  23442. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23443. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23444. PayLoc string `json:"pay_loc"`
  23445. ClrType string `json:"clr_type"`
  23446. RefdSetlFlag string `json:"refd_setl_flag"`
  23447. CvlservFlag string `json:"cvlserv_flag"`
  23448. EmpName string `json:"emp_name"`
  23449. Brdy string `json:"brdy"`
  23450. Naty string `json:"naty"`
  23451. Certno string `json:"certno"`
  23452. DiseCode string `json:"dise_code"`
  23453. FixmedinsCode string `json:"fixmedins_code"`
  23454. DedcHospLv string `json:"dedc_hosp_lv"`
  23455. OpterName string `json:"opter_name"`
  23456. Balc float64 `json:"balc"`
  23457. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23458. PsnCertType string `json:"psn_cert_type"`
  23459. HifobPay float64 `json:"hifob_pay"`
  23460. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23461. HifesPay float64 `json:"hifes_pay"`
  23462. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23463. OptTime string `json:"opt_time"`
  23464. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23465. SetlID string `json:"setl_id"`
  23466. MafPay float64 `json:"maf_pay"`
  23467. PsnName string `json:"psn_name"`
  23468. InsuOptins interface{} `json:"insu_optins"`
  23469. PrefFundPay interface{} `json:"pref_fund_pay"`
  23470. ClrOptins string `json:"clr_optins"`
  23471. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23472. DiseName string `json:"dise_name"`
  23473. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23474. Age float64 `json:"age"`
  23475. DtrtCertType string `json:"dtrt_cert_type"`
  23476. HospLv string `json:"hosp_lv"`
  23477. PsnCashPay float64 `json:"psn_cash_pay"`
  23478. } `json:"setlinfo"`
  23479. } `json:"output"`
  23480. RefmsgTime string `json:"refmsg_time"`
  23481. RespondTime string `json:"respond_time"`
  23482. Signtype interface{} `json:"signtype"`
  23483. WarnMsg interface{} `json:"warn_msg"`
  23484. }
  23485. type ResultElevenah struct {
  23486. Cainfo string `json:"cainfo"`
  23487. ErrMsg string `json:"err_msg"`
  23488. InfRefmsgid string `json:"inf_refmsgid"`
  23489. Infcode int64 `json:"infcode"`
  23490. Output struct {
  23491. Setlinfo struct {
  23492. SetlTime int64 `json:"setl_time"`
  23493. CvlservPay float64 `json:"cvlserv_pay"`
  23494. Year string `json:"year"`
  23495. MedType string `json:"med_type"`
  23496. PsnPay float64 `json:"psn_pay"`
  23497. OpterID string `json:"opter_id"`
  23498. Begndate int64 `json:"begndate"`
  23499. FlxempeFlag string `json:"flxempe_flag"`
  23500. HifmiPay float64 `json:"hifmi_pay"`
  23501. PsnNo string `json:"psn_no"`
  23502. ActPayDedc float64 `json:"act_pay_dedc"`
  23503. MedinsSetlID interface{} `json:"medins_setl_id"`
  23504. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23505. ClrWay string `json:"clr_way"`
  23506. OthPay float64 `json:"oth_pay"`
  23507. Gend string `json:"gend"`
  23508. MdtrtID string `json:"mdtrt_id"`
  23509. AcctPay float64 `json:"acct_pay"`
  23510. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23511. Insutype string `json:"insutype"`
  23512. Invono interface{} `json:"invono"`
  23513. Enddate int64 `json:"enddate"`
  23514. CashPayamt float64 `json:"cash_payamt"`
  23515. PsnType string `json:"psn_type"`
  23516. FixmedinsName string `json:"fixmedins_name"`
  23517. HifpPay float64 `json:"hifp_pay"`
  23518. NewFlag interface{} `json:"new_flag"`
  23519. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23520. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23521. PayLoc string `json:"pay_loc"`
  23522. ClrType string `json:"clr_type"`
  23523. RefdSetlFlag string `json:"refd_setl_flag"`
  23524. CvlservFlag string `json:"cvlserv_flag"`
  23525. EmpName string `json:"emp_name"`
  23526. Brdy int64 `json:"brdy"`
  23527. Naty string `json:"naty"`
  23528. Certno string `json:"certno"`
  23529. DiseCode string `json:"dise_code"`
  23530. FixmedinsCode string `json:"fixmedins_code"`
  23531. DedcHospLv string `json:"dedc_hosp_lv"`
  23532. OpterName string `json:"opter_name"`
  23533. Balc float64 `json:"balc"`
  23534. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23535. PsnCertType string `json:"psn_cert_type"`
  23536. HifobPay float64 `json:"hifob_pay"`
  23537. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23538. HifesPay float64 `json:"hifes_pay"`
  23539. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23540. OptTime int64 `json:"opt_time"`
  23541. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23542. SetlID string `json:"setl_id"`
  23543. MafPay float64 `json:"maf_pay"`
  23544. PsnName string `json:"psn_name"`
  23545. InsuOptins interface{} `json:"insu_optins"`
  23546. PrefFundPay interface{} `json:"pref_fund_pay"`
  23547. ClrOptins string `json:"clr_optins"`
  23548. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23549. DiseName string `json:"dise_name"`
  23550. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23551. Age float64 `json:"age"`
  23552. DtrtCertType string `json:"dtrt_cert_type"`
  23553. HospLv string `json:"hosp_lv"`
  23554. PsnCashPay float64 `json:"psn_cash_pay"`
  23555. } `json:"setlinfo"`
  23556. } `json:"output"`
  23557. RefmsgTime string `json:"refmsg_time"`
  23558. RespondTime string `json:"respond_time"`
  23559. Signtype interface{} `json:"signtype"`
  23560. WarnMsg interface{} `json:"warn_msg"`
  23561. }
  23562. type ResultEleven10265 struct {
  23563. Cainfo string `json:"cainfo"`
  23564. ErrMsg string `json:"err_msg"`
  23565. InfRefmsgid string `json:"inf_refmsgid"`
  23566. Infcode string `json:"infcode"`
  23567. Output struct {
  23568. Setlinfo struct {
  23569. SetlTime string `json:"setl_time"`
  23570. CvlservPay float64 `json:"cvlserv_pay"`
  23571. Year string `json:"year"`
  23572. MedType string `json:"med_type"`
  23573. PsnPay float64 `json:"psn_pay"`
  23574. OpterID string `json:"opter_id"`
  23575. Begndate string `json:"begndate"`
  23576. FlxempeFlag string `json:"flxempe_flag"`
  23577. HifmiPay float64 `json:"hifmi_pay"`
  23578. PsnNo string `json:"psn_no"`
  23579. ActPayDedc float64 `json:"act_pay_dedc"`
  23580. MedinsSetlID interface{} `json:"medins_setl_id"`
  23581. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23582. ClrWay string `json:"clr_way"`
  23583. OthPay float64 `json:"oth_pay"`
  23584. Gend string `json:"gend"`
  23585. MdtrtID string `json:"mdtrt_id"`
  23586. AcctPay float64 `json:"acct_pay"`
  23587. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23588. Insutype string `json:"insutype"`
  23589. Invono interface{} `json:"invono"`
  23590. Enddate string `json:"enddate"`
  23591. CashPayamt float64 `json:"cash_payamt"`
  23592. PsnType string `json:"psn_type"`
  23593. FixmedinsName string `json:"fixmedins_name"`
  23594. HifpPay float64 `json:"hifp_pay"`
  23595. NewFlag interface{} `json:"new_flag"`
  23596. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23597. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23598. PayLoc string `json:"pay_loc"`
  23599. ClrType string `json:"clr_type"`
  23600. RefdSetlFlag string `json:"refd_setl_flag"`
  23601. CvlservFlag string `json:"cvlserv_flag"`
  23602. EmpName string `json:"emp_name"`
  23603. Brdy string `json:"brdy"`
  23604. Naty string `json:"naty"`
  23605. Certno string `json:"certno"`
  23606. DiseCode string `json:"dise_code"`
  23607. FixmedinsCode string `json:"fixmedins_code"`
  23608. DedcHospLv string `json:"dedc_hosp_lv"`
  23609. OpterName string `json:"opter_name"`
  23610. Balc float64 `json:"balc"`
  23611. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23612. PsnCertType string `json:"psn_cert_type"`
  23613. HifobPay float64 `json:"hifob_pay"`
  23614. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23615. HifesPay float64 `json:"hifes_pay"`
  23616. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23617. OptTime string `json:"opt_time"`
  23618. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23619. SetlID string `json:"setl_id"`
  23620. MafPay float64 `json:"maf_pay"`
  23621. PsnName string `json:"psn_name"`
  23622. InsuOptins interface{} `json:"insu_optins"`
  23623. PrefFundPay interface{} `json:"pref_fund_pay"`
  23624. ClrOptins string `json:"clr_optins"`
  23625. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23626. DiseName string `json:"dise_name"`
  23627. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23628. Age float64 `json:"age"`
  23629. DtrtCertType string `json:"dtrt_cert_type"`
  23630. HospLv string `json:"hosp_lv"`
  23631. PsnCashPay float64 `json:"psn_cash_pay"`
  23632. } `json:"setlinfo"`
  23633. } `json:"output"`
  23634. RefmsgTime string `json:"refmsg_time"`
  23635. RespondTime string `json:"respond_time"`
  23636. Signtype interface{} `json:"signtype"`
  23637. WarnMsg interface{} `json:"warn_msg"`
  23638. }
  23639. type ResultTwelve struct {
  23640. Cainfo string `json:"cainfo"`
  23641. ErrMsg string `json:"err_msg"`
  23642. InfRefmsgid string `json:"inf_refmsgid"`
  23643. Infcode int64 `json:"infcode"`
  23644. Output struct {
  23645. MdtrtId string `json:"mdtrt_id"`
  23646. ChrgBchno string `json:"chrg_bchno"`
  23647. PsnNo string `json:"psn_no"`
  23648. } `json:"output"`
  23649. RefmsgTime string `json:"refmsg_time"`
  23650. RespondTime string `json:"respond_time"`
  23651. Signtype interface{} `json:"signtype"`
  23652. WarnMsg interface{} `json:"warn_msg"`
  23653. }
  23654. type ResultThirteen struct {
  23655. ErrMsg string `json:"err_msg"`
  23656. InfRefmsgid string `json:"inf_refmsgid"`
  23657. Infcode int64 `json:"infcode"`
  23658. Output struct {
  23659. Result struct {
  23660. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23661. } `json:"result"`
  23662. } `json:"output"`
  23663. RefmsgTime string `json:"refmsg_time"`
  23664. RespondTime string `json:"respond_time"`
  23665. Signtype interface{} `json:"signtype"`
  23666. WarnInfo interface{} `json:"warn_info"`
  23667. }
  23668. type ResultThirteen10265 struct {
  23669. ErrMsg string `json:"err_msg"`
  23670. InfRefmsgid string `json:"inf_refmsgid"`
  23671. Infcode string `json:"infcode"`
  23672. Output struct {
  23673. Result struct {
  23674. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23675. } `json:"result"`
  23676. } `json:"output"`
  23677. RefmsgTime string `json:"refmsg_time"`
  23678. RespondTime string `json:"respond_time"`
  23679. Signtype interface{} `json:"signtype"`
  23680. WarnInfo interface{} `json:"warn_info"`
  23681. }
  23682. type ResultFourteen struct {
  23683. ErrMsg string `json:"err_msg"`
  23684. InfRefmsgid string `json:"inf_refmsgid"`
  23685. Infcode int64 `json:"infcode"`
  23686. Output struct {
  23687. } `json:"output"`
  23688. RefmsgTime string `json:"refmsg_time"`
  23689. RespondTime string `json:"respond_time"`
  23690. Signtype interface{} `json:"signtype"`
  23691. WarnInfo interface{} `json:"warn_info"`
  23692. }
  23693. type ResultCFYLJG001 struct {
  23694. ErrMsg string `json:"err_msg"`
  23695. InfRefmsgid string `json:"inf_refmsgid"`
  23696. Infcode int64 `json:"infcode"`
  23697. Output struct {
  23698. RxTraceCode string `json:"rx_trace_code"`
  23699. HiRxno string `json:"hi_rxno"`
  23700. } `json:"output"`
  23701. RefmsgTime string `json:"refmsg_time"`
  23702. RespondTime string `json:"respond_time"`
  23703. Signtype interface{} `json:"signtype"`
  23704. WarnInfo interface{} `json:"warn_info"`
  23705. }
  23706. type ResultCFYLJG001AH struct {
  23707. RxTraceCode string `json:"rxTraceCode"`
  23708. HiRxno string `json:"hiRxno"`
  23709. }
  23710. type ResultCFYLJG007 struct {
  23711. ErrMsg string `json:"err_msg"`
  23712. InfRefmsgid string `json:"inf_refmsgid"`
  23713. Infcode int64 `json:"infcode"`
  23714. Output struct {
  23715. HiRxno string `json:"hi_rxno"`
  23716. RxStasName string `json:"rx_stas_name"`
  23717. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  23718. Seltdelts []interface{} `json:"seltdelts"`
  23719. RxUsedStasName string `json:"rx_used_stas_name"`
  23720. RxStasCodg string `json:"rx_stas_codg"`
  23721. } `json:"output"`
  23722. RefmsgTime string `json:"refmsg_time"`
  23723. RespondTime string `json:"respond_time"`
  23724. Signtype interface{} `json:"signtype"`
  23725. WarnInfo interface{} `json:"warn_info"`
  23726. }
  23727. type ResultCFYLJG002 struct {
  23728. ErrMsg string `json:"err_msg"`
  23729. InfRefmsgid string `json:"inf_refmsgid"`
  23730. Infcode int64 `json:"infcode"`
  23731. Output struct {
  23732. RxFile string `json:"rx_file"`
  23733. SignDigest string `json:"sign_digest"`
  23734. SignCertSn string `json:"sign_cert_sn"`
  23735. SignCertDn string `json:"sign_cert_dn"`
  23736. } `json:"output"`
  23737. RefmsgTime string `json:"refmsg_time"`
  23738. RespondTime string `json:"respond_time"`
  23739. Signtype interface{} `json:"signtype"`
  23740. WarnInfo interface{} `json:"warn_info"`
  23741. }
  23742. type ResultCFYLJG003 struct {
  23743. ErrMsg string `json:"err_msg"`
  23744. InfRefmsgid string `json:"inf_refmsgid"`
  23745. Infcode int64 `json:"infcode"`
  23746. Output struct {
  23747. HiRxno string `json:"hi_rxno"`
  23748. RxStasCodg string `json:"rx_stas_codg"`
  23749. RxStasName string `json:"rx_stas_name"`
  23750. } `json:"output"`
  23751. RefmsgTime string `json:"refmsg_time"`
  23752. RespondTime string `json:"respond_time"`
  23753. Signtype interface{} `json:"signtype"`
  23754. WarnInfo interface{} `json:"warn_info"`
  23755. }
  23756. type ResultCFYLJG004 struct {
  23757. ErrMsg string `json:"err_msg"`
  23758. InfRefmsgid string `json:"inf_refmsgid"`
  23759. Infcode int64 `json:"infcode"`
  23760. Output struct {
  23761. HiRxno string `json:"hi_rxno"`
  23762. RxStasCodg string `json:"rx_stas_codg"`
  23763. RxStasName string `json:"rx_stas_name"`
  23764. } `json:"output"`
  23765. RefmsgTime string `json:"refmsg_time"`
  23766. RespondTime string `json:"respond_time"`
  23767. Signtype interface{} `json:"signtype"`
  23768. WarnInfo interface{} `json:"warn_info"`
  23769. }
  23770. type ResultCFYLJG008 struct {
  23771. ErrMsg string `json:"err_msg"`
  23772. InfRefmsgid string `json:"inf_refmsgid"`
  23773. Infcode int64 `json:"infcode"`
  23774. Output struct {
  23775. PoolareaNo string `json:"poolareaNo"`
  23776. AdmdvsName string `json:"admdvsName"`
  23777. Count string `json:"count"`
  23778. } `json:"output"`
  23779. RefmsgTime string `json:"refmsg_time"`
  23780. RespondTime string `json:"respond_time"`
  23781. Signtype interface{} `json:"signtype"`
  23782. WarnInfo interface{} `json:"warn_info"`
  23783. }
  23784. type ResultCFYLJG005 struct {
  23785. ErrMsg string `json:"err_msg"`
  23786. InfRefmsgid string `json:"inf_refmsgid"`
  23787. Infcode int64 `json:"infcode"`
  23788. Output struct {
  23789. HiRxNo string `json:"hi_rxno"`
  23790. FixMedinsCode string `json:"fixmedins_code"`
  23791. FixMedinsName string `json:"fixmedins_name"`
  23792. RxStasCodg string `json:"rx_stas_codg"`
  23793. RxStasName string `json:"rx_stas_name"`
  23794. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  23795. RxUserdStasName string `json:"rx_userd_stas_name"`
  23796. PrscTime string `json:"prsc_time"`
  23797. RxDrugCnt float64 `json:"rx_drug_cnt"`
  23798. RxUsedWayCodg string `json:"rx_used_way_codg"`
  23799. RxUsedWayName string `json:"rx_used_way_name"`
  23800. RxFrquCodg string `json:"rx_frqu_codg"`
  23801. RxFrquName string `json:"rx_frqu_name"`
  23802. RxDosunt string `json:"rx_dosunt"`
  23803. RxDoscnt float64 `json:"rx_doscnt"`
  23804. RxDrordDscr string `json:"rx_drord_dscr"`
  23805. ValiDays int64 `json:"vali_days"`
  23806. ValiEndTime string `json:"vali_end_time"`
  23807. ReptFlag string `json:"rept_flag"`
  23808. MaxReptCnt int64 `json:"max_rept_cnt"`
  23809. ReptdCnt int64 `json:"reptd_cnt"`
  23810. MinInrvDays int64 `json:"min_inrv_days"`
  23811. RxTypeCode string `json:"rx_type_code"`
  23812. RxTypeName string `json:"rx_type_name"`
  23813. LongRxFlag string `json:"long_rx_flag"`
  23814. RxDetlList []struct {
  23815. MedListCodg string `json:"med_list_codg"`
  23816. MedinsListCodg string `json:"medins_list_codg"`
  23817. HospPrepFlag string `json:"hosp_prep_flag"`
  23818. RxItemTypeCode string `json:"rx_item_type_code"`
  23819. RxItemTypeName string `json:"rx_item_type_name"`
  23820. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  23821. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  23822. TcmHerbFoote string `json:"tcmherb_foote"`
  23823. MednTypeCode string `json:"medn_type_code"`
  23824. MednTypeName string `json:"medn_type_name"`
  23825. MainMedcFlag string `json:"main_medc_flag"`
  23826. UrgtFlag string `json:"urgt_flag"`
  23827. BasMednFlag string `json:"bas_medn_flag"`
  23828. ImpDrugFlag string `json:"imp_drug_flag"`
  23829. ProdBarc string `json:"prod_barc"`
  23830. DrugProdname string `json:"drug_prodname"`
  23831. GennameCodg string `json:"genname_codg"`
  23832. DrugGenname string `json:"drug_genname"`
  23833. DrugDosform string `json:"drug_dosform"`
  23834. DrugSpec string `json:"drug_spec"`
  23835. PrdrName string `json:"prdr_name"`
  23836. MedcWayCodg string `json:"medc_way_codg"`
  23837. MedcWayDscr string `json:"medc_way_dscr"`
  23838. MedcBegntime string `json:"medc_begntime"`
  23839. MedcEndtime string `json:"medc_endtime"`
  23840. MedcDays float64 `json:"medc_days"`
  23841. DrugPric float64 `json:"drug_pric"`
  23842. DrugSumamt float64 `json:"drug_sumamt"`
  23843. DrugCnt float64 `json:"drug_cnt"`
  23844. DrugDosunt string `json:"drug_dosunt"`
  23845. SinDoscnt float64 `json:"sin_doscnt"`
  23846. SinDosunt string `json:"sin_dosunt"`
  23847. UsedFrquCodg string `json:"used_frqu_codg"`
  23848. UsedFrquName string `json:"used_frqu_name"`
  23849. DrugTotlcnt string `json:"drug_totlcnt"`
  23850. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  23851. DiseCodg string `json:"dise_codg"`
  23852. HospApprFlag string `json:"hosp_appr_flag"`
  23853. } `json:"rx_detl_list"`
  23854. RxOtpinfo struct {
  23855. MedType string `json:"med_type"`
  23856. IptOtpNo string `json:"ipt_otp_no"`
  23857. OtpIptFlag string `json:"otp_ipt_flag"`
  23858. PatnName string `json:"patn_name"`
  23859. PatnAge float64 `json:"patn_age"`
  23860. PatnHgt float64 `json:"patn_hgt"`
  23861. PatnWt float64 `json:"patn_wt"`
  23862. Gend string `json:"gend"`
  23863. GesoVal float64 `json:"geso_val"`
  23864. NwbFlag string `json:"nwb_flag"`
  23865. NwbAge string `json:"nwb_age"`
  23866. SuckPrdFlag string `json:"suck_prd_flag"`
  23867. AlgsHis string `json:"algs_his"`
  23868. Insutype string `json:"insutype"`
  23869. PrscDeptName string `json:"prsc_dept_name"`
  23870. PrscDrName string `json:"prsc_dr_name"`
  23871. PharName string `json:"phar_name"`
  23872. PharChkTime string `json:"phar_chk_time"`
  23873. MdtrtTime string `json:"mdtrt_time"`
  23874. DiseCodg string `json:"dise_codg"`
  23875. DiseName string `json:"dise_name"`
  23876. SpDiseFlag string `json:"sp_dise_flag"`
  23877. MaindiagCode string `json:"maindiag_code"`
  23878. MaindiagName string `json:"maindiag_name"`
  23879. DiseCondDscr string `json:"dise_cond_dscr"`
  23880. FstdiagFlag string `json:"fstdiag_flag"`
  23881. } `json:"rx_otpinfo"`
  23882. RxDiseList []struct {
  23883. DiagType string `json:"diag_type"`
  23884. MaindiagFlag string `json:"maindiag_flag"`
  23885. DiagSrtNo string `json:"diag_srt_no"`
  23886. DiagCode string `json:"diag_code"`
  23887. DiagName string `json:"diag_name"`
  23888. DiagDept string `json:"diag_dept"`
  23889. DiagDrNo string `json:"diag_dr_no"`
  23890. DiagDrName string `json:"diag_dr_name"`
  23891. DiagTime string `json:"diag_time"`
  23892. TcmDiseCode string `json:"tcm_dise_code"`
  23893. TcmDiseName string `json:"tcm_dise_name"`
  23894. TcmSympCode string `json:"tcmsymp_code"`
  23895. TcmSymp string `json:"tcmsymp"`
  23896. } `json:"rx_dise_list"`
  23897. } `json:"output"`
  23898. RefmsgTime string `json:"refmsg_time"`
  23899. RespondTime string `json:"respond_time"`
  23900. Signtype interface{} `json:"signtype"`
  23901. WarnInfo interface{} `json:"warn_info"`
  23902. }
  23903. type ResultCFYLJG006 struct {
  23904. ErrMsg string `json:"err_msg"`
  23905. InfRefmsgid string `json:"inf_refmsgid"`
  23906. Infcode int64 `json:"infcode"`
  23907. Output struct {
  23908. HiRxNo string `json:"hi_rxno"`
  23909. PharCode string `json:"phar_code"`
  23910. PharName string `json:"phar_name"`
  23911. RxChkOpnn string `json:"rx_chk_opnn"`
  23912. RxChkTime string `json:"rx_chk_time"`
  23913. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  23914. RxChkStasName string `json:"rx_chk_stas_name"`
  23915. RxStasCodg string `json:"rx_stas_codg"`
  23916. RxStasName string `json:"rx_stas_name"`
  23917. } `json:"output"`
  23918. RefmsgTime string `json:"refmsg_time"`
  23919. RespondTime string `json:"respond_time"`
  23920. Signtype interface{} `json:"signtype"`
  23921. WarnInfo interface{} `json:"warn_info"`
  23922. }
  23923. type ResultFourteen10265 struct {
  23924. ErrMsg string `json:"err_msg"`
  23925. InfRefmsgid string `json:"inf_refmsgid"`
  23926. Infcode string `json:"infcode"`
  23927. Output struct {
  23928. } `json:"output"`
  23929. RefmsgTime string `json:"refmsg_time"`
  23930. RespondTime string `json:"respond_time"`
  23931. Signtype interface{} `json:"signtype"`
  23932. WarnInfo interface{} `json:"warn_info"`
  23933. }
  23934. type ResultSixteen struct {
  23935. Cainfo string `json:"cainfo"`
  23936. ErrMsg string `json:"err_msg"`
  23937. InfRefmsgid string `json:"inf_refmsgid"`
  23938. Infcode int64 `json:"infcode"`
  23939. Output struct {
  23940. Setlinfo struct {
  23941. MdtrtID string `json:"mdtrt_id"`
  23942. SetlID string `json:"setl_id"`
  23943. ClrOptins string `json:"clr_optins"`
  23944. SetlTime string `json:"setl_time"`
  23945. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23946. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23947. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23948. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23949. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23950. ActPayDedc float64 `json:"act_pay_dedc"`
  23951. HifpPay float64 `json:"hifp_pay"`
  23952. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23953. Lfpay float64 `json:"selfpay"`
  23954. CvlservPay float64 `json:"cvlserv_pay"`
  23955. HifesPay float64 `json:"hifes_pay"`
  23956. HifmiPay float64 `json:"hifmi_pay"`
  23957. HifobPay float64 `json:"hifob_pay"`
  23958. MafPay float64 `json:"maf_pay"`
  23959. OthPay float64 `json:"oth_pay"`
  23960. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23961. PsnPartAmt float64 `json:"psn_part_amt"`
  23962. AcctPay float64 `json:"acct_pay"`
  23963. Balc float64 `json:"balc"`
  23964. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23965. HospPartAmt float64 `json:"hosp_part_amt"`
  23966. MedinsSetlID string `json:"medins_setl_id"`
  23967. PdnCashPay string `json:"pdn_cash_pay"`
  23968. } `json:"setlinfo"`
  23969. } `json:"output"`
  23970. RefmsgTime string `json:"refmsg_time"`
  23971. RespondTime string `json:"respond_time"`
  23972. Signtype interface{} `json:"signtype"`
  23973. WarnMsg interface{} `json:"warn_msg"`
  23974. }
  23975. type ResultSixteen10265 struct {
  23976. Cainfo string `json:"cainfo"`
  23977. ErrMsg string `json:"err_msg"`
  23978. InfRefmsgid string `json:"inf_refmsgid"`
  23979. Infcode string `json:"infcode"`
  23980. Output struct {
  23981. Setlinfo struct {
  23982. MdtrtID string `json:"mdtrt_id"`
  23983. SetlID string `json:"setl_id"`
  23984. ClrOptins string `json:"clr_optins"`
  23985. SetlTime string `json:"setl_time"`
  23986. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23987. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23988. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23989. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23990. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23991. ActPayDedc float64 `json:"act_pay_dedc"`
  23992. HifpPay float64 `json:"hifp_pay"`
  23993. PoolPropSe float64 `json:"pool_prop_selfpay"`
  23994. Lfpay float64 `json:"selfpay"`
  23995. CvlservPay float64 `json:"cvlserv_pay"`
  23996. HifesPay float64 `json:"hifes_pay"`
  23997. HifmiPay float64 `json:"hifmi_pay"`
  23998. HifobPay float64 `json:"hifob_pay"`
  23999. MafPay float64 `json:"maf_pay"`
  24000. OthPay float64 `json:"oth_pay"`
  24001. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24002. PsnPartAmt float64 `json:"psn_part_amt"`
  24003. AcctPay float64 `json:"acct_pay"`
  24004. Balc float64 `json:"balc"`
  24005. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24006. HospPartAmt float64 `json:"hosp_part_amt"`
  24007. MedinsSetlID string `json:"medins_setl_id"`
  24008. PdnCashPay string `json:"pdn_cash_pay"`
  24009. } `json:"setlinfo"`
  24010. } `json:"output"`
  24011. RefmsgTime string `json:"refmsg_time"`
  24012. RespondTime string `json:"respond_time"`
  24013. Signtype interface{} `json:"signtype"`
  24014. WarnMsg interface{} `json:"warn_msg"`
  24015. }
  24016. type ResultSixteen10265Two struct {
  24017. Cainfo string `json:"cainfo"`
  24018. ErrMsg string `json:"err_msg"`
  24019. InfRefmsgid string `json:"inf_refmsgid"`
  24020. Infcode string `json:"infcode"`
  24021. Output struct {
  24022. Setlinfo interface{} `json:"setlinfo"`
  24023. } `json:"output"`
  24024. RefmsgTime string `json:"refmsg_time"`
  24025. RespondTime string `json:"respond_time"`
  24026. Signtype interface{} `json:"signtype"`
  24027. WarnMsg interface{} `json:"warn_msg"`
  24028. }
  24029. type ResultgzSixteen10265Two struct {
  24030. Cainfo string `json:"cainfo"`
  24031. ErrMsg string `json:"err_msg"`
  24032. InfRefmsgid string `json:"inf_refmsgid"`
  24033. Infcode int64 `json:"infcode"`
  24034. Output struct {
  24035. Setlinfo interface{} `json:"setlinfo"`
  24036. } `json:"output"`
  24037. RefmsgTime string `json:"refmsg_time"`
  24038. RespondTime string `json:"respond_time"`
  24039. Signtype interface{} `json:"signtype"`
  24040. WarnMsg interface{} `json:"warn_msg"`
  24041. }
  24042. type ResultSeventeen struct {
  24043. ErrMsg string `json:"err_msg"`
  24044. InfRefmsgid string `json:"inf_refmsgid"`
  24045. Infcode int64 `json:"infcode"`
  24046. Output struct {
  24047. SetlListId string `json:"setl_list_id"`
  24048. } `json:"output"`
  24049. RefmsgTime string `json:"refmsg_time"`
  24050. RespondTime string `json:"respond_time"`
  24051. Signtype string `json:"signtype"`
  24052. WarnInfo string `json:"warn_info"`
  24053. }
  24054. type ResultSeventeenOther struct {
  24055. ErrMsg string `json:"err_msg"`
  24056. InfRefmsgid string `json:"inf_refmsgid"`
  24057. Infcode string `json:"infcode"`
  24058. Output struct {
  24059. SetlListId string `json:"setl_list_id"`
  24060. } `json:"output"`
  24061. RefmsgTime string `json:"refmsg_time"`
  24062. RespondTime string `json:"respond_time"`
  24063. Signtype string `json:"signtype"`
  24064. WarnInfo string `json:"warn_info"`
  24065. }
  24066. type Result90991 struct {
  24067. ErrMsg string `json:"err_msg"`
  24068. InfRefmsgid string `json:"inf_refmsgid"`
  24069. Infcode int64 `json:"infcode"`
  24070. Output struct {
  24071. Result struct {
  24072. PsnNo string `json:"psn_no"`
  24073. CardStat string `json:"card_stat"`
  24074. Certno string `json:"certno"`
  24075. PsnName string `json:"psn_name"`
  24076. CheckStat string `json:"check_stat"`
  24077. SscnoCheckStat string `json:"sscno_check_stat"`
  24078. } `json:"result"`
  24079. } `json:"output"`
  24080. RefmsgTime string `json:"refmsg_time"`
  24081. RespondTime string `json:"respond_time"`
  24082. Signtype interface{} `json:"signtype"`
  24083. WarnInfo interface{} `json:"warn_info"`
  24084. }
  24085. type Result90100 struct {
  24086. ErrMsg string `json:"err_msg"`
  24087. InfRefmsgid string `json:"inf_refmsgid"`
  24088. Infcode int64 `json:"infcode"`
  24089. Output struct {
  24090. PoolareaNo string `json:"poolarea_no"`
  24091. PoolareaNoName string `json:"poolarea_no_name"`
  24092. Insutype string `json:"insutype"`
  24093. InsutypeName string `json:"insutype_name"`
  24094. ClctType string `json:"clct_type"`
  24095. ClctTypeName string `json:"clct_type_name"`
  24096. ClctFlag string `json:"clct_flag"`
  24097. ClctFlagName string `json:"clct_flag_name"`
  24098. AccrymBegn string `json:"accrym_begn"`
  24099. AccrymEnd string `json:"accrym_end"`
  24100. ClctTime string `json:"clct_time"`
  24101. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  24102. } `json:"output"`
  24103. RefmsgTime string `json:"refmsg_time"`
  24104. RespondTime string `json:"respond_time"`
  24105. Signtype interface{} `json:"signtype"`
  24106. WarnInfo interface{} `json:"warn_info"`
  24107. }
  24108. type Custom struct {
  24109. DetItemFeeSumamt string
  24110. Cut string
  24111. FeedetlSn string
  24112. Price string
  24113. MedListCodg string
  24114. Type int64
  24115. AdviceId int64
  24116. ProjectId int64
  24117. ItemId int64
  24118. }
  24119. type Result5301 struct {
  24120. ErrMsg string `json:"err_msg"`
  24121. InfRefmsgid string `json:"inf_refmsgid"`
  24122. Infcode int64 `json:"infcode"`
  24123. Output struct {
  24124. Result []struct {
  24125. OpspDiseCode string `json:"opsp_dise_code"`
  24126. OpspDiseName string `json:"opsp_dise_name"`
  24127. Begndate string `json:"begndate"`
  24128. Enddate string `json:"enddate"`
  24129. } `json:"feedetail"`
  24130. } `json:"output"`
  24131. RefmsgTime string `json:"refmsg_time"`
  24132. RespondTime string `json:"respond_time"`
  24133. Signtype interface{} `json:"signtype"`
  24134. WarnInfo interface{} `json:"warn_info"`
  24135. }
  24136. type Result5301For10265 struct {
  24137. ErrMsg string `json:"err_msg"`
  24138. InfRefmsgid string `json:"inf_refmsgid"`
  24139. Infcode string `json:"infcode"`
  24140. Output struct {
  24141. Result []struct {
  24142. OpspDiseCode string `json:"opsp_dise_code"`
  24143. OpspDiseName string `json:"opsp_dise_name"`
  24144. Begndate string `json:"begndate"`
  24145. Enddate string `json:"enddate"`
  24146. } `json:"feedetail"`
  24147. } `json:"output"`
  24148. RefmsgTime string `json:"refmsg_time"`
  24149. RespondTime string `json:"respond_time"`
  24150. Signtype interface{} `json:"signtype"`
  24151. WarnInfo interface{} `json:"warn_info"`
  24152. }
  24153. //获取个人信息----挂号-----上传就诊信息
  24154. func (c *HisApiController) GetRegisterInfo() {
  24155. id, _ := c.GetInt64("id")
  24156. record_time := c.GetString("record_time")
  24157. settlementValue, _ := c.GetInt64("settlement_value")
  24158. medical_insurance_card := c.GetString("medical_insurance_card")
  24159. name := c.GetString("name")
  24160. id_card_type, _ := c.GetInt64("id_card_type")
  24161. certificates, _ := c.GetInt64("certificates")
  24162. medical_care, _ := c.GetInt64("medical_care")
  24163. birthday := c.GetString("birthday")
  24164. id_card := c.GetString("id_card")
  24165. register_type, _ := c.GetInt64("register")
  24166. doctor, _ := c.GetInt64("doctor")
  24167. department, _ := c.GetInt64("department")
  24168. gender, _ := c.GetInt64("sex")
  24169. registration_fee, _ := c.GetFloat("registration_fee")
  24170. medical_expenses, _ := c.GetFloat("medical_expenses")
  24171. social_type, _ := c.GetInt64("social_type")
  24172. admin_user_id, _ := c.GetInt64("admin_user_id")
  24173. insuplc_admdvs := c.GetString("insuplc_admdvs")
  24174. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  24175. mdtrt_type := c.GetString("mdtrt_type")
  24176. if id_card_type == 5 {
  24177. id_card_type = 4
  24178. }
  24179. timeLayout := "2006-01-02"
  24180. loc, _ := time.LoadLocation("Local")
  24181. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  24182. birthUnix := birthdays.Unix()
  24183. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24184. if err != nil {
  24185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24186. return
  24187. }
  24188. recordDateTime := theTime.Unix()
  24189. adminInfo := c.GetAdminUserInfo()
  24190. var patient service.Patients
  24191. if id == 0 {
  24192. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  24193. } else {
  24194. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  24195. }
  24196. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24197. if patientPrescription.ID == 0 {
  24198. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24199. }
  24200. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  24201. if patient.ID == 0 {
  24202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  24203. return
  24204. }
  24205. if len(patient.IdCardNo) == 0 {
  24206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  24207. return
  24208. }
  24209. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  24210. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  24211. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  24212. //就诊结算未完成,不能进行二次挂号
  24213. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  24214. if len(his) >= 1 {
  24215. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  24216. if len(his) >= 1 && order.ID == 0 {
  24217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  24218. return
  24219. }
  24220. }
  24221. var aaaa string
  24222. //var register_log string
  24223. if config.IsOpen == 1 {
  24224. var res ResultTwo
  24225. var res10265 ResultTwo10265
  24226. var PsnNo string
  24227. var PsnCertType string
  24228. var Certno string
  24229. var PsnName string
  24230. var Gend string
  24231. var Naty string
  24232. var Brdy string
  24233. var Age float64
  24234. var infoStr string
  24235. var idetinfoStr string
  24236. var infocode int64
  24237. var verify_number string
  24238. fmt.Println(verify_number)
  24239. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  24240. psn_info, _ := service.GetPsnByPatientId(id)
  24241. PsnNo = psn_info.PsnNo
  24242. PsnCertType = psn_info.PsnCertType
  24243. Certno = psn_info.Certno
  24244. PsnName = psn_info.PsnName
  24245. Gend = psn_info.Gend
  24246. Naty = psn_info.Naty
  24247. Brdy = psn_info.Brdy
  24248. Age = psn_info.Age
  24249. infoStr = psn_info.Insuinfo
  24250. idetinfoStr = psn_info.Idetinfo
  24251. infocode = 0
  24252. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24253. psn_info, _ := service.GetPsnByPatientId(id)
  24254. PsnNo = psn_info.PsnNo
  24255. PsnCertType = psn_info.PsnCertType
  24256. Certno = psn_info.Certno
  24257. PsnName = psn_info.PsnName
  24258. Gend = psn_info.Gend
  24259. Naty = psn_info.Naty
  24260. Brdy = psn_info.Brdy
  24261. Age = psn_info.Age
  24262. infoStr = psn_info.Insuinfo
  24263. idetinfoStr = psn_info.Idetinfo
  24264. infocode = 0
  24265. verify_number = psn_info.VerifyNumber
  24266. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24267. if id_card_type == 2 {
  24268. //请求内网数据
  24269. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  24270. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24271. "&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
  24272. resp, requestErr := http.Get(api)
  24273. if requestErr != nil {
  24274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24275. return
  24276. }
  24277. body, ioErr := ioutil.ReadAll(resp.Body)
  24278. if ioErr != nil {
  24279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24281. return
  24282. }
  24283. var respJSON map[string]interface{}
  24284. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24287. return
  24288. }
  24289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24290. result_byte, _ := json.Marshal(respJSON)
  24291. result := string(result_byte)
  24292. var dat map[string]interface{}
  24293. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24294. fmt.Println(dat)
  24295. } else {
  24296. fmt.Println(err)
  24297. }
  24298. userJSONBytes, _ := json.Marshal(dat)
  24299. var res ResultTwo
  24300. var resTwo10265 ResultTwo10265
  24301. if miConfig.Code == "H15049901371" {
  24302. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  24303. utils.ErrorLog("解析失败:%v", err)
  24304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24305. return
  24306. }
  24307. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  24308. res.Infcode = Infcode
  24309. res.ErrMsg = resTwo10265.ErrMsg
  24310. res.Output = resTwo10265.Output
  24311. res.InfRefmsgid = resTwo10265.InfRefmsgid
  24312. res.RespondTime = resTwo10265.RespondTime
  24313. res.WarnInfo = resTwo10265.WarnInfo
  24314. } else {
  24315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24316. utils.ErrorLog("解析失败:%v", err)
  24317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24318. return
  24319. }
  24320. }
  24321. //var insutypes []string
  24322. //var insutype string
  24323. //var is390 int = 0
  24324. //var is310 int = 0
  24325. //for _, item := range res.Output.Iinfo {
  24326. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24327. // insutypes = append(insutypes, item.Insutype)
  24328. // }
  24329. //}
  24330. //if len(insutypes) == 1 {
  24331. // insutype = insutypes[0]
  24332. //} else {
  24333. // for _, i := range insutypes {
  24334. // if i == "390" {
  24335. // is390 = 1
  24336. // }
  24337. //
  24338. // if i == "310" {
  24339. // is310 = 1
  24340. // }
  24341. // }
  24342. //}
  24343. //if is390 == 1 {
  24344. // insutype = "390"
  24345. //}
  24346. //if is310 == 1 {
  24347. // insutype = "310"
  24348. //}
  24349. //if len(insutypes) == 0 {
  24350. // insutype = "310"
  24351. //}
  24352. PsnNo = res.Output.Baseinfo.PsnNo
  24353. PsnCertType = res.Output.Baseinfo.PsnCertType
  24354. Certno = res.Output.Baseinfo.Certno
  24355. PsnName = res.Output.Baseinfo.PsnName
  24356. Gend = res.Output.Baseinfo.Gend
  24357. Naty = res.Output.Baseinfo.Naty
  24358. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24359. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24360. infoStr = string(Iinfos)
  24361. idetinfoStr = string(Idetinfos)
  24362. infocode = res.Infcode
  24363. //infocode = 0
  24364. //verify_number = psn_info.VerifyNumber
  24365. } else {
  24366. psn_info, _ := service.GetPsnByPatientId(id)
  24367. PsnNo = psn_info.PsnNo
  24368. PsnCertType = psn_info.PsnCertType
  24369. Certno = psn_info.Certno
  24370. PsnName = psn_info.PsnName
  24371. Gend = psn_info.Gend
  24372. Naty = psn_info.Naty
  24373. Brdy = psn_info.Brdy
  24374. Age = psn_info.Age
  24375. infoStr = psn_info.Insuinfo
  24376. idetinfoStr = psn_info.Idetinfo
  24377. infocode = 0
  24378. verify_number = psn_info.VerifyNumber
  24379. }
  24380. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24381. if id_card_type == 1 {
  24382. psn_info, _ := service.GetPsnByPatientId(id)
  24383. PsnNo = psn_info.PsnNo
  24384. PsnCertType = psn_info.PsnCertType
  24385. Certno = psn_info.Certno
  24386. PsnName = psn_info.PsnName
  24387. Gend = psn_info.Gend
  24388. Naty = psn_info.Naty
  24389. Brdy = psn_info.Brdy
  24390. Age = psn_info.Age
  24391. infoStr = psn_info.Insuinfo
  24392. idetinfoStr = psn_info.Idetinfo
  24393. infocode = 0
  24394. verify_number = psn_info.VerifyNumber
  24395. } else if id_card_type == 2 {
  24396. 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)
  24397. fmt.Println(errMsgLog)
  24398. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24399. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24400. utils.ErrorLog("解析失败:%v", err)
  24401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24402. return
  24403. }
  24404. PsnNo = res.Output.Baseinfo.PsnNo
  24405. PsnCertType = res.Output.Baseinfo.PsnCertType
  24406. Certno = res.Output.Baseinfo.Certno
  24407. PsnName = res.Output.Baseinfo.PsnName
  24408. Gend = res.Output.Baseinfo.Gend
  24409. Naty = res.Output.Baseinfo.Naty
  24410. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24411. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24412. infoStr = string(Iinfos)
  24413. idetinfoStr = string(Idetinfos)
  24414. infocode = res.Infcode
  24415. }
  24416. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24417. if id_card_type == 1 {
  24418. psn_info, _ := service.GetPsnByPatientId(id)
  24419. PsnNo = psn_info.PsnNo
  24420. PsnCertType = psn_info.PsnCertType
  24421. Certno = psn_info.Certno
  24422. PsnName = psn_info.PsnName
  24423. Gend = psn_info.Gend
  24424. Naty = psn_info.Naty
  24425. Brdy = psn_info.Brdy
  24426. Age = psn_info.Age
  24427. infoStr = psn_info.Insuinfo
  24428. idetinfoStr = psn_info.Idetinfo
  24429. infocode = 0
  24430. verify_number = psn_info.VerifyNumber
  24431. } else if id_card_type == 2 {
  24432. 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, "")
  24433. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24434. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24435. utils.ErrorLog("解析失败:%v", err)
  24436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24437. return
  24438. }
  24439. PsnNo = res.Output.Baseinfo.PsnNo
  24440. PsnCertType = res.Output.Baseinfo.PsnCertType
  24441. Certno = res.Output.Baseinfo.Certno
  24442. PsnName = res.Output.Baseinfo.PsnName
  24443. Gend = res.Output.Baseinfo.Gend
  24444. Naty = res.Output.Baseinfo.Naty
  24445. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24446. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24447. infoStr = string(Iinfos)
  24448. idetinfoStr = string(Idetinfos)
  24449. infocode = res.Infcode
  24450. } else {
  24451. psn_info, _ := service.GetPsnByPatientId(id)
  24452. PsnNo = psn_info.PsnNo
  24453. PsnCertType = psn_info.PsnCertType
  24454. Certno = psn_info.Certno
  24455. PsnName = psn_info.PsnName
  24456. Gend = psn_info.Gend
  24457. Naty = psn_info.Naty
  24458. Brdy = psn_info.Brdy
  24459. Age = psn_info.Age
  24460. infoStr = psn_info.Insuinfo
  24461. idetinfoStr = psn_info.Idetinfo
  24462. infocode = 0
  24463. verify_number = psn_info.VerifyNumber
  24464. }
  24465. } else if miConfig.MdtrtareaAdmvs == "361025" {
  24466. if id_card_type == 1 {
  24467. psn_info, _ := service.GetPsnByPatientId(id)
  24468. PsnNo = psn_info.PsnNo
  24469. PsnCertType = psn_info.PsnCertType
  24470. Certno = psn_info.Certno
  24471. PsnName = psn_info.PsnName
  24472. Gend = psn_info.Gend
  24473. Naty = psn_info.Naty
  24474. Brdy = psn_info.Brdy
  24475. Age = psn_info.Age
  24476. infoStr = psn_info.Insuinfo
  24477. idetinfoStr = psn_info.Idetinfo
  24478. infocode = 0
  24479. verify_number = psn_info.VerifyNumber
  24480. } else if id_card_type == 2 {
  24481. psn_info, _ := service.GetPsnByPatientId(id)
  24482. PsnNo = psn_info.PsnNo
  24483. PsnCertType = psn_info.PsnCertType
  24484. Certno = psn_info.Certno
  24485. PsnName = psn_info.PsnName
  24486. Gend = psn_info.Gend
  24487. Naty = psn_info.Naty
  24488. Brdy = psn_info.Brdy
  24489. Age = psn_info.Age
  24490. infoStr = psn_info.Insuinfo
  24491. idetinfoStr = psn_info.Idetinfo
  24492. infocode = 0
  24493. verify_number = psn_info.VerifyNumber
  24494. } else {
  24495. psn_info, _ := service.GetPsnByPatientId(id)
  24496. PsnNo = psn_info.PsnNo
  24497. PsnCertType = psn_info.PsnCertType
  24498. Certno = psn_info.Certno
  24499. PsnName = psn_info.PsnName
  24500. Gend = psn_info.Gend
  24501. Naty = psn_info.Naty
  24502. Brdy = psn_info.Brdy
  24503. Age = psn_info.Age
  24504. infoStr = psn_info.Insuinfo
  24505. idetinfoStr = psn_info.Idetinfo
  24506. infocode = 0
  24507. verify_number = psn_info.VerifyNumber
  24508. }
  24509. } else if miConfig.MdtrtareaAdmvs == "360100" {
  24510. if id_card_type == 1 {
  24511. psn_info, _ := service.GetPsnByPatientId(id)
  24512. PsnNo = psn_info.PsnNo
  24513. PsnCertType = psn_info.PsnCertType
  24514. Certno = psn_info.Certno
  24515. PsnName = psn_info.PsnName
  24516. Gend = psn_info.Gend
  24517. Naty = psn_info.Naty
  24518. Brdy = psn_info.Brdy
  24519. Age = psn_info.Age
  24520. infoStr = psn_info.Insuinfo
  24521. idetinfoStr = psn_info.Idetinfo
  24522. infocode = 0
  24523. verify_number = psn_info.VerifyNumber
  24524. } else if id_card_type == 2 {
  24525. psn_info, _ := service.GetPsnByPatientId(id)
  24526. PsnNo = psn_info.PsnNo
  24527. PsnCertType = psn_info.PsnCertType
  24528. Certno = psn_info.Certno
  24529. PsnName = psn_info.PsnName
  24530. Gend = psn_info.Gend
  24531. Naty = psn_info.Naty
  24532. Brdy = psn_info.Brdy
  24533. Age = psn_info.Age
  24534. infoStr = psn_info.Insuinfo
  24535. idetinfoStr = psn_info.Idetinfo
  24536. infocode = 0
  24537. verify_number = psn_info.VerifyNumber
  24538. } else {
  24539. psn_info, _ := service.GetPsnByPatientId(id)
  24540. PsnNo = psn_info.PsnNo
  24541. PsnCertType = psn_info.PsnCertType
  24542. Certno = psn_info.Certno
  24543. PsnName = psn_info.PsnName
  24544. Gend = psn_info.Gend
  24545. Naty = psn_info.Naty
  24546. Brdy = psn_info.Brdy
  24547. Age = psn_info.Age
  24548. infoStr = psn_info.Insuinfo
  24549. idetinfoStr = psn_info.Idetinfo
  24550. infocode = 0
  24551. verify_number = psn_info.VerifyNumber
  24552. }
  24553. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  24554. psn_info, _ := service.GetPsnByPatientId(id)
  24555. PsnNo = psn_info.PsnNo
  24556. PsnCertType = psn_info.PsnCertType
  24557. Certno = psn_info.Certno
  24558. PsnName = psn_info.PsnName
  24559. Gend = psn_info.Gend
  24560. Naty = psn_info.Naty
  24561. Brdy = psn_info.Brdy
  24562. Age = psn_info.Age
  24563. infoStr = psn_info.Insuinfo
  24564. idetinfoStr = psn_info.Idetinfo
  24565. infocode = 0
  24566. verify_number = psn_info.VerifyNumber
  24567. idetinfoStr = psn_info.Idetinfo
  24568. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24569. if id_card_type == 1 {
  24570. psn_info, _ := service.GetPsnByPatientId(id)
  24571. PsnNo = psn_info.PsnNo
  24572. PsnCertType = psn_info.PsnCertType
  24573. Certno = psn_info.Certno
  24574. PsnName = psn_info.PsnName
  24575. Gend = psn_info.Gend
  24576. Naty = psn_info.Naty
  24577. Brdy = psn_info.Brdy
  24578. Age = psn_info.Age
  24579. infoStr = psn_info.Insuinfo
  24580. idetinfoStr = psn_info.Idetinfo
  24581. infocode = 0
  24582. verify_number = psn_info.VerifyNumber
  24583. } else if id_card_type == 2 {
  24584. 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)
  24585. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24586. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24587. utils.ErrorLog("解析失败:%v", err)
  24588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24589. return
  24590. }
  24591. PsnNo = res.Output.Baseinfo.PsnNo
  24592. PsnCertType = res.Output.Baseinfo.PsnCertType
  24593. Certno = res.Output.Baseinfo.Certno
  24594. PsnName = res.Output.Baseinfo.PsnName
  24595. Gend = res.Output.Baseinfo.Gend
  24596. Naty = res.Output.Baseinfo.Naty
  24597. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24598. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24599. infoStr = string(Iinfos)
  24600. idetinfoStr = string(Idetinfos)
  24601. infocode = res.Infcode
  24602. } else if id_card_type == 4 {
  24603. psn_info, _ := service.GetPsnByPatientId(id)
  24604. PsnNo = psn_info.PsnNo
  24605. PsnCertType = psn_info.PsnCertType
  24606. Certno = psn_info.Certno
  24607. PsnName = psn_info.PsnName
  24608. Gend = psn_info.Gend
  24609. Naty = psn_info.Naty
  24610. Brdy = psn_info.Brdy
  24611. Age = psn_info.Age
  24612. infoStr = psn_info.Insuinfo
  24613. idetinfoStr = psn_info.Idetinfo
  24614. infocode = 0
  24615. verify_number = psn_info.VerifyNumber
  24616. }
  24617. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24618. var result string
  24619. var requestLog string
  24620. 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), "")
  24621. if id_card_type == 4 {
  24622. psn_info, _ := service.GetPsnByPatientId(id)
  24623. PsnNo = psn_info.PsnNo
  24624. PsnCertType = psn_info.PsnCertType
  24625. Certno = psn_info.Certno
  24626. PsnName = psn_info.PsnName
  24627. Gend = psn_info.Gend
  24628. Naty = psn_info.Naty
  24629. Brdy = psn_info.Brdy
  24630. Age = psn_info.Age
  24631. infoStr = psn_info.Insuinfo
  24632. idetinfoStr = psn_info.Idetinfo
  24633. infocode = 0
  24634. verify_number = psn_info.VerifyNumber
  24635. } else {
  24636. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24637. if miConfig.Code == "H15049901371" {
  24638. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24639. utils.ErrorLog("解析失败:%v", err)
  24640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24641. return
  24642. }
  24643. res.ErrMsg = res10265.ErrMsg
  24644. res.Output = res10265.Output
  24645. res.InfRefmsgid = res10265.InfRefmsgid
  24646. } else {
  24647. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24648. utils.ErrorLog("解析失败:%v", err)
  24649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24650. return
  24651. }
  24652. }
  24653. PsnNo = res.Output.Baseinfo.PsnNo
  24654. PsnCertType = res.Output.Baseinfo.PsnCertType
  24655. Certno = res.Output.Baseinfo.Certno
  24656. PsnName = res.Output.Baseinfo.PsnName
  24657. Gend = res.Output.Baseinfo.Gend
  24658. Naty = res.Output.Baseinfo.Naty
  24659. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24660. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24661. infoStr = string(Iinfos)
  24662. idetinfoStr = string(Idetinfos)
  24663. if miConfig.Code == "H15049901371" {
  24664. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24665. } else {
  24666. infocode = res.Infcode
  24667. }
  24668. }
  24669. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24670. psn_info, _ := service.GetPsnByPatientId(id)
  24671. PsnNo = psn_info.PsnNo
  24672. PsnCertType = psn_info.PsnCertType
  24673. Certno = psn_info.Certno
  24674. PsnName = psn_info.PsnName
  24675. Gend = psn_info.Gend
  24676. Naty = psn_info.Naty
  24677. Brdy = psn_info.Brdy
  24678. Age = psn_info.Age
  24679. infoStr = psn_info.Insuinfo
  24680. idetinfoStr = psn_info.Idetinfo
  24681. infocode = 0
  24682. verify_number = psn_info.VerifyNumber
  24683. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24684. psn_info, _ := service.GetPsnByPatientId(id)
  24685. PsnNo = psn_info.PsnNo
  24686. PsnCertType = psn_info.PsnCertType
  24687. Certno = psn_info.Certno
  24688. PsnName = psn_info.PsnName
  24689. Gend = psn_info.Gend
  24690. Naty = psn_info.Naty
  24691. Brdy = psn_info.Brdy
  24692. Age = psn_info.Age
  24693. infoStr = psn_info.Insuinfo
  24694. idetinfoStr = psn_info.Idetinfo
  24695. infocode = 0
  24696. verify_number = psn_info.VerifyNumber
  24697. } else {
  24698. var result string
  24699. var requestLog string
  24700. //if miConfig.UserOrgId == 10138 {
  24701. if id_card_type != 4 || id_card_type != 1 {
  24702. var insa string
  24703. if len(patient.InsuplcAdmdvs) > 0 {
  24704. insa = patient.InsuplcAdmdvs
  24705. } else {
  24706. insa = miConfig.InsuplcAdmdvs
  24707. }
  24708. //psn_info, _ := service.GetPsnByPatientId(id)
  24709. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  24710. 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)
  24711. }
  24712. //}
  24713. //else {
  24714. // var insa string
  24715. // if len(patient.InsuplcAdmdvs) > 0 {
  24716. // insa = patient.InsuplcAdmdvs
  24717. // } else {
  24718. // insa = miConfig.InsuplcAdmdvs
  24719. // }
  24720. // 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)
  24721. //}
  24722. if id_card_type == 4 || id_card_type == 1 {
  24723. psn_info, _ := service.GetPsnByPatientId(id)
  24724. PsnNo = psn_info.PsnNo
  24725. PsnCertType = psn_info.PsnCertType
  24726. Certno = psn_info.Certno
  24727. PsnName = psn_info.PsnName
  24728. Gend = psn_info.Gend
  24729. Naty = psn_info.Naty
  24730. Brdy = psn_info.Brdy
  24731. Age = psn_info.Age
  24732. infoStr = psn_info.Insuinfo
  24733. idetinfoStr = psn_info.Idetinfo
  24734. infocode = 0
  24735. verify_number = psn_info.VerifyNumber
  24736. } else {
  24737. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24738. if miConfig.Code == "H15049901371" {
  24739. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24740. utils.ErrorLog("解析失败:%v", err)
  24741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24742. return
  24743. }
  24744. res.ErrMsg = res10265.ErrMsg
  24745. res.Output = res10265.Output
  24746. res.InfRefmsgid = res10265.InfRefmsgid
  24747. } else {
  24748. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24749. utils.ErrorLog("解析失败:%v", err)
  24750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24751. return
  24752. }
  24753. }
  24754. PsnNo = res.Output.Baseinfo.PsnNo
  24755. PsnCertType = res.Output.Baseinfo.PsnCertType
  24756. Certno = res.Output.Baseinfo.Certno
  24757. PsnName = res.Output.Baseinfo.PsnName
  24758. Gend = res.Output.Baseinfo.Gend
  24759. Naty = res.Output.Baseinfo.Naty
  24760. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24761. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24762. infoStr = string(Iinfos)
  24763. idetinfoStr = string(Idetinfos)
  24764. if miConfig.Code == "H15049901371" {
  24765. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24766. } else {
  24767. infocode = res.Infcode
  24768. }
  24769. }
  24770. }
  24771. if infocode == 0 {
  24772. his := models.VMHisPatient{
  24773. Name: name,
  24774. Gender: gender,
  24775. Birthday: birthUnix,
  24776. MedicalTreatmentType: medical_care,
  24777. IdType: certificates,
  24778. IdCardNo: id_card,
  24779. BalanceAccountsType: settlementValue,
  24780. SocialType: social_type,
  24781. MedicalInsuranceNumber: medical_insurance_card,
  24782. RegisterType: register_type,
  24783. RegisterCost: registration_fee,
  24784. TreatmentCost: medical_expenses,
  24785. Status: 1,
  24786. Ctime: time.Now().Unix(),
  24787. Mtime: time.Now().Unix(),
  24788. PsnNo: PsnNo,
  24789. PsnCertType: PsnCertType,
  24790. Certno: Certno,
  24791. PsnName: PsnName,
  24792. Gend: Gend,
  24793. Naty: Naty,
  24794. Brdy: Brdy,
  24795. Age: Age,
  24796. Iinfo: infoStr,
  24797. Idetinfo: idetinfoStr,
  24798. PatientId: patient.ID,
  24799. RecordDate: theTime.Unix(),
  24800. UserOrgId: adminInfo.CurrentOrgId,
  24801. AdminUserId: admin_user_id,
  24802. IsReturn: 1,
  24803. IdCardType: id_card_type,
  24804. Doctor: doctor,
  24805. Departments: department,
  24806. MdtrtGrpType: mdtrt_type,
  24807. }
  24808. timestamp := time.Now().Unix()
  24809. tempTime := time.Unix(timestamp, 0)
  24810. timeFormat := tempTime.Format("20060102150405")
  24811. chrgBchno := rand.Intn(100000) + 10000
  24812. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  24813. his.Number = ipt_otp_no
  24814. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  24815. department, _ := service.GetDepartMentDetail(department)
  24816. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  24817. IdCardNo := ""
  24818. if id_card_type == 1 {
  24819. // IdCardNo = medical_insurance_card
  24820. IdCardNo = patient.IdCardNo
  24821. } else {
  24822. IdCardNo = patient.IdCardNo
  24823. }
  24824. var rf []*ResultFive
  24825. json.Unmarshal([]byte(his.Iinfo), &rf)
  24826. var insutypes []*ResultFive
  24827. var insutype string
  24828. var insuplc_admdvs_temp string
  24829. var is390 int = 0
  24830. var is310 int = 0
  24831. for _, item := range rf {
  24832. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24833. insutypes = append(insutypes, item)
  24834. }
  24835. }
  24836. if len(insutypes) == 1 {
  24837. insutype = insutypes[0].Insutype
  24838. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24839. if insutype == "390" {
  24840. is390 = 1
  24841. }
  24842. if insutype == "310" {
  24843. is310 = 1
  24844. }
  24845. } else {
  24846. for _, i := range insutypes {
  24847. if i.Insutype == "390" {
  24848. is390 = 1
  24849. }
  24850. if i.Insutype == "310" {
  24851. is310 = 1
  24852. }
  24853. }
  24854. }
  24855. if is390 == 1 {
  24856. insutype = "390"
  24857. }
  24858. if is310 == 1 {
  24859. insutype = "310"
  24860. }
  24861. fmt.Println(social_type)
  24862. if social_type > 0 {
  24863. insutype = strconv.FormatInt(social_type, 10)
  24864. }
  24865. var infocode int64
  24866. var resThree ResultThree
  24867. var resThree10265 ResultThree10265
  24868. if len(insuplc_admdvs) == 0 {
  24869. psn_info, _ := service.GetPsnByPatientId(id)
  24870. //if len(psn_info.InsuplcAdmdvs) > 0 {
  24871. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24872. //}
  24873. } else {
  24874. insuplc_admdvs_temp = insuplc_admdvs
  24875. }
  24876. if miConfig.MdtrtareaAdmvs == "421300" {
  24877. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24878. psn_info, _ := service.GetPsnByPatientId(id)
  24879. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24880. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24881. "&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
  24882. resp, requestErr := http.Get(api)
  24883. if requestErr != nil {
  24884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24885. return
  24886. }
  24887. body, ioErr := ioutil.ReadAll(resp.Body)
  24888. if ioErr != nil {
  24889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24891. return
  24892. }
  24893. var respJSON map[string]interface{}
  24894. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24897. return
  24898. }
  24899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24900. result, _ := json.Marshal(respJSON)
  24901. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24902. utils.ErrorLog("解析失败:%v", err)
  24903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24904. return
  24905. }
  24906. infocode = resThree.Infcode
  24907. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24908. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24909. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24910. // insuplc_admdvs_temp =
  24911. //}
  24912. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24913. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24914. //}
  24915. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24916. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24917. "&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
  24918. resp, requestErr := http.Get(api)
  24919. if requestErr != nil {
  24920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24921. return
  24922. }
  24923. body, ioErr := ioutil.ReadAll(resp.Body)
  24924. if ioErr != nil {
  24925. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24927. return
  24928. }
  24929. var respJSON map[string]interface{}
  24930. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24933. return
  24934. }
  24935. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24936. result, _ := json.Marshal(respJSON)
  24937. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24938. utils.ErrorLog("解析失败:%v", err)
  24939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24940. return
  24941. }
  24942. infocode = resThree.Infcode
  24943. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24944. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24945. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24946. // insuplc_admdvs_temp =
  24947. //}
  24948. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24949. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24950. //}
  24951. utils.ErrorLog("解析失败:%v", insutype)
  24952. utils.ErrorLog("解析失败:%v", PsnNo)
  24953. utils.ErrorLog("解析失败:%v", Certno)
  24954. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  24955. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  24956. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  24957. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  24958. utils.ErrorLog("解析失败:%v", PsnNo)
  24959. utils.ErrorLog("解析失败:%v", department.Number)
  24960. utils.ErrorLog("解析失败:%v", department.Name)
  24961. utils.ErrorLog("解析失败:%v", roles.UserName)
  24962. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24963. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24964. "&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
  24965. resp, requestErr := http.Get(api)
  24966. if requestErr != nil {
  24967. utils.ErrorLog("解析失败:%v", requestErr)
  24968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24969. return
  24970. }
  24971. body, ioErr := ioutil.ReadAll(resp.Body)
  24972. if ioErr != nil {
  24973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24975. return
  24976. }
  24977. var respJSON map[string]interface{}
  24978. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24981. return
  24982. }
  24983. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24984. result, _ := json.Marshal(respJSON)
  24985. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24986. utils.ErrorLog("解析失败:%v", err)
  24987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24988. return
  24989. }
  24990. infocode = resThree.Infcode
  24991. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24992. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24993. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  24994. // insuplc_admdvs_temp =
  24995. //}
  24996. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  24997. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24998. //}
  24999. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25000. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25001. "&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
  25002. resp, requestErr := http.Get(api)
  25003. if requestErr != nil {
  25004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25005. return
  25006. }
  25007. body, ioErr := ioutil.ReadAll(resp.Body)
  25008. if ioErr != nil {
  25009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25011. return
  25012. }
  25013. var respJSON map[string]interface{}
  25014. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25017. return
  25018. }
  25019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25020. result, _ := json.Marshal(respJSON)
  25021. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25022. utils.ErrorLog("解析失败:%v", err)
  25023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25024. return
  25025. }
  25026. infocode = resThree.Infcode
  25027. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25028. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25029. psn_info, _ := service.GetPsnByPatientId(id)
  25030. var verify_number string
  25031. if id_card_type == 4 {
  25032. verify_number = psn_info.VerifyNumber
  25033. } else if id_card_type == 1 {
  25034. bas := strings.Split(psn_info.CardInfo, "|")
  25035. cardNumber := bas[2]
  25036. verify_number = cardNumber
  25037. }
  25038. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25039. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25040. "&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
  25041. resp, requestErr := http.Get(api)
  25042. if requestErr != nil {
  25043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25044. return
  25045. }
  25046. body, ioErr := ioutil.ReadAll(resp.Body)
  25047. if ioErr != nil {
  25048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25050. return
  25051. }
  25052. var respJSON map[string]interface{}
  25053. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25056. return
  25057. }
  25058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25059. result, _ := json.Marshal(respJSON)
  25060. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25061. // utils.ErrorLog("解析失败:%v", err)
  25062. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25063. // return
  25064. //}
  25065. //infocode = resThree.Infcode
  25066. //result, _ := json.Marshal(respJSON)
  25067. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25068. utils.ErrorLog("解析失败:%v", err)
  25069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25070. return
  25071. }
  25072. resThree.ErrMsg = resThree10265.ErrMsg
  25073. resThree.Output = resThree10265.Output
  25074. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25075. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25076. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25077. psn_info, _ := service.GetPsnByPatientId(id)
  25078. his.PsnNo = psn_info.PsnNo
  25079. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25080. var cert_no string
  25081. if id_card_type == 3 {
  25082. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  25083. cert_no = IdCardNo
  25084. } else if id_card_type == 4 {
  25085. cert_no = IdCardNo
  25086. psn_info.VerifyNumber = psn_info.VerifyNumber
  25087. } else {
  25088. bas := strings.Split(psn_info.CardInfo, "|")
  25089. cert_no = bas[2]
  25090. }
  25091. var hisPrescription []*models.HisPrescription
  25092. fmt.Println(hisPrescription)
  25093. for _, item := range rf {
  25094. if item.Insutype == insutype {
  25095. //insuplc_admdvs = item.InsuplcAdmdvs
  25096. his.InsuplcAdmdvs = insuplc_admdvs
  25097. }
  25098. }
  25099. his.Insutype = insutype
  25100. var res3101 Result3101
  25101. res3101.Infcode = "0"
  25102. //res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25103. if res3101.Infcode == "0" {
  25104. fmt.Println("33333333")
  25105. if len(res3101.Output.Result) > 0 {
  25106. fmt.Println("222222")
  25107. for _, item := range res3101.Output.Result {
  25108. if len(res3101.ErrMsg) == 0 {
  25109. res3101.ErrMsg = item.VolaCont
  25110. } else {
  25111. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25112. }
  25113. }
  25114. c.ServeSuccessJSON(map[string]interface{}{
  25115. "failed_code": -10,
  25116. "msg": res3101.ErrMsg,
  25117. })
  25118. return
  25119. } else {
  25120. fmt.Println("11111")
  25121. var api string
  25122. if miConfig.MdtrtareaAdmvs == "320921" {
  25123. ipt_otp_no = timeFormat
  25124. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25125. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25126. "&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
  25127. } else {
  25128. ipt_otp_no = timeFormat
  25129. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25130. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25131. "&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
  25132. }
  25133. resp, requestErr := http.Get(api)
  25134. if requestErr != nil {
  25135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25136. return
  25137. }
  25138. body, ioErr := ioutil.ReadAll(resp.Body)
  25139. if ioErr != nil {
  25140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25142. return
  25143. }
  25144. var respJSON map[string]interface{}
  25145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25148. return
  25149. }
  25150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25151. result, _ := json.Marshal(respJSON)
  25152. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25153. utils.ErrorLog("解析失败:%v", err)
  25154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25155. return
  25156. }
  25157. resThree.ErrMsg = resThree10265.ErrMsg
  25158. resThree.Output = resThree10265.Output
  25159. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25160. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25161. }
  25162. } else if res3101.Infcode != "0" {
  25163. c.ServeSuccessJSON(map[string]interface{}{
  25164. "failed_code": -10,
  25165. "msg": res3101.ErrMsg,
  25166. })
  25167. return
  25168. }
  25169. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25170. psn_info, _ := service.GetPsnByPatientId(id)
  25171. var cert_no string
  25172. if id_card_type == 1 {
  25173. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25174. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25175. } else if id_card_type == 4 {
  25176. cert_no = psn_info.VerifyNumber
  25177. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25178. } else {
  25179. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25180. cert_no = psn_info.VerifyNumber
  25181. }
  25182. 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)
  25183. saveLog(result, requestLog, "2201", "挂号")
  25184. if miConfig.Code == "H15049901371" {
  25185. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25186. utils.ErrorLog("解析失败:%v", err)
  25187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25188. return
  25189. }
  25190. resThree.ErrMsg = resThree10265.ErrMsg
  25191. resThree.Output = resThree10265.Output
  25192. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25193. } else {
  25194. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25195. utils.ErrorLog("解析失败:%v", err)
  25196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25197. return
  25198. }
  25199. }
  25200. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25201. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  25202. psn_info, _ := service.GetPsnByPatientId(id)
  25203. var result string
  25204. var requestLog string
  25205. if id_card_type == 1 {
  25206. bas := strings.Split(psn_info.CardInfo, "|")
  25207. basNumber := bas[2]
  25208. card_sn := bas[3]
  25209. 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)
  25210. saveLog(result, requestLog, "2201A", "挂号")
  25211. } else if id_card_type == 2 {
  25212. 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, "", "", "", "", "", "")
  25213. saveLog(result, requestLog, "2201A", "挂号")
  25214. } else {
  25215. 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)
  25216. saveLog(result, requestLog, "2201A", "挂号")
  25217. }
  25218. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25219. utils.ErrorLog("解析失败:%v", err)
  25220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25221. return
  25222. }
  25223. infocode = resThree.Infcode
  25224. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  25225. psn_info, _ := service.GetPsnByPatientId(id)
  25226. var result string
  25227. var requestLog string
  25228. if id_card_type == 1 {
  25229. bas := strings.Split(psn_info.CardInfo, "|")
  25230. basNumber := bas[2]
  25231. card_sn := ""
  25232. 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)
  25233. saveLog(result, requestLog, "2201A", "挂号")
  25234. } else if id_card_type == 2 {
  25235. 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, "", "", "", "", "", "")
  25236. saveLog(result, requestLog, "2201A", "挂号")
  25237. } else {
  25238. 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)
  25239. saveLog(result, requestLog, "2201A", "挂号")
  25240. }
  25241. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25242. utils.ErrorLog("解析失败:%v", err)
  25243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25244. return
  25245. }
  25246. infocode = resThree.Infcode
  25247. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  25248. psn_info, _ := service.GetPsnByPatientId(id)
  25249. var result string
  25250. var requestLog string
  25251. if id_card_type == 1 {
  25252. bas := strings.Split(psn_info.CardInfo, "|")
  25253. basNumber := bas[2]
  25254. card_sn := ""
  25255. 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)
  25256. saveLog(result, requestLog, "2201A", "挂号")
  25257. } else if id_card_type == 2 {
  25258. 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, "", "", "", "", "", "")
  25259. saveLog(result, requestLog, "2201A", "挂号")
  25260. } else {
  25261. 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)
  25262. saveLog(result, requestLog, "2201A", "挂号")
  25263. }
  25264. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25265. utils.ErrorLog("解析失败:%v", err)
  25266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25267. return
  25268. }
  25269. infocode = resThree.Infcode
  25270. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25271. psn_info, _ := service.GetPsnByPatientId(id)
  25272. his.PsnNo = psn_info.PsnNo
  25273. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25274. var cert_no string
  25275. if id_card_type == 1 {
  25276. bas := strings.Split(psn_info.CardInfo, "|")
  25277. cert_no = bas[2]
  25278. } else if id_card_type == 4 {
  25279. cert_no = psn_info.VerifyNumber
  25280. psn_info.VerifyNumber = psn_info.VerifyNumber
  25281. IdCardNo = psn_info.VerifyNumber
  25282. } else {
  25283. cert_no = IdCardNo
  25284. psn_info.VerifyNumber = cert_no
  25285. }
  25286. for _, item := range rf {
  25287. if item.Insutype == insutype {
  25288. his.InsuplcAdmdvs = insuplc_admdvs
  25289. }
  25290. }
  25291. his.Insutype = insutype
  25292. var api string
  25293. ipt_otp_no = timeFormat
  25294. 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 +
  25295. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25296. "&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
  25297. resp, requestErr := http.Get(api)
  25298. if requestErr != nil {
  25299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25300. return
  25301. }
  25302. body, ioErr := ioutil.ReadAll(resp.Body)
  25303. if ioErr != nil {
  25304. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25306. return
  25307. }
  25308. var respJSON map[string]interface{}
  25309. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25312. return
  25313. }
  25314. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25315. if status == "0" {
  25316. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25317. c.ServeSuccessJSON(map[string]interface{}{
  25318. "failed_code": -10,
  25319. "msg": err_msg,
  25320. })
  25321. return
  25322. }
  25323. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25324. result, _ := json.Marshal(respJSON)
  25325. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25326. utils.ErrorLog("解析失败:%v", err)
  25327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25328. return
  25329. }
  25330. infocode = resThree.Infcode
  25331. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25332. psn_info, _ := service.GetPsnByPatientId(id)
  25333. his.PsnNo = psn_info.PsnNo
  25334. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25335. var cert_no string
  25336. if id_card_type == 1 {
  25337. bas := strings.Split(psn_info.CardInfo, "|")
  25338. cert_no = bas[2]
  25339. } else if id_card_type == 4 {
  25340. cert_no = psn_info.VerifyNumber
  25341. psn_info.VerifyNumber = psn_info.VerifyNumber
  25342. IdCardNo = psn_info.VerifyNumber
  25343. } else {
  25344. cert_no = IdCardNo
  25345. psn_info.VerifyNumber = cert_no
  25346. }
  25347. for _, item := range rf {
  25348. if item.Insutype == insutype {
  25349. his.InsuplcAdmdvs = insuplc_admdvs
  25350. patient.InsuplcAdmdvs = insuplc_admdvs
  25351. }
  25352. }
  25353. his.Insutype = insutype
  25354. var api string
  25355. ipt_otp_no = timeFormat
  25356. 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 +
  25357. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25358. "&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
  25359. resp, requestErr := http.Get(api)
  25360. if requestErr != nil {
  25361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25362. return
  25363. }
  25364. body, ioErr := ioutil.ReadAll(resp.Body)
  25365. if ioErr != nil {
  25366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25368. return
  25369. }
  25370. var respJSON map[string]interface{}
  25371. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25374. return
  25375. }
  25376. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25377. if status == "0" {
  25378. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25379. c.ServeSuccessJSON(map[string]interface{}{
  25380. "failed_code": -10,
  25381. "msg": err_msg,
  25382. })
  25383. return
  25384. }
  25385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25386. result, _ := json.Marshal(respJSON)
  25387. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25388. utils.ErrorLog("解析失败:%v", err)
  25389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25390. return
  25391. }
  25392. infocode = resThree.Infcode
  25393. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25394. hour := time.Now().Format("15")
  25395. min := time.Now().Format("04")
  25396. sec := time.Now().Format("05")
  25397. begin := record_time +" " + hour + ":" + min + ":" + sec
  25398. psn_info, _ := service.GetPsnByPatientId(id)
  25399. var result string
  25400. var requestLog string
  25401. if id_card_type == 1 {
  25402. bas := strings.Split(psn_info.CardInfo, "|")
  25403. basNumber := bas[2]
  25404. card_sn := bas[3]
  25405. 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,begin)
  25406. saveLog(result, requestLog, "2201A", "挂号")
  25407. } else if id_card_type == 2 {
  25408. 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, "", "",begin)
  25409. saveLog(result, requestLog, "2201A", "挂号")
  25410. } else {
  25411. 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, "", "",begin)
  25412. saveLog(result, requestLog, "2201A", "挂号")
  25413. }
  25414. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25415. utils.ErrorLog("解析失败:%v", err)
  25416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25417. return
  25418. }
  25419. infocode = resThree.Infcode
  25420. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25421. psn_info, _ := service.GetPsnByPatientId(id)
  25422. 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)
  25423. saveLog(result, requestLog, "2201A", "挂号")
  25424. if miConfig.Code == "H15049901371" {
  25425. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25426. utils.ErrorLog("解析失败:%v", err)
  25427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25428. return
  25429. }
  25430. resThree.ErrMsg = resThree10265.ErrMsg
  25431. resThree.Output = resThree10265.Output
  25432. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25433. } else {
  25434. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25435. utils.ErrorLog("解析失败:%v", err)
  25436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25437. return
  25438. }
  25439. }
  25440. if miConfig.Code == "H15049901371" {
  25441. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25442. } else {
  25443. infocode = resThree.Infcode
  25444. }
  25445. } else {
  25446. psn_info, _ := service.GetPsnByPatientId(id)
  25447. if id_card_type == 4 || id_card_type == 1 {
  25448. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25449. }
  25450. var rf []*ResultFive
  25451. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25452. var insutypes []*ResultFive
  25453. var insutype string
  25454. var is390 int = 0
  25455. var is310 int = 0
  25456. for _, item := range rf {
  25457. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25458. insutypes = append(insutypes, item)
  25459. }
  25460. }
  25461. if len(insutypes) == 1 {
  25462. insutype = insutypes[0].Insutype
  25463. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25464. } else {
  25465. for _, i := range insutypes {
  25466. if i.Insutype == "390" {
  25467. is390 = 1
  25468. }
  25469. if i.Insutype == "310" {
  25470. is310 = 1
  25471. }
  25472. }
  25473. }
  25474. if is390 == 1 {
  25475. insutype = "390"
  25476. }
  25477. if is310 == 1 {
  25478. insutype = "310"
  25479. }
  25480. fmt.Println(len(insutypes))
  25481. if len(insutypes) == 0 {
  25482. for index, item := range rf {
  25483. if index == 0 {
  25484. insutype = item.Insutype
  25485. insuplc_admdvs = item.InsuplcAdmdvs
  25486. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25487. }
  25488. }
  25489. fmt.Println(insutype)
  25490. fmt.Println(insuplc_admdvs)
  25491. }
  25492. if social_type > 0 {
  25493. insutype = strconv.FormatInt(social_type, 10)
  25494. }
  25495. fmt.Println("--------")
  25496. fmt.Println(psn_info)
  25497. fmt.Println(psn_info.PsnNo)
  25498. for _, item := range rf {
  25499. if item.Insutype == insutype{
  25500. insutype = item.Insutype
  25501. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25502. }
  25503. }
  25504. if miConfig.MdtrtareaAdmvs == "441202" {
  25505. var hisPrescription []*models.HisPrescription
  25506. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25507. if res3101.Infcode == 0 {
  25508. fmt.Println("33333333")
  25509. if len(res3101.Output.Result) > 0 {
  25510. fmt.Println("222222")
  25511. for _, item := range res3101.Output.Result {
  25512. if len(res3101.ErrMsg) == 0 {
  25513. res3101.ErrMsg = item.VolaCont
  25514. } else {
  25515. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25516. }
  25517. }
  25518. c.ServeSuccessJSON(map[string]interface{}{
  25519. "failed_code": -10,
  25520. "msg": res3101.ErrMsg,
  25521. })
  25522. return
  25523. } else {
  25524. hour := time.Now().Format("15")
  25525. min := time.Now().Format("04")
  25526. sec := time.Now().Format("05")
  25527. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25528. fmt.Println(record_time_two)
  25529. 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)
  25530. saveLog(result, requestLog, "2201A", "挂号")
  25531. if miConfig.Code == "H15049901371" {
  25532. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25533. utils.ErrorLog("解析失败:%v", err)
  25534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25535. return
  25536. }
  25537. resThree.ErrMsg = resThree10265.ErrMsg
  25538. resThree.Output = resThree10265.Output
  25539. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25540. } else {
  25541. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25542. utils.ErrorLog("解析失败:%v", err)
  25543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25544. return
  25545. }
  25546. }
  25547. if miConfig.Code == "H15049901371" {
  25548. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25549. } else {
  25550. infocode = resThree.Infcode
  25551. }
  25552. }
  25553. } else if res3101.Infcode != 0 {
  25554. c.ServeSuccessJSON(map[string]interface{}{
  25555. "failed_code": -10,
  25556. "msg": res3101.ErrMsg,
  25557. })
  25558. return
  25559. }
  25560. } else if miConfig.MdtrtareaAdmvs == "440205" {
  25561. var hisPrescription []*models.HisPrescription
  25562. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25563. if res3101.Infcode == 0 {
  25564. fmt.Println("33333333")
  25565. if len(res3101.Output.Result) > 0 {
  25566. fmt.Println("222222")
  25567. for _, item := range res3101.Output.Result {
  25568. if len(res3101.ErrMsg) == 0 {
  25569. res3101.ErrMsg = item.VolaCont
  25570. } else {
  25571. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25572. }
  25573. }
  25574. c.ServeSuccessJSON(map[string]interface{}{
  25575. "failed_code": -10,
  25576. "msg": res3101.ErrMsg,
  25577. })
  25578. return
  25579. } else {
  25580. hour := time.Now().Format("15")
  25581. min := time.Now().Format("04")
  25582. sec := time.Now().Format("05")
  25583. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25584. fmt.Println(record_time_two)
  25585. 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)
  25586. saveLog(result, requestLog, "2201A", "挂号")
  25587. if miConfig.Code == "H15049901371" {
  25588. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25589. utils.ErrorLog("解析失败:%v", err)
  25590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25591. return
  25592. }
  25593. resThree.ErrMsg = resThree10265.ErrMsg
  25594. resThree.Output = resThree10265.Output
  25595. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25596. } else {
  25597. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25598. utils.ErrorLog("解析失败:%v", err)
  25599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25600. return
  25601. }
  25602. }
  25603. if miConfig.Code == "H15049901371" {
  25604. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25605. } else {
  25606. infocode = resThree.Infcode
  25607. }
  25608. }
  25609. } else if res3101.Infcode != 0 {
  25610. c.ServeSuccessJSON(map[string]interface{}{
  25611. "failed_code": -10,
  25612. "msg": res3101.ErrMsg,
  25613. })
  25614. return
  25615. }
  25616. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25617. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25618. psn_info, _ := service.GetPsnByPatientId(id)
  25619. var verify_number string
  25620. if id_card_type == 4 {
  25621. verify_number = psn_info.VerifyNumber
  25622. } else if id_card_type == 1 {
  25623. bas := strings.Split(psn_info.CardInfo, "|")
  25624. cardNumber := bas[2]
  25625. verify_number = cardNumber
  25626. } else {
  25627. verify_number = psn_info.Certno
  25628. }
  25629. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25630. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25631. "&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
  25632. resp, requestErr := http.Get(api)
  25633. if requestErr != nil {
  25634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25635. return
  25636. }
  25637. body, ioErr := ioutil.ReadAll(resp.Body)
  25638. if ioErr != nil {
  25639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25641. return
  25642. }
  25643. var respJSON map[string]interface{}
  25644. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25647. return
  25648. }
  25649. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25650. result, _ := json.Marshal(respJSON)
  25651. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25652. utils.ErrorLog("解析失败:%v", err)
  25653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25654. return
  25655. }
  25656. infocode = resThree.Infcode
  25657. } else {
  25658. hour := time.Now().Format("15")
  25659. min := time.Now().Format("04")
  25660. sec := time.Now().Format("05")
  25661. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25662. if id_card_type == 1 {
  25663. for _, item := range rf {
  25664. if item.Insutype == strconv.FormatInt(social_type, 10) {
  25665. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  25666. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25667. } else if strconv.FormatInt(social_type, 10) == "390" {
  25668. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25669. } else {
  25670. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25671. }
  25672. }
  25673. }
  25674. }
  25675. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  25676. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25677. }
  25678. if id_card_type == 1 {
  25679. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  25680. bas := strings.Split(psn_info.CardInfo, "|")
  25681. basNumber := bas[1]
  25682. IdCardNo = basNumber
  25683. }
  25684. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  25685. IdCardNo = psn_info.VerifyNumber
  25686. }
  25687. if len(insuplc_admdvs_temp) == 0 {
  25688. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25689. }
  25690. var result string
  25691. var requestLog string
  25692. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882"{
  25693. var hisPrescription []*models.HisPrescription
  25694. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25695. if res3101.Infcode == 0 {
  25696. if len(res3101.Output.Result) > 0 {
  25697. if len(res3101.Output.Result) > 0 {
  25698. c.ServeSuccessJSON(map[string]interface{}{
  25699. "failed_code": -10,
  25700. "failed_type": 100,
  25701. "warm_type": 1,
  25702. "msg": res3101,
  25703. })
  25704. return
  25705. } else {
  25706. c.ServeSuccessJSON(map[string]interface{}{
  25707. "failed_code": -10,
  25708. "msg": res3101.ErrMsg,
  25709. })
  25710. return
  25711. }
  25712. } else {
  25713. hour := time.Now().Format("15")
  25714. min := time.Now().Format("04")
  25715. sec := time.Now().Format("05")
  25716. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25717. fmt.Println(record_time_two)
  25718. if his.IdCardType == 2 {
  25719. IdCardNo = psn_info.Certno
  25720. psn_info.VerifyNumber = psn_info.Certno
  25721. } else if his.IdCardType == 4 {
  25722. IdCardNo = psn_info.Certno
  25723. } else {
  25724. bas := strings.Split(psn_info.CardInfo, "|")
  25725. IdCardNo = bas[2]
  25726. }
  25727. aaaa = insutype
  25728. 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)
  25729. saveLog(result, requestLog, "2201A", "挂号")
  25730. if miConfig.Code == "H15049901371" {
  25731. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25732. utils.ErrorLog("解析失败:%v", err)
  25733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25734. return
  25735. }
  25736. resThree.ErrMsg = resThree10265.ErrMsg
  25737. resThree.Output = resThree10265.Output
  25738. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25739. } else {
  25740. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25741. utils.ErrorLog("解析失败:%v", err)
  25742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25743. return
  25744. }
  25745. }
  25746. if miConfig.Code == "H15049901371" {
  25747. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25748. } else {
  25749. infocode = resThree.Infcode
  25750. }
  25751. }
  25752. } else if res3101.Infcode != 0 {
  25753. c.ServeSuccessJSON(map[string]interface{}{
  25754. "failed_code": -10,
  25755. "msg": res3101.ErrMsg,
  25756. })
  25757. return
  25758. }
  25759. } else {
  25760. psn_info, _ := service.GetPsnByPatientId(id)
  25761. var rf []*ResultFive
  25762. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25763. //var insutypes []*ResultFive
  25764. var insutype string
  25765. var insutypes []*ResultFive
  25766. var is390 int = 0
  25767. var is310 int = 0
  25768. for _, item := range rf {
  25769. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25770. insutypes = append(insutypes, item)
  25771. }
  25772. }
  25773. if len(insutypes) == 1 {
  25774. insutype = insutypes[0].Insutype
  25775. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25776. } else {
  25777. for _, i := range insutypes {
  25778. if i.Insutype == "390" {
  25779. is390 = 1
  25780. }
  25781. if i.Insutype == "310" {
  25782. is310 = 1
  25783. }
  25784. }
  25785. }
  25786. if is390 == 1 {
  25787. insutype = "390"
  25788. }
  25789. if is310 == 1 {
  25790. insutype = "310"
  25791. }
  25792. if len(insutypes) == 0 {
  25793. insutype = "310"
  25794. }
  25795. if social_type > 0 {
  25796. insutype = strconv.FormatInt(social_type, 10)
  25797. }
  25798. for _, item := range rf {
  25799. if item.Insutype == insutype {
  25800. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25801. }
  25802. }
  25803. if len(insuplc_admdvs_tt) > 0 {
  25804. insuplc_admdvs_temp = insuplc_admdvs_tt
  25805. }
  25806. 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)
  25807. saveLog(result, requestLog, "2201A", "挂号")
  25808. }
  25809. if miConfig.Code == "H15049901371" {
  25810. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25811. utils.ErrorLog("解析失败:%v", err)
  25812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25813. return
  25814. }
  25815. resThree.ErrMsg = resThree10265.ErrMsg
  25816. resThree.Output = resThree10265.Output
  25817. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25818. } else {
  25819. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25820. utils.ErrorLog("解析失败:%v", err)
  25821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25822. return
  25823. }
  25824. }
  25825. if miConfig.Code == "H15049901371" {
  25826. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25827. } else {
  25828. infocode = resThree.Infcode
  25829. }
  25830. }
  25831. }
  25832. if infocode == -1 {
  25833. adminUser := c.GetAdminUserInfo()
  25834. errlog := &models.HisOrderError{
  25835. UserOrgId: adminUser.CurrentOrgId,
  25836. Ctime: time.Now().Unix(),
  25837. Mtime: time.Now().Unix(),
  25838. ErrMsg: resThree.ErrMsg,
  25839. Status: 1,
  25840. PatientId: id,
  25841. RecordTime: recordDateTime,
  25842. Stage: 2,
  25843. }
  25844. service.CreateErrMsgLog(errlog)
  25845. c.ServeSuccessJSON(map[string]interface{}{
  25846. "failed_code": -10,
  25847. "msg": resThree.ErrMsg,
  25848. })
  25849. return
  25850. }
  25851. utils.ErrorLog("解析失败:%v", insutype)
  25852. his.Number = resThree.Output.Data.MdtrtID
  25853. his.PsnNo = resThree.Output.Data.PsnNo
  25854. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  25855. his.IdCardNo = patient.IdCardNo
  25856. his.PhoneNumber = patient.Phone
  25857. his.UserOrgId = adminInfo.CurrentOrgId
  25858. his.Insutype = insutype
  25859. if miConfig.Code == "H44030500255"{
  25860. his.Insutype = aaaa
  25861. }
  25862. his.Ctime = time.Now().Unix()
  25863. his.Mtime = time.Now().Unix()
  25864. his.InsuplcAdmdvs = insuplc_admdvs_temp
  25865. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  25866. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25867. }
  25868. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  25869. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25870. }
  25871. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  25872. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  25873. }
  25874. his.Status = 1
  25875. his.MdtrtGrpType = mdtrt_type
  25876. service.UpdateHisPatientStatus(&his)
  25877. service.UpdateHisPatient123(&patient)
  25878. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  25879. c.ServeSuccessJSON(map[string]interface{}{
  25880. "his_info": his,
  25881. })
  25882. } else {
  25883. adminUser := c.GetAdminUserInfo()
  25884. errlog := &models.HisOrderError{
  25885. UserOrgId: adminUser.CurrentOrgId,
  25886. Ctime: time.Now().Unix(),
  25887. Mtime: time.Now().Unix(),
  25888. ErrMsg: res.ErrMsg,
  25889. Status: 1,
  25890. PatientId: id,
  25891. RecordTime: recordDateTime,
  25892. Stage: 1,
  25893. }
  25894. service.CreateErrMsgLog(errlog)
  25895. c.ServeSuccessJSON(map[string]interface{}{
  25896. "failed_code": -10,
  25897. "msg": res.ErrMsg,
  25898. })
  25899. return
  25900. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  25901. }
  25902. }
  25903. }
  25904. func (c *HisApiController) GetUploadInfo() {
  25905. id, _ := c.GetInt64("id")
  25906. record_time := c.GetString("record_time")
  25907. his_patient_id, _ := c.GetInt64("his_patient_id")
  25908. order_id, _ := c.GetInt64("order_id")
  25909. pay_way, _ := c.GetInt64("pay_way")
  25910. pay_ways := c.GetString("pay_ways")
  25911. oth_desc := c.GetString("oth_desc")
  25912. pay_price, _ := c.GetFloat("pay_price")
  25913. pay_card_no := c.GetString("pay_card_no")
  25914. discount_price, _ := c.GetFloat("discount_price")
  25915. preferential_price, _ := c.GetFloat("preferential_price")
  25916. reality_price, _ := c.GetFloat("reality_price")
  25917. found_price, _ := c.GetFloat("found_price")
  25918. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  25919. private_price, _ := c.GetFloat("private_price")
  25920. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  25921. admin_user_id, _ := c.GetInt64("admin_user_id")
  25922. fapiao_code := c.GetString("fapiao_code")
  25923. fapiao_number := c.GetString("fapiao_number")
  25924. diagnosis_id := c.GetString("diagnosis")
  25925. sick_type, _ := c.GetInt64("sick_type")
  25926. reg_type, _ := c.GetInt64("p_type")
  25927. begin_time := c.GetString("begin_time")
  25928. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  25929. cash_pay := c.GetString("cash_pay")
  25930. band_card_pay := c.GetString("band_card_pay")
  25931. wechat_pay := c.GetString("wechat_pay")
  25932. ali_pay := c.GetString("ali_pay")
  25933. jifen_pay := c.GetString("jifen_pay")
  25934. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  25935. fmt.Println(acct_used_flag)
  25936. id_str := c.GetString("ids")
  25937. ids_arr := strings.Split(id_str, ",")
  25938. timeLayout := "2006-01-02"
  25939. loc, _ := time.LoadLocation("Local")
  25940. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25941. if err != nil {
  25942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25943. return
  25944. }
  25945. recordDateTime := theTime.Unix()
  25946. adminUser := c.GetAdminUserInfo()
  25947. var tempOrder models.HisOrder
  25948. tempOrder, _ = service.GetHisOrderByID(order_id)
  25949. var prescriptions []*models.HisPrescription
  25950. var start_time int64
  25951. var end_time int64
  25952. //押金模块
  25953. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  25954. tmp_decimal := c.GetString("tmp_decimal")
  25955. var decimal float64 //本次使用的押金
  25956. var errmsg error
  25957. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  25958. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  25959. return
  25960. }
  25961. if len(tmp_decimal) > 0 {
  25962. if tmp_decimal[0] == 45 {
  25963. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  25964. return
  25965. }
  25966. }
  25967. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  25968. fmt.Println(errs)
  25969. decimal = tt
  25970. //if adminUser.CurrentOrgId == 10106{
  25971. // if len(fapiao_code) == 0{
  25972. // fapiao_code = "144072080589"
  25973. // }
  25974. // if len(fapiao_number) == 0{
  25975. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  25976. // if order.ID == 0{
  25977. // fapiao_number = "00001520"
  25978. // }else{
  25979. // //fapiao_code = "00001520"
  25980. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  25981. // var zero string
  25982. // if fpNumber >= 1000{
  25983. // zero = "0000" + strconv.Itoa(fpNumber)
  25984. // }else if fpNumber >= 10000{
  25985. // zero = "000" + strconv.Itoa(fpNumber)
  25986. // } else if fpNumber >= 100000{
  25987. // zero = "00" + strconv.Itoa(fpNumber)
  25988. // } else if fpNumber >= 1000000{
  25989. // zero = "0" + strconv.Itoa(fpNumber)
  25990. // }else {
  25991. // zero = strconv.Itoa(fpNumber)
  25992. // }
  25993. // fapiao_number = zero
  25994. // }
  25995. // }
  25996. //}
  25997. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25998. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25999. var patientPrescription models.HisPrescriptionInfo
  26000. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26001. if patientPrescription.ID == 0 {
  26002. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26003. }
  26004. //if patientPrescription.Do
  26005. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26006. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26007. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26008. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26009. var config []*models.HisXtDiagnoseConfig
  26010. for _, item := range diagnosis_ids {
  26011. id, _ := strconv.ParseInt(item, 10, 64)
  26012. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26013. config = append(config, &diagnosisConfig)
  26014. }
  26015. sickConfig, _ := service.FindSickById(sick_type)
  26016. //if tempOrder.ID == 0 {
  26017. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  26018. //}
  26019. if tempOrder.ID == 0 {
  26020. var result string
  26021. var requestLog string
  26022. var res2 ResultSix
  26023. var res3 GZResultSix
  26024. var ressix10265 ResultSix10265
  26025. if miConfig.MdtrtareaAdmvs == "421300" {
  26026. data := make(map[string]interface{})
  26027. client := &http.Client{}
  26028. data["psn_no"] = his.PsnNo
  26029. data["mdtrt_id"] = his.Number
  26030. data["opter"] = roles.UserName
  26031. data["org_name"] = miConfig.OrgName
  26032. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26033. data["doctor_id"] = doctor_info.DoctorNumber
  26034. data["doctor_name"] = doctor_info.UserName
  26035. data["department"] = department.Name
  26036. data["fixmedins_code"] = miConfig.Code
  26037. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26038. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26039. data["secret_key"] = miConfig.SecretKey
  26040. data["sick_code"] = sickConfig.CountryCode
  26041. data["sick_name"] = sickConfig.ClassName
  26042. data["dept"] = strconv.FormatInt(department.ID, 10)
  26043. data["config"] = config
  26044. data["begin_time"] = begin_time
  26045. bytesData, _ := json.Marshal(data)
  26046. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26047. resp, _ := client.Do(req)
  26048. defer resp.Body.Close()
  26049. body, ioErr := ioutil.ReadAll(resp.Body)
  26050. if ioErr != nil {
  26051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26053. return
  26054. }
  26055. var respJSON map[string]interface{}
  26056. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26059. return
  26060. }
  26061. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26062. userJSONBytes, _ := json.Marshal(respJSON)
  26063. fmt.Println("log")
  26064. fmt.Println(string(userJSONBytes))
  26065. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26066. utils.ErrorLog("解析失败:%v", err)
  26067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26068. return
  26069. }
  26070. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26071. data := make(map[string]interface{})
  26072. client := &http.Client{}
  26073. data["psn_no"] = his.PsnNo
  26074. data["mdtrt_id"] = his.Number
  26075. data["opter"] = roles.UserName
  26076. data["org_name"] = miConfig.OrgName
  26077. if reg_type == 11 && his.Insutype == "390" {
  26078. data["med_type"] = "110104"
  26079. } else {
  26080. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26081. }
  26082. data["doctor_id"] = doctor_info.DoctorNumber
  26083. data["doctor_name"] = doctor_info.UserName
  26084. data["department"] = department.Name
  26085. data["fixmedins_code"] = miConfig.Code
  26086. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26087. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26088. data["secret_key"] = miConfig.SecretKey
  26089. data["sick_code"] = sickConfig.CountryCode
  26090. data["sick_name"] = sickConfig.ClassName
  26091. data["dept"] = strconv.FormatInt(department.ID, 10)
  26092. data["config"] = config
  26093. data["begin_time"] = begin_time
  26094. bytesData, _ := json.Marshal(data)
  26095. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26096. resp, _ := client.Do(req)
  26097. defer resp.Body.Close()
  26098. body, ioErr := ioutil.ReadAll(resp.Body)
  26099. if ioErr != nil {
  26100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26102. return
  26103. }
  26104. var respJSON map[string]interface{}
  26105. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26108. return
  26109. }
  26110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26111. userJSONBytes, _ := json.Marshal(respJSON)
  26112. fmt.Println("log")
  26113. fmt.Println(string(userJSONBytes))
  26114. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26115. utils.ErrorLog("解析失败:%v", err)
  26116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26117. return
  26118. }
  26119. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26120. data := make(map[string]interface{})
  26121. client := &http.Client{}
  26122. data["psn_no"] = his.PsnNo
  26123. data["mdtrt_id"] = his.Number
  26124. data["opter"] = roles.UserName
  26125. data["org_name"] = miConfig.OrgName
  26126. if reg_type == 11 && his.Insutype == "390" {
  26127. data["med_type"] = "110104"
  26128. } else {
  26129. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26130. }
  26131. data["doctor_id"] = doctor_info.DoctorNumber
  26132. data["doctor_name"] = doctor_info.UserName
  26133. data["department"] = department.Name
  26134. data["fixmedins_code"] = miConfig.Code
  26135. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26136. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26137. data["secret_key"] = miConfig.SecretKey
  26138. data["sick_code"] = sickConfig.CountryCode
  26139. data["sick_name"] = sickConfig.ClassName
  26140. data["dept"] = strconv.FormatInt(department.ID, 10)
  26141. data["config"] = config
  26142. data["begin_time"] = begin_time
  26143. bytesData, _ := json.Marshal(data)
  26144. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26145. resp, _ := client.Do(req)
  26146. defer resp.Body.Close()
  26147. body, ioErr := ioutil.ReadAll(resp.Body)
  26148. if ioErr != nil {
  26149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26151. return
  26152. }
  26153. var respJSON map[string]interface{}
  26154. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26157. return
  26158. }
  26159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26160. userJSONBytes, _ := json.Marshal(respJSON)
  26161. fmt.Println("log")
  26162. fmt.Println(string(userJSONBytes))
  26163. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26164. utils.ErrorLog("解析失败:%v", err)
  26165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26166. return
  26167. }
  26168. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26169. data := make(map[string]interface{})
  26170. client := &http.Client{}
  26171. data["psn_no"] = his.PsnNo
  26172. data["mdtrt_id"] = his.Number
  26173. data["opter"] = roles.UserName
  26174. data["org_name"] = miConfig.OrgName
  26175. if reg_type == 11 && his.Insutype == "390" {
  26176. data["med_type"] = "110104"
  26177. } else {
  26178. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26179. }
  26180. data["doctor_id"] = doctor_info.DoctorNumber
  26181. data["doctor_name"] = doctor_info.UserName
  26182. data["department"] = department.Name
  26183. data["fixmedins_code"] = miConfig.Code
  26184. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26185. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26186. data["secret_key"] = miConfig.SecretKey
  26187. data["sick_code"] = sickConfig.CountryCode
  26188. data["sick_name"] = sickConfig.ClassName
  26189. data["dept"] = strconv.FormatInt(department.ID, 10)
  26190. data["config"] = config
  26191. data["begin_time"] = begin_time
  26192. bytesData, _ := json.Marshal(data)
  26193. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26194. resp, _ := client.Do(req)
  26195. defer resp.Body.Close()
  26196. body, ioErr := ioutil.ReadAll(resp.Body)
  26197. if ioErr != nil {
  26198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26200. return
  26201. }
  26202. var respJSON map[string]interface{}
  26203. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26206. return
  26207. }
  26208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26209. userJSONBytes, _ := json.Marshal(respJSON)
  26210. fmt.Println("log")
  26211. fmt.Println(string(userJSONBytes))
  26212. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26213. utils.ErrorLog("解析失败:%v", err)
  26214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26215. return
  26216. }
  26217. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26218. data := make(map[string]interface{})
  26219. client := &http.Client{}
  26220. data["psn_no"] = his.PsnNo
  26221. data["mdtrt_id"] = his.Number
  26222. data["doctor"] = roles.UserName
  26223. data["department"] = department.Name
  26224. data["org_name"] = miConfig.OrgName
  26225. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26226. data["doctor_id"] = doctor_info.DoctorNumber
  26227. data["new_doctor_name"] = doctor_info.UserName
  26228. data["fixmedins_code"] = miConfig.Code
  26229. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26230. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26231. data["secret_key"] = miConfig.SecretKey
  26232. data["sick_code"] = sickConfig.CountryCode
  26233. data["sick_name"] = sickConfig.ClassName
  26234. data["url"] = miConfig.Url
  26235. data["ak"] = miConfig.AccessKey
  26236. data["begin_time"] = begin_time
  26237. data["cainfo"] = miConfig.Cainfo
  26238. data["dept"] = strconv.FormatInt(department.ID, 10)
  26239. data["config"] = config
  26240. bytesData, _ := json.Marshal(data)
  26241. var req *http.Request
  26242. if miConfig.MdtrtareaAdmvs == "320921" {
  26243. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26244. //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 +
  26245. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26246. } else {
  26247. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26248. }
  26249. resp, _ := client.Do(req)
  26250. defer resp.Body.Close()
  26251. body, ioErr := ioutil.ReadAll(resp.Body)
  26252. if ioErr != nil {
  26253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26255. return
  26256. }
  26257. var respJSON map[string]interface{}
  26258. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26261. return
  26262. }
  26263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26264. userJSONBytes, _ := json.Marshal(respJSON)
  26265. fmt.Println("log")
  26266. fmt.Println(string(userJSONBytes))
  26267. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26268. utils.ErrorLog("解析失败:%v", err)
  26269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26270. return
  26271. }
  26272. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26273. res2.Output = ressix10265.Output
  26274. res2.ErrMsg = ressix10265.ErrMsg
  26275. res2.Cainfo = ressix10265.Cainfo
  26276. res2.WarnMsg = ressix10265.WarnMsg
  26277. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26278. res2.Infcode = infocode
  26279. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26280. data := make(map[string]interface{})
  26281. client := &http.Client{}
  26282. data["psn_no"] = his.PsnNo
  26283. data["mdtrt_id"] = his.Number
  26284. data["doctor"] = roles.UserName
  26285. data["department"] = department.Name
  26286. data["org_name"] = miConfig.OrgName
  26287. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26288. data["doctor_id"] = doctor_info.DoctorNumber
  26289. data["new_doctor_name"] = doctor_info.UserName
  26290. data["fixmedins_code"] = miConfig.Code
  26291. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26292. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26293. data["secret_key"] = miConfig.SecretKey
  26294. data["sick_code"] = sickConfig.CountryCode
  26295. data["sick_name"] = sickConfig.ClassName
  26296. data["url"] = miConfig.Url
  26297. data["ak"] = miConfig.AccessKey
  26298. data["begin_time"] = begin_time
  26299. data["cainfo"] = miConfig.Cainfo
  26300. data["dept"] = strconv.FormatInt(department.ID, 10)
  26301. data["config"] = config
  26302. bytesData, _ := json.Marshal(data)
  26303. var req *http.Request
  26304. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26305. resp, _ := client.Do(req)
  26306. defer resp.Body.Close()
  26307. body, ioErr := ioutil.ReadAll(resp.Body)
  26308. if ioErr != nil {
  26309. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26311. return
  26312. }
  26313. var respJSON map[string]interface{}
  26314. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26315. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26317. return
  26318. }
  26319. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26320. userJSONBytes, _ := json.Marshal(respJSON)
  26321. fmt.Println("log")
  26322. fmt.Println(string(userJSONBytes))
  26323. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26324. utils.ErrorLog("解析失败:%v", err)
  26325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26326. return
  26327. }
  26328. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26329. res2.Output = ressix10265.Output
  26330. res2.ErrMsg = ressix10265.ErrMsg
  26331. res2.Cainfo = ressix10265.Cainfo
  26332. res2.WarnMsg = ressix10265.WarnMsg
  26333. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26334. res2.Infcode = infocode
  26335. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26336. 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)
  26337. saveLog(result, requestLog, "2203", "上传就诊信息")
  26338. var respJSON2 map[string]interface{}
  26339. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26342. return
  26343. }
  26344. userJSONBytes2, _ := json.Marshal(respJSON2)
  26345. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26346. utils.ErrorLog("解析失败:%v", err)
  26347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26348. return
  26349. }
  26350. 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)
  26351. fmt.Println(result2)
  26352. fmt.Println(src_request)
  26353. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26354. data := make(map[string]interface{})
  26355. client := &http.Client{}
  26356. data["psn_no"] = his.PsnNo
  26357. data["mdtrt_id"] = his.Number
  26358. data["doctor"] = roles.UserName
  26359. data["department"] = department.Name
  26360. data["org_name"] = miConfig.OrgName
  26361. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26362. data["doctor_id"] = doctor_info.DoctorNumber
  26363. data["new_doctor_name"] = doctor_info.UserName
  26364. data["fixmedins_code"] = miConfig.Code
  26365. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26366. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26367. data["secret_key"] = miConfig.SecretKey
  26368. data["sick_code"] = sickConfig.CountryCode
  26369. data["sick_name"] = sickConfig.ClassName
  26370. data["url"] = miConfig.Url
  26371. data["ak"] = miConfig.AccessKey
  26372. data["begin_time"] = begin_time
  26373. data["cainfo"] = miConfig.Cainfo
  26374. data["dept"] = strconv.FormatInt(department.ID, 10)
  26375. data["config"] = config
  26376. bytesData, _ := json.Marshal(data)
  26377. var req *http.Request
  26378. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  26379. resp, _ := client.Do(req)
  26380. defer resp.Body.Close()
  26381. body, ioErr := ioutil.ReadAll(resp.Body)
  26382. if ioErr != nil {
  26383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26385. return
  26386. }
  26387. var respJSON map[string]interface{}
  26388. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26391. return
  26392. }
  26393. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26394. userJSONBytes, _ := json.Marshal(respJSON)
  26395. fmt.Println("log")
  26396. fmt.Println(string(userJSONBytes))
  26397. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26398. utils.ErrorLog("解析失败:%v", err)
  26399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26400. return
  26401. }
  26402. } else {
  26403. if miConfig.MdtrtareaAdmvs == "440781" { //
  26404. 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)
  26405. } else {
  26406. if miConfig.Code == "H15049901371" {
  26407. //赤峰地区国家医保医疗类别
  26408. //职工透析:医疗类别选特殊情况门诊990502
  26409. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26410. var med_type string
  26411. if his.Insutype == "390" {
  26412. if reg_type == 14 {
  26413. med_type = "9933"
  26414. } else if reg_type == 11 {
  26415. med_type = "11"
  26416. }
  26417. } else if his.Insutype == "310" {
  26418. if reg_type == 14 {
  26419. med_type = "990502"
  26420. } else if reg_type == 11 {
  26421. med_type = "11"
  26422. }
  26423. }
  26424. 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)
  26425. } else {
  26426. 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)
  26427. }
  26428. }
  26429. saveLog(result, requestLog, "2203", "上传就诊信息")
  26430. var respJSON2 map[string]interface{}
  26431. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26434. return
  26435. }
  26436. userJSONBytes2, _ := json.Marshal(respJSON2)
  26437. if miConfig.Code == "H15049901371" {
  26438. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  26439. utils.ErrorLog("解析失败:%v", err)
  26440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26441. return
  26442. }
  26443. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26444. res2.Output = ressix10265.Output
  26445. res2.ErrMsg = ressix10265.ErrMsg
  26446. res2.Cainfo = ressix10265.Cainfo
  26447. res2.WarnMsg = ressix10265.WarnMsg
  26448. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26449. res2.Infcode = infocode
  26450. } else {
  26451. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26452. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26453. utils.ErrorLog("解析失败:%v", err)
  26454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26455. return
  26456. }
  26457. res2.Infcode = res3.Infcode
  26458. } else {
  26459. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26460. utils.ErrorLog("解析失败:%v", err)
  26461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26462. return
  26463. }
  26464. }
  26465. }
  26466. }
  26467. if res2.Infcode == -1 {
  26468. adminUser := c.GetAdminUserInfo()
  26469. errlog := &models.HisOrderError{
  26470. UserOrgId: adminUser.CurrentOrgId,
  26471. Ctime: time.Now().Unix(),
  26472. Mtime: time.Now().Unix(),
  26473. ErrMsg: res2.ErrMsg,
  26474. Status: 1,
  26475. PatientId: id,
  26476. RecordTime: recordDateTime,
  26477. Stage: 3,
  26478. }
  26479. service.CreateErrMsgLog(errlog)
  26480. c.ServeSuccessJSON(map[string]interface{}{
  26481. "failed_code": -10,
  26482. "msg": res2.ErrMsg,
  26483. })
  26484. return
  26485. } else {
  26486. his.Diagnosis = diagnosis_id
  26487. his.SickType = sickConfig.ID
  26488. //var p_type int64
  26489. //if reg_type == 1111 || reg_type == 1112 {
  26490. // p_type = 11
  26491. //
  26492. //}
  26493. his.PType = fmt.Sprintf("%d", reg_type)
  26494. service.UpdateHisPatientThree(&his)
  26495. data := make(map[string]interface{})
  26496. if settle_accounts_type == 1 { //日结
  26497. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26498. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26499. } else {
  26500. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26501. }
  26502. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  26503. data["pre"] = prescriptions
  26504. } else { //月结
  26505. start_time_str := c.GetString("start_time")
  26506. end_time_str := c.GetString("end_time")
  26507. timeLayout := "2006-01-02"
  26508. loc, _ := time.LoadLocation("Local")
  26509. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26510. if err != nil {
  26511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26512. return
  26513. }
  26514. recordStartTime := theStartTime.Unix()
  26515. start_time = recordStartTime
  26516. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26517. if err != nil {
  26518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26519. return
  26520. }
  26521. recordEndTime := theEndTime.Unix()
  26522. end_time = recordEndTime
  26523. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26524. data["pre"] = prescriptions
  26525. }
  26526. timestamp := time.Now().Unix()
  26527. tempTime := time.Unix(timestamp, 0)
  26528. timeFormat := tempTime.Format("20060102150405")
  26529. chrgBchno := rand.Intn(100000) + 10000
  26530. new_chrg_bchno := ""
  26531. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  26532. new_chrg_bchno = chrg_bchno
  26533. strconv.FormatInt(his.PatientId, 10)
  26534. client := &http.Client{}
  26535. if adminUser.CurrentOrgId == 10265 {
  26536. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26537. new_chrg_bchno = "0000"
  26538. }
  26539. }
  26540. data["psn_no"] = his.PsnNo
  26541. data["mdtrt_id"] = his.Number
  26542. data["chrg_bchno"] = new_chrg_bchno
  26543. data["org_name"] = miConfig.OrgName
  26544. data["doctor"] = doctor_info.UserName
  26545. data["doctor_id"] = doctor_info.DoctorNumber
  26546. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  26547. data["fixmedins_code"] = miConfig.Code
  26548. data["dept_code"] = department.Number
  26549. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26550. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26551. data["secret_key"] = miConfig.SecretKey
  26552. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26553. data["url"] = miConfig.Url
  26554. data["ak"] = miConfig.AccessKey
  26555. data["new_doctor_name"] = patientPrescription.Doctor
  26556. data["diag_code"] = sickConfig.CountryCode
  26557. data["cainfo"] = miConfig.Cainfo
  26558. data["opter"] = roles.UserName
  26559. var ids []int64
  26560. for _, item := range prescriptions {
  26561. ids = append(ids, item.ID)
  26562. }
  26563. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26564. if config.IsOpen == 1 { //对接了医保,走医保流程
  26565. var res ResultFour
  26566. var resFour10265 ResultFour10265
  26567. if miConfig.MdtrtareaAdmvs == "421300" {
  26568. bytesData, _ := json.Marshal(data)
  26569. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26570. resp, _ := client.Do(req)
  26571. defer resp.Body.Close()
  26572. body, ioErr := ioutil.ReadAll(resp.Body)
  26573. if ioErr != nil {
  26574. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26576. return
  26577. }
  26578. var respJSON map[string]interface{}
  26579. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26580. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26582. return
  26583. }
  26584. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26585. userJSONBytes, _ := json.Marshal(respJSON)
  26586. fmt.Println("log")
  26587. fmt.Println(string(userJSONBytes))
  26588. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26589. utils.ErrorLog("解析失败:%v", err)
  26590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26591. return
  26592. }
  26593. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26594. bytesData, _ := json.Marshal(data)
  26595. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26596. resp, _ := client.Do(req)
  26597. defer resp.Body.Close()
  26598. body, ioErr := ioutil.ReadAll(resp.Body)
  26599. if ioErr != nil {
  26600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26602. return
  26603. }
  26604. var respJSON map[string]interface{}
  26605. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26608. return
  26609. }
  26610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26611. userJSONBytes, _ := json.Marshal(respJSON)
  26612. fmt.Println("log")
  26613. fmt.Println(string(userJSONBytes))
  26614. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26615. utils.ErrorLog("解析失败:%v", err)
  26616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26617. return
  26618. }
  26619. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26620. bytesData, _ := json.Marshal(data)
  26621. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26622. resp, _ := client.Do(req)
  26623. defer resp.Body.Close()
  26624. body, ioErr := ioutil.ReadAll(resp.Body)
  26625. if ioErr != nil {
  26626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26628. return
  26629. }
  26630. var respJSON map[string]interface{}
  26631. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26634. return
  26635. }
  26636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26637. userJSONBytes, _ := json.Marshal(respJSON)
  26638. fmt.Println("log")
  26639. fmt.Println(string(userJSONBytes))
  26640. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26641. utils.ErrorLog("解析失败:%v", err)
  26642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26643. return
  26644. }
  26645. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26646. bytesData, _ := json.Marshal(data)
  26647. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26648. resp, _ := client.Do(req)
  26649. defer resp.Body.Close()
  26650. body, ioErr := ioutil.ReadAll(resp.Body)
  26651. if ioErr != nil {
  26652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26654. return
  26655. }
  26656. var respJSON map[string]interface{}
  26657. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26660. return
  26661. }
  26662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26663. userJSONBytes, _ := json.Marshal(respJSON)
  26664. fmt.Println("log")
  26665. fmt.Println(string(userJSONBytes))
  26666. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26667. utils.ErrorLog("解析失败:%v", err)
  26668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26669. return
  26670. }
  26671. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26672. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26673. var result3101 Result3101
  26674. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26675. result3101.Infcode = "0"
  26676. if result3101.Infcode == "0" {
  26677. if len(result3101.Output.Result) > 0 {
  26678. var errMsgs []string
  26679. for _, item := range result3101.Output.Result {
  26680. errMsgs = append(errMsgs, item.VolaCont)
  26681. }
  26682. c.ServeSuccessJSON(map[string]interface{}{
  26683. "failed_code": -10,
  26684. "msg": errMsgs,
  26685. })
  26686. return
  26687. }
  26688. }
  26689. bytesData, _ := json.Marshal(data)
  26690. var req *http.Request
  26691. if miConfig.MdtrtareaAdmvs == "320921" {
  26692. data["diag_code"] = sickConfig.CountryCode
  26693. fmt.Println(data)
  26694. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26695. } else {
  26696. data["diag_code"] = sickConfig.CountryCode
  26697. fmt.Println(data)
  26698. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26699. }
  26700. resp, _ := client.Do(req)
  26701. defer resp.Body.Close()
  26702. body, ioErr := ioutil.ReadAll(resp.Body)
  26703. if ioErr != nil {
  26704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26706. return
  26707. }
  26708. var respJSON map[string]interface{}
  26709. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26712. return
  26713. }
  26714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26715. userJSONBytes, _ := json.Marshal(respJSON)
  26716. fmt.Println("log")
  26717. fmt.Println(string(userJSONBytes))
  26718. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26719. utils.ErrorLog("解析失败:%v", err)
  26720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26721. return
  26722. }
  26723. res.InfRefmsgid = resFour10265.InfRefmsgid
  26724. res.Output = resFour10265.Output
  26725. res.ErrMsg = resFour10265.ErrMsg
  26726. res.Cainfo = resFour10265.Cainfo
  26727. res.WarnMsg = resFour10265.WarnMsg
  26728. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26729. res.Infcode = infocode
  26730. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26731. var pagesize int = 2
  26732. var start int = 1
  26733. var stop int
  26734. var pagecount int
  26735. var curpage int
  26736. var isSuccess bool = true
  26737. data["doctor_id"] = doctor_info.DoctorNumber
  26738. //总页数,向上取整,注意除之前要先转换类型为float64
  26739. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  26740. for curpage = 1; curpage <= pagecount; curpage++ {
  26741. if curpage == 1 {
  26742. start = 1
  26743. } else {
  26744. start = (curpage-1)*pagesize + 1
  26745. }
  26746. stop = curpage * pagesize
  26747. if stop > len(prescriptions) {
  26748. stop = len(prescriptions)
  26749. }
  26750. //var requestLog string
  26751. data["pre"] = prescriptions[start-1 : stop]
  26752. fmt.Println(data["pre"])
  26753. bytesData, _ := json.Marshal(data)
  26754. var req *http.Request
  26755. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  26756. resp, _ := client.Do(req)
  26757. defer resp.Body.Close()
  26758. body, ioErr := ioutil.ReadAll(resp.Body)
  26759. if ioErr != nil {
  26760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26762. return
  26763. }
  26764. var respJSON map[string]interface{}
  26765. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26768. return
  26769. }
  26770. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26771. userJSONBytes, _ := json.Marshal(respJSON)
  26772. fmt.Println("log")
  26773. fmt.Println(string(userJSONBytes))
  26774. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26775. utils.ErrorLog("解析失败:%v", err)
  26776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26777. return
  26778. }
  26779. res.InfRefmsgid = resFour10265.InfRefmsgid
  26780. res.Output = resFour10265.Output
  26781. res.ErrMsg = resFour10265.ErrMsg
  26782. res.Cainfo = resFour10265.Cainfo
  26783. res.WarnMsg = resFour10265.WarnMsg
  26784. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26785. res.Infcode = infocode
  26786. if infocode == 0 {
  26787. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  26788. } else {
  26789. isSuccess = false
  26790. errlog := &models.HisOrderError{
  26791. UserOrgId: adminUser.CurrentOrgId,
  26792. Ctime: time.Now().Unix(),
  26793. Mtime: time.Now().Unix(),
  26794. Number: chrg_bchno,
  26795. ErrMsg: "",
  26796. Status: 1,
  26797. PatientId: id,
  26798. RecordTime: recordDateTime,
  26799. Stage: 4,
  26800. }
  26801. service.CreateErrMsgLog(errlog)
  26802. c.ServeSuccessJSON(map[string]interface{}{
  26803. "failed_code": -10,
  26804. "msg": res.ErrMsg,
  26805. })
  26806. return
  26807. }
  26808. }
  26809. if isSuccess {
  26810. res.Infcode = 0
  26811. }
  26812. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26813. 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)
  26814. var dat map[string]interface{}
  26815. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26816. fmt.Println(dat)
  26817. } else {
  26818. fmt.Println(err)
  26819. }
  26820. saveLog(result, request_log, "2204", "上传费用明细")
  26821. userJSONBytes, _ := json.Marshal(dat)
  26822. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26823. utils.ErrorLog("解析失败:%v", err)
  26824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26825. return
  26826. }
  26827. res.InfRefmsgid = resFour10265.InfRefmsgid
  26828. res.Output = resFour10265.Output
  26829. res.ErrMsg = resFour10265.ErrMsg
  26830. res.Cainfo = resFour10265.Cainfo
  26831. res.WarnMsg = resFour10265.WarnMsg
  26832. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26833. res.Infcode = infocode
  26834. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26835. bytesData, _ := json.Marshal(data)
  26836. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  26837. resp, _ := client.Do(req)
  26838. defer resp.Body.Close()
  26839. body, ioErr := ioutil.ReadAll(resp.Body)
  26840. if ioErr != nil {
  26841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26843. return
  26844. }
  26845. var respJSON map[string]interface{}
  26846. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26849. return
  26850. }
  26851. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26852. userJSONBytes, _ := json.Marshal(respJSON)
  26853. fmt.Println("log")
  26854. fmt.Println(string(userJSONBytes))
  26855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26856. utils.ErrorLog("解析失败:%v", err)
  26857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26858. return
  26859. }
  26860. } else {
  26861. if miConfig.Code == "H15049901371" {
  26862. 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)
  26863. var dat map[string]interface{}
  26864. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26865. fmt.Println(dat)
  26866. } else {
  26867. fmt.Println(err)
  26868. }
  26869. saveLog(result, request_log, "2204", "上传费用明细")
  26870. userJSONBytes, _ := json.Marshal(dat)
  26871. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26872. utils.ErrorLog("解析失败:%v", err)
  26873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26874. return
  26875. }
  26876. res.InfRefmsgid = resFour10265.InfRefmsgid
  26877. res.Output = resFour10265.Output
  26878. res.ErrMsg = resFour10265.ErrMsg
  26879. res.Cainfo = resFour10265.Cainfo
  26880. res.WarnMsg = resFour10265.WarnMsg
  26881. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26882. res.Infcode = infocode
  26883. } else {
  26884. 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)
  26885. var dat map[string]interface{}
  26886. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26887. fmt.Println(dat)
  26888. } else {
  26889. fmt.Println(err)
  26890. }
  26891. saveLog(result, request_log, "2204", "上传费用明细")
  26892. userJSONBytes, _ := json.Marshal(dat)
  26893. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26894. utils.ErrorLog("解析失败:%v", err)
  26895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26896. return
  26897. }
  26898. }
  26899. }
  26900. if res.Infcode == 0 {
  26901. order := &models.HisOrder{
  26902. UserOrgId: adminUser.CurrentOrgId,
  26903. HisPatientId: his.ID,
  26904. PatientId: his.PatientId,
  26905. SettleAccountsDate: recordDateTime,
  26906. MdtrtId: his.Number,
  26907. PsnNo: his.PsnNo,
  26908. MedType: strconv.FormatInt(reg_type, 10),
  26909. Ctime: time.Now().Unix(),
  26910. Mtime: time.Now().Unix(),
  26911. Status: 1,
  26912. Number: chrg_bchno,
  26913. Infcode: res.Infcode,
  26914. WarnMsg: res.WarnMsg,
  26915. Cainfo: res.Cainfo,
  26916. ErrMsg: res.ErrMsg,
  26917. RespondTime: res.RefmsgTime,
  26918. InfRefmsgid: res.InfRefmsgid,
  26919. OrderStatus: 1,
  26920. PayWay: pay_way,
  26921. PayWays: pay_ways,
  26922. OthDesc: oth_desc,
  26923. PayPrice: pay_price,
  26924. PayCardNo: pay_card_no,
  26925. DiscountPrice: discount_price,
  26926. PreferentialPrice: preferential_price,
  26927. RealityPrice: reality_price,
  26928. FoundPrice: found_price,
  26929. MedicalInsurancePrice: medical_insurance_price,
  26930. PrivatePrice: private_price,
  26931. IsMedicineInsurance: 1,
  26932. SettleType: settle_accounts_type,
  26933. SettleStartTime: start_time,
  26934. SettleEndTime: end_time,
  26935. Creator: roles.AdminUserId,
  26936. Modify: roles.AdminUserId,
  26937. FaPiaoNumber: fapiao_number,
  26938. FaPiaoCode: fapiao_code,
  26939. PType: 2,
  26940. Diagnosis: diagnosis_id,
  26941. CashPay: cash_pay,
  26942. WechatPay: wechat_pay,
  26943. AliPay: ali_pay,
  26944. JifenPay: jifen_pay,
  26945. BandCardPay: band_card_pay,
  26946. }
  26947. err = service.CreateOrder(order)
  26948. if err != nil {
  26949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  26950. return
  26951. }
  26952. for _, item := range res.Output.Result {
  26953. temp := strings.Split(item.FeedetlSn, "-")
  26954. var advice_id int64 = 0
  26955. var project_id int64 = 0
  26956. var types int64 = 0
  26957. id, _ := strconv.ParseInt(temp[2], 10, 64)
  26958. types, _ = strconv.ParseInt(temp[1], 10, 64)
  26959. if temp[1] == "1" {
  26960. advice_id = id
  26961. project_id = 0
  26962. } else if temp[1] == "2" {
  26963. advice_id = 0
  26964. project_id = id
  26965. }
  26966. if item.MedChrgitmType == "9" {
  26967. item.MedChrgitmType = "09"
  26968. }
  26969. info := &models.HisOrderInfo{
  26970. OrderNumber: order.Number,
  26971. FeedetlSn: item.FeedetlSn,
  26972. UploadDate: time.Now().Unix(),
  26973. AdviceId: advice_id,
  26974. DetItemFeeSumamt: item.DetItemFeeSumamt,
  26975. Cnt: item.Cnt,
  26976. Pric: float64(item.Pric),
  26977. PatientId: his.PatientId,
  26978. PricUplmtAmt: item.PricUplmtAmt,
  26979. SelfpayProp: item.SelfpayProp,
  26980. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  26981. OverlmtAmt: item.OverlmtAmt,
  26982. PreselfpayAmt: item.PreselfpayAmt,
  26983. BasMednFlag: item.BasMednFlag,
  26984. MedChrgitmType: item.MedChrgitmType,
  26985. HiNegoDrugFlag: item.HiNegoDrugFlag,
  26986. Status: 1,
  26987. Memo: item.Memo,
  26988. Mtime: time.Now().Unix(),
  26989. InscpScpAmt: item.InscpScpAmt,
  26990. DrtReimFlag: item.DrtReimFlag,
  26991. Ctime: time.Now().Unix(),
  26992. ListSpItemFlag: item.ListSpItemFlag,
  26993. ChldMedcFlag: item.ChldMedcFlag,
  26994. LmtUsedFlag: item.LmtUsedFlag,
  26995. ChrgitmLv: item.ChrgitmLv,
  26996. UserOrgId: adminUser.CurrentOrgId,
  26997. HisPatientId: his.ID,
  26998. OrderId: order.ID,
  26999. ProjectId: project_id,
  27000. Type: types,
  27001. }
  27002. service.CreateOrderInfo(info)
  27003. }
  27004. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27005. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27006. var total float64
  27007. for _, item := range prescriptions {
  27008. if item.Type == 1 { //药品
  27009. for _, subItem := range item.HisDoctorAdviceInfo {
  27010. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27011. total_one := price * subItem.PrescribingNumber
  27012. total = total + total_one
  27013. }
  27014. }
  27015. if item.Type == 2 { //项目
  27016. for _, subItem := range item.HisPrescriptionProject {
  27017. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27018. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27019. total_one := price * cnt
  27020. total = total + total_one
  27021. }
  27022. }
  27023. }
  27024. allTotal := fmt.Sprintf("%.2f", total)
  27025. //if adminUser.CurrentOrgId == 9919 {
  27026. //
  27027. // allTotal = fmt.Sprintf("%.2f", total)
  27028. //
  27029. //} else {
  27030. //
  27031. // allTotal = fmt.Sprintf("%.2f", total)
  27032. //
  27033. //}
  27034. if res.Infcode == 0 {
  27035. var rf []*ResultFive
  27036. json.Unmarshal([]byte(his.Iinfo), &rf)
  27037. chrg_bchno := chrg_bchno
  27038. cert_no := his.Certno
  27039. var insutypes []string
  27040. var insutype string
  27041. var is390 int = 0
  27042. var is310 int = 0
  27043. for _, item := range rf {
  27044. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27045. insutypes = append(insutypes, item.Insutype)
  27046. }
  27047. }
  27048. if len(insutypes) == 1 {
  27049. insutype = insutypes[0]
  27050. } else {
  27051. for _, i := range insutypes {
  27052. if i == "390" {
  27053. is390 = 1
  27054. }
  27055. if i == "310" {
  27056. is310 = 1
  27057. }
  27058. }
  27059. }
  27060. if is390 == 1 {
  27061. insutype = "390"
  27062. }
  27063. if is310 == 1 {
  27064. insutype = "310"
  27065. }
  27066. if len(insutypes) == 0 {
  27067. insutype = "310"
  27068. }
  27069. if len(insutypes) == 2 {
  27070. insutype = strconv.FormatInt(his.SocialType, 10)
  27071. }
  27072. insutype = strconv.FormatInt(his.SocialType, 10)
  27073. //insutype = "390"
  27074. if his.IdCardType == 1 {
  27075. // cert_no = his.MedicalInsuranceNumber
  27076. cert_no = his.Certno
  27077. } else {
  27078. cert_no = his.Certno
  27079. }
  27080. var res ResultSeven
  27081. var resSeven10265 ResultSeven10265
  27082. var gzresSeven10265Two GZResultSeven10265Two
  27083. var src_resquest string
  27084. var result2 string
  27085. if miConfig.MdtrtareaAdmvs == "421300" {
  27086. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27087. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27088. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27089. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27090. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27091. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27092. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27093. resp, requestErr := http.Get(api)
  27094. if requestErr != nil {
  27095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27096. return
  27097. }
  27098. body, ioErr := ioutil.ReadAll(resp.Body)
  27099. if ioErr != nil {
  27100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27102. return
  27103. }
  27104. var respJSON map[string]interface{}
  27105. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27108. return
  27109. }
  27110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27111. result, _ := json.Marshal(respJSON)
  27112. if miConfig.Code == "H15049901371" {
  27113. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27114. utils.ErrorLog("解析失败:%v", err)
  27115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27116. return
  27117. }
  27118. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27119. res.Output = resSeven10265.Output
  27120. res.ErrMsg = resSeven10265.ErrMsg
  27121. res.Cainfo = resSeven10265.Cainfo
  27122. res.WarnMsg = resSeven10265.WarnMsg
  27123. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27124. res.Infcode = infocode
  27125. } else {
  27126. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27127. utils.ErrorLog("解析失败:%v", err)
  27128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27129. return
  27130. }
  27131. }
  27132. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27133. if reg_type == 11 && his.Insutype == "390" {
  27134. reg_type = 110104
  27135. }
  27136. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27137. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27138. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27139. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27140. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27141. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27142. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27143. resp, requestErr := http.Get(api)
  27144. if requestErr != nil {
  27145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27146. return
  27147. }
  27148. body, ioErr := ioutil.ReadAll(resp.Body)
  27149. if ioErr != nil {
  27150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27152. return
  27153. }
  27154. var respJSON map[string]interface{}
  27155. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27158. return
  27159. }
  27160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27161. result, _ := json.Marshal(respJSON)
  27162. if miConfig.Code == "H15049901371" {
  27163. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27164. utils.ErrorLog("解析失败:%v", err)
  27165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27166. return
  27167. }
  27168. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27169. res.Output = resSeven10265.Output
  27170. res.ErrMsg = resSeven10265.ErrMsg
  27171. res.Cainfo = resSeven10265.Cainfo
  27172. res.WarnMsg = resSeven10265.WarnMsg
  27173. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27174. res.Infcode = infocode
  27175. } else {
  27176. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27177. utils.ErrorLog("解析失败:%v", err)
  27178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27179. return
  27180. }
  27181. }
  27182. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27183. if reg_type == 11 && his.Insutype == "390" {
  27184. reg_type = 110104
  27185. }
  27186. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27187. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27188. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27189. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27190. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27191. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27192. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27193. resp, requestErr := http.Get(api)
  27194. if requestErr != nil {
  27195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27196. return
  27197. }
  27198. body, ioErr := ioutil.ReadAll(resp.Body)
  27199. if ioErr != nil {
  27200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27202. return
  27203. }
  27204. var respJSON map[string]interface{}
  27205. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27208. return
  27209. }
  27210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27211. result, _ := json.Marshal(respJSON)
  27212. if miConfig.Code == "H15049901371" {
  27213. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27214. utils.ErrorLog("解析失败:%v", err)
  27215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27216. return
  27217. }
  27218. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27219. res.Output = resSeven10265.Output
  27220. res.ErrMsg = resSeven10265.ErrMsg
  27221. res.Cainfo = resSeven10265.Cainfo
  27222. res.WarnMsg = resSeven10265.WarnMsg
  27223. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27224. res.Infcode = infocode
  27225. } else {
  27226. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27227. utils.ErrorLog("解析失败:%v", err)
  27228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27229. return
  27230. }
  27231. }
  27232. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27233. if reg_type == 11 && his.Insutype == "390" {
  27234. reg_type = 110104
  27235. }
  27236. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27237. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27238. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27239. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27240. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27241. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27242. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27243. resp, requestErr := http.Get(api)
  27244. if requestErr != nil {
  27245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27246. return
  27247. }
  27248. body, ioErr := ioutil.ReadAll(resp.Body)
  27249. if ioErr != nil {
  27250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27252. return
  27253. }
  27254. var respJSON map[string]interface{}
  27255. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27258. return
  27259. }
  27260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27261. result, _ := json.Marshal(respJSON)
  27262. if miConfig.Code == "H15049901371" {
  27263. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27264. utils.ErrorLog("解析失败:%v", err)
  27265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27266. return
  27267. }
  27268. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27269. res.Output = resSeven10265.Output
  27270. res.ErrMsg = resSeven10265.ErrMsg
  27271. res.Cainfo = resSeven10265.Cainfo
  27272. res.WarnMsg = resSeven10265.WarnMsg
  27273. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27274. res.Infcode = infocode
  27275. } else {
  27276. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27277. utils.ErrorLog("解析失败:%v", err)
  27278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27279. return
  27280. }
  27281. }
  27282. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27283. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  27284. var result3101 Result3101
  27285. //utils.ErrorLog("解析失败:%v", result3101)
  27286. result3101.Infcode = "0"
  27287. if result3101.Infcode == "0" {
  27288. if len(result3101.Output.Result) > 0 {
  27289. var errMsgs []string
  27290. for _, item := range result3101.Output.Result {
  27291. errMsgs = append(errMsgs, item.VolaCont)
  27292. }
  27293. c.ServeSuccessJSON(map[string]interface{}{
  27294. "failed_code": -10,
  27295. "msg": errMsgs,
  27296. })
  27297. return
  27298. } else {
  27299. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27300. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27301. bas := strings.Split(psn_info.CardInfo, "|")
  27302. if his.IdCardType == 1 {
  27303. cert_no = bas[2]
  27304. } else if his.IdCardType == 3 {
  27305. cert_no = his.Certno
  27306. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27307. } else if his.IdCardType == 4 {
  27308. cert_no = his.Certno
  27309. psn_info.VerifyNumber = psn_info.VerifyNumber
  27310. }
  27311. var api string
  27312. if miConfig.MdtrtareaAdmvs == "320921" {
  27313. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27314. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27315. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27316. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27317. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27318. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27319. "&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
  27320. } else {
  27321. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27322. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27323. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27324. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27325. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27326. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27327. "&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
  27328. }
  27329. resp, requestErr := http.Get(api)
  27330. if requestErr != nil {
  27331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27332. return
  27333. }
  27334. body, ioErr := ioutil.ReadAll(resp.Body)
  27335. if ioErr != nil {
  27336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27338. return
  27339. }
  27340. var respJSON map[string]interface{}
  27341. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27344. return
  27345. }
  27346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27347. result, _ := json.Marshal(respJSON)
  27348. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27349. utils.ErrorLog("解析失败:%v", err)
  27350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27351. return
  27352. }
  27353. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27354. res.Output = resSeven10265.Output
  27355. res.ErrMsg = resSeven10265.ErrMsg
  27356. res.Cainfo = resSeven10265.Cainfo
  27357. res.WarnMsg = resSeven10265.WarnMsg
  27358. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27359. res.Infcode = infocode
  27360. }
  27361. }
  27362. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27363. psn_info, _ := service.GetPsnByPatientId(id)
  27364. var verify_number string
  27365. if psn_info.IdCardType == 4 {
  27366. verify_number = psn_info.VerifyNumber
  27367. } else if psn_info.IdCardType == 1 {
  27368. bas := strings.Split(psn_info.CardInfo, "|")
  27369. cardNumber := bas[2]
  27370. verify_number = cardNumber
  27371. } else {
  27372. psn_info.IdCardType = 2
  27373. verify_number = psn_info.Certno
  27374. }
  27375. var api string
  27376. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27377. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27378. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27379. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27380. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27381. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27382. "&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
  27383. resp, requestErr := http.Get(api)
  27384. if requestErr != nil {
  27385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27386. return
  27387. }
  27388. body, ioErr := ioutil.ReadAll(resp.Body)
  27389. if ioErr != nil {
  27390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27392. return
  27393. }
  27394. var respJSON map[string]interface{}
  27395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27398. return
  27399. }
  27400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27401. result, _ := json.Marshal(respJSON)
  27402. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27403. utils.ErrorLog("解析失败:%v", err)
  27404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27405. return
  27406. }
  27407. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27408. res.Output = resSeven10265.Output
  27409. res.ErrMsg = resSeven10265.ErrMsg
  27410. res.Cainfo = resSeven10265.Cainfo
  27411. res.WarnMsg = resSeven10265.WarnMsg
  27412. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27413. res.Infcode = infocode
  27414. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27415. var cert_no string
  27416. if his.IdCardType == 4 {
  27417. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27418. cert_no = psn_info.VerifyNumber
  27419. 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)
  27420. } else if his.IdCardType == 1 {
  27421. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27422. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27423. 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)
  27424. }
  27425. //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)
  27426. var dat map[string]interface{}
  27427. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27428. fmt.Println(dat)
  27429. } else {
  27430. fmt.Println(err)
  27431. }
  27432. saveLog(result2, src_resquest, "2207", "结算")
  27433. userJSONBytes, _ := json.Marshal(dat)
  27434. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27435. utils.ErrorLog("解析失败:%v", err)
  27436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27437. return
  27438. }
  27439. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27440. res.Output = resSeven10265.Output
  27441. res.ErrMsg = resSeven10265.ErrMsg
  27442. res.Cainfo = resSeven10265.Cainfo
  27443. res.WarnMsg = resSeven10265.WarnMsg
  27444. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27445. res.Infcode = infocode
  27446. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27447. res2 := c.GetoleInfo()
  27448. if res2.Infcode == 0 {
  27449. var result string
  27450. var request_log string
  27451. var result_log string
  27452. if res2.Output.MdtrtCertType == "02" {
  27453. 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)
  27454. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27455. } else if res2.Output.MdtrtCertType == "01" {
  27456. 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)
  27457. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27458. } else {
  27459. 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)
  27460. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27461. }
  27462. var dat map[string]interface{}
  27463. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27464. fmt.Println(dat)
  27465. } else {
  27466. fmt.Println(err)
  27467. }
  27468. userJSONBytes, _ := json.Marshal(dat)
  27469. var res5 ResultTwo
  27470. //var resTwo10265 ResultTwo10265
  27471. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27472. utils.ErrorLog("解析失败:%v", err)
  27473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27474. return
  27475. }
  27476. if res5.Infcode == -1 {
  27477. c.ServeSuccessJSON(map[string]interface{}{
  27478. "failed_code": -10,
  27479. "msg": res5.ErrMsg,
  27480. })
  27481. return
  27482. }
  27483. var insutypes []string
  27484. var insutype string
  27485. var is390 int = 0
  27486. var is310 int = 0
  27487. for _, item := range res5.Output.Iinfo {
  27488. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27489. insutypes = append(insutypes, item.Insutype)
  27490. }
  27491. }
  27492. if len(insutypes) == 1 {
  27493. insutype = insutypes[0]
  27494. } else {
  27495. for _, i := range insutypes {
  27496. if i == "390" {
  27497. is390 = 1
  27498. }
  27499. if i == "310" {
  27500. is310 = 1
  27501. }
  27502. }
  27503. }
  27504. if is390 == 1 {
  27505. insutype = "390"
  27506. }
  27507. if is310 == 1 {
  27508. insutype = "310"
  27509. }
  27510. if len(insutypes) == 0 {
  27511. insutype = "310"
  27512. }
  27513. fmt.Println(insutype)
  27514. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27515. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27516. infoStr := string(Iinfos)
  27517. idetinfoStr := string(Idetinfos)
  27518. psn := &models.HisPsn{
  27519. PsnNo: res5.Output.Baseinfo.PsnNo,
  27520. PatientId: id,
  27521. Certno: res5.Output.Baseinfo.Certno,
  27522. Gend: res5.Output.Baseinfo.Gend,
  27523. Naty: res5.Output.Baseinfo.Naty,
  27524. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27525. PsnName: res5.Output.Baseinfo.PsnName,
  27526. Idetinfo: idetinfoStr,
  27527. Insuinfo: infoStr,
  27528. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27530. VerifyNumber: res2.Output.EcToken,
  27531. }
  27532. if res2.Output.MdtrtCertType == "01" {
  27533. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27534. psn.VerifyNumber = res2.Output.EcToken
  27535. } else if res2.Output.MdtrtCertType == "02" {
  27536. psn.VerifyNumber = res2.Output.CardNo
  27537. } else {
  27538. psn.VerifyNumber = res2.Output.MdtrtCertNo
  27539. }
  27540. service.CreateHisPsn(psn)
  27541. if res2.Output.MdtrtCertType == "01" {
  27542. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27543. token := res2.Output.EcToken
  27544. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  27545. } else if res2.Output.MdtrtCertType == "02" {
  27546. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  27547. } else {
  27548. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  27549. }
  27550. var dat2 map[string]interface{}
  27551. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27552. fmt.Println(dat2)
  27553. } else {
  27554. fmt.Println(err)
  27555. }
  27556. userJSONBytes3, _ := json.Marshal(dat2)
  27557. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27558. utils.ErrorLog("解析失败:%v", err)
  27559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27560. return
  27561. }
  27562. saveLog(result2, src_resquest, "2207", "结算")
  27563. } else {
  27564. c.ServeSuccessJSON(map[string]interface{}{
  27565. "failed_code": -10,
  27566. "msg": res2.ErrMsg,
  27567. })
  27568. return
  27569. }
  27570. } else {
  27571. if miConfig.Code == "H15049901371" {
  27572. //赤峰地区国家医保医疗类别
  27573. //职工透析:医疗类别选特殊情况门诊990502
  27574. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27575. var med_type string
  27576. if his.Insutype == "390" {
  27577. if reg_type == 14 {
  27578. med_type = "9933"
  27579. } else if reg_type == 11 {
  27580. med_type = "11"
  27581. }
  27582. } else if his.Insutype == "310" {
  27583. if reg_type == 14 {
  27584. med_type = "990502"
  27585. } else if reg_type == 11 {
  27586. med_type = "11"
  27587. }
  27588. }
  27589. 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)
  27590. } else {
  27591. if his.IdCardType == 4 {
  27592. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27593. var token string
  27594. token = psn_info.VerifyNumber
  27595. 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)
  27596. } else {
  27597. if his.IdCardType == 1 {
  27598. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27599. bas := strings.Split(psn_info.CardInfo, "|")
  27600. basNumber := bas[2]
  27601. cert_no = basNumber
  27602. }
  27603. 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)
  27604. }
  27605. }
  27606. //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)
  27607. var dat map[string]interface{}
  27608. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27609. fmt.Println(dat)
  27610. } else {
  27611. fmt.Println(err)
  27612. }
  27613. saveLog(result2, src_resquest, "2207", "结算")
  27614. userJSONBytes, _ := json.Marshal(dat)
  27615. if miConfig.Code == "H15049901371" {
  27616. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27617. utils.ErrorLog("解析失败:%v", err)
  27618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27619. return
  27620. }
  27621. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27622. res.Output = resSeven10265.Output
  27623. res.ErrMsg = resSeven10265.ErrMsg
  27624. res.Cainfo = resSeven10265.Cainfo
  27625. res.WarnMsg = resSeven10265.WarnMsg
  27626. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27627. res.Infcode = infocode
  27628. } else {
  27629. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27630. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27631. utils.ErrorLog("解析失败:%v", err)
  27632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27633. return
  27634. }
  27635. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27636. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27637. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27638. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27639. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27640. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27641. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27642. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27643. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27644. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27645. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27646. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27647. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27648. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27649. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27650. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27651. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27652. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27653. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27654. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27655. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27656. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27657. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27658. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27659. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27660. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27661. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27662. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27663. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27664. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27665. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27666. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27667. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27668. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27669. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27670. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27671. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27672. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27673. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27674. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27675. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27676. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27677. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27678. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27679. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27680. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27681. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27682. res.Cainfo = gzresSeven10265Two.Cainfo
  27683. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27684. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27685. //res.Infcode = infocode
  27686. } else {
  27687. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27688. utils.ErrorLog("解析失败:%v", err)
  27689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27690. return
  27691. }
  27692. }
  27693. }
  27694. }
  27695. if res.Infcode == -1 {
  27696. errlog := &models.HisOrderError{
  27697. UserOrgId: adminUser.CurrentOrgId,
  27698. Ctime: time.Now().Unix(),
  27699. Mtime: time.Now().Unix(),
  27700. Number: chrg_bchno,
  27701. ErrMsg: res.ErrMsg,
  27702. Status: 1,
  27703. PatientId: id,
  27704. RecordTime: recordDateTime,
  27705. Stage: 6,
  27706. }
  27707. service.CreateErrMsgLog(errlog)
  27708. c.ServeSuccessJSON(map[string]interface{}{
  27709. "failed_code": -10,
  27710. "msg": res.ErrMsg,
  27711. })
  27712. return
  27713. } else {
  27714. sickConfig, _ := service.FindSickById(his.SickType)
  27715. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27716. order.OrderStatus = 2
  27717. order.Status = 1
  27718. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27719. order.SetlId = res.Output.Setlinfo.SetlID
  27720. order.PsnNo = res.Output.Setlinfo.PsnNo
  27721. order.PsnName = res.Output.Setlinfo.PsnName
  27722. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27723. order.Certno = res.Output.Setlinfo.Certno
  27724. order.Gend = res.Output.Setlinfo.Gend
  27725. order.Naty = res.Output.Setlinfo.Naty
  27726. order.Age = res.Output.Setlinfo.Age
  27727. order.Insutype = res.Output.Setlinfo.Insutype
  27728. order.PsnType = res.Output.Setlinfo.PsnType
  27729. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27730. order.SetlTime = res.Output.Setlinfo.SetlTime
  27731. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27732. if res.Output.Setlinfo.MedType == "140101" {
  27733. order.MedType = "14"
  27734. } else {
  27735. if res.Output.Setlinfo.MedType == "110104" {
  27736. order.MedType = "11"
  27737. } else {
  27738. order.MedType = res.Output.Setlinfo.MedType
  27739. }
  27740. }
  27741. if reg_type == 1112 {
  27742. order.MedType = "1112"
  27743. }
  27744. if reg_type == 1111 {
  27745. order.MedType = "1111"
  27746. }
  27747. order.ClrType = res.Output.Setlinfo.ClrType
  27748. if adminUser.CurrentOrgId == 10480 {
  27749. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27750. order.ClrType = "11"
  27751. } else {
  27752. order.ClrType = "9903"
  27753. }
  27754. }
  27755. if adminUser.CurrentOrgId == 10721 {
  27756. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27757. order.ClrType = "11"
  27758. } else {
  27759. order.ClrType = "9903"
  27760. }
  27761. }
  27762. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27763. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27764. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27765. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27766. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27767. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27768. order.HifpPay = res.Output.Setlinfo.HifpPay
  27769. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27770. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27771. order.HifesPay = res.Output.Setlinfo.HifesPay
  27772. order.HifobPay = res.Output.Setlinfo.HifobPay
  27773. order.MafPay = res.Output.Setlinfo.MafPay
  27774. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27775. order.OthPay = res.Output.Setlinfo.OthPay
  27776. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27777. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27778. order.AcctPay = res.Output.Setlinfo.AcctPay
  27779. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27780. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27781. order.Balc = res.Output.Setlinfo.Balc
  27782. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27783. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27784. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27785. //order.ClrType = res.Output.Setlinfo.ClrType
  27786. order.ClrWay = res.Output.Setlinfo.ClrWay
  27787. order.Creator = order.Creator
  27788. order.Modify = roles.AdminUserId
  27789. order.RequestLog = src_resquest
  27790. order.FaPiaoNumber = fapiao_number
  27791. order.FaPiaoCode = fapiao_code
  27792. order.SickName = sickConfig.ClassName
  27793. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27794. //detailStr := string(setlDetail)
  27795. //order.SetlDetail = detailStr
  27796. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27797. err = service.UpDateOrder(order)
  27798. if err == nil {
  27799. //判断是否使用了押金
  27800. if dec_way == "true" {
  27801. tmpstring := strconv.FormatInt(order.ID, 10)
  27802. order.Decimal = decimal
  27803. service.UpDateOrder(order)
  27804. //扣押金
  27805. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27806. if errmsg != nil {
  27807. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27808. return
  27809. }
  27810. }
  27811. c.ServeSuccessJSON(map[string]interface{}{
  27812. "msg": "结算成功",
  27813. })
  27814. } else {
  27815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27816. return
  27817. }
  27818. }
  27819. } else {
  27820. adminUser := c.GetAdminUserInfo()
  27821. errlog := &models.HisOrderError{
  27822. UserOrgId: adminUser.CurrentOrgId,
  27823. Ctime: time.Now().Unix(),
  27824. Mtime: time.Now().Unix(),
  27825. ErrMsg: res.ErrMsg,
  27826. Status: 1,
  27827. PatientId: id,
  27828. RecordTime: recordDateTime,
  27829. Stage: 4,
  27830. }
  27831. service.CreateErrMsgLog(errlog)
  27832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  27833. return
  27834. }
  27835. } else {
  27836. adminUser := c.GetAdminUserInfo()
  27837. errlog := &models.HisOrderError{
  27838. UserOrgId: adminUser.CurrentOrgId,
  27839. Ctime: time.Now().Unix(),
  27840. Mtime: time.Now().Unix(),
  27841. ErrMsg: res.ErrMsg,
  27842. Status: 1,
  27843. PatientId: id,
  27844. RecordTime: recordDateTime,
  27845. Stage: 4,
  27846. }
  27847. service.CreateErrMsgLog(errlog)
  27848. c.ServeSuccessJSON(map[string]interface{}{
  27849. "failed_code": -10,
  27850. "msg": res.ErrMsg,
  27851. })
  27852. return
  27853. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  27854. //return
  27855. }
  27856. }
  27857. }
  27858. } else if tempOrder.ID > 0 {
  27859. if tempOrder.IsPre == 1 {
  27860. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  27861. var rf []*ResultFive
  27862. json.Unmarshal([]byte(his.Iinfo), &rf)
  27863. chrg_bchno := tempOrder.Number
  27864. cert_no := his.Certno
  27865. var insutypes []string
  27866. var insutype string
  27867. var is390 int = 0
  27868. var is310 int = 0
  27869. for _, item := range rf {
  27870. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27871. insutypes = append(insutypes, item.Insutype)
  27872. }
  27873. }
  27874. if len(insutypes) == 1 {
  27875. insutype = insutypes[0]
  27876. } else {
  27877. for _, i := range insutypes {
  27878. if i == "390" {
  27879. is390 = 1
  27880. }
  27881. if i == "310" {
  27882. is310 = 1
  27883. }
  27884. }
  27885. }
  27886. if is390 == 1 {
  27887. insutype = "390"
  27888. }
  27889. if is310 == 1 {
  27890. insutype = "310"
  27891. }
  27892. if len(insutypes) == 0 {
  27893. insutype = "310"
  27894. }
  27895. if len(insutypes) == 2 {
  27896. insutype = strconv.FormatInt(his.SocialType, 10)
  27897. }
  27898. //insutype = "390"
  27899. if his.IdCardType == 1 {
  27900. // cert_no = his.MedicalInsuranceNumber
  27901. cert_no = his.Certno
  27902. } else {
  27903. cert_no = his.Certno
  27904. }
  27905. var res ResultSeven
  27906. var ahres ResultSevenAH
  27907. var resSeven10265 ResultSeven10265
  27908. var gzresSeven10265Two GZResultSeven10265Two
  27909. var src_resquest string
  27910. var result2 string
  27911. if miConfig.MdtrtareaAdmvs == "450721" {
  27912. res2 := c.GetoleInfo()
  27913. if res2.Infcode == 0 {
  27914. var result string
  27915. var request_log string
  27916. var result_log string
  27917. if res2.Output.MdtrtCertType == "02" {
  27918. 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)
  27919. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27920. } else if res2.Output.MdtrtCertType == "01" {
  27921. 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)
  27922. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27923. } else {
  27924. 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)
  27925. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27926. }
  27927. var dat map[string]interface{}
  27928. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27929. fmt.Println(dat)
  27930. } else {
  27931. fmt.Println(err)
  27932. }
  27933. userJSONBytes, _ := json.Marshal(dat)
  27934. var res5 ResultTwo
  27935. //var resTwo10265 ResultTwo10265
  27936. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27937. utils.ErrorLog("解析失败:%v", err)
  27938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27939. return
  27940. }
  27941. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  27942. if res5.Infcode == -1 {
  27943. c.ServeSuccessJSON(map[string]interface{}{
  27944. "failed_code": -10,
  27945. "msg": res5.ErrMsg,
  27946. })
  27947. return
  27948. }
  27949. var insutypes []string
  27950. var insutype string
  27951. var is390 int = 0
  27952. var is310 int = 0
  27953. for _, item := range res5.Output.Iinfo {
  27954. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27955. insutypes = append(insutypes, item.Insutype)
  27956. }
  27957. }
  27958. if len(insutypes) == 1 {
  27959. insutype = insutypes[0]
  27960. } else {
  27961. for _, i := range insutypes {
  27962. if i == "390" {
  27963. is390 = 1
  27964. }
  27965. if i == "310" {
  27966. is310 = 1
  27967. }
  27968. }
  27969. }
  27970. if is390 == 1 {
  27971. insutype = "390"
  27972. }
  27973. if is310 == 1 {
  27974. insutype = "310"
  27975. }
  27976. if len(insutypes) == 0 {
  27977. insutype = "310"
  27978. }
  27979. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27980. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27981. infoStr := string(Iinfos)
  27982. idetinfoStr := string(Idetinfos)
  27983. psn := &models.HisPsn{
  27984. PsnNo: res5.Output.Baseinfo.PsnNo,
  27985. PatientId: id,
  27986. Certno: res5.Output.Baseinfo.Certno,
  27987. Gend: res5.Output.Baseinfo.Gend,
  27988. Naty: res5.Output.Baseinfo.Naty,
  27989. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27990. PsnName: res5.Output.Baseinfo.PsnName,
  27991. Idetinfo: idetinfoStr,
  27992. Insuinfo: infoStr,
  27993. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27994. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27995. VerifyNumber: res2.Output.EcToken,
  27996. }
  27997. service.CreateHisPsn(psn)
  27998. if res2.Output.MdtrtCertType == "01" {
  27999. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28000. token := res2.Output.EcToken
  28001. 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)
  28002. } else if res2.Output.MdtrtCertType == "02" {
  28003. 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)
  28004. } else {
  28005. 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)
  28006. }
  28007. var dat2 map[string]interface{}
  28008. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28009. fmt.Println(dat2)
  28010. } else {
  28011. fmt.Println(err)
  28012. }
  28013. userJSONBytes3, _ := json.Marshal(dat2)
  28014. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28015. utils.ErrorLog("解析失败:%v", err)
  28016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28017. return
  28018. }
  28019. saveLog(result2, src_resquest, "2207", "结算")
  28020. } else {
  28021. c.ServeSuccessJSON(map[string]interface{}{
  28022. "failed_code": -10,
  28023. "msg": res2.ErrMsg,
  28024. })
  28025. return
  28026. }
  28027. } else if miConfig.MdtrtareaAdmvs == "421300" {
  28028. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28029. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28030. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28031. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28032. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28033. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28034. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28035. resp, requestErr := http.Get(api)
  28036. if requestErr != nil {
  28037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28038. return
  28039. }
  28040. body, ioErr := ioutil.ReadAll(resp.Body)
  28041. if ioErr != nil {
  28042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28044. return
  28045. }
  28046. var respJSON map[string]interface{}
  28047. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28050. return
  28051. }
  28052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28053. result, _ := json.Marshal(respJSON)
  28054. fmt.Println("log")
  28055. fmt.Println(string(result))
  28056. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28057. utils.ErrorLog("解析失败:%v", err)
  28058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28059. return
  28060. }
  28061. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28062. if reg_type == 11 && his.Insutype == "390" {
  28063. reg_type = 110104
  28064. }
  28065. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28066. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28067. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28068. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28069. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28070. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28071. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28072. resp, requestErr := http.Get(api)
  28073. if requestErr != nil {
  28074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28075. return
  28076. }
  28077. body, ioErr := ioutil.ReadAll(resp.Body)
  28078. if ioErr != nil {
  28079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28081. return
  28082. }
  28083. var respJSON map[string]interface{}
  28084. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28087. return
  28088. }
  28089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28090. result, _ := json.Marshal(respJSON)
  28091. fmt.Println("log")
  28092. fmt.Println(string(result))
  28093. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28094. utils.ErrorLog("解析失败:%v", err)
  28095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28096. return
  28097. }
  28098. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28099. if reg_type == 11 && his.Insutype == "390" {
  28100. reg_type = 110104
  28101. }
  28102. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28103. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28104. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28105. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28106. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28107. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28108. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28109. resp, requestErr := http.Get(api)
  28110. if requestErr != nil {
  28111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28112. return
  28113. }
  28114. body, ioErr := ioutil.ReadAll(resp.Body)
  28115. if ioErr != nil {
  28116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28118. return
  28119. }
  28120. var respJSON map[string]interface{}
  28121. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28124. return
  28125. }
  28126. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28127. result, _ := json.Marshal(respJSON)
  28128. fmt.Println("log")
  28129. fmt.Println(string(result))
  28130. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28131. utils.ErrorLog("解析失败:%v", err)
  28132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28133. return
  28134. }
  28135. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28136. if reg_type == 11 && his.Insutype == "390" {
  28137. reg_type = 110104
  28138. }
  28139. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28140. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28141. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28142. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28143. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28144. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28145. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28146. resp, requestErr := http.Get(api)
  28147. if requestErr != nil {
  28148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28149. return
  28150. }
  28151. body, ioErr := ioutil.ReadAll(resp.Body)
  28152. if ioErr != nil {
  28153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28155. return
  28156. }
  28157. var respJSON map[string]interface{}
  28158. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28161. return
  28162. }
  28163. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28164. result, _ := json.Marshal(respJSON)
  28165. fmt.Println("log")
  28166. fmt.Println(string(result))
  28167. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28168. utils.ErrorLog("解析失败:%v", err)
  28169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28170. return
  28171. }
  28172. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28173. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28174. var result3101 Result3101
  28175. //utils.ErrorLog("解析失败:%v", result3101)
  28176. result3101.Infcode = "0"
  28177. if result3101.Infcode == "0" {
  28178. if len(result3101.Output.Result) > 0 {
  28179. var errMsgs []string
  28180. for _, item := range result3101.Output.Result {
  28181. errMsgs = append(errMsgs, item.VolaCont)
  28182. }
  28183. c.ServeSuccessJSON(map[string]interface{}{
  28184. "failed_code": -10,
  28185. "msg": errMsgs,
  28186. })
  28187. return
  28188. } else {
  28189. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28190. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28191. bas := strings.Split(psn_info.CardInfo, "|")
  28192. if his.IdCardType == 1 {
  28193. cert_no = bas[2]
  28194. } else if his.IdCardType == 3 {
  28195. cert_no = his.Certno
  28196. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28197. } else if his.IdCardType == 4 {
  28198. cert_no = his.Certno
  28199. psn_info.VerifyNumber = psn_info.VerifyNumber
  28200. }
  28201. //江苏地区国家医保医疗类别
  28202. //职工透析:医疗类别选特殊情况门诊9933
  28203. //居民血透门慢: 医疗类别选门诊慢病1402
  28204. //var med_type string
  28205. //if his.Insutype == "310" {
  28206. // if reg_type == 14 {
  28207. // med_type = "9933"
  28208. // } else if reg_type == 11 {
  28209. // med_type = "11"
  28210. //
  28211. // }
  28212. //} else if his.Insutype == "390" {
  28213. // if reg_type == 14 {
  28214. // med_type = "1402"
  28215. // } else if reg_type == 11 {
  28216. // med_type = "11"
  28217. // }
  28218. //}
  28219. var api string
  28220. if miConfig.MdtrtareaAdmvs == "320921" {
  28221. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28222. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28223. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28224. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28225. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28226. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28227. "&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
  28228. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28229. } else {
  28230. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28231. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28232. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28233. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28234. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28235. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28236. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28237. "&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
  28238. }
  28239. resp, requestErr := http.Get(api)
  28240. if requestErr != nil {
  28241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28242. return
  28243. }
  28244. body, ioErr := ioutil.ReadAll(resp.Body)
  28245. if ioErr != nil {
  28246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28248. return
  28249. }
  28250. var respJSON map[string]interface{}
  28251. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28254. return
  28255. }
  28256. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28257. result, _ := json.Marshal(respJSON)
  28258. fmt.Println("log")
  28259. fmt.Println(string(result))
  28260. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28261. utils.ErrorLog("解析失败:%v", err)
  28262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28263. return
  28264. }
  28265. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28266. res.Output = resSeven10265.Output
  28267. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28268. res.ErrMsg = resSeven10265.ErrMsg
  28269. res.Cainfo = resSeven10265.Cainfo
  28270. res.WarnMsg = resSeven10265.WarnMsg
  28271. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28272. res.Infcode = infocode
  28273. }
  28274. }
  28275. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28276. psn_info, _ := service.GetPsnByPatientId(id)
  28277. var verify_number string
  28278. if psn_info.IdCardType == 4 {
  28279. verify_number = psn_info.VerifyNumber
  28280. } else if psn_info.IdCardType == 1 {
  28281. bas := strings.Split(psn_info.CardInfo, "|")
  28282. cardNumber := bas[2]
  28283. verify_number = cardNumber
  28284. } else {
  28285. verify_number = psn_info.Certno
  28286. psn_info.IdCardType = 2
  28287. }
  28288. var api string
  28289. new_chrg_bchno := chrg_bchno
  28290. if adminUser.CurrentOrgId == 10265 {
  28291. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28292. new_chrg_bchno = "0000"
  28293. }
  28294. }
  28295. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28296. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  28297. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28298. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28299. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28300. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28301. "&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
  28302. resp, requestErr := http.Get(api)
  28303. if requestErr != nil {
  28304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28305. return
  28306. }
  28307. body, ioErr := ioutil.ReadAll(resp.Body)
  28308. if ioErr != nil {
  28309. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28311. return
  28312. }
  28313. var respJSON map[string]interface{}
  28314. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28315. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28317. return
  28318. }
  28319. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28320. result, _ := json.Marshal(respJSON)
  28321. fmt.Println("log")
  28322. fmt.Println(string(result))
  28323. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28324. utils.ErrorLog("解析失败:%v", err)
  28325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28326. return
  28327. }
  28328. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28329. res.Output = resSeven10265.Output
  28330. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28331. res.ErrMsg = resSeven10265.ErrMsg
  28332. res.Cainfo = resSeven10265.Cainfo
  28333. res.WarnMsg = resSeven10265.WarnMsg
  28334. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28335. res.Infcode = infocode
  28336. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28337. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28338. var cert_no string
  28339. if his.IdCardType == 1 {
  28340. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28341. } else {
  28342. cert_no = psn_info.VerifyNumber
  28343. }
  28344. 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)
  28345. var dat map[string]interface{}
  28346. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28347. fmt.Println(dat)
  28348. } else {
  28349. fmt.Println(err)
  28350. }
  28351. saveLog(result2, src_resquest, "2207", "结算")
  28352. userJSONBytes, _ := json.Marshal(dat)
  28353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28354. utils.ErrorLog("解析失败:%v", err)
  28355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28356. return
  28357. }
  28358. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28359. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28360. var cert_no string
  28361. var card_sn string
  28362. if his.IdCardType == 1 {
  28363. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28364. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28365. bas := strings.Split(psn_info.CardInfo, "|")
  28366. card_sn = bas[3]
  28367. } else if his.IdCardType == 2 {
  28368. cert_no = his.IdCardNo
  28369. } else {
  28370. cert_no = psn_info.VerifyNumber
  28371. }
  28372. var rf []*ResultFive
  28373. json.Unmarshal([]byte(his.Iinfo), &rf)
  28374. var psn_type string
  28375. for _, item := range rf {
  28376. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28377. psn_type = item.PsnType
  28378. }
  28379. }
  28380. 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)
  28381. var dat map[string]interface{}
  28382. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28383. fmt.Println(dat)
  28384. } else {
  28385. fmt.Println(err)
  28386. }
  28387. saveLog(result2, src_resquest, "2207", "结算")
  28388. userJSONBytes, _ := json.Marshal(dat)
  28389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28390. utils.ErrorLog("解析失败:%v", err)
  28391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28392. return
  28393. }
  28394. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28395. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28396. var cert_no string
  28397. var card_sn string
  28398. if his.IdCardType == 1 {
  28399. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28400. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28401. //bas := strings.Split(psn_info.CardInfo, "|")
  28402. card_sn = ""
  28403. } else if his.IdCardType == 2 {
  28404. cert_no = his.IdCardNo
  28405. } else {
  28406. cert_no = psn_info.VerifyNumber
  28407. }
  28408. var rf []*ResultFive
  28409. json.Unmarshal([]byte(his.Iinfo), &rf)
  28410. var psn_type string
  28411. for _, item := range rf {
  28412. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28413. psn_type = item.PsnType
  28414. }
  28415. }
  28416. 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)
  28417. var dat map[string]interface{}
  28418. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28419. fmt.Println(dat)
  28420. } else {
  28421. fmt.Println(err)
  28422. }
  28423. saveLog(result2, src_resquest, "2207", "结算")
  28424. userJSONBytes, _ := json.Marshal(dat)
  28425. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28426. utils.ErrorLog("解析失败:%v", err)
  28427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28428. return
  28429. }
  28430. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28431. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28432. var cert_no string
  28433. var card_sn string
  28434. if his.IdCardType == 1 {
  28435. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28436. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28437. //bas := strings.Split(psn_info.CardInfo, "|")
  28438. card_sn = ""
  28439. } else if his.IdCardType == 2 {
  28440. cert_no = his.IdCardNo
  28441. } else {
  28442. cert_no = psn_info.VerifyNumber
  28443. }
  28444. var rf []*ResultFive
  28445. json.Unmarshal([]byte(his.Iinfo), &rf)
  28446. var psn_type string
  28447. for _, item := range rf {
  28448. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28449. psn_type = item.PsnType
  28450. }
  28451. }
  28452. 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)
  28453. var dat map[string]interface{}
  28454. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28455. fmt.Println(dat)
  28456. } else {
  28457. fmt.Println(err)
  28458. }
  28459. saveLog(result2, src_resquest, "2207", "结算")
  28460. userJSONBytes, _ := json.Marshal(dat)
  28461. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28462. utils.ErrorLog("解析失败:%v", err)
  28463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28464. return
  28465. }
  28466. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28467. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28468. if his.IdCardType == 1 {
  28469. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28470. bas := strings.Split(psn_info.CardInfo, "|")
  28471. cert_no = bas[2]
  28472. } else if his.IdCardType == 3 {
  28473. cert_no = his.Certno
  28474. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28475. } else if his.IdCardType == 4 {
  28476. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28477. cert_no = psn_info.VerifyNumber
  28478. psn_info.VerifyNumber = psn_info.VerifyNumber
  28479. } else {
  28480. cert_no = his.Certno
  28481. psn_info.VerifyNumber = his.Certno
  28482. }
  28483. var api string
  28484. var med_type string
  28485. if his.Insutype == "390" {
  28486. if reg_type == 992102 {
  28487. med_type = "992102"
  28488. }
  28489. if reg_type == 1104 {
  28490. med_type = "1104"
  28491. }
  28492. if reg_type == 1104 {
  28493. med_type = "1104"
  28494. }
  28495. if reg_type == 140104 {
  28496. med_type = "140104"
  28497. }
  28498. if reg_type == 140201 {
  28499. med_type = "140201"
  28500. }
  28501. if reg_type == 14 {
  28502. med_type = "14"
  28503. }
  28504. } else if his.Insutype == "310" {
  28505. if reg_type == 1104 {
  28506. med_type = "1104"
  28507. }
  28508. if reg_type == 992102 {
  28509. med_type = "992102"
  28510. }
  28511. if reg_type == 140104 {
  28512. med_type = "140104"
  28513. }
  28514. if reg_type == 140201 {
  28515. med_type = "140201"
  28516. }
  28517. if reg_type == 14 {
  28518. med_type = "14"
  28519. }
  28520. }
  28521. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28522. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28523. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28524. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28525. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28526. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28527. "&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
  28528. resp, requestErr := http.Get(api)
  28529. if requestErr != nil {
  28530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28531. return
  28532. }
  28533. body, ioErr := ioutil.ReadAll(resp.Body)
  28534. if ioErr != nil {
  28535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28537. return
  28538. }
  28539. var respJSON map[string]interface{}
  28540. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28543. return
  28544. }
  28545. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28546. if status == "0" {
  28547. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28548. c.ServeSuccessJSON(map[string]interface{}{
  28549. "failed_code": -10,
  28550. "msg": err_msg,
  28551. })
  28552. return
  28553. }
  28554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28555. result, _ := json.Marshal(respJSON)
  28556. fmt.Println("log")
  28557. fmt.Println(string(result))
  28558. if err := json.Unmarshal(result, &ahres); err != nil {
  28559. utils.ErrorLog("解析失败:%v", err)
  28560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28561. return
  28562. }
  28563. res.InfRefmsgid = ahres.InfRefmsgid
  28564. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28565. // 创建对应的Time类型
  28566. t := time.UnixMilli(timestamp)
  28567. // 格式化成指定的日期字符串
  28568. str := t.Format("2006-01-02 15:04:05")
  28569. res.Output.Setlinfo.SetlTime = str
  28570. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28571. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28572. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28573. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28574. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28575. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28576. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28577. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28578. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28579. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28580. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28581. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28582. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28583. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28584. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28585. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28586. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28587. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28588. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28589. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28590. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28591. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28592. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28593. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28594. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28595. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28596. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28597. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28598. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28599. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28600. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28601. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28602. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28603. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28604. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28605. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28606. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28607. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28608. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28609. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28610. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28611. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28612. res.Output.Setldetail = ahres.Output.Setldetail
  28613. res.ErrMsg = ahres.ErrMsg
  28614. res.Cainfo = ahres.Cainfo
  28615. res.WarnMsg = ahres.WarnMsg
  28616. res.Infcode = ahres.Infcode
  28617. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28618. res.Output.Setlinfo.ClrType = "11"
  28619. } else {
  28620. res.Output.Setlinfo.ClrType = "9903"
  28621. }
  28622. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28623. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28624. if his.IdCardType == 1 {
  28625. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28626. bas := strings.Split(psn_info.CardInfo, "|")
  28627. cert_no = bas[2]
  28628. } else if his.IdCardType == 3 {
  28629. cert_no = his.Certno
  28630. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28631. } else if his.IdCardType == 4 {
  28632. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28633. cert_no = his.Certno
  28634. psn_info.VerifyNumber = psn_info.VerifyNumber
  28635. } else {
  28636. cert_no = his.Certno
  28637. psn_info.VerifyNumber = his.Certno
  28638. }
  28639. var api string
  28640. var med_type string
  28641. if his.Insutype == "390" {
  28642. if reg_type == 1104 {
  28643. med_type = "1104"
  28644. }
  28645. if reg_type == 992102 {
  28646. med_type = "992102"
  28647. }
  28648. if reg_type == 140104 {
  28649. med_type = "140104"
  28650. }
  28651. if reg_type == 14 {
  28652. med_type = "14"
  28653. }
  28654. if reg_type == 140201 {
  28655. med_type = "140201"
  28656. }
  28657. } else if his.Insutype == "310" {
  28658. if reg_type == 1104 {
  28659. med_type = "1104"
  28660. }
  28661. if reg_type == 992102 {
  28662. med_type = "992102"
  28663. }
  28664. if reg_type == 14 {
  28665. med_type = "14"
  28666. }
  28667. if reg_type == 140104 {
  28668. med_type = "140104"
  28669. }
  28670. if reg_type == 140201 {
  28671. med_type = "140201"
  28672. }
  28673. }
  28674. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28675. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28676. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28677. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28678. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28679. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28680. "&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
  28681. resp, requestErr := http.Get(api)
  28682. if requestErr != nil {
  28683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28684. return
  28685. }
  28686. body, ioErr := ioutil.ReadAll(resp.Body)
  28687. if ioErr != nil {
  28688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28690. return
  28691. }
  28692. var respJSON map[string]interface{}
  28693. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28696. return
  28697. }
  28698. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28699. if status == "0" {
  28700. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28701. c.ServeSuccessJSON(map[string]interface{}{
  28702. "failed_code": -10,
  28703. "msg": err_msg,
  28704. })
  28705. return
  28706. }
  28707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28708. result, _ := json.Marshal(respJSON)
  28709. fmt.Println("log")
  28710. fmt.Println(string(result))
  28711. if err := json.Unmarshal(result, &ahres); err != nil {
  28712. utils.ErrorLog("解析失败:%v", err)
  28713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28714. return
  28715. }
  28716. res.InfRefmsgid = ahres.InfRefmsgid
  28717. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28718. // 创建对应的Time类型
  28719. t := time.UnixMilli(timestamp)
  28720. // 格式化成指定的日期字符串
  28721. str := t.Format("2006-01-02 15:04:05")
  28722. res.Output.Setlinfo.SetlTime = str
  28723. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28724. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28725. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28726. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28727. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28728. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28729. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28730. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28731. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28732. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28733. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28734. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28735. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28736. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28737. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28738. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28739. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28740. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28741. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28742. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28743. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28744. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28745. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28746. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28747. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28748. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28749. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28750. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28751. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28752. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28753. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28754. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28755. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28756. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28757. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28758. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28759. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28760. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28761. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28762. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28763. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28764. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28765. res.Output.Setldetail = ahres.Output.Setldetail
  28766. res.ErrMsg = ahres.ErrMsg
  28767. res.Cainfo = ahres.Cainfo
  28768. res.WarnMsg = ahres.WarnMsg
  28769. res.Infcode = ahres.Infcode
  28770. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28771. res.Output.Setlinfo.ClrType = "11"
  28772. } else {
  28773. res.Output.Setlinfo.ClrType = "9903"
  28774. }
  28775. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28776. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28777. var cert_no string
  28778. if his.IdCardType == 1 {
  28779. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28780. } else if his.IdCardType == 2 {
  28781. cert_no = his.IdCardNo
  28782. } else {
  28783. cert_no = psn_info.VerifyNumber
  28784. }
  28785. 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, "")
  28786. var dat map[string]interface{}
  28787. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28788. fmt.Println(dat)
  28789. } else {
  28790. fmt.Println(err)
  28791. }
  28792. saveLog(result2, src_resquest, "2207", "结算")
  28793. userJSONBytes, _ := json.Marshal(dat)
  28794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28795. utils.ErrorLog("解析失败:%v", err)
  28796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28797. return
  28798. }
  28799. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28800. psn_info, _ := service.GetPsnByPatientId(id)
  28801. var verify_number string
  28802. if psn_info.IdCardType == 4 {
  28803. verify_number = psn_info.VerifyNumber
  28804. } else if psn_info.IdCardType == 1 {
  28805. bas := strings.Split(psn_info.CardInfo, "|")
  28806. cardNumber := bas[2]
  28807. verify_number = cardNumber
  28808. } else {
  28809. verify_number = psn_info.Certno
  28810. psn_info.IdCardType = 2
  28811. }
  28812. var api string
  28813. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28814. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28815. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28816. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28817. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28818. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28819. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  28820. resp, requestErr := http.Get(api)
  28821. if requestErr != nil {
  28822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28823. return
  28824. }
  28825. body, ioErr := ioutil.ReadAll(resp.Body)
  28826. if ioErr != nil {
  28827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28829. return
  28830. }
  28831. var respJSON map[string]interface{}
  28832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28835. return
  28836. }
  28837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28838. result, _ := json.Marshal(respJSON)
  28839. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28840. utils.ErrorLog("解析失败:%v", err)
  28841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28842. return
  28843. }
  28844. } else {
  28845. var src_resquest string
  28846. if miConfig.Code == "H15049901371" {
  28847. //赤峰地区国家医保医疗类别
  28848. //职工透析:医疗类别选特殊情况门诊990502
  28849. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28850. var med_type string
  28851. if his.Insutype == "390" {
  28852. if reg_type == 14 {
  28853. med_type = "9933"
  28854. } else if reg_type == 11 {
  28855. med_type = "11"
  28856. }
  28857. } else if his.Insutype == "310" {
  28858. if reg_type == 14 {
  28859. med_type = "990502"
  28860. } else if reg_type == 11 {
  28861. med_type = "11"
  28862. }
  28863. }
  28864. 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)
  28865. } else {
  28866. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882"{
  28867. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28868. if result3101.Infcode == 0 {
  28869. if len(result3101.Output.Result) > 0 {
  28870. c.ServeSuccessJSON(map[string]interface{}{
  28871. "failed_code": -10,
  28872. "failed_type": 100,
  28873. "warm_type": 2,
  28874. "msg": result3101,
  28875. })
  28876. return
  28877. }
  28878. } else {
  28879. c.ServeSuccessJSON(map[string]interface{}{
  28880. "failed_code": -10,
  28881. "msg": result3101.ErrMsg,
  28882. })
  28883. return
  28884. }
  28885. }
  28886. if his.IdCardType == 4 {
  28887. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28888. token := psn_info.VerifyNumber
  28889. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  28890. } else {
  28891. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  28892. }
  28893. }
  28894. var dat map[string]interface{}
  28895. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28896. fmt.Println(dat)
  28897. } else {
  28898. fmt.Println(err)
  28899. }
  28900. saveLog(result2, src_resquest, "2207", "结算")
  28901. userJSONBytes, _ := json.Marshal(dat)
  28902. if miConfig.Code == "H15049901371" {
  28903. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28904. utils.ErrorLog("解析失败:%v", err)
  28905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28906. return
  28907. }
  28908. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28909. res.Output = resSeven10265.Output
  28910. res.ErrMsg = resSeven10265.ErrMsg
  28911. res.Cainfo = resSeven10265.Cainfo
  28912. res.WarnMsg = resSeven10265.WarnMsg
  28913. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28914. res.Infcode = infocode
  28915. } else {
  28916. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28917. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  28918. utils.ErrorLog("解析失败:%v", err)
  28919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28920. return
  28921. }
  28922. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  28923. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  28924. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  28925. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28926. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  28927. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  28928. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  28929. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28930. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  28931. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28932. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28933. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28934. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28935. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28936. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  28937. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  28938. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  28939. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  28940. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  28941. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  28942. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28943. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  28944. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  28945. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  28946. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  28947. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  28948. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  28949. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  28950. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  28951. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  28952. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  28953. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  28954. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  28955. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  28956. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28957. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  28958. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  28959. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  28960. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28961. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  28962. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  28963. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  28964. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  28965. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  28966. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  28967. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  28968. res.ErrMsg = gzresSeven10265Two.ErrMsg
  28969. res.Cainfo = gzresSeven10265Two.Cainfo
  28970. res.WarnMsg = gzresSeven10265Two.WarnMsg
  28971. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  28972. //res.Infcode = infocode
  28973. } else {
  28974. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28975. utils.ErrorLog("解析失败:%v", err)
  28976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28977. return
  28978. }
  28979. }
  28980. }
  28981. }
  28982. if res.Infcode == -1 {
  28983. errlog := &models.HisOrderError{
  28984. UserOrgId: adminUser.CurrentOrgId,
  28985. Ctime: time.Now().Unix(),
  28986. Mtime: time.Now().Unix(),
  28987. Number: chrg_bchno,
  28988. ErrMsg: res.ErrMsg,
  28989. Status: 1,
  28990. PatientId: id,
  28991. RecordTime: recordDateTime,
  28992. Stage: 6,
  28993. }
  28994. service.CreateErrMsgLog(errlog)
  28995. c.ServeSuccessJSON(map[string]interface{}{
  28996. "failed_code": -10,
  28997. "msg": res.ErrMsg,
  28998. })
  28999. return
  29000. } else {
  29001. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29002. order.OrderStatus = 2
  29003. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29004. order.SetlId = res.Output.Setlinfo.SetlID
  29005. order.PsnNo = res.Output.Setlinfo.PsnNo
  29006. order.PsnName = res.Output.Setlinfo.PsnName
  29007. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29008. order.Certno = res.Output.Setlinfo.Certno
  29009. order.Gend = res.Output.Setlinfo.Gend
  29010. order.Naty = res.Output.Setlinfo.Naty
  29011. order.Age = res.Output.Setlinfo.Age
  29012. order.Insutype = res.Output.Setlinfo.Insutype
  29013. order.PsnType = res.Output.Setlinfo.PsnType
  29014. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29015. order.SetlTime = res.Output.Setlinfo.SetlTime
  29016. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29017. order.PayWays = pay_ways
  29018. order.AcctUsedFlag = acct_used_flag
  29019. order.WechatPay = wechat_pay
  29020. order.AliPay = ali_pay
  29021. order.JifenPay = jifen_pay
  29022. order.BandCardPay = band_card_pay
  29023. order.CashPay = cash_pay
  29024. order.OthDesc = oth_desc
  29025. //order.MedType = res.Output.Setlinfo.MedType
  29026. if reg_type == 1112 {
  29027. order.MedType = "1112"
  29028. }
  29029. if reg_type == 1111 {
  29030. order.MedType = "1111"
  29031. }
  29032. order.ClrType = res.Output.Setlinfo.ClrType
  29033. if adminUser.CurrentOrgId == 10480 {
  29034. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29035. order.ClrType = "11"
  29036. } else {
  29037. order.ClrType = "9903"
  29038. }
  29039. }
  29040. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29041. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29042. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29043. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29044. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29045. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29046. order.HifpPay = res.Output.Setlinfo.HifpPay
  29047. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29048. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29049. order.HifesPay = res.Output.Setlinfo.HifesPay
  29050. order.HifobPay = res.Output.Setlinfo.HifobPay
  29051. order.MafPay = res.Output.Setlinfo.MafPay
  29052. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29053. order.OthPay = res.Output.Setlinfo.OthPay
  29054. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29055. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29056. order.AcctPay = res.Output.Setlinfo.AcctPay
  29057. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29058. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29059. order.Balc = res.Output.Setlinfo.Balc
  29060. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29061. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29062. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29063. order.ClrWay = res.Output.Setlinfo.ClrWay
  29064. order.Creator = order.Creator
  29065. order.Modify = roles.AdminUserId
  29066. order.RequestLog = src_resquest
  29067. order.Diagnosis = diagnosis_id
  29068. order.FaPiaoNumber = fapiao_number
  29069. order.FaPiaoCode = fapiao_code
  29070. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29071. detailStr := string(setlDetail)
  29072. order.SetlDetail = detailStr
  29073. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29074. err = service.UpDateOrder(order)
  29075. if err == nil {
  29076. //判断是否使用了押金
  29077. if dec_way == "true" {
  29078. tmpstring := strconv.FormatInt(order.ID, 10)
  29079. //扣押金
  29080. order.Decimal = decimal
  29081. service.UpDateOrder(order)
  29082. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  29083. if errmsg != nil {
  29084. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  29085. return
  29086. }
  29087. }
  29088. c.ServeSuccessJSON(map[string]interface{}{
  29089. "msg": "结算成功",
  29090. })
  29091. } else {
  29092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29093. return
  29094. }
  29095. }
  29096. }
  29097. }
  29098. }
  29099. // 上传明细-预结算-
  29100. func (c *HisApiController) GetPreUploadInfo() {
  29101. id, _ := c.GetInt64("id")
  29102. record_time := c.GetString("record_time")
  29103. his_patient_id, _ := c.GetInt64("his_patient_id")
  29104. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  29105. admin_user_id, _ := c.GetInt64("admin_user_id")
  29106. diagnosis_id := c.GetString("diagnosis")
  29107. sick_type, _ := c.GetInt64("sick_type")
  29108. reg_type, _ := c.GetInt64("p_type")
  29109. begin_time := c.GetString("begin_time")
  29110. acct_used_flag := c.GetString("acct_used_flag")
  29111. id_str := c.GetString("ids")
  29112. ids_arr := strings.Split(id_str, ",")
  29113. timeLayout := "2006-01-02"
  29114. loc, _ := time.LoadLocation("Local")
  29115. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29116. if err != nil {
  29117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29118. return
  29119. }
  29120. recordDateTime := theTime.Unix()
  29121. adminUser := c.GetAdminUserInfo()
  29122. diagnosis_ids := strings.Split(diagnosis_id, ",")
  29123. var config []*models.HisXtDiagnoseConfig
  29124. for _, item := range diagnosis_ids {
  29125. id, _ := strconv.ParseInt(item, 10, 64)
  29126. if id > 0 {
  29127. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29128. config = append(config, &diagnosisConfig)
  29129. }
  29130. }
  29131. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  29132. sickConfig, _ := service.FindSickById(sick_type)
  29133. var prescriptions []*models.HisPrescription
  29134. var start_time int64
  29135. var end_time int64
  29136. var isSuccess bool = true
  29137. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29138. fmt.Println(his_patient_id)
  29139. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29140. timestamp := time.Now().Unix()
  29141. tempTime := time.Unix(timestamp, 0)
  29142. timeFormat := tempTime.Format("20060102150405")
  29143. chrgBchno := rand.Intn(100000) + 10000
  29144. new_chrg_bchno := ""
  29145. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  29146. new_chrg_bchno = chrg_bchno
  29147. if adminUser.CurrentOrgId == 10265 {
  29148. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29149. new_chrg_bchno = "0000"
  29150. }
  29151. }
  29152. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29153. var patientPrescription models.HisPrescriptionInfo
  29154. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29155. if patientPrescription.ID == 0 {
  29156. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  29157. }
  29158. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29159. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29160. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29161. strconv.FormatInt(his.PatientId, 10)
  29162. var res2406 Result2406
  29163. //安徽单病种处理
  29164. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  29165. data := make(map[string]interface{})
  29166. client := &http.Client{}
  29167. data["psn_no"] = his.PsnNo
  29168. data["mdtrt_id"] = his.Number
  29169. data["operator"] = roles.UserName
  29170. data["cert_no"] = his.IdCardNo
  29171. data["org_name"] = miConfig.OrgName
  29172. data["psn_name"] = his.Name
  29173. data["ipt_otp_no"] = his.IptOtpNo
  29174. data["ipt_psn_sp_flag_type"] = "0901"
  29175. data["ipt_psn_sp_flag"] = "1"
  29176. data["fixmedins_code"] = miConfig.Code
  29177. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29178. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29179. data["url"] = miConfig.Url
  29180. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29181. bytesData, _ := json.Marshal(data)
  29182. var req *http.Request
  29183. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29184. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29185. resp, _ := client.Do(req)
  29186. defer resp.Body.Close()
  29187. body, ioErr := ioutil.ReadAll(resp.Body)
  29188. if ioErr != nil {
  29189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29191. return
  29192. }
  29193. var respJSON map[string]interface{}
  29194. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29197. return
  29198. }
  29199. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29200. if status == "0" {
  29201. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29202. c.ServeSuccessJSON(map[string]interface{}{
  29203. "failed_code": -10,
  29204. "msg": err_msg,
  29205. })
  29206. return
  29207. }
  29208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29209. userJSONBytes, _ := json.Marshal(respJSON)
  29210. fmt.Println("log")
  29211. fmt.Println(string(userJSONBytes))
  29212. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29213. utils.ErrorLog("解析失败:%v", err)
  29214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29215. return
  29216. }
  29217. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  29218. data := make(map[string]interface{})
  29219. client := &http.Client{}
  29220. data["psn_no"] = his.PsnNo
  29221. data["mdtrt_id"] = his.Number
  29222. data["operator"] = roles.UserName
  29223. data["cert_no"] = his.IdCardNo
  29224. data["org_name"] = miConfig.OrgName
  29225. data["psn_name"] = his.Name
  29226. data["ipt_otp_no"] = his.IptOtpNo
  29227. data["ipt_psn_sp_flag_type"] = "0901"
  29228. data["ipt_psn_sp_flag"] = "1"
  29229. data["fixmedins_code"] = miConfig.Code
  29230. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29231. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29232. data["url"] = miConfig.Url
  29233. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29234. bytesData, _ := json.Marshal(data)
  29235. var req *http.Request
  29236. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29237. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29238. resp, _ := client.Do(req)
  29239. defer resp.Body.Close()
  29240. body, ioErr := ioutil.ReadAll(resp.Body)
  29241. if ioErr != nil {
  29242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29244. return
  29245. }
  29246. var respJSON map[string]interface{}
  29247. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29250. return
  29251. }
  29252. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29253. if status == "0" {
  29254. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29255. c.ServeSuccessJSON(map[string]interface{}{
  29256. "failed_code": -10,
  29257. "msg": err_msg,
  29258. })
  29259. return
  29260. }
  29261. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29262. userJSONBytes, _ := json.Marshal(respJSON)
  29263. fmt.Println("log")
  29264. fmt.Println(string(userJSONBytes))
  29265. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29266. utils.ErrorLog("解析失败:%v", err)
  29267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29268. return
  29269. }
  29270. }
  29271. if res2406.Infcode != 0 {
  29272. adminUser := c.GetAdminUserInfo()
  29273. errlog := &models.HisOrderError{
  29274. UserOrgId: adminUser.CurrentOrgId,
  29275. Ctime: time.Now().Unix(),
  29276. Mtime: time.Now().Unix(),
  29277. ErrMsg: res2406.ErrMsg,
  29278. Status: 1,
  29279. PatientId: id,
  29280. RecordTime: recordDateTime,
  29281. Stage: 3,
  29282. }
  29283. service.CreateErrMsgLog(errlog)
  29284. c.ServeSuccessJSON(map[string]interface{}{
  29285. "failed_code": -10,
  29286. "msg": res2406.ErrMsg,
  29287. })
  29288. return
  29289. }
  29290. var res2 ResultSix
  29291. var res3 GZResultSix
  29292. var resSix10265 ResultSix10265
  29293. //var time_stamp string
  29294. if miConfig.MdtrtareaAdmvs == "421300" {
  29295. data := make(map[string]interface{})
  29296. client := &http.Client{}
  29297. data["psn_no"] = his.PsnNo
  29298. data["mdtrt_id"] = his.Number
  29299. data["department"] = department.Name
  29300. data["org_name"] = miConfig.OrgName
  29301. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29302. data["doctor_id"] = doctor_info.DoctorNumber
  29303. data["doctor_name"] = roles.UserName
  29304. data["fixmedins_code"] = miConfig.Code
  29305. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29306. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29307. data["secret_key"] = miConfig.SecretKey
  29308. data["sick_code"] = sickConfig.CountryCode
  29309. data["sick_name"] = sickConfig.ClassName
  29310. data["begin_time"] = begin_time
  29311. data["dept"] = strconv.FormatInt(department.ID, 10)
  29312. data["config"] = config
  29313. data["opter"] = roles.UserName
  29314. fmt.Println(data)
  29315. bytesData, _ := json.Marshal(data)
  29316. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29317. resp, _ := client.Do(req)
  29318. defer resp.Body.Close()
  29319. body, ioErr := ioutil.ReadAll(resp.Body)
  29320. if ioErr != nil {
  29321. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29323. return
  29324. }
  29325. var respJSON map[string]interface{}
  29326. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29329. return
  29330. }
  29331. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29332. userJSONBytes, _ := json.Marshal(respJSON)
  29333. fmt.Println("log")
  29334. fmt.Println(string(userJSONBytes))
  29335. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29336. utils.ErrorLog("解析失败:%v", err)
  29337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29338. return
  29339. }
  29340. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29341. data := make(map[string]interface{})
  29342. client := &http.Client{}
  29343. data["psn_no"] = his.PsnNo
  29344. data["mdtrt_id"] = his.Number
  29345. data["department"] = department.Name
  29346. data["org_name"] = miConfig.OrgName
  29347. if reg_type == 11 && his.Insutype == "390" {
  29348. data["med_type"] = "110104"
  29349. } else {
  29350. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29351. }
  29352. data["doctor_id"] = doctor_info.DoctorNumber
  29353. data["doctor_name"] = roles.UserName
  29354. data["fixmedins_code"] = miConfig.Code
  29355. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29356. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29357. data["secret_key"] = miConfig.SecretKey
  29358. data["sick_code"] = sickConfig.CountryCode
  29359. data["sick_name"] = sickConfig.ClassName
  29360. data["begin_time"] = begin_time
  29361. data["dept"] = strconv.FormatInt(department.ID, 10)
  29362. data["config"] = config
  29363. data["opter"] = roles.UserName
  29364. fmt.Println(data)
  29365. bytesData, _ := json.Marshal(data)
  29366. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29367. resp, _ := client.Do(req)
  29368. defer resp.Body.Close()
  29369. body, ioErr := ioutil.ReadAll(resp.Body)
  29370. if ioErr != nil {
  29371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29373. return
  29374. }
  29375. var respJSON map[string]interface{}
  29376. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29379. return
  29380. }
  29381. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29382. userJSONBytes, _ := json.Marshal(respJSON)
  29383. fmt.Println("log")
  29384. fmt.Println(string(userJSONBytes))
  29385. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29386. utils.ErrorLog("解析失败:%v", err)
  29387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29388. return
  29389. }
  29390. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29391. data := make(map[string]interface{})
  29392. client := &http.Client{}
  29393. data["psn_no"] = his.PsnNo
  29394. data["mdtrt_id"] = his.Number
  29395. data["department"] = department.Name
  29396. data["org_name"] = miConfig.OrgName
  29397. if reg_type == 11 && his.Insutype == "390" {
  29398. data["med_type"] = "110104"
  29399. } else {
  29400. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29401. }
  29402. data["doctor_id"] = doctor_info.DoctorNumber
  29403. data["doctor_name"] = roles.UserName
  29404. data["fixmedins_code"] = miConfig.Code
  29405. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29406. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29407. data["secret_key"] = miConfig.SecretKey
  29408. data["sick_code"] = sickConfig.CountryCode
  29409. data["sick_name"] = sickConfig.ClassName
  29410. data["begin_time"] = begin_time
  29411. data["dept"] = strconv.FormatInt(department.ID, 10)
  29412. data["config"] = config
  29413. data["opter"] = roles.UserName
  29414. fmt.Println(data)
  29415. bytesData, _ := json.Marshal(data)
  29416. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29417. resp, _ := client.Do(req)
  29418. defer resp.Body.Close()
  29419. body, ioErr := ioutil.ReadAll(resp.Body)
  29420. if ioErr != nil {
  29421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29423. return
  29424. }
  29425. var respJSON map[string]interface{}
  29426. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29429. return
  29430. }
  29431. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29432. userJSONBytes, _ := json.Marshal(respJSON)
  29433. fmt.Println("log")
  29434. fmt.Println(string(userJSONBytes))
  29435. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29436. utils.ErrorLog("解析失败:%v", err)
  29437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29438. return
  29439. }
  29440. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29441. data := make(map[string]interface{})
  29442. client := &http.Client{}
  29443. data["psn_no"] = his.PsnNo
  29444. data["mdtrt_id"] = his.Number
  29445. data["department"] = department.Name
  29446. data["org_name"] = miConfig.OrgName
  29447. if reg_type == 11 && his.Insutype == "390" {
  29448. data["med_type"] = "110104"
  29449. } else {
  29450. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29451. }
  29452. data["doctor_id"] = doctor_info.DoctorNumber
  29453. data["doctor_name"] = roles.UserName
  29454. data["fixmedins_code"] = miConfig.Code
  29455. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29456. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29457. data["secret_key"] = miConfig.SecretKey
  29458. data["sick_code"] = sickConfig.CountryCode
  29459. data["sick_name"] = sickConfig.ClassName
  29460. data["begin_time"] = begin_time
  29461. data["dept"] = strconv.FormatInt(department.ID, 10)
  29462. data["config"] = config
  29463. data["opter"] = roles.UserName
  29464. fmt.Println(data)
  29465. bytesData, _ := json.Marshal(data)
  29466. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29467. resp, _ := client.Do(req)
  29468. defer resp.Body.Close()
  29469. body, ioErr := ioutil.ReadAll(resp.Body)
  29470. if ioErr != nil {
  29471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29473. return
  29474. }
  29475. var respJSON map[string]interface{}
  29476. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29479. return
  29480. }
  29481. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29482. userJSONBytes, _ := json.Marshal(respJSON)
  29483. fmt.Println("log")
  29484. fmt.Println(string(userJSONBytes))
  29485. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29486. utils.ErrorLog("解析失败:%v", err)
  29487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29488. return
  29489. }
  29490. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29491. data := make(map[string]interface{})
  29492. client := &http.Client{}
  29493. data["psn_no"] = his.PsnNo
  29494. data["mdtrt_id"] = his.Number
  29495. data["doctor"] = roles.UserName
  29496. data["department"] = department.Name
  29497. data["org_name"] = miConfig.OrgName
  29498. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29499. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  29500. data["fixmedins_code"] = miConfig.Code
  29501. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29502. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29503. data["secret_key"] = miConfig.SecretKey
  29504. data["sick_code"] = sickConfig.CountryCode
  29505. data["sick_name"] = sickConfig.ClassName
  29506. data["begin_time"] = begin_time
  29507. data["dept"] = strconv.FormatInt(department.ID, 10)
  29508. data["config"] = config
  29509. data["url"] = miConfig.Url
  29510. data["ak"] = miConfig.AccessKey
  29511. data["cainfo"] = miConfig.Cainfo
  29512. bytesData, _ := json.Marshal(data)
  29513. var req *http.Request
  29514. if miConfig.MdtrtareaAdmvs == "320921" {
  29515. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29516. } else {
  29517. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29518. }
  29519. resp, _ := client.Do(req)
  29520. defer resp.Body.Close()
  29521. body, ioErr := ioutil.ReadAll(resp.Body)
  29522. if ioErr != nil {
  29523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29525. return
  29526. }
  29527. var respJSON map[string]interface{}
  29528. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29531. return
  29532. }
  29533. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29534. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29535. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29536. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29537. userJSONBytes, _ := json.Marshal(respJSON)
  29538. fmt.Println("log")
  29539. fmt.Println(string(userJSONBytes))
  29540. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29541. utils.ErrorLog("解析失败:%v", err)
  29542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29543. return
  29544. }
  29545. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29546. res2.Output = resSix10265.Output
  29547. res2.ErrMsg = resSix10265.ErrMsg
  29548. res2.Cainfo = resSix10265.Cainfo
  29549. res2.WarnMsg = resSix10265.WarnMsg
  29550. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29551. res2.Infcode = infocode
  29552. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29553. data := make(map[string]interface{})
  29554. client := &http.Client{}
  29555. data["psn_no"] = his.PsnNo
  29556. data["mdtrt_id"] = his.Number
  29557. data["doctor"] = roles.UserName
  29558. data["department"] = department.Name
  29559. data["org_name"] = miConfig.OrgName
  29560. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29561. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  29562. data["fixmedins_code"] = miConfig.Code
  29563. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29564. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29565. data["secret_key"] = miConfig.SecretKey
  29566. data["sick_code"] = sickConfig.CountryCode
  29567. data["sick_name"] = sickConfig.ClassName
  29568. data["begin_time"] = begin_time
  29569. data["dept"] = strconv.FormatInt(department.ID, 10)
  29570. data["config"] = config
  29571. //data["url"] = miConfig.Url
  29572. //data["ak"] = miConfig.AccessKey
  29573. data["cainfo"] = miConfig.Cainfo
  29574. fmt.Println(data)
  29575. bytesData, _ := json.Marshal(data)
  29576. var req *http.Request
  29577. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  29578. resp, _ := client.Do(req)
  29579. defer resp.Body.Close()
  29580. body, ioErr := ioutil.ReadAll(resp.Body)
  29581. if ioErr != nil {
  29582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29584. return
  29585. }
  29586. var respJSON map[string]interface{}
  29587. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29590. return
  29591. }
  29592. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29593. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29594. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29596. userJSONBytes, _ := json.Marshal(respJSON)
  29597. fmt.Println("log")
  29598. fmt.Println(string(userJSONBytes))
  29599. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29600. utils.ErrorLog("解析失败:%v", err)
  29601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29602. return
  29603. }
  29604. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29605. res2.Output = resSix10265.Output
  29606. res2.ErrMsg = resSix10265.ErrMsg
  29607. res2.Cainfo = resSix10265.Cainfo
  29608. res2.WarnMsg = resSix10265.WarnMsg
  29609. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29610. res2.Infcode = infocode
  29611. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29612. 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)
  29613. saveLog(result, requestLog, "2203", "上传就诊信息")
  29614. var respJSON2 map[string]interface{}
  29615. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29618. return
  29619. }
  29620. userJSONBytes2, _ := json.Marshal(respJSON2)
  29621. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29622. utils.ErrorLog("解析失败:%v", err)
  29623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29624. return
  29625. }
  29626. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29627. var result string
  29628. var requestLog string
  29629. 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, "")
  29630. saveLog(result, requestLog, "2203", "上传就诊信息")
  29631. var respJSON2 map[string]interface{}
  29632. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29635. return
  29636. }
  29637. userJSONBytes2, _ := json.Marshal(respJSON2)
  29638. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29639. utils.ErrorLog("解析失败:%v", err)
  29640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29641. return
  29642. }
  29643. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29644. var result string
  29645. var requestLog string
  29646. 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, "")
  29647. saveLog(result, requestLog, "2203", "上传就诊信息")
  29648. var respJSON2 map[string]interface{}
  29649. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29652. return
  29653. }
  29654. userJSONBytes2, _ := json.Marshal(respJSON2)
  29655. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29656. utils.ErrorLog("解析失败:%v", err)
  29657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29658. return
  29659. }
  29660. } else if miConfig.MdtrtareaAdmvs == "360100" {
  29661. var result string
  29662. var requestLog string
  29663. 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, "")
  29664. saveLog(result, requestLog, "2203", "上传就诊信息")
  29665. var respJSON2 map[string]interface{}
  29666. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29669. return
  29670. }
  29671. userJSONBytes2, _ := json.Marshal(respJSON2)
  29672. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29673. utils.ErrorLog("解析失败:%v", err)
  29674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29675. return
  29676. }
  29677. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29678. data := make(map[string]interface{})
  29679. client := &http.Client{}
  29680. data["psn_no"] = his.PsnNo
  29681. data["mdtrt_id"] = his.Number
  29682. data["operator"] = roles.UserName
  29683. data["department"] = department.Name
  29684. data["org_name"] = miConfig.OrgName
  29685. var med_type string
  29686. if his.Insutype == "390" {
  29687. if reg_type == 992102 {
  29688. med_type = "992102"
  29689. data["sick_code"] = "ZDZ940"
  29690. data["sick_name"] = "慢性肾衰竭"
  29691. }
  29692. if reg_type == 140104 {
  29693. med_type = "140104"
  29694. data["sick_code"] = sickConfig.CountryCode
  29695. data["sick_name"] = sickConfig.ClassName
  29696. }
  29697. if reg_type == 14 {
  29698. med_type = "140104"
  29699. data["sick_code"] = sickConfig.CountryCode
  29700. data["sick_name"] = sickConfig.ClassName
  29701. }
  29702. if reg_type == 1104 {
  29703. med_type = "1104"
  29704. data["sick_code"] = sickConfig.CountryCode
  29705. data["sick_name"] = sickConfig.ClassName
  29706. }
  29707. } else if his.Insutype == "310" {
  29708. if reg_type == 992102 {
  29709. med_type = "992102"
  29710. data["sick_code"] = "ZDZ940"
  29711. data["sick_name"] = "慢性肾衰竭"
  29712. }
  29713. if reg_type == 140104 {
  29714. med_type = "140104"
  29715. data["sick_code"] = sickConfig.CountryCode
  29716. data["sick_name"] = sickConfig.ClassName
  29717. }
  29718. if reg_type == 14 {
  29719. med_type = "14"
  29720. data["sick_code"] = sickConfig.CountryCode
  29721. data["sick_name"] = sickConfig.ClassName
  29722. }
  29723. if reg_type == 1104 {
  29724. med_type = "1104"
  29725. data["sick_code"] = sickConfig.CountryCode
  29726. data["sick_name"] = sickConfig.ClassName
  29727. }
  29728. }
  29729. data["med_type"] = med_type
  29730. data["doctor_number"] = doctor_info.DoctorNumber
  29731. data["doctor_name"] = doctor_info.UserName
  29732. data["fixmedins_code"] = miConfig.Code
  29733. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29734. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29735. data["secret_key"] = miConfig.SecretKey
  29736. data["begin_time"] = begin_time
  29737. data["dept"] = strconv.FormatInt(department.ID, 10)
  29738. data["config"] = config
  29739. data["url"] = miConfig.Url
  29740. data["ak"] = miConfig.AccessKey
  29741. data["cainfo"] = miConfig.Cainfo
  29742. bytesData, _ := json.Marshal(data)
  29743. var req *http.Request
  29744. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  29745. resp, _ := client.Do(req)
  29746. defer resp.Body.Close()
  29747. body, ioErr := ioutil.ReadAll(resp.Body)
  29748. if ioErr != nil {
  29749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29751. return
  29752. }
  29753. var respJSON map[string]interface{}
  29754. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29757. return
  29758. }
  29759. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29760. if status == "0" {
  29761. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29762. c.ServeSuccessJSON(map[string]interface{}{
  29763. "failed_code": -10,
  29764. "msg": err_msg,
  29765. })
  29766. return
  29767. }
  29768. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29769. userJSONBytes, _ := json.Marshal(respJSON)
  29770. fmt.Println("log")
  29771. fmt.Println(string(userJSONBytes))
  29772. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29773. utils.ErrorLog("解析失败:%v", err)
  29774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29775. return
  29776. }
  29777. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29778. data := make(map[string]interface{})
  29779. client := &http.Client{}
  29780. data["psn_no"] = his.PsnNo
  29781. data["mdtrt_id"] = his.Number
  29782. data["operator"] = roles.UserName
  29783. data["department"] = department.Name
  29784. data["org_name"] = miConfig.OrgName
  29785. var med_type string
  29786. if his.Insutype == "390" {
  29787. if reg_type == 992102 {
  29788. med_type = "992102"
  29789. data["sick_code"] = sickConfig.CountryCode
  29790. data["sick_name"] = sickConfig.ClassName
  29791. }
  29792. if reg_type == 140104 {
  29793. med_type = "140104"
  29794. data["sick_code"] = sickConfig.CountryCode
  29795. data["sick_name"] = sickConfig.ClassName
  29796. }
  29797. if reg_type == 140201 {
  29798. med_type = "140201"
  29799. data["sick_code"] = sickConfig.CountryCode
  29800. data["sick_name"] = sickConfig.ClassName
  29801. }
  29802. if reg_type == 14 {
  29803. med_type = "14"
  29804. data["sick_code"] = sickConfig.CountryCode
  29805. data["sick_name"] = sickConfig.ClassName
  29806. }
  29807. if reg_type == 11 {
  29808. med_type = "11"
  29809. data["sick_code"] = sickConfig.CountryCode
  29810. data["sick_name"] = sickConfig.ClassName
  29811. }
  29812. } else if his.Insutype == "310" {
  29813. if reg_type == 992102 {
  29814. med_type = "992102"
  29815. data["sick_code"] = sickConfig.CountryCode
  29816. data["sick_name"] = sickConfig.ClassName
  29817. }
  29818. if reg_type == 140104 {
  29819. med_type = "140104"
  29820. data["sick_code"] = sickConfig.CountryCode
  29821. data["sick_name"] = sickConfig.ClassName
  29822. }
  29823. if reg_type == 140201 {
  29824. med_type = "140201"
  29825. data["sick_code"] = sickConfig.CountryCode
  29826. data["sick_name"] = sickConfig.ClassName
  29827. }
  29828. if reg_type == 14 {
  29829. med_type = "14"
  29830. data["sick_code"] = sickConfig.CountryCode
  29831. data["sick_name"] = sickConfig.ClassName
  29832. }
  29833. if reg_type == 11 {
  29834. med_type = "11"
  29835. data["sick_code"] = sickConfig.CountryCode
  29836. data["sick_name"] = sickConfig.ClassName
  29837. }
  29838. }
  29839. data["med_type"] = med_type
  29840. data["doctor_number"] = doctor_info.DoctorNumber
  29841. data["doctor_name"] = doctor_info.UserName
  29842. data["fixmedins_code"] = miConfig.Code
  29843. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29844. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29845. data["secret_key"] = miConfig.SecretKey
  29846. data["begin_time"] = begin_time
  29847. data["dept"] = strconv.FormatInt(department.ID, 10)
  29848. data["config"] = config
  29849. data["url"] = miConfig.Url
  29850. data["ak"] = miConfig.AccessKey
  29851. data["cainfo"] = miConfig.Cainfo
  29852. bytesData, _ := json.Marshal(data)
  29853. var req *http.Request
  29854. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  29855. resp, _ := client.Do(req)
  29856. defer resp.Body.Close()
  29857. body, ioErr := ioutil.ReadAll(resp.Body)
  29858. if ioErr != nil {
  29859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29861. return
  29862. }
  29863. var respJSON map[string]interface{}
  29864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29867. return
  29868. }
  29869. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29870. if status == "0" {
  29871. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29872. c.ServeSuccessJSON(map[string]interface{}{
  29873. "failed_code": -10,
  29874. "msg": err_msg,
  29875. })
  29876. return
  29877. }
  29878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29879. userJSONBytes, _ := json.Marshal(respJSON)
  29880. fmt.Println("log")
  29881. fmt.Println(string(userJSONBytes))
  29882. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29883. utils.ErrorLog("解析失败:%v", err)
  29884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29885. return
  29886. }
  29887. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29888. var result string
  29889. var requestLog string
  29890. 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, "",begin_time)
  29891. saveLog(result, requestLog, "2203", "上传就诊信息")
  29892. var respJSON2 map[string]interface{}
  29893. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29896. return
  29897. }
  29898. userJSONBytes2, _ := json.Marshal(respJSON2)
  29899. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29900. utils.ErrorLog("解析失败:%v", err)
  29901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29902. return
  29903. }
  29904. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29905. data := make(map[string]interface{})
  29906. client := &http.Client{}
  29907. data["psn_no"] = his.PsnNo
  29908. data["mdtrt_id"] = his.Number
  29909. data["doctor"] = roles.UserName
  29910. data["department"] = department.Name
  29911. data["org_name"] = miConfig.OrgName
  29912. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29913. data["doctor_id"] = doctor_info.DoctorNumber
  29914. data["fixmedins_code"] = miConfig.Code
  29915. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29916. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29917. data["secret_key"] = miConfig.SecretKey
  29918. data["sick_code"] = sickConfig.CountryCode
  29919. data["sick_name"] = sickConfig.ClassName
  29920. data["begin_time"] = begin_time
  29921. data["new_doctor_name"] = doctor_info.UserName
  29922. data["dept"] = strconv.FormatInt(department.ID, 10)
  29923. data["config"] = config
  29924. bytesData, _ := json.Marshal(data)
  29925. var req *http.Request
  29926. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  29927. resp, _ := client.Do(req)
  29928. defer resp.Body.Close()
  29929. body, ioErr := ioutil.ReadAll(resp.Body)
  29930. if ioErr != nil {
  29931. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29933. return
  29934. }
  29935. var respJSON map[string]interface{}
  29936. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29939. return
  29940. }
  29941. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29942. userJSONBytes, _ := json.Marshal(respJSON)
  29943. fmt.Println("log")
  29944. fmt.Println(string(userJSONBytes))
  29945. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29946. utils.ErrorLog("解析失败:%v", err)
  29947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29948. return
  29949. }
  29950. } else {
  29951. var result string
  29952. var requestLog string
  29953. if miConfig.MdtrtareaAdmvs == "440781" { //
  29954. 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)
  29955. } else {
  29956. if miConfig.Code == "H15049901371" {
  29957. //赤峰地区国家医保医疗类别
  29958. //职工透析:医疗类别选特殊情况门诊990502
  29959. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29960. var med_type string
  29961. if his.Insutype == "390" {
  29962. if reg_type == 14 {
  29963. med_type = "9933"
  29964. } else if reg_type == 11 {
  29965. med_type = "11"
  29966. }
  29967. } else if his.Insutype == "310" {
  29968. if reg_type == 14 {
  29969. med_type = "990502"
  29970. } else if reg_type == 11 {
  29971. med_type = "11"
  29972. }
  29973. }
  29974. 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)
  29975. } else {
  29976. 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)
  29977. }
  29978. saveLog(result, requestLog, "2203", "上传就诊信息")
  29979. var respJSON2 map[string]interface{}
  29980. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29983. return
  29984. }
  29985. userJSONBytes2, _ := json.Marshal(respJSON2)
  29986. if miConfig.Code == "H15049901371" {
  29987. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  29988. utils.ErrorLog("解析失败:%v", err)
  29989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29990. return
  29991. }
  29992. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29993. res2.Output = resSix10265.Output
  29994. res2.ErrMsg = resSix10265.ErrMsg
  29995. res2.Cainfo = resSix10265.Cainfo
  29996. res2.WarnMsg = resSix10265.WarnMsg
  29997. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29998. res2.Infcode = infocode
  29999. } else {
  30000. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30001. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  30002. utils.ErrorLog("解析失败:%v", err)
  30003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30004. return
  30005. }
  30006. res2.Infcode = res3.Infcode
  30007. } else {
  30008. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30009. utils.ErrorLog("解析失败:%v", err)
  30010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30011. return
  30012. }
  30013. }
  30014. }
  30015. }
  30016. }
  30017. if res2.Infcode == -1 {
  30018. adminUser := c.GetAdminUserInfo()
  30019. errlog := &models.HisOrderError{
  30020. UserOrgId: adminUser.CurrentOrgId,
  30021. Ctime: time.Now().Unix(),
  30022. Mtime: time.Now().Unix(),
  30023. ErrMsg: res2.ErrMsg,
  30024. Status: 1,
  30025. PatientId: id,
  30026. RecordTime: recordDateTime,
  30027. Stage: 3,
  30028. }
  30029. service.CreateErrMsgLog(errlog)
  30030. c.ServeSuccessJSON(map[string]interface{}{
  30031. "failed_code": -10,
  30032. "msg": res2.ErrMsg,
  30033. })
  30034. return
  30035. }
  30036. if res2.Infcode != 0 {
  30037. adminUser := c.GetAdminUserInfo()
  30038. errlog := &models.HisOrderError{
  30039. UserOrgId: adminUser.CurrentOrgId,
  30040. Ctime: time.Now().Unix(),
  30041. Mtime: time.Now().Unix(),
  30042. ErrMsg: res2.ErrMsg,
  30043. Status: 1,
  30044. PatientId: id,
  30045. RecordTime: recordDateTime,
  30046. Stage: 3,
  30047. }
  30048. service.CreateErrMsgLog(errlog)
  30049. c.ServeSuccessJSON(map[string]interface{}{
  30050. "failed_code": -10,
  30051. "msg": res2.ErrMsg,
  30052. })
  30053. return
  30054. } else {
  30055. his.Diagnosis = diagnosis_id
  30056. his.SickType = sickConfig.ID
  30057. his.PType = fmt.Sprintf("%d", reg_type)
  30058. service.UpdateHisPatientThree(&his)
  30059. data := make(map[string]interface{})
  30060. if settle_accounts_type == 1 { //日结
  30061. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  30062. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  30063. } else {
  30064. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  30065. }
  30066. data["pre"] = prescriptions
  30067. } else { //月结
  30068. start_time_str := c.GetString("start_time")
  30069. end_time_str := c.GetString("end_time")
  30070. timeLayout := "2006-01-02"
  30071. loc, _ := time.LoadLocation("Local")
  30072. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  30073. if err != nil {
  30074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30075. return
  30076. }
  30077. recordStartTime := theStartTime.Unix()
  30078. start_time = recordStartTime
  30079. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  30080. if err != nil {
  30081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30082. return
  30083. }
  30084. recordEndTime := theEndTime.Unix()
  30085. end_time = recordEndTime
  30086. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  30087. data["pre"] = prescriptions
  30088. }
  30089. client := &http.Client{}
  30090. data["psn_no"] = his.PsnNo
  30091. data["mdtrt_id"] = his.Number
  30092. data["chrg_bchno"] = new_chrg_bchno
  30093. data["org_name"] = miConfig.OrgName
  30094. data["doctor"] = doctor_info.UserName
  30095. data["doctor_id"] = doctor_info.DoctorNumber
  30096. data["dept"] = department.Name
  30097. data["fixmedins_code"] = miConfig.Code
  30098. data["opter"] = roles.UserName
  30099. data["dept_code"] = department.Number
  30100. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30101. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30102. data["secret_key"] = miConfig.SecretKey
  30103. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  30104. data["url"] = miConfig.Url
  30105. data["ak"] = miConfig.AccessKey
  30106. data["new_doctor_name"] = patientPrescription.Doctor
  30107. if his.Insutype == "390" {
  30108. if reg_type == 992102 {
  30109. data["diag_code"] = "ZDZ940"
  30110. }
  30111. if reg_type == 140104 {
  30112. data["diag_code"] = sickConfig.CountryCode
  30113. }
  30114. if reg_type == 140201 {
  30115. data["diag_code"] = sickConfig.CountryCode
  30116. }
  30117. if reg_type == 14 {
  30118. data["diag_code"] = sickConfig.CountryCode
  30119. }
  30120. if reg_type == 1104 {
  30121. data["diag_code"] = sickConfig.CountryCode
  30122. }
  30123. } else if his.Insutype == "310" {
  30124. if miConfig.MdtrtareaAdmvs == "341203" {
  30125. if reg_type == 992102 {
  30126. data["diag_code"] = "ZDZ940"
  30127. }
  30128. if reg_type != 992102 {
  30129. data["diag_code"] = sickConfig.CountryCode
  30130. }
  30131. } else {
  30132. data["diag_code"] = sickConfig.CountryCode
  30133. }
  30134. }
  30135. data["cainfo"] = miConfig.Cainfo
  30136. data["opter"] = roles.UserName
  30137. var ids []int64
  30138. for _, item := range prescriptions {
  30139. ids = append(ids, item.ID)
  30140. }
  30141. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30142. if config.IsOpen == 1 { //对接了医保,走医保流程
  30143. var res ResultFour
  30144. var resFour10265 ResultFour10265
  30145. if miConfig.MdtrtareaAdmvs == "421300" {
  30146. bytesData, _ := json.Marshal(data)
  30147. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30148. resp, _ := client.Do(req)
  30149. defer resp.Body.Close()
  30150. body, ioErr := ioutil.ReadAll(resp.Body)
  30151. if ioErr != nil {
  30152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30154. return
  30155. }
  30156. var respJSON map[string]interface{}
  30157. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30160. return
  30161. }
  30162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30163. userJSONBytes, _ := json.Marshal(respJSON)
  30164. fmt.Println("log")
  30165. fmt.Println(string(userJSONBytes))
  30166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30167. utils.ErrorLog("解析失败:%v", err)
  30168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30169. return
  30170. }
  30171. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30172. bytesData, _ := json.Marshal(data)
  30173. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30174. resp, _ := client.Do(req)
  30175. defer resp.Body.Close()
  30176. body, ioErr := ioutil.ReadAll(resp.Body)
  30177. if ioErr != nil {
  30178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30180. return
  30181. }
  30182. var respJSON map[string]interface{}
  30183. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30186. return
  30187. }
  30188. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30189. userJSONBytes, _ := json.Marshal(respJSON)
  30190. fmt.Println("log")
  30191. fmt.Println(string(userJSONBytes))
  30192. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30193. utils.ErrorLog("解析失败:%v", err)
  30194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30195. return
  30196. }
  30197. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30198. bytesData, _ := json.Marshal(data)
  30199. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30200. resp, _ := client.Do(req)
  30201. defer resp.Body.Close()
  30202. body, ioErr := ioutil.ReadAll(resp.Body)
  30203. if ioErr != nil {
  30204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30206. return
  30207. }
  30208. var respJSON map[string]interface{}
  30209. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30212. return
  30213. }
  30214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30215. userJSONBytes, _ := json.Marshal(respJSON)
  30216. fmt.Println("log")
  30217. fmt.Println(string(userJSONBytes))
  30218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30219. utils.ErrorLog("解析失败:%v", err)
  30220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30221. return
  30222. }
  30223. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30224. bytesData, _ := json.Marshal(data)
  30225. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30226. resp, _ := client.Do(req)
  30227. defer resp.Body.Close()
  30228. body, ioErr := ioutil.ReadAll(resp.Body)
  30229. if ioErr != nil {
  30230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30232. return
  30233. }
  30234. var respJSON map[string]interface{}
  30235. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30238. return
  30239. }
  30240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30241. userJSONBytes, _ := json.Marshal(respJSON)
  30242. fmt.Println("log")
  30243. fmt.Println(string(userJSONBytes))
  30244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30245. utils.ErrorLog("解析失败:%v", err)
  30246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30247. return
  30248. }
  30249. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30250. var result3101 Result3101
  30251. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30252. result3101.Infcode = "0"
  30253. if result3101.Infcode == "0" {
  30254. if len(result3101.Output.Result) > 0 {
  30255. var errMsgs []string
  30256. for _, item := range result3101.Output.Result {
  30257. errMsgs = append(errMsgs, item.VolaCont)
  30258. }
  30259. c.ServeSuccessJSON(map[string]interface{}{
  30260. "failed_code": -10,
  30261. "msg": errMsgs,
  30262. })
  30263. return
  30264. } else {
  30265. if miConfig.MdtrtareaAdmvs == "320921" {
  30266. data["doctor_id"] = "D320923012139"
  30267. } else {
  30268. data["doctor_id"] = "D371621008686"
  30269. }
  30270. bytesData, _ := json.Marshal(data)
  30271. var req *http.Request
  30272. if miConfig.MdtrtareaAdmvs == "320921" {
  30273. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30274. } else {
  30275. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30276. }
  30277. resp, _ := client.Do(req)
  30278. defer resp.Body.Close()
  30279. body, ioErr := ioutil.ReadAll(resp.Body)
  30280. if ioErr != nil {
  30281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30283. return
  30284. }
  30285. var respJSON map[string]interface{}
  30286. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30289. return
  30290. }
  30291. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30292. userJSONBytes, _ := json.Marshal(respJSON)
  30293. fmt.Println("log")
  30294. fmt.Println(string(userJSONBytes))
  30295. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30296. utils.ErrorLog("解析失败:%v", err)
  30297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30298. return
  30299. }
  30300. res.InfRefmsgid = resFour10265.InfRefmsgid
  30301. res.Output = resFour10265.Output
  30302. res.ErrMsg = resFour10265.ErrMsg
  30303. res.Cainfo = resFour10265.Cainfo
  30304. res.WarnMsg = resFour10265.WarnMsg
  30305. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30306. res.Infcode = infocode
  30307. }
  30308. }
  30309. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30310. var pagesize int = 5
  30311. var start int = 1
  30312. var stop int
  30313. var pagecount int
  30314. var curpage int
  30315. data["doctor_id"] = doctor_info.DoctorNumber
  30316. var res2 ResultFour
  30317. //var result res.
  30318. //总页数,向上取整,注意除之前要先转换类型为float64
  30319. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  30320. for curpage = 1; curpage <= pagecount; curpage++ {
  30321. if curpage == 1 {
  30322. start = 1
  30323. } else {
  30324. start = (curpage-1)*pagesize + 1
  30325. }
  30326. stop = curpage * pagesize
  30327. if stop > len(prescriptions) {
  30328. stop = len(prescriptions)
  30329. }
  30330. //var requestLog string
  30331. data["pre"] = prescriptions[start-1 : stop]
  30332. fmt.Println(data["pre"])
  30333. bytesData, _ := json.Marshal(data)
  30334. var req *http.Request
  30335. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  30336. resp, _ := client.Do(req)
  30337. defer resp.Body.Close()
  30338. body, ioErr := ioutil.ReadAll(resp.Body)
  30339. if ioErr != nil {
  30340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30342. return
  30343. }
  30344. var respJSON map[string]interface{}
  30345. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30348. return
  30349. }
  30350. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30351. userJSONBytes, _ := json.Marshal(respJSON)
  30352. fmt.Println("log")
  30353. fmt.Println(string(userJSONBytes))
  30354. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30355. utils.ErrorLog("解析失败:%v", err)
  30356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30357. return
  30358. }
  30359. res.InfRefmsgid = resFour10265.InfRefmsgid
  30360. res.Output = resFour10265.Output
  30361. res.ErrMsg = resFour10265.ErrMsg
  30362. res.Cainfo = resFour10265.Cainfo
  30363. res.WarnMsg = resFour10265.WarnMsg
  30364. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30365. res.Infcode = infocode
  30366. if infocode == 0 {
  30367. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  30368. } else {
  30369. isSuccess = false
  30370. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  30371. res.Infcode = -1
  30372. res.ErrMsg = resFour10265.ErrMsg
  30373. errlog := &models.HisOrderError{
  30374. UserOrgId: adminUser.CurrentOrgId,
  30375. Ctime: time.Now().Unix(),
  30376. Mtime: time.Now().Unix(),
  30377. Number: chrg_bchno,
  30378. ErrMsg: "",
  30379. Status: 1,
  30380. PatientId: id,
  30381. RecordTime: recordDateTime,
  30382. Stage: 4,
  30383. }
  30384. service.CreateErrMsgLog(errlog)
  30385. }
  30386. }
  30387. if isSuccess {
  30388. res.Infcode = 0
  30389. res.Output.Result = res2.Output.Result
  30390. } else {
  30391. order := &models.HisOrder{
  30392. UserOrgId: adminUser.CurrentOrgId,
  30393. HisPatientId: his.ID,
  30394. PatientId: his.PatientId,
  30395. SettleAccountsDate: recordDateTime,
  30396. Ctime: time.Now().Unix(),
  30397. Mtime: time.Now().Unix(),
  30398. MdtrtId: his.Number,
  30399. PsnNo: his.PsnNo,
  30400. MedType: strconv.FormatInt(reg_type, 10),
  30401. Status: 1,
  30402. Number: chrg_bchno,
  30403. Infcode: res.Infcode,
  30404. WarnMsg: res.WarnMsg,
  30405. Cainfo: res.Cainfo,
  30406. ErrMsg: res.ErrMsg,
  30407. RespondTime: res.RefmsgTime,
  30408. InfRefmsgid: res.InfRefmsgid,
  30409. OrderStatus: 1,
  30410. IsMedicineInsurance: 1,
  30411. SettleType: settle_accounts_type,
  30412. SettleStartTime: start_time,
  30413. SettleEndTime: end_time,
  30414. Creator: roles.AdminUserId,
  30415. Modify: roles.AdminUserId,
  30416. PType: 2,
  30417. Diagnosis: diagnosis_id,
  30418. }
  30419. err = service.CreateOrder(order)
  30420. if err != nil {
  30421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30422. return
  30423. }
  30424. c.ServeSuccessJSON(map[string]interface{}{
  30425. "failed_code": -10,
  30426. "msg": res2.ErrMsg,
  30427. })
  30428. return
  30429. }
  30430. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30431. 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)
  30432. var dat map[string]interface{}
  30433. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30434. fmt.Println(dat)
  30435. } else {
  30436. fmt.Println(err)
  30437. }
  30438. saveLog(result, request_log, "2204", "上传费用明细")
  30439. userJSONBytes, _ := json.Marshal(dat)
  30440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30441. utils.ErrorLog("解析失败:%v", err)
  30442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30443. return
  30444. }
  30445. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30446. 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, "", "")
  30447. var dat map[string]interface{}
  30448. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30449. fmt.Println(dat)
  30450. } else {
  30451. fmt.Println(err)
  30452. }
  30453. saveLog(result, request_log, "2204", "上传费用明细")
  30454. userJSONBytes, _ := json.Marshal(dat)
  30455. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30456. utils.ErrorLog("解析失败:%v", err)
  30457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30458. return
  30459. }
  30460. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30461. 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, "", "")
  30462. var dat map[string]interface{}
  30463. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30464. fmt.Println(dat)
  30465. } else {
  30466. fmt.Println(err)
  30467. }
  30468. saveLog(result, request_log, "2204", "上传费用明细")
  30469. userJSONBytes, _ := json.Marshal(dat)
  30470. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30471. utils.ErrorLog("解析失败:%v", err)
  30472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30473. return
  30474. }
  30475. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30476. 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, "", "")
  30477. var dat map[string]interface{}
  30478. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30479. fmt.Println(dat)
  30480. } else {
  30481. fmt.Println(err)
  30482. }
  30483. saveLog(result, request_log, "2204", "上传费用明细")
  30484. userJSONBytes, _ := json.Marshal(dat)
  30485. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30486. utils.ErrorLog("解析失败:%v", err)
  30487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30488. return
  30489. }
  30490. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30491. bytesData, _ := json.Marshal(data)
  30492. var req *http.Request
  30493. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30494. resp, _ := client.Do(req)
  30495. defer resp.Body.Close()
  30496. body, ioErr := ioutil.ReadAll(resp.Body)
  30497. if ioErr != nil {
  30498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30500. return
  30501. }
  30502. var respJSON map[string]interface{}
  30503. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30506. return
  30507. }
  30508. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30509. if status == "0" {
  30510. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30511. c.ServeSuccessJSON(map[string]interface{}{
  30512. "failed_code": -10,
  30513. "msg": err_msg,
  30514. })
  30515. return
  30516. }
  30517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30518. userJSONBytes, _ := json.Marshal(respJSON)
  30519. fmt.Println("log")
  30520. fmt.Println(string(userJSONBytes))
  30521. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30522. utils.ErrorLog("解析失败:%v", err)
  30523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30524. return
  30525. }
  30526. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30527. bytesData, _ := json.Marshal(data)
  30528. var req *http.Request
  30529. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30530. resp, _ := client.Do(req)
  30531. defer resp.Body.Close()
  30532. body, ioErr := ioutil.ReadAll(resp.Body)
  30533. if ioErr != nil {
  30534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30536. return
  30537. }
  30538. var respJSON map[string]interface{}
  30539. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30542. return
  30543. }
  30544. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30545. if status == "0" {
  30546. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30547. c.ServeSuccessJSON(map[string]interface{}{
  30548. "failed_code": -10,
  30549. "msg": err_msg,
  30550. })
  30551. return
  30552. }
  30553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30554. userJSONBytes, _ := json.Marshal(respJSON)
  30555. fmt.Println("log")
  30556. fmt.Println(string(userJSONBytes))
  30557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30558. utils.ErrorLog("解析失败:%v", err)
  30559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30560. return
  30561. }
  30562. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30563. 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, "", "")
  30564. var dat map[string]interface{}
  30565. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30566. fmt.Println(dat)
  30567. } else {
  30568. fmt.Println(err)
  30569. }
  30570. saveLog(result, request_log, "2204", "上传费用明细")
  30571. userJSONBytes, _ := json.Marshal(dat)
  30572. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30573. utils.ErrorLog("解析失败:%v", err)
  30574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30575. return
  30576. }
  30577. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30578. bytesData, _ := json.Marshal(data)
  30579. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  30580. resp, _ := client.Do(req)
  30581. defer resp.Body.Close()
  30582. body, ioErr := ioutil.ReadAll(resp.Body)
  30583. if ioErr != nil {
  30584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30586. return
  30587. }
  30588. var respJSON map[string]interface{}
  30589. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30592. return
  30593. }
  30594. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30595. userJSONBytes, _ := json.Marshal(respJSON)
  30596. fmt.Println("log")
  30597. fmt.Println(string(userJSONBytes))
  30598. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30599. utils.ErrorLog("解析失败:%v", err)
  30600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30601. return
  30602. }
  30603. } else {
  30604. if miConfig.MdtrtareaAdmvs == "441202" {
  30605. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30606. if result3101.Infcode == 0 {
  30607. if len(result3101.Output.Result) > 0 {
  30608. var errMsgs []string
  30609. for _, item := range result3101.Output.Result {
  30610. errMsgs = append(errMsgs, item.VolaCont)
  30611. }
  30612. c.ServeSuccessJSON(map[string]interface{}{
  30613. "failed_code": -10,
  30614. "msg": errMsgs,
  30615. })
  30616. return
  30617. } else {
  30618. 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)
  30619. var dat map[string]interface{}
  30620. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30621. fmt.Println(dat)
  30622. } else {
  30623. fmt.Println(err)
  30624. }
  30625. saveLog(result, request_log, "2204", "上传费用明细")
  30626. userJSONBytes, _ := json.Marshal(dat)
  30627. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30628. utils.ErrorLog("解析失败:%v", err)
  30629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30630. return
  30631. }
  30632. }
  30633. } else {
  30634. c.ServeSuccessJSON(map[string]interface{}{
  30635. "failed_code": -10,
  30636. "msg": result3101.ErrMsg,
  30637. })
  30638. return
  30639. }
  30640. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30641. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30642. if result3101.Infcode == 0 {
  30643. if len(result3101.Output.Result) > 0 {
  30644. var errMsgs []string
  30645. for _, item := range result3101.Output.Result {
  30646. errMsgs = append(errMsgs, item.VolaCont)
  30647. }
  30648. c.ServeSuccessJSON(map[string]interface{}{
  30649. "failed_code": -10,
  30650. "msg": errMsgs,
  30651. })
  30652. return
  30653. } else {
  30654. 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)
  30655. var dat map[string]interface{}
  30656. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30657. fmt.Println(dat)
  30658. } else {
  30659. fmt.Println(err)
  30660. }
  30661. saveLog(result, request_log, "2204", "上传费用明细")
  30662. userJSONBytes, _ := json.Marshal(dat)
  30663. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30664. utils.ErrorLog("解析失败:%v", err)
  30665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30666. return
  30667. }
  30668. }
  30669. } else {
  30670. c.ServeSuccessJSON(map[string]interface{}{
  30671. "failed_code": -10,
  30672. "msg": result3101.ErrMsg,
  30673. })
  30674. return
  30675. }
  30676. } else {
  30677. if miConfig.Code == "H15049901371" {
  30678. 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)
  30679. var dat map[string]interface{}
  30680. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30681. fmt.Println(dat)
  30682. } else {
  30683. fmt.Println(err)
  30684. }
  30685. saveLog(result, request_log, "2204", "上传费用明细")
  30686. userJSONBytes, _ := json.Marshal(dat)
  30687. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30688. utils.ErrorLog("解析失败:%v", err)
  30689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30690. return
  30691. }
  30692. res.InfRefmsgid = resFour10265.InfRefmsgid
  30693. res.Output = resFour10265.Output
  30694. res.ErrMsg = resFour10265.ErrMsg
  30695. res.Cainfo = resFour10265.Cainfo
  30696. res.WarnMsg = resFour10265.WarnMsg
  30697. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30698. res.Infcode = infocode
  30699. } else {
  30700. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882"{
  30701. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30702. if result3101.Infcode == 0 {
  30703. if len(result3101.Output.Result) > 0 {
  30704. c.ServeSuccessJSON(map[string]interface{}{
  30705. "failed_code": -10,
  30706. "failed_type": 100,
  30707. "warm_type": 1,
  30708. "msg": result3101,
  30709. })
  30710. return
  30711. } else {
  30712. 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)
  30713. var dat map[string]interface{}
  30714. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30715. fmt.Println(dat)
  30716. } else {
  30717. fmt.Println(err)
  30718. }
  30719. saveLog(result, request_log, "2204", "上传费用明细")
  30720. userJSONBytes, _ := json.Marshal(dat)
  30721. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30722. utils.ErrorLog("解析失败:%v", err)
  30723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30724. return
  30725. }
  30726. }
  30727. } else {
  30728. c.ServeSuccessJSON(map[string]interface{}{
  30729. "failed_code": -10,
  30730. "msg": result3101.ErrMsg,
  30731. })
  30732. return
  30733. }
  30734. } else {
  30735. 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)
  30736. var dat map[string]interface{}
  30737. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30738. fmt.Println(dat)
  30739. } else {
  30740. fmt.Println(err)
  30741. }
  30742. saveLog(result, request_log, "2204", "上传费用明细")
  30743. userJSONBytes, _ := json.Marshal(dat)
  30744. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30745. utils.ErrorLog("解析失败:%v", err)
  30746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30747. return
  30748. }
  30749. }
  30750. }
  30751. }
  30752. }
  30753. var total_two float64
  30754. if res.Infcode == -1 {
  30755. errlog := &models.HisOrderError{
  30756. UserOrgId: adminUser.CurrentOrgId,
  30757. Ctime: time.Now().Unix(),
  30758. Mtime: time.Now().Unix(),
  30759. Number: chrg_bchno,
  30760. ErrMsg: res.ErrMsg,
  30761. Status: 1,
  30762. PatientId: id,
  30763. RecordTime: recordDateTime,
  30764. Stage: 4,
  30765. }
  30766. service.CreateErrMsgLog(errlog)
  30767. c.ServeSuccessJSON(map[string]interface{}{
  30768. "failed_code": -10,
  30769. "msg": res.ErrMsg,
  30770. })
  30771. return
  30772. }
  30773. if res.Infcode == 0 {
  30774. order := &models.HisOrder{
  30775. UserOrgId: adminUser.CurrentOrgId,
  30776. HisPatientId: his.ID,
  30777. PatientId: his.PatientId,
  30778. SettleAccountsDate: recordDateTime,
  30779. Ctime: time.Now().Unix(),
  30780. Mtime: time.Now().Unix(),
  30781. MdtrtId: his.Number,
  30782. PsnNo: his.PsnNo,
  30783. MedType: strconv.FormatInt(reg_type, 10),
  30784. Status: 1,
  30785. Number: chrg_bchno,
  30786. Infcode: res.Infcode,
  30787. WarnMsg: res.WarnMsg,
  30788. Cainfo: res.Cainfo,
  30789. ErrMsg: res.ErrMsg,
  30790. RespondTime: res.RefmsgTime,
  30791. InfRefmsgid: res.InfRefmsgid,
  30792. OrderStatus: 1,
  30793. IsMedicineInsurance: 1,
  30794. SettleType: settle_accounts_type,
  30795. SettleStartTime: start_time,
  30796. SettleEndTime: end_time,
  30797. Creator: roles.AdminUserId,
  30798. Modify: roles.AdminUserId,
  30799. PType: 2,
  30800. Diagnosis: diagnosis_id,
  30801. }
  30802. err = service.CreateOrder(order)
  30803. if err != nil {
  30804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30805. return
  30806. }
  30807. for _, item := range res.Output.Result {
  30808. temp := strings.Split(item.FeedetlSn, "-")
  30809. var advice_id int64 = 0
  30810. var project_id int64 = 0
  30811. var types int64 = 0
  30812. id, _ := strconv.ParseInt(temp[2], 10, 64)
  30813. types, _ = strconv.ParseInt(temp[1], 10, 64)
  30814. if temp[1] == "1" {
  30815. advice_id = id
  30816. project_id = 0
  30817. } else if temp[1] == "2" {
  30818. advice_id = 0
  30819. project_id = id
  30820. }
  30821. total_two = total_two + item.DetItemFeeSumamt
  30822. info := &models.HisOrderInfo{
  30823. OrderNumber: order.Number,
  30824. FeedetlSn: item.FeedetlSn,
  30825. UploadDate: time.Now().Unix(),
  30826. AdviceId: advice_id,
  30827. DetItemFeeSumamt: item.DetItemFeeSumamt,
  30828. Cnt: item.Cnt,
  30829. Pric: float64(item.Pric),
  30830. PatientId: his.PatientId,
  30831. PricUplmtAmt: item.PricUplmtAmt,
  30832. SelfpayProp: item.SelfpayProp,
  30833. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  30834. OverlmtAmt: item.OverlmtAmt,
  30835. PreselfpayAmt: item.PreselfpayAmt,
  30836. BasMednFlag: item.BasMednFlag,
  30837. MedChrgitmType: item.MedChrgitmType,
  30838. HiNegoDrugFlag: item.HiNegoDrugFlag,
  30839. Status: 1,
  30840. Memo: item.Memo,
  30841. Mtime: time.Now().Unix(),
  30842. InscpScpAmt: item.InscpScpAmt,
  30843. DrtReimFlag: item.DrtReimFlag,
  30844. Ctime: time.Now().Unix(),
  30845. ListSpItemFlag: item.ListSpItemFlag,
  30846. ChldMedcFlag: item.ChldMedcFlag,
  30847. LmtUsedFlag: item.LmtUsedFlag,
  30848. ChrgitmLv: item.ChrgitmLv,
  30849. UserOrgId: adminUser.CurrentOrgId,
  30850. HisPatientId: his.ID,
  30851. OrderId: order.ID,
  30852. ProjectId: project_id,
  30853. Type: types,
  30854. }
  30855. service.CreateOrderInfo(info)
  30856. }
  30857. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  30858. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  30859. var total float64
  30860. for _, item := range prescriptions {
  30861. if item.Type == 1 { //药品
  30862. for _, subItem := range item.HisDoctorAdviceInfo {
  30863. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  30864. total_one := price * subItem.PrescribingNumber
  30865. fmt.Println("subItem")
  30866. fmt.Println(subItem.Price)
  30867. fmt.Println("price")
  30868. fmt.Println(price)
  30869. fmt.Println("total_one")
  30870. fmt.Println(total_one)
  30871. total = total + total_one
  30872. fmt.Println(total)
  30873. }
  30874. }
  30875. if item.Type == 2 { //项目
  30876. for _, subItem := range item.HisPrescriptionProject {
  30877. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  30878. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  30879. total_one := price * cnt
  30880. total = total + total_one
  30881. }
  30882. }
  30883. }
  30884. allTotal := fmt.Sprintf("%.2f", total)
  30885. if res.Infcode == 0 {
  30886. var rf []*ResultFive
  30887. json.Unmarshal([]byte(his.Iinfo), &rf)
  30888. chrg_bchno := chrg_bchno
  30889. cert_no := his.Certno
  30890. var insutypes []string
  30891. var insutype string
  30892. var is390 int = 0
  30893. var is310 int = 0
  30894. for _, item := range rf {
  30895. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  30896. insutypes = append(insutypes, item.Insutype)
  30897. }
  30898. }
  30899. if len(insutypes) == 1 {
  30900. insutype = insutypes[0]
  30901. } else {
  30902. for _, i := range insutypes {
  30903. if i == "390" {
  30904. is390 = 1
  30905. }
  30906. if i == "310" {
  30907. is310 = 1
  30908. }
  30909. }
  30910. }
  30911. if is390 == 1 {
  30912. insutype = "390"
  30913. }
  30914. if is310 == 1 {
  30915. insutype = "310"
  30916. }
  30917. if len(insutypes) == 0 {
  30918. insutype = "390"
  30919. }
  30920. if len(insutypes) == 2 {
  30921. insutype = strconv.FormatInt(his.SocialType, 10)
  30922. }
  30923. //insutype = "390"
  30924. if his.IdCardType == 1 {
  30925. cert_no = his.MedicalInsuranceNumber
  30926. } else {
  30927. cert_no = his.Certno
  30928. }
  30929. var res ResultSeven
  30930. var ahres ResultSevenAH
  30931. var resSeven10265 ResultSeven10265
  30932. var resSeven10265Two ResultSeven10265Two
  30933. var gzresSeven10265Two GZResultSeven10265Two
  30934. if miConfig.MdtrtareaAdmvs == "421300" {
  30935. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  30936. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30937. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30938. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30939. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30940. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30941. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30942. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30943. resp, requestErr := http.Get(api)
  30944. if requestErr != nil {
  30945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30946. return
  30947. }
  30948. body, ioErr := ioutil.ReadAll(resp.Body)
  30949. if ioErr != nil {
  30950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30952. return
  30953. }
  30954. var respJSON map[string]interface{}
  30955. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30958. return
  30959. }
  30960. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30961. result, _ := json.Marshal(respJSON)
  30962. fmt.Println("log")
  30963. fmt.Println(string(result))
  30964. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30965. utils.ErrorLog("解析失败:%v", err)
  30966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30967. return
  30968. }
  30969. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30970. if reg_type == 11 && his.Insutype == "390" {
  30971. reg_type = 110104
  30972. }
  30973. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30974. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30975. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30976. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30977. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30978. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30979. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30980. resp, requestErr := http.Get(api)
  30981. if requestErr != nil {
  30982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30983. return
  30984. }
  30985. body, ioErr := ioutil.ReadAll(resp.Body)
  30986. if ioErr != nil {
  30987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30989. return
  30990. }
  30991. var respJSON map[string]interface{}
  30992. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30995. return
  30996. }
  30997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30998. result, _ := json.Marshal(respJSON)
  30999. fmt.Println("log")
  31000. fmt.Println(string(result))
  31001. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31002. utils.ErrorLog("解析失败:%v", err)
  31003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31004. return
  31005. }
  31006. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31007. if reg_type == 11 && his.Insutype == "390" {
  31008. reg_type = 110104
  31009. }
  31010. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31011. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31012. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31013. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31014. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31015. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31016. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31017. resp, requestErr := http.Get(api)
  31018. if requestErr != nil {
  31019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31020. return
  31021. }
  31022. body, ioErr := ioutil.ReadAll(resp.Body)
  31023. if ioErr != nil {
  31024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31026. return
  31027. }
  31028. var respJSON map[string]interface{}
  31029. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31032. return
  31033. }
  31034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31035. result, _ := json.Marshal(respJSON)
  31036. fmt.Println("log")
  31037. fmt.Println(string(result))
  31038. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31039. utils.ErrorLog("解析失败:%v", err)
  31040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31041. return
  31042. }
  31043. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31044. if reg_type == 11 && his.Insutype == "390" {
  31045. reg_type = 110104
  31046. }
  31047. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31048. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31049. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31050. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31051. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31052. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31053. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31054. resp, requestErr := http.Get(api)
  31055. if requestErr != nil {
  31056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31057. return
  31058. }
  31059. body, ioErr := ioutil.ReadAll(resp.Body)
  31060. if ioErr != nil {
  31061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31063. return
  31064. }
  31065. var respJSON map[string]interface{}
  31066. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31069. return
  31070. }
  31071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31072. result, _ := json.Marshal(respJSON)
  31073. fmt.Println("log")
  31074. fmt.Println(string(result))
  31075. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31076. utils.ErrorLog("解析失败:%v", err)
  31077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31078. return
  31079. }
  31080. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31081. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31082. var result3101 Result3101
  31083. //utils.ErrorLog("解析失败:%v", result3101)
  31084. result3101.Infcode = "0"
  31085. if result3101.Infcode == "0" {
  31086. if len(result3101.Output.Result) > 0 {
  31087. var errMsgs []string
  31088. for _, item := range result3101.Output.Result {
  31089. errMsgs = append(errMsgs, item.VolaCont)
  31090. }
  31091. c.ServeSuccessJSON(map[string]interface{}{
  31092. "failed_code": -10,
  31093. "msg": errMsgs,
  31094. })
  31095. return
  31096. } else {
  31097. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31098. if his.IdCardType != 4 {
  31099. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31100. bas := strings.Split(psn_info.CardInfo, "|")
  31101. if his.IdCardType == 1 {
  31102. cert_no = bas[2]
  31103. } else {
  31104. cert_no = bas[1]
  31105. }
  31106. } else {
  31107. cert_no = his.Certno
  31108. }
  31109. //江苏地区国家医保医疗类别
  31110. //职工透析:医疗类别选特殊情况门诊9933
  31111. //居民血透门慢: 医疗类别选门诊慢病1402
  31112. //var med_type string
  31113. //if his.Insutype == "310" {
  31114. // if reg_type == 14 {
  31115. // med_type = "9933"
  31116. // } else if reg_type == 11 {
  31117. // med_type = "11"
  31118. //
  31119. // }
  31120. //} else if his.Insutype == "390" {
  31121. // if reg_type == 14 {
  31122. // med_type = "1402"
  31123. // } else if reg_type == 11 {
  31124. // med_type = "11"
  31125. // }
  31126. //}
  31127. var api string
  31128. if miConfig.MdtrtareaAdmvs == "320921" {
  31129. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31130. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31131. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31132. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31133. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31134. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31135. "&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
  31136. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31137. } else {
  31138. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31139. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31140. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31141. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31142. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31143. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31144. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31145. "&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
  31146. }
  31147. resp, requestErr := http.Get(api)
  31148. if requestErr != nil {
  31149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31150. return
  31151. }
  31152. body, ioErr := ioutil.ReadAll(resp.Body)
  31153. if ioErr != nil {
  31154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31156. return
  31157. }
  31158. var respJSON map[string]interface{}
  31159. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31162. return
  31163. }
  31164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31165. result, _ := json.Marshal(respJSON)
  31166. fmt.Println("log")
  31167. fmt.Println(string(result))
  31168. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  31169. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31170. utils.ErrorLog("解析失败:%v", err)
  31171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31172. return
  31173. }
  31174. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31175. res.Output = resSeven10265.Output
  31176. res.ErrMsg = resSeven10265.ErrMsg
  31177. res.Cainfo = resSeven10265.Cainfo
  31178. res.WarnMsg = resSeven10265.WarnMsg
  31179. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31180. res.Infcode = infocode
  31181. } else {
  31182. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31183. utils.ErrorLog("解析失败:%v", err)
  31184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31185. return
  31186. }
  31187. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31188. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31189. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31190. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31191. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31192. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31193. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31194. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31195. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31196. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31197. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31198. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31199. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31200. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31201. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31202. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31203. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31204. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31205. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31206. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31207. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31208. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31209. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31210. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31211. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31212. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31213. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31214. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31215. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31216. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31217. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31218. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31219. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31220. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31221. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31222. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31223. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31224. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31225. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31226. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31227. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31228. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31229. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31230. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31231. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31232. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31233. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31234. res.ErrMsg = resSeven10265Two.ErrMsg
  31235. res.Cainfo = resSeven10265Two.Cainfo
  31236. res.WarnMsg = resSeven10265Two.WarnMsg
  31237. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31238. res.Infcode = infocode
  31239. }
  31240. }
  31241. }
  31242. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31243. psn_info, _ := service.GetPsnByPatientId(id)
  31244. var verify_number string
  31245. if psn_info.IdCardType == 4 {
  31246. verify_number = psn_info.VerifyNumber
  31247. } else if psn_info.IdCardType == 1 {
  31248. bas := strings.Split(psn_info.CardInfo, "|")
  31249. cardNumber := bas[2]
  31250. verify_number = cardNumber
  31251. } else {
  31252. psn_info.IdCardType = 2
  31253. verify_number = psn_info.Certno
  31254. }
  31255. var api string
  31256. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31257. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  31258. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31259. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31260. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  31261. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31262. "&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
  31263. resp, requestErr := http.Get(api)
  31264. if requestErr != nil {
  31265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31266. return
  31267. }
  31268. body, ioErr := ioutil.ReadAll(resp.Body)
  31269. if ioErr != nil {
  31270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31272. return
  31273. }
  31274. var respJSON map[string]interface{}
  31275. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31278. return
  31279. }
  31280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31281. result, _ := json.Marshal(respJSON)
  31282. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31283. utils.ErrorLog("解析失败:%v", err)
  31284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31285. return
  31286. }
  31287. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31288. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  31289. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  31290. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31291. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  31292. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  31293. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  31294. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  31295. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  31296. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  31297. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  31298. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  31299. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  31300. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31301. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  31302. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  31303. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  31304. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  31305. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  31306. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  31307. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31308. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  31309. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  31310. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  31311. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  31312. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  31313. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  31314. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  31315. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  31316. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  31317. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  31318. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  31319. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  31320. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  31321. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31322. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  31323. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  31324. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  31325. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  31326. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  31327. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  31328. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  31329. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  31330. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  31331. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  31332. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  31333. res.ErrMsg = resSeven10265.ErrMsg
  31334. res.Cainfo = resSeven10265.Cainfo
  31335. res.WarnMsg = resSeven10265.WarnMsg
  31336. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31337. res.Infcode = infocode
  31338. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31339. acct_used_flag := "1"
  31340. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  31341. var result string
  31342. var request_log string
  31343. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  31344. 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)
  31345. } else {
  31346. 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)
  31347. }
  31348. var dat map[string]interface{}
  31349. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31350. fmt.Println(dat)
  31351. } else {
  31352. fmt.Println(err)
  31353. }
  31354. saveLog(result, request_log, "2206", "预结算")
  31355. userJSONBytes, _ := json.Marshal(dat)
  31356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31357. utils.ErrorLog("解析失败:%v", err)
  31358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31359. return
  31360. }
  31361. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31362. var result string
  31363. var request_log string
  31364. if his.IdCardType == 2 {
  31365. insutype = strconv.FormatInt(his.SocialType, 10)
  31366. 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, "")
  31367. } else if his.IdCardType == 1 {
  31368. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31369. bas := strings.Split(psn_info.CardInfo, "|")
  31370. basNumber := bas[2]
  31371. card_sn := bas[3]
  31372. var rf []*ResultFive
  31373. json.Unmarshal([]byte(his.Iinfo), &rf)
  31374. var psn_type string
  31375. for _, item := range rf {
  31376. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31377. psn_type = item.PsnType
  31378. }
  31379. }
  31380. insutype = strconv.FormatInt(his.SocialType, 10)
  31381. 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)
  31382. } else {
  31383. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31384. //bas := strings.Split(psn_info.CardInfo, "|")
  31385. //basNumber := bas[2]
  31386. //card_sn := bas[3]
  31387. var rf []*ResultFive
  31388. json.Unmarshal([]byte(his.Iinfo), &rf)
  31389. var psn_type string
  31390. for _, item := range rf {
  31391. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31392. psn_type = item.PsnType
  31393. }
  31394. }
  31395. insutype = strconv.FormatInt(his.SocialType, 10)
  31396. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31397. 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)
  31398. }
  31399. var dat map[string]interface{}
  31400. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31401. fmt.Println(dat)
  31402. } else {
  31403. fmt.Println(err)
  31404. }
  31405. saveLog(result, request_log, "2206", "预结算")
  31406. userJSONBytes, _ := json.Marshal(dat)
  31407. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31408. utils.ErrorLog("解析失败:%v", err)
  31409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31410. return
  31411. }
  31412. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31413. var result string
  31414. var request_log string
  31415. if his.IdCardType == 2 {
  31416. insutype = strconv.FormatInt(his.SocialType, 10)
  31417. 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, "")
  31418. } else if his.IdCardType == 1 {
  31419. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31420. bas := strings.Split(psn_info.CardInfo, "|")
  31421. basNumber := bas[0]
  31422. card_sn := ""
  31423. var rf []*ResultFive
  31424. json.Unmarshal([]byte(his.Iinfo), &rf)
  31425. var psn_type string
  31426. for _, item := range rf {
  31427. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31428. psn_type = item.PsnType
  31429. }
  31430. }
  31431. insutype = strconv.FormatInt(his.SocialType, 10)
  31432. 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)
  31433. } else {
  31434. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31435. //bas := strings.Split(psn_info.CardInfo, "|")
  31436. //basNumber := bas[2]
  31437. //card_sn := bas[3]
  31438. var rf []*ResultFive
  31439. json.Unmarshal([]byte(his.Iinfo), &rf)
  31440. var psn_type string
  31441. for _, item := range rf {
  31442. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31443. psn_type = item.PsnType
  31444. }
  31445. }
  31446. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31447. 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)
  31448. }
  31449. var dat map[string]interface{}
  31450. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31451. fmt.Println(dat)
  31452. } else {
  31453. fmt.Println(err)
  31454. }
  31455. saveLog(result, request_log, "2206", "预结算")
  31456. userJSONBytes, _ := json.Marshal(dat)
  31457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31458. utils.ErrorLog("解析失败:%v", err)
  31459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31460. return
  31461. }
  31462. } else if miConfig.MdtrtareaAdmvs == "360100" {
  31463. var result string
  31464. var request_log string
  31465. if his.IdCardType == 2 {
  31466. insutype = strconv.FormatInt(his.SocialType, 10)
  31467. 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, "")
  31468. } else if his.IdCardType == 1 {
  31469. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31470. bas := strings.Split(psn_info.CardInfo, "|")
  31471. basNumber := bas[0]
  31472. card_sn := ""
  31473. var rf []*ResultFive
  31474. json.Unmarshal([]byte(his.Iinfo), &rf)
  31475. var psn_type string
  31476. for _, item := range rf {
  31477. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31478. psn_type = item.PsnType
  31479. }
  31480. }
  31481. insutype = strconv.FormatInt(his.SocialType, 10)
  31482. 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)
  31483. } else {
  31484. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31485. //bas := strings.Split(psn_info.CardInfo, "|")
  31486. //basNumber := bas[2]
  31487. //card_sn := bas[3]
  31488. var rf []*ResultFive
  31489. json.Unmarshal([]byte(his.Iinfo), &rf)
  31490. var psn_type string
  31491. for _, item := range rf {
  31492. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31493. psn_type = item.PsnType
  31494. }
  31495. }
  31496. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31497. 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)
  31498. }
  31499. var dat map[string]interface{}
  31500. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31501. fmt.Println(dat)
  31502. } else {
  31503. fmt.Println(err)
  31504. }
  31505. saveLog(result, request_log, "2206", "预结算")
  31506. userJSONBytes, _ := json.Marshal(dat)
  31507. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31508. utils.ErrorLog("解析失败:%v", err)
  31509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31510. return
  31511. }
  31512. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31513. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31514. if his.IdCardType == 4 {
  31515. psn_info.VerifyNumber = psn_info.VerifyNumber
  31516. cert_no = psn_info.VerifyNumber
  31517. } else if his.IdCardType == 2 {
  31518. cert_no = psn_info.Certno
  31519. psn_info.VerifyNumber = psn_info.Certno
  31520. } else {
  31521. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31522. bas := strings.Split(psn_info.CardInfo, "|")
  31523. if his.IdCardType == 1 {
  31524. cert_no = bas[2]
  31525. } else {
  31526. cert_no = bas[1]
  31527. }
  31528. }
  31529. var api string
  31530. var med_type string
  31531. if his.Insutype == "390" {
  31532. if reg_type == 992102 {
  31533. med_type = "992102"
  31534. }
  31535. if reg_type == 140104 {
  31536. med_type = "140104"
  31537. }
  31538. if reg_type == 140201 {
  31539. med_type = "140201"
  31540. }
  31541. if reg_type == 14 {
  31542. med_type = "140104"
  31543. }
  31544. if reg_type == 1104 {
  31545. med_type = "1104"
  31546. }
  31547. } else if his.Insutype == "310" {
  31548. if reg_type == 1104 {
  31549. med_type = "1104"
  31550. }
  31551. if reg_type == 992102 {
  31552. med_type = "992102"
  31553. }
  31554. if reg_type == 140104 {
  31555. med_type = "140104"
  31556. }
  31557. if reg_type == 140201 {
  31558. med_type = "140201"
  31559. }
  31560. if reg_type == 14 {
  31561. med_type = "140104"
  31562. }
  31563. }
  31564. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31565. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31566. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31567. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31568. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31569. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31570. "&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
  31571. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31572. resp, requestErr := http.Get(api)
  31573. if requestErr != nil {
  31574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31575. return
  31576. }
  31577. body, ioErr := ioutil.ReadAll(resp.Body)
  31578. if ioErr != nil {
  31579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31581. return
  31582. }
  31583. var respJSON map[string]interface{}
  31584. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31587. return
  31588. }
  31589. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31590. if status == "0" {
  31591. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31592. c.ServeSuccessJSON(map[string]interface{}{
  31593. "failed_code": -10,
  31594. "msg": err_msg,
  31595. })
  31596. return
  31597. }
  31598. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31599. result, _ := json.Marshal(respJSON)
  31600. fmt.Println("log")
  31601. fmt.Println(string(result))
  31602. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  31603. utils.ErrorLog("解析失败:%v", err)
  31604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31605. return
  31606. }
  31607. res.InfRefmsgid = ahres.InfRefmsgid
  31608. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31609. // 创建对应的Time类型
  31610. t := time.UnixMilli(timestamp)
  31611. // 格式化成指定的日期字符串
  31612. str := t.Format("2006-01-02 15:04:05")
  31613. res.Output.Setlinfo.SetlTime = str
  31614. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31615. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31616. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31617. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31618. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31619. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31620. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31621. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31622. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31623. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31624. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31625. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31626. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31627. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31628. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31629. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31630. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31631. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31632. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31633. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31634. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31635. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31636. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31637. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31638. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31639. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31640. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31641. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31642. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31643. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31644. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31645. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31646. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31647. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  31648. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31649. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  31650. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  31651. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  31652. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  31653. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31654. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  31655. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31656. //res.Output.Setldetail = ahres.Output.Setldetail
  31657. res.ErrMsg = ahres.ErrMsg
  31658. res.Cainfo = ahres.Cainfo
  31659. res.WarnMsg = ahres.WarnMsg
  31660. res.Infcode = ahres.Infcode
  31661. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31662. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31663. if his.IdCardType == 4 {
  31664. psn_info.VerifyNumber = psn_info.VerifyNumber
  31665. cert_no = psn_info.Certno
  31666. } else if his.IdCardType == 2 {
  31667. cert_no = psn_info.Certno
  31668. psn_info.VerifyNumber = psn_info.Certno
  31669. } else {
  31670. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31671. bas := strings.Split(psn_info.CardInfo, "|")
  31672. if his.IdCardType == 1 {
  31673. cert_no = bas[2]
  31674. } else {
  31675. cert_no = bas[1]
  31676. }
  31677. }
  31678. var api string
  31679. var med_type string
  31680. if his.Insutype == "390" {
  31681. if reg_type == 992102 {
  31682. med_type = "992102"
  31683. }
  31684. if reg_type == 140104 {
  31685. med_type = "140104"
  31686. }
  31687. if reg_type == 140201 {
  31688. med_type = "140201"
  31689. }
  31690. if reg_type == 14 {
  31691. med_type = "14"
  31692. }
  31693. } else if his.Insutype == "310" {
  31694. if reg_type == 992102 {
  31695. med_type = "992102"
  31696. }
  31697. if reg_type == 140104 {
  31698. med_type = "140104"
  31699. }
  31700. if reg_type == 140201 {
  31701. med_type = "140201"
  31702. }
  31703. if reg_type == 14 {
  31704. med_type = "14"
  31705. }
  31706. }
  31707. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31708. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31709. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31710. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31711. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31712. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31713. "&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
  31714. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31715. resp, requestErr := http.Get(api)
  31716. if requestErr != nil {
  31717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31718. return
  31719. }
  31720. body, ioErr := ioutil.ReadAll(resp.Body)
  31721. if ioErr != nil {
  31722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31724. return
  31725. }
  31726. var respJSON map[string]interface{}
  31727. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31730. return
  31731. }
  31732. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31733. if status == "0" {
  31734. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31735. c.ServeSuccessJSON(map[string]interface{}{
  31736. "failed_code": -10,
  31737. "msg": err_msg,
  31738. })
  31739. return
  31740. }
  31741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31742. result, _ := json.Marshal(respJSON)
  31743. fmt.Println("log")
  31744. fmt.Println(string(result))
  31745. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  31746. utils.ErrorLog("解析失败:%v", err)
  31747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31748. return
  31749. }
  31750. res.InfRefmsgid = ahres.InfRefmsgid
  31751. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31752. // 创建对应的Time类型
  31753. t := time.UnixMilli(timestamp)
  31754. // 格式化成指定的日期字符串
  31755. str := t.Format("2006-01-02 15:04:05")
  31756. res.Output.Setlinfo.SetlTime = str
  31757. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31758. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31759. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31760. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31761. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31762. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31763. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31764. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31765. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31766. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31767. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31768. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31769. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31770. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31771. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31772. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31773. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31774. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31775. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31776. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31777. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31778. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31779. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31780. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31781. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31782. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31783. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31784. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31785. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31786. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31787. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31788. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31789. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31790. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  31791. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31792. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  31793. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  31794. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  31795. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  31796. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31797. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  31798. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31799. //res.Output.Setldetail = ahres.Output.Setldetail
  31800. res.ErrMsg = ahres.ErrMsg
  31801. res.Cainfo = ahres.Cainfo
  31802. res.WarnMsg = ahres.WarnMsg
  31803. res.Infcode = ahres.Infcode
  31804. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31805. var result string
  31806. var request_log string
  31807. if his.IdCardType == 2 {
  31808. 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")
  31809. } else if his.IdCardType == 1 {
  31810. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31811. bas := strings.Split(psn_info.CardInfo, "|")
  31812. basNumber := bas[2]
  31813. card_sn := bas[3]
  31814. 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")
  31815. } else {
  31816. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31817. 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")
  31818. }
  31819. var dat map[string]interface{}
  31820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31821. fmt.Println(dat)
  31822. } else {
  31823. fmt.Println(err)
  31824. }
  31825. saveLog(result, request_log, "2206", "预结算")
  31826. userJSONBytes, _ := json.Marshal(dat)
  31827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31828. utils.ErrorLog("解析失败:%v", err)
  31829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31830. return
  31831. }
  31832. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31833. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31834. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31835. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31836. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31837. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31838. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31839. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31840. resp, requestErr := http.Get(api)
  31841. if requestErr != nil {
  31842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31843. return
  31844. }
  31845. body, ioErr := ioutil.ReadAll(resp.Body)
  31846. if ioErr != nil {
  31847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31849. return
  31850. }
  31851. var respJSON map[string]interface{}
  31852. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31855. return
  31856. }
  31857. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31858. result, _ := json.Marshal(respJSON)
  31859. fmt.Println("log")
  31860. fmt.Println(string(result))
  31861. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31862. utils.ErrorLog("解析失败:%v", err)
  31863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31864. return
  31865. }
  31866. } else {
  31867. if miConfig.MdtrtareaAdmvs == "441202" {
  31868. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31869. if result3101.Infcode == 0 {
  31870. if len(result3101.Output.Result) > 0 {
  31871. c.ServeSuccessJSON(map[string]interface{}{
  31872. "failed_code": -10,
  31873. "failed_type": 100,
  31874. "msg": result3101.Output.Result,
  31875. })
  31876. return
  31877. } else {
  31878. var result string
  31879. var request_log string
  31880. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31881. allTotal = fmt.Sprintf("%.2f", total_two)
  31882. if his.IdCardType == 4 {
  31883. 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)
  31884. } else {
  31885. 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)
  31886. }
  31887. var dat map[string]interface{}
  31888. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31889. fmt.Println(dat)
  31890. } else {
  31891. fmt.Println(err)
  31892. }
  31893. saveLog(result, request_log, "2206", "预结算")
  31894. //userJSONBytes, _ := json.Marshal(dat)
  31895. //
  31896. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31897. // utils.ErrorLog("解析失败:%v", err)
  31898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31899. // return
  31900. //}
  31901. userJSONBytes, _ := json.Marshal(dat)
  31902. if miConfig.Code == "H15049901371" {
  31903. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  31904. utils.ErrorLog("解析失败:%v", err)
  31905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31906. return
  31907. }
  31908. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31909. res.Output = resSeven10265.Output
  31910. res.ErrMsg = resSeven10265.ErrMsg
  31911. res.Cainfo = resSeven10265.Cainfo
  31912. res.WarnMsg = resSeven10265.WarnMsg
  31913. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31914. res.Infcode = infocode
  31915. } else {
  31916. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31917. utils.ErrorLog("解析失败:%v", err)
  31918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31919. return
  31920. }
  31921. }
  31922. }
  31923. } else {
  31924. c.ServeSuccessJSON(map[string]interface{}{
  31925. "failed_code": -10,
  31926. "msg": result3101.ErrMsg,
  31927. })
  31928. return
  31929. }
  31930. } else if miConfig.MdtrtareaAdmvs == "440205" {
  31931. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31932. if result3101.Infcode == 0 {
  31933. if len(result3101.Output.Result) > 0 {
  31934. var errMsgs []string
  31935. for _, item := range result3101.Output.Result {
  31936. errMsgs = append(errMsgs, item.VolaCont)
  31937. }
  31938. c.ServeSuccessJSON(map[string]interface{}{
  31939. "failed_code": -10,
  31940. "msg": errMsgs,
  31941. })
  31942. return
  31943. } else {
  31944. var result string
  31945. var request_log string
  31946. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31947. allTotal = fmt.Sprintf("%.2f", total_two)
  31948. if his.IdCardType == 4 {
  31949. 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)
  31950. } else {
  31951. 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)
  31952. }
  31953. var dat map[string]interface{}
  31954. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31955. fmt.Println(dat)
  31956. } else {
  31957. fmt.Println(err)
  31958. }
  31959. saveLog(result, request_log, "2206", "预结算")
  31960. //userJSONBytes, _ := json.Marshal(dat)
  31961. //
  31962. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31963. // utils.ErrorLog("解析失败:%v", err)
  31964. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31965. // return
  31966. //}
  31967. userJSONBytes, _ := json.Marshal(dat)
  31968. if miConfig.Code == "H15049901371" {
  31969. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  31970. utils.ErrorLog("解析失败:%v", err)
  31971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31972. return
  31973. }
  31974. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31975. res.Output = resSeven10265.Output
  31976. res.ErrMsg = resSeven10265.ErrMsg
  31977. res.Cainfo = resSeven10265.Cainfo
  31978. res.WarnMsg = resSeven10265.WarnMsg
  31979. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31980. res.Infcode = infocode
  31981. } else {
  31982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31983. utils.ErrorLog("解析失败:%v", err)
  31984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31985. return
  31986. }
  31987. }
  31988. }
  31989. } else {
  31990. c.ServeSuccessJSON(map[string]interface{}{
  31991. "failed_code": -10,
  31992. "msg": result3101.ErrMsg,
  31993. })
  31994. return
  31995. }
  31996. } else {
  31997. var result string
  31998. var request_log string
  31999. var dat map[string]interface{}
  32000. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32001. allTotal = fmt.Sprintf("%.2f", total_two)
  32002. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  32003. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32004. if result3101.Infcode == 0 {
  32005. if len(result3101.Output.Result) > 0 {
  32006. c.ServeSuccessJSON(map[string]interface{}{
  32007. "failed_code": -10,
  32008. "failed_type": 100,
  32009. "warm_type": 2,
  32010. "msg": result3101,
  32011. })
  32012. return
  32013. } else {
  32014. var result string
  32015. var request_log string
  32016. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32017. allTotal = fmt.Sprintf("%.2f", total_two)
  32018. if his.IdCardType == 4 {
  32019. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, his.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)
  32020. } else {
  32021. if his.IdCardType == 2 {
  32022. cert_no = psn_info.Certno
  32023. psn_info.VerifyNumber = psn_info.Certno
  32024. } else {
  32025. bas := strings.Split(psn_info.CardInfo, "|")
  32026. cert_no = bas[2]
  32027. }
  32028. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  32029. }
  32030. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32031. fmt.Println(dat)
  32032. } else {
  32033. fmt.Println(err)
  32034. }
  32035. saveLog(result, request_log, "2206", "预结算")
  32036. }
  32037. } else {
  32038. c.ServeSuccessJSON(map[string]interface{}{
  32039. "failed_code": -10,
  32040. "msg": result3101.ErrMsg,
  32041. })
  32042. return
  32043. }
  32044. } else {
  32045. if his.IdCardType == 4 {
  32046. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, his.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)
  32047. } else {
  32048. if his.IdCardType == 2 {
  32049. cert_no = psn_info.Certno
  32050. psn_info.VerifyNumber = psn_info.Certno
  32051. } else {
  32052. bas := strings.Split(psn_info.CardInfo, "|")
  32053. cert_no = bas[2]
  32054. }
  32055. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, his.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)
  32056. }
  32057. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32058. fmt.Println(dat)
  32059. } else {
  32060. fmt.Println(err)
  32061. }
  32062. saveLog(result, request_log, "2206", "预结算")
  32063. }
  32064. //userJSONBytes, _ := json.Marshal(dat)
  32065. //
  32066. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32067. // utils.ErrorLog("解析失败:%v", err)
  32068. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32069. // return
  32070. //}
  32071. userJSONBytes, _ := json.Marshal(dat)
  32072. if miConfig.Code == "H15049901371" {
  32073. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32074. utils.ErrorLog("解析失败:%v", err)
  32075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32076. return
  32077. }
  32078. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32079. res.Output = resSeven10265.Output
  32080. res.ErrMsg = resSeven10265.ErrMsg
  32081. res.Cainfo = resSeven10265.Cainfo
  32082. res.WarnMsg = resSeven10265.WarnMsg
  32083. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32084. res.Infcode = infocode
  32085. } else {
  32086. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32087. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  32088. utils.ErrorLog("解析失败:%v", err)
  32089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32090. return
  32091. }
  32092. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  32093. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  32094. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  32095. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32096. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  32097. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  32098. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  32099. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32100. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  32101. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32102. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32103. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32104. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32105. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32106. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  32107. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  32108. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  32109. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  32110. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  32111. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  32112. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32113. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  32114. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  32115. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  32116. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  32117. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  32118. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  32119. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  32120. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  32121. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  32122. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  32123. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  32124. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  32125. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  32126. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32127. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  32128. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  32129. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  32130. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32131. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  32132. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  32133. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  32134. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  32135. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  32136. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  32137. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  32138. res.ErrMsg = gzresSeven10265Two.ErrMsg
  32139. res.Cainfo = gzresSeven10265Two.Cainfo
  32140. res.WarnMsg = gzresSeven10265Two.WarnMsg
  32141. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  32142. //res.Infcode = infocode
  32143. } else {
  32144. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32145. utils.ErrorLog("解析失败:%v", err)
  32146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32147. return
  32148. }
  32149. }
  32150. }
  32151. }
  32152. }
  32153. utils.ErrorLog("解析失败:%v", res.Infcode)
  32154. if res.Infcode == -1 {
  32155. errlog := &models.HisOrderError{
  32156. UserOrgId: adminUser.CurrentOrgId,
  32157. Ctime: time.Now().Unix(),
  32158. Mtime: time.Now().Unix(),
  32159. Number: chrg_bchno,
  32160. ErrMsg: res.ErrMsg,
  32161. Status: 1,
  32162. PatientId: id,
  32163. RecordTime: recordDateTime,
  32164. Stage: 20,
  32165. }
  32166. service.CreateErrMsgLog(errlog)
  32167. c.ServeSuccessJSON(map[string]interface{}{
  32168. "failed_code": -10,
  32169. "msg": res.ErrMsg,
  32170. })
  32171. return
  32172. }
  32173. if res.Infcode != 0 {
  32174. errlog := &models.HisOrderError{
  32175. UserOrgId: adminUser.CurrentOrgId,
  32176. Ctime: time.Now().Unix(),
  32177. Mtime: time.Now().Unix(),
  32178. Number: chrg_bchno,
  32179. ErrMsg: res.ErrMsg,
  32180. Status: 1,
  32181. PatientId: id,
  32182. RecordTime: recordDateTime,
  32183. Stage: 20,
  32184. }
  32185. service.CreateErrMsgLog(errlog)
  32186. c.ServeSuccessJSON(map[string]interface{}{
  32187. "failed_code": -10,
  32188. "msg": res.ErrMsg,
  32189. })
  32190. return
  32191. } else {
  32192. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32193. order.OrderStatus = 1
  32194. order.IsPre = 1
  32195. order.Status = 1
  32196. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  32197. order.SetlId = res.Output.Setlinfo.SetlID
  32198. order.PsnNo = res.Output.Setlinfo.PsnNo
  32199. order.PsnName = res.Output.Setlinfo.PsnName
  32200. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  32201. order.Certno = res.Output.Setlinfo.Certno
  32202. order.Gend = res.Output.Setlinfo.Gend
  32203. order.Naty = res.Output.Setlinfo.Naty
  32204. order.Age = res.Output.Setlinfo.Age
  32205. order.Insutype = res.Output.Setlinfo.Insutype
  32206. order.PsnType = res.Output.Setlinfo.PsnType
  32207. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  32208. order.SetlTime = res.Output.Setlinfo.SetlTime
  32209. order.AcctUsedFlag = acct_used_flag
  32210. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  32211. if res.Output.Setlinfo.MedType == "140101" {
  32212. order.MedType = "14"
  32213. } else {
  32214. if res.Output.Setlinfo.MedType == "110104" {
  32215. order.MedType = "11"
  32216. } else {
  32217. order.MedType = res.Output.Setlinfo.MedType
  32218. }
  32219. }
  32220. if res.Output.Setlinfo.MedType == "992102" {
  32221. order.MedType = "992102"
  32222. }
  32223. if res.Output.Setlinfo.MedType == "140104" {
  32224. order.MedType = "140104"
  32225. }
  32226. if res.Output.Setlinfo.MedType == "1104" {
  32227. order.MedType = "1104"
  32228. }
  32229. if res.Output.Setlinfo.MedType == "140201" {
  32230. order.MedType = "140201"
  32231. }
  32232. if res.Output.Setlinfo.MedType == "14" {
  32233. order.MedType = "14"
  32234. }
  32235. if reg_type == 1112 {
  32236. order.MedType = "1112"
  32237. }
  32238. if reg_type == 1111 {
  32239. order.MedType = "1111"
  32240. }
  32241. order.ClrType = res.Output.Setlinfo.ClrType
  32242. if adminUser.CurrentOrgId == 10480 {
  32243. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32244. order.ClrType = "11"
  32245. } else {
  32246. order.ClrType = "9903"
  32247. }
  32248. }
  32249. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  32250. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  32251. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  32252. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  32253. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  32254. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  32255. order.HifpPay = res.Output.Setlinfo.HifpPay
  32256. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  32257. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  32258. order.HifesPay = res.Output.Setlinfo.HifesPay
  32259. order.HifobPay = res.Output.Setlinfo.HifobPay
  32260. order.MafPay = res.Output.Setlinfo.MafPay
  32261. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  32262. order.OthPay = res.Output.Setlinfo.OthPay
  32263. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  32264. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  32265. order.AcctPay = res.Output.Setlinfo.AcctPay
  32266. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  32267. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  32268. order.Balc = res.Output.Setlinfo.Balc
  32269. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  32270. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  32271. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  32272. order.ClrWay = res.Output.Setlinfo.ClrWay
  32273. order.Creator = order.Creator
  32274. order.Modify = roles.AdminUserId
  32275. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32276. //detailStr := string(setlDetail)
  32277. //order.SetlDetail = detailStr
  32278. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32279. err = service.UpDateOrder(order)
  32280. if err == nil {
  32281. c.ServeSuccessJSON(map[string]interface{}{
  32282. "msg": "预结算成功",
  32283. })
  32284. } else {
  32285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32286. return
  32287. }
  32288. }
  32289. } else {
  32290. adminUser := c.GetAdminUserInfo()
  32291. errlog := &models.HisOrderError{
  32292. UserOrgId: adminUser.CurrentOrgId,
  32293. Ctime: time.Now().Unix(),
  32294. Mtime: time.Now().Unix(),
  32295. ErrMsg: res.ErrMsg,
  32296. Status: 1,
  32297. PatientId: id,
  32298. RecordTime: recordDateTime,
  32299. Stage: 4,
  32300. }
  32301. service.CreateErrMsgLog(errlog)
  32302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  32303. return
  32304. }
  32305. } else {
  32306. if miConfig.MdtrtareaAdmvs == "150499" {
  32307. order := &models.HisOrder{
  32308. UserOrgId: adminUser.CurrentOrgId,
  32309. HisPatientId: his.ID,
  32310. PatientId: his.PatientId,
  32311. SettleAccountsDate: recordDateTime,
  32312. Ctime: time.Now().Unix(),
  32313. Mtime: time.Now().Unix(),
  32314. MdtrtId: his.Number,
  32315. PsnNo: his.PsnNo,
  32316. MedType: strconv.FormatInt(reg_type, 10),
  32317. Status: 1,
  32318. Number: chrg_bchno,
  32319. Infcode: res.Infcode,
  32320. WarnMsg: res.WarnMsg,
  32321. Cainfo: res.Cainfo,
  32322. ErrMsg: res.ErrMsg,
  32323. RespondTime: res.RefmsgTime,
  32324. InfRefmsgid: res.InfRefmsgid,
  32325. OrderStatus: 1,
  32326. IsMedicineInsurance: 1,
  32327. SettleType: settle_accounts_type,
  32328. SettleStartTime: start_time,
  32329. SettleEndTime: end_time,
  32330. Creator: roles.AdminUserId,
  32331. Modify: roles.AdminUserId,
  32332. PType: 2,
  32333. Diagnosis: diagnosis_id,
  32334. }
  32335. err = service.CreateOrder(order)
  32336. if err != nil {
  32337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  32338. return
  32339. }
  32340. }
  32341. adminUser := c.GetAdminUserInfo()
  32342. errlog := &models.HisOrderError{
  32343. UserOrgId: adminUser.CurrentOrgId,
  32344. Ctime: time.Now().Unix(),
  32345. Mtime: time.Now().Unix(),
  32346. ErrMsg: res.ErrMsg,
  32347. Status: 1,
  32348. PatientId: id,
  32349. RecordTime: recordDateTime,
  32350. Stage: 4,
  32351. }
  32352. service.CreateErrMsgLog(errlog)
  32353. c.ServeSuccessJSON(map[string]interface{}{
  32354. "failed_code": -10,
  32355. "msg": res.ErrMsg,
  32356. })
  32357. return
  32358. }
  32359. }
  32360. }
  32361. }
  32362. // 退款
  32363. func (c *HisApiController) Refund() {
  32364. order_id, _ := c.GetInt64("order_id")
  32365. admin_user_id, _ := c.GetInt64("admin_user_id")
  32366. adminUser := c.GetAdminUserInfo()
  32367. var order models.HisOrder
  32368. order, _ = service.GetHisOrderByID(order_id)
  32369. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  32370. if fapiao.ID > 0 {
  32371. c.ServeSuccessJSON(map[string]interface{}{
  32372. "failed_code": -10,
  32373. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  32374. })
  32375. return
  32376. }
  32377. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32378. if order.ID == 0 {
  32379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32380. return
  32381. }
  32382. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32383. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32384. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32385. if config.IsOpen == 1 { //对接了医保,走医保流程
  32386. var res ResultSixteen
  32387. var ahres ResultSevenAH
  32388. var resSixteen10265 ResultSixteen10265
  32389. var resSixteen10265Two ResultSixteen10265Two
  32390. var gz ResultgzSixteen10265Two
  32391. var src_resquest string
  32392. var result string
  32393. if miConfig.MdtrtareaAdmvs == "421300" {
  32394. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32395. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32396. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32397. resp3, requestErr3 := http.Get(api3)
  32398. if requestErr3 != nil {
  32399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32400. return
  32401. }
  32402. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32403. if ioErr3 != nil {
  32404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32406. return
  32407. }
  32408. var respJSON3 map[string]interface{}
  32409. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32412. return
  32413. }
  32414. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32415. userJSONBytes3, _ := json.Marshal(respJSON3)
  32416. fmt.Println("log")
  32417. fmt.Println(string(userJSONBytes3))
  32418. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32419. utils.ErrorLog("解析失败:%v", err)
  32420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32421. return
  32422. }
  32423. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32424. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32425. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32426. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32427. resp3, requestErr3 := http.Get(api3)
  32428. if requestErr3 != nil {
  32429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32430. return
  32431. }
  32432. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32433. if ioErr3 != nil {
  32434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32436. return
  32437. }
  32438. var respJSON3 map[string]interface{}
  32439. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32442. return
  32443. }
  32444. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32445. userJSONBytes3, _ := json.Marshal(respJSON3)
  32446. fmt.Println("log")
  32447. fmt.Println(string(userJSONBytes3))
  32448. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32449. utils.ErrorLog("解析失败:%v", err)
  32450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32451. return
  32452. }
  32453. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32454. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32455. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32456. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32457. resp3, requestErr3 := http.Get(api3)
  32458. if requestErr3 != nil {
  32459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32460. return
  32461. }
  32462. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32463. if ioErr3 != nil {
  32464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32466. return
  32467. }
  32468. var respJSON3 map[string]interface{}
  32469. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32472. return
  32473. }
  32474. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32475. userJSONBytes3, _ := json.Marshal(respJSON3)
  32476. fmt.Println("log")
  32477. fmt.Println(string(userJSONBytes3))
  32478. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32479. utils.ErrorLog("解析失败:%v", err)
  32480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32481. return
  32482. }
  32483. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32484. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32485. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32486. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32487. resp3, requestErr3 := http.Get(api3)
  32488. if requestErr3 != nil {
  32489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32490. return
  32491. }
  32492. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32493. if ioErr3 != nil {
  32494. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32496. return
  32497. }
  32498. var respJSON3 map[string]interface{}
  32499. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32500. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32502. return
  32503. }
  32504. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32505. userJSONBytes3, _ := json.Marshal(respJSON3)
  32506. fmt.Println("log")
  32507. fmt.Println(string(userJSONBytes3))
  32508. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32509. utils.ErrorLog("解析失败:%v", err)
  32510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32511. return
  32512. }
  32513. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32514. var api3 string
  32515. if miConfig.MdtrtareaAdmvs == "320921" {
  32516. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32517. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32518. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32519. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32520. } else {
  32521. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32522. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32523. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32524. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32525. }
  32526. resp3, requestErr3 := http.Get(api3)
  32527. if requestErr3 != nil {
  32528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32529. return
  32530. }
  32531. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32532. if ioErr3 != nil {
  32533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32535. return
  32536. }
  32537. var respJSON3 map[string]interface{}
  32538. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32541. return
  32542. }
  32543. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32544. userJSONBytes3, _ := json.Marshal(respJSON3)
  32545. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  32546. utils.ErrorLog("解析失败:%v", err)
  32547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32548. return
  32549. }
  32550. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  32551. res.Output = resSixteen10265.Output
  32552. res.ErrMsg = resSixteen10265.ErrMsg
  32553. res.Cainfo = resSixteen10265.Cainfo
  32554. res.WarnMsg = resSixteen10265.WarnMsg
  32555. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  32556. res.Infcode = infocode
  32557. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32558. var api3 string
  32559. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  32560. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32561. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32562. resp3, requestErr3 := http.Get(api3)
  32563. if requestErr3 != nil {
  32564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32565. return
  32566. }
  32567. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32568. if ioErr3 != nil {
  32569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32571. return
  32572. }
  32573. var respJSON3 map[string]interface{}
  32574. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32577. return
  32578. }
  32579. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32580. userJSONBytes3, _ := json.Marshal(respJSON3)
  32581. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  32582. utils.ErrorLog("解析失败:%v", err)
  32583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32584. return
  32585. }
  32586. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  32587. res.Output = resSixteen10265.Output
  32588. res.ErrMsg = resSixteen10265.ErrMsg
  32589. res.Cainfo = resSixteen10265.Cainfo
  32590. res.WarnMsg = resSixteen10265.WarnMsg
  32591. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  32592. res.Infcode = infocode
  32593. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32594. 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)
  32595. var dat map[string]interface{}
  32596. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32597. fmt.Println(dat)
  32598. } else {
  32599. fmt.Println(err)
  32600. }
  32601. saveLog(result, src_resquest, "2208", "退费")
  32602. userJSONBytes, _ := json.Marshal(dat)
  32603. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32604. utils.ErrorLog("解析失败:%v", err)
  32605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32606. return
  32607. }
  32608. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32609. 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, "")
  32610. var dat map[string]interface{}
  32611. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32612. fmt.Println(dat)
  32613. } else {
  32614. fmt.Println(err)
  32615. }
  32616. saveLog(result, src_resquest, "2208", "退费")
  32617. userJSONBytes, _ := json.Marshal(dat)
  32618. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32619. utils.ErrorLog("解析失败:%v", err)
  32620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32621. return
  32622. }
  32623. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32624. 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, "")
  32625. var dat map[string]interface{}
  32626. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32627. fmt.Println(dat)
  32628. } else {
  32629. fmt.Println(err)
  32630. }
  32631. saveLog(result, src_resquest, "2208", "退费")
  32632. userJSONBytes, _ := json.Marshal(dat)
  32633. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32634. utils.ErrorLog("解析失败:%v", err)
  32635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32636. return
  32637. }
  32638. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32639. 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, "")
  32640. var dat map[string]interface{}
  32641. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32642. fmt.Println(dat)
  32643. } else {
  32644. fmt.Println(err)
  32645. }
  32646. saveLog(result, src_resquest, "2208", "退费")
  32647. userJSONBytes, _ := json.Marshal(dat)
  32648. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32649. utils.ErrorLog("解析失败:%v", err)
  32650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32651. return
  32652. }
  32653. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32654. var api3 string
  32655. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  32656. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32657. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32658. resp3, requestErr3 := http.Get(api3)
  32659. if requestErr3 != nil {
  32660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32661. return
  32662. }
  32663. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32664. if ioErr3 != nil {
  32665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32667. return
  32668. }
  32669. var respJSON3 map[string]interface{}
  32670. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32673. return
  32674. }
  32675. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32676. if status == "0" {
  32677. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32678. c.ServeSuccessJSON(map[string]interface{}{
  32679. "failed_code": -10,
  32680. "msg": err_msg,
  32681. })
  32682. return
  32683. }
  32684. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32685. userJSONBytes3, _ := json.Marshal(respJSON3)
  32686. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32687. // utils.ErrorLog("解析失败:%v", err)
  32688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32689. // return
  32690. //}
  32691. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  32692. utils.ErrorLog("解析失败:%v", err)
  32693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32694. return
  32695. }
  32696. res.InfRefmsgid = ahres.InfRefmsgid
  32697. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32698. // 创建对应的Time类型
  32699. t := time.UnixMilli(timestamp)
  32700. // 格式化成指定的日期字符串
  32701. str := t.Format("2006-01-02 15:04:05")
  32702. res.Output.Setlinfo.SetlTime = str
  32703. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32704. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32705. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32706. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32707. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32708. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32709. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32710. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32711. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32712. //
  32713. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32714. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32715. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32716. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32717. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32718. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32719. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32720. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32721. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32722. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32723. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32724. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32725. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32726. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32727. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32728. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32729. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32730. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32731. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32732. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32733. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32734. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32735. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32736. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32737. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32738. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32739. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32740. //res.Output.Setldetail = ahres.Output.Setldetail
  32741. res.ErrMsg = ahres.ErrMsg
  32742. res.Cainfo = ahres.Cainfo
  32743. res.WarnMsg = ahres.WarnMsg
  32744. res.Infcode = ahres.Infcode
  32745. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32746. var api3 string
  32747. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  32748. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32749. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32750. resp3, requestErr3 := http.Get(api3)
  32751. if requestErr3 != nil {
  32752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32753. return
  32754. }
  32755. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32756. if ioErr3 != nil {
  32757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32759. return
  32760. }
  32761. var respJSON3 map[string]interface{}
  32762. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32765. return
  32766. }
  32767. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32768. if status == "0" {
  32769. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32770. c.ServeSuccessJSON(map[string]interface{}{
  32771. "failed_code": -10,
  32772. "msg": err_msg,
  32773. })
  32774. return
  32775. }
  32776. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32777. userJSONBytes3, _ := json.Marshal(respJSON3)
  32778. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32779. // utils.ErrorLog("解析失败:%v", err)
  32780. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32781. // return
  32782. //}
  32783. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  32784. utils.ErrorLog("解析失败:%v", err)
  32785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32786. return
  32787. }
  32788. res.InfRefmsgid = ahres.InfRefmsgid
  32789. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32790. // 创建对应的Time类型
  32791. t := time.UnixMilli(timestamp)
  32792. // 格式化成指定的日期字符串
  32793. str := t.Format("2006-01-02 15:04:05")
  32794. res.Output.Setlinfo.SetlTime = str
  32795. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32796. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32797. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32798. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32799. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32800. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32801. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32802. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32803. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32804. //
  32805. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32806. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32807. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32808. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32809. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32810. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32811. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32812. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32813. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32814. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32815. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32816. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32817. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32818. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32819. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32820. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32821. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32822. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32823. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32824. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32825. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32826. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32827. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32828. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32829. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32830. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32831. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32832. //res.Output.Setldetail = ahres.Output.Setldetail
  32833. res.ErrMsg = ahres.ErrMsg
  32834. res.Cainfo = ahres.Cainfo
  32835. res.WarnMsg = ahres.WarnMsg
  32836. res.Infcode = ahres.Infcode
  32837. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32838. 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, "")
  32839. var dat map[string]interface{}
  32840. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32841. fmt.Println(dat)
  32842. } else {
  32843. fmt.Println(err)
  32844. }
  32845. saveLog(result, src_resquest, "2208", "退费")
  32846. userJSONBytes, _ := json.Marshal(dat)
  32847. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32848. utils.ErrorLog("解析失败:%v", err)
  32849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32850. return
  32851. }
  32852. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32853. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  32854. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32855. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32856. resp3, requestErr3 := http.Get(api3)
  32857. if requestErr3 != nil {
  32858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32859. return
  32860. }
  32861. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32862. if ioErr3 != nil {
  32863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32865. return
  32866. }
  32867. var respJSON3 map[string]interface{}
  32868. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32871. return
  32872. }
  32873. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32874. userJSONBytes3, _ := json.Marshal(respJSON3)
  32875. fmt.Println("log")
  32876. fmt.Println(string(userJSONBytes3))
  32877. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32878. utils.ErrorLog("解析失败:%v", err)
  32879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32880. return
  32881. }
  32882. } else {
  32883. if miConfig.Code == "H15049901371" {
  32884. 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)
  32885. var dat map[string]interface{}
  32886. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32887. fmt.Println(dat)
  32888. } else {
  32889. fmt.Println(err)
  32890. }
  32891. saveLog(result, src_resquest, "2208", "退费")
  32892. if strings.Contains(result, "Post") {
  32893. res.Infcode = -1
  32894. res.ErrMsg = result
  32895. }
  32896. userJSONBytes, _ := json.Marshal(dat)
  32897. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  32898. utils.ErrorLog("解析失败:%v", err)
  32899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32900. return
  32901. }
  32902. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  32903. res.Output = resSixteen10265.Output
  32904. res.ErrMsg = resSixteen10265.ErrMsg
  32905. res.Cainfo = resSixteen10265.Cainfo
  32906. res.WarnMsg = resSixteen10265.WarnMsg
  32907. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  32908. res.Infcode = infocode
  32909. } else {
  32910. 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)
  32911. var dat map[string]interface{}
  32912. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32913. fmt.Println(dat)
  32914. } else {
  32915. fmt.Println(err)
  32916. }
  32917. saveLog(result, src_resquest, "2208", "退费")
  32918. userJSONBytes, _ := json.Marshal(dat)
  32919. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32920. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  32921. utils.ErrorLog("解析失败:%v", err)
  32922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32923. return
  32924. }
  32925. res.Infcode = gz.Infcode
  32926. } else {
  32927. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32928. utils.ErrorLog("解析失败:%v", err)
  32929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32930. return
  32931. }
  32932. }
  32933. if strings.Contains(result, "Post") {
  32934. res.Infcode = -1
  32935. res.ErrMsg = result
  32936. }
  32937. }
  32938. }
  32939. if res.Infcode == -1 {
  32940. c.ServeSuccessJSON(map[string]interface{}{
  32941. "failed_code": -10,
  32942. "msg": res.ErrMsg,
  32943. })
  32944. return
  32945. }
  32946. if res.Infcode != -1 {
  32947. var res2 ResultSix
  32948. var resSix10265 ResultSix10265
  32949. if miConfig.MdtrtareaAdmvs == "421300" {
  32950. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32951. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32952. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32953. resp3, requestErr3 := http.Get(api3)
  32954. if requestErr3 != nil {
  32955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32956. return
  32957. }
  32958. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32959. if ioErr3 != nil {
  32960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32962. return
  32963. }
  32964. var respJSON3 map[string]interface{}
  32965. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32968. return
  32969. }
  32970. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32971. userJSONBytes3, _ := json.Marshal(respJSON3)
  32972. fmt.Println("log")
  32973. fmt.Println(string(userJSONBytes3))
  32974. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32975. utils.ErrorLog("解析失败:%v", err)
  32976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32977. return
  32978. }
  32979. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32980. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32981. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32982. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32983. resp3, requestErr3 := http.Get(api3)
  32984. if requestErr3 != nil {
  32985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32986. return
  32987. }
  32988. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32989. if ioErr3 != nil {
  32990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32992. return
  32993. }
  32994. var respJSON3 map[string]interface{}
  32995. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32998. return
  32999. }
  33000. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33001. userJSONBytes3, _ := json.Marshal(respJSON3)
  33002. fmt.Println("log")
  33003. fmt.Println(string(userJSONBytes3))
  33004. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33005. utils.ErrorLog("解析失败:%v", err)
  33006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33007. return
  33008. }
  33009. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33010. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33011. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33012. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33013. resp3, requestErr3 := http.Get(api3)
  33014. if requestErr3 != nil {
  33015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33016. return
  33017. }
  33018. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33019. if ioErr3 != nil {
  33020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33022. return
  33023. }
  33024. var respJSON3 map[string]interface{}
  33025. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33028. return
  33029. }
  33030. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33031. userJSONBytes3, _ := json.Marshal(respJSON3)
  33032. fmt.Println("log")
  33033. fmt.Println(string(userJSONBytes3))
  33034. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33035. utils.ErrorLog("解析失败:%v", err)
  33036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33037. return
  33038. }
  33039. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33040. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33041. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33042. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33043. resp3, requestErr3 := http.Get(api3)
  33044. if requestErr3 != nil {
  33045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33046. return
  33047. }
  33048. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33049. if ioErr3 != nil {
  33050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33052. return
  33053. }
  33054. var respJSON3 map[string]interface{}
  33055. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33058. return
  33059. }
  33060. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33061. userJSONBytes3, _ := json.Marshal(respJSON3)
  33062. fmt.Println("log")
  33063. fmt.Println(string(userJSONBytes3))
  33064. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33065. utils.ErrorLog("解析失败:%v", err)
  33066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33067. return
  33068. }
  33069. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33070. var api3 string
  33071. if miConfig.MdtrtareaAdmvs == "320921" {
  33072. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33073. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33074. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33075. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33076. } else {
  33077. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33078. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33079. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33080. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33081. }
  33082. resp3, requestErr3 := http.Get(api3)
  33083. if requestErr3 != nil {
  33084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33085. return
  33086. }
  33087. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33088. if ioErr3 != nil {
  33089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33091. return
  33092. }
  33093. var respJSON3 map[string]interface{}
  33094. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33097. return
  33098. }
  33099. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33100. userJSONBytes3, _ := json.Marshal(respJSON3)
  33101. fmt.Println("log")
  33102. fmt.Println(string(userJSONBytes3))
  33103. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33104. utils.ErrorLog("解析失败:%v", err)
  33105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33106. return
  33107. }
  33108. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33109. res2.Output = resSix10265.Output
  33110. res2.ErrMsg = resSix10265.ErrMsg
  33111. res2.Cainfo = resSix10265.Cainfo
  33112. res2.WarnMsg = resSix10265.WarnMsg
  33113. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33114. res2.Infcode = infocode
  33115. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33116. var api3 string
  33117. new_chrg_bchno := order.Number
  33118. if adminUser.CurrentOrgId == 10265 {
  33119. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33120. new_chrg_bchno = "0000"
  33121. }
  33122. }
  33123. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33124. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33125. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33126. resp3, requestErr3 := http.Get(api3)
  33127. if requestErr3 != nil {
  33128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33129. return
  33130. }
  33131. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33132. if ioErr3 != nil {
  33133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33135. return
  33136. }
  33137. var respJSON3 map[string]interface{}
  33138. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33141. return
  33142. }
  33143. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33144. userJSONBytes3, _ := json.Marshal(respJSON3)
  33145. fmt.Println("log")
  33146. fmt.Println(string(userJSONBytes3))
  33147. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33148. utils.ErrorLog("解析失败:%v", err)
  33149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33150. return
  33151. }
  33152. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33153. res2.Output = resSix10265.Output
  33154. res2.ErrMsg = resSix10265.ErrMsg
  33155. res2.Cainfo = resSix10265.Cainfo
  33156. res2.WarnMsg = resSix10265.WarnMsg
  33157. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33158. res2.Infcode = infocode
  33159. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33160. 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)
  33161. var dat map[string]interface{}
  33162. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33163. fmt.Println(dat)
  33164. } else {
  33165. fmt.Println(err)
  33166. }
  33167. saveLog(result2, src_request, "2205", "撤销明细")
  33168. userJSONBytes, _ := json.Marshal(dat)
  33169. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33170. utils.ErrorLog("解析失败:%v", err)
  33171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33172. return
  33173. }
  33174. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33175. 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, "")
  33176. var dat map[string]interface{}
  33177. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33178. fmt.Println(dat)
  33179. } else {
  33180. fmt.Println(err)
  33181. }
  33182. saveLog(result2, src_request, "2205", "撤销明细")
  33183. userJSONBytes, _ := json.Marshal(dat)
  33184. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33185. utils.ErrorLog("解析失败:%v", err)
  33186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33187. return
  33188. }
  33189. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33190. 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, "")
  33191. var dat map[string]interface{}
  33192. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33193. fmt.Println(dat)
  33194. } else {
  33195. fmt.Println(err)
  33196. }
  33197. saveLog(result2, src_request, "2205", "撤销明细")
  33198. userJSONBytes, _ := json.Marshal(dat)
  33199. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33200. utils.ErrorLog("解析失败:%v", err)
  33201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33202. return
  33203. }
  33204. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33205. 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, "")
  33206. var dat map[string]interface{}
  33207. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33208. fmt.Println(dat)
  33209. } else {
  33210. fmt.Println(err)
  33211. }
  33212. saveLog(result2, src_request, "2205", "撤销明细")
  33213. userJSONBytes, _ := json.Marshal(dat)
  33214. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33215. utils.ErrorLog("解析失败:%v", err)
  33216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33217. return
  33218. }
  33219. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33220. var api3 string
  33221. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33222. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33223. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33224. resp3, requestErr3 := http.Get(api3)
  33225. if requestErr3 != nil {
  33226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33227. return
  33228. }
  33229. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33230. if ioErr3 != nil {
  33231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33233. return
  33234. }
  33235. var respJSON3 map[string]interface{}
  33236. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33239. return
  33240. }
  33241. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33242. if status == "0" {
  33243. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33244. c.ServeSuccessJSON(map[string]interface{}{
  33245. "failed_code": -10,
  33246. "msg": err_msg,
  33247. })
  33248. return
  33249. }
  33250. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33251. userJSONBytes3, _ := json.Marshal(respJSON3)
  33252. fmt.Println("log")
  33253. fmt.Println(string(userJSONBytes3))
  33254. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33255. utils.ErrorLog("解析失败:%v", err)
  33256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33257. return
  33258. }
  33259. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33260. 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, "")
  33261. var dat map[string]interface{}
  33262. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33263. fmt.Println(dat)
  33264. } else {
  33265. fmt.Println(err)
  33266. }
  33267. saveLog(result2, src_request, "2205", "撤销明细")
  33268. userJSONBytes, _ := json.Marshal(dat)
  33269. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33270. utils.ErrorLog("解析失败:%v", err)
  33271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33272. return
  33273. }
  33274. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33275. 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, "")
  33276. var dat map[string]interface{}
  33277. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33278. fmt.Println(dat)
  33279. } else {
  33280. fmt.Println(err)
  33281. }
  33282. saveLog(result2, src_request, "2205", "撤销明细")
  33283. userJSONBytes, _ := json.Marshal(dat)
  33284. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33285. utils.ErrorLog("解析失败:%v", err)
  33286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33287. return
  33288. }
  33289. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33290. 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, "")
  33291. var dat map[string]interface{}
  33292. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33293. fmt.Println(dat)
  33294. } else {
  33295. fmt.Println(err)
  33296. }
  33297. saveLog(result2, src_request, "2205", "撤销明细")
  33298. userJSONBytes, _ := json.Marshal(dat)
  33299. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33300. utils.ErrorLog("解析失败:%v", err)
  33301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33302. return
  33303. }
  33304. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33305. var api3 string
  33306. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33307. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33308. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33309. resp3, requestErr3 := http.Get(api3)
  33310. if requestErr3 != nil {
  33311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33312. return
  33313. }
  33314. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33315. if ioErr3 != nil {
  33316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33318. return
  33319. }
  33320. var respJSON3 map[string]interface{}
  33321. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33324. return
  33325. }
  33326. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33327. if status == "0" {
  33328. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33329. c.ServeSuccessJSON(map[string]interface{}{
  33330. "failed_code": -10,
  33331. "msg": err_msg,
  33332. })
  33333. return
  33334. }
  33335. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33336. userJSONBytes3, _ := json.Marshal(respJSON3)
  33337. fmt.Println("log")
  33338. fmt.Println(string(userJSONBytes3))
  33339. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33340. utils.ErrorLog("解析失败:%v", err)
  33341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33342. return
  33343. }
  33344. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33345. 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, "")
  33346. var dat map[string]interface{}
  33347. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33348. fmt.Println(dat)
  33349. } else {
  33350. fmt.Println(err)
  33351. }
  33352. saveLog(result2, src_request, "2205", "撤销明细")
  33353. userJSONBytes, _ := json.Marshal(dat)
  33354. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33355. utils.ErrorLog("解析失败:%v", err)
  33356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33357. return
  33358. }
  33359. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33360. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  33361. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33362. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33363. resp3, requestErr3 := http.Get(api3)
  33364. if requestErr3 != nil {
  33365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33366. return
  33367. }
  33368. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33369. if ioErr3 != nil {
  33370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33372. return
  33373. }
  33374. var respJSON3 map[string]interface{}
  33375. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33378. return
  33379. }
  33380. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33381. userJSONBytes3, _ := json.Marshal(respJSON3)
  33382. fmt.Println("log")
  33383. fmt.Println(string(userJSONBytes3))
  33384. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33385. utils.ErrorLog("解析失败:%v", err)
  33386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33387. return
  33388. }
  33389. } else {
  33390. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33391. res2.Infcode = 0
  33392. } else {
  33393. 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)
  33394. var dat map[string]interface{}
  33395. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33396. fmt.Println(dat)
  33397. } else {
  33398. fmt.Println(err)
  33399. }
  33400. saveLog(result2, src_request, "2205", "撤销明细")
  33401. userJSONBytes, _ := json.Marshal(dat)
  33402. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33403. utils.ErrorLog("解析失败:%v", err)
  33404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33405. return
  33406. }
  33407. }
  33408. }
  33409. if res2.Infcode == -1 {
  33410. c.ServeSuccessJSON(map[string]interface{}{
  33411. "failed_code": -10,
  33412. "msg": res2.ErrMsg,
  33413. })
  33414. return
  33415. }
  33416. if res2.Infcode == 0 {
  33417. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  33418. if err == nil {
  33419. //当押金不为零时产生退费记录
  33420. if order.Decimal != 0 {
  33421. tmp := strconv.FormatInt(order.ID, 10)
  33422. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  33423. if err != nil {
  33424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33425. return
  33426. }
  33427. }
  33428. c.ServeSuccessJSON(map[string]interface{}{
  33429. "msg": "退费成功",
  33430. })
  33431. } else {
  33432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33433. return
  33434. }
  33435. } else {
  33436. c.ServeSuccessJSON(map[string]interface{}{
  33437. "failed_code": -10,
  33438. "msg": res2.ErrMsg,
  33439. })
  33440. }
  33441. } else {
  33442. c.ServeSuccessJSON(map[string]interface{}{
  33443. "failed_code": -10,
  33444. "msg": res.ErrMsg,
  33445. })
  33446. }
  33447. }
  33448. }
  33449. func (c *HisApiController) RefundNumber() {
  33450. record_time := c.GetString("record_time")
  33451. //patient_id, _ := c.GetInt64("patient_id")
  33452. admin_user_id, _ := c.GetInt64("admin_user_id")
  33453. his_patient_id, _ := c.GetInt64("id")
  33454. timeLayout := "2006-01-02"
  33455. loc, _ := time.LoadLocation("Local")
  33456. adminUser := c.GetAdminUserInfo()
  33457. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33458. fmt.Println(err)
  33459. if err != nil {
  33460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33461. return
  33462. }
  33463. recordDateTime := theTime.Unix()
  33464. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33465. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  33466. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33467. //order, _ := service.GetHisOrderByID(order_id)
  33468. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33469. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33470. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33471. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  33472. if count > 0 {
  33473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  33474. return
  33475. }
  33476. if config.IsOpen == 1 { //对接了医保,走医保流程
  33477. var res2 ResultSix
  33478. var res3 GZResultSix
  33479. var resSix10265 ResultSix10265
  33480. if miConfig.MdtrtareaAdmvs == "421300" {
  33481. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33482. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33483. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33484. resp3, requestErr3 := http.Get(api3)
  33485. if requestErr3 != nil {
  33486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33487. return
  33488. }
  33489. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33490. if ioErr3 != nil {
  33491. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33493. return
  33494. }
  33495. var respJSON3 map[string]interface{}
  33496. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33499. return
  33500. }
  33501. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33502. userJSONBytes3, _ := json.Marshal(respJSON3)
  33503. fmt.Println("log")
  33504. fmt.Println(string(userJSONBytes3))
  33505. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33506. utils.ErrorLog("解析失败:%v", err)
  33507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33508. return
  33509. }
  33510. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33511. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33512. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33513. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33514. resp3, requestErr3 := http.Get(api3)
  33515. if requestErr3 != nil {
  33516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33517. return
  33518. }
  33519. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33520. if ioErr3 != nil {
  33521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33523. return
  33524. }
  33525. var respJSON3 map[string]interface{}
  33526. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33529. return
  33530. }
  33531. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33532. userJSONBytes3, _ := json.Marshal(respJSON3)
  33533. fmt.Println("log")
  33534. fmt.Println(string(userJSONBytes3))
  33535. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33536. utils.ErrorLog("解析失败:%v", err)
  33537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33538. return
  33539. }
  33540. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33541. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  33542. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33543. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33544. resp3, requestErr3 := http.Get(api3)
  33545. if requestErr3 != nil {
  33546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33547. return
  33548. }
  33549. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33550. if ioErr3 != nil {
  33551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33553. return
  33554. }
  33555. var respJSON3 map[string]interface{}
  33556. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33557. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33559. return
  33560. }
  33561. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33562. userJSONBytes3, _ := json.Marshal(respJSON3)
  33563. fmt.Println("log")
  33564. fmt.Println(string(userJSONBytes3))
  33565. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33566. utils.ErrorLog("解析失败:%v", err)
  33567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33568. return
  33569. }
  33570. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33571. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  33572. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33573. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33574. resp3, requestErr3 := http.Get(api3)
  33575. if requestErr3 != nil {
  33576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33577. return
  33578. }
  33579. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33580. if ioErr3 != nil {
  33581. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33583. return
  33584. }
  33585. var respJSON3 map[string]interface{}
  33586. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33589. return
  33590. }
  33591. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33592. userJSONBytes3, _ := json.Marshal(respJSON3)
  33593. fmt.Println("log")
  33594. fmt.Println(string(userJSONBytes3))
  33595. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33596. utils.ErrorLog("解析失败:%v", err)
  33597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33598. return
  33599. }
  33600. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33601. var api3 string
  33602. if miConfig.MdtrtareaAdmvs == "320921" {
  33603. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  33604. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33605. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33606. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33607. } else {
  33608. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33609. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  33610. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33611. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33612. }
  33613. resp3, requestErr3 := http.Get(api3)
  33614. if requestErr3 != nil {
  33615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33616. return
  33617. }
  33618. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33619. if ioErr3 != nil {
  33620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33622. return
  33623. }
  33624. var respJSON3 map[string]interface{}
  33625. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33628. return
  33629. }
  33630. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33631. userJSONBytes3, _ := json.Marshal(respJSON3)
  33632. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33633. utils.ErrorLog("解析失败:%v", err)
  33634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33635. return
  33636. }
  33637. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33638. res2.Output = resSix10265.Output
  33639. res2.ErrMsg = resSix10265.ErrMsg
  33640. res2.Cainfo = resSix10265.Cainfo
  33641. res2.WarnMsg = resSix10265.WarnMsg
  33642. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33643. res2.Infcode = infocode
  33644. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33645. var api3 string
  33646. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  33647. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33648. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33649. resp3, requestErr3 := http.Get(api3)
  33650. if requestErr3 != nil {
  33651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33652. return
  33653. }
  33654. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33655. if ioErr3 != nil {
  33656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33658. return
  33659. }
  33660. var respJSON3 map[string]interface{}
  33661. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33664. return
  33665. }
  33666. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33667. userJSONBytes3, _ := json.Marshal(respJSON3)
  33668. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33669. utils.ErrorLog("解析失败:%v", err)
  33670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33671. return
  33672. }
  33673. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33674. res2.Output = resSix10265.Output
  33675. res2.ErrMsg = resSix10265.ErrMsg
  33676. res2.Cainfo = resSix10265.Cainfo
  33677. res2.WarnMsg = resSix10265.WarnMsg
  33678. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33679. res2.Infcode = infocode
  33680. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33681. 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)
  33682. var dat map[string]interface{}
  33683. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33684. fmt.Println(dat)
  33685. } else {
  33686. fmt.Println(err)
  33687. }
  33688. saveLog(result, request, "2202", "退号")
  33689. userJSONBytes, _ := json.Marshal(dat)
  33690. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33691. utils.ErrorLog("解析失败:%v", err)
  33692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33693. return
  33694. }
  33695. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33696. 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, "")
  33697. var dat map[string]interface{}
  33698. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33699. fmt.Println(dat)
  33700. } else {
  33701. fmt.Println(err)
  33702. }
  33703. saveLog(result, request, "2202", "退号")
  33704. userJSONBytes, _ := json.Marshal(dat)
  33705. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33706. utils.ErrorLog("解析失败:%v", err)
  33707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33708. return
  33709. }
  33710. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33711. 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, "")
  33712. var dat map[string]interface{}
  33713. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33714. fmt.Println(dat)
  33715. } else {
  33716. fmt.Println(err)
  33717. }
  33718. saveLog(result, request, "2202", "退号")
  33719. userJSONBytes, _ := json.Marshal(dat)
  33720. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33721. utils.ErrorLog("解析失败:%v", err)
  33722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33723. return
  33724. }
  33725. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33726. 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, "")
  33727. var dat map[string]interface{}
  33728. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33729. fmt.Println(dat)
  33730. } else {
  33731. fmt.Println(err)
  33732. }
  33733. saveLog(result, request, "2202", "退号")
  33734. userJSONBytes, _ := json.Marshal(dat)
  33735. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33736. utils.ErrorLog("解析失败:%v", err)
  33737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33738. return
  33739. }
  33740. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33741. var api3 string
  33742. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  33743. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33744. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33745. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33746. resp3, requestErr3 := http.Get(api3)
  33747. if requestErr3 != nil {
  33748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33749. return
  33750. }
  33751. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33752. if ioErr3 != nil {
  33753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33755. return
  33756. }
  33757. var respJSON3 map[string]interface{}
  33758. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33761. return
  33762. }
  33763. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33764. if status == "0" {
  33765. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33766. c.ServeSuccessJSON(map[string]interface{}{
  33767. "failed_code": -10,
  33768. "msg": err_msg,
  33769. })
  33770. return
  33771. }
  33772. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33773. userJSONBytes3, _ := json.Marshal(respJSON3)
  33774. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33775. utils.ErrorLog("解析失败:%v", err)
  33776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33777. return
  33778. }
  33779. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  33780. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33781. var api3 string
  33782. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  33783. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33784. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33785. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33786. resp3, requestErr3 := http.Get(api3)
  33787. if requestErr3 != nil {
  33788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33789. return
  33790. }
  33791. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33792. if ioErr3 != nil {
  33793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33795. return
  33796. }
  33797. var respJSON3 map[string]interface{}
  33798. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33801. return
  33802. }
  33803. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33804. if status == "0" {
  33805. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33806. c.ServeSuccessJSON(map[string]interface{}{
  33807. "failed_code": -10,
  33808. "msg": err_msg,
  33809. })
  33810. return
  33811. }
  33812. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33813. userJSONBytes3, _ := json.Marshal(respJSON3)
  33814. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33815. utils.ErrorLog("解析失败:%v", err)
  33816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33817. return
  33818. }
  33819. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  33820. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33821. 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, "")
  33822. var dat map[string]interface{}
  33823. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33824. fmt.Println(dat)
  33825. } else {
  33826. fmt.Println(err)
  33827. }
  33828. saveLog(result, request, "2202", "退号")
  33829. userJSONBytes, _ := json.Marshal(dat)
  33830. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33831. utils.ErrorLog("解析失败:%v", err)
  33832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33833. return
  33834. }
  33835. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33836. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  33837. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33838. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33839. resp3, requestErr3 := http.Get(api3)
  33840. if requestErr3 != nil {
  33841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33842. return
  33843. }
  33844. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33845. if ioErr3 != nil {
  33846. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33848. return
  33849. }
  33850. var respJSON3 map[string]interface{}
  33851. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33854. return
  33855. }
  33856. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33857. userJSONBytes3, _ := json.Marshal(respJSON3)
  33858. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33859. utils.ErrorLog("解析失败:%v", err)
  33860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33861. return
  33862. }
  33863. } else {
  33864. var api3 string
  33865. if miConfig.Code == "H15049901371" {
  33866. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  33867. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33868. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33869. } else {
  33870. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  33871. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33872. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33873. }
  33874. resp3, requestErr3 := http.Get(api3)
  33875. if requestErr3 != nil {
  33876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33877. return
  33878. }
  33879. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33880. if ioErr3 != nil {
  33881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33883. return
  33884. }
  33885. var respJSON3 map[string]interface{}
  33886. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33889. return
  33890. }
  33891. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33892. userJSONBytes3, _ := json.Marshal(respJSON3)
  33893. if miConfig.Code == "H15049901371" {
  33894. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33895. utils.ErrorLog("解析失败:%v", err)
  33896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33897. return
  33898. }
  33899. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33900. res2.Output = resSix10265.Output
  33901. res2.ErrMsg = resSix10265.ErrMsg
  33902. res2.Cainfo = resSix10265.Cainfo
  33903. res2.WarnMsg = resSix10265.WarnMsg
  33904. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33905. res2.Infcode = infocode
  33906. } else {
  33907. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33908. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  33909. utils.ErrorLog("解析失败:%v", err)
  33910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33911. return
  33912. }
  33913. res2.Infcode = res3.Infcode
  33914. } else {
  33915. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33916. utils.ErrorLog("解析失败:%v", err)
  33917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33918. return
  33919. }
  33920. }
  33921. }
  33922. }
  33923. if res2.Infcode == -1 {
  33924. c.ServeSuccessJSON(map[string]interface{}{
  33925. "failed_code": -10,
  33926. "msg": res2.ErrMsg,
  33927. })
  33928. return
  33929. }
  33930. if res2.Infcode == 0 {
  33931. if err == nil {
  33932. c.ServeSuccessJSON(map[string]interface{}{
  33933. "msg": "退号成功",
  33934. })
  33935. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  33936. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  33937. } else {
  33938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33939. return
  33940. }
  33941. }
  33942. } else {
  33943. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  33944. //if err == nil {
  33945. // c.ServeSuccessJSON(map[string]interface{}{
  33946. // "msg": "退费成功",
  33947. // })
  33948. //} else {
  33949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33950. // return
  33951. //}
  33952. }
  33953. }
  33954. func (c *HisApiController) RefundDetail() {
  33955. order_id, _ := c.GetInt64("order_id")
  33956. admin_user_id, _ := c.GetInt64("admin_user_id")
  33957. //his_patient_id, _ := c.GetInt64("his_patient_id")
  33958. number := c.GetString("number")
  33959. record_time := c.GetString("record_time")
  33960. patient_id, _ := c.GetInt64("patient_id")
  33961. //med_type, _ := c.GetInt64("med_type")
  33962. timeLayout := "2006-01-02"
  33963. loc, _ := time.LoadLocation("Local")
  33964. adminUser := c.GetAdminUserInfo()
  33965. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33966. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33967. fmt.Println(err)
  33968. if err != nil {
  33969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33970. return
  33971. }
  33972. recordDateTime := theTime.Unix()
  33973. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  33974. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33975. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33976. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33977. var order models.HisOrder
  33978. order, _ = service.GetHisOrderByID(order_id)
  33979. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33980. if config.IsOpen == 1 { //对接了医保,走医保流程
  33981. var res2 ResultSix
  33982. if miConfig.MdtrtareaAdmvs == "421300" {
  33983. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33984. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33985. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33986. resp3, requestErr3 := http.Get(api3)
  33987. if requestErr3 != nil {
  33988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33989. return
  33990. }
  33991. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33992. if ioErr3 != nil {
  33993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33995. return
  33996. }
  33997. var respJSON3 map[string]interface{}
  33998. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34001. return
  34002. }
  34003. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34004. userJSONBytes3, _ := json.Marshal(respJSON3)
  34005. fmt.Println("log")
  34006. fmt.Println(string(userJSONBytes3))
  34007. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34008. utils.ErrorLog("解析失败:%v", err)
  34009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34010. return
  34011. }
  34012. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34013. if err == nil {
  34014. c.ServeSuccessJSON(map[string]interface{}{
  34015. "msg": "撤销明细成功",
  34016. })
  34017. return
  34018. } else {
  34019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34020. return
  34021. }
  34022. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34023. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34024. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34025. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34026. resp3, requestErr3 := http.Get(api3)
  34027. if requestErr3 != nil {
  34028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34029. return
  34030. }
  34031. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34032. if ioErr3 != nil {
  34033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34035. return
  34036. }
  34037. var respJSON3 map[string]interface{}
  34038. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34041. return
  34042. }
  34043. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34044. userJSONBytes3, _ := json.Marshal(respJSON3)
  34045. fmt.Println("log")
  34046. fmt.Println(string(userJSONBytes3))
  34047. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34048. utils.ErrorLog("解析失败:%v", err)
  34049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34050. return
  34051. }
  34052. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34053. if err == nil {
  34054. c.ServeSuccessJSON(map[string]interface{}{
  34055. "msg": "撤销明细成功",
  34056. })
  34057. return
  34058. } else {
  34059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34060. return
  34061. }
  34062. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34063. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34064. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34065. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34066. resp3, requestErr3 := http.Get(api3)
  34067. if requestErr3 != nil {
  34068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34069. return
  34070. }
  34071. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34072. if ioErr3 != nil {
  34073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34075. return
  34076. }
  34077. var respJSON3 map[string]interface{}
  34078. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34081. return
  34082. }
  34083. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34084. userJSONBytes3, _ := json.Marshal(respJSON3)
  34085. fmt.Println("log")
  34086. fmt.Println(string(userJSONBytes3))
  34087. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34088. utils.ErrorLog("解析失败:%v", err)
  34089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34090. return
  34091. }
  34092. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34093. if err == nil {
  34094. c.ServeSuccessJSON(map[string]interface{}{
  34095. "msg": "撤销明细成功",
  34096. })
  34097. return
  34098. } else {
  34099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34100. return
  34101. }
  34102. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34103. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34104. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34105. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34106. resp3, requestErr3 := http.Get(api3)
  34107. if requestErr3 != nil {
  34108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34109. return
  34110. }
  34111. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34112. if ioErr3 != nil {
  34113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34115. return
  34116. }
  34117. var respJSON3 map[string]interface{}
  34118. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34121. return
  34122. }
  34123. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34124. userJSONBytes3, _ := json.Marshal(respJSON3)
  34125. fmt.Println("log")
  34126. fmt.Println(string(userJSONBytes3))
  34127. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34128. utils.ErrorLog("解析失败:%v", err)
  34129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34130. return
  34131. }
  34132. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34133. if err == nil {
  34134. c.ServeSuccessJSON(map[string]interface{}{
  34135. "msg": "撤销明细成功",
  34136. })
  34137. return
  34138. } else {
  34139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34140. return
  34141. }
  34142. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34143. var resSix10265 ResultSix10265
  34144. var api3 string
  34145. if miConfig.MdtrtareaAdmvs == "320921" {
  34146. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34147. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34148. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34149. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34150. } else {
  34151. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34152. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34153. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34154. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34155. }
  34156. resp3, requestErr3 := http.Get(api3)
  34157. utils.ErrorLog("接口: %v", requestErr3)
  34158. if requestErr3 != nil {
  34159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34160. return
  34161. }
  34162. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34163. if ioErr3 != nil {
  34164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34166. return
  34167. }
  34168. var respJSON3 map[string]interface{}
  34169. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34172. return
  34173. }
  34174. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34175. userJSONBytes3, _ := json.Marshal(respJSON3)
  34176. fmt.Println("log")
  34177. fmt.Println(string(userJSONBytes3))
  34178. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34179. utils.ErrorLog("解析失败:%v", err)
  34180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34181. return
  34182. }
  34183. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34184. res2.Output = resSix10265.Output
  34185. res2.ErrMsg = resSix10265.ErrMsg
  34186. res2.Cainfo = resSix10265.Cainfo
  34187. res2.WarnMsg = resSix10265.WarnMsg
  34188. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34189. res2.Infcode = infocode
  34190. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34191. if err == nil {
  34192. c.ServeSuccessJSON(map[string]interface{}{
  34193. "msg": "撤销明细成功",
  34194. })
  34195. return
  34196. } else {
  34197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34198. return
  34199. }
  34200. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34201. var api3 string
  34202. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34203. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34204. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34205. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34206. resp3, requestErr3 := http.Get(api3)
  34207. utils.ErrorLog("接口: %v", requestErr3)
  34208. if requestErr3 != nil {
  34209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34210. return
  34211. }
  34212. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34213. if ioErr3 != nil {
  34214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34216. return
  34217. }
  34218. var respJSON3 map[string]interface{}
  34219. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34222. return
  34223. }
  34224. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34225. if status == "0" {
  34226. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34227. c.ServeSuccessJSON(map[string]interface{}{
  34228. "failed_code": -10,
  34229. "msg": err_msg,
  34230. })
  34231. return
  34232. }
  34233. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34234. userJSONBytes3, _ := json.Marshal(respJSON3)
  34235. fmt.Println("log")
  34236. fmt.Println(string(userJSONBytes3))
  34237. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34238. utils.ErrorLog("解析失败:%v", err)
  34239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34240. return
  34241. }
  34242. fmt.Println(res2.Infcode)
  34243. if res2.Infcode == -1 {
  34244. c.ServeSuccessJSON(map[string]interface{}{
  34245. "failed_code": -10,
  34246. "msg": res2.ErrMsg,
  34247. })
  34248. return
  34249. }
  34250. if res2.Infcode == 0 {
  34251. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34252. if err == nil {
  34253. c.ServeSuccessJSON(map[string]interface{}{
  34254. "msg": "撤销明细成功",
  34255. })
  34256. return
  34257. } else {
  34258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34259. return
  34260. }
  34261. } else {
  34262. c.ServeSuccessJSON(map[string]interface{}{
  34263. "failed_code": -10,
  34264. "msg": res2.ErrMsg,
  34265. })
  34266. }
  34267. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34268. if err == nil {
  34269. c.ServeSuccessJSON(map[string]interface{}{
  34270. "msg": "撤销明细成功",
  34271. })
  34272. return
  34273. } else {
  34274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34275. return
  34276. }
  34277. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34278. var api3 string
  34279. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34280. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34281. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34282. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34283. resp3, requestErr3 := http.Get(api3)
  34284. utils.ErrorLog("接口: %v", requestErr3)
  34285. if requestErr3 != nil {
  34286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34287. return
  34288. }
  34289. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34290. if ioErr3 != nil {
  34291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34293. return
  34294. }
  34295. var respJSON3 map[string]interface{}
  34296. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34299. return
  34300. }
  34301. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34302. if status == "0" {
  34303. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34304. c.ServeSuccessJSON(map[string]interface{}{
  34305. "failed_code": -10,
  34306. "msg": err_msg,
  34307. })
  34308. return
  34309. }
  34310. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34311. userJSONBytes3, _ := json.Marshal(respJSON3)
  34312. fmt.Println("log")
  34313. fmt.Println(string(userJSONBytes3))
  34314. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34315. utils.ErrorLog("解析失败:%v", err)
  34316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34317. return
  34318. }
  34319. fmt.Println(res2.Infcode)
  34320. if res2.Infcode == -1 {
  34321. c.ServeSuccessJSON(map[string]interface{}{
  34322. "failed_code": -10,
  34323. "msg": res2.ErrMsg,
  34324. })
  34325. return
  34326. }
  34327. if res2.Infcode == 0 {
  34328. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34329. if err == nil {
  34330. c.ServeSuccessJSON(map[string]interface{}{
  34331. "msg": "撤销明细成功",
  34332. })
  34333. return
  34334. } else {
  34335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34336. return
  34337. }
  34338. } else {
  34339. c.ServeSuccessJSON(map[string]interface{}{
  34340. "failed_code": -10,
  34341. "msg": res2.ErrMsg,
  34342. })
  34343. }
  34344. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34345. if err == nil {
  34346. c.ServeSuccessJSON(map[string]interface{}{
  34347. "msg": "撤销明细成功",
  34348. })
  34349. return
  34350. } else {
  34351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34352. return
  34353. }
  34354. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34355. var resSix10265 ResultSix10265
  34356. new_chrg_bchno := order.Number
  34357. if adminUser.CurrentOrgId == 10265 {
  34358. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  34359. new_chrg_bchno = "0000"
  34360. }
  34361. }
  34362. var api3 string
  34363. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  34364. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34365. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34366. resp3, requestErr3 := http.Get(api3)
  34367. if requestErr3 != nil {
  34368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34369. return
  34370. }
  34371. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34372. if ioErr3 != nil {
  34373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34375. return
  34376. }
  34377. var respJSON3 map[string]interface{}
  34378. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34381. return
  34382. }
  34383. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34384. userJSONBytes3, _ := json.Marshal(respJSON3)
  34385. fmt.Println("log")
  34386. fmt.Println(string(userJSONBytes3))
  34387. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34388. utils.ErrorLog("解析失败:%v", err)
  34389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34390. return
  34391. }
  34392. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34393. res2.Output = resSix10265.Output
  34394. res2.ErrMsg = resSix10265.ErrMsg
  34395. res2.Cainfo = resSix10265.Cainfo
  34396. res2.WarnMsg = resSix10265.WarnMsg
  34397. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34398. res2.Infcode = infocode
  34399. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34400. if err == nil {
  34401. c.ServeSuccessJSON(map[string]interface{}{
  34402. "msg": "撤销明细成功",
  34403. })
  34404. return
  34405. } else {
  34406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34407. return
  34408. }
  34409. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34410. 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)
  34411. var dat map[string]interface{}
  34412. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34413. fmt.Println(dat)
  34414. } else {
  34415. fmt.Println(err)
  34416. }
  34417. saveLog(result2, src_request, "2205", "撤销明细")
  34418. userJSONBytes, _ := json.Marshal(dat)
  34419. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34420. utils.ErrorLog("解析失败:%v", err)
  34421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34422. return
  34423. }
  34424. if res2.Infcode == 0 {
  34425. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34426. if err == nil {
  34427. c.ServeSuccessJSON(map[string]interface{}{
  34428. "msg": "撤销明细成功",
  34429. })
  34430. return
  34431. } else {
  34432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34433. return
  34434. }
  34435. } else {
  34436. c.ServeSuccessJSON(map[string]interface{}{
  34437. "failed_code": -10,
  34438. "msg": res2.ErrMsg,
  34439. })
  34440. }
  34441. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34442. 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, "")
  34443. var dat map[string]interface{}
  34444. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34445. fmt.Println(dat)
  34446. } else {
  34447. fmt.Println(err)
  34448. }
  34449. saveLog(result2, src_request, "2205", "撤销明细")
  34450. userJSONBytes, _ := json.Marshal(dat)
  34451. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34452. utils.ErrorLog("解析失败:%v", err)
  34453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34454. return
  34455. }
  34456. if res2.Infcode == 0 {
  34457. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34458. if err == nil {
  34459. c.ServeSuccessJSON(map[string]interface{}{
  34460. "msg": "撤销明细成功",
  34461. })
  34462. return
  34463. } else {
  34464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34465. return
  34466. }
  34467. } else {
  34468. c.ServeSuccessJSON(map[string]interface{}{
  34469. "failed_code": -10,
  34470. "msg": res2.ErrMsg,
  34471. })
  34472. }
  34473. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34474. 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, "")
  34475. var dat map[string]interface{}
  34476. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34477. fmt.Println(dat)
  34478. } else {
  34479. fmt.Println(err)
  34480. }
  34481. saveLog(result2, src_request, "2205", "撤销明细")
  34482. userJSONBytes, _ := json.Marshal(dat)
  34483. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34484. utils.ErrorLog("解析失败:%v", err)
  34485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34486. return
  34487. }
  34488. if res2.Infcode == 0 {
  34489. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34490. if err == nil {
  34491. c.ServeSuccessJSON(map[string]interface{}{
  34492. "msg": "撤销明细成功",
  34493. })
  34494. return
  34495. } else {
  34496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34497. return
  34498. }
  34499. } else {
  34500. c.ServeSuccessJSON(map[string]interface{}{
  34501. "failed_code": -10,
  34502. "msg": res2.ErrMsg,
  34503. })
  34504. }
  34505. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34506. 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, "")
  34507. var dat map[string]interface{}
  34508. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34509. fmt.Println(dat)
  34510. } else {
  34511. fmt.Println(err)
  34512. }
  34513. saveLog(result2, src_request, "2205", "撤销明细")
  34514. userJSONBytes, _ := json.Marshal(dat)
  34515. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34516. utils.ErrorLog("解析失败:%v", err)
  34517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34518. return
  34519. }
  34520. if res2.Infcode == 0 {
  34521. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34522. if err == nil {
  34523. c.ServeSuccessJSON(map[string]interface{}{
  34524. "msg": "撤销明细成功",
  34525. })
  34526. return
  34527. } else {
  34528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34529. return
  34530. }
  34531. } else {
  34532. c.ServeSuccessJSON(map[string]interface{}{
  34533. "failed_code": -10,
  34534. "msg": res2.ErrMsg,
  34535. })
  34536. }
  34537. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34538. 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, "")
  34539. var dat map[string]interface{}
  34540. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34541. fmt.Println(dat)
  34542. } else {
  34543. fmt.Println(err)
  34544. }
  34545. saveLog(result2, src_request, "2205", "撤销明细")
  34546. userJSONBytes, _ := json.Marshal(dat)
  34547. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34548. utils.ErrorLog("解析失败:%v", err)
  34549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34550. return
  34551. }
  34552. if res2.Infcode == 0 {
  34553. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34554. if err == nil {
  34555. c.ServeSuccessJSON(map[string]interface{}{
  34556. "msg": "撤销明细成功",
  34557. })
  34558. return
  34559. } else {
  34560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34561. return
  34562. }
  34563. } else {
  34564. c.ServeSuccessJSON(map[string]interface{}{
  34565. "failed_code": -10,
  34566. "msg": res2.ErrMsg,
  34567. })
  34568. }
  34569. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34570. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  34571. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34572. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34573. resp2, requestErr2 := http.Get(api2)
  34574. if requestErr2 != nil {
  34575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34576. return
  34577. }
  34578. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  34579. if ioErr2 != nil {
  34580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  34581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34582. return
  34583. }
  34584. var respJSON2 map[string]interface{}
  34585. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  34586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34588. return
  34589. }
  34590. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34591. userJSONBytes3, _ := json.Marshal(respJSON2)
  34592. fmt.Println("log")
  34593. fmt.Println(string(userJSONBytes3))
  34594. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34595. utils.ErrorLog("解析失败:%v", err)
  34596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34597. return
  34598. }
  34599. if res2.Infcode == 0 {
  34600. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34601. if err == nil {
  34602. c.ServeSuccessJSON(map[string]interface{}{
  34603. "msg": "撤销明细成功",
  34604. })
  34605. return
  34606. } else {
  34607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34608. return
  34609. }
  34610. } else {
  34611. c.ServeSuccessJSON(map[string]interface{}{
  34612. "failed_code": -10,
  34613. "msg": res2.ErrMsg,
  34614. })
  34615. }
  34616. } else {
  34617. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  34618. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34619. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34620. resp2, requestErr2 := http.Get(api2)
  34621. if requestErr2 != nil {
  34622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34623. return
  34624. }
  34625. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  34626. if ioErr2 != nil {
  34627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  34628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34629. return
  34630. }
  34631. var respJSON2 map[string]interface{}
  34632. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  34633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34635. return
  34636. }
  34637. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34638. userJSONBytes3, _ := json.Marshal(respJSON2)
  34639. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34640. utils.ErrorLog("解析失败:%v", err)
  34641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34642. return
  34643. }
  34644. if res2.Infcode == -1 {
  34645. c.ServeSuccessJSON(map[string]interface{}{
  34646. "failed_code": -10,
  34647. "msg": res2.ErrMsg,
  34648. })
  34649. return
  34650. } else {
  34651. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34652. if err == nil {
  34653. c.ServeSuccessJSON(map[string]interface{}{
  34654. "msg": "撤销明细成功",
  34655. })
  34656. return
  34657. } else {
  34658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34659. return
  34660. }
  34661. }
  34662. }
  34663. } else {
  34664. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34665. if err == nil {
  34666. c.ServeSuccessJSON(map[string]interface{}{
  34667. "msg": "退费成功",
  34668. })
  34669. } else {
  34670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34671. return
  34672. }
  34673. }
  34674. }
  34675. // 对账
  34676. func (c *HisApiController) GetCheckAccount() {
  34677. start_time := c.GetString("start_time")
  34678. end_time := c.GetString("end_time")
  34679. insutype := c.GetString("insutype")
  34680. clr_type := c.GetString("clr_type")
  34681. clr_org := c.GetString("clr_optins")
  34682. admin_user_id, _ := c.GetInt64("admin_user_id")
  34683. adminUser := c.GetAdminUserInfo()
  34684. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34685. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34686. if len(clr_org) == 0 {
  34687. clr_org = miConfig.InsuplcAdmdvs
  34688. }
  34689. timeLayout := "2006-01-02"
  34690. loc, _ := time.LoadLocation("Local")
  34691. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34692. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34693. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34694. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34695. fixmedins_setl_cnt := int64(len(orders))
  34696. var medfee_sumamt float64
  34697. var acct_pay float64
  34698. var fund_pay_sumamt float64
  34699. for _, item := range orders {
  34700. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34701. acct_pay = acct_pay + item.AcctPay
  34702. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  34703. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  34704. } else {
  34705. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34706. }
  34707. }
  34708. var user_name string
  34709. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34710. if role.ID == 0 {
  34711. user_name = "xxx"
  34712. } else {
  34713. user_name = role.UserName
  34714. }
  34715. var res ResultEight
  34716. var res10188 ResultEightFor10188
  34717. if config.IsOpen == 1 {
  34718. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34719. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  34720. "insutype=" + insutype +
  34721. "&clr_type=" + clr_type +
  34722. "&setl_optins=" + clr_org +
  34723. "&stmt_begndate=" + start_time +
  34724. "&stm_enddate=" + end_time +
  34725. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34726. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34727. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34728. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34729. "&fixmedins_code=" + miConfig.Code +
  34730. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34731. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34732. "&secret_key=" + miConfig.SecretKey +
  34733. "&org_name=" + miConfig.OrgName +
  34734. "&doctor=" + user_name +
  34735. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34736. fmt.Println(api)
  34737. resp, requestErr := http.Get(api)
  34738. if requestErr != nil {
  34739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34740. return
  34741. }
  34742. body, ioErr := ioutil.ReadAll(resp.Body)
  34743. fmt.Println(body)
  34744. if ioErr != nil {
  34745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34747. return
  34748. }
  34749. var respJSON map[string]interface{}
  34750. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34753. return
  34754. }
  34755. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34756. userJSONBytes, _ := json.Marshal(respJSON)
  34757. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34758. utils.ErrorLog("解析失败:%v", err)
  34759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34760. return
  34761. }
  34762. res.InfRefmsgid = res10188.InfRefmsgid
  34763. res.Output = res10188.Output
  34764. res.ErrMsg = res10188.ErrMsg
  34765. res.Cainfo = res10188.Cainfo
  34766. res.WarnMsg = res10188.WarnMsg
  34767. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  34768. res.Infcode = infocode
  34769. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34770. if clr_type != "9903" {
  34771. clr_type = "99" // 就诊 ID(来自2201接口返回)
  34772. }
  34773. if clr_type == "9903" {
  34774. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  34775. }
  34776. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  34777. "insutype=" + insutype +
  34778. "&clr_type=" + clr_type +
  34779. "&setl_optins=" + clr_org +
  34780. "&stmt_begndate=" + start_time +
  34781. "&stm_enddate=" + end_time +
  34782. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34783. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34784. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34785. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  34786. "&fixmedins_code=" + miConfig.Code +
  34787. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34788. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34789. "&secret_key=" + miConfig.SecretKey +
  34790. "&org_name=" + miConfig.OrgName +
  34791. "&doctor=" + user_name
  34792. resp, requestErr := http.Get(api)
  34793. if requestErr != nil {
  34794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34795. return
  34796. }
  34797. body, ioErr := ioutil.ReadAll(resp.Body)
  34798. if ioErr != nil {
  34799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34801. return
  34802. }
  34803. var respJSON map[string]interface{}
  34804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34807. return
  34808. }
  34809. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34810. result, _ := json.Marshal(respJSON)
  34811. fmt.Println("log")
  34812. fmt.Println(string(result))
  34813. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  34814. utils.ErrorLog("解析失败:%v", err)
  34815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34816. return
  34817. }
  34818. res.InfRefmsgid = res10188.InfRefmsgid
  34819. res.Output = res10188.Output
  34820. res.ErrMsg = res10188.ErrMsg
  34821. res.Cainfo = res10188.Cainfo
  34822. res.WarnMsg = res10188.WarnMsg
  34823. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  34824. res.Infcode = infocode
  34825. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34826. var baseParams models.BaseParams
  34827. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34828. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34829. baseParams.SecretKey = miConfig.SecretKey
  34830. baseParams.OrgName = miConfig.OrgName
  34831. baseParams.FixmedinsCode = miConfig.Code
  34832. baseParams.EncKey = miConfig.EncKey
  34833. baseParams.AppSecret = miConfig.AppSecret
  34834. baseParams.SignKey = miConfig.SignKey
  34835. baseParams.AppID = miConfig.Code
  34836. baseParams.Doctor = role.UserName
  34837. baseParams.RequestUrl = miConfig.Url
  34838. businessParams := models.BusinessParams{
  34839. Insutype: insutype,
  34840. ClrType: clr_type,
  34841. SetlOptins: clr_org,
  34842. StmtBegndate: start_time,
  34843. StmtEnddate: end_time,
  34844. MedfeeSumamt: medfee_sumamt,
  34845. FundPaySumamt: fund_pay_sumamt,
  34846. AcctPay: acct_pay,
  34847. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34848. }
  34849. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  34850. fmt.Println(requestLog)
  34851. fmt.Println(result)
  34852. fmt.Println(err_msg)
  34853. var dat map[string]interface{}
  34854. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34855. fmt.Println(dat)
  34856. } else {
  34857. fmt.Println(err)
  34858. }
  34859. userJSONBytes, _ := json.Marshal(dat)
  34860. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34861. utils.ErrorLog("解析失败:%v", err)
  34862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34863. return
  34864. }
  34865. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34866. var baseParams models.BaseParams
  34867. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34868. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34869. baseParams.SecretKey = miConfig.SecretKey
  34870. baseParams.OrgName = miConfig.OrgName
  34871. baseParams.FixmedinsCode = miConfig.Code
  34872. baseParams.EncKey = miConfig.EncKey
  34873. baseParams.AppSecret = miConfig.AppSecret
  34874. baseParams.SignKey = miConfig.SignKey
  34875. baseParams.AppID = miConfig.Code
  34876. baseParams.Doctor = role.UserName
  34877. baseParams.RequestUrl = miConfig.Url
  34878. baseParams.AccessKey = miConfig.AccessKey
  34879. businessParams := models.BusinessParams{
  34880. Insutype: insutype,
  34881. ClrType: clr_type,
  34882. SetlOptins: "430822",
  34883. StmtBegndate: start_time,
  34884. StmtEnddate: end_time,
  34885. MedfeeSumamt: medfee_sumamt,
  34886. FundPaySumamt: fund_pay_sumamt,
  34887. AcctPay: acct_pay,
  34888. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34889. }
  34890. 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)
  34891. fmt.Println(requestLog)
  34892. fmt.Println(result)
  34893. var dat map[string]interface{}
  34894. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34895. fmt.Println(dat)
  34896. } else {
  34897. fmt.Println(err)
  34898. }
  34899. userJSONBytes, _ := json.Marshal(dat)
  34900. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34901. utils.ErrorLog("解析失败:%v", err)
  34902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34903. return
  34904. }
  34905. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34906. var baseParams models.BaseParams
  34907. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  34908. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  34909. baseParams.SecretKey = miConfig.SecretKey
  34910. baseParams.OrgName = miConfig.OrgName
  34911. baseParams.FixmedinsCode = miConfig.Code
  34912. baseParams.EncKey = miConfig.EncKey
  34913. baseParams.AppSecret = miConfig.AppSecret
  34914. baseParams.SignKey = miConfig.SignKey
  34915. baseParams.AppID = miConfig.Code
  34916. baseParams.Doctor = role.UserName
  34917. baseParams.RequestUrl = miConfig.Url
  34918. businessParams := models.BusinessParams{
  34919. Insutype: insutype,
  34920. ClrType: clr_type,
  34921. SetlOptins: clr_org,
  34922. StmtBegndate: start_time,
  34923. StmtEnddate: end_time,
  34924. MedfeeSumamt: medfee_sumamt,
  34925. FundPaySumamt: fund_pay_sumamt,
  34926. AcctPay: acct_pay,
  34927. FixmedinsSetlCnt: fixmedins_setl_cnt,
  34928. }
  34929. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  34930. fmt.Println(requestLog)
  34931. fmt.Println(result)
  34932. fmt.Println(err_msg)
  34933. var dat map[string]interface{}
  34934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34935. fmt.Println(dat)
  34936. } else {
  34937. fmt.Println(err)
  34938. }
  34939. userJSONBytes, _ := json.Marshal(dat)
  34940. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34941. utils.ErrorLog("解析失败:%v", err)
  34942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34943. return
  34944. }
  34945. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34946. if len(clr_type) == 0 {
  34947. clr_type = "11"
  34948. }
  34949. api := miConfig.Url + "gdyb/ten?" +
  34950. "insutype=" + insutype +
  34951. "&clr_type=" + clr_type +
  34952. "&setl_optins=" + clr_org +
  34953. "&stmt_begndate=" + start_time +
  34954. "&stm_enddate=" + end_time +
  34955. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34956. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34957. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  34958. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34959. "&fixmedins_code=" + miConfig.Code +
  34960. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34961. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34962. "&secret_key=" + miConfig.SecretKey +
  34963. "&org_name=" + miConfig.OrgName +
  34964. "&doctor=" + user_name
  34965. fmt.Println(api)
  34966. resp, requestErr := http.Get(api)
  34967. if requestErr != nil {
  34968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34969. return
  34970. }
  34971. body, ioErr := ioutil.ReadAll(resp.Body)
  34972. fmt.Println(body)
  34973. if ioErr != nil {
  34974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34976. return
  34977. }
  34978. var respJSON map[string]interface{}
  34979. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34982. return
  34983. }
  34984. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34985. userJSONBytes, _ := json.Marshal(respJSON)
  34986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34987. utils.ErrorLog("解析失败:%v", err)
  34988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34989. return
  34990. }
  34991. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34992. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  34993. //fixmedins_setl_cnt := int64(len(orders_two))
  34994. //var medfee_sumamt float64
  34995. //var acct_pay float64
  34996. //var fund_pay_sumamt float64
  34997. //for _, item := range orders_two {
  34998. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34999. // acct_pay = acct_pay + item.AcctPay
  35000. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35001. //}
  35002. var baseParams models.BaseParams
  35003. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35004. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35005. baseParams.SecretKey = miConfig.SecretKey
  35006. baseParams.OrgName = miConfig.OrgName
  35007. baseParams.FixmedinsCode = miConfig.Code
  35008. baseParams.EncKey = miConfig.EncKey
  35009. baseParams.AppSecret = miConfig.AppSecret
  35010. baseParams.SignKey = miConfig.SignKey
  35011. baseParams.AppID = miConfig.Code
  35012. baseParams.Doctor = role.UserName
  35013. baseParams.RequestUrl = miConfig.Url
  35014. if clr_type == "9903" {
  35015. clr_type = "9901"
  35016. }
  35017. businessParams := models.BusinessParams{
  35018. Insutype: insutype,
  35019. ClrType: clr_type,
  35020. SetlOptins: "360302",
  35021. StmtBegndate: start_time,
  35022. StmtEnddate: end_time,
  35023. MedfeeSumamt: 0,
  35024. FundPaySumamt: 0,
  35025. AcctPay: 0,
  35026. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35027. }
  35028. 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))
  35029. fmt.Println(requestLog)
  35030. fmt.Println(result)
  35031. var dat map[string]interface{}
  35032. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35033. fmt.Println(dat)
  35034. } else {
  35035. fmt.Println(err)
  35036. }
  35037. userJSONBytes, _ := json.Marshal(dat)
  35038. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35039. utils.ErrorLog("解析失败:%v", err)
  35040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35041. return
  35042. }
  35043. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35044. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35045. //fixmedins_setl_cnt := int64(len(orders_two))
  35046. //var medfee_sumamt float64
  35047. //var acct_pay float64
  35048. //var fund_pay_sumamt float64
  35049. //for _, item := range orders_two {
  35050. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35051. // acct_pay = acct_pay + item.AcctPay
  35052. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35053. //}
  35054. var baseParams models.BaseParams
  35055. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35056. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35057. baseParams.SecretKey = miConfig.SecretKey
  35058. baseParams.OrgName = miConfig.OrgName
  35059. baseParams.FixmedinsCode = miConfig.Code
  35060. baseParams.EncKey = miConfig.EncKey
  35061. baseParams.AppSecret = miConfig.AppSecret
  35062. baseParams.SignKey = miConfig.SignKey
  35063. baseParams.AppID = miConfig.Code
  35064. baseParams.Doctor = role.UserName
  35065. baseParams.RequestUrl = miConfig.Url
  35066. if clr_type == "9903" {
  35067. clr_type = "9994"
  35068. }
  35069. businessParams := models.BusinessParams{
  35070. Insutype: insutype,
  35071. ClrType: clr_type,
  35072. SetlOptins: "361025",
  35073. StmtBegndate: start_time,
  35074. StmtEnddate: end_time,
  35075. MedfeeSumamt: 0,
  35076. FundPaySumamt: 0,
  35077. AcctPay: 0,
  35078. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35079. }
  35080. result, requestLog := service.Jxyb32012(businessParams.FixmedinsSetlCnt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, miConfig.AccessKey, miConfig.SecretKey, fmt.Sprintf("%.2f", medfee_sumamt), fmt.Sprintf("%.2f", fund_pay_sumamt), fmt.Sprintf("%.2f", acct_pay))
  35081. fmt.Println(requestLog)
  35082. fmt.Println(result)
  35083. var dat map[string]interface{}
  35084. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35085. fmt.Println(dat)
  35086. } else {
  35087. fmt.Println(err)
  35088. }
  35089. userJSONBytes, _ := json.Marshal(dat)
  35090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35091. utils.ErrorLog("解析失败:%v", err)
  35092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35093. return
  35094. }
  35095. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35096. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35097. //fixmedins_setl_cnt := int64(len(orders_two))
  35098. //var medfee_sumamt float64
  35099. //var acct_pay float64
  35100. //var fund_pay_sumamt float64
  35101. //for _, item := range orders_two {
  35102. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35103. // acct_pay = acct_pay + item.AcctPay
  35104. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35105. //}
  35106. var baseParams models.BaseParams
  35107. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35108. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35109. baseParams.SecretKey = miConfig.SecretKey
  35110. baseParams.OrgName = miConfig.OrgName
  35111. baseParams.FixmedinsCode = miConfig.Code
  35112. baseParams.EncKey = miConfig.EncKey
  35113. baseParams.AppSecret = miConfig.AppSecret
  35114. baseParams.SignKey = miConfig.SignKey
  35115. baseParams.AppID = miConfig.Code
  35116. baseParams.Doctor = role.UserName
  35117. baseParams.RequestUrl = miConfig.Url
  35118. if clr_type == "9903" {
  35119. clr_type = "9994"
  35120. }
  35121. businessParams := models.BusinessParams{
  35122. Insutype: insutype,
  35123. ClrType: clr_type,
  35124. SetlOptins: "360100",
  35125. StmtBegndate: start_time,
  35126. StmtEnddate: end_time,
  35127. MedfeeSumamt: 0,
  35128. FundPaySumamt: 0,
  35129. AcctPay: 0,
  35130. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35131. }
  35132. result, requestLog := service.Jxyb32012(businessParams.FixmedinsSetlCnt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, miConfig.AccessKey, miConfig.SecretKey, fmt.Sprintf("%.2f", medfee_sumamt), fmt.Sprintf("%.2f", fund_pay_sumamt), fmt.Sprintf("%.2f", acct_pay))
  35133. fmt.Println(requestLog)
  35134. fmt.Println(result)
  35135. var dat map[string]interface{}
  35136. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35137. fmt.Println(dat)
  35138. } else {
  35139. fmt.Println(err)
  35140. }
  35141. userJSONBytes, _ := json.Marshal(dat)
  35142. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35143. utils.ErrorLog("解析失败:%v", err)
  35144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35145. return
  35146. }
  35147. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35148. var api string
  35149. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35150. "&clr_type=" + clr_type +
  35151. "&setl_optins=" + clr_org +
  35152. "&stmt_begndate=" + start_time +
  35153. "&stm_enddate=" + end_time +
  35154. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35155. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35156. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35157. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35158. "&fixmedins_code=" + miConfig.Code +
  35159. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35160. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35161. "&secret_key=" + miConfig.SecretKey +
  35162. "&org_name=" + miConfig.OrgName +
  35163. "&doctor=" + user_name + "&url=" + miConfig.Url
  35164. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35165. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35166. resp, requestErr := http.Get(api)
  35167. if requestErr != nil {
  35168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35169. return
  35170. }
  35171. body, ioErr := ioutil.ReadAll(resp.Body)
  35172. if ioErr != nil {
  35173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35175. return
  35176. }
  35177. var respJSON map[string]interface{}
  35178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35181. return
  35182. }
  35183. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35184. if status == "0" {
  35185. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35186. c.ServeSuccessJSON(map[string]interface{}{
  35187. "failed_code": -10,
  35188. "msg": err_msg,
  35189. })
  35190. return
  35191. }
  35192. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35193. userJSONBytes, _ := json.Marshal(respJSON)
  35194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35195. utils.ErrorLog("解析失败:%v", err)
  35196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35197. return
  35198. }
  35199. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35200. var api string
  35201. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35202. "&clr_type=" + clr_type +
  35203. "&setl_optins=" + clr_org +
  35204. "&stmt_begndate=" + start_time +
  35205. "&stm_enddate=" + end_time +
  35206. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35207. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35208. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35209. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35210. "&fixmedins_code=" + miConfig.Code +
  35211. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35212. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35213. "&secret_key=" + miConfig.SecretKey +
  35214. "&org_name=" + miConfig.OrgName +
  35215. "&doctor=" + user_name + "&url=" + miConfig.Url
  35216. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35217. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35218. resp, requestErr := http.Get(api)
  35219. if requestErr != nil {
  35220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35221. return
  35222. }
  35223. body, ioErr := ioutil.ReadAll(resp.Body)
  35224. if ioErr != nil {
  35225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35227. return
  35228. }
  35229. var respJSON map[string]interface{}
  35230. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35233. return
  35234. }
  35235. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35236. if status == "0" {
  35237. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35238. c.ServeSuccessJSON(map[string]interface{}{
  35239. "failed_code": -10,
  35240. "msg": err_msg,
  35241. })
  35242. return
  35243. }
  35244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35245. userJSONBytes, _ := json.Marshal(respJSON)
  35246. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35247. utils.ErrorLog("解析失败:%v", err)
  35248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35249. return
  35250. }
  35251. } else {
  35252. if len(clr_type) == 0 {
  35253. clr_type = "11"
  35254. }
  35255. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35256. "insutype=" + insutype +
  35257. "&clr_type=" + clr_type +
  35258. "&setl_optins=" + clr_org +
  35259. "&stmt_begndate=" + start_time +
  35260. "&stm_enddate=" + end_time +
  35261. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35262. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35263. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35264. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35265. "&fixmedins_code=" + miConfig.Code +
  35266. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35267. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35268. "&secret_key=" + miConfig.SecretKey +
  35269. "&org_name=" + miConfig.OrgName +
  35270. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35271. fmt.Println(api)
  35272. resp, requestErr := http.Get(api)
  35273. if requestErr != nil {
  35274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35275. return
  35276. }
  35277. body, ioErr := ioutil.ReadAll(resp.Body)
  35278. fmt.Println(body)
  35279. if ioErr != nil {
  35280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35282. return
  35283. }
  35284. var respJSON map[string]interface{}
  35285. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35288. return
  35289. }
  35290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35291. userJSONBytes, _ := json.Marshal(respJSON)
  35292. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35293. utils.ErrorLog("解析失败:%v", err)
  35294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35295. return
  35296. }
  35297. }
  35298. if res.Infcode == 0 {
  35299. if res.Output.Stmtinfo.StmtRslt == "0" {
  35300. micc := &models.MedicalInsuranceCostCompare{
  35301. StartTime: startime.Unix(),
  35302. EndTime: endtime.Unix(),
  35303. Insutype: insutype,
  35304. CheckType: 1,
  35305. Num: fixmedins_setl_cnt,
  35306. Mtime: time.Now().Unix(),
  35307. Status: 1,
  35308. UserOrgId: adminUser.CurrentOrgId,
  35309. CostTotal: medfee_sumamt,
  35310. FuncTotal: fund_pay_sumamt,
  35311. PsnPay: acct_pay,
  35312. Creator: admin_user_id,
  35313. Ctime: time.Now().Unix(),
  35314. ClrType: clr_type,
  35315. }
  35316. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  35317. if err == nil {
  35318. c.ServeSuccessJSON(map[string]interface{}{
  35319. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35320. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35321. })
  35322. } else {
  35323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35324. }
  35325. } else {
  35326. c.ServeSuccessJSON(map[string]interface{}{
  35327. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35328. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35329. })
  35330. }
  35331. } else {
  35332. c.ServeSuccessJSON(map[string]interface{}{
  35333. "failed_code": -10,
  35334. "msg": res.ErrMsg,
  35335. })
  35336. }
  35337. }
  35338. }
  35339. func (c *HisApiController) Check310() {
  35340. adminUser := c.GetAdminUserInfo()
  35341. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35342. var user_name string
  35343. user_name = "高慧裕"
  35344. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35345. "insutype=" + "310" +
  35346. "&clr_type=" + "" +
  35347. "&setl_optins=" + "441202" +
  35348. "&stmt_begndate=" + "2022-03-01" +
  35349. "&stm_enddate=" + "2022-03-31" +
  35350. "&medfee_sumamt=" + "194930.12" +
  35351. "&fund_pay_sumamt=" + "188741.46" +
  35352. "&acct_pay=" + "0" +
  35353. "&fixmedins_setl_cnt=" + "452" +
  35354. "&fixmedins_code=" + miConfig.Code +
  35355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35356. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35357. "&secret_key=" + miConfig.SecretKey +
  35358. "&org_name=" + miConfig.OrgName +
  35359. "&doctor=" + user_name
  35360. fmt.Println(api)
  35361. resp, requestErr := http.Get(api)
  35362. if requestErr != nil {
  35363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35364. return
  35365. }
  35366. body, ioErr := ioutil.ReadAll(resp.Body)
  35367. fmt.Println(body)
  35368. if ioErr != nil {
  35369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35371. return
  35372. }
  35373. var respJSON map[string]interface{}
  35374. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35377. return
  35378. }
  35379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35380. userJSONBytes, _ := json.Marshal(respJSON)
  35381. var res ResultEight
  35382. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35383. utils.ErrorLog("解析失败:%v", err)
  35384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35385. return
  35386. }
  35387. }
  35388. func (c *HisApiController) Check390() {
  35389. adminUser := c.GetAdminUserInfo()
  35390. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35391. var user_name string
  35392. user_name = "高慧裕"
  35393. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35394. "insutype=" + "390" +
  35395. "&clr_type=" + "" +
  35396. "&setl_optins=" + "441202" +
  35397. "&stmt_begndate=" + "2022-03-01" +
  35398. "&stm_enddate=" + "2022-03-31" +
  35399. "&medfee_sumamt=" + "1068448.89" +
  35400. "&fund_pay_sumamt=" + "1014677.62" +
  35401. "&acct_pay=" + "0" +
  35402. "&fixmedins_setl_cnt=" + "1950" +
  35403. "&fixmedins_code=" + miConfig.Code +
  35404. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35405. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35406. "&secret_key=" + miConfig.SecretKey +
  35407. "&org_name=" + miConfig.OrgName +
  35408. "&doctor=" + user_name
  35409. fmt.Println(api)
  35410. resp, requestErr := http.Get(api)
  35411. if requestErr != nil {
  35412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35413. return
  35414. }
  35415. body, ioErr := ioutil.ReadAll(resp.Body)
  35416. fmt.Println(body)
  35417. if ioErr != nil {
  35418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35420. return
  35421. }
  35422. var respJSON map[string]interface{}
  35423. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35426. return
  35427. }
  35428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35429. userJSONBytes, _ := json.Marshal(respJSON)
  35430. var res ResultEight
  35431. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35432. utils.ErrorLog("解析失败:%v", err)
  35433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35434. return
  35435. }
  35436. }
  35437. // 对账明细
  35438. func (c *HisApiController) GetCheckDetailAccount() {
  35439. start_time := c.GetString("start_time")
  35440. end_time := c.GetString("end_time")
  35441. admin_user_id, _ := c.GetInt64("admin_user_id")
  35442. adminUser := c.GetAdminUserInfo()
  35443. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35444. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35445. timeLayout := "2006-01-02"
  35446. loc, _ := time.LoadLocation("Local")
  35447. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35448. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35449. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35450. rand.Seed(time.Now().UnixNano())
  35451. num := rand.Intn(30000)
  35452. Mkdir(miConfig.OrgName)
  35453. file := strconv.FormatInt(int64(num), 10)
  35454. file_name := file + ".txt"
  35455. zip_name := file + ".zip"
  35456. zip_path := miConfig.OrgName + "/" + zip_name
  35457. file_path := miConfig.OrgName + "/" + file_name
  35458. decimal.DivisionPrecision = 2
  35459. var medfee_sumamt float64
  35460. var psn_cash_pay float64
  35461. var fund_pay_sumamt float64
  35462. fixmedins_setl_cnt := int64(len(orders))
  35463. for _, item := range orders {
  35464. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35465. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  35466. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35467. }
  35468. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  35469. defer f.Close()
  35470. if err != nil {
  35471. fmt.Println(err.Error())
  35472. } else {
  35473. for _, item := range orders {
  35474. var refd_setl_flag string
  35475. if item.OrderStatus == 2 {
  35476. refd_setl_flag = "0"
  35477. var str string
  35478. str = item.SetlId + " " +
  35479. item.MdtrtId + " " +
  35480. item.PsnNo + " " +
  35481. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35482. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35483. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  35484. _, err = f.Write([]byte(str))
  35485. }
  35486. if item.OrderStatus == 3 {
  35487. var str string
  35488. str = item.SetlId + " " +
  35489. item.MdtrtId + " " +
  35490. item.PsnNo + " " +
  35491. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35492. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35493. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  35494. _, err = f.Write([]byte(str))
  35495. var str2 string
  35496. str2 = item.SetlId + " " +
  35497. item.MdtrtId + " " +
  35498. item.PsnNo + " " +
  35499. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  35500. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  35501. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  35502. _, err = f.Write([]byte(str2))
  35503. }
  35504. }
  35505. }
  35506. Zip(file_path, zip_path)
  35507. fmt.Println(ReadFile(zip_path))
  35508. fmt.Println(string(ReadFile(zip_path)))
  35509. if config.IsOpen == 1 {
  35510. var user_name string
  35511. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35512. if role.ID == 0 {
  35513. user_name = "管理员"
  35514. } else {
  35515. user_name = role.UserName
  35516. }
  35517. baseParams := models.BaseParams{
  35518. SecretKey: miConfig.SecretKey,
  35519. FixmedinsCode: miConfig.Code,
  35520. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35521. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35522. OrgName: miConfig.OrgName,
  35523. Doctor: user_name,
  35524. }
  35525. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  35526. var dat map[string]interface{}
  35527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35528. fmt.Println(dat)
  35529. } else {
  35530. fmt.Println(err)
  35531. }
  35532. userJSONBytes, _ := json.Marshal(dat)
  35533. var res ResultNine
  35534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35535. utils.ErrorLog("解析失败:%v", err)
  35536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35537. return
  35538. }
  35539. if res.Infcode == 0 {
  35540. fileNo := res.Output.FileQuryNo
  35541. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  35542. "file_qury_no=" + fileNo +
  35543. "&setl_optins=" + "定点医保中心" +
  35544. "&stmt_begndate=" + start_time +
  35545. "&stm_enddate=" + end_time +
  35546. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35547. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35548. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  35549. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35550. "&fixmedins_code=" + miConfig.Code +
  35551. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35552. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35553. "&secret_key=" + miConfig.SecretKey +
  35554. "&org_name=" + miConfig.OrgName +
  35555. "&doctor=" + user_name
  35556. resp, requestErr := http.Get(api)
  35557. if requestErr != nil {
  35558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35559. return
  35560. }
  35561. body, ioErr := ioutil.ReadAll(resp.Body)
  35562. if ioErr != nil {
  35563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35565. return
  35566. }
  35567. var respJSON map[string]interface{}
  35568. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35571. return
  35572. }
  35573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35574. userJSONBytes, _ := json.Marshal(respJSON)
  35575. var res ResultTen
  35576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35577. utils.ErrorLog("解析失败:%v", err)
  35578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35579. return
  35580. }
  35581. if res.Infcode == 0 {
  35582. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  35583. micc := &models.MedicalInsuranceCostCompare{
  35584. StartTime: startime.Unix(),
  35585. EndTime: endtime.Unix(),
  35586. Insutype: "0",
  35587. CheckType: 2,
  35588. Num: fixmedins_setl_cnt,
  35589. Mtime: time.Now().Unix(),
  35590. Status: 1,
  35591. UserOrgId: adminUser.CurrentOrgId,
  35592. CostTotal: medfee_sumamt,
  35593. FuncTotal: fund_pay_sumamt,
  35594. PsnPay: psn_cash_pay,
  35595. Creator: admin_user_id,
  35596. Ctime: time.Now().Unix(),
  35597. }
  35598. service.CreateMedicalInsuranceCostCompareRecord(micc)
  35599. c.ServeSuccessJSON(map[string]interface{}{
  35600. "msg": "明细对账成功",
  35601. })
  35602. }
  35603. } else {
  35604. }
  35605. }
  35606. }
  35607. type CustomOrderInfo struct {
  35608. Name string
  35609. Spec string
  35610. Unit string
  35611. Count float64
  35612. Price float64
  35613. Total float64
  35614. }
  35615. func (c *HisApiController) GetBatchSettleAccounts() {
  35616. admin_user_id, _ := c.GetInt64("admin_user_id")
  35617. order_ids := c.GetString("order_ids")
  35618. order_ids_arr := strings.Split(order_ids, ",")
  35619. data3 := []map[string]interface{}{}
  35620. for _, item := range order_ids_arr {
  35621. id, _ := strconv.ParseInt(item, 10, 64)
  35622. order_id := id
  35623. adminUser := c.GetAdminUserInfo()
  35624. order, _ := service.GetHisOrderByID(order_id)
  35625. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35626. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  35627. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  35628. orderInfos = append(orderInfos, orderInfos_two...)
  35629. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  35630. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  35631. var diagnosis_ids []string
  35632. if his.ID > 0 {
  35633. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  35634. } else {
  35635. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  35636. }
  35637. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  35638. var dia_config []*models.HisXtDiagnoseConfig
  35639. var name string
  35640. for _, item := range diagnosis_ids {
  35641. id, _ := strconv.ParseInt(item, 10, 64)
  35642. diagnosisConfig, _ := service.FindDiagnoseById(id)
  35643. dia_config = append(dia_config, &diagnosisConfig)
  35644. if len(name) == 0 {
  35645. name = diagnosisConfig.ClassName
  35646. }
  35647. //} else {
  35648. // name = name + "," + diagnosisConfig.ClassName
  35649. //}
  35650. }
  35651. var bedCostTotal float64 = 0 //床位总费
  35652. var bedCostSelfTotal float64 = 0 //床位自费
  35653. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  35654. var bedSelfTotal float64 = 0 //床位部分项目自费
  35655. var bedInscpTotal float64 = 0 //床位部分项目自费
  35656. var operationCostTotal float64 = 0 //手术费
  35657. var operationCostSelfTotal float64 = 0 //手术费
  35658. var operationCostPartSelfTotal float64 = 0 //手术费
  35659. var operationSelfTotal float64 = 0 //床位部分项目自费
  35660. var operationInscpTotal float64 = 0 //床位部分项目自费
  35661. var otherCostTotal float64 = 0 //其他费用
  35662. var otherCostSelfTotal float64 = 0 //其他费用
  35663. var otherCostPartSelfTotal float64 = 0 //其他费用
  35664. var otherSelfTotal float64 = 0 //床位部分项目自费
  35665. var otherInscpTotal float64 = 0 //床位部分项目自费
  35666. var materialCostTotal float64 = 0 //材料费
  35667. var materialCostSelfTotal float64 = 0 //材料费
  35668. var materialCostPartSelfTotal float64 = 0 //材料费
  35669. var materialSelfTotal float64 = 0 //床位部分项目自费
  35670. var materialInscpTotal float64 = 0 //床位部分项目自费
  35671. var westernMedicineCostTotal float64 = 0 //西药费
  35672. var westernMedicineCostSelfTotal float64 = 0 //西药费
  35673. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  35674. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  35675. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  35676. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  35677. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  35678. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  35679. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  35680. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  35681. var checkCostTotal float64 = 0 //检查费
  35682. var checkCostSelfTotal float64 = 0 //检查费
  35683. var checkCostPartSelfTotal float64 = 0 //检查费
  35684. var checkSelfTotal float64 = 0 //床位部分项目自费
  35685. var checkInscpTotal float64 = 0 //床位部分项目自费
  35686. var laboratoryCostTotal float64 = 0 //化验费
  35687. var laboratoryCostSelfTotal float64 = 0 //化验费
  35688. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  35689. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  35690. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  35691. var treatCostTotal float64 = 0 //治疗费用
  35692. var treatCostSelfTotal float64 = 0 //治疗费用
  35693. var treatCostPartSelfTotal float64 = 0 //治疗费用
  35694. var treatSelfTotal float64 = 0 //床位部分项目自费
  35695. var treatInscpTotal float64 = 0 //床位部分项目自费
  35696. decimal.DivisionPrecision = 2
  35697. for _, item := range orderInfos {
  35698. if item.MedChrgitmType == "01" { //床位费
  35699. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35700. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35701. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35702. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35703. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35704. }
  35705. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  35706. if item.MedChrgitmType == "03" { //检查费
  35707. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35708. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35709. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35710. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35711. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35712. }
  35713. } else {
  35714. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  35715. fmt.Println("------------")
  35716. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35717. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35718. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35719. }
  35720. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  35721. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35722. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35723. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35724. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35725. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35726. }
  35727. }
  35728. if item.MedChrgitmType == "04" { //化验费
  35729. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35730. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35731. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35732. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35733. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35734. }
  35735. if item.MedChrgitmType == "05" { //治疗费
  35736. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35737. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35738. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35739. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35740. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35741. }
  35742. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  35743. fmt.Println("------------")
  35744. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35745. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35746. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35747. }
  35748. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  35749. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35750. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35751. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35752. }
  35753. //if item.MedChrgitmType == "06" { //手术费
  35754. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35755. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35756. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35757. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35758. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35759. //
  35760. //}
  35761. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  35762. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35763. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35764. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35765. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35766. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35767. }
  35768. if item.MedChrgitmType == "09" { //西药费
  35769. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35770. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35771. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35772. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35773. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35774. }
  35775. if item.MedChrgitmType == "11" { //中成费
  35776. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35777. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35778. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35779. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35780. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35781. }
  35782. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  35783. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  35784. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  35785. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  35786. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  35787. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  35788. }
  35789. }
  35790. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35791. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35792. var user_name string
  35793. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35794. if role.ID == 0 {
  35795. user_name = "管理员"
  35796. } else {
  35797. user_name = role.UserName
  35798. }
  35799. baseParams := models.BaseParams{
  35800. SecretKey: miConfig.SecretKey,
  35801. FixmedinsCode: miConfig.Code,
  35802. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35803. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35804. OrgName: miConfig.OrgName,
  35805. Doctor: user_name,
  35806. RequestUrl: miConfig.Url,
  35807. AccessKey: miConfig.AccessKey,
  35808. }
  35809. businessParams := models.BusinessParams{
  35810. PsnNo: order.PsnNo,
  35811. MdtrtId: order.MdtrtId,
  35812. SetlId: order.SetlId,
  35813. }
  35814. var res ResultEleven
  35815. var resEleven10265 ResultEleven10265
  35816. if config.IsOpen == 1 {
  35817. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35818. result := service.Gdyb5203(baseParams, businessParams)
  35819. service.Gdyb5204(baseParams, businessParams)
  35820. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35821. var dat map[string]interface{}
  35822. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35823. fmt.Println(dat)
  35824. } else {
  35825. fmt.Println(err)
  35826. }
  35827. userJSONBytes, _ := json.Marshal(dat)
  35828. if miConfig.Code == "H15049901371" {
  35829. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35830. utils.ErrorLog("解析失败:%v", err)
  35831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35832. return
  35833. }
  35834. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35835. res.Output = resEleven10265.Output
  35836. res.ErrMsg = resEleven10265.ErrMsg
  35837. res.Cainfo = resEleven10265.Cainfo
  35838. res.WarnMsg = resEleven10265.WarnMsg
  35839. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35840. res.Infcode = infocode
  35841. } else {
  35842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35843. utils.ErrorLog("解析失败:%v", err)
  35844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35845. return
  35846. }
  35847. }
  35848. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35849. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35850. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35851. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35852. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35853. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35854. var doctor_name string
  35855. if roles.ID == 0 {
  35856. doctor_name = "管理员"
  35857. } else {
  35858. doctor_name = roles.UserName
  35859. }
  35860. yiliao_leibie := ""
  35861. switch order.MedType {
  35862. case "11":
  35863. yiliao_leibie = "普通门诊"
  35864. break
  35865. case "12":
  35866. yiliao_leibie = "门诊挂号"
  35867. break
  35868. case "13":
  35869. yiliao_leibie = "急诊"
  35870. break
  35871. case "14":
  35872. yiliao_leibie = "门诊特殊病"
  35873. break
  35874. case "15":
  35875. yiliao_leibie = "门诊统筹"
  35876. break
  35877. case "16":
  35878. yiliao_leibie = "门诊慢性病"
  35879. break
  35880. case "21":
  35881. yiliao_leibie = "普通住院"
  35882. break
  35883. }
  35884. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35885. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  35886. if res.Infcode == 0 {
  35887. data2 := map[string]interface{}{
  35888. "diagnosis": name,
  35889. "order_infos": orderInfos,
  35890. "number": order.MdtrtId,
  35891. "date": order.SettleAccountsDate,
  35892. "charge_admin": charge_admin,
  35893. "printor_admin": printor_admin,
  35894. "info": res.Output.Setlinfo,
  35895. "order": order,
  35896. "bedCostTotal": bedCostTotal,
  35897. "bedCostSelfTotal": bedCostSelfTotal,
  35898. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35899. "bedSelfTotal": bedSelfTotal,
  35900. "bedInscpTotal": bedInscpTotal,
  35901. "operationCostTotal": operationCostTotal,
  35902. "operationCostSelfTotal": operationCostSelfTotal,
  35903. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35904. "operationSelfTotal": operationSelfTotal,
  35905. "operationInscpTotal": operationInscpTotal,
  35906. "otherCostTotal": otherCostTotal,
  35907. "otherCostSelfTotal": otherCostSelfTotal,
  35908. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35909. "otherSelfTotal": otherSelfTotal,
  35910. "otherInscpTotal": otherInscpTotal,
  35911. "materialCostTotal": materialCostTotal,
  35912. "materialCostSelfTotal": materialCostSelfTotal,
  35913. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35914. "materialSelfTotal": materialSelfTotal,
  35915. "materialInscpTotal": materialInscpTotal,
  35916. "westernMedicineCostTotal": westernMedicineCostTotal,
  35917. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35918. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35919. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35920. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35921. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35922. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35923. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35924. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35925. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35926. "checkCostTotal": checkCostTotal,
  35927. "checkCostSelfTotal": checkCostSelfTotal,
  35928. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35929. "checkSelfTotal": checkSelfTotal,
  35930. "checkInscpTotal": checkInscpTotal,
  35931. "laboratoryCostTotal": laboratoryCostTotal,
  35932. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35933. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35934. "laboratorySelfTotal": laboratorySelfTotal,
  35935. "laboratoryInscpTotal": laboratoryInscpTotal,
  35936. "treatCostTotal": treatCostTotal,
  35937. "treatCostSelfTotal": treatCostSelfTotal,
  35938. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35939. "treatSelfTotal": treatSelfTotal,
  35940. "treatInscpTotal": treatInscpTotal,
  35941. "doctor_info": doctor_info,
  35942. "doctor_code": adminRole_two.DoctorCode,
  35943. "doctor_name": doctor_name,
  35944. "health_card_no": order.PsnNo,
  35945. "department": departments.Name,
  35946. "yiliao_leibie": yiliao_leibie,
  35947. "after_money": order.AccountPrice,
  35948. "patient": patient,
  35949. "org_name": miConfig.OrgName,
  35950. "org_code": miConfig.Code,
  35951. "order_number": order.Number,
  35952. "his_hospital": his_hospital,
  35953. "his": his,
  35954. "dia_config": dia_config,
  35955. "psn_cash_pay": order.PsnCashPay,
  35956. //"check_order_info": cus_slice,
  35957. }
  35958. data3 = append(data3, data2)
  35959. }
  35960. }
  35961. }
  35962. c.ServeSuccessJSON(map[string]interface{}{
  35963. "infos": data3,
  35964. })
  35965. }
  35966. func (c *HisApiController) GetSettleAccounts() {
  35967. //id, _ := c.GetInt64("id")
  35968. //record_time := c.GetString("record_time")
  35969. order_id, _ := c.GetInt64("order_id")
  35970. admin_user_id, _ := c.GetInt64("admin_user_id")
  35971. //timeLayout := "2006-01-02"
  35972. //loc, _ := time.LoadLocation("Local")
  35973. //
  35974. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35975. //if err != nil {
  35976. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35977. // return
  35978. //}Hbyb5203
  35979. //recordDateTime := theTime.Unix()
  35980. adminUser := c.GetAdminUserInfo()
  35981. order, _ := service.GetHisOrderByID(order_id)
  35982. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35983. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  35984. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  35985. orderInfos = append(orderInfos, orderInfos_two...)
  35986. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  35987. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  35988. var diagnosis_ids []string
  35989. if his.ID > 0 {
  35990. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  35991. } else {
  35992. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  35993. }
  35994. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  35995. var dia_config []*models.HisXtDiagnoseConfig
  35996. var name string
  35997. for _, item := range diagnosis_ids {
  35998. id, _ := strconv.ParseInt(item, 10, 64)
  35999. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36000. dia_config = append(dia_config, &diagnosisConfig)
  36001. if len(name) == 0 {
  36002. name = diagnosisConfig.ClassName
  36003. } else {
  36004. name = name + "," + diagnosisConfig.ClassName
  36005. }
  36006. }
  36007. if patient.UserOrgId == 10215 {
  36008. name = "慢性肾功能不全(血透治疗)"
  36009. }
  36010. var bedCostTotal float64 = 0 //床位总费
  36011. var bedCostSelfTotal float64 = 0 //床位自费
  36012. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36013. var bedSelfTotal float64 = 0 //床位部分项目自费
  36014. var bedInscpTotal float64 = 0 //床位部分项目自费
  36015. var operationCostTotal float64 = 0 //手术费
  36016. var operationCostSelfTotal float64 = 0 //手术费
  36017. var operationCostPartSelfTotal float64 = 0 //手术费
  36018. var operationSelfTotal float64 = 0 //床位部分项目自费
  36019. var operationInscpTotal float64 = 0 //床位部分项目自费
  36020. var otherCostTotal float64 = 0 //其他费用
  36021. var otherCostSelfTotal float64 = 0 //其他费用
  36022. var otherCostPartSelfTotal float64 = 0 //其他费用
  36023. var otherSelfTotal float64 = 0 //床位部分项目自费
  36024. var otherInscpTotal float64 = 0 //床位部分项目自费
  36025. var materialCostTotal float64 = 0 //材料费
  36026. var materialCostSelfTotal float64 = 0 //材料费
  36027. var materialCostPartSelfTotal float64 = 0 //材料费
  36028. var materialSelfTotal float64 = 0 //床位部分项目自费
  36029. var materialInscpTotal float64 = 0 //床位部分项目自费
  36030. var westernMedicineCostTotal float64 = 0 //西药费
  36031. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36032. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36033. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36034. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36035. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36036. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36037. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36038. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36039. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36040. var checkCostTotal float64 = 0 //检查费
  36041. var checkCostSelfTotal float64 = 0 //检查费
  36042. var checkCostPartSelfTotal float64 = 0 //检查费
  36043. var checkSelfTotal float64 = 0 //床位部分项目自费
  36044. var checkInscpTotal float64 = 0 //床位部分项目自费
  36045. var laboratoryCostTotal float64 = 0 //化验费
  36046. var laboratoryCostSelfTotal float64 = 0 //化验费
  36047. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36048. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36049. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36050. var treatCostTotal float64 = 0 //治疗费用
  36051. var treatCostSelfTotal float64 = 0 //治疗费用
  36052. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36053. var treatSelfTotal float64 = 0 //床位部分项目自费
  36054. var treatInscpTotal float64 = 0 //床位部分项目自费
  36055. var zcCostTotal float64 = 0 //治疗费用
  36056. var zcCostSelfTotal float64 = 0 //治疗费用
  36057. var zcCostPartSelfTotal float64 = 0 //治疗费用
  36058. var zcSelfTotal float64 = 0 //床位部分项目自费
  36059. var zcInscpTotal float64 = 0 //床位部分项目自费
  36060. var huliCostTotal float64 = 0 //治疗费用
  36061. var huliCostSelfTotal float64 = 0 //治疗费用
  36062. var huliCostPartSelfTotal float64 = 0 //治疗费用
  36063. var huliSelfTotal float64 = 0 //床位部分项目自费
  36064. var huliInscpTotal float64 = 0 //床位部分项目自费
  36065. decimal.DivisionPrecision = 2
  36066. for _, item := range orderInfos {
  36067. if item.MedChrgitmType == "01" { //床位费
  36068. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36069. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36070. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36071. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36072. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36073. }
  36074. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36075. if item.MedChrgitmType == "03" { //检查费
  36076. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36077. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36078. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36079. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36080. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36081. }
  36082. } else {
  36083. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36084. fmt.Println("------------")
  36085. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36086. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36087. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36088. }
  36089. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36090. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36091. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36092. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36093. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36094. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36095. }
  36096. }
  36097. if item.MedChrgitmType == "04" { //化验费
  36098. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36099. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36100. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36101. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36102. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36103. }
  36104. if item.MedChrgitmType == "05" { //治疗费
  36105. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36106. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36107. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36108. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36109. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36110. }
  36111. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36112. fmt.Println("------------")
  36113. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36114. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36115. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36116. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36117. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36118. }
  36119. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36120. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36121. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36122. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36123. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36124. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36125. }
  36126. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36127. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36128. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36129. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36130. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36131. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36132. }
  36133. if item.MedChrgitmType == "09" { //西药费
  36134. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36135. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36136. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36137. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36138. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36139. }
  36140. if item.MedChrgitmType == "11" { //中成费
  36141. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36142. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36143. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36144. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36145. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36146. }
  36147. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  36148. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36149. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36150. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36151. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36152. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36153. }
  36154. if item.MedChrgitmType == "02" { //其他费
  36155. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36156. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36157. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36158. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36159. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36160. }
  36161. if item.MedChrgitmType == "07" { //其他费
  36162. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36163. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36164. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36165. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36166. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36167. }
  36168. }
  36169. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36170. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36171. var user_name string
  36172. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36173. if role.ID == 0 {
  36174. user_name = "管理员"
  36175. } else {
  36176. user_name = role.UserName
  36177. }
  36178. baseParams := models.BaseParams{
  36179. SecretKey: miConfig.SecretKey,
  36180. FixmedinsCode: miConfig.Code,
  36181. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36182. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36183. OrgName: miConfig.OrgName,
  36184. Doctor: user_name,
  36185. RequestUrl: miConfig.Url,
  36186. AccessKey: miConfig.AccessKey,
  36187. }
  36188. businessParams := models.BusinessParams{
  36189. PsnNo: order.PsnNo,
  36190. MdtrtId: order.MdtrtId,
  36191. SetlId: order.SetlId,
  36192. }
  36193. var res ResultEleven
  36194. var resah ResultElevenah
  36195. var resEleven10265 ResultEleven10265
  36196. if config.IsOpen == 1 {
  36197. if miConfig.MdtrtareaAdmvs == "421300" {
  36198. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36199. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36200. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36201. resp, requestErr := http.Get(api)
  36202. if requestErr != nil {
  36203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36204. return
  36205. }
  36206. body, ioErr := ioutil.ReadAll(resp.Body)
  36207. if ioErr != nil {
  36208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36210. return
  36211. }
  36212. var respJSON map[string]interface{}
  36213. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36216. return
  36217. }
  36218. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36219. result, _ := json.Marshal(respJSON)
  36220. fmt.Println("log")
  36221. fmt.Println(string(result))
  36222. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36223. utils.ErrorLog("解析失败:%v", err)
  36224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36225. return
  36226. }
  36227. } else if miConfig.MdtrtareaAdmvs == "420200" {
  36228. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36229. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36230. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36231. resp, requestErr := http.Get(api)
  36232. if requestErr != nil {
  36233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36234. return
  36235. }
  36236. body, ioErr := ioutil.ReadAll(resp.Body)
  36237. if ioErr != nil {
  36238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36240. return
  36241. }
  36242. var respJSON map[string]interface{}
  36243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36246. return
  36247. }
  36248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36249. result, _ := json.Marshal(respJSON)
  36250. fmt.Println("log")
  36251. fmt.Println(string(result))
  36252. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36253. utils.ErrorLog("解析失败:%v", err)
  36254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36255. return
  36256. }
  36257. } else if miConfig.MdtrtareaAdmvs == "420902" {
  36258. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36259. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36260. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36261. resp, requestErr := http.Get(api)
  36262. if requestErr != nil {
  36263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36264. return
  36265. }
  36266. body, ioErr := ioutil.ReadAll(resp.Body)
  36267. if ioErr != nil {
  36268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36270. return
  36271. }
  36272. var respJSON map[string]interface{}
  36273. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36276. return
  36277. }
  36278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36279. result, _ := json.Marshal(respJSON)
  36280. fmt.Println("log")
  36281. fmt.Println(string(result))
  36282. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36283. utils.ErrorLog("解析失败:%v", err)
  36284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36285. return
  36286. }
  36287. } else if miConfig.MdtrtareaAdmvs == "421182" {
  36288. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36289. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36290. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  36291. resp, requestErr := http.Get(api)
  36292. if requestErr != nil {
  36293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36294. return
  36295. }
  36296. body, ioErr := ioutil.ReadAll(resp.Body)
  36297. if ioErr != nil {
  36298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36300. return
  36301. }
  36302. var respJSON map[string]interface{}
  36303. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36306. return
  36307. }
  36308. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36309. result, _ := json.Marshal(respJSON)
  36310. fmt.Println("log")
  36311. fmt.Println(string(result))
  36312. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36313. utils.ErrorLog("解析失败:%v", err)
  36314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36315. return
  36316. }
  36317. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36318. var api string
  36319. if miConfig.MdtrtareaAdmvs == "320921" {
  36320. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36321. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36322. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36323. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36324. } else {
  36325. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36326. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36327. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36328. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36329. }
  36330. resp, requestErr := http.Get(api)
  36331. if requestErr != nil {
  36332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36333. return
  36334. }
  36335. body, ioErr := ioutil.ReadAll(resp.Body)
  36336. if ioErr != nil {
  36337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36339. return
  36340. }
  36341. var respJSON map[string]interface{}
  36342. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36345. return
  36346. }
  36347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36348. result, _ := json.Marshal(respJSON)
  36349. fmt.Println("log")
  36350. fmt.Println(string(result))
  36351. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  36352. utils.ErrorLog("解析失败:%v", err)
  36353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36354. return
  36355. }
  36356. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36357. res.Output = resEleven10265.Output
  36358. res.ErrMsg = resEleven10265.ErrMsg
  36359. res.Cainfo = resEleven10265.Cainfo
  36360. res.WarnMsg = resEleven10265.WarnMsg
  36361. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36362. res.Infcode = infocode
  36363. } else if miConfig.MdtrtareaAdmvs == "350500" {
  36364. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  36365. saveLog(result, requestLog, "5203", "结算单")
  36366. var dat map[string]interface{}
  36367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36368. fmt.Println(dat)
  36369. } else {
  36370. fmt.Println(err)
  36371. }
  36372. userJSONBytes, _ := json.Marshal(dat)
  36373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36374. utils.ErrorLog("解析失败:%v", err)
  36375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36376. return
  36377. }
  36378. } else if miConfig.MdtrtareaAdmvs == "360302" {
  36379. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36380. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36381. saveLog(result, requestLog, "5203", "结算单")
  36382. var dat map[string]interface{}
  36383. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36384. fmt.Println(dat)
  36385. } else {
  36386. fmt.Println(err)
  36387. }
  36388. userJSONBytes, _ := json.Marshal(dat)
  36389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36390. utils.ErrorLog("解析失败:%v", err)
  36391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36392. return
  36393. }
  36394. } else if miConfig.MdtrtareaAdmvs == "361025" {
  36395. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36396. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36397. saveLog(result, requestLog, "5203", "结算单")
  36398. var dat map[string]interface{}
  36399. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36400. fmt.Println(dat)
  36401. } else {
  36402. fmt.Println(err)
  36403. }
  36404. userJSONBytes, _ := json.Marshal(dat)
  36405. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36406. utils.ErrorLog("解析失败:%v", err)
  36407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36408. return
  36409. }
  36410. } else if miConfig.MdtrtareaAdmvs == "360100" {
  36411. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36412. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36413. saveLog(result, requestLog, "5203", "结算单")
  36414. var dat map[string]interface{}
  36415. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36416. fmt.Println(dat)
  36417. } else {
  36418. fmt.Println(err)
  36419. }
  36420. userJSONBytes, _ := json.Marshal(dat)
  36421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36422. utils.ErrorLog("解析失败:%v", err)
  36423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36424. return
  36425. }
  36426. } else if miConfig.MdtrtareaAdmvs == "341203" {
  36427. var api string
  36428. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36429. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36430. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36431. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36432. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36433. resp, requestErr := http.Get(api)
  36434. if requestErr != nil {
  36435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36436. return
  36437. }
  36438. body, ioErr := ioutil.ReadAll(resp.Body)
  36439. if ioErr != nil {
  36440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36442. return
  36443. }
  36444. var respJSON map[string]interface{}
  36445. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36448. return
  36449. }
  36450. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36451. if status == "0" {
  36452. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36453. c.ServeSuccessJSON(map[string]interface{}{
  36454. "failed_code": -10,
  36455. "msg": err_msg,
  36456. })
  36457. return
  36458. }
  36459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36460. result, _ := json.Marshal(respJSON)
  36461. fmt.Println("log")
  36462. fmt.Println(string(result))
  36463. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  36464. utils.ErrorLog("解析失败:%v", err)
  36465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36466. return
  36467. }
  36468. res.InfRefmsgid = resah.InfRefmsgid
  36469. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36470. // 创建对应的Time类型
  36471. t := time.UnixMilli(timestamp)
  36472. // 格式化成指定的日期字符串
  36473. str := t.Format("2006-01-02 15:04:05")
  36474. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36475. // 创建对应的Time类型
  36476. t3 := time.UnixMilli(timestamp2)
  36477. // 格式化成指定的日期字符串
  36478. str2 := t3.Format("2006-01-02 15:04:05")
  36479. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  36480. // 创建对应的Time类型
  36481. t4 := time.UnixMilli(timestamp3)
  36482. // 格式化成指定的日期字符串
  36483. str3 := t4.Format("2006-01-02 15:04:05")
  36484. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  36485. // 创建对应的Time类型
  36486. t5 := time.UnixMilli(timestamp4)
  36487. // 格式化成指定的日期字符串
  36488. str5 := t5.Format("2006-01-02 15:04:05")
  36489. res.Output.Setlinfo.Brdy = str2
  36490. res.Output.Setlinfo.SetlTime = str
  36491. res.Output.Setlinfo.Begndate = str3
  36492. res.Output.Setlinfo.Enddate = str5
  36493. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  36494. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  36495. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  36496. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  36497. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36498. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36499. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  36500. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  36501. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36502. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  36503. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  36504. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  36505. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  36506. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  36507. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  36508. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  36509. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  36510. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  36511. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36512. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  36513. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  36514. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36515. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  36516. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  36517. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  36518. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  36519. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  36520. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  36521. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  36522. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  36523. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  36524. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  36525. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36526. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  36527. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  36528. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  36529. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  36530. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  36531. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  36532. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  36533. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  36534. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  36535. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  36536. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  36537. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  36538. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  36539. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  36540. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  36541. //res.Output.Setldetail = resah.Output.Setldetail
  36542. res.ErrMsg = resah.ErrMsg
  36543. res.Cainfo = resah.Cainfo
  36544. res.WarnMsg = resah.WarnMsg
  36545. } else if miConfig.MdtrtareaAdmvs == "340699" {
  36546. var api string
  36547. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36548. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36549. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36550. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36551. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36552. resp, requestErr := http.Get(api)
  36553. if requestErr != nil {
  36554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36555. return
  36556. }
  36557. body, ioErr := ioutil.ReadAll(resp.Body)
  36558. if ioErr != nil {
  36559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36561. return
  36562. }
  36563. var respJSON map[string]interface{}
  36564. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36567. return
  36568. }
  36569. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36570. if status == "0" {
  36571. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36572. c.ServeSuccessJSON(map[string]interface{}{
  36573. "failed_code": -10,
  36574. "msg": err_msg,
  36575. })
  36576. return
  36577. }
  36578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36579. result, _ := json.Marshal(respJSON)
  36580. fmt.Println("log")
  36581. fmt.Println(string(result))
  36582. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  36583. utils.ErrorLog("解析失败:%v", err)
  36584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36585. return
  36586. }
  36587. res.InfRefmsgid = resah.InfRefmsgid
  36588. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36589. // 创建对应的Time类型
  36590. t := time.UnixMilli(timestamp)
  36591. // 格式化成指定的日期字符串
  36592. str := t.Format("2006-01-02 15:04:05")
  36593. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36594. // 创建对应的Time类型
  36595. t3 := time.UnixMilli(timestamp2)
  36596. // 格式化成指定的日期字符串
  36597. str2 := t3.Format("2006-01-02 15:04:05")
  36598. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  36599. // 创建对应的Time类型
  36600. t4 := time.UnixMilli(timestamp3)
  36601. // 格式化成指定的日期字符串
  36602. str3 := t4.Format("2006-01-02 15:04:05")
  36603. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  36604. // 创建对应的Time类型
  36605. t5 := time.UnixMilli(timestamp4)
  36606. // 格式化成指定的日期字符串
  36607. str5 := t5.Format("2006-01-02 15:04:05")
  36608. res.Output.Setlinfo.Brdy = str2
  36609. res.Output.Setlinfo.SetlTime = str
  36610. res.Output.Setlinfo.Begndate = str3
  36611. res.Output.Setlinfo.Enddate = str5
  36612. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  36613. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  36614. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  36615. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  36616. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36617. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36618. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  36619. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  36620. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36621. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  36622. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  36623. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  36624. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  36625. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  36626. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  36627. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  36628. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  36629. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  36630. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36631. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  36632. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  36633. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36634. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  36635. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  36636. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  36637. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  36638. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  36639. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  36640. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  36641. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  36642. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  36643. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  36644. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36645. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  36646. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  36647. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  36648. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  36649. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  36650. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  36651. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  36652. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  36653. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  36654. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  36655. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  36656. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  36657. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  36658. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  36659. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  36660. //res.Output.Setldetail = resah.Output.Setldetail
  36661. res.ErrMsg = resah.ErrMsg
  36662. res.Cainfo = resah.Cainfo
  36663. res.WarnMsg = resah.WarnMsg
  36664. } else if miConfig.MdtrtareaAdmvs == "430800" {
  36665. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  36666. saveLog(result, requestLog, "5203", "结算单")
  36667. var dat map[string]interface{}
  36668. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36669. fmt.Println(dat)
  36670. } else {
  36671. fmt.Println(err)
  36672. }
  36673. userJSONBytes, _ := json.Marshal(dat)
  36674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36675. utils.ErrorLog("解析失败:%v", err)
  36676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36677. return
  36678. }
  36679. } else if miConfig.MdtrtareaAdmvs == "150499" {
  36680. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36681. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36682. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36683. resp, requestErr := http.Get(api)
  36684. if requestErr != nil {
  36685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36686. return
  36687. }
  36688. body, ioErr := ioutil.ReadAll(resp.Body)
  36689. if ioErr != nil {
  36690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36692. return
  36693. }
  36694. var respJSON map[string]interface{}
  36695. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36698. return
  36699. }
  36700. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36701. result, _ := json.Marshal(respJSON)
  36702. fmt.Println("log")
  36703. fmt.Println(string(result))
  36704. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  36705. utils.ErrorLog("解析失败:%v", err)
  36706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36707. return
  36708. }
  36709. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36710. res.Output = resEleven10265.Output
  36711. res.ErrMsg = resEleven10265.ErrMsg
  36712. res.Cainfo = resEleven10265.Cainfo
  36713. res.WarnMsg = resEleven10265.WarnMsg
  36714. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36715. res.Infcode = infocode
  36716. } else if miConfig.MdtrtareaAdmvs == "441799" {
  36717. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36718. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36719. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36720. resp, requestErr := http.Get(api)
  36721. if requestErr != nil {
  36722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36723. return
  36724. }
  36725. body, ioErr := ioutil.ReadAll(resp.Body)
  36726. if ioErr != nil {
  36727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36729. return
  36730. }
  36731. var respJSON map[string]interface{}
  36732. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36735. return
  36736. }
  36737. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36738. result, _ := json.Marshal(respJSON)
  36739. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36740. utils.ErrorLog("解析失败:%v", err)
  36741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36742. return
  36743. }
  36744. } else if miConfig.MdtrtareaAdmvs == "450721" {
  36745. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  36746. //return
  36747. } else {
  36748. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36749. if len(his.InsuplcAdmdvs) == 0 {
  36750. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  36751. } else {
  36752. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36753. }
  36754. result := service.Gdyb5203(baseParams, businessParams)
  36755. //service.Gdyb5204(baseParams, businessParams)
  36756. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36757. var dat map[string]interface{}
  36758. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36759. fmt.Println(dat)
  36760. } else {
  36761. fmt.Println(err)
  36762. }
  36763. userJSONBytes, _ := json.Marshal(dat)
  36764. if miConfig.Code == "H15049901371" {
  36765. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36766. utils.ErrorLog("解析失败:%v", err)
  36767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36768. return
  36769. }
  36770. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36771. res.Output = resEleven10265.Output
  36772. res.ErrMsg = resEleven10265.ErrMsg
  36773. res.Cainfo = resEleven10265.Cainfo
  36774. res.WarnMsg = resEleven10265.WarnMsg
  36775. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36776. res.Infcode = infocode
  36777. } else {
  36778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36779. utils.ErrorLog("解析失败:%v", err)
  36780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36781. return
  36782. }
  36783. }
  36784. }
  36785. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36786. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36787. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36788. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36789. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36790. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36791. var doctor_name string
  36792. if roles.ID == 0 {
  36793. doctor_name = "管理员"
  36794. } else {
  36795. doctor_name = roles.UserName
  36796. }
  36797. yiliao_leibie := ""
  36798. switch order.MedType {
  36799. case "11":
  36800. yiliao_leibie = "普通门诊"
  36801. break
  36802. case "12":
  36803. yiliao_leibie = "门诊挂号"
  36804. break
  36805. case "13":
  36806. yiliao_leibie = "急诊"
  36807. break
  36808. case "14":
  36809. yiliao_leibie = "门诊特殊病"
  36810. break
  36811. case "15":
  36812. yiliao_leibie = "门诊统筹"
  36813. break
  36814. case "16":
  36815. yiliao_leibie = "门诊慢性病"
  36816. break
  36817. case "21":
  36818. yiliao_leibie = "普通住院"
  36819. break
  36820. }
  36821. //var rf []CustomFundPay
  36822. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  36823. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36824. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  36825. if res.Infcode == 0 {
  36826. 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 || adminUser.CurrentOrgId == 10571 || adminUser.CurrentOrgId == 10752{
  36827. c.ServeSuccessJSON(map[string]interface{}{
  36828. "diagnosis": name,
  36829. "order_infos": orderInfos,
  36830. "number": order.MdtrtId,
  36831. "date": order.SettleAccountsDate,
  36832. "charge_admin": charge_admin,
  36833. "printor_admin": printor_admin,
  36834. "info": res.Output.Setlinfo,
  36835. "order": order,
  36836. "bedCostTotal": bedCostTotal,
  36837. "bedCostSelfTotal": bedCostSelfTotal,
  36838. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36839. "bedSelfTotal": bedSelfTotal,
  36840. "bedInscpTotal": bedInscpTotal,
  36841. "operationCostTotal": operationCostTotal,
  36842. "operationCostSelfTotal": operationCostSelfTotal,
  36843. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36844. "operationSelfTotal": operationSelfTotal,
  36845. "operationInscpTotal": operationInscpTotal,
  36846. "otherCostTotal": otherCostTotal,
  36847. "otherCostSelfTotal": otherCostSelfTotal,
  36848. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36849. "otherSelfTotal": otherSelfTotal,
  36850. "otherInscpTotal": otherInscpTotal,
  36851. "materialCostTotal": materialCostTotal,
  36852. "materialCostSelfTotal": materialCostSelfTotal,
  36853. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36854. "materialSelfTotal": materialSelfTotal,
  36855. "materialInscpTotal": materialInscpTotal,
  36856. "westernMedicineCostTotal": westernMedicineCostTotal,
  36857. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36858. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36859. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36860. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36861. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36862. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36863. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36864. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36865. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36866. "checkCostTotal": checkCostTotal,
  36867. "checkCostSelfTotal": checkCostSelfTotal,
  36868. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36869. "checkSelfTotal": checkSelfTotal,
  36870. "checkInscpTotal": checkInscpTotal,
  36871. "laboratoryCostTotal": laboratoryCostTotal,
  36872. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36873. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36874. "laboratorySelfTotal": laboratorySelfTotal,
  36875. "laboratoryInscpTotal": laboratoryInscpTotal,
  36876. "treatCostTotal": treatCostTotal,
  36877. "treatCostSelfTotal": treatCostSelfTotal,
  36878. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36879. "treatSelfTotal": treatSelfTotal,
  36880. "treatInscpTotal": treatInscpTotal,
  36881. "doctor_info": doctor_info,
  36882. "doctor_code": adminRole_two.DoctorCode,
  36883. "doctor_name": doctor_name,
  36884. "health_card_no": order.PsnNo,
  36885. "department": departments.Name,
  36886. "yiliao_leibie": yiliao_leibie,
  36887. "after_money": order.AccountPrice,
  36888. "patient": patient,
  36889. "org_name": miConfig.OrgName,
  36890. "org_code": miConfig.Code,
  36891. "order_number": order.Number,
  36892. "his_hospital": his_hospital,
  36893. "his": his,
  36894. "dia_config": dia_config,
  36895. "psn_cash_pay": order.PsnCashPay,
  36896. "zcCostTotal": zcCostTotal,
  36897. "zcCostSelfTotal": zcCostSelfTotal,
  36898. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  36899. "zcSelfTotal": zcSelfTotal,
  36900. "zcInscpTotal": zcInscpTotal,
  36901. "huliCostTotal": huliCostTotal,
  36902. "huliCostSelfTotal": huliCostSelfTotal,
  36903. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  36904. "huliSelfTotal": huliSelfTotal,
  36905. "huliInscpTotal": huliInscpTotal,
  36906. //"funds": rf,
  36907. //"check_order_info": cus_slice,
  36908. })
  36909. } else {
  36910. c.ServeSuccessJSON(map[string]interface{}{
  36911. "diagnosis": name,
  36912. "order_infos": orderInfos,
  36913. "number": order.MdtrtId,
  36914. "date": order.SettleAccountsDate,
  36915. "charge_admin": charge_admin,
  36916. "printor_admin": printor_admin,
  36917. "info": order,
  36918. "order": order,
  36919. "bedCostTotal": bedCostTotal,
  36920. "bedCostSelfTotal": bedCostSelfTotal,
  36921. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36922. "bedSelfTotal": bedSelfTotal,
  36923. "bedInscpTotal": bedInscpTotal,
  36924. "operationCostTotal": operationCostTotal,
  36925. "operationCostSelfTotal": operationCostSelfTotal,
  36926. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36927. "operationSelfTotal": operationSelfTotal,
  36928. "operationInscpTotal": operationInscpTotal,
  36929. "otherCostTotal": otherCostTotal,
  36930. "otherCostSelfTotal": otherCostSelfTotal,
  36931. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36932. "otherSelfTotal": otherSelfTotal,
  36933. "otherInscpTotal": otherInscpTotal,
  36934. "materialCostTotal": materialCostTotal,
  36935. "materialCostSelfTotal": materialCostSelfTotal,
  36936. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36937. "materialSelfTotal": materialSelfTotal,
  36938. "materialInscpTotal": materialInscpTotal,
  36939. "westernMedicineCostTotal": westernMedicineCostTotal,
  36940. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36941. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36942. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36943. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36944. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36945. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36946. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36947. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36948. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36949. "checkCostTotal": checkCostTotal,
  36950. "checkCostSelfTotal": checkCostSelfTotal,
  36951. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36952. "checkSelfTotal": checkSelfTotal,
  36953. "checkInscpTotal": checkInscpTotal,
  36954. "laboratoryCostTotal": laboratoryCostTotal,
  36955. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36956. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36957. "laboratorySelfTotal": laboratorySelfTotal,
  36958. "laboratoryInscpTotal": laboratoryInscpTotal,
  36959. "treatCostTotal": treatCostTotal,
  36960. "treatCostSelfTotal": treatCostSelfTotal,
  36961. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36962. "treatSelfTotal": treatSelfTotal,
  36963. "treatInscpTotal": treatInscpTotal,
  36964. "doctor_info": doctor_info,
  36965. "doctor_code": adminRole_two.DoctorCode,
  36966. "doctor_name": doctor_name,
  36967. "health_card_no": order.PsnNo,
  36968. "department": departments.Name,
  36969. "yiliao_leibie": yiliao_leibie,
  36970. "after_money": order.AccountPrice,
  36971. "patient": patient,
  36972. "org_name": miConfig.OrgName,
  36973. "org_code": miConfig.Code,
  36974. "order_number": order.Number,
  36975. "his_hospital": his_hospital,
  36976. "his": his,
  36977. "dia_config": dia_config,
  36978. "psn_cash_pay": order.PsnCashPay,
  36979. "zcCostTotal": zcCostTotal,
  36980. "zcCostSelfTotal": zcCostSelfTotal,
  36981. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  36982. "zcSelfTotal": zcSelfTotal,
  36983. "zcInscpTotal": zcInscpTotal,
  36984. "huliCostTotal": huliCostTotal,
  36985. "huliCostSelfTotal": huliCostSelfTotal,
  36986. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  36987. "huliSelfTotal": huliSelfTotal,
  36988. "huliInscpTotal": huliInscpTotal,
  36989. //"funds": rf,
  36990. //"check_order_info": cus_slice,
  36991. })
  36992. }
  36993. }
  36994. }
  36995. }
  36996. //func (c *HisApiController) CheckTreatment() {
  36997. // patient_id, _ := c.GetInt64("patient_id")
  36998. // id_card_no := c.GetString("id_card_no")
  36999. // insutype := c.GetString("insutype")
  37000. // med_type := c.GetString("med_type")
  37001. // admin_user_id, _ := c.GetInt64("admin_user_id")
  37002. //
  37003. // adminUser := c.GetAdminUserInfo()
  37004. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37005. //
  37006. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37007. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37008. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37009. //
  37010. // if miConfig.MdtrtareaAdmvs == "421300" {
  37011. // var res ResultTwo
  37012. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  37013. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37014. // "&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)
  37015. // resp, requestErr := http.Get(api)
  37016. // if requestErr != nil {
  37017. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37018. // return
  37019. // }
  37020. //
  37021. // body, ioErr := ioutil.ReadAll(resp.Body)
  37022. // if ioErr != nil {
  37023. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37024. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37025. // return
  37026. // }
  37027. // var respJSON map[string]interface{}
  37028. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37029. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37031. // return
  37032. // }
  37033. //
  37034. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37035. // result, _ := json.Marshal(respJSON)
  37036. //
  37037. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37038. // utils.ErrorLog("解析失败:%v", err)
  37039. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37040. // return
  37041. // }
  37042. //
  37043. // if res.Infcode == 0 {
  37044. //
  37045. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  37046. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37047. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  37048. // resp, requestErr := http.Get(api)
  37049. // if requestErr != nil {
  37050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37051. // return
  37052. // }
  37053. //
  37054. // body, ioErr := ioutil.ReadAll(resp.Body)
  37055. // if ioErr != nil {
  37056. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37057. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37058. // return
  37059. // }
  37060. // var respJSON map[string]interface{}
  37061. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37062. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37064. // return
  37065. // }
  37066. // var res Result2001
  37067. //
  37068. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37069. // result2, _ := json.Marshal(respJSON)
  37070. //
  37071. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  37072. // utils.ErrorLog("解析失败:%v", err)
  37073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37074. // return
  37075. // }
  37076. //
  37077. // if res.Infcode == 0 {
  37078. // c.ServeSuccessJSON(map[string]interface{}{
  37079. // "msg": res.Output.Trtinfo,
  37080. // })
  37081. // }
  37082. //
  37083. // } else {
  37084. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37085. // return
  37086. // }
  37087. //
  37088. // } else {
  37089. //
  37090. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37091. // var dat map[string]interface{}
  37092. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37093. // fmt.Println(dat)
  37094. // } else {
  37095. // fmt.Println(err)
  37096. // }
  37097. // userJSONBytes, _ := json.Marshal(dat)
  37098. // var res ResultTwo
  37099. // var res10265 ResultTwo10265
  37100. // if miConfig.Code == "H15049901371" {
  37101. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37102. // utils.ErrorLog("解析失败:%v", err)
  37103. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37104. // return
  37105. // }
  37106. // res.ErrMsg = res10265.ErrMsg
  37107. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37108. // res.Infcode = infocode
  37109. // res.Output = res10265.Output
  37110. // res.InfRefmsgid = res10265.InfRefmsgid
  37111. // } else {
  37112. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37113. // utils.ErrorLog("解析失败:%v", err)
  37114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37115. // return
  37116. // }
  37117. // }
  37118. //
  37119. // var user_name string
  37120. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  37121. // if role.ID == 0 {
  37122. // user_name = "xxx"
  37123. // } else {
  37124. // user_name = role.UserName
  37125. // }
  37126. //
  37127. // baseParams := models.BaseParams{
  37128. // SecretKey: miConfig.SecretKey,
  37129. // FixmedinsCode: miConfig.Code,
  37130. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37131. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37132. // OrgName: miConfig.OrgName,
  37133. // Doctor: user_name,
  37134. // }
  37135. //
  37136. // if config.IsOpen == 1 {
  37137. // if miConfig.Code == "H15049901371" {
  37138. // if med_type == "14" {
  37139. // if insutype == "390" {
  37140. // med_type = "9933"
  37141. // } else if insutype == "310" {
  37142. // med_type = "990502"
  37143. // }
  37144. // } else if med_type == "11" {
  37145. // med_type = "11"
  37146. // }
  37147. // }
  37148. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  37149. // var dat map[string]interface{}
  37150. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37151. // fmt.Println(dat)
  37152. // } else {
  37153. // fmt.Println(err)
  37154. // }
  37155. // var res Result2001
  37156. // var res10265 Result2001Org10265
  37157. // if miConfig.Code == "H15049901371" {
  37158. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37159. // utils.ErrorLog("解析失败:%v", err)
  37160. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37161. // return
  37162. // }
  37163. // res.ErrMsg = res10265.ErrMsg
  37164. // res.Output = res10265.Output
  37165. // res.InfRefmsgid = res10265.InfRefmsgid
  37166. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37167. // res.Infcode = infocode
  37168. // } else {
  37169. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37170. // utils.ErrorLog("解析失败:%v", err)
  37171. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37172. // return
  37173. // }
  37174. // }
  37175. // if res.Infcode == 0 {
  37176. // c.ServeSuccessJSON(map[string]interface{}{
  37177. // "msg": res.Output.Trtinfo,
  37178. // })
  37179. // }
  37180. // }
  37181. // }
  37182. //}
  37183. //func (c *HisApiController) PutRecord() {
  37184. // id, _ := c.GetInt64("id")
  37185. // record_time := c.GetString("record_time")
  37186. // timeLayout := "2006-01-02"
  37187. // loc, _ := time.LoadLocation("Local")
  37188. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37189. // if err != nil {
  37190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37191. // return
  37192. // }
  37193. // recordDateTime := theTime.Unix()
  37194. //
  37195. // adminInfo := c.GetAdminUserInfo()
  37196. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  37197. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37198. //
  37199. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37200. //
  37201. // fmt.Println(miConfig.SecretKey)
  37202. //
  37203. // if patient == nil {
  37204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37205. // return
  37206. // }
  37207. // if len(patient.IdCardNo) == 0 {
  37208. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  37209. // return
  37210. // }
  37211. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  37212. // if config.IsOpen == 1 {
  37213. // 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
  37214. // resp, requestErr := http.Get(api)
  37215. // if requestErr != nil {
  37216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37217. // return
  37218. // }
  37219. // defer resp.Body.Close()
  37220. // body, ioErr := ioutil.ReadAll(resp.Body)
  37221. // if ioErr != nil {
  37222. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37223. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37224. // return
  37225. // }
  37226. // var respJSON map[string]interface{}
  37227. //
  37228. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37229. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37230. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37231. // return
  37232. // }
  37233. //
  37234. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37235. // userJSONBytes, _ := json.Marshal(userJSON)
  37236. // var res ResultTwo
  37237. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37238. // utils.ErrorLog("解析失败:%v", err)
  37239. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37240. // return
  37241. // }
  37242. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37243. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37244. // infoStr := string(Iinfos)
  37245. // idetinfoStr := string(Idetinfos)
  37246. //
  37247. // if res.Infcode == 0 {
  37248. // his := models.VMHisPatient{
  37249. // Status: 1,
  37250. // Ctime: time.Now().Unix(),
  37251. // Mtime: time.Now().Unix(),
  37252. // PsnNo: res.Output.Baseinfo.PsnNo,
  37253. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  37254. // Certno: res.Output.Baseinfo.Certno,
  37255. // PsnName: res.Output.Baseinfo.PsnName,
  37256. // Gend: res.Output.Baseinfo.Gend,
  37257. // Naty: res.Output.Baseinfo.Naty,
  37258. // Brdy: res.Output.Baseinfo.Brdy,
  37259. // Age: res.Output.Baseinfo.Age,
  37260. // Iinfo: infoStr,
  37261. // Idetinfo: idetinfoStr,
  37262. // PatientId: patient.ID,
  37263. // RecordDate: theTime.Unix(),
  37264. // UserOrgId: adminInfo.CurrentOrgId,
  37265. // AdminUserId: adminInfo.AdminUser.Id,
  37266. // IsReturn: 1,
  37267. // }
  37268. //
  37269. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  37270. // //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")
  37271. // //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")
  37272. //
  37273. // //var dat map[string]interface{}
  37274. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37275. // // fmt.Println(dat)
  37276. // //} else {
  37277. // // fmt.Println(err)
  37278. // //}
  37279. //
  37280. // var dat2 map[string]interface{}
  37281. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37282. // fmt.Println(dat2)
  37283. // } else {
  37284. // fmt.Println(err)
  37285. // }
  37286. //
  37287. // } else {
  37288. // adminUser := c.GetAdminUserInfo()
  37289. // errlog := &models.HisOrderError{
  37290. // UserOrgId: adminUser.CurrentOrgId,
  37291. // Ctime: time.Now().Unix(),
  37292. // Mtime: time.Now().Unix(),
  37293. // ErrMsg: res.ErrMsg,
  37294. // Status: 1,
  37295. // PatientId: id,
  37296. // RecordTime: recordDateTime,
  37297. // Stage: 1,
  37298. // }
  37299. // service.CreateErrMsgLog(errlog)
  37300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  37301. // return
  37302. // }
  37303. // }
  37304. //
  37305. //}
  37306. //func (c *HisApiController) GetUploadDiag() {
  37307. // id, _ := c.GetInt64("id")
  37308. // record_time := c.GetString("record_time")
  37309. //
  37310. // diagnosis_id, _ := c.GetInt64("diagnosis")
  37311. // sick_type, _ := c.GetInt64("sick_type")
  37312. // reg_type, _ := c.GetInt64("reg_type")
  37313. //
  37314. // timeLayout := "2006-01-02"
  37315. // loc, _ := time.LoadLocation("Local")
  37316. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37317. // if err != nil {
  37318. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37319. // return
  37320. // }
  37321. //
  37322. // var patientPrescription models.HisPrescriptionInfo
  37323. // recordDateTime := theTime.Unix()
  37324. // adminInfo := c.GetAdminUserInfo()
  37325. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37326. //
  37327. // if patientPrescription.ID == 0 {
  37328. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37329. // }
  37330. //
  37331. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37332. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  37333. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37334. // sickConfig, _ := service.FindSickById(sick_type)
  37335. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37336. //
  37337. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  37338. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  37339. // "&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 +
  37340. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  37341. // resp2, requestErr2 := http.Get(api2)
  37342. // if requestErr2 != nil {
  37343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37344. // return
  37345. // }
  37346. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  37347. // if ioErr2 != nil {
  37348. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  37349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37350. // return
  37351. // }
  37352. // var respJSON2 map[string]interface{}
  37353. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  37354. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37356. // return
  37357. // }
  37358. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37359. // userJSONBytes2, _ := json.Marshal(respJSON2)
  37360. //
  37361. // var res2 ResultSix
  37362. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37363. // utils.ErrorLog("解析失败:%v", err)
  37364. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37365. // return
  37366. // }
  37367. // if res2.Infcode != 0 {
  37368. // adminUser := c.GetAdminUserInfo()
  37369. // errlog := &models.HisOrderError{
  37370. // UserOrgId: adminUser.CurrentOrgId,
  37371. // Ctime: time.Now().Unix(),
  37372. // Mtime: time.Now().Unix(),
  37373. // ErrMsg: res2.ErrMsg,
  37374. // Status: 1,
  37375. // PatientId: id,
  37376. // RecordTime: recordDateTime,
  37377. // Stage: 3,
  37378. // }
  37379. // service.CreateErrMsgLog(errlog)
  37380. //
  37381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  37382. // return
  37383. // }
  37384. //
  37385. // c.ServeSuccessJSON(map[string]interface{}{
  37386. // "msg": "上传成功",
  37387. // })
  37388. //
  37389. //}
  37390. type QueryResult struct {
  37391. ID int64
  37392. Name string
  37393. Code string
  37394. List_type_code string
  37395. }
  37396. func (c *HisApiController) GetCheckCode() {
  37397. ids_str := c.GetString("ids")
  37398. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  37399. ids_arr := strings.Split(ids_str, ",")
  37400. var queryResult []QueryResult
  37401. ids := make([]int64, 0)
  37402. for _, item := range ids_arr {
  37403. id, _ := strconv.ParseInt(item, 10, 64)
  37404. ids = append(ids, id)
  37405. }
  37406. if record_type == 1 {
  37407. drugs, _ := service.GetBatchDrugList(ids)
  37408. for _, item := range drugs {
  37409. result := QueryResult{
  37410. ID: item.ID,
  37411. Name: item.DrugName,
  37412. Code: item.MedicalInsuranceNumber,
  37413. List_type_code: "101",
  37414. }
  37415. queryResult = append(queryResult, result)
  37416. }
  37417. } else if record_type == 2 {
  37418. goods, _ := service.GetBatchGoodInformationList(ids)
  37419. fmt.Println(goods)
  37420. for _, item := range goods {
  37421. result := QueryResult{
  37422. ID: item.ID,
  37423. Name: item.GoodName,
  37424. Code: item.SocialSecurityDirectoryCode,
  37425. List_type_code: "301",
  37426. }
  37427. queryResult = append(queryResult, result)
  37428. }
  37429. } else if record_type == 3 {
  37430. projects, _ := service.GetBathchMyPorjecgList(ids)
  37431. for _, item := range projects {
  37432. result := QueryResult{
  37433. ID: item.ID,
  37434. Name: item.ProjectName,
  37435. Code: item.MedicalCode,
  37436. List_type_code: "201",
  37437. }
  37438. queryResult = append(queryResult, result)
  37439. }
  37440. }
  37441. admin_user_id, _ := c.GetInt64("admin_user_id")
  37442. adminUser := c.GetAdminUserInfo()
  37443. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37444. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37445. var user_name string
  37446. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37447. if role.ID == 0 {
  37448. user_name = "管理员"
  37449. } else {
  37450. user_name = role.UserName
  37451. }
  37452. baseParams := models.BaseParams{
  37453. SecretKey: miConfig.SecretKey,
  37454. FixmedinsCode: miConfig.Code,
  37455. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37456. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37457. OrgName: miConfig.OrgName,
  37458. Doctor: user_name,
  37459. }
  37460. var result string
  37461. if miConfig.MdtrtareaAdmvs == "430800" {
  37462. for _, item := range queryResult {
  37463. if record_type == 1 {
  37464. 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)
  37465. } else if record_type == 2 {
  37466. fmt.Println(item.Code)
  37467. 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)
  37468. } else if record_type == 3 {
  37469. 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)
  37470. }
  37471. var dat map[string]interface{}
  37472. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37473. fmt.Println(dat)
  37474. } else {
  37475. fmt.Println(err)
  37476. }
  37477. userJSONBytes, _ := json.Marshal(dat)
  37478. var res ResultSix
  37479. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37480. utils.ErrorLog("解析失败:%v", err)
  37481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37482. return
  37483. }
  37484. if res.Infcode == 0 {
  37485. if record_type == 1 {
  37486. service.UpdateBaseDrugById(item.ID)
  37487. } else if record_type == 2 {
  37488. service.UpdateGoodInformaitonByDetail(item.ID)
  37489. } else if record_type == 3 {
  37490. service.UpdateProjectById(item.ID)
  37491. }
  37492. c.ServeSuccessJSON(map[string]interface{}{
  37493. "failed_code": 0,
  37494. "msg": "目录对照成功",
  37495. })
  37496. } else {
  37497. c.ServeSuccessJSON(map[string]interface{}{
  37498. "failed_code": -10,
  37499. "msg": res.ErrMsg,
  37500. })
  37501. }
  37502. }
  37503. } else {
  37504. for _, item := range queryResult {
  37505. var result string
  37506. if record_type == 1 {
  37507. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37508. } else if record_type == 2 {
  37509. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37510. } else if record_type == 3 {
  37511. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37512. }
  37513. var dat map[string]interface{}
  37514. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37515. fmt.Println(dat)
  37516. } else {
  37517. fmt.Println(err)
  37518. }
  37519. userJSONBytes, _ := json.Marshal(dat)
  37520. var res ResultSix
  37521. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37522. utils.ErrorLog("解析失败:%v", err)
  37523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37524. return
  37525. }
  37526. if res.Infcode == 0 {
  37527. if record_type == 1 {
  37528. service.UpdateBaseDrugById(item.ID)
  37529. } else if record_type == 2 {
  37530. service.UpdateGoodInformaitonByDetail(item.ID)
  37531. } else if record_type == 3 {
  37532. service.UpdateProjectById(item.ID)
  37533. }
  37534. c.ServeSuccessJSON(map[string]interface{}{
  37535. "failed_code": 0,
  37536. "msg": "目录对照成功",
  37537. })
  37538. } else {
  37539. c.ServeSuccessJSON(map[string]interface{}{
  37540. "failed_code": -10,
  37541. "msg": res.ErrMsg,
  37542. })
  37543. }
  37544. }
  37545. }
  37546. }
  37547. func (c *HisApiController) UnCheckCode() {
  37548. ids_str := c.GetString("ids")
  37549. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  37550. admin_user_id, _ := c.GetInt64("admin_user_id")
  37551. ids_arr := strings.Split(ids_str, ",")
  37552. var queryResult []QueryResult
  37553. ids := make([]int64, 0)
  37554. for _, item := range ids_arr {
  37555. id, _ := strconv.ParseInt(item, 10, 64)
  37556. ids = append(ids, id)
  37557. }
  37558. if record_type == 1 {
  37559. drugs, _ := service.GetBatchDrugList(ids)
  37560. for _, item := range drugs {
  37561. result := QueryResult{
  37562. ID: item.ID,
  37563. Name: item.DrugName,
  37564. Code: item.MedicalInsuranceNumber,
  37565. List_type_code: "101",
  37566. }
  37567. queryResult = append(queryResult, result)
  37568. }
  37569. } else if record_type == 2 {
  37570. goods, _ := service.GetBatchGoodInformationList(ids)
  37571. for _, item := range goods {
  37572. result := QueryResult{
  37573. ID: item.ID,
  37574. Name: item.GoodName,
  37575. Code: item.SocialSecurityDirectoryCode,
  37576. List_type_code: "301",
  37577. }
  37578. queryResult = append(queryResult, result)
  37579. }
  37580. } else if record_type == 3 {
  37581. projects, _ := service.GetBathchMyPorjecgList(ids)
  37582. for _, item := range projects {
  37583. result := QueryResult{
  37584. ID: item.ID,
  37585. Name: item.ProjectName,
  37586. Code: item.MedicalCode,
  37587. List_type_code: "201",
  37588. }
  37589. queryResult = append(queryResult, result)
  37590. }
  37591. }
  37592. adminUser := c.GetAdminUserInfo()
  37593. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37594. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37595. var user_name string
  37596. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37597. if role.ID == 0 {
  37598. user_name = "xxx"
  37599. } else {
  37600. user_name = role.UserName
  37601. }
  37602. baseParams := &models.BaseParams{
  37603. SecretKey: miConfig.SecretKey,
  37604. FixmedinsCode: miConfig.Code,
  37605. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37606. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37607. OrgName: miConfig.OrgName,
  37608. Doctor: user_name,
  37609. }
  37610. if config.IsOpen == 1 {
  37611. if miConfig.MdtrtareaAdmvs == "430800" {
  37612. for _, item := range queryResult {
  37613. var result string
  37614. if record_type == 1 {
  37615. 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)
  37616. } else if record_type == 2 {
  37617. fmt.Println(item.Code)
  37618. 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)
  37619. } else if record_type == 3 {
  37620. 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)
  37621. }
  37622. var dat map[string]interface{}
  37623. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37624. fmt.Println(dat)
  37625. } else {
  37626. fmt.Println(err)
  37627. }
  37628. userJSONBytes, _ := json.Marshal(dat)
  37629. var res ResultSix
  37630. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37631. utils.ErrorLog("解析失败:%v", err)
  37632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37633. return
  37634. }
  37635. if res.Infcode == 0 {
  37636. if record_type == 1 {
  37637. service.UpdateBaseDrugById(item.ID)
  37638. } else if record_type == 2 {
  37639. service.UpdateGoodInformaitonByDetail(item.ID)
  37640. } else if record_type == 3 {
  37641. service.UpdateProjectById(item.ID)
  37642. }
  37643. c.ServeSuccessJSON(map[string]interface{}{
  37644. "failed_code": 0,
  37645. "msg": "目录对照成功",
  37646. })
  37647. } else {
  37648. c.ServeSuccessJSON(map[string]interface{}{
  37649. "failed_code": -10,
  37650. "msg": res.ErrMsg,
  37651. })
  37652. }
  37653. }
  37654. } else {
  37655. for _, item := range queryResult {
  37656. var result string
  37657. if record_type == 1 {
  37658. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  37659. } else if record_type == 2 {
  37660. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  37661. } else if record_type == 3 {
  37662. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  37663. }
  37664. var dat2 map[string]interface{}
  37665. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37666. fmt.Println(dat2)
  37667. } else {
  37668. fmt.Println(err)
  37669. }
  37670. userJSONBytes, _ := json.Marshal(dat2)
  37671. var res ResultSix
  37672. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37673. utils.ErrorLog("解析失败:%v", err)
  37674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37675. return
  37676. }
  37677. if res.Infcode == 0 {
  37678. if record_type == 1 {
  37679. service.UpdateDrugByIdDetail(item.ID)
  37680. } else if record_type == 2 {
  37681. service.UpdateGoodInfoById(item.ID)
  37682. } else if record_type == 3 {
  37683. service.UpdateMyProjectById(item.ID)
  37684. }
  37685. c.ServeSuccessJSON(map[string]interface{}{
  37686. "failed_code": 0,
  37687. "msg": "撤销目录对照成功",
  37688. })
  37689. } else {
  37690. c.ServeSuccessJSON(map[string]interface{}{
  37691. "failed_code": -10,
  37692. "msg": res.ErrMsg,
  37693. })
  37694. }
  37695. }
  37696. }
  37697. }
  37698. }
  37699. func (c *HisApiController) GetPatientInfo() {
  37700. id_card_no := c.GetString("id_card_no")
  37701. admin_user_id, _ := c.GetInt64("admin_user_id")
  37702. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  37703. if patient.ID == 0 {
  37704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37705. return
  37706. }
  37707. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  37708. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  37709. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  37710. var res ResultTwo
  37711. var res10265 ResultTwo10265
  37712. if config.IsOpen == 1 {
  37713. if miConfig.MdtrtareaAdmvs == "150499" {
  37714. //请求内网数据
  37715. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  37716. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  37717. "&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
  37718. resp, requestErr := http.Get(api)
  37719. if requestErr != nil {
  37720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37721. return
  37722. }
  37723. body, ioErr := ioutil.ReadAll(resp.Body)
  37724. if ioErr != nil {
  37725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37727. return
  37728. }
  37729. var respJSON map[string]interface{}
  37730. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37733. return
  37734. }
  37735. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37736. result_byte, _ := json.Marshal(respJSON)
  37737. result := string(result_byte)
  37738. var dat map[string]interface{}
  37739. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37740. fmt.Println(dat)
  37741. } else {
  37742. fmt.Println(err)
  37743. }
  37744. userJSONBytes, _ := json.Marshal(dat)
  37745. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37746. utils.ErrorLog("解析失败:%v", err)
  37747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37748. return
  37749. }
  37750. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37751. res.Infcode = Infcode
  37752. res.ErrMsg = res10265.ErrMsg
  37753. res.Output = res10265.Output
  37754. res.InfRefmsgid = res10265.InfRefmsgid
  37755. res.RespondTime = res10265.RespondTime
  37756. res.WarnInfo = res10265.WarnInfo
  37757. } else {
  37758. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37759. var dat map[string]interface{}
  37760. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37761. fmt.Println(dat)
  37762. } else {
  37763. fmt.Println(err)
  37764. }
  37765. userJSONBytes, _ := json.Marshal(dat)
  37766. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37767. utils.ErrorLog("解析失败:%v", err)
  37768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37769. return
  37770. }
  37771. }
  37772. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37773. // utils.ErrorLog("解析失败:%v", err)
  37774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37775. // return
  37776. //}
  37777. for index, item := range res.Output.Iinfo {
  37778. if item.PsnInsuStas == "2" {
  37779. fmt.Println("--------")
  37780. res.Output.Iinfo[index].Insutype = "300"
  37781. res.Output.Iinfo[index].PsnInsuStas = "1"
  37782. }
  37783. }
  37784. fmt.Println(res.Output.Iinfo)
  37785. if res.Infcode != 0 {
  37786. c.ServeSuccessJSON(map[string]interface{}{
  37787. "failed_code": -10,
  37788. "msg": res.ErrMsg,
  37789. })
  37790. } else {
  37791. c.ServeSuccessJSON(map[string]interface{}{
  37792. "failed_code": 0,
  37793. "info": res,
  37794. })
  37795. }
  37796. }
  37797. }
  37798. func (c *HisApiController) PsnPutOnRecord() {
  37799. record_type, _ := c.GetInt64("type")
  37800. patient_id, _ := c.GetInt64("patient_id")
  37801. admin_user_id, _ := c.GetInt64("admin_user_id")
  37802. start_time := c.GetString("start_time")
  37803. end_time := c.GetString("end_time")
  37804. adminUser := c.GetAdminUserInfo()
  37805. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37806. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37807. var patients []*models.Patients
  37808. if record_type == 1 { //全部备案
  37809. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  37810. patients = append(patients, patient...)
  37811. } else { //单个备案
  37812. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37813. patients = append(patients, patient)
  37814. }
  37815. var user_name string
  37816. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37817. if role.ID == 0 {
  37818. user_name = "xxx"
  37819. } else {
  37820. user_name = role.UserName
  37821. }
  37822. if config.IsOpen == 1 {
  37823. for _, item := range patients {
  37824. 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
  37825. resp, requestErr := http.Get(api)
  37826. if requestErr != nil {
  37827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37828. return
  37829. }
  37830. defer resp.Body.Close()
  37831. body, ioErr := ioutil.ReadAll(resp.Body)
  37832. if ioErr != nil {
  37833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37835. return
  37836. }
  37837. var respJSON map[string]interface{}
  37838. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37841. return
  37842. }
  37843. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37844. userJSONBytes, _ := json.Marshal(userJSON)
  37845. var res ResultTwo
  37846. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37847. utils.ErrorLog("解析失败:%v", err)
  37848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37849. return
  37850. }
  37851. if res.Infcode == 0 {
  37852. 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)
  37853. var dat map[string]interface{}
  37854. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37855. fmt.Println(dat)
  37856. } else {
  37857. fmt.Println(err)
  37858. }
  37859. userJSONBytes, _ := json.Marshal(dat)
  37860. var res2 ResultThirteen
  37861. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  37862. utils.ErrorLog("解析失败:%v", err)
  37863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37864. return
  37865. }
  37866. if res2.Infcode == 0 {
  37867. psnResult := &models.GdybPsnRecord{
  37868. UserOrgId: adminUser.CurrentOrgId,
  37869. PatientId: item.ID,
  37870. PsnNo: res.Output.Baseinfo.PsnNo,
  37871. Ctime: time.Now().Unix(),
  37872. Mtime: time.Now().Unix(),
  37873. Status: 1,
  37874. IsCancel: 1,
  37875. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  37876. }
  37877. service.CreatePsnRecord(psnResult)
  37878. } else {
  37879. c.ServeSuccessJSON(map[string]interface{}{
  37880. "failed_code": -10,
  37881. "msg": res2.ErrMsg,
  37882. })
  37883. return
  37884. }
  37885. }
  37886. }
  37887. }
  37888. }
  37889. func (c *HisApiController) PsnUnPutOnRecord() {
  37890. id, _ := c.GetInt64("id")
  37891. //record_type, _ := c.GetInt64("type")
  37892. admin_user_id, _ := c.GetInt64("admin_user_id")
  37893. adminUser := c.GetAdminUserInfo()
  37894. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37895. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37896. var user_name string
  37897. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37898. if role.ID == 0 {
  37899. user_name = "xxx"
  37900. } else {
  37901. user_name = role.UserName
  37902. }
  37903. psn_record, _ := service.GetPsnRecordById(id)
  37904. if psn_record.ID == 0 {
  37905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  37906. return
  37907. }
  37908. if config.IsOpen == 1 {
  37909. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  37910. var dat map[string]interface{}
  37911. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37912. fmt.Println(dat)
  37913. } else {
  37914. fmt.Println(err)
  37915. }
  37916. userJSONBytes, _ := json.Marshal(dat)
  37917. var res ResultFourteen
  37918. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37919. utils.ErrorLog("解析失败:%v", err)
  37920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37921. return
  37922. }
  37923. if res.Infcode == 0 {
  37924. psn_record.IsCancel = 2
  37925. service.CreatePsnRecord(&psn_record)
  37926. } else {
  37927. c.ServeSuccessJSON(map[string]interface{}{
  37928. "failed_code": -10,
  37929. "msg": res.ErrMsg,
  37930. })
  37931. return
  37932. }
  37933. }
  37934. }
  37935. func (c *HisApiController) PsnPutNCDSOnRecord() {
  37936. patient_id, _ := c.GetInt64("patient_id")
  37937. insutype_two := c.GetString("insutype")
  37938. psn_no := c.GetString("psn_no")
  37939. doctor_id, _ := c.GetInt64("doctor_id")
  37940. sick_id, _ := c.GetInt64("sick_id")
  37941. department_id, _ := c.GetInt64("department_id")
  37942. start_time := c.GetString("start_time")
  37943. end_time := c.GetString("end_time")
  37944. check_time := c.GetString("check_time")
  37945. hospital_code := c.GetString("hospital_code")
  37946. hospital_name := c.GetString("hospital_name")
  37947. adminUser := c.GetAdminUserInfo()
  37948. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37949. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37950. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37951. sick, _ := service.FindSickById(sick_id)
  37952. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  37953. if len(hospital_code) == 0 {
  37954. hospital_code = miConfig.Code
  37955. }
  37956. if len(hospital_name) == 0 {
  37957. hospital_name = miConfig.OrgName
  37958. }
  37959. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  37960. var res ResultTwo
  37961. var res10265 ResultTwo10265
  37962. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37963. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  37964. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  37965. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  37966. "&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
  37967. resp, requestErr := http.Get(api)
  37968. if requestErr != nil {
  37969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37970. return
  37971. }
  37972. body, ioErr := ioutil.ReadAll(resp.Body)
  37973. if ioErr != nil {
  37974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37976. return
  37977. }
  37978. var respJSON map[string]interface{}
  37979. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37982. return
  37983. }
  37984. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37985. result, _ := json.Marshal(respJSON)
  37986. fmt.Println("log")
  37987. fmt.Println(string(result))
  37988. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37989. utils.ErrorLog("解析失败:%v", err)
  37990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37991. return
  37992. }
  37993. res.ErrMsg = res10265.ErrMsg
  37994. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37995. res.Infcode = infocode
  37996. res.Output = res10265.Output
  37997. res.InfRefmsgid = res10265.InfRefmsgid
  37998. } else {
  37999. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38000. if miConfig.Code == "H15049901371" {
  38001. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38002. utils.ErrorLog("解析失败:%v", err)
  38003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38004. return
  38005. }
  38006. res.ErrMsg = res10265.ErrMsg
  38007. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38008. res.Infcode = infocode
  38009. res.Output = res10265.Output
  38010. res.InfRefmsgid = res10265.InfRefmsgid
  38011. } else {
  38012. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38013. utils.ErrorLog("解析失败:%v", err)
  38014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38015. return
  38016. }
  38017. }
  38018. }
  38019. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38020. infoStr := string(Iinfos)
  38021. var rf []*ResultFive
  38022. json.Unmarshal([]byte(infoStr), &rf)
  38023. var insuplc_admdvs string
  38024. var insutype string
  38025. var is390 int = 0
  38026. var is310 int = 0
  38027. var insutypes []*ResultFive
  38028. for _, item := range rf {
  38029. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38030. insutypes = append(insutypes, item)
  38031. }
  38032. }
  38033. if len(insutypes) == 1 {
  38034. insutype = insutypes[0].Insutype
  38035. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38036. } else {
  38037. for _, i := range insutypes {
  38038. if i.Insutype == "390" {
  38039. is390 = 1
  38040. }
  38041. if i.Insutype == "310" {
  38042. is310 = 1
  38043. }
  38044. }
  38045. }
  38046. if is390 == 1 {
  38047. insutype = "390"
  38048. }
  38049. if is310 == 1 {
  38050. insutype = "310"
  38051. }
  38052. if len(insutypes) == 2 {
  38053. insutype = insutype_two
  38054. }
  38055. if len(insutypes) == 0 {
  38056. insutype = "310"
  38057. }
  38058. insutype = insutype_two
  38059. fmt.Println(insutype)
  38060. for _, item := range rf {
  38061. fmt.Println(item.Insutype)
  38062. fmt.Println(insutype)
  38063. if item.Insutype == insutype {
  38064. fmt.Println(item.Insutype)
  38065. fmt.Println(insutype)
  38066. insuplc_admdvs = item.InsuplcAdmdvs
  38067. }
  38068. }
  38069. fmt.Println(insuplc_admdvs)
  38070. var res2 ResultThirteen
  38071. var res10265_2 ResultThirteen10265
  38072. if config.IsOpen == 1 {
  38073. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  38074. } else {
  38075. if miConfig.MdtrtareaAdmvs == "150499" {
  38076. //
  38077. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  38078. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38079. // "&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
  38080. //resp, requestErr := http.Get(api)
  38081. //if requestErr != nil {
  38082. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38083. // return
  38084. //}
  38085. //
  38086. //body, ioErr := ioutil.ReadAll(resp.Body)
  38087. //if ioErr != nil {
  38088. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38090. // return
  38091. //}
  38092. //var respJSON map[string]interface{}
  38093. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38094. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38095. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38096. // return
  38097. //}
  38098. //
  38099. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38100. //result, _ := json.Marshal(respJSON)
  38101. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  38102. // utils.ErrorLog("解析失败:%v", err)
  38103. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38104. // return
  38105. //}
  38106. //infocode = resThree.Infcode
  38107. //result, _ := json.Marshal(respJSON)
  38108. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  38109. // utils.ErrorLog("解析失败:%v", err)
  38110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38111. // return
  38112. //}
  38113. //
  38114. //resThree.ErrMsg = resThree10265.ErrMsg
  38115. //
  38116. //resThree.Output = resThree10265.Output
  38117. //
  38118. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  38119. //
  38120. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  38121. //
  38122. } else {
  38123. 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)
  38124. var dat map[string]interface{}
  38125. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38126. fmt.Println(dat)
  38127. } else {
  38128. fmt.Println(err)
  38129. }
  38130. userJSONBytes, _ := json.Marshal(dat)
  38131. if miConfig.Code == "H15049901371" {
  38132. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  38133. utils.ErrorLog("解析失败:%v", err)
  38134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38135. return
  38136. }
  38137. res2.ErrMsg = res10265_2.ErrMsg
  38138. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  38139. res2.Infcode = infocode
  38140. res2.Output = res10265_2.Output
  38141. res2.InfRefmsgid = res10265_2.InfRefmsgid
  38142. } else {
  38143. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38144. utils.ErrorLog("解析失败:%v", err)
  38145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38146. return
  38147. }
  38148. }
  38149. }
  38150. }
  38151. if res2.Infcode == 0 {
  38152. psnResult := &models.GdybPsnNcdsRecord{
  38153. UserOrgId: adminUser.CurrentOrgId,
  38154. PatientId: patient.ID,
  38155. PsnNo: psn_no,
  38156. DoctorId: doctor.AdminUserId,
  38157. DepartmentId: department_id,
  38158. SickType: sick_id,
  38159. Insutype: insutype,
  38160. Ctime: time.Now().Unix(),
  38161. Mtime: time.Now().Unix(),
  38162. Status: 1,
  38163. IsCancel: 1,
  38164. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38165. }
  38166. service.CreatePsnNCDSRecord(psnResult)
  38167. c.ServeSuccessJSON(map[string]interface{}{
  38168. "failed_code": 0,
  38169. "msg": "备案成功",
  38170. "result": psnResult,
  38171. })
  38172. } else {
  38173. c.ServeSuccessJSON(map[string]interface{}{
  38174. "failed_code": -10,
  38175. "msg": res2.ErrMsg,
  38176. })
  38177. return
  38178. }
  38179. }
  38180. }
  38181. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  38182. id, _ := c.GetInt64("id")
  38183. admin_user_id, _ := c.GetInt64("admin_user_id")
  38184. adminUser := c.GetAdminUserInfo()
  38185. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38186. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38187. //config, _ := service.Ge(adminUser.CurrentOrgId)
  38188. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  38189. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38190. //var user_name string
  38191. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38192. //if role.ID == 0 {
  38193. // user_name = "xxx"
  38194. //} else {
  38195. // user_name = role.UserName
  38196. //}
  38197. psn_record, _ := service.GetPsnNCDSRecordById(id)
  38198. if psn_record.ID == 0 {
  38199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38200. return
  38201. }
  38202. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38203. var res ResultTwo
  38204. var res10265 ResultTwo10265
  38205. if miConfig.Code == "H15049901371" {
  38206. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38207. utils.ErrorLog("解析失败:%v", err)
  38208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38209. return
  38210. }
  38211. res.ErrMsg = res10265.ErrMsg
  38212. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38213. res.Infcode = infocode
  38214. res.Output = res10265.Output
  38215. res.InfRefmsgid = res10265.InfRefmsgid
  38216. } else {
  38217. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38218. utils.ErrorLog("解析失败:%v", err)
  38219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38220. return
  38221. }
  38222. }
  38223. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38224. infoStr := string(Iinfos)
  38225. var rf []*ResultFive
  38226. json.Unmarshal([]byte(infoStr), &rf)
  38227. var insuplc_admdvs string
  38228. var insutype string
  38229. var is390 int = 0
  38230. var is310 int = 0
  38231. var insutypes []*ResultFive
  38232. for _, item := range rf {
  38233. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38234. insutypes = append(insutypes, item)
  38235. }
  38236. }
  38237. if len(insutypes) == 1 {
  38238. insutype = insutypes[0].Insutype
  38239. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38240. } else {
  38241. for _, i := range insutypes {
  38242. if i.Insutype == "390" {
  38243. is390 = 1
  38244. }
  38245. if i.Insutype == "310" {
  38246. is310 = 1
  38247. }
  38248. }
  38249. }
  38250. if is390 == 1 {
  38251. insutype = "390"
  38252. }
  38253. if is310 == 1 {
  38254. insutype = "310"
  38255. }
  38256. if len(insutypes) == 0 {
  38257. insutype = "310"
  38258. }
  38259. insutype = psn_record.Insutype
  38260. for _, item := range rf {
  38261. if item.Insutype == insutype {
  38262. insuplc_admdvs = item.InsuplcAdmdvs
  38263. }
  38264. }
  38265. if config.IsOpen == 1 {
  38266. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38267. var dat map[string]interface{}
  38268. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38269. fmt.Println(dat)
  38270. } else {
  38271. fmt.Println(err)
  38272. }
  38273. userJSONBytes, _ := json.Marshal(dat)
  38274. var res ResultFourteen
  38275. var res10265 ResultFourteen10265
  38276. if miConfig.Code == "H15049901371" {
  38277. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38278. utils.ErrorLog("解析失败:%v", err)
  38279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38280. return
  38281. }
  38282. res.ErrMsg = res10265.ErrMsg
  38283. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38284. res.Infcode = infocode
  38285. res.Output = res10265.Output
  38286. res.InfRefmsgid = res10265.InfRefmsgid
  38287. } else {
  38288. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38289. utils.ErrorLog("解析失败:%v", err)
  38290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38291. return
  38292. }
  38293. }
  38294. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38295. // utils.ErrorLog("解析失败:%v", err)
  38296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38297. // return
  38298. //}
  38299. if res.Infcode == 0 {
  38300. psn_record.IsCancel = 2
  38301. service.CreatePsnNCDSRecord(&psn_record)
  38302. c.ServeSuccessJSON(map[string]interface{}{
  38303. "failed_code": 0,
  38304. "msg": "撤销备案成功",
  38305. })
  38306. } else {
  38307. c.ServeSuccessJSON(map[string]interface{}{
  38308. "failed_code": -10,
  38309. "msg": res.ErrMsg,
  38310. })
  38311. return
  38312. }
  38313. }
  38314. }
  38315. func (c *HisApiController) TestTest() {
  38316. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  38317. fmt.Println(patient.Iinfo)
  38318. }
  38319. type CustomData struct {
  38320. MsgId string
  38321. PsnNo string
  38322. Info string
  38323. }
  38324. func (c *HisApiController) ReversalData() {
  38325. var customData []*CustomData
  38326. custom := &CustomData{
  38327. MsgId: "H44022900158202103301714472004",
  38328. PsnNo: "44020000001101329945",
  38329. Info: "2207",
  38330. }
  38331. customData = append(customData, custom)
  38332. custom1 := &CustomData{
  38333. MsgId: "H4402290015820210330172057803",
  38334. PsnNo: "44020000001101161813",
  38335. Info: "2207",
  38336. }
  38337. customData = append(customData, custom1)
  38338. custom2 := &CustomData{
  38339. MsgId: "H44022900158202103301705198813",
  38340. PsnNo: "44190000133097375417",
  38341. Info: "2207",
  38342. }
  38343. customData = append(customData, custom2)
  38344. custom3 := &CustomData{
  38345. MsgId: "H44022900158202103301715524756",
  38346. PsnNo: "44020000001100187221",
  38347. Info: "2207",
  38348. }
  38349. customData = append(customData, custom3)
  38350. custom4 := &CustomData{
  38351. MsgId: "H44022900158202103301730376224",
  38352. PsnNo: "44020000001101959155",
  38353. Info: "2207",
  38354. }
  38355. customData = append(customData, custom4)
  38356. custom5 := &CustomData{
  38357. MsgId: "H44022900158202103301748008725",
  38358. PsnNo: "44020000001104246641",
  38359. Info: "2207",
  38360. }
  38361. customData = append(customData, custom5)
  38362. custom6 := &CustomData{
  38363. MsgId: "H44022900158202103301718096755",
  38364. PsnNo: "44020000001102211860",
  38365. Info: "2207",
  38366. }
  38367. customData = append(customData, custom6)
  38368. custom7 := &CustomData{
  38369. MsgId: "H44022900158202103301736551640",
  38370. PsnNo: "44020000001102687718",
  38371. Info: "2207",
  38372. }
  38373. customData = append(customData, custom7)
  38374. custom8 := &CustomData{
  38375. MsgId: "H44022900158202103301743097676",
  38376. PsnNo: "44020000001102127785",
  38377. Info: "2207",
  38378. }
  38379. customData = append(customData, custom8)
  38380. custom9 := &CustomData{
  38381. MsgId: "H44022900158202103301712304203",
  38382. PsnNo: "44020000001101518097",
  38383. Info: "2207",
  38384. }
  38385. customData = append(customData, custom9)
  38386. custom10 := &CustomData{
  38387. MsgId: "H44022900158202103301738448785",
  38388. PsnNo: "44020000001100500813",
  38389. Info: "2207",
  38390. }
  38391. customData = append(customData, custom10)
  38392. custom11 := &CustomData{
  38393. MsgId: "H44022900158202103301732455843",
  38394. PsnNo: "44020000001102690557",
  38395. Info: "2207",
  38396. }
  38397. customData = append(customData, custom11)
  38398. custom12 := &CustomData{
  38399. MsgId: "H44022900158202103301745421708",
  38400. PsnNo: "44020000001102211928",
  38401. Info: "2207",
  38402. }
  38403. customData = append(customData, custom12)
  38404. custom1212 := &CustomData{
  38405. MsgId: "H440229001582021033017351627",
  38406. PsnNo: "44020000001102481733",
  38407. Info: "2207",
  38408. }
  38409. customData = append(customData, custom1212)
  38410. custom13 := &CustomData{
  38411. MsgId: "H44022900158202103301740327951",
  38412. PsnNo: "44020000001103174866",
  38413. Info: "2207",
  38414. }
  38415. customData = append(customData, custom13)
  38416. custom14 := &CustomData{
  38417. MsgId: "H4402290015820210330174922668",
  38418. PsnNo: "44020000001102927272",
  38419. Info: "2207",
  38420. }
  38421. customData = append(customData, custom14)
  38422. custom15 := &CustomData{
  38423. MsgId: "H44022900158202103301752362273",
  38424. PsnNo: "44020000001102942890",
  38425. Info: "2207",
  38426. }
  38427. customData = append(customData, custom15)
  38428. custom16 := &CustomData{
  38429. MsgId: "H44022900158202103301751082917",
  38430. PsnNo: "44020000001101662162",
  38431. Info: "2207",
  38432. }
  38433. customData = append(customData, custom16)
  38434. custom17 := &CustomData{
  38435. MsgId: "H44022900158202103301754147728",
  38436. PsnNo: "44020000000229014511",
  38437. Info: "2207",
  38438. }
  38439. customData = append(customData, custom17)
  38440. adminUser := c.GetAdminUserInfo()
  38441. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38442. for _, item := range customData {
  38443. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  38444. fmt.Println(result)
  38445. }
  38446. }
  38447. func (c *HisApiController) GetAllopatry() {
  38448. year := c.GetString("year")
  38449. month := c.GetString("month")
  38450. admin_user_id, _ := c.GetInt64("admin_user_id")
  38451. adminUser := c.GetAdminUserInfo()
  38452. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38453. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38454. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38455. var dat map[string]interface{}
  38456. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38457. fmt.Println(dat)
  38458. } else {
  38459. fmt.Println(err)
  38460. }
  38461. userJSONBytes, _ := json.Marshal(dat)
  38462. var res models.Result9001
  38463. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38464. utils.ErrorLog("解析失败:%v", err)
  38465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38466. return
  38467. }
  38468. fmt.Println(res.Output.Signinoutb)
  38469. fmt.Println(res.Output.Signinoutb.SignNo)
  38470. fmt.Println(string(userJSONBytes))
  38471. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  38472. var dat3 map[string]interface{}
  38473. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  38474. fmt.Println(dat3)
  38475. } else {
  38476. fmt.Println(err)
  38477. }
  38478. userJSONBytes3, _ := json.Marshal(dat3)
  38479. var res3 models.Result3260
  38480. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  38481. utils.ErrorLog("解析失败:%v", err)
  38482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38483. return
  38484. }
  38485. var curpage int
  38486. var pagesize int = 100
  38487. var start int = 1
  38488. //var stop int
  38489. //pagecount := 10
  38490. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  38491. var res22 []models.Result3260
  38492. for curpage = 1; curpage <= pagecount; curpage++ {
  38493. if curpage == 1 {
  38494. start = 0
  38495. } else {
  38496. start = (curpage-1)*pagesize + 1
  38497. }
  38498. fmt.Println(start)
  38499. //stop = curpage * pagesize
  38500. //if stop > int(res3.Output.Totalrow) {
  38501. // stop =int(res3.Output.Totalrow)
  38502. //}
  38503. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  38504. var dat2 map[string]interface{}
  38505. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38506. fmt.Println(dat)
  38507. } else {
  38508. fmt.Println(err)
  38509. }
  38510. userJSONBytes2, _ := json.Marshal(dat2)
  38511. var res2 models.Result3260
  38512. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38513. utils.ErrorLog("解析失败:%v", err)
  38514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38515. return
  38516. }
  38517. if res2.Infcode == 0 {
  38518. res22 = append(res22, res2)
  38519. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  38520. //var dat2 map[string]interface{}
  38521. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  38522. // fmt.Println(dat)
  38523. //} else {
  38524. // fmt.Println(err)
  38525. //}
  38526. //c.ServeSuccessJSON(map[string]interface{}{
  38527. // "list": res2.Output.Data,
  38528. //})
  38529. //continue
  38530. }
  38531. }
  38532. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  38533. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  38534. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  38535. //var dat2 map[string]interface{}
  38536. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38537. // fmt.Println(dat)
  38538. //} else {
  38539. // fmt.Println(err)
  38540. //}
  38541. //userJSONBytes2, _ := json.Marshal(dat2)
  38542. //var res2 models.Result3260
  38543. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38544. // utils.ErrorLog("解析失败:%v", err)
  38545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38546. // return
  38547. //}
  38548. //if res2.Infcode == 0 {
  38549. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  38550. // var dat2 map[string]interface{}
  38551. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  38552. // fmt.Println(dat)
  38553. // } else {
  38554. // fmt.Println(err)
  38555. // }
  38556. // c.ServeSuccessJSON(map[string]interface{}{
  38557. // "list": res2.Output.Data,
  38558. // })
  38559. //}
  38560. }
  38561. func (c *HisApiController) ComfirmAllopatry() {
  38562. year := c.GetString("year")
  38563. month := c.GetString("month")
  38564. admin_user_id, _ := c.GetInt64("admin_user_id")
  38565. adminUser := c.GetAdminUserInfo()
  38566. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38567. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38568. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38569. var dat map[string]interface{}
  38570. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38571. fmt.Println(dat)
  38572. } else {
  38573. fmt.Println(err)
  38574. }
  38575. userJSONBytes, _ := json.Marshal(dat)
  38576. var res models.Result9001
  38577. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38578. utils.ErrorLog("解析失败:%v", err)
  38579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38580. return
  38581. }
  38582. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  38583. var dat2 map[string]interface{}
  38584. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38585. fmt.Println(dat)
  38586. } else {
  38587. fmt.Println(err)
  38588. }
  38589. userJSONBytes2, _ := json.Marshal(dat2)
  38590. var res2 models.Result3260
  38591. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38592. utils.ErrorLog("解析失败:%v", err)
  38593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38594. return
  38595. }
  38596. //if res2.Infcode == 0 {
  38597. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  38598. // var dat map[string]interface{}
  38599. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38600. // fmt.Println(dat)
  38601. // } else {
  38602. // fmt.Println(err)
  38603. // }
  38604. // userJSONBytes, _ := json.Marshal(dat)
  38605. // var res3 models.Result3261
  38606. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  38607. // utils.ErrorLog("解析失败:%v", err)
  38608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38609. // return
  38610. // }
  38611. //
  38612. // if res3.Infcode == 0 {
  38613. // record := &models.HisYidiClearRecord{
  38614. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  38615. // Ctime: time.Now().Unix(),
  38616. // Mtime: time.Now().Unix(),
  38617. // Status: 1,
  38618. // MsgId: msgId,
  38619. // }
  38620. // service.SaveClearRecord(record)
  38621. // c.ServeSuccessJSON(map[string]interface{}{
  38622. // "msg": "提取成功",
  38623. // })
  38624. // }
  38625. //}
  38626. }
  38627. func (c *HisApiController) RefundAllopatry() {
  38628. year := c.GetString("year")
  38629. month := c.GetString("month")
  38630. //id, _ := c.GetInt64("id")
  38631. admin_user_id, _ := c.GetInt64("admin_user_id")
  38632. adminUser := c.GetAdminUserInfo()
  38633. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38634. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38635. //record, _ := service.GetClearRecordById(id)
  38636. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38637. var dat map[string]interface{}
  38638. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  38639. fmt.Println(dat)
  38640. } else {
  38641. fmt.Println(err)
  38642. }
  38643. userJSONBytes, _ := json.Marshal(dat)
  38644. var res models.Result9001
  38645. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38646. utils.ErrorLog("解析失败:%v", err)
  38647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38648. return
  38649. }
  38650. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  38651. var dat2 map[string]interface{}
  38652. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  38653. fmt.Println(dat)
  38654. } else {
  38655. fmt.Println(err)
  38656. }
  38657. userJSONBytes2, _ := json.Marshal(dat2)
  38658. var empty ResultFourteen
  38659. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  38660. utils.ErrorLog("解析失败:%v", err)
  38661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38662. return
  38663. }
  38664. if empty.Infcode == 0 {
  38665. c.ServeSuccessJSON(map[string]interface{}{
  38666. "msg": "撤销成功",
  38667. })
  38668. return
  38669. }
  38670. }
  38671. func (c *HisApiController) ReversalOtherData() {
  38672. var customData []*CustomData
  38673. custom := &CustomData{
  38674. MsgId: "H44022900158202103301714472004",
  38675. PsnNo: "44020000001101329945",
  38676. Info: "2208",
  38677. }
  38678. customData = append(customData, custom)
  38679. custom1 := &CustomData{
  38680. MsgId: "H4402290015820210330172057803",
  38681. PsnNo: "44020000001101161813",
  38682. Info: "2208",
  38683. }
  38684. customData = append(customData, custom1)
  38685. custom2 := &CustomData{
  38686. MsgId: "H44022900158202103301705198813",
  38687. PsnNo: "44190000133097375417",
  38688. Info: "2208",
  38689. }
  38690. customData = append(customData, custom2)
  38691. custom3 := &CustomData{
  38692. MsgId: "H44022900158202103301715524756",
  38693. PsnNo: "44020000001100187221",
  38694. Info: "2208",
  38695. }
  38696. customData = append(customData, custom3)
  38697. custom4 := &CustomData{
  38698. MsgId: "H44022900158202103301730376224",
  38699. PsnNo: "44020000001101959155",
  38700. Info: "2208",
  38701. }
  38702. customData = append(customData, custom4)
  38703. custom5 := &CustomData{
  38704. MsgId: "H44022900158202103301748008725",
  38705. PsnNo: "44020000001104246641",
  38706. Info: "2208",
  38707. }
  38708. customData = append(customData, custom5)
  38709. custom6 := &CustomData{
  38710. MsgId: "H44022900158202103301718096755",
  38711. PsnNo: "44020000001102211860",
  38712. Info: "2208",
  38713. }
  38714. customData = append(customData, custom6)
  38715. custom7 := &CustomData{
  38716. MsgId: "H44022900158202103301736551640",
  38717. PsnNo: "44020000001102687718",
  38718. Info: "2208",
  38719. }
  38720. customData = append(customData, custom7)
  38721. custom8 := &CustomData{
  38722. MsgId: "H44022900158202103301743097676",
  38723. PsnNo: "44020000001102127785",
  38724. Info: "2208",
  38725. }
  38726. customData = append(customData, custom8)
  38727. custom9 := &CustomData{
  38728. MsgId: "H44022900158202103301712304203",
  38729. PsnNo: "44020000001101518097",
  38730. Info: "2208",
  38731. }
  38732. customData = append(customData, custom9)
  38733. custom10 := &CustomData{
  38734. MsgId: "H44022900158202103301738448785",
  38735. PsnNo: "44020000001100500813",
  38736. Info: "2208",
  38737. }
  38738. customData = append(customData, custom10)
  38739. custom11 := &CustomData{
  38740. MsgId: "H44022900158202103301732455843",
  38741. PsnNo: "44020000001102690557",
  38742. Info: "2208",
  38743. }
  38744. customData = append(customData, custom11)
  38745. custom12 := &CustomData{
  38746. MsgId: "H44022900158202103301745421708",
  38747. PsnNo: "44020000001102211928",
  38748. Info: "2208",
  38749. }
  38750. customData = append(customData, custom12)
  38751. custom1212 := &CustomData{
  38752. MsgId: "H440229001582021033017351627",
  38753. PsnNo: "44020000001102481733",
  38754. Info: "2208",
  38755. }
  38756. customData = append(customData, custom1212)
  38757. custom13 := &CustomData{
  38758. MsgId: "H44022900158202103301740327951",
  38759. PsnNo: "44020000001103174866",
  38760. Info: "2208",
  38761. }
  38762. customData = append(customData, custom13)
  38763. custom14 := &CustomData{
  38764. MsgId: "H4402290015820210330174922668",
  38765. PsnNo: "44020000001102927272",
  38766. Info: "2208",
  38767. }
  38768. customData = append(customData, custom14)
  38769. custom15 := &CustomData{
  38770. MsgId: "H44022900158202103301752362273",
  38771. PsnNo: "44020000001102942890",
  38772. Info: "2208",
  38773. }
  38774. customData = append(customData, custom15)
  38775. custom16 := &CustomData{
  38776. MsgId: "H44022900158202103301751082917",
  38777. PsnNo: "44020000001101662162",
  38778. Info: "2208",
  38779. }
  38780. customData = append(customData, custom16)
  38781. custom17 := &CustomData{
  38782. MsgId: "H44022900158202103301754147728",
  38783. PsnNo: "44020000000229014511",
  38784. Info: "2208",
  38785. }
  38786. customData = append(customData, custom17)
  38787. adminUser := c.GetAdminUserInfo()
  38788. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38789. for _, item := range customData {
  38790. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  38791. fmt.Println(result)
  38792. }
  38793. }
  38794. func PathExists(path string) (bool, error) {
  38795. _, err := os.Stat(path)
  38796. if err == nil {
  38797. return true, nil
  38798. }
  38799. if os.IsNotExist(err) {
  38800. return false, nil
  38801. }
  38802. return false, err
  38803. }
  38804. // 创建文件夹
  38805. func Mkdir(dir string) {
  38806. // 创建文件夹
  38807. exist, err := PathExists(dir)
  38808. if err != nil {
  38809. fmt.Println(err.Error())
  38810. } else {
  38811. if exist {
  38812. fmt.Println(dir + "文件夹已存在!")
  38813. } else {
  38814. // 文件夹名称,权限
  38815. err := os.Mkdir(dir, os.ModePerm)
  38816. if err != nil {
  38817. fmt.Println(dir+"文件夹创建失败:", err.Error())
  38818. } else {
  38819. fmt.Println(dir + "文件夹创建成功!")
  38820. }
  38821. }
  38822. }
  38823. }
  38824. // 压缩文件
  38825. func Zip(srcFile string, destZip string) error {
  38826. zipfile, err := os.Create(destZip)
  38827. if err != nil {
  38828. return err
  38829. }
  38830. defer zipfile.Close()
  38831. archive := zip.NewWriter(zipfile)
  38832. defer archive.Close()
  38833. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  38834. if err != nil {
  38835. return err
  38836. }
  38837. header, err := zip.FileInfoHeader(info)
  38838. if err != nil {
  38839. return err
  38840. }
  38841. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  38842. // header.Name = path
  38843. if info.IsDir() {
  38844. header.Name += "/"
  38845. } else {
  38846. header.Method = zip.Deflate
  38847. }
  38848. writer, err := archive.CreateHeader(header)
  38849. if err != nil {
  38850. return err
  38851. }
  38852. if !info.IsDir() {
  38853. file, err := os.Open(path)
  38854. if err != nil {
  38855. return err
  38856. }
  38857. defer file.Close()
  38858. _, err = io.Copy(writer, file)
  38859. }
  38860. return err
  38861. })
  38862. return err
  38863. }
  38864. func ReadFile(filePath string) []byte {
  38865. f, err := os.Open(filePath)
  38866. if err != nil {
  38867. fmt.Println("read file fail", err)
  38868. return nil
  38869. }
  38870. defer f.Close()
  38871. fd, err := ioutil.ReadAll(f)
  38872. if err != nil {
  38873. fmt.Println("read to fd fail", err)
  38874. return nil
  38875. }
  38876. return fd
  38877. }
  38878. func saveLogq(result string, request string, infno string, desc string) {
  38879. dir := "日志"
  38880. utils.Mkdir(dir)
  38881. month := time.Unix(1557042972, 0).Format("1")
  38882. year := time.Now().Format("2006")
  38883. month = time.Now().Format("01")
  38884. day := time.Now().Format("02")
  38885. hour := time.Now().Format("15")
  38886. min := time.Now().Format("04")
  38887. sec := time.Now().Format("05")
  38888. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  38889. file := year + month + day + "_log"
  38890. file_name := file + ".txt"
  38891. file_path := "日志" + "/" + file_name
  38892. exist, _ := utils.PathExists(file_path)
  38893. if exist { //存在
  38894. fmt.Println("存在")
  38895. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  38896. if err != nil {
  38897. fmt.Println("read fail")
  38898. }
  38899. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  38900. n, _ := f.Seek(0, 2)
  38901. _, err = f.WriteAt([]byte(content), n)
  38902. } else { //不存在
  38903. fmt.Println("文件不存在,创建文件")
  38904. f, err := os.Create("日志" + "/" + file_name)
  38905. defer f.Close()
  38906. if err != nil {
  38907. } else {
  38908. _, err = f.Write([]byte("记录日志"))
  38909. }
  38910. }
  38911. }
  38912. func saveLog(result string, request string, infno string, desc string) {
  38913. org_id, _ := beego.AppConfig.Int64("org_id")
  38914. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38915. dir := miConfig.OrgName + "日志"
  38916. utils.Mkdir(dir)
  38917. month := time.Unix(1557042972, 0).Format("1")
  38918. year := time.Now().Format("2006")
  38919. month = time.Now().Format("01")
  38920. day := time.Now().Format("02")
  38921. hour := time.Now().Format("15")
  38922. min := time.Now().Format("04")
  38923. sec := time.Now().Format("05")
  38924. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  38925. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  38926. file_name := file + ".txt"
  38927. file_path := miConfig.OrgName + "日志" + "/" + file_name
  38928. exist, _ := utils.PathExists(file_path)
  38929. if exist { //存在
  38930. fmt.Println("存在")
  38931. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  38932. if err != nil {
  38933. fmt.Println("read fail")
  38934. }
  38935. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  38936. n, _ := f.Seek(0, 2)
  38937. _, err = f.WriteAt([]byte(content), n)
  38938. } else { //不存在
  38939. fmt.Println("文件不存在,创建文件")
  38940. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  38941. defer f.Close()
  38942. if err != nil {
  38943. } else {
  38944. _, err = f.Write([]byte("记录日志"))
  38945. }
  38946. }
  38947. }
  38948. type Charset string
  38949. const (
  38950. UTF8 = Charset("UTF-8")
  38951. GB18030 = Charset("GB18030")
  38952. )
  38953. func ConvertToString(src string, srcCode string, tagCode string) string {
  38954. srcCoder := mahonia.NewDecoder(srcCode)
  38955. srcResult := srcCoder.ConvertString(src)
  38956. tagCoder := mahonia.NewDecoder(tagCode)
  38957. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  38958. result := string(cdata)
  38959. return result
  38960. }
  38961. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  38962. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  38963. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  38964. var token string
  38965. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  38966. var api string
  38967. if miConfig.MdtrtareaAdmvs == "320921" {
  38968. 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 +
  38969. "&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
  38970. fmt.Println(api)
  38971. } else {
  38972. 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 +
  38973. "&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
  38974. }
  38975. resp, requestErr := http.Get(api)
  38976. if requestErr != nil {
  38977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38978. return ""
  38979. }
  38980. body, ioErr := ioutil.ReadAll(resp.Body)
  38981. if ioErr != nil {
  38982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38984. return ""
  38985. }
  38986. var respJSON map[string]interface{}
  38987. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38990. return ""
  38991. }
  38992. var status string
  38993. status = respJSON["data"].(map[string]interface{})["status"].(string)
  38994. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  38995. var res ResultTwo //1101结果
  38996. var res10265 ResultTwo10265 //1101结果
  38997. if status == "0" { //读卡成功
  38998. var card_info string //卡信息
  38999. var busi_card_info string
  39000. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39001. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39002. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39003. fmt.Println(card_info)
  39004. fmt.Println(busi_card_info)
  39005. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39006. result, _ := json.Marshal(respJSON)
  39007. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39008. utils.ErrorLog("解析失败:%v", err)
  39009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39010. return ""
  39011. }
  39012. res.ErrMsg = res10265.ErrMsg
  39013. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39014. res.Infcode = infocode
  39015. res.Output = res10265.Output
  39016. res.InfRefmsgid = res10265.InfRefmsgid
  39017. if res.Infcode == 0 {
  39018. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39019. if err == gorm.ErrRecordNotFound {
  39020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39021. return ""
  39022. } else if err != nil {
  39023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39024. return ""
  39025. } else {
  39026. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39027. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39028. infoStr := string(Iinfos)
  39029. idetinfoStr := string(Idetinfos)
  39030. psn := &models.HisPsn{
  39031. PsnNo: res.Output.Baseinfo.PsnNo,
  39032. PatientId: patient.ID,
  39033. Certno: res.Output.Baseinfo.Certno,
  39034. Gend: res.Output.Baseinfo.Gend,
  39035. Naty: res.Output.Baseinfo.Naty,
  39036. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39037. PsnName: res.Output.Baseinfo.PsnName,
  39038. Idetinfo: idetinfoStr,
  39039. Insuinfo: infoStr,
  39040. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39041. CardInfo: card_info,
  39042. VerifyNumber: token,
  39043. }
  39044. service.CreateHisPsn(psn)
  39045. return token
  39046. }
  39047. }
  39048. } else {
  39049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39050. return ""
  39051. }
  39052. } else { //读卡失败
  39053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39054. return ""
  39055. }
  39056. return token
  39057. }
  39058. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  39059. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39060. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39061. var token string
  39062. var api string
  39063. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39064. "&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
  39065. fmt.Println(api)
  39066. resp, requestErr := http.Get(api)
  39067. if requestErr != nil {
  39068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39069. return ""
  39070. }
  39071. body, ioErr := ioutil.ReadAll(resp.Body)
  39072. if ioErr != nil {
  39073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39075. return ""
  39076. }
  39077. var respJSON map[string]interface{}
  39078. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39081. return ""
  39082. }
  39083. var status string
  39084. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39085. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39086. var res ResultTwo //1101结果
  39087. if status == "1" { //读卡成功
  39088. var card_info string //卡信息
  39089. var busi_card_info string
  39090. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39091. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39092. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39093. fmt.Println(card_info)
  39094. fmt.Println(busi_card_info)
  39095. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39096. result, _ := json.Marshal(respJSON)
  39097. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39098. utils.ErrorLog("解析失败:%v", err)
  39099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39100. return ""
  39101. }
  39102. if res.Infcode == 0 {
  39103. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39104. if err == gorm.ErrRecordNotFound {
  39105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39106. return ""
  39107. } else if err != nil {
  39108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39109. return ""
  39110. } else {
  39111. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39112. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39113. infoStr := string(Iinfos)
  39114. idetinfoStr := string(Idetinfos)
  39115. psn := &models.HisPsn{
  39116. PsnNo: res.Output.Baseinfo.PsnNo,
  39117. PatientId: patient.ID,
  39118. Certno: res.Output.Baseinfo.Certno,
  39119. Gend: res.Output.Baseinfo.Gend,
  39120. Naty: res.Output.Baseinfo.Naty,
  39121. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39122. PsnName: res.Output.Baseinfo.PsnName,
  39123. Idetinfo: idetinfoStr,
  39124. Insuinfo: infoStr,
  39125. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39126. CardInfo: card_info,
  39127. VerifyNumber: token,
  39128. }
  39129. service.CreateHisPsn(psn)
  39130. return token
  39131. }
  39132. }
  39133. } else {
  39134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39135. return ""
  39136. }
  39137. return token
  39138. }
  39139. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  39140. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39141. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39142. var token string
  39143. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  39144. var api string
  39145. if miConfig.MdtrtareaAdmvs == "320921" {
  39146. 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 +
  39147. "&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
  39148. fmt.Println(api)
  39149. } else {
  39150. 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 +
  39151. "&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
  39152. }
  39153. resp, requestErr := http.Get(api)
  39154. if requestErr != nil {
  39155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39156. return ""
  39157. }
  39158. body, ioErr := ioutil.ReadAll(resp.Body)
  39159. if ioErr != nil {
  39160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39162. return ""
  39163. }
  39164. var respJSON map[string]interface{}
  39165. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39168. return ""
  39169. }
  39170. var status string
  39171. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39172. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39173. var res ResultTwo //1101结果
  39174. var res10265 ResultTwo10265 //1101结果
  39175. if status == "0" { //读卡成功
  39176. var card_info string //卡信息
  39177. var busi_card_info string
  39178. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39179. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39180. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39181. fmt.Println(card_info)
  39182. fmt.Println(busi_card_info)
  39183. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39184. result, _ := json.Marshal(respJSON)
  39185. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39186. utils.ErrorLog("解析失败:%v", err)
  39187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39188. return ""
  39189. }
  39190. res.ErrMsg = res10265.ErrMsg
  39191. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39192. res.Infcode = infocode
  39193. res.Output = res10265.Output
  39194. res.InfRefmsgid = res10265.InfRefmsgid
  39195. if res.Infcode == 0 {
  39196. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39197. if err == gorm.ErrRecordNotFound {
  39198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39199. return ""
  39200. } else if err != nil {
  39201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39202. return ""
  39203. } else {
  39204. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39205. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39206. infoStr := string(Iinfos)
  39207. idetinfoStr := string(Idetinfos)
  39208. psn := &models.HisPsn{
  39209. PsnNo: res.Output.Baseinfo.PsnNo,
  39210. PatientId: patient.ID,
  39211. Certno: res.Output.Baseinfo.Certno,
  39212. Gend: res.Output.Baseinfo.Gend,
  39213. Naty: res.Output.Baseinfo.Naty,
  39214. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39215. PsnName: res.Output.Baseinfo.PsnName,
  39216. Idetinfo: idetinfoStr,
  39217. Insuinfo: infoStr,
  39218. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39219. CardInfo: card_info,
  39220. VerifyNumber: token,
  39221. }
  39222. service.CreateHisPsn(psn)
  39223. return token
  39224. }
  39225. }
  39226. } else {
  39227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39228. return ""
  39229. }
  39230. } else { //读卡失败
  39231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39232. return ""
  39233. }
  39234. return token
  39235. }
  39236. func DeleteExtraSpaceTwo(s string) string {
  39237. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39238. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39239. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39240. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39241. s2 := make([]byte, len(s1)) //定义字符数组切片
  39242. copy(s2, s1) //将字符串复制到切片
  39243. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39244. for len(spc_index) > 0 { //找到适配项
  39245. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39246. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39247. }
  39248. return string(s2)
  39249. }
  39250. func Remove0000(s string) string {
  39251. str := make([]rune, 0, len(s))
  39252. for _, v := range []rune(s) {
  39253. if v == 0 {
  39254. continue
  39255. }
  39256. str = append(str, v)
  39257. }
  39258. return string(str)
  39259. }
  39260. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  39261. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  39262. readCard := DllDef.MustFindProc("EcQuery")
  39263. pCardInfo := make([]byte, 8192)
  39264. pBusiCardInfo := make([]byte, 8192)
  39265. data := make(map[string]interface{})
  39266. //pData := make(map[string]interface{})
  39267. inputData := make(map[string]interface{})
  39268. inputData["orgId"] = code
  39269. inputData["businessType"] = "01101"
  39270. inputData["operatorId"] = operator_id
  39271. inputData["operatorName"] = operator_name
  39272. inputData["officeId"] = "001"
  39273. inputData["officeName"] = "血透室"
  39274. //
  39275. data["data"] = inputData
  39276. data["transType"] = "ec.query"
  39277. data["orgId"] = code
  39278. bytesData, _ := json.Marshal(data)
  39279. pCardInfo = bytesData
  39280. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  39281. fmt.Println(ret2)
  39282. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  39283. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  39284. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  39285. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  39286. if ret2 != 0 {
  39287. return "", ""
  39288. }
  39289. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  39290. }
  39291. func DeleteExtraSpace(s string) string {
  39292. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39293. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39294. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39295. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39296. s2 := make([]byte, len(s1)) //定义字符数组切片
  39297. copy(s2, s1) //将字符串复制到切片
  39298. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39299. for len(spc_index) > 0 { //找到适配项
  39300. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39301. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39302. }
  39303. return string(s2)
  39304. }
  39305. // 对账
  39306. func (c *HisApiController) Post3202() {
  39307. start_time := c.GetString("start_time")
  39308. end_time := c.GetString("end_time")
  39309. //insutype := c.GetString("insutype")
  39310. clr_type := c.GetString("clr_type")
  39311. clr_org := c.GetString("clr_optins")
  39312. admin_user_id, _ := c.GetInt64("admin_user_id")
  39313. adminUser := c.GetAdminUserInfo()
  39314. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39315. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39316. if len(clr_org) == 0 {
  39317. clr_org = miConfig.MdtrtareaAdmvs
  39318. }
  39319. timeLayout := "2006-01-02"
  39320. loc, _ := time.LoadLocation("Local")
  39321. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39322. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39323. var orders []*models.HisOrder
  39324. if clr_org == "421300" {
  39325. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39326. } else if clr_org == "420902" {
  39327. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39328. } else {
  39329. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39330. }
  39331. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39332. //fixmedins_setl_cnt := int64(len(orders))
  39333. var medfee_sumamt float64
  39334. var acct_pay float64
  39335. var fund_pay_sumamt float64
  39336. for _, item := range orders {
  39337. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39338. acct_pay = acct_pay + item.AcctPay
  39339. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39340. }
  39341. //var medfee_sumamt_two float64
  39342. //var acct_pay_two float64
  39343. //var fund_pay_sumamt_two float64
  39344. //for _, item := range orders_two {
  39345. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39346. // acct_pay_two = acct_pay_two + item.AcctPay
  39347. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39348. //}
  39349. //var user_name string
  39350. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39351. //if role.ID == 0 {
  39352. // user_name = "xxx"
  39353. //} else {
  39354. // user_name = role.UserName
  39355. //}
  39356. var res ResultSix
  39357. if config.IsOpen == 1 {
  39358. var bps []*models.BusinessParamsTwo
  39359. var bp models.BusinessParamsTwo
  39360. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39361. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39362. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39363. bp.MedfeeSumamt = medfee_sumamt_str
  39364. bp.AcctPay = acct_pay_str
  39365. bp.FundPaySumamt = fund_pay_sumamt_str
  39366. bp.Insutype = ""
  39367. bp.StmtBegndate = start_time
  39368. bp.ClrType = clr_type
  39369. bp.SetlOptins = clr_org
  39370. bp.StmtEnddate = end_time
  39371. bps = append(bps, &bp)
  39372. data := make(map[string]interface{})
  39373. data["bps"] = bps
  39374. data["org_name"] = miConfig.OrgName
  39375. data["doctor"] = role.UserName
  39376. data["fixmedins_code"] = miConfig.Code
  39377. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39378. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39379. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39380. if miConfig.MdtrtareaAdmvs == "421300" {
  39381. client := &http.Client{}
  39382. bytesData, _ := json.Marshal(data)
  39383. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39384. resp, _ := client.Do(req)
  39385. defer resp.Body.Close()
  39386. body, ioErr := ioutil.ReadAll(resp.Body)
  39387. if ioErr != nil {
  39388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39390. return
  39391. }
  39392. var respJSON map[string]interface{}
  39393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39396. return
  39397. }
  39398. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39399. userJSONBytes, _ := json.Marshal(respJSON)
  39400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39401. utils.ErrorLog("解析失败:%v", err)
  39402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39403. return
  39404. }
  39405. }
  39406. if miConfig.MdtrtareaAdmvs == "420200" {
  39407. client := &http.Client{}
  39408. bytesData, _ := json.Marshal(data)
  39409. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39410. resp, _ := client.Do(req)
  39411. defer resp.Body.Close()
  39412. body, ioErr := ioutil.ReadAll(resp.Body)
  39413. if ioErr != nil {
  39414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39416. return
  39417. }
  39418. var respJSON map[string]interface{}
  39419. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39422. return
  39423. }
  39424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39425. userJSONBytes, _ := json.Marshal(respJSON)
  39426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39427. utils.ErrorLog("解析失败:%v", err)
  39428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39429. return
  39430. }
  39431. }
  39432. if miConfig.MdtrtareaAdmvs == "421182" {
  39433. client := &http.Client{}
  39434. bytesData, _ := json.Marshal(data)
  39435. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39436. resp, _ := client.Do(req)
  39437. defer resp.Body.Close()
  39438. body, ioErr := ioutil.ReadAll(resp.Body)
  39439. if ioErr != nil {
  39440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39442. return
  39443. }
  39444. var respJSON map[string]interface{}
  39445. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39448. return
  39449. }
  39450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39451. userJSONBytes, _ := json.Marshal(respJSON)
  39452. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39453. utils.ErrorLog("解析失败:%v", err)
  39454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39455. return
  39456. }
  39457. }
  39458. if miConfig.MdtrtareaAdmvs == "420902" {
  39459. client := &http.Client{}
  39460. bytesData, _ := json.Marshal(data)
  39461. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39462. resp, _ := client.Do(req)
  39463. defer resp.Body.Close()
  39464. body, ioErr := ioutil.ReadAll(resp.Body)
  39465. if ioErr != nil {
  39466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39468. return
  39469. }
  39470. var respJSON map[string]interface{}
  39471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39474. return
  39475. }
  39476. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39477. userJSONBytes, _ := json.Marshal(respJSON)
  39478. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39479. utils.ErrorLog("解析失败:%v", err)
  39480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39481. return
  39482. }
  39483. }
  39484. if res.Infcode == 0 {
  39485. c.ServeSuccessJSON(map[string]interface{}{
  39486. "msg": "发起成功",
  39487. })
  39488. } else {
  39489. c.ServeSuccessJSON(map[string]interface{}{
  39490. "failed_code": -10,
  39491. "msg": res.ErrMsg,
  39492. })
  39493. }
  39494. }
  39495. }
  39496. func (c *HisApiController) Post3204a() {
  39497. start_time := c.GetString("start_time")
  39498. end_time := c.GetString("end_time")
  39499. //insutype := c.GetString("insutype")
  39500. clr_type := c.GetString("clr_type")
  39501. clr_org := c.GetString("clr_optins")
  39502. admin_user_id, _ := c.GetInt64("admin_user_id")
  39503. adminUser := c.GetAdminUserInfo()
  39504. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39505. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39506. if len(clr_org) == 0 {
  39507. clr_org = miConfig.MdtrtareaAdmvs
  39508. }
  39509. timeLayout := "2006-01-02"
  39510. loc, _ := time.LoadLocation("Local")
  39511. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39512. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39513. var orders []*models.HisOrder
  39514. if clr_org == "421300" {
  39515. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39516. } else if clr_org == "420902" {
  39517. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39518. } else {
  39519. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39520. }
  39521. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39522. //fixmedins_setl_cnt := int64(len(orders))
  39523. var medfee_sumamt float64
  39524. var acct_pay float64
  39525. var fund_pay_sumamt float64
  39526. for _, item := range orders {
  39527. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39528. acct_pay = acct_pay + item.AcctPay
  39529. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39530. }
  39531. //var medfee_sumamt_two float64
  39532. //var acct_pay_two float64
  39533. //var fund_pay_sumamt_two float64
  39534. //for _, item := range orders_two {
  39535. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39536. // acct_pay_two = acct_pay_two + item.AcctPay
  39537. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39538. //}
  39539. //var user_name string
  39540. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39541. //if role.ID == 0 {
  39542. // user_name = "xxx"
  39543. //} else {
  39544. // user_name = role.UserName
  39545. //}
  39546. var res ResultSix
  39547. if config.IsOpen == 1 {
  39548. var bps []*models.BusinessParamsTwo
  39549. var bp models.BusinessParamsTwo
  39550. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39551. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39552. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39553. bp.MedfeeSumamt = medfee_sumamt_str
  39554. bp.AcctPay = acct_pay_str
  39555. bp.FundPaySumamt = fund_pay_sumamt_str
  39556. bp.Insutype = ""
  39557. bp.StmtBegndate = start_time
  39558. bp.ClrType = clr_type
  39559. bp.SetlOptins = clr_org
  39560. bp.StmtEnddate = end_time
  39561. bps = append(bps, &bp)
  39562. data := make(map[string]interface{})
  39563. data["bps"] = bps
  39564. data["org_name"] = miConfig.OrgName
  39565. data["doctor"] = role.UserName
  39566. data["fixmedins_code"] = miConfig.Code
  39567. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39568. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39569. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39570. if miConfig.MdtrtareaAdmvs == "421300" {
  39571. client := &http.Client{}
  39572. bytesData, _ := json.Marshal(data)
  39573. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  39574. resp, _ := client.Do(req)
  39575. defer resp.Body.Close()
  39576. body, ioErr := ioutil.ReadAll(resp.Body)
  39577. if ioErr != nil {
  39578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39580. return
  39581. }
  39582. var respJSON map[string]interface{}
  39583. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39586. return
  39587. }
  39588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39589. userJSONBytes, _ := json.Marshal(respJSON)
  39590. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39591. utils.ErrorLog("解析失败:%v", err)
  39592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39593. return
  39594. }
  39595. }
  39596. if miConfig.MdtrtareaAdmvs == "420200" {
  39597. client := &http.Client{}
  39598. bytesData, _ := json.Marshal(data)
  39599. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  39600. resp, _ := client.Do(req)
  39601. defer resp.Body.Close()
  39602. body, ioErr := ioutil.ReadAll(resp.Body)
  39603. if ioErr != nil {
  39604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39606. return
  39607. }
  39608. var respJSON map[string]interface{}
  39609. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39612. return
  39613. }
  39614. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39615. userJSONBytes, _ := json.Marshal(respJSON)
  39616. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39617. utils.ErrorLog("解析失败:%v", err)
  39618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39619. return
  39620. }
  39621. }
  39622. if miConfig.MdtrtareaAdmvs == "421182" {
  39623. client := &http.Client{}
  39624. bytesData, _ := json.Marshal(data)
  39625. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  39626. resp, _ := client.Do(req)
  39627. defer resp.Body.Close()
  39628. body, ioErr := ioutil.ReadAll(resp.Body)
  39629. if ioErr != nil {
  39630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39632. return
  39633. }
  39634. var respJSON map[string]interface{}
  39635. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39638. return
  39639. }
  39640. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39641. userJSONBytes, _ := json.Marshal(respJSON)
  39642. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39643. utils.ErrorLog("解析失败:%v", err)
  39644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39645. return
  39646. }
  39647. }
  39648. if miConfig.MdtrtareaAdmvs == "420902" {
  39649. client := &http.Client{}
  39650. bytesData, _ := json.Marshal(data)
  39651. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  39652. resp, _ := client.Do(req)
  39653. defer resp.Body.Close()
  39654. body, ioErr := ioutil.ReadAll(resp.Body)
  39655. if ioErr != nil {
  39656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39658. return
  39659. }
  39660. var respJSON map[string]interface{}
  39661. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39664. return
  39665. }
  39666. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39667. userJSONBytes, _ := json.Marshal(respJSON)
  39668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39669. utils.ErrorLog("解析失败:%v", err)
  39670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39671. return
  39672. }
  39673. }
  39674. if res.Infcode == 0 {
  39675. c.ServeSuccessJSON(map[string]interface{}{
  39676. "msg": "撤销成功",
  39677. })
  39678. } else {
  39679. c.ServeSuccessJSON(map[string]interface{}{
  39680. "failed_code": -10,
  39681. "msg": res.ErrMsg,
  39682. })
  39683. }
  39684. }
  39685. }
  39686. func (c *HisApiController) Post3204() {
  39687. admin_user_id, _ := c.GetInt64("admin_user_id")
  39688. id := c.GetString("id")
  39689. adminUser := c.GetAdminUserInfo()
  39690. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39691. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39692. //clr_org := miConfig.MdtrtareaAdmvs
  39693. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39694. var res ResultSix
  39695. if config.IsOpen == 1 {
  39696. data := make(map[string]interface{})
  39697. data["id"] = id
  39698. data["org_name"] = miConfig.OrgName
  39699. data["doctor"] = role.UserName
  39700. data["fixmedins_code"] = miConfig.Code
  39701. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39702. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39703. client := &http.Client{}
  39704. bytesData, _ := json.Marshal(data)
  39705. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  39706. resp, _ := client.Do(req)
  39707. defer resp.Body.Close()
  39708. body, ioErr := ioutil.ReadAll(resp.Body)
  39709. if ioErr != nil {
  39710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39712. return
  39713. }
  39714. var respJSON map[string]interface{}
  39715. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39718. return
  39719. }
  39720. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39721. userJSONBytes, _ := json.Marshal(respJSON)
  39722. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39723. utils.ErrorLog("解析失败:%v", err)
  39724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39725. return
  39726. }
  39727. if res.Infcode == 0 {
  39728. c.ServeSuccessJSON(map[string]interface{}{
  39729. "msg": "发起成功",
  39730. })
  39731. } else {
  39732. c.ServeSuccessJSON(map[string]interface{}{
  39733. "failed_code": -10,
  39734. "msg": res.ErrMsg,
  39735. })
  39736. }
  39737. }
  39738. }
  39739. func (c *HisApiController) Post8404() {
  39740. admin_user_id, _ := c.GetInt64("admin_user_id")
  39741. month := c.GetString("month")
  39742. adminUser := c.GetAdminUserInfo()
  39743. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39744. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39745. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39746. var res ResultSix
  39747. if config.IsOpen == 1 {
  39748. data := make(map[string]interface{})
  39749. data["month"] = month
  39750. data["org_name"] = miConfig.OrgName
  39751. data["doctor"] = role.UserName
  39752. data["fixmedins_code"] = miConfig.Code
  39753. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39754. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39755. client := &http.Client{}
  39756. bytesData, _ := json.Marshal(data)
  39757. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  39758. resp, _ := client.Do(req)
  39759. defer resp.Body.Close()
  39760. body, ioErr := ioutil.ReadAll(resp.Body)
  39761. if ioErr != nil {
  39762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39764. return
  39765. }
  39766. var respJSON map[string]interface{}
  39767. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39770. return
  39771. }
  39772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39773. userJSONBytes, _ := json.Marshal(respJSON)
  39774. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39775. utils.ErrorLog("解析失败:%v", err)
  39776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39777. return
  39778. }
  39779. if res.Infcode == 0 {
  39780. c.ServeSuccessJSON(map[string]interface{}{
  39781. "msg": "查询成功",
  39782. })
  39783. } else {
  39784. c.ServeSuccessJSON(map[string]interface{}{
  39785. "failed_code": -10,
  39786. "msg": res.ErrMsg,
  39787. })
  39788. }
  39789. }
  39790. }
  39791. func (c *HisApiController) Post3202b() {
  39792. start_time := c.GetString("start_time")
  39793. end_time := c.GetString("end_time")
  39794. //insutype := c.GetString("insutype")
  39795. clr_type := c.GetString("clr_type")
  39796. clr_org := c.GetString("clr_optins")
  39797. admin_user_id, _ := c.GetInt64("admin_user_id")
  39798. adminUser := c.GetAdminUserInfo()
  39799. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39800. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39801. if len(clr_org) == 0 {
  39802. clr_org = miConfig.MdtrtareaAdmvs
  39803. }
  39804. timeLayout := "2006-01-02"
  39805. loc, _ := time.LoadLocation("Local")
  39806. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39807. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39808. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39809. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39810. //fixmedins_setl_cnt := int64(len(orders))
  39811. var medfee_sumamt float64
  39812. var acct_pay float64
  39813. var fund_pay_sumamt float64
  39814. for _, item := range orders {
  39815. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39816. acct_pay = acct_pay + item.AcctPay
  39817. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39818. }
  39819. //var medfee_sumamt_two float64
  39820. //var acct_pay_two float64
  39821. //var fund_pay_sumamt_two float64
  39822. //for _, item := range orders_two {
  39823. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39824. // acct_pay_two = acct_pay_two + item.AcctPay
  39825. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39826. //}
  39827. //var user_name string
  39828. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39829. //if role.ID == 0 {
  39830. // user_name = "xxx"
  39831. //} else {
  39832. // user_name = role.UserName
  39833. //}
  39834. var res ResultSix
  39835. if config.IsOpen == 1 {
  39836. var bps []*models.BusinessParamsTwo
  39837. var bp models.BusinessParamsTwo
  39838. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39839. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39840. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39841. bp.MedfeeSumamt = medfee_sumamt_str
  39842. bp.AcctPay = acct_pay_str
  39843. bp.FundPaySumamt = fund_pay_sumamt_str
  39844. bp.Insutype = "390"
  39845. bp.StmtBegndate = start_time
  39846. bp.ClrType = clr_type
  39847. bp.SetlOptins = clr_org
  39848. bp.StmtEnddate = end_time
  39849. bps = append(bps, &bp)
  39850. data := make(map[string]interface{})
  39851. data["bps"] = bps
  39852. data["org_name"] = miConfig.OrgName
  39853. data["doctor"] = role.UserName
  39854. data["fixmedins_code"] = miConfig.Code
  39855. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39856. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39857. if miConfig.MdtrtareaAdmvs == "421300" {
  39858. client := &http.Client{}
  39859. bytesData, _ := json.Marshal(data)
  39860. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  39861. resp, _ := client.Do(req)
  39862. defer resp.Body.Close()
  39863. body, ioErr := ioutil.ReadAll(resp.Body)
  39864. if ioErr != nil {
  39865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39867. return
  39868. }
  39869. var respJSON map[string]interface{}
  39870. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39873. return
  39874. }
  39875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39876. userJSONBytes, _ := json.Marshal(respJSON)
  39877. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39878. utils.ErrorLog("解析失败:%v", err)
  39879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39880. return
  39881. }
  39882. }
  39883. if miConfig.MdtrtareaAdmvs == "420200" {
  39884. client := &http.Client{}
  39885. bytesData, _ := json.Marshal(data)
  39886. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  39887. resp, _ := client.Do(req)
  39888. defer resp.Body.Close()
  39889. body, ioErr := ioutil.ReadAll(resp.Body)
  39890. if ioErr != nil {
  39891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39893. return
  39894. }
  39895. var respJSON map[string]interface{}
  39896. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39899. return
  39900. }
  39901. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39902. userJSONBytes, _ := json.Marshal(respJSON)
  39903. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39904. utils.ErrorLog("解析失败:%v", err)
  39905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39906. return
  39907. }
  39908. }
  39909. if miConfig.MdtrtareaAdmvs == "421182" {
  39910. client := &http.Client{}
  39911. bytesData, _ := json.Marshal(data)
  39912. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  39913. resp, _ := client.Do(req)
  39914. defer resp.Body.Close()
  39915. body, ioErr := ioutil.ReadAll(resp.Body)
  39916. if ioErr != nil {
  39917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39919. return
  39920. }
  39921. var respJSON map[string]interface{}
  39922. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39925. return
  39926. }
  39927. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39928. userJSONBytes, _ := json.Marshal(respJSON)
  39929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39930. utils.ErrorLog("解析失败:%v", err)
  39931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39932. return
  39933. }
  39934. }
  39935. if res.Infcode == 0 {
  39936. c.ServeSuccessJSON(map[string]interface{}{
  39937. "msg": "发起成功",
  39938. })
  39939. } else {
  39940. c.ServeSuccessJSON(map[string]interface{}{
  39941. "failed_code": -10,
  39942. "msg": res.ErrMsg,
  39943. })
  39944. }
  39945. }
  39946. }
  39947. func (c *HisApiController) Post1608() {
  39948. start_time := c.GetString("start_time")
  39949. end_time := c.GetString("end_time")
  39950. admin_user_id, _ := c.GetInt64("admin_user_id")
  39951. adminUser := c.GetAdminUserInfo()
  39952. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39953. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39954. timeLayout := "2006-01-02"
  39955. loc, _ := time.LoadLocation("Local")
  39956. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39957. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39958. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39959. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39960. fixmedins_setl_cnt := int64(len(orders))
  39961. var medfee_sumamt float64
  39962. var func_smamt float64
  39963. for _, item := range orders {
  39964. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39965. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  39966. }
  39967. times := strings.Split(start_time, "-")
  39968. time_tows := strings.Split(end_time, "-")
  39969. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39970. var res ResultSix
  39971. if config.IsOpen == 1 {
  39972. //var bps []*models.BusinessParamsTwo
  39973. //var bp models.BusinessParamsTwo
  39974. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39975. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  39976. data := make(map[string]interface{})
  39977. data["org_name"] = miConfig.OrgName
  39978. data["doctor"] = role.UserName
  39979. data["func_smamt"] = func_smamt_str
  39980. data["fixmedins_code"] = miConfig.Code
  39981. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39982. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39983. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  39984. data["medfee_sumamt"] = medfee_sumamt_str
  39985. data["start_time"] = times[0] + times[1] + times[2]
  39986. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  39987. if miConfig.MdtrtareaAdmvs == "421300" {
  39988. client := &http.Client{}
  39989. bytesData, _ := json.Marshal(data)
  39990. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  39991. resp, _ := client.Do(req)
  39992. defer resp.Body.Close()
  39993. body, ioErr := ioutil.ReadAll(resp.Body)
  39994. if ioErr != nil {
  39995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39997. return
  39998. }
  39999. var respJSON map[string]interface{}
  40000. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40003. return
  40004. }
  40005. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40006. userJSONBytes, _ := json.Marshal(respJSON)
  40007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40008. utils.ErrorLog("解析失败:%v", err)
  40009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40010. return
  40011. }
  40012. }
  40013. if miConfig.MdtrtareaAdmvs == "420200" {
  40014. client := &http.Client{}
  40015. bytesData, _ := json.Marshal(data)
  40016. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40017. resp, _ := client.Do(req)
  40018. defer resp.Body.Close()
  40019. body, ioErr := ioutil.ReadAll(resp.Body)
  40020. if ioErr != nil {
  40021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40023. return
  40024. }
  40025. var respJSON map[string]interface{}
  40026. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40029. return
  40030. }
  40031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40032. userJSONBytes, _ := json.Marshal(respJSON)
  40033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40034. utils.ErrorLog("解析失败:%v", err)
  40035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40036. return
  40037. }
  40038. }
  40039. if miConfig.MdtrtareaAdmvs == "421182" {
  40040. client := &http.Client{}
  40041. bytesData, _ := json.Marshal(data)
  40042. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  40043. resp, _ := client.Do(req)
  40044. defer resp.Body.Close()
  40045. body, ioErr := ioutil.ReadAll(resp.Body)
  40046. if ioErr != nil {
  40047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40049. return
  40050. }
  40051. var respJSON map[string]interface{}
  40052. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40055. return
  40056. }
  40057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40058. userJSONBytes, _ := json.Marshal(respJSON)
  40059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40060. utils.ErrorLog("解析失败:%v", err)
  40061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40062. return
  40063. }
  40064. }
  40065. if res.Infcode == 0 {
  40066. c.ServeSuccessJSON(map[string]interface{}{
  40067. "msg": "发起成功",
  40068. })
  40069. } else {
  40070. c.ServeSuccessJSON(map[string]interface{}{
  40071. "failed_code": -10,
  40072. "msg": res.ErrMsg,
  40073. })
  40074. }
  40075. }
  40076. }
  40077. // 5.11.1.1【5262】结算信息按时间段查询
  40078. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40079. admin_user_id, _ := c.GetInt64("admin_user_id")
  40080. adminUser := c.GetAdminUserInfo()
  40081. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40082. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40083. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40084. var res Result5262
  40085. if config.IsOpen == 1 {
  40086. if miConfig.MdtrtareaAdmvs == "421300" {
  40087. data := make(map[string]interface{})
  40088. data["bps"] = bp
  40089. data["org_name"] = miConfig.OrgName
  40090. data["doctor"] = role.UserName
  40091. data["fixmedins_code"] = miConfig.Code
  40092. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40093. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40094. data["page"] = strconv.FormatInt(page, 10)
  40095. data["limit"] = strconv.FormatInt(limit, 10)
  40096. fmt.Println(data)
  40097. client := &http.Client{}
  40098. bytesData, _ := json.Marshal(data)
  40099. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40100. resp, _ := client.Do(req)
  40101. defer resp.Body.Close()
  40102. body, ioErr := ioutil.ReadAll(resp.Body)
  40103. if ioErr != nil {
  40104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40106. return
  40107. }
  40108. var respJSON map[string]interface{}
  40109. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40112. return
  40113. }
  40114. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40115. userJSONBytes, _ := json.Marshal(respJSON)
  40116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40117. utils.ErrorLog("解析失败:%v", err)
  40118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40119. return
  40120. }
  40121. }
  40122. if miConfig.MdtrtareaAdmvs == "420200" {
  40123. data := make(map[string]interface{})
  40124. data["bps"] = bp
  40125. data["org_name"] = miConfig.OrgName
  40126. data["doctor"] = role.UserName
  40127. data["fixmedins_code"] = miConfig.Code
  40128. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40129. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40130. data["page"] = strconv.FormatInt(page, 10)
  40131. data["limit"] = strconv.FormatInt(limit, 10)
  40132. fmt.Println(data)
  40133. client := &http.Client{}
  40134. bytesData, _ := json.Marshal(data)
  40135. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40136. resp, _ := client.Do(req)
  40137. defer resp.Body.Close()
  40138. body, ioErr := ioutil.ReadAll(resp.Body)
  40139. if ioErr != nil {
  40140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40142. return
  40143. }
  40144. var respJSON map[string]interface{}
  40145. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40148. return
  40149. }
  40150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40151. userJSONBytes, _ := json.Marshal(respJSON)
  40152. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40153. utils.ErrorLog("解析失败:%v", err)
  40154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40155. return
  40156. }
  40157. }
  40158. if miConfig.MdtrtareaAdmvs == "421182" {
  40159. data := make(map[string]interface{})
  40160. data["bps"] = bp
  40161. data["org_name"] = miConfig.OrgName
  40162. data["doctor"] = role.UserName
  40163. data["fixmedins_code"] = miConfig.Code
  40164. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40165. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40166. data["page"] = strconv.FormatInt(page, 10)
  40167. data["limit"] = strconv.FormatInt(limit, 10)
  40168. fmt.Println(data)
  40169. client := &http.Client{}
  40170. bytesData, _ := json.Marshal(data)
  40171. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40172. resp, _ := client.Do(req)
  40173. defer resp.Body.Close()
  40174. body, ioErr := ioutil.ReadAll(resp.Body)
  40175. if ioErr != nil {
  40176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40178. return
  40179. }
  40180. var respJSON map[string]interface{}
  40181. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40184. return
  40185. }
  40186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40187. userJSONBytes, _ := json.Marshal(respJSON)
  40188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40189. utils.ErrorLog("解析失败:%v", err)
  40190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40191. return
  40192. }
  40193. }
  40194. if miConfig.MdtrtareaAdmvs == "420902" {
  40195. data := make(map[string]interface{})
  40196. data["bps"] = bp
  40197. data["org_name"] = miConfig.OrgName
  40198. data["doctor"] = role.UserName
  40199. data["fixmedins_code"] = miConfig.Code
  40200. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40201. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40202. data["page"] = strconv.FormatInt(page, 10)
  40203. data["limit"] = strconv.FormatInt(limit, 10)
  40204. fmt.Println(data)
  40205. client := &http.Client{}
  40206. bytesData, _ := json.Marshal(data)
  40207. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40208. resp, _ := client.Do(req)
  40209. defer resp.Body.Close()
  40210. body, ioErr := ioutil.ReadAll(resp.Body)
  40211. if ioErr != nil {
  40212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40214. return
  40215. }
  40216. var respJSON map[string]interface{}
  40217. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40220. return
  40221. }
  40222. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40223. userJSONBytes, _ := json.Marshal(respJSON)
  40224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40225. utils.ErrorLog("解析失败:%v", err)
  40226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40227. return
  40228. }
  40229. }
  40230. if res.Infcode == 0 {
  40231. c.ServeSuccessJSON(map[string]interface{}{
  40232. "order": res.Output.Result,
  40233. "total": res.Output.PageInfo.RecordCounts,
  40234. })
  40235. } else {
  40236. c.ServeSuccessJSON(map[string]interface{}{
  40237. "failed_code": -10,
  40238. "msg": res.ErrMsg,
  40239. })
  40240. }
  40241. }
  40242. }
  40243. // 5.11.1.2【5267】异地结算信息时间段查询
  40244. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40245. admin_user_id, _ := c.GetInt64("admin_user_id")
  40246. adminUser := c.GetAdminUserInfo()
  40247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40248. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40249. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40250. var res Result5267
  40251. if config.IsOpen == 1 {
  40252. if miConfig.MdtrtareaAdmvs == "421300" {
  40253. data := make(map[string]interface{})
  40254. data["bps"] = bp
  40255. data["org_name"] = miConfig.OrgName
  40256. data["doctor"] = role.UserName
  40257. data["fixmedins_code"] = miConfig.Code
  40258. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40259. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40260. data["page"] = page
  40261. data["limit"] = limit
  40262. fmt.Println(data)
  40263. client := &http.Client{}
  40264. bytesData, _ := json.Marshal(data)
  40265. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40266. resp, _ := client.Do(req)
  40267. defer resp.Body.Close()
  40268. body, ioErr := ioutil.ReadAll(resp.Body)
  40269. if ioErr != nil {
  40270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40272. return
  40273. }
  40274. var respJSON map[string]interface{}
  40275. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40278. return
  40279. }
  40280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40281. userJSONBytes, _ := json.Marshal(respJSON)
  40282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40283. utils.ErrorLog("解析失败:%v", err)
  40284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40285. return
  40286. }
  40287. }
  40288. if miConfig.MdtrtareaAdmvs == "420200" {
  40289. data := make(map[string]interface{})
  40290. data["bps"] = bp
  40291. data["org_name"] = miConfig.OrgName
  40292. data["doctor"] = role.UserName
  40293. data["fixmedins_code"] = miConfig.Code
  40294. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40295. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40296. data["page"] = page
  40297. data["limit"] = limit
  40298. fmt.Println(data)
  40299. client := &http.Client{}
  40300. bytesData, _ := json.Marshal(data)
  40301. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40302. resp, _ := client.Do(req)
  40303. defer resp.Body.Close()
  40304. body, ioErr := ioutil.ReadAll(resp.Body)
  40305. if ioErr != nil {
  40306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40308. return
  40309. }
  40310. var respJSON map[string]interface{}
  40311. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40314. return
  40315. }
  40316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40317. userJSONBytes, _ := json.Marshal(respJSON)
  40318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40319. utils.ErrorLog("解析失败:%v", err)
  40320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40321. return
  40322. }
  40323. }
  40324. if miConfig.MdtrtareaAdmvs == "421182" {
  40325. data := make(map[string]interface{})
  40326. data["bps"] = bp
  40327. data["org_name"] = miConfig.OrgName
  40328. data["doctor"] = role.UserName
  40329. data["fixmedins_code"] = miConfig.Code
  40330. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40331. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40332. data["page"] = page
  40333. data["limit"] = limit
  40334. fmt.Println(data)
  40335. client := &http.Client{}
  40336. bytesData, _ := json.Marshal(data)
  40337. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  40338. resp, _ := client.Do(req)
  40339. defer resp.Body.Close()
  40340. body, ioErr := ioutil.ReadAll(resp.Body)
  40341. if ioErr != nil {
  40342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40344. return
  40345. }
  40346. var respJSON map[string]interface{}
  40347. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40350. return
  40351. }
  40352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40353. userJSONBytes, _ := json.Marshal(respJSON)
  40354. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40355. utils.ErrorLog("解析失败:%v", err)
  40356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40357. return
  40358. }
  40359. }
  40360. if res.Infcode == 0 {
  40361. c.ServeSuccessJSON(map[string]interface{}{
  40362. "order": res.Output.Result,
  40363. "total": res.Output.PageInfo.RecordCounts,
  40364. })
  40365. } else {
  40366. c.ServeSuccessJSON(map[string]interface{}{
  40367. "failed_code": -10,
  40368. "msg": res.ErrMsg,
  40369. })
  40370. }
  40371. }
  40372. }
  40373. func (c *HisApiController) Post3501() {
  40374. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40375. data := make(map[string]interface{})
  40376. var struct3501s []models.Struct3501
  40377. var struct3501 models.Struct3501
  40378. struct3501.OrgName = miConfig.OrgName
  40379. struct3501.AccessKey = miConfig.AccessKey
  40380. struct3501.RequestUrl = miConfig.Url
  40381. struct3501.SecretKey = miConfig.SecretKey
  40382. struct3501.ManuDate = "2022-08-17"
  40383. struct3501.FixmedinsBchno = ""
  40384. struct3501.ManuLotnum = ""
  40385. struct3501.RxFlag = "0"
  40386. struct3501.ExpyEnd = "2022-08-17"
  40387. struct3501.Invdate = "2022-08-17"
  40388. struct3501.InvCnt = "20.25"
  40389. struct3501.Memo = ""
  40390. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40391. struct3501.FixmedinsHilistId = miConfig.Code
  40392. struct3501.FixmedinsHilistName = miConfig.OrgName
  40393. struct3501s = append(struct3501s, struct3501)
  40394. data["struct_3501s"] = struct3501s
  40395. client := &http.Client{}
  40396. bytesData, _ := json.Marshal(data)
  40397. var req *http.Request
  40398. if miConfig.MdtrtareaAdmvs == "320921" {
  40399. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40400. } else {
  40401. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40402. }
  40403. resp, _ := client.Do(req)
  40404. defer resp.Body.Close()
  40405. body, ioErr := ioutil.ReadAll(resp.Body)
  40406. if ioErr != nil {
  40407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40409. return
  40410. }
  40411. var respJSON map[string]interface{}
  40412. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40415. return
  40416. }
  40417. var res ResultSix
  40418. var resSix10265 ResultSix10265 //1101结果
  40419. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40420. result, _ := json.Marshal(respJSON)
  40421. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40422. utils.ErrorLog("解析失败:%v", err)
  40423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40424. return
  40425. }
  40426. res.InfRefmsgid = resSix10265.InfRefmsgid
  40427. res.Output = resSix10265.Output
  40428. res.ErrMsg = resSix10265.ErrMsg
  40429. res.Cainfo = resSix10265.Cainfo
  40430. res.WarnMsg = resSix10265.WarnMsg
  40431. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40432. res.Infcode = infocode
  40433. if infocode == 0 {
  40434. c.ServeSuccessJSON(map[string]interface{}{
  40435. "msg": "上传成功",
  40436. })
  40437. return
  40438. } else {
  40439. c.ServeSuccessJSON(map[string]interface{}{
  40440. "failed_code": -10,
  40441. "msg": res.ErrMsg,
  40442. })
  40443. return
  40444. }
  40445. }
  40446. func (c *HisApiController) Post3502() {
  40447. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40448. data := make(map[string]interface{})
  40449. var struct3502s []models.Struct3502
  40450. var struct3502 models.Struct3502
  40451. struct3502.OrgName = miConfig.OrgName
  40452. struct3502.AccessKey = miConfig.AccessKey
  40453. struct3502.RequestUrl = miConfig.Url
  40454. struct3502.SecretKey = miConfig.SecretKey
  40455. struct3502.ManuDate = "2022-08-15"
  40456. struct3502.FixmedinsBchno = ""
  40457. struct3502.ManuLotnum = ""
  40458. struct3502.RxFlag = "0"
  40459. struct3502.ExpyEnd = "2022-08-15"
  40460. struct3502.Invdate = "2022-08-15"
  40461. struct3502.InvCnt = "20.25"
  40462. struct3502.Memo = ""
  40463. struct3502.MedListCodg = "XB01ABD056B002020200517"
  40464. struct3502.FixmedinsHilistId = miConfig.Code
  40465. struct3502.FixmedinsHilistName = miConfig.OrgName
  40466. struct3502s = append(struct3502s, struct3502)
  40467. data["struct_3502s"] = struct3502s
  40468. client := &http.Client{}
  40469. bytesData, _ := json.Marshal(data)
  40470. var req *http.Request
  40471. if miConfig.MdtrtareaAdmvs == "320921" {
  40472. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40473. } else {
  40474. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40475. }
  40476. resp, _ := client.Do(req)
  40477. defer resp.Body.Close()
  40478. body, ioErr := ioutil.ReadAll(resp.Body)
  40479. if ioErr != nil {
  40480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40482. return
  40483. }
  40484. var respJSON map[string]interface{}
  40485. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40488. return
  40489. }
  40490. var res ResultSix
  40491. var resSix10265 ResultSix10265 //1101结果
  40492. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40493. result, _ := json.Marshal(respJSON)
  40494. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40495. utils.ErrorLog("解析失败:%v", err)
  40496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40497. return
  40498. }
  40499. res.InfRefmsgid = resSix10265.InfRefmsgid
  40500. res.Output = resSix10265.Output
  40501. res.ErrMsg = resSix10265.ErrMsg
  40502. res.Cainfo = resSix10265.Cainfo
  40503. res.WarnMsg = resSix10265.WarnMsg
  40504. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40505. res.Infcode = infocode
  40506. if infocode == 0 {
  40507. c.ServeSuccessJSON(map[string]interface{}{
  40508. "msg": "上传成功",
  40509. })
  40510. return
  40511. } else {
  40512. c.ServeSuccessJSON(map[string]interface{}{
  40513. "failed_code": -10,
  40514. "msg": res.ErrMsg,
  40515. })
  40516. return
  40517. }
  40518. }
  40519. func (c *HisApiController) Post3503() {
  40520. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40521. data := make(map[string]interface{})
  40522. var struct3501s []models.Struct3501
  40523. var struct3501 models.Struct3501
  40524. struct3501.OrgName = miConfig.OrgName
  40525. struct3501.AccessKey = miConfig.AccessKey
  40526. struct3501.RequestUrl = miConfig.Url
  40527. struct3501.SecretKey = miConfig.SecretKey
  40528. struct3501.ManuDate = "2022-08-15"
  40529. struct3501.FixmedinsBchno = ""
  40530. struct3501.ManuLotnum = ""
  40531. struct3501.RxFlag = "0"
  40532. struct3501.ExpyEnd = "2022-08-15"
  40533. struct3501.Invdate = "2022-08-15"
  40534. struct3501.InvCnt = "20.25"
  40535. struct3501.Memo = ""
  40536. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40537. struct3501.FixmedinsHilistId = miConfig.Code
  40538. struct3501.FixmedinsHilistName = miConfig.OrgName
  40539. struct3501s = append(struct3501s, struct3501)
  40540. data["struct_3501s"] = struct3501s
  40541. client := &http.Client{}
  40542. bytesData, _ := json.Marshal(data)
  40543. var req *http.Request
  40544. if miConfig.MdtrtareaAdmvs == "320921" {
  40545. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40546. } else {
  40547. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40548. }
  40549. resp, _ := client.Do(req)
  40550. defer resp.Body.Close()
  40551. body, ioErr := ioutil.ReadAll(resp.Body)
  40552. if ioErr != nil {
  40553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40555. return
  40556. }
  40557. var respJSON map[string]interface{}
  40558. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40561. return
  40562. }
  40563. var res ResultSix
  40564. var resSix10265 ResultSix10265 //1101结果
  40565. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40566. result, _ := json.Marshal(respJSON)
  40567. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40568. utils.ErrorLog("解析失败:%v", err)
  40569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40570. return
  40571. }
  40572. res.InfRefmsgid = resSix10265.InfRefmsgid
  40573. res.Output = resSix10265.Output
  40574. res.ErrMsg = resSix10265.ErrMsg
  40575. res.Cainfo = resSix10265.Cainfo
  40576. res.WarnMsg = resSix10265.WarnMsg
  40577. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40578. res.Infcode = infocode
  40579. if infocode == 0 {
  40580. c.ServeSuccessJSON(map[string]interface{}{
  40581. "msg": "上传成功",
  40582. })
  40583. return
  40584. } else {
  40585. c.ServeSuccessJSON(map[string]interface{}{
  40586. "failed_code": -10,
  40587. "msg": res.ErrMsg,
  40588. })
  40589. return
  40590. }
  40591. }
  40592. func (c *HisApiController) Post3504() {
  40593. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40594. data := make(map[string]interface{})
  40595. var struct3501s []models.Struct3501
  40596. var struct3501 models.Struct3501
  40597. struct3501.OrgName = miConfig.OrgName
  40598. struct3501.AccessKey = miConfig.AccessKey
  40599. struct3501.RequestUrl = miConfig.Url
  40600. struct3501.SecretKey = miConfig.SecretKey
  40601. struct3501.ManuDate = "2022-08-15"
  40602. struct3501.FixmedinsBchno = ""
  40603. struct3501.ManuLotnum = ""
  40604. struct3501.RxFlag = "0"
  40605. struct3501.ExpyEnd = "2022-08-15"
  40606. struct3501.Invdate = "2022-08-15"
  40607. struct3501.InvCnt = "20.25"
  40608. struct3501.Memo = ""
  40609. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40610. struct3501.FixmedinsHilistId = miConfig.Code
  40611. struct3501.FixmedinsHilistName = miConfig.OrgName
  40612. struct3501s = append(struct3501s, struct3501)
  40613. data["struct_3501s"] = struct3501s
  40614. client := &http.Client{}
  40615. bytesData, _ := json.Marshal(data)
  40616. var req *http.Request
  40617. if miConfig.MdtrtareaAdmvs == "320921" {
  40618. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40619. } else {
  40620. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40621. }
  40622. resp, _ := client.Do(req)
  40623. defer resp.Body.Close()
  40624. body, ioErr := ioutil.ReadAll(resp.Body)
  40625. if ioErr != nil {
  40626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40628. return
  40629. }
  40630. var respJSON map[string]interface{}
  40631. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40634. return
  40635. }
  40636. var res ResultSix
  40637. var resSix10265 ResultSix10265 //1101结果
  40638. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40639. result, _ := json.Marshal(respJSON)
  40640. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40641. utils.ErrorLog("解析失败:%v", err)
  40642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40643. return
  40644. }
  40645. res.InfRefmsgid = resSix10265.InfRefmsgid
  40646. res.Output = resSix10265.Output
  40647. res.ErrMsg = resSix10265.ErrMsg
  40648. res.Cainfo = resSix10265.Cainfo
  40649. res.WarnMsg = resSix10265.WarnMsg
  40650. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40651. res.Infcode = infocode
  40652. if infocode == 0 {
  40653. c.ServeSuccessJSON(map[string]interface{}{
  40654. "msg": "上传成功",
  40655. })
  40656. return
  40657. } else {
  40658. c.ServeSuccessJSON(map[string]interface{}{
  40659. "failed_code": -10,
  40660. "msg": res.ErrMsg,
  40661. })
  40662. return
  40663. }
  40664. }
  40665. func (c *HisApiController) Post3505() {
  40666. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40667. data := make(map[string]interface{})
  40668. var struct3501s []models.Struct3501
  40669. var struct3501 models.Struct3501
  40670. struct3501.OrgName = miConfig.OrgName
  40671. struct3501.AccessKey = miConfig.AccessKey
  40672. struct3501.RequestUrl = miConfig.Url
  40673. struct3501.SecretKey = miConfig.SecretKey
  40674. struct3501.ManuDate = "2022-08-15"
  40675. struct3501.FixmedinsBchno = ""
  40676. struct3501.ManuLotnum = ""
  40677. struct3501.RxFlag = "0"
  40678. struct3501.ExpyEnd = "2022-08-15"
  40679. struct3501.Invdate = "2022-08-15"
  40680. struct3501.InvCnt = "20.25"
  40681. struct3501.Memo = ""
  40682. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40683. struct3501.FixmedinsHilistId = miConfig.Code
  40684. struct3501.FixmedinsHilistName = miConfig.OrgName
  40685. struct3501s = append(struct3501s, struct3501)
  40686. data["struct_3501s"] = struct3501s
  40687. client := &http.Client{}
  40688. bytesData, _ := json.Marshal(data)
  40689. var req *http.Request
  40690. if miConfig.MdtrtareaAdmvs == "320921" {
  40691. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40692. } else {
  40693. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40694. }
  40695. resp, _ := client.Do(req)
  40696. defer resp.Body.Close()
  40697. body, ioErr := ioutil.ReadAll(resp.Body)
  40698. if ioErr != nil {
  40699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40701. return
  40702. }
  40703. var respJSON map[string]interface{}
  40704. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40707. return
  40708. }
  40709. var res ResultSix
  40710. var resSix10265 ResultSix10265 //1101结果
  40711. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40712. result, _ := json.Marshal(respJSON)
  40713. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40714. utils.ErrorLog("解析失败:%v", err)
  40715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40716. return
  40717. }
  40718. res.InfRefmsgid = resSix10265.InfRefmsgid
  40719. res.Output = resSix10265.Output
  40720. res.ErrMsg = resSix10265.ErrMsg
  40721. res.Cainfo = resSix10265.Cainfo
  40722. res.WarnMsg = resSix10265.WarnMsg
  40723. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40724. res.Infcode = infocode
  40725. if infocode == 0 {
  40726. c.ServeSuccessJSON(map[string]interface{}{
  40727. "msg": "上传成功",
  40728. })
  40729. return
  40730. } else {
  40731. c.ServeSuccessJSON(map[string]interface{}{
  40732. "failed_code": -10,
  40733. "msg": res.ErrMsg,
  40734. })
  40735. return
  40736. }
  40737. }
  40738. func (c *HisApiController) Post3506() {
  40739. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40740. data := make(map[string]interface{})
  40741. var struct3501s []models.Struct3501
  40742. var struct3501 models.Struct3501
  40743. struct3501.OrgName = miConfig.OrgName
  40744. struct3501.AccessKey = miConfig.AccessKey
  40745. struct3501.RequestUrl = miConfig.Url
  40746. struct3501.SecretKey = miConfig.SecretKey
  40747. struct3501.ManuDate = "2022-08-15"
  40748. struct3501.FixmedinsBchno = ""
  40749. struct3501.ManuLotnum = ""
  40750. struct3501.RxFlag = "0"
  40751. struct3501.ExpyEnd = "2022-08-15"
  40752. struct3501.Invdate = "2022-08-15"
  40753. struct3501.InvCnt = "20.25"
  40754. struct3501.Memo = ""
  40755. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40756. struct3501.FixmedinsHilistId = miConfig.Code
  40757. struct3501.FixmedinsHilistName = miConfig.OrgName
  40758. struct3501s = append(struct3501s, struct3501)
  40759. data["struct_3501s"] = struct3501s
  40760. client := &http.Client{}
  40761. bytesData, _ := json.Marshal(data)
  40762. var req *http.Request
  40763. if miConfig.MdtrtareaAdmvs == "320921" {
  40764. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40765. } else {
  40766. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40767. }
  40768. resp, _ := client.Do(req)
  40769. defer resp.Body.Close()
  40770. body, ioErr := ioutil.ReadAll(resp.Body)
  40771. if ioErr != nil {
  40772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40774. return
  40775. }
  40776. var respJSON map[string]interface{}
  40777. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40780. return
  40781. }
  40782. var res ResultSix
  40783. var resSix10265 ResultSix10265 //1101结果
  40784. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40785. result, _ := json.Marshal(respJSON)
  40786. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40787. utils.ErrorLog("解析失败:%v", err)
  40788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40789. return
  40790. }
  40791. res.InfRefmsgid = resSix10265.InfRefmsgid
  40792. res.Output = resSix10265.Output
  40793. res.ErrMsg = resSix10265.ErrMsg
  40794. res.Cainfo = resSix10265.Cainfo
  40795. res.WarnMsg = resSix10265.WarnMsg
  40796. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40797. res.Infcode = infocode
  40798. if infocode == 0 {
  40799. c.ServeSuccessJSON(map[string]interface{}{
  40800. "msg": "上传成功",
  40801. })
  40802. return
  40803. } else {
  40804. c.ServeSuccessJSON(map[string]interface{}{
  40805. "failed_code": -10,
  40806. "msg": res.ErrMsg,
  40807. })
  40808. return
  40809. }
  40810. }
  40811. func (c *HisApiController) Post3507() {
  40812. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40813. data := make(map[string]interface{})
  40814. var struct3501s []models.Struct3501
  40815. var struct3501 models.Struct3501
  40816. struct3501.OrgName = miConfig.OrgName
  40817. struct3501.AccessKey = miConfig.AccessKey
  40818. struct3501.RequestUrl = miConfig.Url
  40819. struct3501.SecretKey = miConfig.SecretKey
  40820. struct3501.ManuDate = "2022-08-15"
  40821. struct3501.FixmedinsBchno = ""
  40822. struct3501.ManuLotnum = ""
  40823. struct3501.RxFlag = "0"
  40824. struct3501.ExpyEnd = "2022-08-15"
  40825. struct3501.Invdate = "2022-08-15"
  40826. struct3501.InvCnt = "20.25"
  40827. struct3501.Memo = ""
  40828. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40829. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  40830. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  40831. struct3501s = append(struct3501s, struct3501)
  40832. data["struct_3501s"] = struct3501s
  40833. client := &http.Client{}
  40834. bytesData, _ := json.Marshal(data)
  40835. var req *http.Request
  40836. if miConfig.MdtrtareaAdmvs == "320921" {
  40837. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40838. } else {
  40839. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40840. }
  40841. resp, _ := client.Do(req)
  40842. defer resp.Body.Close()
  40843. body, ioErr := ioutil.ReadAll(resp.Body)
  40844. if ioErr != nil {
  40845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40847. return
  40848. }
  40849. var respJSON map[string]interface{}
  40850. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40853. return
  40854. }
  40855. var res ResultSix
  40856. var resSix10265 ResultSix10265 //1101结果
  40857. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40858. result, _ := json.Marshal(respJSON)
  40859. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40860. utils.ErrorLog("解析失败:%v", err)
  40861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40862. return
  40863. }
  40864. res.InfRefmsgid = resSix10265.InfRefmsgid
  40865. res.Output = resSix10265.Output
  40866. res.ErrMsg = resSix10265.ErrMsg
  40867. res.Cainfo = resSix10265.Cainfo
  40868. res.WarnMsg = resSix10265.WarnMsg
  40869. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40870. res.Infcode = infocode
  40871. if infocode == 0 {
  40872. c.ServeSuccessJSON(map[string]interface{}{
  40873. "msg": "上传成功",
  40874. })
  40875. return
  40876. } else {
  40877. c.ServeSuccessJSON(map[string]interface{}{
  40878. "failed_code": -10,
  40879. "msg": res.ErrMsg,
  40880. })
  40881. return
  40882. }
  40883. }
  40884. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  40885. // WebSocket服务器地址
  40886. serverURL := "ws://127.0.0.1:8899"
  40887. // 解析WebSocket服务器地址
  40888. u, err := url.Parse(serverURL)
  40889. if err != nil {
  40890. }
  40891. // 建立WebSocket连接
  40892. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40893. if err != nil {
  40894. }
  40895. defer conn.Close()
  40896. input2 := make(map[string]interface{})
  40897. input := make(map[string]interface{})
  40898. inputData := make(map[string]interface{})
  40899. inputData["orgId"] = code
  40900. inputData["businessType"] = "01101"
  40901. inputData["operatorId"] = operator_id
  40902. inputData["operatorName"] = operator_name
  40903. inputData["officeId"] = "001"
  40904. inputData["officeName"] = "血透室"
  40905. inputData["deviceType"] = ""
  40906. input["data"] = inputData
  40907. input["orgId"] = code
  40908. input["transType"] = "ec.query"
  40909. //if md == ""
  40910. if md[:4] == "4403" {
  40911. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40912. } else if md[:4] == "4401" {
  40913. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40914. } else {
  40915. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  40916. }
  40917. input2["indata"] = input
  40918. fmt.Println(input2)
  40919. bytesData, _ := json.Marshal(input2)
  40920. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40921. if err != nil {
  40922. fmt.Println(err)
  40923. }
  40924. // 接收消息
  40925. _, receivedMessage, err := conn.ReadMessage()
  40926. if err != nil {
  40927. fmt.Println(err)
  40928. }
  40929. return "", string(receivedMessage)
  40930. }
  40931. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  40932. // WebSocket服务器地址
  40933. serverURL := "ws://127.0.0.1:8899"
  40934. // 解析WebSocket服务器地址
  40935. u, err := url.Parse(serverURL)
  40936. if err != nil {
  40937. }
  40938. // 建立WebSocket连接
  40939. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40940. if err != nil {
  40941. }
  40942. defer conn.Close()
  40943. input2 := make(map[string]interface{})
  40944. input := make(map[string]interface{})
  40945. inputData := make(map[string]interface{})
  40946. inputData["orgId"] = code
  40947. inputData["businessType"] = "01101"
  40948. inputData["operatorId"] = operator_id
  40949. inputData["operatorName"] = operator_name
  40950. inputData["officeId"] = "001"
  40951. inputData["officeName"] = "血透室"
  40952. inputData["deviceType"] = ""
  40953. input["data"] = inputData
  40954. input["orgId"] = code
  40955. input["transType"] = "ec.query"
  40956. //if md == ""
  40957. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  40958. input2["indata"] = input
  40959. fmt.Println(input2)
  40960. bytesData, _ := json.Marshal(input2)
  40961. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  40962. if err != nil {
  40963. fmt.Println(err)
  40964. }
  40965. // 接收消息
  40966. _, receivedMessage, err := conn.ReadMessage()
  40967. if err != nil {
  40968. fmt.Println(err)
  40969. }
  40970. return "", string(receivedMessage)
  40971. }
  40972. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  40973. // WebSocket服务器地址
  40974. serverURL := "ws://127.0.0.1:8899"
  40975. // 解析WebSocket服务器地址
  40976. u, err := url.Parse(serverURL)
  40977. if err != nil {
  40978. }
  40979. // 建立WebSocket连接
  40980. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  40981. if err != nil {
  40982. }
  40983. defer conn.Close()
  40984. input2 := make(map[string]interface{})
  40985. input := make(map[string]interface{})
  40986. inputData := make(map[string]interface{})
  40987. inputData["orgId"] = code
  40988. inputData["businessType"] = "01301"
  40989. inputData["operatorId"] = operator_id
  40990. inputData["operatorName"] = operator_name
  40991. inputData["officeId"] = "001"
  40992. inputData["officeName"] = "血透室"
  40993. inputData["deviceType"] = ""
  40994. input["data"] = inputData
  40995. input["orgId"] = code
  40996. input["transType"] = "ec.query"
  40997. //if md == ""
  40998. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  40999. input2["indata"] = input
  41000. fmt.Println(input2)
  41001. bytesData, _ := json.Marshal(input2)
  41002. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41003. if err != nil {
  41004. fmt.Println(err)
  41005. }
  41006. // 接收消息
  41007. _, receivedMessage, err := conn.ReadMessage()
  41008. if err != nil {
  41009. fmt.Println(err)
  41010. }
  41011. return "", string(receivedMessage)
  41012. }
  41013. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  41014. // WebSocket服务器地址
  41015. serverURL := "ws://127.0.0.1:8899"
  41016. // 解析WebSocket服务器地址
  41017. u, err := url.Parse(serverURL)
  41018. if err != nil {
  41019. }
  41020. // 建立WebSocket连接
  41021. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41022. if err != nil {
  41023. }
  41024. defer conn.Close()
  41025. input2 := make(map[string]interface{})
  41026. input := make(map[string]interface{})
  41027. inputData := make(map[string]interface{})
  41028. inputData["orgId"] = code
  41029. inputData["businessType"] = "01103"
  41030. inputData["operatorId"] = operator_id
  41031. inputData["operatorName"] = operator_name
  41032. inputData["officeId"] = "001"
  41033. inputData["officeName"] = "血透室"
  41034. inputData["deviceType"] = ""
  41035. input["data"] = inputData
  41036. input["orgId"] = code
  41037. input["transType"] = "ec.query"
  41038. //if md ==
  41039. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  41040. input2["indata"] = input
  41041. fmt.Println(input2)
  41042. bytesData, _ := json.Marshal(input2)
  41043. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41044. if err != nil {
  41045. fmt.Println(err)
  41046. }
  41047. // 接收消息
  41048. _, receivedMessage, err := conn.ReadMessage()
  41049. if err != nil {
  41050. fmt.Println(err)
  41051. }
  41052. return "", string(receivedMessage)
  41053. }
  41054. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41055. // WebSocket服务器地址
  41056. serverURL := "ws://127.0.0.1:8899"
  41057. // 解析WebSocket服务器地址
  41058. u, err := url.Parse(serverURL)
  41059. if err != nil {
  41060. }
  41061. // 建立WebSocket连接
  41062. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41063. if err != nil {
  41064. }
  41065. defer conn.Close()
  41066. input2 := make(map[string]interface{})
  41067. input := make(map[string]interface{})
  41068. inputData := make(map[string]interface{})
  41069. inputData["orgId"] = code
  41070. inputData["businessType"] = "01101"
  41071. inputData["operatorId"] = operator_id
  41072. inputData["operatorName"] = operator_name
  41073. inputData["officeId"] = "001"
  41074. inputData["officeName"] = "血透室"
  41075. inputData["deviceType"] = ""
  41076. input["data"] = inputData
  41077. input["orgId"] = code
  41078. input["transType"] = "ec.query"
  41079. //if md == ""
  41080. if md[:4] == "4403" {
  41081. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41082. } else if md[:4] == "4401" {
  41083. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41084. } else {
  41085. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41086. }
  41087. input2["indata"] = input
  41088. fmt.Println(input2)
  41089. bytesData, _ := json.Marshal(input2)
  41090. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41091. if err != nil {
  41092. fmt.Println(err)
  41093. }
  41094. // 接收消息
  41095. _, receivedMessage, err := conn.ReadMessage()
  41096. if err != nil {
  41097. fmt.Println(err)
  41098. }
  41099. return "", string(receivedMessage)
  41100. }
  41101. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  41102. // WebSocket服务器地址
  41103. serverURL := "ws://127.0.0.1:8899"
  41104. // 解析WebSocket服务器地址
  41105. u, err := url.Parse(serverURL)
  41106. if err != nil {
  41107. }
  41108. // 建立WebSocket连接
  41109. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41110. if err != nil {
  41111. }
  41112. defer conn.Close()
  41113. input2 := make(map[string]interface{})
  41114. input := make(map[string]interface{})
  41115. inputData := make(map[string]interface{})
  41116. inputData["orgId"] = code
  41117. inputData["businessType"] = "01301"
  41118. inputData["operatorId"] = operator_id
  41119. inputData["operatorName"] = operator_name
  41120. inputData["officeId"] = "001"
  41121. inputData["officeName"] = "血透室"
  41122. inputData["deviceType"] = ""
  41123. input["data"] = inputData
  41124. input["orgId"] = code
  41125. input["transType"] = "ec.query"
  41126. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41127. input2["indata"] = input
  41128. bytesData, _ := json.Marshal(input2)
  41129. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41130. if err != nil {
  41131. fmt.Println(err)
  41132. }
  41133. // 接收消息
  41134. _, receivedMessage, err := conn.ReadMessage()
  41135. if err != nil {
  41136. fmt.Println(err)
  41137. }
  41138. return "", string(receivedMessage)
  41139. }
  41140. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  41141. newArr = make([]string, 0)
  41142. for i := 0; i < len(arr); i++ {
  41143. repeat := false
  41144. for j := i + 1; j < len(arr); j++ {
  41145. if arr[i] == arr[j] {
  41146. repeat = true
  41147. break
  41148. }
  41149. }
  41150. if !repeat {
  41151. newArr = append(newArr, arr[i])
  41152. }
  41153. }
  41154. return
  41155. }
  41156. func getBirthdateAndAge(idNumber string) (string, int, error) {
  41157. if len(idNumber) != 18 {
  41158. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  41159. }
  41160. // 提取出生日期
  41161. year, err := strconv.Atoi(idNumber[6:10])
  41162. if err != nil {
  41163. return "", 0, err
  41164. }
  41165. month, err := strconv.Atoi(idNumber[10:12])
  41166. if err != nil {
  41167. return "", 0, err
  41168. }
  41169. day, err := strconv.Atoi(idNumber[12:14])
  41170. if err != nil {
  41171. return "", 0, err
  41172. }
  41173. // 格式化生日字符串
  41174. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  41175. birthdateFormatted := birthdate.Format("2006-01-02")
  41176. // 计算年龄
  41177. today := time.Now()
  41178. age := today.Year() - birthdate.Year()
  41179. if today.YearDay() < birthdate.YearDay() {
  41180. age--
  41181. }
  41182. return birthdateFormatted, age, nil
  41183. }
  41184. // 从身份证号码中提取出生年月日
  41185. func getBirthDateFromIDCard(idCard string) (string, error) {
  41186. // 身份证号码长度应为18位
  41187. if len(idCard) != 18 {
  41188. return "", fmt.Errorf("身份证号码长度应为18位")
  41189. }
  41190. // 提取出生日期部分 (YYYYMMDD)
  41191. birthDateStr := idCard[6:14]
  41192. // 解析出生日期
  41193. birthDate, err := time.Parse("20060102", birthDateStr)
  41194. if err != nil {
  41195. return "", fmt.Errorf("解析出生日期失败: %v", err)
  41196. }
  41197. // 格式化出生日期为 YYYY-MM-DD
  41198. formattedDate := birthDate.Format("2006-01-02")
  41199. return formattedDate, nil
  41200. }